PR middle-end/87593 - conflicting format_arg attributes on a declaration accepted
[official-gcc.git] / gcc / doc / extend.texi
blob47a987fef6a88e272300876e9b559280c1ef53ec
1 c Copyright (C) 1988-2018 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    Nested function in GNU C.
30 * 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 * Other Builtins::      Other built-in functions.
88 * Target Builtins::     Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas::             Pragmas accepted by GCC.
91 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
92 * Thread-Local::        Per-thread variables.
93 * Binary constants::    Binary constants using the @samp{0b} prefix.
94 @end menu
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@.  This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces.  For
111 example:
113 @smallexample
114 (@{ int y = foo (); int z;
115    if (y > 0) z = y;
116    else z = - y;
117    z; @})
118 @end smallexample
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct.  (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once).  For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects.  In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
146 @smallexample
147 #define maxint(a,b) \
148   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression.  For instance, if @code{A} is a class, then
162 @smallexample
163         A a;
165         (@{a;@}).Foo ()
166 @end smallexample
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end.  This makes statement
176 expressions inside macros slightly different from function calls.  In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call.  In the statement expression case they are destroyed during
180 the statement expression.  For instance,
182 @smallexample
183 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186 void foo ()
188   macro (X ());
189   function (X ());
191 @end smallexample
193 @noindent
194 has different places where temporaries are destroyed.  For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}.  In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++.  (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted.  Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression.  In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression.  For example,
219 @smallexample
220   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}.  If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope.  A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
244 @noindent
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself.  You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros.  If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them.  However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function.  A
263 local label avoids this problem.  For example:
265 @smallexample
266 #define SEARCH(value, array, target)              \
267 do @{                                              \
268   __label__ found;                                \
269   typeof (target) _SEARCH_target = (target);      \
270   typeof (*(array)) *_SEARCH_array = (array);     \
271   int i, j;                                       \
272   int value;                                      \
273   for (i = 0; i < max; i++)                       \
274     for (j = 0; j < max; j++)                     \
275       if (_SEARCH_array[i][j] == _SEARCH_target)  \
276         @{ (value) = i; goto found; @}              \
277   (value) = -1;                                   \
278  found:;                                          \
279 @} while (0)
280 @end smallexample
282 This could also be written using a statement expression:
284 @smallexample
285 #define SEARCH(array, target)                     \
286 (@{                                                \
287   __label__ found;                                \
288   typeof (target) _SEARCH_target = (target);      \
289   typeof (*(array)) *_SEARCH_array = (array);     \
290   int i, j;                                       \
291   int value;                                      \
292   for (i = 0; i < max; i++)                       \
293     for (j = 0; j < max; j++)                     \
294       if (_SEARCH_array[i][j] == _SEARCH_target)  \
295         @{ value = i; goto found; @}                \
296   value = -1;                                     \
297  found:                                           \
298   value;                                          \
300 @end smallexample
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any.  @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}.  The
314 value has type @code{void *}.  This value is a constant and can be used
315 wherever a constant of that type is valid.  For example:
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
323 To use these values, you need to be able to jump to one.  This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}.  For example,
329 @smallexample
330 goto *ptr;
331 @end smallexample
333 @noindent
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
343 @noindent
344 Then you can select a label with indexing, like this:
346 @smallexample
347 goto *array[i];
348 @end smallexample
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement.  The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen.  The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372                              &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned.  If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning.  If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
394 @cindex thunks
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
402 call it twice:
404 @smallexample
405 @group
406 foo (double a, double b)
408   double square (double z) @{ return z * z; @}
410   return square (a) + square (b);
412 @end group
413 @end smallexample
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition.  This is
417 called @dfn{lexical scoping}.  For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
420 @smallexample
421 @group
422 bar (int *array, int offset, int size)
424   int access (int *array, int index)
425     @{ return array[index + offset]; @}
426   int i;
427   /* @r{@dots{}} */
428   for (i = 0; i < size; i++)
429     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @end group
432 @end smallexample
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
441 @smallexample
442 hack (int *array, int size)
444   void store (int index, int value)
445     @{ array[index] = value; @}
447   intermediate (store, size);
449 @end smallexample
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument.  If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose.  If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk.  If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
463 safe.
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}.  This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}).  Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well.  Here is an example:
476 @smallexample
477 @group
478 bar (int *array, int offset, int size)
480   __label__ failure;
481   int access (int *array, int index)
482     @{
483       if (index > size)
484         goto failure;
485       return array[index + offset];
486     @}
487   int i;
488   /* @r{@dots{}} */
489   for (i = 0; i < size; i++)
490     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
491   /* @r{@dots{}} */
492   return 0;
494  /* @r{Control comes here from @code{access}
495     if it detects an error.}  */
496  failure:
497   return -1;
499 @end group
500 @end smallexample
502 A nested function always has no linkage.  Declaring one with
503 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
507 @smallexample
508 bar (int *array, int offset, int size)
510   __label__ failure;
511   auto int access (int *, int);
512   /* @r{@dots{}} */
513   int access (int *array, int index)
514     @{
515       if (index > size)
516         goto failure;
517       return array[index + offset];
518     @}
519   /* @r{@dots{}} */
521 @end smallexample
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
531 of the arguments.
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
536 that data type).
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language.  It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack.  Then it returns the
551 address of that block.
552 @end deftypefn
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
557 and @var{size}.
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}.  The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}.  The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
570 area.
571 @end deftypefn
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function.  You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
577 @end deftypefn
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function.  It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments.  This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable.  For example:
589 @smallexample
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594   int r = fprintf (f, "myprintf: ");
595   if (r < 0)
596     return r;
597   int s = fprintf (f, format, __builtin_va_arg_pack ());
598   if (s < 0)
599     return s;
600   return r + s;
602 @end smallexample
603 @end deftypefn
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function.  It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
613 @smallexample
614 #ifdef __OPTIMIZE__
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618   if (__builtin_va_arg_pack_len () > 1)
619     warn_open_too_many_arguments ();
621   if (__builtin_constant_p (oflag))
622     @{
623       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
624         @{
625           warn_open_missing_mode ();
626           return __open_2 (path, oflag);
627         @}
628       return open (path, oflag, __builtin_va_arg_pack ());
629     @}
631   if (__builtin_va_arg_pack_len () < 1)
632     return __open_2 (path, oflag);
634   return open (path, oflag, __builtin_va_arg_pack ());
636 #endif
637 @end smallexample
638 @end deftypefn
640 @node Typeof
641 @section Referring to a Type with @code{typeof}
642 @findex typeof
643 @findex sizeof
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type.  Here is an example with an expression:
653 @smallexample
654 typeof (x[0](1))
655 @end smallexample
657 @noindent
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
663 @smallexample
664 typeof (int *)
665 @end smallexample
667 @noindent
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used.  For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
680 such a type.
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
688 @smallexample
689 #define max(a,b) \
690   (@{ typeof (a) _a = (a); \
691       typeof (b) _b = (b); \
692     _a > _b ? _a : _b; @})
693 @end smallexample
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}.  Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
708 @noindent
709 Some more examples of the use of @code{typeof}:
711 @itemize @bullet
712 @item
713 This declares @code{y} with the type of what @code{x} points to.
715 @smallexample
716 typeof (*x) y;
717 @end smallexample
719 @item
720 This declares @code{y} as an array of such values.
722 @smallexample
723 typeof (*x) y[4];
724 @end smallexample
726 @item
727 This declares @code{y} as an array of pointers to characters:
729 @smallexample
730 typeof (typeof (char *)[4]) y;
731 @end smallexample
733 @noindent
734 It is equivalent to the following traditional C declaration:
736 @smallexample
737 char *y[4];
738 @end smallexample
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
743 @smallexample
744 #define pointer(T)  typeof(T *)
745 #define array(T, N) typeof(T [N])
746 @end smallexample
748 @noindent
749 Now the declaration can be rewritten this way:
751 @smallexample
752 array (pointer (char), 4) y;
753 @end smallexample
755 @noindent
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
758 @end itemize
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}.  In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer.  (In C++, you should use C++11
766 @code{auto} for this purpose.)  Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
769 @smallexample
770 #define max(a,b) \
771   (@{ __auto_type _a = (a); \
772       __auto_type _b = (b); \
773     _a > _b ? _a : _b; @})
774 @end smallexample
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778 @itemize @bullet
779 @item Each argument to the macro appears only once in the expansion of
780 the macro.  This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
782 such macros.
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
787 @end itemize
789 @node Conditionals
790 @section Conditionals with Omitted Operands
791 @cindex conditional expressions, extensions
792 @cindex omitted middle-operands
793 @cindex middle-operands, omitted
794 @cindex extensions, @code{?:}
795 @cindex @code{?:} extensions
797 The middle operand in a conditional expression may be omitted.  Then
798 if the first operand is nonzero, its value is the value of the conditional
799 expression.
801 Therefore, the expression
803 @smallexample
804 x ? : y
805 @end smallexample
807 @noindent
808 has the value of @code{x} if that is nonzero; otherwise, the value of
809 @code{y}.
811 This example is perfectly equivalent to
813 @smallexample
814 x ? x : y
815 @end smallexample
817 @cindex side effect in @code{?:}
818 @cindex @code{?:} side effect
819 @noindent
820 In this simple case, the ability to omit the middle operand is not
821 especially useful.  When it becomes useful is when the first operand does,
822 or may (if it is a macro argument), contain a side effect.  Then repeating
823 the operand in the middle would perform the side effect twice.  Omitting
824 the middle operand uses the value already computed without the undesirable
825 effects of recomputing it.
827 @node __int128
828 @section 128-bit Integers
829 @cindex @code{__int128} data types
831 As an extension the integer scalar type @code{__int128} is supported for
832 targets which have an integer mode wide enough to hold 128 bits.
833 Simply write @code{__int128} for a signed 128-bit integer, or
834 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
835 support in GCC for expressing an integer constant of type @code{__int128}
836 for targets with @code{long long} integer less than 128 bits wide.
838 @node Long Long
839 @section Double-Word Integers
840 @cindex @code{long long} data types
841 @cindex double-word arithmetic
842 @cindex multiprecision arithmetic
843 @cindex @code{LL} integer suffix
844 @cindex @code{ULL} integer suffix
846 ISO C99 and ISO C++11 support data types for integers that are at least
847 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
848 Simply write @code{long long int} for a signed integer, or
849 @code{unsigned long long int} for an unsigned integer.  To make an
850 integer constant of type @code{long long int}, add the suffix @samp{LL}
851 to the integer.  To make an integer constant of type @code{unsigned long
852 long int}, add the suffix @samp{ULL} to the integer.
854 You can use these types in arithmetic like any other integer types.
855 Addition, subtraction, and bitwise boolean operations on these types
856 are open-coded on all types of machines.  Multiplication is open-coded
857 if the machine supports a fullword-to-doubleword widening multiply
858 instruction.  Division and shifts are open-coded only on machines that
859 provide special support.  The operations that are not open-coded use
860 special library routines that come with GCC@.
862 There may be pitfalls when you use @code{long long} types for function
863 arguments without function prototypes.  If a function
864 expects type @code{int} for its argument, and you pass a value of type
865 @code{long long int}, confusion results because the caller and the
866 subroutine disagree about the number of bytes for the argument.
867 Likewise, if the function expects @code{long long int} and you pass
868 @code{int}.  The best way to avoid such problems is to use prototypes.
870 @node Complex
871 @section Complex Numbers
872 @cindex complex numbers
873 @cindex @code{_Complex} keyword
874 @cindex @code{__complex__} keyword
876 ISO C99 supports complex floating data types, and as an extension GCC
877 supports them in C90 mode and in C++.  GCC also supports complex integer data
878 types which are not part of ISO C99.  You can declare complex types
879 using the keyword @code{_Complex}.  As an extension, the older GNU
880 keyword @code{__complex__} is also supported.
882 For example, @samp{_Complex double x;} declares @code{x} as a
883 variable whose real part and imaginary part are both of type
884 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
885 have real and imaginary parts of type @code{short int}; this is not
886 likely to be useful, but it shows that the set of complex types is
887 complete.
889 To write a constant with a complex data type, use the suffix @samp{i} or
890 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
891 has type @code{_Complex float} and @code{3i} has type
892 @code{_Complex int}.  Such a constant always has a pure imaginary
893 value, but you can form any complex value you like by adding one to a
894 real constant.  This is a GNU extension; if you have an ISO C99
895 conforming C library (such as the GNU C Library), and want to construct complex
896 constants of floating type, you should include @code{<complex.h>} and
897 use the macros @code{I} or @code{_Complex_I} instead.
899 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
900 that includes the @samp{<complex>} header cannot use @samp{i} for the
901 GNU extension.  The @samp{j} suffix still has the GNU meaning.
903 @cindex @code{__real__} keyword
904 @cindex @code{__imag__} keyword
905 To extract the real part of a complex-valued expression @var{exp}, write
906 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
907 extract the imaginary part.  This is a GNU extension; for values of
908 floating type, you should use the ISO C99 functions @code{crealf},
909 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
910 @code{cimagl}, declared in @code{<complex.h>} and also provided as
911 built-in functions by GCC@.
913 @cindex complex conjugation
914 The operator @samp{~} performs complex conjugation when used on a value
915 with a complex type.  This is a GNU extension; for values of
916 floating type, you should use the ISO C99 functions @code{conjf},
917 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
918 provided as built-in functions by GCC@.
920 GCC can allocate complex automatic variables in a noncontiguous
921 fashion; it's even possible for the real part to be in a register while
922 the imaginary part is on the stack (or vice versa).  Only the DWARF
923 debug info format can represent this, so use of DWARF is recommended.
924 If you are using the stabs debug info format, GCC describes a noncontiguous
925 complex variable as if it were two separate variables of noncomplex type.
926 If the variable's actual name is @code{foo}, the two fictitious
927 variables are named @code{foo$real} and @code{foo$imag}.  You can
928 examine and set these two fictitious variables with your debugger.
930 @node Floating Types
931 @section Additional Floating Types
932 @cindex additional floating types
933 @cindex @code{_Float@var{n}} data types
934 @cindex @code{_Float@var{n}x} data types
935 @cindex @code{__float80} data type
936 @cindex @code{__float128} data type
937 @cindex @code{__ibm128} data type
938 @cindex @code{w} floating point suffix
939 @cindex @code{q} floating point suffix
940 @cindex @code{W} floating point suffix
941 @cindex @code{Q} floating point suffix
943 ISO/IEC TS 18661-3:2015 defines C support for additional floating
944 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
945 these type names; the set of types supported depends on the target
946 architecture.  These types are not supported when compiling C++.
947 Constants with these types use suffixes @code{f@var{n}} or
948 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
949 names can be used together with @code{_Complex} to declare complex
950 types.
952 As an extension, GNU C and GNU C++ support additional floating
953 types, which are not supported by all targets.
954 @itemize @bullet
955 @item @code{__float128} is available on i386, x86_64, IA-64, and
956 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
957 the vector scalar (VSX) instruction set.  @code{__float128} supports
958 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
959 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
960 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
961 double}.
963 @item @code{__float80} is available on the i386, x86_64, and IA-64
964 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
965 an alias for the type name @code{_Float64x} on these targets.
967 @item @code{__ibm128} is available on PowerPC targets, and provides
968 access to the IBM extended double format which is the current format
969 used for @code{long double}.  When @code{long double} transitions to
970 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
971 for use in conversions between the two types.
972 @end itemize
974 Support for these additional types includes the arithmetic operators:
975 add, subtract, multiply, divide; unary arithmetic operators;
976 relational operators; equality operators; and conversions to and from
977 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
978 in a literal constant of type @code{__float80} or type
979 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
981 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
982 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
983 expected in future versions of GCC that @code{_Float128} and @code{__float128}
984 will be enabled automatically.
986 The @code{_Float128} type is supported on all systems where
987 @code{__float128} is supported or where @code{long double} has the
988 IEEE binary128 format.  The @code{_Float64x} type is supported on all
989 systems where @code{__float128} is supported.  The @code{_Float32}
990 type is supported on all systems supporting IEEE binary32; the
991 @code{_Float64} and @code{_Float32x} types are supported on all systems
992 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
993 systems by default, and on ARM systems when the IEEE format for 16-bit
994 floating-point types is selected with @option{-mfp16-format=ieee}.
995 GCC does not currently support @code{_Float128x} on any systems.
997 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
998 types using the corresponding internal complex type, @code{XCmode} for
999 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1001 @smallexample
1002 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1003 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1004 @end smallexample
1006 On the PowerPC Linux VSX targets, you can declare complex types using
1007 the corresponding internal complex type, @code{KCmode} for
1008 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1010 @smallexample
1011 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1012 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1013 @end smallexample
1015 @node Half-Precision
1016 @section Half-Precision Floating Point
1017 @cindex half-precision floating point
1018 @cindex @code{__fp16} data type
1020 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1021 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1022 On ARM systems, you must enable this type explicitly with the
1023 @option{-mfp16-format} command-line option in order to use it.
1025 ARM targets support two incompatible representations for half-precision
1026 floating-point values.  You must choose one of the representations and
1027 use it consistently in your program.
1029 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1030 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1031 There are 11 bits of significand precision, approximately 3
1032 decimal digits.
1034 Specifying @option{-mfp16-format=alternative} selects the ARM
1035 alternative format.  This representation is similar to the IEEE
1036 format, but does not support infinities or NaNs.  Instead, the range
1037 of exponents is extended, so that this format can represent normalized
1038 values in the range of @math{2^{-14}} to 131008.
1040 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1041 not require use of the @option{-mfp16-format} command-line option.
1043 The @code{__fp16} type may only be used as an argument to intrinsics defined
1044 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1045 arithmetic and other operations, @code{__fp16} values in C or C++
1046 expressions are automatically promoted to @code{float}.
1048 The ARM target provides hardware support for conversions between
1049 @code{__fp16} and @code{float} values
1050 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1051 hardware support for conversions between @code{__fp16} and @code{double}
1052 values.  GCC generates code using these hardware instructions if you
1053 compile with options to select an FPU that provides them;
1054 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1055 in addition to the @option{-mfp16-format} option to select
1056 a half-precision format.
1058 Language-level support for the @code{__fp16} data type is
1059 independent of whether GCC generates code using hardware floating-point
1060 instructions.  In cases where hardware support is not specified, GCC
1061 implements conversions between @code{__fp16} and other types as library
1062 calls.
1064 It is recommended that portable code use the @code{_Float16} type defined
1065 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1067 @node Decimal Float
1068 @section Decimal Floating Types
1069 @cindex decimal floating types
1070 @cindex @code{_Decimal32} data type
1071 @cindex @code{_Decimal64} data type
1072 @cindex @code{_Decimal128} data type
1073 @cindex @code{df} integer suffix
1074 @cindex @code{dd} integer suffix
1075 @cindex @code{dl} integer suffix
1076 @cindex @code{DF} integer suffix
1077 @cindex @code{DD} integer suffix
1078 @cindex @code{DL} integer suffix
1080 As an extension, GNU C supports decimal floating types as
1081 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1082 floating types in GCC will evolve as the draft technical report changes.
1083 Calling conventions for any target might also change.  Not all targets
1084 support decimal floating types.
1086 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1087 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1088 @code{float}, @code{double}, and @code{long double} whose radix is not
1089 specified by the C standard but is usually two.
1091 Support for decimal floating types includes the arithmetic operators
1092 add, subtract, multiply, divide; unary arithmetic operators;
1093 relational operators; equality operators; and conversions to and from
1094 integer and other floating types.  Use a suffix @samp{df} or
1095 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1096 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1097 @code{_Decimal128}.
1099 GCC support of decimal float as specified by the draft technical report
1100 is incomplete:
1102 @itemize @bullet
1103 @item
1104 When the value of a decimal floating type cannot be represented in the
1105 integer type to which it is being converted, the result is undefined
1106 rather than the result value specified by the draft technical report.
1108 @item
1109 GCC does not provide the C library functionality associated with
1110 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1111 @file{wchar.h}, which must come from a separate C library implementation.
1112 Because of this the GNU C compiler does not define macro
1113 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1114 the technical report.
1115 @end itemize
1117 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1118 are supported by the DWARF debug information format.
1120 @node Hex Floats
1121 @section Hex Floats
1122 @cindex hex floats
1124 ISO C99 and ISO C++17 support floating-point numbers written not only in
1125 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1126 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1127 supports this in C90 mode (except in some cases when strictly
1128 conforming) and in C++98, C++11 and C++14 modes.  In that format the
1129 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1130 mandatory.  The exponent is a decimal number that indicates the power of
1131 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1132 @tex
1133 $1 {15\over16}$,
1134 @end tex
1135 @ifnottex
1136 1 15/16,
1137 @end ifnottex
1138 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1139 is the same as @code{1.55e1}.
1141 Unlike for floating-point numbers in the decimal notation the exponent
1142 is always required in the hexadecimal notation.  Otherwise the compiler
1143 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1144 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1145 extension for floating-point constants of type @code{float}.
1147 @node Fixed-Point
1148 @section Fixed-Point Types
1149 @cindex fixed-point types
1150 @cindex @code{_Fract} data type
1151 @cindex @code{_Accum} data type
1152 @cindex @code{_Sat} data type
1153 @cindex @code{hr} fixed-suffix
1154 @cindex @code{r} fixed-suffix
1155 @cindex @code{lr} fixed-suffix
1156 @cindex @code{llr} fixed-suffix
1157 @cindex @code{uhr} fixed-suffix
1158 @cindex @code{ur} fixed-suffix
1159 @cindex @code{ulr} fixed-suffix
1160 @cindex @code{ullr} fixed-suffix
1161 @cindex @code{hk} fixed-suffix
1162 @cindex @code{k} fixed-suffix
1163 @cindex @code{lk} fixed-suffix
1164 @cindex @code{llk} fixed-suffix
1165 @cindex @code{uhk} fixed-suffix
1166 @cindex @code{uk} fixed-suffix
1167 @cindex @code{ulk} fixed-suffix
1168 @cindex @code{ullk} fixed-suffix
1169 @cindex @code{HR} fixed-suffix
1170 @cindex @code{R} fixed-suffix
1171 @cindex @code{LR} fixed-suffix
1172 @cindex @code{LLR} fixed-suffix
1173 @cindex @code{UHR} fixed-suffix
1174 @cindex @code{UR} fixed-suffix
1175 @cindex @code{ULR} fixed-suffix
1176 @cindex @code{ULLR} fixed-suffix
1177 @cindex @code{HK} fixed-suffix
1178 @cindex @code{K} fixed-suffix
1179 @cindex @code{LK} fixed-suffix
1180 @cindex @code{LLK} fixed-suffix
1181 @cindex @code{UHK} fixed-suffix
1182 @cindex @code{UK} fixed-suffix
1183 @cindex @code{ULK} fixed-suffix
1184 @cindex @code{ULLK} fixed-suffix
1186 As an extension, GNU C supports fixed-point types as
1187 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1188 types in GCC will evolve as the draft technical report changes.
1189 Calling conventions for any target might also change.  Not all targets
1190 support fixed-point types.
1192 The fixed-point types are
1193 @code{short _Fract},
1194 @code{_Fract},
1195 @code{long _Fract},
1196 @code{long long _Fract},
1197 @code{unsigned short _Fract},
1198 @code{unsigned _Fract},
1199 @code{unsigned long _Fract},
1200 @code{unsigned long long _Fract},
1201 @code{_Sat short _Fract},
1202 @code{_Sat _Fract},
1203 @code{_Sat long _Fract},
1204 @code{_Sat long long _Fract},
1205 @code{_Sat unsigned short _Fract},
1206 @code{_Sat unsigned _Fract},
1207 @code{_Sat unsigned long _Fract},
1208 @code{_Sat unsigned long long _Fract},
1209 @code{short _Accum},
1210 @code{_Accum},
1211 @code{long _Accum},
1212 @code{long long _Accum},
1213 @code{unsigned short _Accum},
1214 @code{unsigned _Accum},
1215 @code{unsigned long _Accum},
1216 @code{unsigned long long _Accum},
1217 @code{_Sat short _Accum},
1218 @code{_Sat _Accum},
1219 @code{_Sat long _Accum},
1220 @code{_Sat long long _Accum},
1221 @code{_Sat unsigned short _Accum},
1222 @code{_Sat unsigned _Accum},
1223 @code{_Sat unsigned long _Accum},
1224 @code{_Sat unsigned long long _Accum}.
1226 Fixed-point data values contain fractional and optional integral parts.
1227 The format of fixed-point data varies and depends on the target machine.
1229 Support for fixed-point types includes:
1230 @itemize @bullet
1231 @item
1232 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1233 @item
1234 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1235 @item
1236 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1237 @item
1238 binary shift operators (@code{<<}, @code{>>})
1239 @item
1240 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1241 @item
1242 equality operators (@code{==}, @code{!=})
1243 @item
1244 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1245 @code{<<=}, @code{>>=})
1246 @item
1247 conversions to and from integer, floating-point, or fixed-point types
1248 @end itemize
1250 Use a suffix in a fixed-point literal constant:
1251 @itemize
1252 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1253 @code{_Sat short _Fract}
1254 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1255 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1256 @code{_Sat long _Fract}
1257 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1258 @code{_Sat long long _Fract}
1259 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1260 @code{_Sat unsigned short _Fract}
1261 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1262 @code{_Sat unsigned _Fract}
1263 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1264 @code{_Sat unsigned long _Fract}
1265 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1266 and @code{_Sat unsigned long long _Fract}
1267 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1268 @code{_Sat short _Accum}
1269 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1270 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1271 @code{_Sat long _Accum}
1272 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1273 @code{_Sat long long _Accum}
1274 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1275 @code{_Sat unsigned short _Accum}
1276 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1277 @code{_Sat unsigned _Accum}
1278 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1279 @code{_Sat unsigned long _Accum}
1280 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1281 and @code{_Sat unsigned long long _Accum}
1282 @end itemize
1284 GCC support of fixed-point types as specified by the draft technical report
1285 is incomplete:
1287 @itemize @bullet
1288 @item
1289 Pragmas to control overflow and rounding behaviors are not implemented.
1290 @end itemize
1292 Fixed-point types are supported by the DWARF debug information format.
1294 @node Named Address Spaces
1295 @section Named Address Spaces
1296 @cindex Named Address Spaces
1298 As an extension, GNU C supports named address spaces as
1299 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1300 address spaces in GCC will evolve as the draft technical report
1301 changes.  Calling conventions for any target might also change.  At
1302 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1303 address spaces other than the generic address space.
1305 Address space identifiers may be used exactly like any other C type
1306 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1307 document for more details.
1309 @anchor{AVR Named Address Spaces}
1310 @subsection AVR Named Address Spaces
1312 On the AVR target, there are several address spaces that can be used
1313 in order to put read-only data into the flash memory and access that
1314 data by means of the special instructions @code{LPM} or @code{ELPM}
1315 needed to read from flash.
1317 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1318 flash memory by means of @code{LD*} instructions because the flash
1319 memory is mapped into the RAM address space.  There is @emph{no need}
1320 for language extensions like @code{__flash} or attribute
1321 @ref{AVR Variable Attributes,,@code{progmem}}.
1322 The default linker description files for these devices cater for that
1323 feature and @code{.rodata} stays in flash: The compiler just generates
1324 @code{LD*} instructions, and the linker script adds core specific
1325 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1326 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1327 See @ref{AVR Options} for a list of respective devices.
1329 For devices not in @code{avrtiny} or @code{avrxmega3},
1330 any data including read-only data is located in RAM (the generic
1331 address space) because flash memory is not visible in the RAM address
1332 space.  In order to locate read-only data in flash memory @emph{and}
1333 to generate the right instructions to access this data without
1334 using (inline) assembler code, special address spaces are needed.
1336 @table @code
1337 @item __flash
1338 @cindex @code{__flash} AVR Named Address Spaces
1339 The @code{__flash} qualifier locates data in the
1340 @code{.progmem.data} section. Data is read using the @code{LPM}
1341 instruction. Pointers to this address space are 16 bits wide.
1343 @item __flash1
1344 @itemx __flash2
1345 @itemx __flash3
1346 @itemx __flash4
1347 @itemx __flash5
1348 @cindex @code{__flash1} AVR Named Address Spaces
1349 @cindex @code{__flash2} AVR Named Address Spaces
1350 @cindex @code{__flash3} AVR Named Address Spaces
1351 @cindex @code{__flash4} AVR Named Address Spaces
1352 @cindex @code{__flash5} AVR Named Address Spaces
1353 These are 16-bit address spaces locating data in section
1354 @code{.progmem@var{N}.data} where @var{N} refers to
1355 address space @code{__flash@var{N}}.
1356 The compiler sets the @code{RAMPZ} segment register appropriately 
1357 before reading data by means of the @code{ELPM} instruction.
1359 @item __memx
1360 @cindex @code{__memx} AVR Named Address Spaces
1361 This is a 24-bit address space that linearizes flash and RAM:
1362 If the high bit of the address is set, data is read from
1363 RAM using the lower two bytes as RAM address.
1364 If the high bit of the address is clear, data is read from flash
1365 with @code{RAMPZ} set according to the high byte of the address.
1366 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1368 Objects in this address space are located in @code{.progmemx.data}.
1369 @end table
1371 @b{Example}
1373 @smallexample
1374 char my_read (const __flash char ** p)
1376     /* p is a pointer to RAM that points to a pointer to flash.
1377        The first indirection of p reads that flash pointer
1378        from RAM and the second indirection reads a char from this
1379        flash address.  */
1381     return **p;
1384 /* Locate array[] in flash memory */
1385 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1387 int i = 1;
1389 int main (void)
1391    /* Return 17 by reading from flash memory */
1392    return array[array[i]];
1394 @end smallexample
1396 @noindent
1397 For each named address space supported by avr-gcc there is an equally
1398 named but uppercase built-in macro defined. 
1399 The purpose is to facilitate testing if respective address space
1400 support is available or not:
1402 @smallexample
1403 #ifdef __FLASH
1404 const __flash int var = 1;
1406 int read_var (void)
1408     return var;
1410 #else
1411 #include <avr/pgmspace.h> /* From AVR-LibC */
1413 const int var PROGMEM = 1;
1415 int read_var (void)
1417     return (int) pgm_read_word (&var);
1419 #endif /* __FLASH */
1420 @end smallexample
1422 @noindent
1423 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1424 locates data in flash but
1425 accesses to these data read from generic address space, i.e.@:
1426 from RAM,
1427 so that you need special accessors like @code{pgm_read_byte}
1428 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1429 together with attribute @code{progmem}.
1431 @noindent
1432 @b{Limitations and caveats}
1434 @itemize
1435 @item
1436 Reading across the 64@tie{}KiB section boundary of
1437 the @code{__flash} or @code{__flash@var{N}} address spaces
1438 shows undefined behavior. The only address space that
1439 supports reading across the 64@tie{}KiB flash segment boundaries is
1440 @code{__memx}.
1442 @item
1443 If you use one of the @code{__flash@var{N}} address spaces
1444 you must arrange your linker script to locate the
1445 @code{.progmem@var{N}.data} sections according to your needs.
1447 @item
1448 Any data or pointers to the non-generic address spaces must
1449 be qualified as @code{const}, i.e.@: as read-only data.
1450 This still applies if the data in one of these address
1451 spaces like software version number or calibration lookup table are intended to
1452 be changed after load time by, say, a boot loader. In this case
1453 the right qualification is @code{const} @code{volatile} so that the compiler
1454 must not optimize away known values or insert them
1455 as immediates into operands of instructions.
1457 @item
1458 The following code initializes a variable @code{pfoo}
1459 located in static storage with a 24-bit address:
1460 @smallexample
1461 extern const __memx char foo;
1462 const __memx void *pfoo = &foo;
1463 @end smallexample
1465 @item
1466 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1467 Just use vanilla C / C++ code without overhead as outlined above.
1468 Attribute @code{progmem} is supported but works differently,
1469 see @ref{AVR Variable Attributes}.
1471 @end itemize
1473 @subsection M32C Named Address Spaces
1474 @cindex @code{__far} M32C Named Address Spaces
1476 On the M32C target, with the R8C and M16C CPU variants, variables
1477 qualified with @code{__far} are accessed using 32-bit addresses in
1478 order to access memory beyond the first 64@tie{}Ki bytes.  If
1479 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1480 effect.
1482 @subsection RL78 Named Address Spaces
1483 @cindex @code{__far} RL78 Named Address Spaces
1485 On the RL78 target, variables qualified with @code{__far} are accessed
1486 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1487 addresses.  Non-far variables are assumed to appear in the topmost
1488 64@tie{}KiB of the address space.
1490 @subsection SPU Named Address Spaces
1491 @cindex @code{__ea} SPU Named Address Spaces
1493 On the SPU target variables may be declared as
1494 belonging to another address space by qualifying the type with the
1495 @code{__ea} address space identifier:
1497 @smallexample
1498 extern int __ea i;
1499 @end smallexample
1501 @noindent 
1502 The compiler generates special code to access the variable @code{i}.
1503 It may use runtime library
1504 support, or generate special machine instructions to access that address
1505 space.
1507 @subsection x86 Named Address Spaces
1508 @cindex x86 named address spaces
1510 On the x86 target, variables may be declared as being relative
1511 to the @code{%fs} or @code{%gs} segments.
1513 @table @code
1514 @item __seg_fs
1515 @itemx __seg_gs
1516 @cindex @code{__seg_fs} x86 named address space
1517 @cindex @code{__seg_gs} x86 named address space
1518 The object is accessed with the respective segment override prefix.
1520 The respective segment base must be set via some method specific to
1521 the operating system.  Rather than require an expensive system call
1522 to retrieve the segment base, these address spaces are not considered
1523 to be subspaces of the generic (flat) address space.  This means that
1524 explicit casts are required to convert pointers between these address
1525 spaces and the generic address space.  In practice the application
1526 should cast to @code{uintptr_t} and apply the segment base offset
1527 that it installed previously.
1529 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1530 defined when these address spaces are supported.
1531 @end table
1533 @node Zero Length
1534 @section Arrays of Length Zero
1535 @cindex arrays of length zero
1536 @cindex zero-length arrays
1537 @cindex length-zero arrays
1538 @cindex flexible array members
1540 Declaring zero-length arrays is allowed in GNU C as an extension.
1541 A zero-length array can be useful as the last element of a structure
1542 that is really a header for a variable-length object:
1544 @smallexample
1545 struct line @{
1546   int length;
1547   char contents[0];
1550 struct line *thisline = (struct line *)
1551   malloc (sizeof (struct line) + this_length);
1552 thisline->length = this_length;
1553 @end smallexample
1555 Although the size of a zero-length array is zero, an array member of
1556 this kind may increase the size of the enclosing type as a result of tail
1557 padding.  The offset of a zero-length array member from the beginning
1558 of the enclosing structure is the same as the offset of an array with
1559 one or more elements of the same type.  The alignment of a zero-length
1560 array is the same as the alignment of its elements.
1562 Declaring zero-length arrays in other contexts, including as interior
1563 members of structure objects or as non-member objects, is discouraged.
1564 Accessing elements of zero-length arrays declared in such contexts is
1565 undefined and may be diagnosed.
1567 In the absence of the zero-length array extension, in ISO C90
1568 the @code{contents} array in the example above would typically be declared
1569 to have a single element.  Unlike a zero-length array which only contributes
1570 to the size of the enclosing structure for the purposes of alignment,
1571 a one-element array always occupies at least as much space as a single
1572 object of the type.  Although using one-element arrays this way is
1573 discouraged, GCC handles accesses to trailing one-element array members
1574 analogously to zero-length arrays.
1576 The preferred mechanism to declare variable-length types like
1577 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1578 with slightly different syntax and semantics:
1580 @itemize @bullet
1581 @item
1582 Flexible array members are written as @code{contents[]} without
1583 the @code{0}.
1585 @item
1586 Flexible array members have incomplete type, and so the @code{sizeof}
1587 operator may not be applied.  As a quirk of the original implementation
1588 of zero-length arrays, @code{sizeof} evaluates to zero.
1590 @item
1591 Flexible array members may only appear as the last member of a
1592 @code{struct} that is otherwise non-empty.
1594 @item
1595 A structure containing a flexible array member, or a union containing
1596 such a structure (possibly recursively), may not be a member of a
1597 structure or an element of an array.  (However, these uses are
1598 permitted by GCC as extensions.)
1599 @end itemize
1601 Non-empty initialization of zero-length
1602 arrays is treated like any case where there are more initializer
1603 elements than the array holds, in that a suitable warning about ``excess
1604 elements in array'' is given, and the excess elements (all of them, in
1605 this case) are ignored.
1607 GCC allows static initialization of flexible array members.
1608 This is equivalent to defining a new structure containing the original
1609 structure followed by an array of sufficient size to contain the data.
1610 E.g.@: in the following, @code{f1} is constructed as if it were declared
1611 like @code{f2}.
1613 @smallexample
1614 struct f1 @{
1615   int x; int y[];
1616 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1618 struct f2 @{
1619   struct f1 f1; int data[3];
1620 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1621 @end smallexample
1623 @noindent
1624 The convenience of this extension is that @code{f1} has the desired
1625 type, eliminating the need to consistently refer to @code{f2.f1}.
1627 This has symmetry with normal static arrays, in that an array of
1628 unknown size is also written with @code{[]}.
1630 Of course, this extension only makes sense if the extra data comes at
1631 the end of a top-level object, as otherwise we would be overwriting
1632 data at subsequent offsets.  To avoid undue complication and confusion
1633 with initialization of deeply nested arrays, we simply disallow any
1634 non-empty initialization except when the structure is the top-level
1635 object.  For example:
1637 @smallexample
1638 struct foo @{ int x; int y[]; @};
1639 struct bar @{ struct foo z; @};
1641 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1642 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1643 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1644 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1645 @end smallexample
1647 @node Empty Structures
1648 @section Structures with No Members
1649 @cindex empty structures
1650 @cindex zero-size structures
1652 GCC permits a C structure to have no members:
1654 @smallexample
1655 struct empty @{
1657 @end smallexample
1659 The structure has size zero.  In C++, empty structures are part
1660 of the language.  G++ treats empty structures as if they had a single
1661 member of type @code{char}.
1663 @node Variable Length
1664 @section Arrays of Variable Length
1665 @cindex variable-length arrays
1666 @cindex arrays of variable length
1667 @cindex VLAs
1669 Variable-length automatic arrays are allowed in ISO C99, and as an
1670 extension GCC accepts them in C90 mode and in C++.  These arrays are
1671 declared like any other automatic arrays, but with a length that is not
1672 a constant expression.  The storage is allocated at the point of
1673 declaration and deallocated when the block scope containing the declaration
1674 exits.  For
1675 example:
1677 @smallexample
1678 FILE *
1679 concat_fopen (char *s1, char *s2, char *mode)
1681   char str[strlen (s1) + strlen (s2) + 1];
1682   strcpy (str, s1);
1683   strcat (str, s2);
1684   return fopen (str, mode);
1686 @end smallexample
1688 @cindex scope of a variable length array
1689 @cindex variable-length array scope
1690 @cindex deallocating variable length arrays
1691 Jumping or breaking out of the scope of the array name deallocates the
1692 storage.  Jumping into the scope is not allowed; you get an error
1693 message for it.
1695 @cindex variable-length array in a structure
1696 As an extension, GCC accepts variable-length arrays as a member of
1697 a structure or a union.  For example:
1699 @smallexample
1700 void
1701 foo (int n)
1703   struct S @{ int x[n]; @};
1705 @end smallexample
1707 @cindex @code{alloca} vs variable-length arrays
1708 You can use the function @code{alloca} to get an effect much like
1709 variable-length arrays.  The function @code{alloca} is available in
1710 many other C implementations (but not in all).  On the other hand,
1711 variable-length arrays are more elegant.
1713 There are other differences between these two methods.  Space allocated
1714 with @code{alloca} exists until the containing @emph{function} returns.
1715 The space for a variable-length array is deallocated as soon as the array
1716 name's scope ends, unless you also use @code{alloca} in this scope.
1718 You can also use variable-length arrays as arguments to functions:
1720 @smallexample
1721 struct entry
1722 tester (int len, char data[len][len])
1724   /* @r{@dots{}} */
1726 @end smallexample
1728 The length of an array is computed once when the storage is allocated
1729 and is remembered for the scope of the array in case you access it with
1730 @code{sizeof}.
1732 If you want to pass the array first and the length afterward, you can
1733 use a forward declaration in the parameter list---another GNU extension.
1735 @smallexample
1736 struct entry
1737 tester (int len; char data[len][len], int len)
1739   /* @r{@dots{}} */
1741 @end smallexample
1743 @cindex parameter forward declaration
1744 The @samp{int len} before the semicolon is a @dfn{parameter forward
1745 declaration}, and it serves the purpose of making the name @code{len}
1746 known when the declaration of @code{data} is parsed.
1748 You can write any number of such parameter forward declarations in the
1749 parameter list.  They can be separated by commas or semicolons, but the
1750 last one must end with a semicolon, which is followed by the ``real''
1751 parameter declarations.  Each forward declaration must match a ``real''
1752 declaration in parameter name and data type.  ISO C99 does not support
1753 parameter forward declarations.
1755 @node Variadic Macros
1756 @section Macros with a Variable Number of Arguments.
1757 @cindex variable number of arguments
1758 @cindex macro with variable arguments
1759 @cindex rest argument (in macro)
1760 @cindex variadic macros
1762 In the ISO C standard of 1999, a macro can be declared to accept a
1763 variable number of arguments much as a function can.  The syntax for
1764 defining the macro is similar to that of a function.  Here is an
1765 example:
1767 @smallexample
1768 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1769 @end smallexample
1771 @noindent
1772 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1773 such a macro, it represents the zero or more tokens until the closing
1774 parenthesis that ends the invocation, including any commas.  This set of
1775 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1776 wherever it appears.  See the CPP manual for more information.
1778 GCC has long supported variadic macros, and used a different syntax that
1779 allowed you to give a name to the variable arguments just like any other
1780 argument.  Here is an example:
1782 @smallexample
1783 #define debug(format, args...) fprintf (stderr, format, args)
1784 @end smallexample
1786 @noindent
1787 This is in all ways equivalent to the ISO C example above, but arguably
1788 more readable and descriptive.
1790 GNU CPP has two further variadic macro extensions, and permits them to
1791 be used with either of the above forms of macro definition.
1793 In standard C, you are not allowed to leave the variable argument out
1794 entirely; but you are allowed to pass an empty argument.  For example,
1795 this invocation is invalid in ISO C, because there is no comma after
1796 the string:
1798 @smallexample
1799 debug ("A message")
1800 @end smallexample
1802 GNU CPP permits you to completely omit the variable arguments in this
1803 way.  In the above examples, the compiler would complain, though since
1804 the expansion of the macro still has the extra comma after the format
1805 string.
1807 To help solve this problem, CPP behaves specially for variable arguments
1808 used with the token paste operator, @samp{##}.  If instead you write
1810 @smallexample
1811 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1812 @end smallexample
1814 @noindent
1815 and if the variable arguments are omitted or empty, the @samp{##}
1816 operator causes the preprocessor to remove the comma before it.  If you
1817 do provide some variable arguments in your macro invocation, GNU CPP
1818 does not complain about the paste operation and instead places the
1819 variable arguments after the comma.  Just like any other pasted macro
1820 argument, these arguments are not macro expanded.
1822 @node Escaped Newlines
1823 @section Slightly Looser Rules for Escaped Newlines
1824 @cindex escaped newlines
1825 @cindex newlines (escaped)
1827 The preprocessor treatment of escaped newlines is more relaxed 
1828 than that specified by the C90 standard, which requires the newline
1829 to immediately follow a backslash.  
1830 GCC's implementation allows whitespace in the form
1831 of spaces, horizontal and vertical tabs, and form feeds between the
1832 backslash and the subsequent newline.  The preprocessor issues a
1833 warning, but treats it as a valid escaped newline and combines the two
1834 lines to form a single logical line.  This works within comments and
1835 tokens, as well as between tokens.  Comments are @emph{not} treated as
1836 whitespace for the purposes of this relaxation, since they have not
1837 yet been replaced with spaces.
1839 @node Subscripting
1840 @section Non-Lvalue Arrays May Have Subscripts
1841 @cindex subscripting
1842 @cindex arrays, non-lvalue
1844 @cindex subscripting and function values
1845 In ISO C99, arrays that are not lvalues still decay to pointers, and
1846 may be subscripted, although they may not be modified or used after
1847 the next sequence point and the unary @samp{&} operator may not be
1848 applied to them.  As an extension, GNU C allows such arrays to be
1849 subscripted in C90 mode, though otherwise they do not decay to
1850 pointers outside C99 mode.  For example,
1851 this is valid in GNU C though not valid in C90:
1853 @smallexample
1854 @group
1855 struct foo @{int a[4];@};
1857 struct foo f();
1859 bar (int index)
1861   return f().a[index];
1863 @end group
1864 @end smallexample
1866 @node Pointer Arith
1867 @section Arithmetic on @code{void}- and Function-Pointers
1868 @cindex void pointers, arithmetic
1869 @cindex void, size of pointer to
1870 @cindex function pointers, arithmetic
1871 @cindex function, size of pointer to
1873 In GNU C, addition and subtraction operations are supported on pointers to
1874 @code{void} and on pointers to functions.  This is done by treating the
1875 size of a @code{void} or of a function as 1.
1877 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1878 and on function types, and returns 1.
1880 @opindex Wpointer-arith
1881 The option @option{-Wpointer-arith} requests a warning if these extensions
1882 are used.
1884 @node Pointers to Arrays
1885 @section Pointers to Arrays with Qualifiers Work as Expected
1886 @cindex pointers to arrays
1887 @cindex const qualifier
1889 In GNU C, pointers to arrays with qualifiers work similar to pointers
1890 to other qualified types. For example, a value of type @code{int (*)[5]}
1891 can be used to initialize a variable of type @code{const int (*)[5]}.
1892 These types are incompatible in ISO C because the @code{const} qualifier
1893 is formally attached to the element type of the array and not the
1894 array itself.
1896 @smallexample
1897 extern void
1898 transpose (int N, int M, double out[M][N], const double in[N][M]);
1899 double x[3][2];
1900 double y[2][3];
1901 @r{@dots{}}
1902 transpose(3, 2, y, x);
1903 @end smallexample
1905 @node Initializers
1906 @section Non-Constant Initializers
1907 @cindex initializers, non-constant
1908 @cindex non-constant initializers
1910 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1911 automatic variable are not required to be constant expressions in GNU C@.
1912 Here is an example of an initializer with run-time varying elements:
1914 @smallexample
1915 foo (float f, float g)
1917   float beat_freqs[2] = @{ f-g, f+g @};
1918   /* @r{@dots{}} */
1920 @end smallexample
1922 @node Compound Literals
1923 @section Compound Literals
1924 @cindex constructor expressions
1925 @cindex initializations in expressions
1926 @cindex structures, constructor expression
1927 @cindex expressions, constructor
1928 @cindex compound literals
1929 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1931 A compound literal looks like a cast of a brace-enclosed aggregate
1932 initializer list.  Its value is an object of the type specified in
1933 the cast, containing the elements specified in the initializer.
1934 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1935 C99 and later support compound literals.  As an extension, GCC
1936 supports compound literals also in C90 mode and in C++, although
1937 as explained below, the C++ semantics are somewhat different.
1939 Usually, the specified type of a compound literal is a structure.  Assume
1940 that @code{struct foo} and @code{structure} are declared as shown:
1942 @smallexample
1943 struct foo @{int a; char b[2];@} structure;
1944 @end smallexample
1946 @noindent
1947 Here is an example of constructing a @code{struct foo} with a compound literal:
1949 @smallexample
1950 structure = ((struct foo) @{x + y, 'a', 0@});
1951 @end smallexample
1953 @noindent
1954 This is equivalent to writing the following:
1956 @smallexample
1958   struct foo temp = @{x + y, 'a', 0@};
1959   structure = temp;
1961 @end smallexample
1963 You can also construct an array, though this is dangerous in C++, as
1964 explained below.  If all the elements of the compound literal are
1965 (made up of) simple constant expressions suitable for use in
1966 initializers of objects of static storage duration, then the compound
1967 literal can be coerced to a pointer to its first element and used in
1968 such an initializer, as shown here:
1970 @smallexample
1971 char **foo = (char *[]) @{ "x", "y", "z" @};
1972 @end smallexample
1974 Compound literals for scalar types and union types are also allowed.  In
1975 the following example the variable @code{i} is initialized to the value
1976 @code{2}, the result of incrementing the unnamed object created by
1977 the compound literal.
1979 @smallexample
1980 int i = ++(int) @{ 1 @};
1981 @end smallexample
1983 As a GNU extension, GCC allows initialization of objects with static storage
1984 duration by compound literals (which is not possible in ISO C99 because
1985 the initializer is not a constant).
1986 It is handled as if the object were initialized only with the brace-enclosed
1987 list if the types of the compound literal and the object match.
1988 The elements of the compound literal must be constant.
1989 If the object being initialized has array type of unknown size, the size is
1990 determined by the size of the compound literal.
1992 @smallexample
1993 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1994 static int y[] = (int []) @{1, 2, 3@};
1995 static int z[] = (int [3]) @{1@};
1996 @end smallexample
1998 @noindent
1999 The above lines are equivalent to the following:
2000 @smallexample
2001 static struct foo x = @{1, 'a', 'b'@};
2002 static int y[] = @{1, 2, 3@};
2003 static int z[] = @{1, 0, 0@};
2004 @end smallexample
2006 In C, a compound literal designates an unnamed object with static or
2007 automatic storage duration.  In C++, a compound literal designates a
2008 temporary object that only lives until the end of its full-expression.
2009 As a result, well-defined C code that takes the address of a subobject
2010 of a compound literal can be undefined in C++, so G++ rejects
2011 the conversion of a temporary array to a pointer.  For instance, if
2012 the array compound literal example above appeared inside a function,
2013 any subsequent use of @code{foo} in C++ would have undefined behavior
2014 because the lifetime of the array ends after the declaration of @code{foo}.
2016 As an optimization, G++ sometimes gives array compound literals longer
2017 lifetimes: when the array either appears outside a function or has
2018 a @code{const}-qualified type.  If @code{foo} and its initializer had
2019 elements of type @code{char *const} rather than @code{char *}, or if
2020 @code{foo} were a global variable, the array would have static storage
2021 duration.  But it is probably safest just to avoid the use of array
2022 compound literals in C++ code.
2024 @node Designated Inits
2025 @section Designated Initializers
2026 @cindex initializers with labeled elements
2027 @cindex labeled elements in initializers
2028 @cindex case labels in initializers
2029 @cindex designated initializers
2031 Standard C90 requires the elements of an initializer to appear in a fixed
2032 order, the same as the order of the elements in the array or structure
2033 being initialized.
2035 In ISO C99 you can give the elements in any order, specifying the array
2036 indices or structure field names they apply to, and GNU C allows this as
2037 an extension in C90 mode as well.  This extension is not
2038 implemented in GNU C++.
2040 To specify an array index, write
2041 @samp{[@var{index}] =} before the element value.  For example,
2043 @smallexample
2044 int a[6] = @{ [4] = 29, [2] = 15 @};
2045 @end smallexample
2047 @noindent
2048 is equivalent to
2050 @smallexample
2051 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2052 @end smallexample
2054 @noindent
2055 The index values must be constant expressions, even if the array being
2056 initialized is automatic.
2058 An alternative syntax for this that has been obsolete since GCC 2.5 but
2059 GCC still accepts is to write @samp{[@var{index}]} before the element
2060 value, with no @samp{=}.
2062 To initialize a range of elements to the same value, write
2063 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2064 extension.  For example,
2066 @smallexample
2067 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2068 @end smallexample
2070 @noindent
2071 If the value in it has side effects, the side effects happen only once,
2072 not for each initialized field by the range initializer.
2074 @noindent
2075 Note that the length of the array is the highest value specified
2076 plus one.
2078 In a structure initializer, specify the name of a field to initialize
2079 with @samp{.@var{fieldname} =} before the element value.  For example,
2080 given the following structure,
2082 @smallexample
2083 struct point @{ int x, y; @};
2084 @end smallexample
2086 @noindent
2087 the following initialization
2089 @smallexample
2090 struct point p = @{ .y = yvalue, .x = xvalue @};
2091 @end smallexample
2093 @noindent
2094 is equivalent to
2096 @smallexample
2097 struct point p = @{ xvalue, yvalue @};
2098 @end smallexample
2100 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2101 @samp{@var{fieldname}:}, as shown here:
2103 @smallexample
2104 struct point p = @{ y: yvalue, x: xvalue @};
2105 @end smallexample
2107 Omitted field members are implicitly initialized the same as objects
2108 that have static storage duration.
2110 @cindex designators
2111 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2112 @dfn{designator}.  You can also use a designator (or the obsolete colon
2113 syntax) when initializing a union, to specify which element of the union
2114 should be used.  For example,
2116 @smallexample
2117 union foo @{ int i; double d; @};
2119 union foo f = @{ .d = 4 @};
2120 @end smallexample
2122 @noindent
2123 converts 4 to a @code{double} to store it in the union using
2124 the second element.  By contrast, casting 4 to type @code{union foo}
2125 stores it into the union as the integer @code{i}, since it is
2126 an integer.  @xref{Cast to Union}.
2128 You can combine this technique of naming elements with ordinary C
2129 initialization of successive elements.  Each initializer element that
2130 does not have a designator applies to the next consecutive element of the
2131 array or structure.  For example,
2133 @smallexample
2134 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2135 @end smallexample
2137 @noindent
2138 is equivalent to
2140 @smallexample
2141 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2142 @end smallexample
2144 Labeling the elements of an array initializer is especially useful
2145 when the indices are characters or belong to an @code{enum} type.
2146 For example:
2148 @smallexample
2149 int whitespace[256]
2150   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2151       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2152 @end smallexample
2154 @cindex designator lists
2155 You can also write a series of @samp{.@var{fieldname}} and
2156 @samp{[@var{index}]} designators before an @samp{=} to specify a
2157 nested subobject to initialize; the list is taken relative to the
2158 subobject corresponding to the closest surrounding brace pair.  For
2159 example, with the @samp{struct point} declaration above:
2161 @smallexample
2162 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2163 @end smallexample
2165 @noindent
2166 If the same field is initialized multiple times, it has the value from
2167 the last initialization.  If any such overridden initialization has
2168 side effect, it is unspecified whether the side effect happens or not.
2169 Currently, GCC discards them and issues a warning.
2171 @node Case Ranges
2172 @section Case Ranges
2173 @cindex case ranges
2174 @cindex ranges in case statements
2176 You can specify a range of consecutive values in a single @code{case} label,
2177 like this:
2179 @smallexample
2180 case @var{low} ... @var{high}:
2181 @end smallexample
2183 @noindent
2184 This has the same effect as the proper number of individual @code{case}
2185 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2187 This feature is especially useful for ranges of ASCII character codes:
2189 @smallexample
2190 case 'A' ... 'Z':
2191 @end smallexample
2193 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2194 it may be parsed wrong when you use it with integer values.  For example,
2195 write this:
2197 @smallexample
2198 case 1 ... 5:
2199 @end smallexample
2201 @noindent
2202 rather than this:
2204 @smallexample
2205 case 1...5:
2206 @end smallexample
2208 @node Cast to Union
2209 @section Cast to a Union Type
2210 @cindex cast to a union
2211 @cindex union, casting to a
2213 A cast to union type looks similar to other casts, except that the type
2214 specified is a union type.  You can specify the type either with the
2215 @code{union} keyword or with a @code{typedef} name that refers to
2216 a union.  A cast to a union actually creates a compound literal and
2217 yields an lvalue, not an rvalue like true casts do.
2218 @xref{Compound Literals}.
2220 The types that may be cast to the union type are those of the members
2221 of the union.  Thus, given the following union and variables:
2223 @smallexample
2224 union foo @{ int i; double d; @};
2225 int x;
2226 double y;
2227 @end smallexample
2229 @noindent
2230 both @code{x} and @code{y} can be cast to type @code{union foo}.
2232 Using the cast as the right-hand side of an assignment to a variable of
2233 union type is equivalent to storing in a member of the union:
2235 @smallexample
2236 union foo u;
2237 /* @r{@dots{}} */
2238 u = (union foo) x  @equiv{}  u.i = x
2239 u = (union foo) y  @equiv{}  u.d = y
2240 @end smallexample
2242 You can also use the union cast as a function argument:
2244 @smallexample
2245 void hack (union foo);
2246 /* @r{@dots{}} */
2247 hack ((union foo) x);
2248 @end smallexample
2250 @node Mixed Declarations
2251 @section Mixed Declarations and Code
2252 @cindex mixed declarations and code
2253 @cindex declarations, mixed with code
2254 @cindex code, mixed with declarations
2256 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2257 within compound statements.  As an extension, GNU C also allows this in
2258 C90 mode.  For example, you could do:
2260 @smallexample
2261 int i;
2262 /* @r{@dots{}} */
2263 i++;
2264 int j = i + 2;
2265 @end smallexample
2267 Each identifier is visible from where it is declared until the end of
2268 the enclosing block.
2270 @node Function Attributes
2271 @section Declaring Attributes of Functions
2272 @cindex function attributes
2273 @cindex declaring attributes of functions
2274 @cindex @code{volatile} applied to function
2275 @cindex @code{const} applied to function
2277 In GNU C, you can use function attributes to declare certain things
2278 about functions called in your program which help the compiler
2279 optimize calls and check your code more carefully.  For example, you
2280 can use attributes to declare that a function never returns
2281 (@code{noreturn}), returns a value depending only on its arguments
2282 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2284 You can also use attributes to control memory placement, code
2285 generation options or call/return conventions within the function
2286 being annotated.  Many of these attributes are target-specific.  For
2287 example, many targets support attributes for defining interrupt
2288 handler functions, which typically must follow special register usage
2289 and return conventions.
2291 Function attributes are introduced by the @code{__attribute__} keyword
2292 on a declaration, followed by an attribute specification inside double
2293 parentheses.  You can specify multiple attributes in a declaration by
2294 separating them by commas within the double parentheses or by
2295 immediately following an attribute declaration with another attribute
2296 declaration.  @xref{Attribute Syntax}, for the exact rules on attribute
2297 syntax and placement.  Compatible attribute specifications on distinct
2298 declarations of the same function are merged.  An attribute specification
2299 that is not compatible with attributes already applied to a declaration
2300 of the same function is ignored with a warning.
2302 GCC also supports attributes on
2303 variable declarations (@pxref{Variable Attributes}),
2304 labels (@pxref{Label Attributes}),
2305 enumerators (@pxref{Enumerator Attributes}),
2306 statements (@pxref{Statement Attributes}),
2307 and types (@pxref{Type Attributes}).
2309 There is some overlap between the purposes of attributes and pragmas
2310 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2311 found convenient to use @code{__attribute__} to achieve a natural
2312 attachment of attributes to their corresponding declarations, whereas
2313 @code{#pragma} is of use for compatibility with other compilers
2314 or constructs that do not naturally form part of the grammar.
2316 In addition to the attributes documented here,
2317 GCC plugins may provide their own attributes.
2319 @menu
2320 * Common Function Attributes::
2321 * AArch64 Function Attributes::
2322 * ARC Function Attributes::
2323 * ARM Function Attributes::
2324 * AVR Function Attributes::
2325 * Blackfin Function Attributes::
2326 * CR16 Function Attributes::
2327 * C-SKY Function Attributes::
2328 * Epiphany Function Attributes::
2329 * H8/300 Function Attributes::
2330 * IA-64 Function Attributes::
2331 * M32C Function Attributes::
2332 * M32R/D Function Attributes::
2333 * m68k Function Attributes::
2334 * MCORE Function Attributes::
2335 * MeP Function Attributes::
2336 * MicroBlaze Function Attributes::
2337 * Microsoft Windows Function Attributes::
2338 * MIPS Function Attributes::
2339 * MSP430 Function Attributes::
2340 * NDS32 Function Attributes::
2341 * Nios II Function Attributes::
2342 * Nvidia PTX Function Attributes::
2343 * PowerPC Function Attributes::
2344 * RISC-V Function Attributes::
2345 * RL78 Function Attributes::
2346 * RX Function Attributes::
2347 * S/390 Function Attributes::
2348 * SH Function Attributes::
2349 * SPU Function Attributes::
2350 * Symbian OS Function Attributes::
2351 * V850 Function Attributes::
2352 * Visium Function Attributes::
2353 * x86 Function Attributes::
2354 * Xstormy16 Function Attributes::
2355 @end menu
2357 @node Common Function Attributes
2358 @subsection Common Function Attributes
2360 The following attributes are supported on most targets.
2362 @table @code
2363 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2365 @item alias ("@var{target}")
2366 @cindex @code{alias} function attribute
2367 The @code{alias} attribute causes the declaration to be emitted as an
2368 alias for another symbol, which must be specified.  For instance,
2370 @smallexample
2371 void __f () @{ /* @r{Do something.} */; @}
2372 void f () __attribute__ ((weak, alias ("__f")));
2373 @end smallexample
2375 @noindent
2376 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2377 mangled name for the target must be used.  It is an error if @samp{__f}
2378 is not defined in the same translation unit.
2380 This attribute requires assembler and object file support,
2381 and may not be available on all targets.
2383 @item aligned (@var{alignment})
2384 @cindex @code{aligned} function attribute
2385 This attribute specifies a minimum alignment for the function,
2386 measured in bytes.
2388 You cannot use this attribute to decrease the alignment of a function,
2389 only to increase it.  However, when you explicitly specify a function
2390 alignment this overrides the effect of the
2391 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2392 function.
2394 Note that the effectiveness of @code{aligned} attributes may be
2395 limited by inherent limitations in your linker.  On many systems, the
2396 linker is only able to arrange for functions to be aligned up to a
2397 certain maximum alignment.  (For some linkers, the maximum supported
2398 alignment may be very very small.)  See your linker documentation for
2399 further information.
2401 The @code{aligned} attribute can also be used for variables and fields
2402 (@pxref{Variable Attributes}.)
2404 @item alloc_align
2405 @cindex @code{alloc_align} function attribute
2406 The @code{alloc_align} attribute is used to tell the compiler that the
2407 function return value points to memory, where the returned pointer minimum
2408 alignment is given by one of the functions parameters.  GCC uses this
2409 information to improve pointer alignment analysis.
2411 The function parameter denoting the allocated alignment is specified by
2412 one integer argument, whose number is the argument of the attribute.
2413 Argument numbering starts at one.
2415 For instance,
2417 @smallexample
2418 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2419 @end smallexample
2421 @noindent
2422 declares that @code{my_memalign} returns memory with minimum alignment
2423 given by parameter 1.
2425 @item alloc_size
2426 @cindex @code{alloc_size} function attribute
2427 The @code{alloc_size} attribute is used to tell the compiler that the
2428 function return value points to memory, where the size is given by
2429 one or two of the functions parameters.  GCC uses this
2430 information to improve the correctness of @code{__builtin_object_size}.
2432 The function parameter(s) denoting the allocated size are specified by
2433 one or two integer arguments supplied to the attribute.  The allocated size
2434 is either the value of the single function argument specified or the product
2435 of the two function arguments specified.  Argument numbering starts at
2436 one.
2438 For instance,
2440 @smallexample
2441 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2442 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2443 @end smallexample
2445 @noindent
2446 declares that @code{my_calloc} returns memory of the size given by
2447 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2448 of the size given by parameter 2.
2450 @item always_inline
2451 @cindex @code{always_inline} function attribute
2452 Generally, functions are not inlined unless optimization is specified.
2453 For functions declared inline, this attribute inlines the function
2454 independent of any restrictions that otherwise apply to inlining.
2455 Failure to inline such a function is diagnosed as an error.
2456 Note that if such a function is called indirectly the compiler may
2457 or may not inline it depending on optimization level and a failure
2458 to inline an indirect call may or may not be diagnosed.
2460 @item artificial
2461 @cindex @code{artificial} function attribute
2462 This attribute is useful for small inline wrappers that if possible
2463 should appear during debugging as a unit.  Depending on the debug
2464 info format it either means marking the function as artificial
2465 or using the caller location for all instructions within the inlined
2466 body.
2468 @item assume_aligned
2469 @cindex @code{assume_aligned} function attribute
2470 The @code{assume_aligned} attribute is used to tell the compiler that the
2471 function return value points to memory, where the returned pointer minimum
2472 alignment is given by the first argument.
2473 If the attribute has two arguments, the second argument is misalignment offset.
2475 For instance
2477 @smallexample
2478 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2479 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2480 @end smallexample
2482 @noindent
2483 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2484 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2485 to 8.
2487 @item cold
2488 @cindex @code{cold} function attribute
2489 The @code{cold} attribute on functions is used to inform the compiler that
2490 the function is unlikely to be executed.  The function is optimized for
2491 size rather than speed and on many targets it is placed into a special
2492 subsection of the text section so all cold functions appear close together,
2493 improving code locality of non-cold parts of program.  The paths leading
2494 to calls of cold functions within code are marked as unlikely by the branch
2495 prediction mechanism.  It is thus useful to mark functions used to handle
2496 unlikely conditions, such as @code{perror}, as cold to improve optimization
2497 of hot functions that do call marked functions in rare occasions.
2499 When profile feedback is available, via @option{-fprofile-use}, cold functions
2500 are automatically detected and this attribute is ignored.
2502 @item const
2503 @cindex @code{const} function attribute
2504 @cindex functions that have no side effects
2505 Many functions do not examine any values except their arguments, and
2506 have no effects except to return a value.  Calls to such functions lend
2507 themselves to optimization such as common subexpression elimination.
2508 The @code{const} attribute imposes greater restrictions on a function's
2509 definition than the similar @code{pure} attribute below because it prohibits
2510 the function from reading global variables.  Consequently, the presence of
2511 the attribute on a function declaration allows GCC to emit more efficient
2512 code for some calls to the function.  Decorating the same function with
2513 both the @code{const} and the @code{pure} attribute is diagnosed.
2515 @cindex pointer arguments
2516 Note that a function that has pointer arguments and examines the data
2517 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2518 function that calls a non-@code{const} function usually must not be
2519 @code{const}.  Because a @code{const} function cannot have any side
2520 effects it does not make sense for such a function to return @code{void}.
2521 Declaring such a function is diagnosed.
2523 @item constructor
2524 @itemx destructor
2525 @itemx constructor (@var{priority})
2526 @itemx destructor (@var{priority})
2527 @cindex @code{constructor} function attribute
2528 @cindex @code{destructor} function attribute
2529 The @code{constructor} attribute causes the function to be called
2530 automatically before execution enters @code{main ()}.  Similarly, the
2531 @code{destructor} attribute causes the function to be called
2532 automatically after @code{main ()} completes or @code{exit ()} is
2533 called.  Functions with these attributes are useful for
2534 initializing data that is used implicitly during the execution of
2535 the program.
2537 You may provide an optional integer priority to control the order in
2538 which constructor and destructor functions are run.  A constructor
2539 with a smaller priority number runs before a constructor with a larger
2540 priority number; the opposite relationship holds for destructors.  So,
2541 if you have a constructor that allocates a resource and a destructor
2542 that deallocates the same resource, both functions typically have the
2543 same priority.  The priorities for constructor and destructor
2544 functions are the same as those specified for namespace-scope C++
2545 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2546 constructors for C++ objects with static storage duration and functions
2547 decorated with attribute @code{constructor} are invoked is unspecified.
2548 In mixed declarations, attribute @code{init_priority} can be used to
2549 impose a specific ordering.
2551 @item deprecated
2552 @itemx deprecated (@var{msg})
2553 @cindex @code{deprecated} function attribute
2554 The @code{deprecated} attribute results in a warning if the function
2555 is used anywhere in the source file.  This is useful when identifying
2556 functions that are expected to be removed in a future version of a
2557 program.  The warning also includes the location of the declaration
2558 of the deprecated function, to enable users to easily find further
2559 information about why the function is deprecated, or what they should
2560 do instead.  Note that the warnings only occurs for uses:
2562 @smallexample
2563 int old_fn () __attribute__ ((deprecated));
2564 int old_fn ();
2565 int (*fn_ptr)() = old_fn;
2566 @end smallexample
2568 @noindent
2569 results in a warning on line 3 but not line 2.  The optional @var{msg}
2570 argument, which must be a string, is printed in the warning if
2571 present.
2573 The @code{deprecated} attribute can also be used for variables and
2574 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2576 The message attached to the attribute is affected by the setting of
2577 the @option{-fmessage-length} option.
2579 @item error ("@var{message}")
2580 @itemx warning ("@var{message}")
2581 @cindex @code{error} function attribute
2582 @cindex @code{warning} function attribute
2583 If the @code{error} or @code{warning} attribute 
2584 is used on a function declaration and a call to such a function
2585 is not eliminated through dead code elimination or other optimizations, 
2586 an error or warning (respectively) that includes @var{message} is diagnosed.  
2587 This is useful
2588 for compile-time checking, especially together with @code{__builtin_constant_p}
2589 and inline functions where checking the inline function arguments is not
2590 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2592 While it is possible to leave the function undefined and thus invoke
2593 a link failure (to define the function with
2594 a message in @code{.gnu.warning*} section),
2595 when using these attributes the problem is diagnosed
2596 earlier and with exact location of the call even in presence of inline
2597 functions or when not emitting debugging information.
2599 @item externally_visible
2600 @cindex @code{externally_visible} function attribute
2601 This attribute, attached to a global variable or function, nullifies
2602 the effect of the @option{-fwhole-program} command-line option, so the
2603 object remains visible outside the current compilation unit.
2605 If @option{-fwhole-program} is used together with @option{-flto} and 
2606 @command{gold} is used as the linker plugin, 
2607 @code{externally_visible} attributes are automatically added to functions 
2608 (not variable yet due to a current @command{gold} issue) 
2609 that are accessed outside of LTO objects according to resolution file
2610 produced by @command{gold}.
2611 For other linkers that cannot generate resolution file,
2612 explicit @code{externally_visible} attributes are still necessary.
2614 @item flatten
2615 @cindex @code{flatten} function attribute
2616 Generally, inlining into a function is limited.  For a function marked with
2617 this attribute, every call inside this function is inlined, if possible.
2618 Whether the function itself is considered for inlining depends on its size and
2619 the current inlining parameters.
2621 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2622 @cindex @code{format} function attribute
2623 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2624 @opindex Wformat
2625 The @code{format} attribute specifies that a function takes @code{printf},
2626 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2627 should be type-checked against a format string.  For example, the
2628 declaration:
2630 @smallexample
2631 extern int
2632 my_printf (void *my_object, const char *my_format, ...)
2633       __attribute__ ((format (printf, 2, 3)));
2634 @end smallexample
2636 @noindent
2637 causes the compiler to check the arguments in calls to @code{my_printf}
2638 for consistency with the @code{printf} style format string argument
2639 @code{my_format}.
2641 The parameter @var{archetype} determines how the format string is
2642 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2643 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2644 @code{strfmon}.  (You can also use @code{__printf__},
2645 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2646 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2647 @code{ms_strftime} are also present.
2648 @var{archetype} values such as @code{printf} refer to the formats accepted
2649 by the system's C runtime library,
2650 while values prefixed with @samp{gnu_} always refer
2651 to the formats accepted by the GNU C Library.  On Microsoft Windows
2652 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2653 @file{msvcrt.dll} library.
2654 The parameter @var{string-index}
2655 specifies which argument is the format string argument (starting
2656 from 1), while @var{first-to-check} is the number of the first
2657 argument to check against the format string.  For functions
2658 where the arguments are not available to be checked (such as
2659 @code{vprintf}), specify the third parameter as zero.  In this case the
2660 compiler only checks the format string for consistency.  For
2661 @code{strftime} formats, the third parameter is required to be zero.
2662 Since non-static C++ methods have an implicit @code{this} argument, the
2663 arguments of such methods should be counted from two, not one, when
2664 giving values for @var{string-index} and @var{first-to-check}.
2666 In the example above, the format string (@code{my_format}) is the second
2667 argument of the function @code{my_print}, and the arguments to check
2668 start with the third argument, so the correct parameters for the format
2669 attribute are 2 and 3.
2671 @opindex ffreestanding
2672 @opindex fno-builtin
2673 The @code{format} attribute allows you to identify your own functions
2674 that take format strings as arguments, so that GCC can check the
2675 calls to these functions for errors.  The compiler always (unless
2676 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2677 for the standard library functions @code{printf}, @code{fprintf},
2678 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2679 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2680 warnings are requested (using @option{-Wformat}), so there is no need to
2681 modify the header file @file{stdio.h}.  In C99 mode, the functions
2682 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2683 @code{vsscanf} are also checked.  Except in strictly conforming C
2684 standard modes, the X/Open function @code{strfmon} is also checked as
2685 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2686 @xref{C Dialect Options,,Options Controlling C Dialect}.
2688 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2689 recognized in the same context.  Declarations including these format attributes
2690 are parsed for correct syntax, however the result of checking of such format
2691 strings is not yet defined, and is not carried out by this version of the
2692 compiler.
2694 The target may also provide additional types of format checks.
2695 @xref{Target Format Checks,,Format Checks Specific to Particular
2696 Target Machines}.
2698 @item format_arg (@var{string-index})
2699 @cindex @code{format_arg} function attribute
2700 @opindex Wformat-nonliteral
2701 The @code{format_arg} attribute specifies that a function takes one or
2702 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
2703 @code{strfmon} style function and modifies it (for example, to translate
2704 it into another language), so the result can be passed to a
2705 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2706 function (with the remaining arguments to the format function the same
2707 as they would have been for the unmodified string).  Multiple
2708 @code{format_arg} attributes may be applied to the same function, each
2709 designating a distinct parameter as a format string.  For example, the
2710 declaration:
2712 @smallexample
2713 extern char *
2714 my_dgettext (char *my_domain, const char *my_format)
2715       __attribute__ ((format_arg (2)));
2716 @end smallexample
2718 @noindent
2719 causes the compiler to check the arguments in calls to a @code{printf},
2720 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2721 format string argument is a call to the @code{my_dgettext} function, for
2722 consistency with the format string argument @code{my_format}.  If the
2723 @code{format_arg} attribute had not been specified, all the compiler
2724 could tell in such calls to format functions would be that the format
2725 string argument is not constant; this would generate a warning when
2726 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2727 without the attribute.
2729 In calls to a function declared with more than one @code{format_arg}
2730 attribute, each with a distinct argument value, the corresponding
2731 actual function arguments are checked against all format strings
2732 designated by the attributes.  This capability is designed to support
2733 the GNU @code{ngettext} family of functions.
2735 The parameter @var{string-index} specifies which argument is the format
2736 string argument (starting from one).  Since non-static C++ methods have
2737 an implicit @code{this} argument, the arguments of such methods should
2738 be counted from two.
2740 The @code{format_arg} attribute allows you to identify your own
2741 functions that modify format strings, so that GCC can check the
2742 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2743 type function whose operands are a call to one of your own function.
2744 The compiler always treats @code{gettext}, @code{dgettext}, and
2745 @code{dcgettext} in this manner except when strict ISO C support is
2746 requested by @option{-ansi} or an appropriate @option{-std} option, or
2747 @option{-ffreestanding} or @option{-fno-builtin}
2748 is used.  @xref{C Dialect Options,,Options
2749 Controlling C Dialect}.
2751 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2752 @code{NSString} reference for compatibility with the @code{format} attribute
2753 above.
2755 The target may also allow additional types in @code{format-arg} attributes.
2756 @xref{Target Format Checks,,Format Checks Specific to Particular
2757 Target Machines}.
2759 @item gnu_inline
2760 @cindex @code{gnu_inline} function attribute
2761 This attribute should be used with a function that is also declared
2762 with the @code{inline} keyword.  It directs GCC to treat the function
2763 as if it were defined in gnu90 mode even when compiling in C99 or
2764 gnu99 mode.
2766 If the function is declared @code{extern}, then this definition of the
2767 function is used only for inlining.  In no case is the function
2768 compiled as a standalone function, not even if you take its address
2769 explicitly.  Such an address becomes an external reference, as if you
2770 had only declared the function, and had not defined it.  This has
2771 almost the effect of a macro.  The way to use this is to put a
2772 function definition in a header file with this attribute, and put
2773 another copy of the function, without @code{extern}, in a library
2774 file.  The definition in the header file causes most calls to the
2775 function to be inlined.  If any uses of the function remain, they
2776 refer to the single copy in the library.  Note that the two
2777 definitions of the functions need not be precisely the same, although
2778 if they do not have the same effect your program may behave oddly.
2780 In C, if the function is neither @code{extern} nor @code{static}, then
2781 the function is compiled as a standalone function, as well as being
2782 inlined where possible.
2784 This is how GCC traditionally handled functions declared
2785 @code{inline}.  Since ISO C99 specifies a different semantics for
2786 @code{inline}, this function attribute is provided as a transition
2787 measure and as a useful feature in its own right.  This attribute is
2788 available in GCC 4.1.3 and later.  It is available if either of the
2789 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2790 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2791 Function is As Fast As a Macro}.
2793 In C++, this attribute does not depend on @code{extern} in any way,
2794 but it still requires the @code{inline} keyword to enable its special
2795 behavior.
2797 @item hot
2798 @cindex @code{hot} function attribute
2799 The @code{hot} attribute on a function is used to inform the compiler that
2800 the function is a hot spot of the compiled program.  The function is
2801 optimized more aggressively and on many targets it is placed into a special
2802 subsection of the text section so all hot functions appear close together,
2803 improving locality.
2805 When profile feedback is available, via @option{-fprofile-use}, hot functions
2806 are automatically detected and this attribute is ignored.
2808 @item ifunc ("@var{resolver}")
2809 @cindex @code{ifunc} function attribute
2810 @cindex indirect functions
2811 @cindex functions that are dynamically resolved
2812 The @code{ifunc} attribute is used to mark a function as an indirect
2813 function using the STT_GNU_IFUNC symbol type extension to the ELF
2814 standard.  This allows the resolution of the symbol value to be
2815 determined dynamically at load time, and an optimized version of the
2816 routine to be selected for the particular processor or other system
2817 characteristics determined then.  To use this attribute, first define
2818 the implementation functions available, and a resolver function that
2819 returns a pointer to the selected implementation function.  The
2820 implementation functions' declarations must match the API of the
2821 function being implemented.  The resolver should be declared to
2822 be a function taking no arguments and returning a pointer to
2823 a function of the same type as the implementation.  For example:
2825 @smallexample
2826 void *my_memcpy (void *dst, const void *src, size_t len)
2828   @dots{}
2829   return dst;
2832 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2834   return my_memcpy; // we will just always select this routine
2836 @end smallexample
2838 @noindent
2839 The exported header file declaring the function the user calls would
2840 contain:
2842 @smallexample
2843 extern void *memcpy (void *, const void *, size_t);
2844 @end smallexample
2846 @noindent
2847 allowing the user to call @code{memcpy} as a regular function, unaware of
2848 the actual implementation.  Finally, the indirect function needs to be
2849 defined in the same translation unit as the resolver function:
2851 @smallexample
2852 void *memcpy (void *, const void *, size_t)
2853      __attribute__ ((ifunc ("resolve_memcpy")));
2854 @end smallexample
2856 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2857 of the resolver function.  A C++ resolver for a non-static member function
2858 of class @code{C} should be declared to return a pointer to a non-member
2859 function taking pointer to @code{C} as the first argument, followed by
2860 the same arguments as of the implementation function.  G++ checks
2861 the signatures of the two functions and issues
2862 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2863 for the necessary cast from a pointer to the implementation member function
2864 to the type of the corresponding non-member function use
2865 the @option{-Wno-pmf-conversions} option.  For example:
2867 @smallexample
2868 class S
2870 private:
2871   int debug_impl (int);
2872   int optimized_impl (int);
2874   typedef int Func (S*, int);
2876   static Func* resolver ();
2877 public:
2879   int interface (int);
2882 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2883 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2885 S::Func* S::resolver ()
2887   int (S::*pimpl) (int)
2888     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2890   // Cast triggers -Wno-pmf-conversions.
2891   return reinterpret_cast<Func*>(pimpl);
2894 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2895 @end smallexample
2897 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2898 and GNU C Library version 2.11.1 are required to use this feature.
2900 @item interrupt
2901 @itemx interrupt_handler
2902 Many GCC back ends support attributes to indicate that a function is
2903 an interrupt handler, which tells the compiler to generate function
2904 entry and exit sequences that differ from those from regular
2905 functions.  The exact syntax and behavior are target-specific;
2906 refer to the following subsections for details.
2908 @item leaf
2909 @cindex @code{leaf} function attribute
2910 Calls to external functions with this attribute must return to the
2911 current compilation unit only by return or by exception handling.  In
2912 particular, a leaf function is not allowed to invoke callback functions
2913 passed to it from the current compilation unit, directly call functions
2914 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2915 might still call functions from other compilation units and thus they
2916 are not necessarily leaf in the sense that they contain no function
2917 calls at all.
2919 The attribute is intended for library functions to improve dataflow
2920 analysis.  The compiler takes the hint that any data not escaping the
2921 current compilation unit cannot be used or modified by the leaf
2922 function.  For example, the @code{sin} function is a leaf function, but
2923 @code{qsort} is not.
2925 Note that leaf functions might indirectly run a signal handler defined
2926 in the current compilation unit that uses static variables.  Similarly,
2927 when lazy symbol resolution is in effect, leaf functions might invoke
2928 indirect functions whose resolver function or implementation function is
2929 defined in the current compilation unit and uses static variables.  There
2930 is no standard-compliant way to write such a signal handler, resolver
2931 function, or implementation function, and the best that you can do is to
2932 remove the @code{leaf} attribute or mark all such static variables
2933 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2934 interposition, care should be taken that functions defined in the
2935 current compilation unit do not unexpectedly interpose other symbols
2936 based on the defined standards mode and defined feature test macros;
2937 otherwise an inadvertent callback would be added.
2939 The attribute has no effect on functions defined within the current
2940 compilation unit.  This is to allow easy merging of multiple compilation
2941 units into one, for example, by using the link-time optimization.  For
2942 this reason the attribute is not allowed on types to annotate indirect
2943 calls.
2945 @item malloc
2946 @cindex @code{malloc} function attribute
2947 @cindex functions that behave like malloc
2948 This tells the compiler that a function is @code{malloc}-like, i.e.,
2949 that the pointer @var{P} returned by the function cannot alias any
2950 other pointer valid when the function returns, and moreover no
2951 pointers to valid objects occur in any storage addressed by @var{P}.
2953 Using this attribute can improve optimization.  Compiler predicts
2954 that a function with the attribute returns non-null in most cases.
2955 Functions like
2956 @code{malloc} and @code{calloc} have this property because they return
2957 a pointer to uninitialized or zeroed-out storage.  However, functions
2958 like @code{realloc} do not have this property, as they can return a
2959 pointer to storage containing pointers.
2961 @item no_icf
2962 @cindex @code{no_icf} function attribute
2963 This function attribute prevents a functions from being merged with another
2964 semantically equivalent function.
2966 @item no_instrument_function
2967 @cindex @code{no_instrument_function} function attribute
2968 @opindex finstrument-functions
2969 If @option{-finstrument-functions} is given, profiling function calls are
2970 generated at entry and exit of most user-compiled functions.
2971 Functions with this attribute are not so instrumented.
2973 @item no_profile_instrument_function
2974 @cindex @code{no_profile_instrument_function} function attribute
2975 The @code{no_profile_instrument_function} attribute on functions is used
2976 to inform the compiler that it should not process any profile feedback based
2977 optimization code instrumentation.
2979 @item no_reorder
2980 @cindex @code{no_reorder} function attribute
2981 Do not reorder functions or variables marked @code{no_reorder}
2982 against each other or top level assembler statements the executable.
2983 The actual order in the program will depend on the linker command
2984 line. Static variables marked like this are also not removed.
2985 This has a similar effect
2986 as the @option{-fno-toplevel-reorder} option, but only applies to the
2987 marked symbols.
2989 @item no_sanitize ("@var{sanitize_option}")
2990 @cindex @code{no_sanitize} function attribute
2991 The @code{no_sanitize} attribute on functions is used
2992 to inform the compiler that it should not do sanitization of all options
2993 mentioned in @var{sanitize_option}.  A list of values acceptable by
2994 @option{-fsanitize} option can be provided.
2996 @smallexample
2997 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2998 f () @{ /* @r{Do something.} */; @}
2999 void __attribute__ ((no_sanitize ("alignment,object-size")))
3000 g () @{ /* @r{Do something.} */; @}
3001 @end smallexample
3003 @item no_sanitize_address
3004 @itemx no_address_safety_analysis
3005 @cindex @code{no_sanitize_address} function attribute
3006 The @code{no_sanitize_address} attribute on functions is used
3007 to inform the compiler that it should not instrument memory accesses
3008 in the function when compiling with the @option{-fsanitize=address} option.
3009 The @code{no_address_safety_analysis} is a deprecated alias of the
3010 @code{no_sanitize_address} attribute, new code should use
3011 @code{no_sanitize_address}.
3013 @item no_sanitize_thread
3014 @cindex @code{no_sanitize_thread} function attribute
3015 The @code{no_sanitize_thread} attribute on functions is used
3016 to inform the compiler that it should not instrument memory accesses
3017 in the function when compiling with the @option{-fsanitize=thread} option.
3019 @item no_sanitize_undefined
3020 @cindex @code{no_sanitize_undefined} function attribute
3021 The @code{no_sanitize_undefined} attribute on functions is used
3022 to inform the compiler that it should not check for undefined behavior
3023 in the function when compiling with the @option{-fsanitize=undefined} option.
3025 @item no_split_stack
3026 @cindex @code{no_split_stack} function attribute
3027 @opindex fsplit-stack
3028 If @option{-fsplit-stack} is given, functions have a small
3029 prologue which decides whether to split the stack.  Functions with the
3030 @code{no_split_stack} attribute do not have that prologue, and thus
3031 may run with only a small amount of stack space available.
3033 @item no_stack_limit
3034 @cindex @code{no_stack_limit} function attribute
3035 This attribute locally overrides the @option{-fstack-limit-register}
3036 and @option{-fstack-limit-symbol} command-line options; it has the effect
3037 of disabling stack limit checking in the function it applies to.
3039 @item noclone
3040 @cindex @code{noclone} function attribute
3041 This function attribute prevents a function from being considered for
3042 cloning---a mechanism that produces specialized copies of functions
3043 and which is (currently) performed by interprocedural constant
3044 propagation.
3046 @item noinline
3047 @cindex @code{noinline} function attribute
3048 This function attribute prevents a function from being considered for
3049 inlining.
3050 @c Don't enumerate the optimizations by name here; we try to be
3051 @c future-compatible with this mechanism.
3052 If the function does not have side effects, there are optimizations
3053 other than inlining that cause function calls to be optimized away,
3054 although the function call is live.  To keep such calls from being
3055 optimized away, put
3056 @smallexample
3057 asm ("");
3058 @end smallexample
3060 @noindent
3061 (@pxref{Extended Asm}) in the called function, to serve as a special
3062 side effect.
3064 @item noipa
3065 @cindex @code{noipa} function attribute
3066 Disable interprocedural optimizations between the function with this
3067 attribute and its callers, as if the body of the function is not available
3068 when optimizing callers and the callers are unavailable when optimizing
3069 the body.  This attribute implies @code{noinline}, @code{noclone} and
3070 @code{no_icf} attributes.    However, this attribute is not equivalent
3071 to a combination of other attributes, because its purpose is to suppress
3072 existing and future optimizations employing interprocedural analysis,
3073 including those that do not have an attribute suitable for disabling
3074 them individually.  This attribute is supported mainly for the purpose
3075 of testing the compiler.
3077 @item nonnull (@var{arg-index}, @dots{})
3078 @cindex @code{nonnull} function attribute
3079 @cindex functions with non-null pointer arguments
3080 The @code{nonnull} attribute specifies that some function parameters should
3081 be non-null pointers.  For instance, the declaration:
3083 @smallexample
3084 extern void *
3085 my_memcpy (void *dest, const void *src, size_t len)
3086         __attribute__((nonnull (1, 2)));
3087 @end smallexample
3089 @noindent
3090 causes the compiler to check that, in calls to @code{my_memcpy},
3091 arguments @var{dest} and @var{src} are non-null.  If the compiler
3092 determines that a null pointer is passed in an argument slot marked
3093 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3094 is issued.  The compiler may also choose to make optimizations based
3095 on the knowledge that certain function arguments will never be null.
3097 If no argument index list is given to the @code{nonnull} attribute,
3098 all pointer arguments are marked as non-null.  To illustrate, the
3099 following declaration is equivalent to the previous example:
3101 @smallexample
3102 extern void *
3103 my_memcpy (void *dest, const void *src, size_t len)
3104         __attribute__((nonnull));
3105 @end smallexample
3107 @item noplt
3108 @cindex @code{noplt} function attribute
3109 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3110 Calls to functions marked with this attribute in position-independent code
3111 do not use the PLT.
3113 @smallexample
3114 @group
3115 /* Externally defined function foo.  */
3116 int foo () __attribute__ ((noplt));
3119 main (/* @r{@dots{}} */)
3121   /* @r{@dots{}} */
3122   foo ();
3123   /* @r{@dots{}} */
3125 @end group
3126 @end smallexample
3128 The @code{noplt} attribute on function @code{foo}
3129 tells the compiler to assume that
3130 the function @code{foo} is externally defined and that the call to
3131 @code{foo} must avoid the PLT
3132 in position-independent code.
3134 In position-dependent code, a few targets also convert calls to
3135 functions that are marked to not use the PLT to use the GOT instead.
3137 @item noreturn
3138 @cindex @code{noreturn} function attribute
3139 @cindex functions that never return
3140 A few standard library functions, such as @code{abort} and @code{exit},
3141 cannot return.  GCC knows this automatically.  Some programs define
3142 their own functions that never return.  You can declare them
3143 @code{noreturn} to tell the compiler this fact.  For example,
3145 @smallexample
3146 @group
3147 void fatal () __attribute__ ((noreturn));
3149 void
3150 fatal (/* @r{@dots{}} */)
3152   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3153   exit (1);
3155 @end group
3156 @end smallexample
3158 The @code{noreturn} keyword tells the compiler to assume that
3159 @code{fatal} cannot return.  It can then optimize without regard to what
3160 would happen if @code{fatal} ever did return.  This makes slightly
3161 better code.  More importantly, it helps avoid spurious warnings of
3162 uninitialized variables.
3164 The @code{noreturn} keyword does not affect the exceptional path when that
3165 applies: a @code{noreturn}-marked function may still return to the caller
3166 by throwing an exception or calling @code{longjmp}.
3168 In order to preserve backtraces, GCC will never turn calls to
3169 @code{noreturn} functions into tail calls.
3171 Do not assume that registers saved by the calling function are
3172 restored before calling the @code{noreturn} function.
3174 It does not make sense for a @code{noreturn} function to have a return
3175 type other than @code{void}.
3177 @item nothrow
3178 @cindex @code{nothrow} function attribute
3179 The @code{nothrow} attribute is used to inform the compiler that a
3180 function cannot throw an exception.  For example, most functions in
3181 the standard C library can be guaranteed not to throw an exception
3182 with the notable exceptions of @code{qsort} and @code{bsearch} that
3183 take function pointer arguments.
3185 @item optimize
3186 @cindex @code{optimize} function attribute
3187 The @code{optimize} attribute is used to specify that a function is to
3188 be compiled with different optimization options than specified on the
3189 command line.  Arguments can either be numbers or strings.  Numbers
3190 are assumed to be an optimization level.  Strings that begin with
3191 @code{O} are assumed to be an optimization option, while other options
3192 are assumed to be used with a @code{-f} prefix.  You can also use the
3193 @samp{#pragma GCC optimize} pragma to set the optimization options
3194 that affect more than one function.
3195 @xref{Function Specific Option Pragmas}, for details about the
3196 @samp{#pragma GCC optimize} pragma.
3198 This attribute should be used for debugging purposes only.  It is not
3199 suitable in production code.
3201 @item patchable_function_entry
3202 @cindex @code{patchable_function_entry} function attribute
3203 @cindex extra NOP instructions at the function entry point
3204 In case the target's text segment can be made writable at run time by
3205 any means, padding the function entry with a number of NOPs can be
3206 used to provide a universal tool for instrumentation.
3208 The @code{patchable_function_entry} function attribute can be used to
3209 change the number of NOPs to any desired value.  The two-value syntax
3210 is the same as for the command-line switch
3211 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3212 the function entry point before the @var{M}th NOP instruction.
3213 @var{M} defaults to 0 if omitted e.g. function entry point is before
3214 the first NOP.
3216 If patchable function entries are enabled globally using the command-line
3217 option @option{-fpatchable-function-entry=N,M}, then you must disable
3218 instrumentation on all functions that are part of the instrumentation
3219 framework with the attribute @code{patchable_function_entry (0)}
3220 to prevent recursion.
3222 @item pure
3223 @cindex @code{pure} function attribute
3224 @cindex functions that have no side effects
3225 Many functions have no effects except the return value and their
3226 return value depends only on the parameters and/or global variables.
3227 Calls to such functions can be subject
3228 to common subexpression elimination and loop optimization just as an
3229 arithmetic operator would be.  These functions should be declared
3230 with the attribute @code{pure}.  For example,
3232 @smallexample
3233 int square (int) __attribute__ ((pure));
3234 @end smallexample
3236 @noindent
3237 says that the hypothetical function @code{square} is safe to call
3238 fewer times than the program says.
3240 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3241 Interesting non-pure functions are functions with infinite loops or those
3242 depending on volatile memory or other system resource, that may change between
3243 two consecutive calls (such as @code{feof} in a multithreading environment).
3245 The @code{pure} attribute imposes similar but looser restrictions on
3246 a function's defintion than the @code{const} attribute: it allows the
3247 function to read global variables.  Decorating the same function with
3248 both the @code{pure} and the @code{const} attribute is diagnosed.
3249 Because a @code{pure} function cannot have any side effects it does not
3250 make sense for such a function to return @code{void}.  Declaring such
3251 a function is diagnosed.
3253 @item returns_nonnull
3254 @cindex @code{returns_nonnull} function attribute
3255 The @code{returns_nonnull} attribute specifies that the function
3256 return value should be a non-null pointer.  For instance, the declaration:
3258 @smallexample
3259 extern void *
3260 mymalloc (size_t len) __attribute__((returns_nonnull));
3261 @end smallexample
3263 @noindent
3264 lets the compiler optimize callers based on the knowledge
3265 that the return value will never be null.
3267 @item returns_twice
3268 @cindex @code{returns_twice} function attribute
3269 @cindex functions that return more than once
3270 The @code{returns_twice} attribute tells the compiler that a function may
3271 return more than one time.  The compiler ensures that all registers
3272 are dead before calling such a function and emits a warning about
3273 the variables that may be clobbered after the second return from the
3274 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3275 The @code{longjmp}-like counterpart of such function, if any, might need
3276 to be marked with the @code{noreturn} attribute.
3278 @item section ("@var{section-name}")
3279 @cindex @code{section} function attribute
3280 @cindex functions in arbitrary sections
3281 Normally, the compiler places the code it generates in the @code{text} section.
3282 Sometimes, however, you need additional sections, or you need certain
3283 particular functions to appear in special sections.  The @code{section}
3284 attribute specifies that a function lives in a particular section.
3285 For example, the declaration:
3287 @smallexample
3288 extern void foobar (void) __attribute__ ((section ("bar")));
3289 @end smallexample
3291 @noindent
3292 puts the function @code{foobar} in the @code{bar} section.
3294 Some file formats do not support arbitrary sections so the @code{section}
3295 attribute is not available on all platforms.
3296 If you need to map the entire contents of a module to a particular
3297 section, consider using the facilities of the linker instead.
3299 @item sentinel
3300 @cindex @code{sentinel} function attribute
3301 This function attribute ensures that a parameter in a function call is
3302 an explicit @code{NULL}.  The attribute is only valid on variadic
3303 functions.  By default, the sentinel is located at position zero, the
3304 last parameter of the function call.  If an optional integer position
3305 argument P is supplied to the attribute, the sentinel must be located at
3306 position P counting backwards from the end of the argument list.
3308 @smallexample
3309 __attribute__ ((sentinel))
3310 is equivalent to
3311 __attribute__ ((sentinel(0)))
3312 @end smallexample
3314 The attribute is automatically set with a position of 0 for the built-in
3315 functions @code{execl} and @code{execlp}.  The built-in function
3316 @code{execle} has the attribute set with a position of 1.
3318 A valid @code{NULL} in this context is defined as zero with any pointer
3319 type.  If your system defines the @code{NULL} macro with an integer type
3320 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3321 with a copy that redefines NULL appropriately.
3323 The warnings for missing or incorrect sentinels are enabled with
3324 @option{-Wformat}.
3326 @item simd
3327 @itemx simd("@var{mask}")
3328 @cindex @code{simd} function attribute
3329 This attribute enables creation of one or more function versions that
3330 can process multiple arguments using SIMD instructions from a
3331 single invocation.  Specifying this attribute allows compiler to
3332 assume that such versions are available at link time (provided
3333 in the same or another translation unit).  Generated versions are
3334 target-dependent and described in the corresponding Vector ABI document.  For
3335 x86_64 target this document can be found
3336 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3338 The optional argument @var{mask} may have the value
3339 @code{notinbranch} or @code{inbranch},
3340 and instructs the compiler to generate non-masked or masked
3341 clones correspondingly. By default, all clones are generated.
3343 If the attribute is specified and @code{#pragma omp declare simd} is
3344 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3345 switch is specified, then the attribute is ignored.
3347 @item stack_protect
3348 @cindex @code{stack_protect} function attribute
3349 This attribute adds stack protection code to the function if 
3350 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3351 or @option{-fstack-protector-explicit} are set.
3353 @item target (@var{options})
3354 @cindex @code{target} function attribute
3355 Multiple target back ends implement the @code{target} attribute
3356 to specify that a function is to
3357 be compiled with different target options than specified on the
3358 command line.  This can be used for instance to have functions
3359 compiled with a different ISA (instruction set architecture) than the
3360 default.  You can also use the @samp{#pragma GCC target} pragma to set
3361 more than one function to be compiled with specific target options.
3362 @xref{Function Specific Option Pragmas}, for details about the
3363 @samp{#pragma GCC target} pragma.
3365 For instance, on an x86, you could declare one function with the
3366 @code{target("sse4.1,arch=core2")} attribute and another with
3367 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3368 compiling the first function with @option{-msse4.1} and
3369 @option{-march=core2} options, and the second function with
3370 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3371 to make sure that a function is only invoked on a machine that
3372 supports the particular ISA it is compiled for (for example by using
3373 @code{cpuid} on x86 to determine what feature bits and architecture
3374 family are used).
3376 @smallexample
3377 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3378 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3379 @end smallexample
3381 You can either use multiple
3382 strings separated by commas to specify multiple options,
3383 or separate the options with a comma (@samp{,}) within a single string.
3385 The options supported are specific to each target; refer to @ref{x86
3386 Function Attributes}, @ref{PowerPC Function Attributes},
3387 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3388 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3389 for details.
3391 @item target_clones (@var{options})
3392 @cindex @code{target_clones} function attribute
3393 The @code{target_clones} attribute is used to specify that a function
3394 be cloned into multiple versions compiled with different target options
3395 than specified on the command line.  The supported options and restrictions
3396 are the same as for @code{target} attribute.
3398 For instance, on an x86, you could compile a function with
3399 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3400 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3402 On a PowerPC, you can compile a function with
3403 @code{target_clones("cpu=power9,default")}.  GCC will create two
3404 function clones, one compiled with @option{-mcpu=power9} and another
3405 with the default options.  GCC must be configured to use GLIBC 2.23 or
3406 newer in order to use the @code{target_clones} attribute.
3408 It also creates a resolver function (see
3409 the @code{ifunc} attribute above) that dynamically selects a clone
3410 suitable for current architecture.  The resolver is created only if there
3411 is a usage of a function with @code{target_clones} attribute.
3413 @item unused
3414 @cindex @code{unused} function attribute
3415 This attribute, attached to a function, means that the function is meant
3416 to be possibly unused.  GCC does not produce a warning for this
3417 function.
3419 @item used
3420 @cindex @code{used} function attribute
3421 This attribute, attached to a function, means that code must be emitted
3422 for the function even if it appears that the function is not referenced.
3423 This is useful, for example, when the function is referenced only in
3424 inline assembly.
3426 When applied to a member function of a C++ class template, the
3427 attribute also means that the function is instantiated if the
3428 class itself is instantiated.
3430 @item visibility ("@var{visibility_type}")
3431 @cindex @code{visibility} function attribute
3432 This attribute affects the linkage of the declaration to which it is attached.
3433 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3434 (@pxref{Common Type Attributes}) as well as functions.
3436 There are four supported @var{visibility_type} values: default,
3437 hidden, protected or internal visibility.
3439 @smallexample
3440 void __attribute__ ((visibility ("protected")))
3441 f () @{ /* @r{Do something.} */; @}
3442 int i __attribute__ ((visibility ("hidden")));
3443 @end smallexample
3445 The possible values of @var{visibility_type} correspond to the
3446 visibility settings in the ELF gABI.
3448 @table @code
3449 @c keep this list of visibilities in alphabetical order.
3451 @item default
3452 Default visibility is the normal case for the object file format.
3453 This value is available for the visibility attribute to override other
3454 options that may change the assumed visibility of entities.
3456 On ELF, default visibility means that the declaration is visible to other
3457 modules and, in shared libraries, means that the declared entity may be
3458 overridden.
3460 On Darwin, default visibility means that the declaration is visible to
3461 other modules.
3463 Default visibility corresponds to ``external linkage'' in the language.
3465 @item hidden
3466 Hidden visibility indicates that the entity declared has a new
3467 form of linkage, which we call ``hidden linkage''.  Two
3468 declarations of an object with hidden linkage refer to the same object
3469 if they are in the same shared object.
3471 @item internal
3472 Internal visibility is like hidden visibility, but with additional
3473 processor specific semantics.  Unless otherwise specified by the
3474 psABI, GCC defines internal visibility to mean that a function is
3475 @emph{never} called from another module.  Compare this with hidden
3476 functions which, while they cannot be referenced directly by other
3477 modules, can be referenced indirectly via function pointers.  By
3478 indicating that a function cannot be called from outside the module,
3479 GCC may for instance omit the load of a PIC register since it is known
3480 that the calling function loaded the correct value.
3482 @item protected
3483 Protected visibility is like default visibility except that it
3484 indicates that references within the defining module bind to the
3485 definition in that module.  That is, the declared entity cannot be
3486 overridden by another module.
3488 @end table
3490 All visibilities are supported on many, but not all, ELF targets
3491 (supported when the assembler supports the @samp{.visibility}
3492 pseudo-op).  Default visibility is supported everywhere.  Hidden
3493 visibility is supported on Darwin targets.
3495 The visibility attribute should be applied only to declarations that
3496 would otherwise have external linkage.  The attribute should be applied
3497 consistently, so that the same entity should not be declared with
3498 different settings of the attribute.
3500 In C++, the visibility attribute applies to types as well as functions
3501 and objects, because in C++ types have linkage.  A class must not have
3502 greater visibility than its non-static data member types and bases,
3503 and class members default to the visibility of their class.  Also, a
3504 declaration without explicit visibility is limited to the visibility
3505 of its type.
3507 In C++, you can mark member functions and static member variables of a
3508 class with the visibility attribute.  This is useful if you know a
3509 particular method or static member variable should only be used from
3510 one shared object; then you can mark it hidden while the rest of the
3511 class has default visibility.  Care must be taken to avoid breaking
3512 the One Definition Rule; for example, it is usually not useful to mark
3513 an inline method as hidden without marking the whole class as hidden.
3515 A C++ namespace declaration can also have the visibility attribute.
3517 @smallexample
3518 namespace nspace1 __attribute__ ((visibility ("protected")))
3519 @{ /* @r{Do something.} */; @}
3520 @end smallexample
3522 This attribute applies only to the particular namespace body, not to
3523 other definitions of the same namespace; it is equivalent to using
3524 @samp{#pragma GCC visibility} before and after the namespace
3525 definition (@pxref{Visibility Pragmas}).
3527 In C++, if a template argument has limited visibility, this
3528 restriction is implicitly propagated to the template instantiation.
3529 Otherwise, template instantiations and specializations default to the
3530 visibility of their template.
3532 If both the template and enclosing class have explicit visibility, the
3533 visibility from the template is used.
3535 @item warn_unused_result
3536 @cindex @code{warn_unused_result} function attribute
3537 The @code{warn_unused_result} attribute causes a warning to be emitted
3538 if a caller of the function with this attribute does not use its
3539 return value.  This is useful for functions where not checking
3540 the result is either a security problem or always a bug, such as
3541 @code{realloc}.
3543 @smallexample
3544 int fn () __attribute__ ((warn_unused_result));
3545 int foo ()
3547   if (fn () < 0) return -1;
3548   fn ();
3549   return 0;
3551 @end smallexample
3553 @noindent
3554 results in warning on line 5.
3556 @item weak
3557 @cindex @code{weak} function attribute
3558 The @code{weak} attribute causes the declaration to be emitted as a weak
3559 symbol rather than a global.  This is primarily useful in defining
3560 library functions that can be overridden in user code, though it can
3561 also be used with non-function declarations.  Weak symbols are supported
3562 for ELF targets, and also for a.out targets when using the GNU assembler
3563 and linker.
3565 @item weakref
3566 @itemx weakref ("@var{target}")
3567 @cindex @code{weakref} function attribute
3568 The @code{weakref} attribute marks a declaration as a weak reference.
3569 Without arguments, it should be accompanied by an @code{alias} attribute
3570 naming the target symbol.  Optionally, the @var{target} may be given as
3571 an argument to @code{weakref} itself.  In either case, @code{weakref}
3572 implicitly marks the declaration as @code{weak}.  Without a
3573 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3574 @code{weakref} is equivalent to @code{weak}.
3576 @smallexample
3577 static int x() __attribute__ ((weakref ("y")));
3578 /* is equivalent to... */
3579 static int x() __attribute__ ((weak, weakref, alias ("y")));
3580 /* and to... */
3581 static int x() __attribute__ ((weakref));
3582 static int x() __attribute__ ((alias ("y")));
3583 @end smallexample
3585 A weak reference is an alias that does not by itself require a
3586 definition to be given for the target symbol.  If the target symbol is
3587 only referenced through weak references, then it becomes a @code{weak}
3588 undefined symbol.  If it is directly referenced, however, then such
3589 strong references prevail, and a definition is required for the
3590 symbol, not necessarily in the same translation unit.
3592 The effect is equivalent to moving all references to the alias to a
3593 separate translation unit, renaming the alias to the aliased symbol,
3594 declaring it as weak, compiling the two separate translation units and
3595 performing a reloadable link on them.
3597 At present, a declaration to which @code{weakref} is attached can
3598 only be @code{static}.
3601 @end table
3603 @c This is the end of the target-independent attribute table
3605 @node AArch64 Function Attributes
3606 @subsection AArch64 Function Attributes
3608 The following target-specific function attributes are available for the
3609 AArch64 target.  For the most part, these options mirror the behavior of
3610 similar command-line options (@pxref{AArch64 Options}), but on a
3611 per-function basis.
3613 @table @code
3614 @item general-regs-only
3615 @cindex @code{general-regs-only} function attribute, AArch64
3616 Indicates that no floating-point or Advanced SIMD registers should be
3617 used when generating code for this function.  If the function explicitly
3618 uses floating-point code, then the compiler gives an error.  This is
3619 the same behavior as that of the command-line option
3620 @option{-mgeneral-regs-only}.
3622 @item fix-cortex-a53-835769
3623 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3624 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3625 applied to this function.  To explicitly disable the workaround for this
3626 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3627 This corresponds to the behavior of the command line options
3628 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3630 @item cmodel=
3631 @cindex @code{cmodel=} function attribute, AArch64
3632 Indicates that code should be generated for a particular code model for
3633 this function.  The behavior and permissible arguments are the same as
3634 for the command line option @option{-mcmodel=}.
3636 @item strict-align
3637 @itemx no-strict-align
3638 @cindex @code{strict-align} function attribute, AArch64
3639 @code{strict-align} indicates that the compiler should not assume that unaligned
3640 memory references are handled by the system.  To allow the compiler to assume
3641 that aligned memory references are handled by the system, the inverse attribute
3642 @code{no-strict-align} can be specified.  The behavior is same as for the
3643 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3645 @item omit-leaf-frame-pointer
3646 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3647 Indicates that the frame pointer should be omitted for a leaf function call.
3648 To keep the frame pointer, the inverse attribute
3649 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3650 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3651 and @option{-mno-omit-leaf-frame-pointer}.
3653 @item tls-dialect=
3654 @cindex @code{tls-dialect=} function attribute, AArch64
3655 Specifies the TLS dialect to use for this function.  The behavior and
3656 permissible arguments are the same as for the command-line option
3657 @option{-mtls-dialect=}.
3659 @item arch=
3660 @cindex @code{arch=} function attribute, AArch64
3661 Specifies the architecture version and architectural extensions to use
3662 for this function.  The behavior and permissible arguments are the same as
3663 for the @option{-march=} command-line option.
3665 @item tune=
3666 @cindex @code{tune=} function attribute, AArch64
3667 Specifies the core for which to tune the performance of this function.
3668 The behavior and permissible arguments are the same as for the @option{-mtune=}
3669 command-line option.
3671 @item cpu=
3672 @cindex @code{cpu=} function attribute, AArch64
3673 Specifies the core for which to tune the performance of this function and also
3674 whose architectural features to use.  The behavior and valid arguments are the
3675 same as for the @option{-mcpu=} command-line option.
3677 @item sign-return-address
3678 @cindex @code{sign-return-address} function attribute, AArch64
3679 Select the function scope on which return address signing will be applied.  The
3680 behavior and permissible arguments are the same as for the command-line option
3681 @option{-msign-return-address=}.  The default value is @code{none}.
3683 @end table
3685 The above target attributes can be specified as follows:
3687 @smallexample
3688 __attribute__((target("@var{attr-string}")))
3690 f (int a)
3692   return a + 5;
3694 @end smallexample
3696 where @code{@var{attr-string}} is one of the attribute strings specified above.
3698 Additionally, the architectural extension string may be specified on its
3699 own.  This can be used to turn on and off particular architectural extensions
3700 without having to specify a particular architecture version or core.  Example:
3702 @smallexample
3703 __attribute__((target("+crc+nocrypto")))
3705 foo (int a)
3707   return a + 5;
3709 @end smallexample
3711 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3712 extension and disables the @code{crypto} extension for the function @code{foo}
3713 without modifying an existing @option{-march=} or @option{-mcpu} option.
3715 Multiple target function attributes can be specified by separating them with
3716 a comma.  For example:
3717 @smallexample
3718 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3720 foo (int a)
3722   return a + 5;
3724 @end smallexample
3726 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3727 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3729 @subsubsection Inlining rules
3730 Specifying target attributes on individual functions or performing link-time
3731 optimization across translation units compiled with different target options
3732 can affect function inlining rules:
3734 In particular, a caller function can inline a callee function only if the
3735 architectural features available to the callee are a subset of the features
3736 available to the caller.
3737 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3738 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3739 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3740 because the all the architectural features that function @code{bar} requires
3741 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3742 inline function @code{foo}.
3744 Additionally inlining a function compiled with @option{-mstrict-align} into a
3745 function compiled without @code{-mstrict-align} is not allowed.
3746 However, inlining a function compiled without @option{-mstrict-align} into a
3747 function compiled with @option{-mstrict-align} is allowed.
3749 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3750 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3751 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3752 architectural feature rules specified above.
3754 @node ARC Function Attributes
3755 @subsection ARC Function Attributes
3757 These function attributes are supported by the ARC back end:
3759 @table @code
3760 @item interrupt
3761 @cindex @code{interrupt} function attribute, ARC
3762 Use this attribute to indicate
3763 that the specified function is an interrupt handler.  The compiler generates
3764 function entry and exit sequences suitable for use in an interrupt handler
3765 when this attribute is present.
3767 On the ARC, you must specify the kind of interrupt to be handled
3768 in a parameter to the interrupt attribute like this:
3770 @smallexample
3771 void f () __attribute__ ((interrupt ("ilink1")));
3772 @end smallexample
3774 Permissible values for this parameter are: @w{@code{ilink1}} and
3775 @w{@code{ilink2}}.
3777 @item long_call
3778 @itemx medium_call
3779 @itemx short_call
3780 @cindex @code{long_call} function attribute, ARC
3781 @cindex @code{medium_call} function attribute, ARC
3782 @cindex @code{short_call} function attribute, ARC
3783 @cindex indirect calls, ARC
3784 These attributes specify how a particular function is called.
3785 These attributes override the
3786 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3787 command-line switches and @code{#pragma long_calls} settings.
3789 For ARC, a function marked with the @code{long_call} attribute is
3790 always called using register-indirect jump-and-link instructions,
3791 thereby enabling the called function to be placed anywhere within the
3792 32-bit address space.  A function marked with the @code{medium_call}
3793 attribute will always be close enough to be called with an unconditional
3794 branch-and-link instruction, which has a 25-bit offset from
3795 the call site.  A function marked with the @code{short_call}
3796 attribute will always be close enough to be called with a conditional
3797 branch-and-link instruction, which has a 21-bit offset from
3798 the call site.
3800 @item jli_always
3801 @cindex @code{jli_always} function attribute, ARC
3802 Forces a particular function to be called using @code{jli}
3803 instruction.  The @code{jli} instruction makes use of a table stored
3804 into @code{.jlitab} section, which holds the location of the functions
3805 which are addressed using this instruction.
3807 @item jli_fixed
3808 @cindex @code{jli_fixed} function attribute, ARC
3809 Identical like the above one, but the location of the function in the
3810 @code{jli} table is known and given as an attribute parameter.
3812 @item secure_call
3813 @cindex @code{secure_call} function attribute, ARC
3814 This attribute allows one to mark secure-code functions that are
3815 callable from normal mode.  The location of the secure call function
3816 into the @code{sjli} table needs to be passed as argument.
3818 @end table
3820 @node ARM Function Attributes
3821 @subsection ARM Function Attributes
3823 These function attributes are supported for ARM targets:
3825 @table @code
3826 @item interrupt
3827 @cindex @code{interrupt} function attribute, ARM
3828 Use this attribute to indicate
3829 that the specified function is an interrupt handler.  The compiler generates
3830 function entry and exit sequences suitable for use in an interrupt handler
3831 when this attribute is present.
3833 You can specify the kind of interrupt to be handled by
3834 adding an optional parameter to the interrupt attribute like this:
3836 @smallexample
3837 void f () __attribute__ ((interrupt ("IRQ")));
3838 @end smallexample
3840 @noindent
3841 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3842 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3844 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3845 may be called with a word-aligned stack pointer.
3847 @item isr
3848 @cindex @code{isr} function attribute, ARM
3849 Use this attribute on ARM to write Interrupt Service Routines. This is an
3850 alias to the @code{interrupt} attribute above.
3852 @item long_call
3853 @itemx short_call
3854 @cindex @code{long_call} function attribute, ARM
3855 @cindex @code{short_call} function attribute, ARM
3856 @cindex indirect calls, ARM
3857 These attributes specify how a particular function is called.
3858 These attributes override the
3859 @option{-mlong-calls} (@pxref{ARM Options})
3860 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3861 @code{long_call} attribute indicates that the function might be far
3862 away from the call site and require a different (more expensive)
3863 calling sequence.   The @code{short_call} attribute always places
3864 the offset to the function from the call site into the @samp{BL}
3865 instruction directly.
3867 @item naked
3868 @cindex @code{naked} function attribute, ARM
3869 This attribute allows the compiler to construct the
3870 requisite function declaration, while allowing the body of the
3871 function to be assembly code. The specified function will not have
3872 prologue/epilogue sequences generated by the compiler. Only basic
3873 @code{asm} statements can safely be included in naked functions
3874 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3875 basic @code{asm} and C code may appear to work, they cannot be
3876 depended upon to work reliably and are not supported.
3878 @item pcs
3879 @cindex @code{pcs} function attribute, ARM
3881 The @code{pcs} attribute can be used to control the calling convention
3882 used for a function on ARM.  The attribute takes an argument that specifies
3883 the calling convention to use.
3885 When compiling using the AAPCS ABI (or a variant of it) then valid
3886 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3887 order to use a variant other than @code{"aapcs"} then the compiler must
3888 be permitted to use the appropriate co-processor registers (i.e., the
3889 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3890 For example,
3892 @smallexample
3893 /* Argument passed in r0, and result returned in r0+r1.  */
3894 double f2d (float) __attribute__((pcs("aapcs")));
3895 @end smallexample
3897 Variadic functions always use the @code{"aapcs"} calling convention and
3898 the compiler rejects attempts to specify an alternative.
3900 @item target (@var{options})
3901 @cindex @code{target} function attribute
3902 As discussed in @ref{Common Function Attributes}, this attribute 
3903 allows specification of target-specific compilation options.
3905 On ARM, the following options are allowed:
3907 @table @samp
3908 @item thumb
3909 @cindex @code{target("thumb")} function attribute, ARM
3910 Force code generation in the Thumb (T16/T32) ISA, depending on the
3911 architecture level.
3913 @item arm
3914 @cindex @code{target("arm")} function attribute, ARM
3915 Force code generation in the ARM (A32) ISA.
3917 Functions from different modes can be inlined in the caller's mode.
3919 @item fpu=
3920 @cindex @code{target("fpu=")} function attribute, ARM
3921 Specifies the fpu for which to tune the performance of this function.
3922 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3923 command-line option.
3925 @item arch=
3926 @cindex @code{arch=} function attribute, ARM
3927 Specifies the architecture version and architectural extensions to use
3928 for this function.  The behavior and permissible arguments are the same as
3929 for the @option{-march=} command-line option.
3931 The above target attributes can be specified as follows:
3933 @smallexample
3934 __attribute__((target("arch=armv8-a+crc")))
3936 f (int a)
3938   return a + 5;
3940 @end smallexample
3942 Additionally, the architectural extension string may be specified on its
3943 own.  This can be used to turn on and off particular architectural extensions
3944 without having to specify a particular architecture version or core.  Example:
3946 @smallexample
3947 __attribute__((target("+crc+nocrypto")))
3949 foo (int a)
3951   return a + 5;
3953 @end smallexample
3955 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3956 extension and disables the @code{crypto} extension for the function @code{foo}
3957 without modifying an existing @option{-march=} or @option{-mcpu} option.
3959 @end table
3961 @end table
3963 @node AVR Function Attributes
3964 @subsection AVR Function Attributes
3966 These function attributes are supported by the AVR back end:
3968 @table @code
3969 @item interrupt
3970 @cindex @code{interrupt} function attribute, AVR
3971 Use this attribute to indicate
3972 that the specified function is an interrupt handler.  The compiler generates
3973 function entry and exit sequences suitable for use in an interrupt handler
3974 when this attribute is present.
3976 On the AVR, the hardware globally disables interrupts when an
3977 interrupt is executed.  The first instruction of an interrupt handler
3978 declared with this attribute is a @code{SEI} instruction to
3979 re-enable interrupts.  See also the @code{signal} function attribute
3980 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3981 @code{interrupt} are specified for the same function, @code{signal}
3982 is silently ignored.
3984 @item naked
3985 @cindex @code{naked} function attribute, AVR
3986 This attribute allows the compiler to construct the
3987 requisite function declaration, while allowing the body of the
3988 function to be assembly code. The specified function will not have
3989 prologue/epilogue sequences generated by the compiler. Only basic
3990 @code{asm} statements can safely be included in naked functions
3991 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3992 basic @code{asm} and C code may appear to work, they cannot be
3993 depended upon to work reliably and are not supported.
3995 @item no_gccisr
3996 @cindex @code{no_gccisr} function attribute, AVR
3997 Do not use @code{__gcc_isr} pseudo instructions in a function with
3998 the @code{interrupt} or @code{signal} attribute aka. interrupt
3999 service routine (ISR).
4000 Use this attribute if the preamble of the ISR prologue should always read
4001 @example
4002 push  __zero_reg__
4003 push  __tmp_reg__
4004 in    __tmp_reg__, __SREG__
4005 push  __tmp_reg__
4006 clr   __zero_reg__
4007 @end example
4008 and accordingly for the postamble of the epilogue --- no matter whether
4009 the mentioned registers are actually used in the ISR or not.
4010 Situations where you might want to use this attribute include:
4011 @itemize @bullet
4012 @item
4013 Code that (effectively) clobbers bits of @code{SREG} other than the
4014 @code{I}-flag by writing to the memory location of @code{SREG}.
4015 @item
4016 Code that uses inline assembler to jump to a different function which
4017 expects (parts of) the prologue code as outlined above to be present.
4018 @end itemize
4019 To disable @code{__gcc_isr} generation for the whole compilation unit,
4020 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4022 @item OS_main
4023 @itemx OS_task
4024 @cindex @code{OS_main} function attribute, AVR
4025 @cindex @code{OS_task} function attribute, AVR
4026 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4027 do not save/restore any call-saved register in their prologue/epilogue.
4029 The @code{OS_main} attribute can be used when there @emph{is
4030 guarantee} that interrupts are disabled at the time when the function
4031 is entered.  This saves resources when the stack pointer has to be
4032 changed to set up a frame for local variables.
4034 The @code{OS_task} attribute can be used when there is @emph{no
4035 guarantee} that interrupts are disabled at that time when the function
4036 is entered like for, e@.g@. task functions in a multi-threading operating
4037 system. In that case, changing the stack pointer register is
4038 guarded by save/clear/restore of the global interrupt enable flag.
4040 The differences to the @code{naked} function attribute are:
4041 @itemize @bullet
4042 @item @code{naked} functions do not have a return instruction whereas 
4043 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4044 @code{RETI} return instruction.
4045 @item @code{naked} functions do not set up a frame for local variables
4046 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4047 as needed.
4048 @end itemize
4050 @item signal
4051 @cindex @code{signal} function attribute, AVR
4052 Use this attribute on the AVR to indicate that the specified
4053 function is an interrupt handler.  The compiler generates function
4054 entry and exit sequences suitable for use in an interrupt handler when this
4055 attribute is present.
4057 See also the @code{interrupt} function attribute. 
4059 The AVR hardware globally disables interrupts when an interrupt is executed.
4060 Interrupt handler functions defined with the @code{signal} attribute
4061 do not re-enable interrupts.  It is save to enable interrupts in a
4062 @code{signal} handler.  This ``save'' only applies to the code
4063 generated by the compiler and not to the IRQ layout of the
4064 application which is responsibility of the application.
4066 If both @code{signal} and @code{interrupt} are specified for the same
4067 function, @code{signal} is silently ignored.
4068 @end table
4070 @node Blackfin Function Attributes
4071 @subsection Blackfin Function Attributes
4073 These function attributes are supported by the Blackfin back end:
4075 @table @code
4077 @item exception_handler
4078 @cindex @code{exception_handler} function attribute
4079 @cindex exception handler functions, Blackfin
4080 Use this attribute on the Blackfin to indicate that the specified function
4081 is an exception handler.  The compiler generates function entry and
4082 exit sequences suitable for use in an exception handler when this
4083 attribute is present.
4085 @item interrupt_handler
4086 @cindex @code{interrupt_handler} function attribute, Blackfin
4087 Use this attribute to
4088 indicate that the specified function is an interrupt handler.  The compiler
4089 generates function entry and exit sequences suitable for use in an
4090 interrupt handler when this attribute is present.
4092 @item kspisusp
4093 @cindex @code{kspisusp} function attribute, Blackfin
4094 @cindex User stack pointer in interrupts on the Blackfin
4095 When used together with @code{interrupt_handler}, @code{exception_handler}
4096 or @code{nmi_handler}, code is generated to load the stack pointer
4097 from the USP register in the function prologue.
4099 @item l1_text
4100 @cindex @code{l1_text} function attribute, Blackfin
4101 This attribute specifies a function to be placed into L1 Instruction
4102 SRAM@. The function is put into a specific section named @code{.l1.text}.
4103 With @option{-mfdpic}, function calls with a such function as the callee
4104 or caller uses inlined PLT.
4106 @item l2
4107 @cindex @code{l2} function attribute, Blackfin
4108 This attribute specifies a function to be placed into L2
4109 SRAM. The function is put into a specific section named
4110 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4111 an inlined PLT.
4113 @item longcall
4114 @itemx shortcall
4115 @cindex indirect calls, Blackfin
4116 @cindex @code{longcall} function attribute, Blackfin
4117 @cindex @code{shortcall} function attribute, Blackfin
4118 The @code{longcall} attribute
4119 indicates that the function might be far away from the call site and
4120 require a different (more expensive) calling sequence.  The
4121 @code{shortcall} attribute indicates that the function is always close
4122 enough for the shorter calling sequence to be used.  These attributes
4123 override the @option{-mlongcall} switch.
4125 @item nesting
4126 @cindex @code{nesting} function attribute, Blackfin
4127 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4128 Use this attribute together with @code{interrupt_handler},
4129 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4130 entry code should enable nested interrupts or exceptions.
4132 @item nmi_handler
4133 @cindex @code{nmi_handler} function attribute, Blackfin
4134 @cindex NMI handler functions on the Blackfin processor
4135 Use this attribute on the Blackfin to indicate that the specified function
4136 is an NMI handler.  The compiler generates function entry and
4137 exit sequences suitable for use in an NMI handler when this
4138 attribute is present.
4140 @item saveall
4141 @cindex @code{saveall} function attribute, Blackfin
4142 @cindex save all registers on the Blackfin
4143 Use this attribute to indicate that
4144 all registers except the stack pointer should be saved in the prologue
4145 regardless of whether they are used or not.
4146 @end table
4148 @node CR16 Function Attributes
4149 @subsection CR16 Function Attributes
4151 These function attributes are supported by the CR16 back end:
4153 @table @code
4154 @item interrupt
4155 @cindex @code{interrupt} function attribute, CR16
4156 Use this attribute to indicate
4157 that the specified function is an interrupt handler.  The compiler generates
4158 function entry and exit sequences suitable for use in an interrupt handler
4159 when this attribute is present.
4160 @end table
4162 @node C-SKY Function Attributes
4163 @subsection C-SKY Function Attributes
4165 These function attributes are supported by the C-SKY back end:
4167 @table @code
4168 @item interrupt
4169 @itemx isr
4170 @cindex @code{interrupt} function attribute, C-SKY
4171 @cindex @code{isr} function attribute, C-SKY
4172 Use these attributes to indicate that the specified function
4173 is an interrupt handler.
4174 The compiler generates function entry and exit sequences suitable for
4175 use in an interrupt handler when either of these attributes are present.
4177 Use of these options requires the @option{-mistack} command-line option
4178 to enable support for the necessary interrupt stack instructions.  They
4179 are ignored with a warning otherwise.  @xref{C-SKY Options}.
4181 @item naked
4182 @cindex @code{naked} function attribute, C-SKY
4183 This attribute allows the compiler to construct the
4184 requisite function declaration, while allowing the body of the
4185 function to be assembly code. The specified function will not have
4186 prologue/epilogue sequences generated by the compiler. Only basic
4187 @code{asm} statements can safely be included in naked functions
4188 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4189 basic @code{asm} and C code may appear to work, they cannot be
4190 depended upon to work reliably and are not supported.
4191 @end table
4194 @node Epiphany Function Attributes
4195 @subsection Epiphany Function Attributes
4197 These function attributes are supported by the Epiphany back end:
4199 @table @code
4200 @item disinterrupt
4201 @cindex @code{disinterrupt} function attribute, Epiphany
4202 This attribute causes the compiler to emit
4203 instructions to disable interrupts for the duration of the given
4204 function.
4206 @item forwarder_section
4207 @cindex @code{forwarder_section} function attribute, Epiphany
4208 This attribute modifies the behavior of an interrupt handler.
4209 The interrupt handler may be in external memory which cannot be
4210 reached by a branch instruction, so generate a local memory trampoline
4211 to transfer control.  The single parameter identifies the section where
4212 the trampoline is placed.
4214 @item interrupt
4215 @cindex @code{interrupt} function attribute, Epiphany
4216 Use this attribute to indicate
4217 that the specified function is an interrupt handler.  The compiler generates
4218 function entry and exit sequences suitable for use in an interrupt handler
4219 when this attribute is present.  It may also generate
4220 a special section with code to initialize the interrupt vector table.
4222 On Epiphany targets one or more optional parameters can be added like this:
4224 @smallexample
4225 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4226 @end smallexample
4228 Permissible values for these parameters are: @w{@code{reset}},
4229 @w{@code{software_exception}}, @w{@code{page_miss}},
4230 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4231 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4232 Multiple parameters indicate that multiple entries in the interrupt
4233 vector table should be initialized for this function, i.e.@: for each
4234 parameter @w{@var{name}}, a jump to the function is emitted in
4235 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4236 entirely, in which case no interrupt vector table entry is provided.
4238 Note that interrupts are enabled inside the function
4239 unless the @code{disinterrupt} attribute is also specified.
4241 The following examples are all valid uses of these attributes on
4242 Epiphany targets:
4243 @smallexample
4244 void __attribute__ ((interrupt)) universal_handler ();
4245 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4246 void __attribute__ ((interrupt ("dma0, dma1"))) 
4247   universal_dma_handler ();
4248 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4249   fast_timer_handler ();
4250 void __attribute__ ((interrupt ("dma0, dma1"), 
4251                      forwarder_section ("tramp")))
4252   external_dma_handler ();
4253 @end smallexample
4255 @item long_call
4256 @itemx short_call
4257 @cindex @code{long_call} function attribute, Epiphany
4258 @cindex @code{short_call} function attribute, Epiphany
4259 @cindex indirect calls, Epiphany
4260 These attributes specify how a particular function is called.
4261 These attributes override the
4262 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4263 command-line switch and @code{#pragma long_calls} settings.
4264 @end table
4267 @node H8/300 Function Attributes
4268 @subsection H8/300 Function Attributes
4270 These function attributes are available for H8/300 targets:
4272 @table @code
4273 @item function_vector
4274 @cindex @code{function_vector} function attribute, H8/300
4275 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4276 that the specified function should be called through the function vector.
4277 Calling a function through the function vector reduces code size; however,
4278 the function vector has a limited size (maximum 128 entries on the H8/300
4279 and 64 entries on the H8/300H and H8S)
4280 and shares space with the interrupt vector.
4282 @item interrupt_handler
4283 @cindex @code{interrupt_handler} function attribute, H8/300
4284 Use this attribute on the H8/300, H8/300H, and H8S to
4285 indicate that the specified function is an interrupt handler.  The compiler
4286 generates function entry and exit sequences suitable for use in an
4287 interrupt handler when this attribute is present.
4289 @item saveall
4290 @cindex @code{saveall} function attribute, H8/300
4291 @cindex save all registers on the H8/300, H8/300H, and H8S
4292 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4293 all registers except the stack pointer should be saved in the prologue
4294 regardless of whether they are used or not.
4295 @end table
4297 @node IA-64 Function Attributes
4298 @subsection IA-64 Function Attributes
4300 These function attributes are supported on IA-64 targets:
4302 @table @code
4303 @item syscall_linkage
4304 @cindex @code{syscall_linkage} function attribute, IA-64
4305 This attribute is used to modify the IA-64 calling convention by marking
4306 all input registers as live at all function exits.  This makes it possible
4307 to restart a system call after an interrupt without having to save/restore
4308 the input registers.  This also prevents kernel data from leaking into
4309 application code.
4311 @item version_id
4312 @cindex @code{version_id} function attribute, IA-64
4313 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4314 symbol to contain a version string, thus allowing for function level
4315 versioning.  HP-UX system header files may use function level versioning
4316 for some system calls.
4318 @smallexample
4319 extern int foo () __attribute__((version_id ("20040821")));
4320 @end smallexample
4322 @noindent
4323 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4324 @end table
4326 @node M32C Function Attributes
4327 @subsection M32C Function Attributes
4329 These function attributes are supported by the M32C back end:
4331 @table @code
4332 @item bank_switch
4333 @cindex @code{bank_switch} function attribute, M32C
4334 When added to an interrupt handler with the M32C port, causes the
4335 prologue and epilogue to use bank switching to preserve the registers
4336 rather than saving them on the stack.
4338 @item fast_interrupt
4339 @cindex @code{fast_interrupt} function attribute, M32C
4340 Use this attribute on the M32C port to indicate that the specified
4341 function is a fast interrupt handler.  This is just like the
4342 @code{interrupt} attribute, except that @code{freit} is used to return
4343 instead of @code{reit}.
4345 @item function_vector
4346 @cindex @code{function_vector} function attribute, M16C/M32C
4347 On M16C/M32C targets, the @code{function_vector} attribute declares a
4348 special page subroutine call function. Use of this attribute reduces
4349 the code size by 2 bytes for each call generated to the
4350 subroutine. The argument to the attribute is the vector number entry
4351 from the special page vector table which contains the 16 low-order
4352 bits of the subroutine's entry address. Each vector table has special
4353 page number (18 to 255) that is used in @code{jsrs} instructions.
4354 Jump addresses of the routines are generated by adding 0x0F0000 (in
4355 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4356 2-byte addresses set in the vector table. Therefore you need to ensure
4357 that all the special page vector routines should get mapped within the
4358 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4359 (for M32C).
4361 In the following example 2 bytes are saved for each call to
4362 function @code{foo}.
4364 @smallexample
4365 void foo (void) __attribute__((function_vector(0x18)));
4366 void foo (void)
4370 void bar (void)
4372     foo();
4374 @end smallexample
4376 If functions are defined in one file and are called in another file,
4377 then be sure to write this declaration in both files.
4379 This attribute is ignored for R8C target.
4381 @item interrupt
4382 @cindex @code{interrupt} function attribute, M32C
4383 Use this attribute to indicate
4384 that the specified function is an interrupt handler.  The compiler generates
4385 function entry and exit sequences suitable for use in an interrupt handler
4386 when this attribute is present.
4387 @end table
4389 @node M32R/D Function Attributes
4390 @subsection M32R/D Function Attributes
4392 These function attributes are supported by the M32R/D back end:
4394 @table @code
4395 @item interrupt
4396 @cindex @code{interrupt} function attribute, M32R/D
4397 Use this attribute to indicate
4398 that the specified function is an interrupt handler.  The compiler generates
4399 function entry and exit sequences suitable for use in an interrupt handler
4400 when this attribute is present.
4402 @item model (@var{model-name})
4403 @cindex @code{model} function attribute, M32R/D
4404 @cindex function addressability on the M32R/D
4406 On the M32R/D, use this attribute to set the addressability of an
4407 object, and of the code generated for a function.  The identifier
4408 @var{model-name} is one of @code{small}, @code{medium}, or
4409 @code{large}, representing each of the code models.
4411 Small model objects live in the lower 16MB of memory (so that their
4412 addresses can be loaded with the @code{ld24} instruction), and are
4413 callable with the @code{bl} instruction.
4415 Medium model objects may live anywhere in the 32-bit address space (the
4416 compiler generates @code{seth/add3} instructions to load their addresses),
4417 and are callable with the @code{bl} instruction.
4419 Large model objects may live anywhere in the 32-bit address space (the
4420 compiler generates @code{seth/add3} instructions to load their addresses),
4421 and may not be reachable with the @code{bl} instruction (the compiler
4422 generates the much slower @code{seth/add3/jl} instruction sequence).
4423 @end table
4425 @node m68k Function Attributes
4426 @subsection m68k Function Attributes
4428 These function attributes are supported by the m68k back end:
4430 @table @code
4431 @item interrupt
4432 @itemx interrupt_handler
4433 @cindex @code{interrupt} function attribute, m68k
4434 @cindex @code{interrupt_handler} function attribute, m68k
4435 Use this attribute to
4436 indicate that the specified function is an interrupt handler.  The compiler
4437 generates function entry and exit sequences suitable for use in an
4438 interrupt handler when this attribute is present.  Either name may be used.
4440 @item interrupt_thread
4441 @cindex @code{interrupt_thread} function attribute, fido
4442 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4443 that the specified function is an interrupt handler that is designed
4444 to run as a thread.  The compiler omits generate prologue/epilogue
4445 sequences and replaces the return instruction with a @code{sleep}
4446 instruction.  This attribute is available only on fido.
4447 @end table
4449 @node MCORE Function Attributes
4450 @subsection MCORE Function Attributes
4452 These function attributes are supported by the MCORE back end:
4454 @table @code
4455 @item naked
4456 @cindex @code{naked} function attribute, MCORE
4457 This attribute allows the compiler to construct the
4458 requisite function declaration, while allowing the body of the
4459 function to be assembly code. The specified function will not have
4460 prologue/epilogue sequences generated by the compiler. Only basic
4461 @code{asm} statements can safely be included in naked functions
4462 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4463 basic @code{asm} and C code may appear to work, they cannot be
4464 depended upon to work reliably and are not supported.
4465 @end table
4467 @node MeP Function Attributes
4468 @subsection MeP Function Attributes
4470 These function attributes are supported by the MeP back end:
4472 @table @code
4473 @item disinterrupt
4474 @cindex @code{disinterrupt} function attribute, MeP
4475 On MeP targets, this attribute causes the compiler to emit
4476 instructions to disable interrupts for the duration of the given
4477 function.
4479 @item interrupt
4480 @cindex @code{interrupt} function attribute, MeP
4481 Use this attribute to indicate
4482 that the specified function is an interrupt handler.  The compiler generates
4483 function entry and exit sequences suitable for use in an interrupt handler
4484 when this attribute is present.
4486 @item near
4487 @cindex @code{near} function attribute, MeP
4488 This attribute causes the compiler to assume the called
4489 function is close enough to use the normal calling convention,
4490 overriding the @option{-mtf} command-line option.
4492 @item far
4493 @cindex @code{far} function attribute, MeP
4494 On MeP targets this causes the compiler to use a calling convention
4495 that assumes the called function is too far away for the built-in
4496 addressing modes.
4498 @item vliw
4499 @cindex @code{vliw} function attribute, MeP
4500 The @code{vliw} attribute tells the compiler to emit
4501 instructions in VLIW mode instead of core mode.  Note that this
4502 attribute is not allowed unless a VLIW coprocessor has been configured
4503 and enabled through command-line options.
4504 @end table
4506 @node MicroBlaze Function Attributes
4507 @subsection MicroBlaze Function Attributes
4509 These function attributes are supported on MicroBlaze targets:
4511 @table @code
4512 @item save_volatiles
4513 @cindex @code{save_volatiles} function attribute, MicroBlaze
4514 Use this attribute to indicate that the function is
4515 an interrupt handler.  All volatile registers (in addition to non-volatile
4516 registers) are saved in the function prologue.  If the function is a leaf
4517 function, only volatiles used by the function are saved.  A normal function
4518 return is generated instead of a return from interrupt.
4520 @item break_handler
4521 @cindex @code{break_handler} function attribute, MicroBlaze
4522 @cindex break handler functions
4523 Use this attribute to indicate that
4524 the specified function is a break handler.  The compiler generates function
4525 entry and exit sequences suitable for use in an break handler when this
4526 attribute is present. The return from @code{break_handler} is done through
4527 the @code{rtbd} instead of @code{rtsd}.
4529 @smallexample
4530 void f () __attribute__ ((break_handler));
4531 @end smallexample
4533 @item interrupt_handler
4534 @itemx fast_interrupt 
4535 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4536 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4537 These attributes indicate that the specified function is an interrupt
4538 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4539 used in low-latency interrupt mode, and @code{interrupt_handler} for
4540 interrupts that do not use low-latency handlers.  In both cases, GCC
4541 emits appropriate prologue code and generates a return from the handler
4542 using @code{rtid} instead of @code{rtsd}.
4543 @end table
4545 @node Microsoft Windows Function Attributes
4546 @subsection Microsoft Windows Function Attributes
4548 The following attributes are available on Microsoft Windows and Symbian OS
4549 targets.
4551 @table @code
4552 @item dllexport
4553 @cindex @code{dllexport} function attribute
4554 @cindex @code{__declspec(dllexport)}
4555 On Microsoft Windows targets and Symbian OS targets the
4556 @code{dllexport} attribute causes the compiler to provide a global
4557 pointer to a pointer in a DLL, so that it can be referenced with the
4558 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4559 name is formed by combining @code{_imp__} and the function or variable
4560 name.
4562 You can use @code{__declspec(dllexport)} as a synonym for
4563 @code{__attribute__ ((dllexport))} for compatibility with other
4564 compilers.
4566 On systems that support the @code{visibility} attribute, this
4567 attribute also implies ``default'' visibility.  It is an error to
4568 explicitly specify any other visibility.
4570 GCC's default behavior is to emit all inline functions with the
4571 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4572 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4573 ignore the attribute for inlined functions unless the 
4574 @option{-fkeep-inline-functions} flag is used instead.
4576 The attribute is ignored for undefined symbols.
4578 When applied to C++ classes, the attribute marks defined non-inlined
4579 member functions and static data members as exports.  Static consts
4580 initialized in-class are not marked unless they are also defined
4581 out-of-class.
4583 For Microsoft Windows targets there are alternative methods for
4584 including the symbol in the DLL's export table such as using a
4585 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4586 the @option{--export-all} linker flag.
4588 @item dllimport
4589 @cindex @code{dllimport} function attribute
4590 @cindex @code{__declspec(dllimport)}
4591 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4592 attribute causes the compiler to reference a function or variable via
4593 a global pointer to a pointer that is set up by the DLL exporting the
4594 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4595 targets, the pointer name is formed by combining @code{_imp__} and the
4596 function or variable name.
4598 You can use @code{__declspec(dllimport)} as a synonym for
4599 @code{__attribute__ ((dllimport))} for compatibility with other
4600 compilers.
4602 On systems that support the @code{visibility} attribute, this
4603 attribute also implies ``default'' visibility.  It is an error to
4604 explicitly specify any other visibility.
4606 Currently, the attribute is ignored for inlined functions.  If the
4607 attribute is applied to a symbol @emph{definition}, an error is reported.
4608 If a symbol previously declared @code{dllimport} is later defined, the
4609 attribute is ignored in subsequent references, and a warning is emitted.
4610 The attribute is also overridden by a subsequent declaration as
4611 @code{dllexport}.
4613 When applied to C++ classes, the attribute marks non-inlined
4614 member functions and static data members as imports.  However, the
4615 attribute is ignored for virtual methods to allow creation of vtables
4616 using thunks.
4618 On the SH Symbian OS target the @code{dllimport} attribute also has
4619 another affect---it can cause the vtable and run-time type information
4620 for a class to be exported.  This happens when the class has a
4621 dllimported constructor or a non-inline, non-pure virtual function
4622 and, for either of those two conditions, the class also has an inline
4623 constructor or destructor and has a key function that is defined in
4624 the current translation unit.
4626 For Microsoft Windows targets the use of the @code{dllimport}
4627 attribute on functions is not necessary, but provides a small
4628 performance benefit by eliminating a thunk in the DLL@.  The use of the
4629 @code{dllimport} attribute on imported variables can be avoided by passing the
4630 @option{--enable-auto-import} switch to the GNU linker.  As with
4631 functions, using the attribute for a variable eliminates a thunk in
4632 the DLL@.
4634 One drawback to using this attribute is that a pointer to a
4635 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4636 address. However, a pointer to a @emph{function} with the
4637 @code{dllimport} attribute can be used as a constant initializer; in
4638 this case, the address of a stub function in the import lib is
4639 referenced.  On Microsoft Windows targets, the attribute can be disabled
4640 for functions by setting the @option{-mnop-fun-dllimport} flag.
4641 @end table
4643 @node MIPS Function Attributes
4644 @subsection MIPS Function Attributes
4646 These function attributes are supported by the MIPS back end:
4648 @table @code
4649 @item interrupt
4650 @cindex @code{interrupt} function attribute, MIPS
4651 Use this attribute to indicate that the specified function is an interrupt
4652 handler.  The compiler generates function entry and exit sequences suitable
4653 for use in an interrupt handler when this attribute is present.
4654 An optional argument is supported for the interrupt attribute which allows
4655 the interrupt mode to be described.  By default GCC assumes the external
4656 interrupt controller (EIC) mode is in use, this can be explicitly set using
4657 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4658 Priority Level (IPL) is copied to the current IPL which has the effect of only
4659 enabling higher priority interrupts.  To use vectored interrupt mode use
4660 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4661 the behavior of the non-masked interrupt support and GCC will arrange to mask
4662 all interrupts from sw0 up to and including the specified interrupt vector.
4664 You can use the following attributes to modify the behavior
4665 of an interrupt handler:
4666 @table @code
4667 @item use_shadow_register_set
4668 @cindex @code{use_shadow_register_set} function attribute, MIPS
4669 Assume that the handler uses a shadow register set, instead of
4670 the main general-purpose registers.  An optional argument @code{intstack} is
4671 supported to indicate that the shadow register set contains a valid stack
4672 pointer.
4674 @item keep_interrupts_masked
4675 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4676 Keep interrupts masked for the whole function.  Without this attribute,
4677 GCC tries to reenable interrupts for as much of the function as it can.
4679 @item use_debug_exception_return
4680 @cindex @code{use_debug_exception_return} function attribute, MIPS
4681 Return using the @code{deret} instruction.  Interrupt handlers that don't
4682 have this attribute return using @code{eret} instead.
4683 @end table
4685 You can use any combination of these attributes, as shown below:
4686 @smallexample
4687 void __attribute__ ((interrupt)) v0 ();
4688 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4689 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4690 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4691 void __attribute__ ((interrupt, use_shadow_register_set,
4692                      keep_interrupts_masked)) v4 ();
4693 void __attribute__ ((interrupt, use_shadow_register_set,
4694                      use_debug_exception_return)) v5 ();
4695 void __attribute__ ((interrupt, keep_interrupts_masked,
4696                      use_debug_exception_return)) v6 ();
4697 void __attribute__ ((interrupt, use_shadow_register_set,
4698                      keep_interrupts_masked,
4699                      use_debug_exception_return)) v7 ();
4700 void __attribute__ ((interrupt("eic"))) v8 ();
4701 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4702 @end smallexample
4704 @item long_call
4705 @itemx short_call
4706 @itemx near
4707 @itemx far
4708 @cindex indirect calls, MIPS
4709 @cindex @code{long_call} function attribute, MIPS
4710 @cindex @code{short_call} function attribute, MIPS
4711 @cindex @code{near} function attribute, MIPS
4712 @cindex @code{far} function attribute, MIPS
4713 These attributes specify how a particular function is called on MIPS@.
4714 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4715 command-line switch.  The @code{long_call} and @code{far} attributes are
4716 synonyms, and cause the compiler to always call
4717 the function by first loading its address into a register, and then using
4718 the contents of that register.  The @code{short_call} and @code{near}
4719 attributes are synonyms, and have the opposite
4720 effect; they specify that non-PIC calls should be made using the more
4721 efficient @code{jal} instruction.
4723 @item mips16
4724 @itemx nomips16
4725 @cindex @code{mips16} function attribute, MIPS
4726 @cindex @code{nomips16} function attribute, MIPS
4728 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4729 function attributes to locally select or turn off MIPS16 code generation.
4730 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4731 while MIPS16 code generation is disabled for functions with the
4732 @code{nomips16} attribute.  These attributes override the
4733 @option{-mips16} and @option{-mno-mips16} options on the command line
4734 (@pxref{MIPS Options}).
4736 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4737 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4738 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4739 may interact badly with some GCC extensions such as @code{__builtin_apply}
4740 (@pxref{Constructing Calls}).
4742 @item micromips, MIPS
4743 @itemx nomicromips, MIPS
4744 @cindex @code{micromips} function attribute
4745 @cindex @code{nomicromips} function attribute
4747 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4748 function attributes to locally select or turn off microMIPS code generation.
4749 A function with the @code{micromips} attribute is emitted as microMIPS code,
4750 while microMIPS code generation is disabled for functions with the
4751 @code{nomicromips} attribute.  These attributes override the
4752 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4753 (@pxref{MIPS Options}).
4755 When compiling files containing mixed microMIPS and non-microMIPS code, the
4756 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4757 command line,
4758 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4759 may interact badly with some GCC extensions such as @code{__builtin_apply}
4760 (@pxref{Constructing Calls}).
4762 @item nocompression
4763 @cindex @code{nocompression} function attribute, MIPS
4764 On MIPS targets, you can use the @code{nocompression} function attribute
4765 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4766 overrides the @option{-mips16} and @option{-mmicromips} options on the
4767 command line (@pxref{MIPS Options}).
4768 @end table
4770 @node MSP430 Function Attributes
4771 @subsection MSP430 Function Attributes
4773 These function attributes are supported by the MSP430 back end:
4775 @table @code
4776 @item critical
4777 @cindex @code{critical} function attribute, MSP430
4778 Critical functions disable interrupts upon entry and restore the
4779 previous interrupt state upon exit.  Critical functions cannot also
4780 have the @code{naked} or @code{reentrant} attributes.  They can have
4781 the @code{interrupt} attribute.
4783 @item interrupt
4784 @cindex @code{interrupt} function attribute, MSP430
4785 Use this attribute to indicate
4786 that the specified function is an interrupt handler.  The compiler generates
4787 function entry and exit sequences suitable for use in an interrupt handler
4788 when this attribute is present.
4790 You can provide an argument to the interrupt
4791 attribute which specifies a name or number.  If the argument is a
4792 number it indicates the slot in the interrupt vector table (0 - 31) to
4793 which this handler should be assigned.  If the argument is a name it
4794 is treated as a symbolic name for the vector slot.  These names should
4795 match up with appropriate entries in the linker script.  By default
4796 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4797 @code{reset} for vector 31 are recognized.
4799 @item naked
4800 @cindex @code{naked} function attribute, MSP430
4801 This attribute allows the compiler to construct the
4802 requisite function declaration, while allowing the body of the
4803 function to be assembly code. The specified function will not have
4804 prologue/epilogue sequences generated by the compiler. Only basic
4805 @code{asm} statements can safely be included in naked functions
4806 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4807 basic @code{asm} and C code may appear to work, they cannot be
4808 depended upon to work reliably and are not supported.
4810 @item reentrant
4811 @cindex @code{reentrant} function attribute, MSP430
4812 Reentrant functions disable interrupts upon entry and enable them
4813 upon exit.  Reentrant functions cannot also have the @code{naked}
4814 or @code{critical} attributes.  They can have the @code{interrupt}
4815 attribute.
4817 @item wakeup
4818 @cindex @code{wakeup} function attribute, MSP430
4819 This attribute only applies to interrupt functions.  It is silently
4820 ignored if applied to a non-interrupt function.  A wakeup interrupt
4821 function will rouse the processor from any low-power state that it
4822 might be in when the function exits.
4824 @item lower
4825 @itemx upper
4826 @itemx either
4827 @cindex @code{lower} function attribute, MSP430
4828 @cindex @code{upper} function attribute, MSP430
4829 @cindex @code{either} function attribute, MSP430
4830 On the MSP430 target these attributes can be used to specify whether
4831 the function or variable should be placed into low memory, high
4832 memory, or the placement should be left to the linker to decide.  The
4833 attributes are only significant if compiling for the MSP430X
4834 architecture.
4836 The attributes work in conjunction with a linker script that has been
4837 augmented to specify where to place sections with a @code{.lower} and
4838 a @code{.upper} prefix.  So, for example, as well as placing the
4839 @code{.data} section, the script also specifies the placement of a
4840 @code{.lower.data} and a @code{.upper.data} section.  The intention
4841 is that @code{lower} sections are placed into a small but easier to
4842 access memory region and the upper sections are placed into a larger, but
4843 slower to access, region.
4845 The @code{either} attribute is special.  It tells the linker to place
4846 the object into the corresponding @code{lower} section if there is
4847 room for it.  If there is insufficient room then the object is placed
4848 into the corresponding @code{upper} section instead.  Note that the
4849 placement algorithm is not very sophisticated.  It does not attempt to
4850 find an optimal packing of the @code{lower} sections.  It just makes
4851 one pass over the objects and does the best that it can.  Using the
4852 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4853 options can help the packing, however, since they produce smaller,
4854 easier to pack regions.
4855 @end table
4857 @node NDS32 Function Attributes
4858 @subsection NDS32 Function Attributes
4860 These function attributes are supported by the NDS32 back end:
4862 @table @code
4863 @item exception
4864 @cindex @code{exception} function attribute
4865 @cindex exception handler functions, NDS32
4866 Use this attribute on the NDS32 target to indicate that the specified function
4867 is an exception handler.  The compiler will generate corresponding sections
4868 for use in an exception handler.
4870 @item interrupt
4871 @cindex @code{interrupt} function attribute, NDS32
4872 On NDS32 target, this attribute indicates that the specified function
4873 is an interrupt handler.  The compiler generates corresponding sections
4874 for use in an interrupt handler.  You can use the following attributes
4875 to modify the behavior:
4876 @table @code
4877 @item nested
4878 @cindex @code{nested} function attribute, NDS32
4879 This interrupt service routine is interruptible.
4880 @item not_nested
4881 @cindex @code{not_nested} function attribute, NDS32
4882 This interrupt service routine is not interruptible.
4883 @item nested_ready
4884 @cindex @code{nested_ready} function attribute, NDS32
4885 This interrupt service routine is interruptible after @code{PSW.GIE}
4886 (global interrupt enable) is set.  This allows interrupt service routine to
4887 finish some short critical code before enabling interrupts.
4888 @item save_all
4889 @cindex @code{save_all} function attribute, NDS32
4890 The system will help save all registers into stack before entering
4891 interrupt handler.
4892 @item partial_save
4893 @cindex @code{partial_save} function attribute, NDS32
4894 The system will help save caller registers into stack before entering
4895 interrupt handler.
4896 @end table
4898 @item naked
4899 @cindex @code{naked} function attribute, NDS32
4900 This attribute allows the compiler to construct the
4901 requisite function declaration, while allowing the body of the
4902 function to be assembly code. The specified function will not have
4903 prologue/epilogue sequences generated by the compiler. Only basic
4904 @code{asm} statements can safely be included in naked functions
4905 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4906 basic @code{asm} and C code may appear to work, they cannot be
4907 depended upon to work reliably and are not supported.
4909 @item reset
4910 @cindex @code{reset} function attribute, NDS32
4911 @cindex reset handler functions
4912 Use this attribute on the NDS32 target to indicate that the specified function
4913 is a reset handler.  The compiler will generate corresponding sections
4914 for use in a reset handler.  You can use the following attributes
4915 to provide extra exception handling:
4916 @table @code
4917 @item nmi
4918 @cindex @code{nmi} function attribute, NDS32
4919 Provide a user-defined function to handle NMI exception.
4920 @item warm
4921 @cindex @code{warm} function attribute, NDS32
4922 Provide a user-defined function to handle warm reset exception.
4923 @end table
4924 @end table
4926 @node Nios II Function Attributes
4927 @subsection Nios II Function Attributes
4929 These function attributes are supported by the Nios II back end:
4931 @table @code
4932 @item target (@var{options})
4933 @cindex @code{target} function attribute
4934 As discussed in @ref{Common Function Attributes}, this attribute 
4935 allows specification of target-specific compilation options.
4937 When compiling for Nios II, the following options are allowed:
4939 @table @samp
4940 @item custom-@var{insn}=@var{N}
4941 @itemx no-custom-@var{insn}
4942 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4943 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4944 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4945 custom instruction with encoding @var{N} when generating code that uses 
4946 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4947 the custom instruction @var{insn}.
4948 These target attributes correspond to the
4949 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4950 command-line options, and support the same set of @var{insn} keywords.
4951 @xref{Nios II Options}, for more information.
4953 @item custom-fpu-cfg=@var{name}
4954 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4955 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4956 command-line option, to select a predefined set of custom instructions
4957 named @var{name}.
4958 @xref{Nios II Options}, for more information.
4959 @end table
4960 @end table
4962 @node Nvidia PTX Function Attributes
4963 @subsection Nvidia PTX Function Attributes
4965 These function attributes are supported by the Nvidia PTX back end:
4967 @table @code
4968 @item kernel
4969 @cindex @code{kernel} attribute, Nvidia PTX
4970 This attribute indicates that the corresponding function should be compiled
4971 as a kernel function, which can be invoked from the host via the CUDA RT 
4972 library.
4973 By default functions are only callable only from other PTX functions.
4975 Kernel functions must have @code{void} return type.
4976 @end table
4978 @node PowerPC Function Attributes
4979 @subsection PowerPC Function Attributes
4981 These function attributes are supported by the PowerPC back end:
4983 @table @code
4984 @item longcall
4985 @itemx shortcall
4986 @cindex indirect calls, PowerPC
4987 @cindex @code{longcall} function attribute, PowerPC
4988 @cindex @code{shortcall} function attribute, PowerPC
4989 The @code{longcall} attribute
4990 indicates that the function might be far away from the call site and
4991 require a different (more expensive) calling sequence.  The
4992 @code{shortcall} attribute indicates that the function is always close
4993 enough for the shorter calling sequence to be used.  These attributes
4994 override both the @option{-mlongcall} switch and
4995 the @code{#pragma longcall} setting.
4997 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4998 calls are necessary.
5000 @item target (@var{options})
5001 @cindex @code{target} function attribute
5002 As discussed in @ref{Common Function Attributes}, this attribute 
5003 allows specification of target-specific compilation options.
5005 On the PowerPC, the following options are allowed:
5007 @table @samp
5008 @item altivec
5009 @itemx no-altivec
5010 @cindex @code{target("altivec")} function attribute, PowerPC
5011 Generate code that uses (does not use) AltiVec instructions.  In
5012 32-bit code, you cannot enable AltiVec instructions unless
5013 @option{-mabi=altivec} is used on the command line.
5015 @item cmpb
5016 @itemx no-cmpb
5017 @cindex @code{target("cmpb")} function attribute, PowerPC
5018 Generate code that uses (does not use) the compare bytes instruction
5019 implemented on the POWER6 processor and other processors that support
5020 the PowerPC V2.05 architecture.
5022 @item dlmzb
5023 @itemx no-dlmzb
5024 @cindex @code{target("dlmzb")} function attribute, PowerPC
5025 Generate code that uses (does not use) the string-search @samp{dlmzb}
5026 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
5027 generated by default when targeting those processors.
5029 @item fprnd
5030 @itemx no-fprnd
5031 @cindex @code{target("fprnd")} function attribute, PowerPC
5032 Generate code that uses (does not use) the FP round to integer
5033 instructions implemented on the POWER5+ processor and other processors
5034 that support the PowerPC V2.03 architecture.
5036 @item hard-dfp
5037 @itemx no-hard-dfp
5038 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5039 Generate code that uses (does not use) the decimal floating-point
5040 instructions implemented on some POWER processors.
5042 @item isel
5043 @itemx no-isel
5044 @cindex @code{target("isel")} function attribute, PowerPC
5045 Generate code that uses (does not use) ISEL instruction.
5047 @item mfcrf
5048 @itemx no-mfcrf
5049 @cindex @code{target("mfcrf")} function attribute, PowerPC
5050 Generate code that uses (does not use) the move from condition
5051 register field instruction implemented on the POWER4 processor and
5052 other processors that support the PowerPC V2.01 architecture.
5054 @item mfpgpr
5055 @itemx no-mfpgpr
5056 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5057 Generate code that uses (does not use) the FP move to/from general
5058 purpose register instructions implemented on the POWER6X processor and
5059 other processors that support the extended PowerPC V2.05 architecture.
5061 @item mulhw
5062 @itemx no-mulhw
5063 @cindex @code{target("mulhw")} function attribute, PowerPC
5064 Generate code that uses (does not use) the half-word multiply and
5065 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5066 These instructions are generated by default when targeting those
5067 processors.
5069 @item multiple
5070 @itemx no-multiple
5071 @cindex @code{target("multiple")} function attribute, PowerPC
5072 Generate code that uses (does not use) the load multiple word
5073 instructions and the store multiple word instructions.
5075 @item update
5076 @itemx no-update
5077 @cindex @code{target("update")} function attribute, PowerPC
5078 Generate code that uses (does not use) the load or store instructions
5079 that update the base register to the address of the calculated memory
5080 location.
5082 @item popcntb
5083 @itemx no-popcntb
5084 @cindex @code{target("popcntb")} function attribute, PowerPC
5085 Generate code that uses (does not use) the popcount and double-precision
5086 FP reciprocal estimate instruction implemented on the POWER5
5087 processor and other processors that support the PowerPC V2.02
5088 architecture.
5090 @item popcntd
5091 @itemx no-popcntd
5092 @cindex @code{target("popcntd")} function attribute, PowerPC
5093 Generate code that uses (does not use) the popcount instruction
5094 implemented on the POWER7 processor and other processors that support
5095 the PowerPC V2.06 architecture.
5097 @item powerpc-gfxopt
5098 @itemx no-powerpc-gfxopt
5099 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5100 Generate code that uses (does not use) the optional PowerPC
5101 architecture instructions in the Graphics group, including
5102 floating-point select.
5104 @item powerpc-gpopt
5105 @itemx no-powerpc-gpopt
5106 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5107 Generate code that uses (does not use) the optional PowerPC
5108 architecture instructions in the General Purpose group, including
5109 floating-point square root.
5111 @item recip-precision
5112 @itemx no-recip-precision
5113 @cindex @code{target("recip-precision")} function attribute, PowerPC
5114 Assume (do not assume) that the reciprocal estimate instructions
5115 provide higher-precision estimates than is mandated by the PowerPC
5116 ABI.
5118 @item string
5119 @itemx no-string
5120 @cindex @code{target("string")} function attribute, PowerPC
5121 Generate code that uses (does not use) the load string instructions
5122 and the store string word instructions to save multiple registers and
5123 do small block moves.
5125 @item vsx
5126 @itemx no-vsx
5127 @cindex @code{target("vsx")} function attribute, PowerPC
5128 Generate code that uses (does not use) vector/scalar (VSX)
5129 instructions, and also enable the use of built-in functions that allow
5130 more direct access to the VSX instruction set.  In 32-bit code, you
5131 cannot enable VSX or AltiVec instructions unless
5132 @option{-mabi=altivec} is used on the command line.
5134 @item friz
5135 @itemx no-friz
5136 @cindex @code{target("friz")} function attribute, PowerPC
5137 Generate (do not generate) the @code{friz} instruction when the
5138 @option{-funsafe-math-optimizations} option is used to optimize
5139 rounding a floating-point value to 64-bit integer and back to floating
5140 point.  The @code{friz} instruction does not return the same value if
5141 the floating-point number is too large to fit in an integer.
5143 @item avoid-indexed-addresses
5144 @itemx no-avoid-indexed-addresses
5145 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5146 Generate code that tries to avoid (not avoid) the use of indexed load
5147 or store instructions.
5149 @item paired
5150 @itemx no-paired
5151 @cindex @code{target("paired")} function attribute, PowerPC
5152 Generate code that uses (does not use) the generation of PAIRED simd
5153 instructions.
5155 @item longcall
5156 @itemx no-longcall
5157 @cindex @code{target("longcall")} function attribute, PowerPC
5158 Generate code that assumes (does not assume) that all calls are far
5159 away so that a longer more expensive calling sequence is required.
5161 @item cpu=@var{CPU}
5162 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5163 Specify the architecture to generate code for when compiling the
5164 function.  If you select the @code{target("cpu=power7")} attribute when
5165 generating 32-bit code, VSX and AltiVec instructions are not generated
5166 unless you use the @option{-mabi=altivec} option on the command line.
5168 @item tune=@var{TUNE}
5169 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5170 Specify the architecture to tune for when compiling the function.  If
5171 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5172 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5173 compilation tunes for the @var{CPU} architecture, and not the
5174 default tuning specified on the command line.
5175 @end table
5177 On the PowerPC, the inliner does not inline a
5178 function that has different target options than the caller, unless the
5179 callee has a subset of the target options of the caller.
5180 @end table
5182 @node RISC-V Function Attributes
5183 @subsection RISC-V Function Attributes
5185 These function attributes are supported by the RISC-V back end:
5187 @table @code
5188 @item naked
5189 @cindex @code{naked} function attribute, RISC-V
5190 This attribute allows the compiler to construct the
5191 requisite function declaration, while allowing the body of the
5192 function to be assembly code. The specified function will not have
5193 prologue/epilogue sequences generated by the compiler. Only basic
5194 @code{asm} statements can safely be included in naked functions
5195 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5196 basic @code{asm} and C code may appear to work, they cannot be
5197 depended upon to work reliably and are not supported.
5199 @item interrupt
5200 @cindex @code{interrupt} function attribute, RISC-V
5201 Use this attribute to indicate that the specified function is an interrupt
5202 handler.  The compiler generates function entry and exit sequences suitable
5203 for use in an interrupt handler when this attribute is present.
5205 You can specify the kind of interrupt to be handled by adding an optional
5206 parameter to the interrupt attribute like this:
5208 @smallexample
5209 void f (void) __attribute__ ((interrupt ("user")));
5210 @end smallexample
5212 Permissible values for this parameter are @code{user}, @code{supervisor},
5213 and @code{machine}.  If there is no parameter, then it defaults to
5214 @code{machine}.
5215 @end table
5217 @node RL78 Function Attributes
5218 @subsection RL78 Function Attributes
5220 These function attributes are supported by the RL78 back end:
5222 @table @code
5223 @item interrupt
5224 @itemx brk_interrupt
5225 @cindex @code{interrupt} function attribute, RL78
5226 @cindex @code{brk_interrupt} function attribute, RL78
5227 These attributes indicate
5228 that the specified function is an interrupt handler.  The compiler generates
5229 function entry and exit sequences suitable for use in an interrupt handler
5230 when this attribute is present.
5232 Use @code{brk_interrupt} instead of @code{interrupt} for
5233 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5234 that must end with @code{RETB} instead of @code{RETI}).
5236 @item naked
5237 @cindex @code{naked} function attribute, RL78
5238 This attribute allows the compiler to construct the
5239 requisite function declaration, while allowing the body of the
5240 function to be assembly code. The specified function will not have
5241 prologue/epilogue sequences generated by the compiler. Only basic
5242 @code{asm} statements can safely be included in naked functions
5243 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5244 basic @code{asm} and C code may appear to work, they cannot be
5245 depended upon to work reliably and are not supported.
5246 @end table
5248 @node RX Function Attributes
5249 @subsection RX Function Attributes
5251 These function attributes are supported by the RX back end:
5253 @table @code
5254 @item fast_interrupt
5255 @cindex @code{fast_interrupt} function attribute, RX
5256 Use this attribute on the RX port to indicate that the specified
5257 function is a fast interrupt handler.  This is just like the
5258 @code{interrupt} attribute, except that @code{freit} is used to return
5259 instead of @code{reit}.
5261 @item interrupt
5262 @cindex @code{interrupt} function attribute, RX
5263 Use this attribute to indicate
5264 that the specified function is an interrupt handler.  The compiler generates
5265 function entry and exit sequences suitable for use in an interrupt handler
5266 when this attribute is present.
5268 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5269 to the attribute, as well as naming an alternate table name.
5270 Parameters are handled sequentially, so one handler can be assigned to
5271 multiple entries in multiple tables.  One may also pass the magic
5272 string @code{"$default"} which causes the function to be used for any
5273 unfilled slots in the current table.
5275 This example shows a simple assignment of a function to one vector in
5276 the default table (note that preprocessor macros may be used for
5277 chip-specific symbolic vector names):
5278 @smallexample
5279 void __attribute__ ((interrupt (5))) txd1_handler ();
5280 @end smallexample
5282 This example assigns a function to two slots in the default table
5283 (using preprocessor macros defined elsewhere) and makes it the default
5284 for the @code{dct} table:
5285 @smallexample
5286 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5287         txd1_handler ();
5288 @end smallexample
5290 @item naked
5291 @cindex @code{naked} function attribute, RX
5292 This attribute allows the compiler to construct the
5293 requisite function declaration, while allowing the body of the
5294 function to be assembly code. The specified function will not have
5295 prologue/epilogue sequences generated by the compiler. Only basic
5296 @code{asm} statements can safely be included in naked functions
5297 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5298 basic @code{asm} and C code may appear to work, they cannot be
5299 depended upon to work reliably and are not supported.
5301 @item vector
5302 @cindex @code{vector} function attribute, RX
5303 This RX attribute is similar to the @code{interrupt} attribute, including its
5304 parameters, but does not make the function an interrupt-handler type
5305 function (i.e. it retains the normal C function calling ABI).  See the
5306 @code{interrupt} attribute for a description of its arguments.
5307 @end table
5309 @node S/390 Function Attributes
5310 @subsection S/390 Function Attributes
5312 These function attributes are supported on the S/390:
5314 @table @code
5315 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5316 @cindex @code{hotpatch} function attribute, S/390
5318 On S/390 System z targets, you can use this function attribute to
5319 make GCC generate a ``hot-patching'' function prologue.  If the
5320 @option{-mhotpatch=} command-line option is used at the same time,
5321 the @code{hotpatch} attribute takes precedence.  The first of the
5322 two arguments specifies the number of halfwords to be added before
5323 the function label.  A second argument can be used to specify the
5324 number of halfwords to be added after the function label.  For
5325 both arguments the maximum allowed value is 1000000.
5327 If both arguments are zero, hotpatching is disabled.
5329 @item target (@var{options})
5330 @cindex @code{target} function attribute
5331 As discussed in @ref{Common Function Attributes}, this attribute
5332 allows specification of target-specific compilation options.
5334 On S/390, the following options are supported:
5336 @table @samp
5337 @item arch=
5338 @item tune=
5339 @item stack-guard=
5340 @item stack-size=
5341 @item branch-cost=
5342 @item warn-framesize=
5343 @item backchain
5344 @itemx no-backchain
5345 @item hard-dfp
5346 @itemx no-hard-dfp
5347 @item hard-float
5348 @itemx soft-float
5349 @item htm
5350 @itemx no-htm
5351 @item vx
5352 @itemx no-vx
5353 @item packed-stack
5354 @itemx no-packed-stack
5355 @item small-exec
5356 @itemx no-small-exec
5357 @item mvcle
5358 @itemx no-mvcle
5359 @item warn-dynamicstack
5360 @itemx no-warn-dynamicstack
5361 @end table
5363 The options work exactly like the S/390 specific command line
5364 options (without the prefix @option{-m}) except that they do not
5365 change any feature macros.  For example,
5367 @smallexample
5368 @code{target("no-vx")}
5369 @end smallexample
5371 does not undefine the @code{__VEC__} macro.
5372 @end table
5374 @node SH Function Attributes
5375 @subsection SH Function Attributes
5377 These function attributes are supported on the SH family of processors:
5379 @table @code
5380 @item function_vector
5381 @cindex @code{function_vector} function attribute, SH
5382 @cindex calling functions through the function vector on SH2A
5383 On SH2A targets, this attribute declares a function to be called using the
5384 TBR relative addressing mode.  The argument to this attribute is the entry
5385 number of the same function in a vector table containing all the TBR
5386 relative addressable functions.  For correct operation the TBR must be setup
5387 accordingly to point to the start of the vector table before any functions with
5388 this attribute are invoked.  Usually a good place to do the initialization is
5389 the startup routine.  The TBR relative vector table can have at max 256 function
5390 entries.  The jumps to these functions are generated using a SH2A specific,
5391 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5392 from GNU binutils version 2.7 or later for this attribute to work correctly.
5394 In an application, for a function being called once, this attribute
5395 saves at least 8 bytes of code; and if other successive calls are being
5396 made to the same function, it saves 2 bytes of code per each of these
5397 calls.
5399 @item interrupt_handler
5400 @cindex @code{interrupt_handler} function attribute, SH
5401 Use this attribute to
5402 indicate that the specified function is an interrupt handler.  The compiler
5403 generates function entry and exit sequences suitable for use in an
5404 interrupt handler when this attribute is present.
5406 @item nosave_low_regs
5407 @cindex @code{nosave_low_regs} function attribute, SH
5408 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5409 function should not save and restore registers R0..R7.  This can be used on SH3*
5410 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5411 interrupt handlers.
5413 @item renesas
5414 @cindex @code{renesas} function attribute, SH
5415 On SH targets this attribute specifies that the function or struct follows the
5416 Renesas ABI.
5418 @item resbank
5419 @cindex @code{resbank} function attribute, SH
5420 On the SH2A target, this attribute enables the high-speed register
5421 saving and restoration using a register bank for @code{interrupt_handler}
5422 routines.  Saving to the bank is performed automatically after the CPU
5423 accepts an interrupt that uses a register bank.
5425 The nineteen 32-bit registers comprising general register R0 to R14,
5426 control register GBR, and system registers MACH, MACL, and PR and the
5427 vector table address offset are saved into a register bank.  Register
5428 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5429 from the bank is executed by issuing a RESBANK instruction.
5431 @item sp_switch
5432 @cindex @code{sp_switch} function attribute, SH
5433 Use this attribute on the SH to indicate an @code{interrupt_handler}
5434 function should switch to an alternate stack.  It expects a string
5435 argument that names a global variable holding the address of the
5436 alternate stack.
5438 @smallexample
5439 void *alt_stack;
5440 void f () __attribute__ ((interrupt_handler,
5441                           sp_switch ("alt_stack")));
5442 @end smallexample
5444 @item trap_exit
5445 @cindex @code{trap_exit} function attribute, SH
5446 Use this attribute on the SH for an @code{interrupt_handler} to return using
5447 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5448 argument specifying the trap number to be used.
5450 @item trapa_handler
5451 @cindex @code{trapa_handler} function attribute, SH
5452 On SH targets this function attribute is similar to @code{interrupt_handler}
5453 but it does not save and restore all registers.
5454 @end table
5456 @node SPU Function Attributes
5457 @subsection SPU Function Attributes
5459 These function attributes are supported by the SPU back end:
5461 @table @code
5462 @item naked
5463 @cindex @code{naked} function attribute, SPU
5464 This attribute allows the compiler to construct the
5465 requisite function declaration, while allowing the body of the
5466 function to be assembly code. The specified function will not have
5467 prologue/epilogue sequences generated by the compiler. Only basic
5468 @code{asm} statements can safely be included in naked functions
5469 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5470 basic @code{asm} and C code may appear to work, they cannot be
5471 depended upon to work reliably and are not supported.
5472 @end table
5474 @node Symbian OS Function Attributes
5475 @subsection Symbian OS Function Attributes
5477 @xref{Microsoft Windows Function Attributes}, for discussion of the
5478 @code{dllexport} and @code{dllimport} attributes.
5480 @node V850 Function Attributes
5481 @subsection V850 Function Attributes
5483 The V850 back end supports these function attributes:
5485 @table @code
5486 @item interrupt
5487 @itemx interrupt_handler
5488 @cindex @code{interrupt} function attribute, V850
5489 @cindex @code{interrupt_handler} function attribute, V850
5490 Use these attributes to indicate
5491 that the specified function is an interrupt handler.  The compiler generates
5492 function entry and exit sequences suitable for use in an interrupt handler
5493 when either attribute is present.
5494 @end table
5496 @node Visium Function Attributes
5497 @subsection Visium Function Attributes
5499 These function attributes are supported by the Visium back end:
5501 @table @code
5502 @item interrupt
5503 @cindex @code{interrupt} function attribute, Visium
5504 Use this attribute to indicate
5505 that the specified function is an interrupt handler.  The compiler generates
5506 function entry and exit sequences suitable for use in an interrupt handler
5507 when this attribute is present.
5508 @end table
5510 @node x86 Function Attributes
5511 @subsection x86 Function Attributes
5513 These function attributes are supported by the x86 back end:
5515 @table @code
5516 @item cdecl
5517 @cindex @code{cdecl} function attribute, x86-32
5518 @cindex functions that pop the argument stack on x86-32
5519 @opindex mrtd
5520 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5521 assume that the calling function pops off the stack space used to
5522 pass arguments.  This is
5523 useful to override the effects of the @option{-mrtd} switch.
5525 @item fastcall
5526 @cindex @code{fastcall} function attribute, x86-32
5527 @cindex functions that pop the argument stack on x86-32
5528 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5529 pass the first argument (if of integral type) in the register ECX and
5530 the second argument (if of integral type) in the register EDX@.  Subsequent
5531 and other typed arguments are passed on the stack.  The called function
5532 pops the arguments off the stack.  If the number of arguments is variable all
5533 arguments are pushed on the stack.
5535 @item thiscall
5536 @cindex @code{thiscall} function attribute, x86-32
5537 @cindex functions that pop the argument stack on x86-32
5538 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5539 pass the first argument (if of integral type) in the register ECX.
5540 Subsequent and other typed arguments are passed on the stack. The called
5541 function pops the arguments off the stack.
5542 If the number of arguments is variable all arguments are pushed on the
5543 stack.
5544 The @code{thiscall} attribute is intended for C++ non-static member functions.
5545 As a GCC extension, this calling convention can be used for C functions
5546 and for static member methods.
5548 @item ms_abi
5549 @itemx sysv_abi
5550 @cindex @code{ms_abi} function attribute, x86
5551 @cindex @code{sysv_abi} function attribute, x86
5553 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5554 to indicate which calling convention should be used for a function.  The
5555 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5556 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5557 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5558 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5560 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5561 requires the @option{-maccumulate-outgoing-args} option.
5563 @item callee_pop_aggregate_return (@var{number})
5564 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5566 On x86-32 targets, you can use this attribute to control how
5567 aggregates are returned in memory.  If the caller is responsible for
5568 popping the hidden pointer together with the rest of the arguments, specify
5569 @var{number} equal to zero.  If callee is responsible for popping the
5570 hidden pointer, specify @var{number} equal to one.  
5572 The default x86-32 ABI assumes that the callee pops the
5573 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5574 the compiler assumes that the
5575 caller pops the stack for hidden pointer.
5577 @item ms_hook_prologue
5578 @cindex @code{ms_hook_prologue} function attribute, x86
5580 On 32-bit and 64-bit x86 targets, you can use
5581 this function attribute to make GCC generate the ``hot-patching'' function
5582 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5583 and newer.
5585 @item naked
5586 @cindex @code{naked} function attribute, x86
5587 This attribute allows the compiler to construct the
5588 requisite function declaration, while allowing the body of the
5589 function to be assembly code. The specified function will not have
5590 prologue/epilogue sequences generated by the compiler. Only basic
5591 @code{asm} statements can safely be included in naked functions
5592 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5593 basic @code{asm} and C code may appear to work, they cannot be
5594 depended upon to work reliably and are not supported.
5596 @item regparm (@var{number})
5597 @cindex @code{regparm} function attribute, x86
5598 @cindex functions that are passed arguments in registers on x86-32
5599 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5600 pass arguments number one to @var{number} if they are of integral type
5601 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5602 take a variable number of arguments continue to be passed all of their
5603 arguments on the stack.
5605 Beware that on some ELF systems this attribute is unsuitable for
5606 global functions in shared libraries with lazy binding (which is the
5607 default).  Lazy binding sends the first call via resolving code in
5608 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5609 per the standard calling conventions.  Solaris 8 is affected by this.
5610 Systems with the GNU C Library version 2.1 or higher
5611 and FreeBSD are believed to be
5612 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5613 disabled with the linker or the loader if desired, to avoid the
5614 problem.)
5616 @item sseregparm
5617 @cindex @code{sseregparm} function attribute, x86
5618 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5619 causes the compiler to pass up to 3 floating-point arguments in
5620 SSE registers instead of on the stack.  Functions that take a
5621 variable number of arguments continue to pass all of their
5622 floating-point arguments on the stack.
5624 @item force_align_arg_pointer
5625 @cindex @code{force_align_arg_pointer} function attribute, x86
5626 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5627 applied to individual function definitions, generating an alternate
5628 prologue and epilogue that realigns the run-time stack if necessary.
5629 This supports mixing legacy codes that run with a 4-byte aligned stack
5630 with modern codes that keep a 16-byte stack for SSE compatibility.
5632 @item stdcall
5633 @cindex @code{stdcall} function attribute, x86-32
5634 @cindex functions that pop the argument stack on x86-32
5635 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5636 assume that the called function pops off the stack space used to
5637 pass arguments, unless it takes a variable number of arguments.
5639 @item no_caller_saved_registers
5640 @cindex @code{no_caller_saved_registers} function attribute, x86
5641 Use this attribute to indicate that the specified function has no
5642 caller-saved registers. That is, all registers are callee-saved. For
5643 example, this attribute can be used for a function called from an
5644 interrupt handler. The compiler generates proper function entry and
5645 exit sequences to save and restore any modified registers, except for
5646 the EFLAGS register.  Since GCC doesn't preserve SSE, MMX nor x87
5647 states, the GCC option @option{-mgeneral-regs-only} should be used to
5648 compile functions with @code{no_caller_saved_registers} attribute.
5650 @item interrupt
5651 @cindex @code{interrupt} function attribute, x86
5652 Use this attribute to indicate that the specified function is an
5653 interrupt handler or an exception handler (depending on parameters passed
5654 to the function, explained further).  The compiler generates function
5655 entry and exit sequences suitable for use in an interrupt handler when
5656 this attribute is present.  The @code{IRET} instruction, instead of the
5657 @code{RET} instruction, is used to return from interrupt handlers.  All
5658 registers, except for the EFLAGS register which is restored by the
5659 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5660 doesn't preserve SSE, MMX nor x87 states, the GCC option
5661 @option{-mgeneral-regs-only} should be used to compile interrupt and
5662 exception handlers.
5664 Any interruptible-without-stack-switch code must be compiled with
5665 @option{-mno-red-zone} since interrupt handlers can and will, because
5666 of the hardware design, touch the red zone.
5668 An interrupt handler must be declared with a mandatory pointer
5669 argument:
5671 @smallexample
5672 struct interrupt_frame;
5674 __attribute__ ((interrupt))
5675 void
5676 f (struct interrupt_frame *frame)
5679 @end smallexample
5681 @noindent
5682 and you must define @code{struct interrupt_frame} as described in the
5683 processor's manual.
5685 Exception handlers differ from interrupt handlers because the system
5686 pushes an error code on the stack.  An exception handler declaration is
5687 similar to that for an interrupt handler, but with a different mandatory
5688 function signature.  The compiler arranges to pop the error code off the
5689 stack before the @code{IRET} instruction.
5691 @smallexample
5692 #ifdef __x86_64__
5693 typedef unsigned long long int uword_t;
5694 #else
5695 typedef unsigned int uword_t;
5696 #endif
5698 struct interrupt_frame;
5700 __attribute__ ((interrupt))
5701 void
5702 f (struct interrupt_frame *frame, uword_t error_code)
5704   ...
5706 @end smallexample
5708 Exception handlers should only be used for exceptions that push an error
5709 code; you should use an interrupt handler in other cases.  The system
5710 will crash if the wrong kind of handler is used.
5712 @item target (@var{options})
5713 @cindex @code{target} function attribute
5714 As discussed in @ref{Common Function Attributes}, this attribute 
5715 allows specification of target-specific compilation options.
5717 On the x86, the following options are allowed:
5718 @table @samp
5719 @item abm
5720 @itemx no-abm
5721 @cindex @code{target("abm")} function attribute, x86
5722 Enable/disable the generation of the advanced bit instructions.
5724 @item aes
5725 @itemx no-aes
5726 @cindex @code{target("aes")} function attribute, x86
5727 Enable/disable the generation of the AES instructions.
5729 @item default
5730 @cindex @code{target("default")} function attribute, x86
5731 @xref{Function Multiversioning}, where it is used to specify the
5732 default function version.
5734 @item mmx
5735 @itemx no-mmx
5736 @cindex @code{target("mmx")} function attribute, x86
5737 Enable/disable the generation of the MMX instructions.
5739 @item pclmul
5740 @itemx no-pclmul
5741 @cindex @code{target("pclmul")} function attribute, x86
5742 Enable/disable the generation of the PCLMUL instructions.
5744 @item popcnt
5745 @itemx no-popcnt
5746 @cindex @code{target("popcnt")} function attribute, x86
5747 Enable/disable the generation of the POPCNT instruction.
5749 @item sse
5750 @itemx no-sse
5751 @cindex @code{target("sse")} function attribute, x86
5752 Enable/disable the generation of the SSE instructions.
5754 @item sse2
5755 @itemx no-sse2
5756 @cindex @code{target("sse2")} function attribute, x86
5757 Enable/disable the generation of the SSE2 instructions.
5759 @item sse3
5760 @itemx no-sse3
5761 @cindex @code{target("sse3")} function attribute, x86
5762 Enable/disable the generation of the SSE3 instructions.
5764 @item sse4
5765 @itemx no-sse4
5766 @cindex @code{target("sse4")} function attribute, x86
5767 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5768 and SSE4.2).
5770 @item sse4.1
5771 @itemx no-sse4.1
5772 @cindex @code{target("sse4.1")} function attribute, x86
5773 Enable/disable the generation of the sse4.1 instructions.
5775 @item sse4.2
5776 @itemx no-sse4.2
5777 @cindex @code{target("sse4.2")} function attribute, x86
5778 Enable/disable the generation of the sse4.2 instructions.
5780 @item sse4a
5781 @itemx no-sse4a
5782 @cindex @code{target("sse4a")} function attribute, x86
5783 Enable/disable the generation of the SSE4A instructions.
5785 @item fma4
5786 @itemx no-fma4
5787 @cindex @code{target("fma4")} function attribute, x86
5788 Enable/disable the generation of the FMA4 instructions.
5790 @item xop
5791 @itemx no-xop
5792 @cindex @code{target("xop")} function attribute, x86
5793 Enable/disable the generation of the XOP instructions.
5795 @item lwp
5796 @itemx no-lwp
5797 @cindex @code{target("lwp")} function attribute, x86
5798 Enable/disable the generation of the LWP instructions.
5800 @item ssse3
5801 @itemx no-ssse3
5802 @cindex @code{target("ssse3")} function attribute, x86
5803 Enable/disable the generation of the SSSE3 instructions.
5805 @item cld
5806 @itemx no-cld
5807 @cindex @code{target("cld")} function attribute, x86
5808 Enable/disable the generation of the CLD before string moves.
5810 @item fancy-math-387
5811 @itemx no-fancy-math-387
5812 @cindex @code{target("fancy-math-387")} function attribute, x86
5813 Enable/disable the generation of the @code{sin}, @code{cos}, and
5814 @code{sqrt} instructions on the 387 floating-point unit.
5816 @item ieee-fp
5817 @itemx no-ieee-fp
5818 @cindex @code{target("ieee-fp")} function attribute, x86
5819 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5821 @item inline-all-stringops
5822 @itemx no-inline-all-stringops
5823 @cindex @code{target("inline-all-stringops")} function attribute, x86
5824 Enable/disable inlining of string operations.
5826 @item inline-stringops-dynamically
5827 @itemx no-inline-stringops-dynamically
5828 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5829 Enable/disable the generation of the inline code to do small string
5830 operations and calling the library routines for large operations.
5832 @item align-stringops
5833 @itemx no-align-stringops
5834 @cindex @code{target("align-stringops")} function attribute, x86
5835 Do/do not align destination of inlined string operations.
5837 @item recip
5838 @itemx no-recip
5839 @cindex @code{target("recip")} function attribute, x86
5840 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5841 instructions followed an additional Newton-Raphson step instead of
5842 doing a floating-point division.
5844 @item arch=@var{ARCH}
5845 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5846 Specify the architecture to generate code for in compiling the function.
5848 @item tune=@var{TUNE}
5849 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5850 Specify the architecture to tune for in compiling the function.
5852 @item fpmath=@var{FPMATH}
5853 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5854 Specify which floating-point unit to use.  You must specify the
5855 @code{target("fpmath=sse,387")} option as
5856 @code{target("fpmath=sse+387")} because the comma would separate
5857 different options.
5859 @item indirect_branch("@var{choice}")
5860 @cindex @code{indirect_branch} function attribute, x86
5861 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5862 to convert indirect call and jump with @var{choice}.  @samp{keep}
5863 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
5864 call and jump to call and return thunk.  @samp{thunk-inline} converts
5865 indirect call and jump to inlined call and return thunk.
5866 @samp{thunk-extern} converts indirect call and jump to external call
5867 and return thunk provided in a separate object file.
5869 @item function_return("@var{choice}")
5870 @cindex @code{function_return} function attribute, x86
5871 On x86 targets, the @code{function_return} attribute causes the compiler
5872 to convert function return with @var{choice}.  @samp{keep} keeps function
5873 return unmodified.  @samp{thunk} converts function return to call and
5874 return thunk.  @samp{thunk-inline} converts function return to inlined
5875 call and return thunk.  @samp{thunk-extern} converts function return to
5876 external call and return thunk provided in a separate object file.
5878 @item nocf_check
5879 @cindex @code{nocf_check} function attribute
5880 The @code{nocf_check} attribute on a function is used to inform the
5881 compiler that the function's prologue should not be instrumented when
5882 compiled with the @option{-fcf-protection=branch} option.  The
5883 compiler assumes that the function's address is a valid target for a
5884 control-flow transfer.
5886 The @code{nocf_check} attribute on a type of pointer to function is
5887 used to inform the compiler that a call through the pointer should
5888 not be instrumented when compiled with the
5889 @option{-fcf-protection=branch} option.  The compiler assumes
5890 that the function's address from the pointer is a valid target for
5891 a control-flow transfer.  A direct function call through a function
5892 name is assumed to be a safe call thus direct calls are not
5893 instrumented by the compiler.
5895 The @code{nocf_check} attribute is applied to an object's type.
5896 In case of assignment of a function address or a function pointer to
5897 another pointer, the attribute is not carried over from the right-hand
5898 object's type; the type of left-hand object stays unchanged.  The
5899 compiler checks for @code{nocf_check} attribute mismatch and reports
5900 a warning in case of mismatch.
5902 @smallexample
5904 int foo (void) __attribute__(nocf_check);
5905 void (*foo1)(void) __attribute__(nocf_check);
5906 void (*foo2)(void);
5908 /* foo's address is assumed to be valid.  */
5910 foo (void) 
5912   /* This call site is not checked for control-flow 
5913      validity.  */
5914   (*foo1)();
5916   /* A warning is issued about attribute mismatch.  */
5917   foo1 = foo2; 
5919   /* This call site is still not checked.  */
5920   (*foo1)();
5922   /* This call site is checked.  */
5923   (*foo2)();
5925   /* A warning is issued about attribute mismatch.  */
5926   foo2 = foo1; 
5928   /* This call site is still checked.  */
5929   (*foo2)();
5931   return 0;
5933 @end smallexample
5935 @item indirect_return
5936 @cindex @code{indirect_return} function attribute, x86
5938 The @code{indirect_return} attribute can be applied to a function,
5939 as well as variable or type of function pointer to inform the
5940 compiler that the function may return via indirect branch.
5942 @end table
5944 On the x86, the inliner does not inline a
5945 function that has different target options than the caller, unless the
5946 callee has a subset of the target options of the caller.  For example
5947 a function declared with @code{target("sse3")} can inline a function
5948 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5949 @end table
5951 @node Xstormy16 Function Attributes
5952 @subsection Xstormy16 Function Attributes
5954 These function attributes are supported by the Xstormy16 back end:
5956 @table @code
5957 @item interrupt
5958 @cindex @code{interrupt} function attribute, Xstormy16
5959 Use this attribute to indicate
5960 that the specified function is an interrupt handler.  The compiler generates
5961 function entry and exit sequences suitable for use in an interrupt handler
5962 when this attribute is present.
5963 @end table
5965 @node Variable Attributes
5966 @section Specifying Attributes of Variables
5967 @cindex attribute of variables
5968 @cindex variable attributes
5970 The keyword @code{__attribute__} allows you to specify special
5971 attributes of variables or structure fields.  This keyword is followed
5972 by an attribute specification inside double parentheses.  Some
5973 attributes are currently defined generically for variables.
5974 Other attributes are defined for variables on particular target
5975 systems.  Other attributes are available for functions
5976 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5977 enumerators (@pxref{Enumerator Attributes}), statements
5978 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5979 Other front ends might define more attributes
5980 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5982 @xref{Attribute Syntax}, for details of the exact syntax for using
5983 attributes.
5985 @menu
5986 * Common Variable Attributes::
5987 * ARC Variable Attributes::
5988 * AVR Variable Attributes::
5989 * Blackfin Variable Attributes::
5990 * H8/300 Variable Attributes::
5991 * IA-64 Variable Attributes::
5992 * M32R/D Variable Attributes::
5993 * MeP Variable Attributes::
5994 * Microsoft Windows Variable Attributes::
5995 * MSP430 Variable Attributes::
5996 * Nvidia PTX Variable Attributes::
5997 * PowerPC Variable Attributes::
5998 * RL78 Variable Attributes::
5999 * SPU Variable Attributes::
6000 * V850 Variable Attributes::
6001 * x86 Variable Attributes::
6002 * Xstormy16 Variable Attributes::
6003 @end menu
6005 @node Common Variable Attributes
6006 @subsection Common Variable Attributes
6008 The following attributes are supported on most targets.
6010 @table @code
6011 @cindex @code{aligned} variable attribute
6012 @item aligned (@var{alignment})
6013 This attribute specifies a minimum alignment for the variable or
6014 structure field, measured in bytes.  For example, the declaration:
6016 @smallexample
6017 int x __attribute__ ((aligned (16))) = 0;
6018 @end smallexample
6020 @noindent
6021 causes the compiler to allocate the global variable @code{x} on a
6022 16-byte boundary.  On a 68040, this could be used in conjunction with
6023 an @code{asm} expression to access the @code{move16} instruction which
6024 requires 16-byte aligned operands.
6026 You can also specify the alignment of structure fields.  For example, to
6027 create a double-word aligned @code{int} pair, you could write:
6029 @smallexample
6030 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6031 @end smallexample
6033 @noindent
6034 This is an alternative to creating a union with a @code{double} member,
6035 which forces the union to be double-word aligned.
6037 As in the preceding examples, you can explicitly specify the alignment
6038 (in bytes) that you wish the compiler to use for a given variable or
6039 structure field.  Alternatively, you can leave out the alignment factor
6040 and just ask the compiler to align a variable or field to the
6041 default alignment for the target architecture you are compiling for.
6042 The default alignment is sufficient for all scalar types, but may not be
6043 enough for all vector types on a target that supports vector operations.
6044 The default alignment is fixed for a particular target ABI.
6046 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6047 which is the largest alignment ever used for any data type on the
6048 target machine you are compiling for.  For example, you could write:
6050 @smallexample
6051 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6052 @end smallexample
6054 The compiler automatically sets the alignment for the declared
6055 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
6056 often make copy operations more efficient, because the compiler can
6057 use whatever instructions copy the biggest chunks of memory when
6058 performing copies to or from the variables or fields that you have
6059 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
6060 may change depending on command-line options.
6062 When used on a struct, or struct member, the @code{aligned} attribute can
6063 only increase the alignment; in order to decrease it, the @code{packed}
6064 attribute must be specified as well.  When used as part of a typedef, the
6065 @code{aligned} attribute can both increase and decrease alignment, and
6066 specifying the @code{packed} attribute generates a warning.
6068 Note that the effectiveness of @code{aligned} attributes may be limited
6069 by inherent limitations in your linker.  On many systems, the linker is
6070 only able to arrange for variables to be aligned up to a certain maximum
6071 alignment.  (For some linkers, the maximum supported alignment may
6072 be very very small.)  If your linker is only able to align variables
6073 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6074 in an @code{__attribute__} still only provides you with 8-byte
6075 alignment.  See your linker documentation for further information.
6077 The @code{aligned} attribute can also be used for functions
6078 (@pxref{Common Function Attributes}.)
6080 @cindex @code{warn_if_not_aligned} variable attribute
6081 @item warn_if_not_aligned (@var{alignment})
6082 This attribute specifies a threshold for the structure field, measured
6083 in bytes.  If the structure field is aligned below the threshold, a
6084 warning will be issued.  For example, the declaration:
6086 @smallexample
6087 struct foo
6089   int i1;
6090   int i2;
6091   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6093 @end smallexample
6095 @noindent
6096 causes the compiler to issue an warning on @code{struct foo}, like
6097 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6098 The compiler also issues a warning, like @samp{warning: 'x' offset
6099 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6100 the misaligned offset:
6102 @smallexample
6103 struct foo
6105   int i1;
6106   int i2;
6107   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6108 @} __attribute__((aligned(16)));
6109 @end smallexample
6111 This warning can be disabled by @option{-Wno-if-not-aligned}.
6112 The @code{warn_if_not_aligned} attribute can also be used for types
6113 (@pxref{Common Type Attributes}.)
6115 @item cleanup (@var{cleanup_function})
6116 @cindex @code{cleanup} variable attribute
6117 The @code{cleanup} attribute runs a function when the variable goes
6118 out of scope.  This attribute can only be applied to auto function
6119 scope variables; it may not be applied to parameters or variables
6120 with static storage duration.  The function must take one parameter,
6121 a pointer to a type compatible with the variable.  The return value
6122 of the function (if any) is ignored.
6124 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6125 is run during the stack unwinding that happens during the
6126 processing of the exception.  Note that the @code{cleanup} attribute
6127 does not allow the exception to be caught, only to perform an action.
6128 It is undefined what happens if @var{cleanup_function} does not
6129 return normally.
6131 @item common
6132 @itemx nocommon
6133 @cindex @code{common} variable attribute
6134 @cindex @code{nocommon} variable attribute
6135 @opindex fcommon
6136 @opindex fno-common
6137 The @code{common} attribute requests GCC to place a variable in
6138 ``common'' storage.  The @code{nocommon} attribute requests the
6139 opposite---to allocate space for it directly.
6141 These attributes override the default chosen by the
6142 @option{-fno-common} and @option{-fcommon} flags respectively.
6144 @item deprecated
6145 @itemx deprecated (@var{msg})
6146 @cindex @code{deprecated} variable attribute
6147 The @code{deprecated} attribute results in a warning if the variable
6148 is used anywhere in the source file.  This is useful when identifying
6149 variables that are expected to be removed in a future version of a
6150 program.  The warning also includes the location of the declaration
6151 of the deprecated variable, to enable users to easily find further
6152 information about why the variable is deprecated, or what they should
6153 do instead.  Note that the warning only occurs for uses:
6155 @smallexample
6156 extern int old_var __attribute__ ((deprecated));
6157 extern int old_var;
6158 int new_fn () @{ return old_var; @}
6159 @end smallexample
6161 @noindent
6162 results in a warning on line 3 but not line 2.  The optional @var{msg}
6163 argument, which must be a string, is printed in the warning if
6164 present.
6166 The @code{deprecated} attribute can also be used for functions and
6167 types (@pxref{Common Function Attributes},
6168 @pxref{Common Type Attributes}).
6170 The message attached to the attribute is affected by the setting of
6171 the @option{-fmessage-length} option.
6173 @item mode (@var{mode})
6174 @cindex @code{mode} variable attribute
6175 This attribute specifies the data type for the declaration---whichever
6176 type corresponds to the mode @var{mode}.  This in effect lets you
6177 request an integer or floating-point type according to its width.
6179 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6180 for a list of the possible keywords for @var{mode}.
6181 You may also specify a mode of @code{byte} or @code{__byte__} to
6182 indicate the mode corresponding to a one-byte integer, @code{word} or
6183 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6184 or @code{__pointer__} for the mode used to represent pointers.
6186 @item nonstring
6187 @cindex @code{nonstring} variable attribute
6188 The @code{nonstring} variable attribute specifies that an object or member
6189 declaration with type array of @code{char}, @code{signed char}, or
6190 @code{unsigned char}, or pointer to such a type is intended to store
6191 character arrays that do not necessarily contain a terminating @code{NUL}.
6192 This is useful in detecting uses of such arrays or pointers with functions
6193 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6194 an array or pointer is used as an argument to a bounded string manipulation
6195 function such as @code{strncpy}.  For example, without the attribute, GCC
6196 will issue a warning for the @code{strncpy} call below because it may
6197 truncate the copy without appending the terminating @code{NUL} character.
6198 Using the attribute makes it possible to suppress the warning.  However,
6199 when the array is declared with the attribute the call to @code{strlen} is
6200 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6201 string the call is undefined.  To copy, compare, of search non-string
6202 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6203 and other functions that operate on arrays of bytes.  In addition,
6204 calling @code{strnlen} and @code{strndup} with such arrays is safe
6205 provided a suitable bound is specified, and not diagnosed.
6207 @smallexample
6208 struct Data
6210   char name [32] __attribute__ ((nonstring));
6213 int f (struct Data *pd, const char *s)
6215   strncpy (pd->name, s, sizeof pd->name);
6216   @dots{}
6217   return strlen (pd->name);   // unsafe, gets a warning
6219 @end smallexample
6221 @item packed
6222 @cindex @code{packed} variable attribute
6223 The @code{packed} attribute specifies that a variable or structure field
6224 should have the smallest possible alignment---one byte for a variable,
6225 and one bit for a field, unless you specify a larger value with the
6226 @code{aligned} attribute.
6228 Here is a structure in which the field @code{x} is packed, so that it
6229 immediately follows @code{a}:
6231 @smallexample
6232 struct foo
6234   char a;
6235   int x[2] __attribute__ ((packed));
6237 @end smallexample
6239 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6240 @code{packed} attribute on bit-fields of type @code{char}.  This has
6241 been fixed in GCC 4.4 but the change can lead to differences in the
6242 structure layout.  See the documentation of
6243 @option{-Wpacked-bitfield-compat} for more information.
6245 @item section ("@var{section-name}")
6246 @cindex @code{section} variable attribute
6247 Normally, the compiler places the objects it generates in sections like
6248 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6249 or you need certain particular variables to appear in special sections,
6250 for example to map to special hardware.  The @code{section}
6251 attribute specifies that a variable (or function) lives in a particular
6252 section.  For example, this small program uses several specific section names:
6254 @smallexample
6255 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6256 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6257 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6258 int init_data __attribute__ ((section ("INITDATA")));
6260 main()
6262   /* @r{Initialize stack pointer} */
6263   init_sp (stack + sizeof (stack));
6265   /* @r{Initialize initialized data} */
6266   memcpy (&init_data, &data, &edata - &data);
6268   /* @r{Turn on the serial ports} */
6269   init_duart (&a);
6270   init_duart (&b);
6272 @end smallexample
6274 @noindent
6275 Use the @code{section} attribute with
6276 @emph{global} variables and not @emph{local} variables,
6277 as shown in the example.
6279 You may use the @code{section} attribute with initialized or
6280 uninitialized global variables but the linker requires
6281 each object be defined once, with the exception that uninitialized
6282 variables tentatively go in the @code{common} (or @code{bss}) section
6283 and can be multiply ``defined''.  Using the @code{section} attribute
6284 changes what section the variable goes into and may cause the
6285 linker to issue an error if an uninitialized variable has multiple
6286 definitions.  You can force a variable to be initialized with the
6287 @option{-fno-common} flag or the @code{nocommon} attribute.
6289 Some file formats do not support arbitrary sections so the @code{section}
6290 attribute is not available on all platforms.
6291 If you need to map the entire contents of a module to a particular
6292 section, consider using the facilities of the linker instead.
6294 @item tls_model ("@var{tls_model}")
6295 @cindex @code{tls_model} variable attribute
6296 The @code{tls_model} attribute sets thread-local storage model
6297 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6298 overriding @option{-ftls-model=} command-line switch on a per-variable
6299 basis.
6300 The @var{tls_model} argument should be one of @code{global-dynamic},
6301 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6303 Not all targets support this attribute.
6305 @item unused
6306 @cindex @code{unused} variable attribute
6307 This attribute, attached to a variable, means that the variable is meant
6308 to be possibly unused.  GCC does not produce a warning for this
6309 variable.
6311 @item used
6312 @cindex @code{used} variable attribute
6313 This attribute, attached to a variable with static storage, means that
6314 the variable must be emitted even if it appears that the variable is not
6315 referenced.
6317 When applied to a static data member of a C++ class template, the
6318 attribute also means that the member is instantiated if the
6319 class itself is instantiated.
6321 @item vector_size (@var{bytes})
6322 @cindex @code{vector_size} variable attribute
6323 This attribute specifies the vector size for the variable, measured in
6324 bytes.  For example, the declaration:
6326 @smallexample
6327 int foo __attribute__ ((vector_size (16)));
6328 @end smallexample
6330 @noindent
6331 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6332 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6333 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6335 This attribute is only applicable to integral and float scalars,
6336 although arrays, pointers, and function return values are allowed in
6337 conjunction with this construct.
6339 Aggregates with this attribute are invalid, even if they are of the same
6340 size as a corresponding scalar.  For example, the declaration:
6342 @smallexample
6343 struct S @{ int a; @};
6344 struct S  __attribute__ ((vector_size (16))) foo;
6345 @end smallexample
6347 @noindent
6348 is invalid even if the size of the structure is the same as the size of
6349 the @code{int}.
6351 @item visibility ("@var{visibility_type}")
6352 @cindex @code{visibility} variable attribute
6353 This attribute affects the linkage of the declaration to which it is attached.
6354 The @code{visibility} attribute is described in
6355 @ref{Common Function Attributes}.
6357 @item weak
6358 @cindex @code{weak} variable attribute
6359 The @code{weak} attribute is described in
6360 @ref{Common Function Attributes}.
6362 @end table
6364 @node ARC Variable Attributes
6365 @subsection ARC Variable Attributes
6367 @table @code
6368 @item aux
6369 @cindex @code{aux} variable attribute, ARC
6370 The @code{aux} attribute is used to directly access the ARC's
6371 auxiliary register space from C.  The auxilirary register number is
6372 given via attribute argument.
6374 @end table
6376 @node AVR Variable Attributes
6377 @subsection AVR Variable Attributes
6379 @table @code
6380 @item progmem
6381 @cindex @code{progmem} variable attribute, AVR
6382 The @code{progmem} attribute is used on the AVR to place read-only
6383 data in the non-volatile program memory (flash). The @code{progmem}
6384 attribute accomplishes this by putting respective variables into a
6385 section whose name starts with @code{.progmem}.
6387 This attribute works similar to the @code{section} attribute
6388 but adds additional checking.
6390 @table @asis
6391 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6392 @code{progmem} affects the location
6393 of the data but not how this data is accessed.
6394 In order to read data located with the @code{progmem} attribute
6395 (inline) assembler must be used.
6396 @smallexample
6397 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6398 #include <avr/pgmspace.h> 
6400 /* Locate var in flash memory */
6401 const int var[2] PROGMEM = @{ 1, 2 @};
6403 int read_var (int i)
6405     /* Access var[] by accessor macro from avr/pgmspace.h */
6406     return (int) pgm_read_word (& var[i]);
6408 @end smallexample
6410 AVR is a Harvard architecture processor and data and read-only data
6411 normally resides in the data memory (RAM).
6413 See also the @ref{AVR Named Address Spaces} section for
6414 an alternate way to locate and access data in flash memory.
6416 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6417 On such devices, there is no need for attribute @code{progmem} or
6418 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6419 Just use standard C / C++.  The compiler will generate @code{LD*}
6420 instructions.  As flash memory is visible in the RAM address range,
6421 and the default linker script does @emph{not} locate @code{.rodata} in
6422 RAM, no special features are needed in order not to waste RAM for
6423 read-only data or to read from flash.  You might even get slightly better
6424 performance by
6425 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6426 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6427 an overview.
6429 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6430 The compiler adds @code{0x4000}
6431 to the addresses of objects and declarations in @code{progmem} and locates
6432 the objects in flash memory, namely in section @code{.progmem.data}.
6433 The offset is needed because the flash memory is visible in the RAM
6434 address space starting at address @code{0x4000}.
6436 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6437 no special functions or macros are needed.
6439 @smallexample
6440 /* var is located in flash memory */
6441 extern const int var[2] __attribute__((progmem));
6443 int read_var (int i)
6445     return var[i];
6447 @end smallexample
6449 Please notice that on these devices, there is no need for @code{progmem}
6450 at all.
6452 @end table
6454 @item io
6455 @itemx io (@var{addr})
6456 @cindex @code{io} variable attribute, AVR
6457 Variables with the @code{io} attribute are used to address
6458 memory-mapped peripherals in the io address range.
6459 If an address is specified, the variable
6460 is assigned that address, and the value is interpreted as an
6461 address in the data address space.
6462 Example:
6464 @smallexample
6465 volatile int porta __attribute__((io (0x22)));
6466 @end smallexample
6468 The address specified in the address in the data address range.
6470 Otherwise, the variable it is not assigned an address, but the
6471 compiler will still use in/out instructions where applicable,
6472 assuming some other module assigns an address in the io address range.
6473 Example:
6475 @smallexample
6476 extern volatile int porta __attribute__((io));
6477 @end smallexample
6479 @item io_low
6480 @itemx io_low (@var{addr})
6481 @cindex @code{io_low} variable attribute, AVR
6482 This is like the @code{io} attribute, but additionally it informs the
6483 compiler that the object lies in the lower half of the I/O area,
6484 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6485 instructions.
6487 @item address
6488 @itemx address (@var{addr})
6489 @cindex @code{address} variable attribute, AVR
6490 Variables with the @code{address} attribute are used to address
6491 memory-mapped peripherals that may lie outside the io address range.
6493 @smallexample
6494 volatile int porta __attribute__((address (0x600)));
6495 @end smallexample
6497 @item absdata
6498 @cindex @code{absdata} variable attribute, AVR
6499 Variables in static storage and with the @code{absdata} attribute can
6500 be accessed by the @code{LDS} and @code{STS} instructions which take
6501 absolute addresses.
6503 @itemize @bullet
6504 @item
6505 This attribute is only supported for the reduced AVR Tiny core
6506 like ATtiny40.
6508 @item
6509 You must make sure that respective data is located in the
6510 address range @code{0x40}@dots{}@code{0xbf} accessible by
6511 @code{LDS} and @code{STS}.  One way to achieve this as an
6512 appropriate linker description file.
6514 @item
6515 If the location does not fit the address range of @code{LDS}
6516 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6517 warning like
6518 @quotation
6519 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6520 @end quotation
6522 @end itemize
6524 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6526 @end table
6528 @node Blackfin Variable Attributes
6529 @subsection Blackfin Variable Attributes
6531 Three attributes are currently defined for the Blackfin.
6533 @table @code
6534 @item l1_data
6535 @itemx l1_data_A
6536 @itemx l1_data_B
6537 @cindex @code{l1_data} variable attribute, Blackfin
6538 @cindex @code{l1_data_A} variable attribute, Blackfin
6539 @cindex @code{l1_data_B} variable attribute, Blackfin
6540 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6541 Variables with @code{l1_data} attribute are put into the specific section
6542 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6543 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6544 attribute are put into the specific section named @code{.l1.data.B}.
6546 @item l2
6547 @cindex @code{l2} variable attribute, Blackfin
6548 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6549 Variables with @code{l2} attribute are put into the specific section
6550 named @code{.l2.data}.
6551 @end table
6553 @node H8/300 Variable Attributes
6554 @subsection H8/300 Variable Attributes
6556 These variable attributes are available for H8/300 targets:
6558 @table @code
6559 @item eightbit_data
6560 @cindex @code{eightbit_data} variable attribute, H8/300
6561 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6562 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6563 variable should be placed into the eight-bit data section.
6564 The compiler generates more efficient code for certain operations
6565 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6566 256 bytes of data.
6568 You must use GAS and GLD from GNU binutils version 2.7 or later for
6569 this attribute to work correctly.
6571 @item tiny_data
6572 @cindex @code{tiny_data} variable attribute, H8/300
6573 @cindex tiny data section on the H8/300H and H8S
6574 Use this attribute on the H8/300H and H8S to indicate that the specified
6575 variable should be placed into the tiny data section.
6576 The compiler generates more efficient code for loads and stores
6577 on data in the tiny data section.  Note the tiny data area is limited to
6578 slightly under 32KB of data.
6580 @end table
6582 @node IA-64 Variable Attributes
6583 @subsection IA-64 Variable Attributes
6585 The IA-64 back end supports the following variable attribute:
6587 @table @code
6588 @item model (@var{model-name})
6589 @cindex @code{model} variable attribute, IA-64
6591 On IA-64, use this attribute to set the addressability of an object.
6592 At present, the only supported identifier for @var{model-name} is
6593 @code{small}, indicating addressability via ``small'' (22-bit)
6594 addresses (so that their addresses can be loaded with the @code{addl}
6595 instruction).  Caveat: such addressing is by definition not position
6596 independent and hence this attribute must not be used for objects
6597 defined by shared libraries.
6599 @end table
6601 @node M32R/D Variable Attributes
6602 @subsection M32R/D Variable Attributes
6604 One attribute is currently defined for the M32R/D@.
6606 @table @code
6607 @item model (@var{model-name})
6608 @cindex @code{model-name} variable attribute, M32R/D
6609 @cindex variable addressability on the M32R/D
6610 Use this attribute on the M32R/D to set the addressability of an object.
6611 The identifier @var{model-name} is one of @code{small}, @code{medium},
6612 or @code{large}, representing each of the code models.
6614 Small model objects live in the lower 16MB of memory (so that their
6615 addresses can be loaded with the @code{ld24} instruction).
6617 Medium and large model objects may live anywhere in the 32-bit address space
6618 (the compiler generates @code{seth/add3} instructions to load their
6619 addresses).
6620 @end table
6622 @node MeP Variable Attributes
6623 @subsection MeP Variable Attributes
6625 The MeP target has a number of addressing modes and busses.  The
6626 @code{near} space spans the standard memory space's first 16 megabytes
6627 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6628 The @code{based} space is a 128-byte region in the memory space that
6629 is addressed relative to the @code{$tp} register.  The @code{tiny}
6630 space is a 65536-byte region relative to the @code{$gp} register.  In
6631 addition to these memory regions, the MeP target has a separate 16-bit
6632 control bus which is specified with @code{cb} attributes.
6634 @table @code
6636 @item based
6637 @cindex @code{based} variable attribute, MeP
6638 Any variable with the @code{based} attribute is assigned to the
6639 @code{.based} section, and is accessed with relative to the
6640 @code{$tp} register.
6642 @item tiny
6643 @cindex @code{tiny} variable attribute, MeP
6644 Likewise, the @code{tiny} attribute assigned variables to the
6645 @code{.tiny} section, relative to the @code{$gp} register.
6647 @item near
6648 @cindex @code{near} variable attribute, MeP
6649 Variables with the @code{near} attribute are assumed to have addresses
6650 that fit in a 24-bit addressing mode.  This is the default for large
6651 variables (@code{-mtiny=4} is the default) but this attribute can
6652 override @code{-mtiny=} for small variables, or override @code{-ml}.
6654 @item far
6655 @cindex @code{far} variable attribute, MeP
6656 Variables with the @code{far} attribute are addressed using a full
6657 32-bit address.  Since this covers the entire memory space, this
6658 allows modules to make no assumptions about where variables might be
6659 stored.
6661 @item io
6662 @cindex @code{io} variable attribute, MeP
6663 @itemx io (@var{addr})
6664 Variables with the @code{io} attribute are used to address
6665 memory-mapped peripherals.  If an address is specified, the variable
6666 is assigned that address, else it is not assigned an address (it is
6667 assumed some other module assigns an address).  Example:
6669 @smallexample
6670 int timer_count __attribute__((io(0x123)));
6671 @end smallexample
6673 @item cb
6674 @itemx cb (@var{addr})
6675 @cindex @code{cb} variable attribute, MeP
6676 Variables with the @code{cb} attribute are used to access the control
6677 bus, using special instructions.  @code{addr} indicates the control bus
6678 address.  Example:
6680 @smallexample
6681 int cpu_clock __attribute__((cb(0x123)));
6682 @end smallexample
6684 @end table
6686 @node Microsoft Windows Variable Attributes
6687 @subsection Microsoft Windows Variable Attributes
6689 You can use these attributes on Microsoft Windows targets.
6690 @ref{x86 Variable Attributes} for additional Windows compatibility
6691 attributes available on all x86 targets.
6693 @table @code
6694 @item dllimport
6695 @itemx dllexport
6696 @cindex @code{dllimport} variable attribute
6697 @cindex @code{dllexport} variable attribute
6698 The @code{dllimport} and @code{dllexport} attributes are described in
6699 @ref{Microsoft Windows Function Attributes}.
6701 @item selectany
6702 @cindex @code{selectany} variable attribute
6703 The @code{selectany} attribute causes an initialized global variable to
6704 have link-once semantics.  When multiple definitions of the variable are
6705 encountered by the linker, the first is selected and the remainder are
6706 discarded.  Following usage by the Microsoft compiler, the linker is told
6707 @emph{not} to warn about size or content differences of the multiple
6708 definitions.
6710 Although the primary usage of this attribute is for POD types, the
6711 attribute can also be applied to global C++ objects that are initialized
6712 by a constructor.  In this case, the static initialization and destruction
6713 code for the object is emitted in each translation defining the object,
6714 but the calls to the constructor and destructor are protected by a
6715 link-once guard variable.
6717 The @code{selectany} attribute is only available on Microsoft Windows
6718 targets.  You can use @code{__declspec (selectany)} as a synonym for
6719 @code{__attribute__ ((selectany))} for compatibility with other
6720 compilers.
6722 @item shared
6723 @cindex @code{shared} variable attribute
6724 On Microsoft Windows, in addition to putting variable definitions in a named
6725 section, the section can also be shared among all running copies of an
6726 executable or DLL@.  For example, this small program defines shared data
6727 by putting it in a named section @code{shared} and marking the section
6728 shareable:
6730 @smallexample
6731 int foo __attribute__((section ("shared"), shared)) = 0;
6734 main()
6736   /* @r{Read and write foo.  All running
6737      copies see the same value.}  */
6738   return 0;
6740 @end smallexample
6742 @noindent
6743 You may only use the @code{shared} attribute along with @code{section}
6744 attribute with a fully-initialized global definition because of the way
6745 linkers work.  See @code{section} attribute for more information.
6747 The @code{shared} attribute is only available on Microsoft Windows@.
6749 @end table
6751 @node MSP430 Variable Attributes
6752 @subsection MSP430 Variable Attributes
6754 @table @code
6755 @item noinit
6756 @cindex @code{noinit} variable attribute, MSP430 
6757 Any data with the @code{noinit} attribute will not be initialised by
6758 the C runtime startup code, or the program loader.  Not initialising
6759 data in this way can reduce program startup times.
6761 @item persistent
6762 @cindex @code{persistent} variable attribute, MSP430 
6763 Any variable with the @code{persistent} attribute will not be
6764 initialised by the C runtime startup code.  Instead its value will be
6765 set once, when the application is loaded, and then never initialised
6766 again, even if the processor is reset or the program restarts.
6767 Persistent data is intended to be placed into FLASH RAM, where its
6768 value will be retained across resets.  The linker script being used to
6769 create the application should ensure that persistent data is correctly
6770 placed.
6772 @item lower
6773 @itemx upper
6774 @itemx either
6775 @cindex @code{lower} variable attribute, MSP430 
6776 @cindex @code{upper} variable attribute, MSP430 
6777 @cindex @code{either} variable attribute, MSP430 
6778 These attributes are the same as the MSP430 function attributes of the
6779 same name (@pxref{MSP430 Function Attributes}).  
6780 These attributes can be applied to both functions and variables.
6781 @end table
6783 @node Nvidia PTX Variable Attributes
6784 @subsection Nvidia PTX Variable Attributes
6786 These variable attributes are supported by the Nvidia PTX back end:
6788 @table @code
6789 @item shared
6790 @cindex @code{shared} attribute, Nvidia PTX
6791 Use this attribute to place a variable in the @code{.shared} memory space.
6792 This memory space is private to each cooperative thread array; only threads
6793 within one thread block refer to the same instance of the variable.
6794 The runtime does not initialize variables in this memory space.
6795 @end table
6797 @node PowerPC Variable Attributes
6798 @subsection PowerPC Variable Attributes
6800 Three attributes currently are defined for PowerPC configurations:
6801 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6803 @cindex @code{ms_struct} variable attribute, PowerPC
6804 @cindex @code{gcc_struct} variable attribute, PowerPC
6805 For full documentation of the struct attributes please see the
6806 documentation in @ref{x86 Variable Attributes}.
6808 @cindex @code{altivec} variable attribute, PowerPC
6809 For documentation of @code{altivec} attribute please see the
6810 documentation in @ref{PowerPC Type Attributes}.
6812 @node RL78 Variable Attributes
6813 @subsection RL78 Variable Attributes
6815 @cindex @code{saddr} variable attribute, RL78
6816 The RL78 back end supports the @code{saddr} variable attribute.  This
6817 specifies placement of the corresponding variable in the SADDR area,
6818 which can be accessed more efficiently than the default memory region.
6820 @node SPU Variable Attributes
6821 @subsection SPU Variable Attributes
6823 @cindex @code{spu_vector} variable attribute, SPU
6824 The SPU supports the @code{spu_vector} attribute for variables.  For
6825 documentation of this attribute please see the documentation in
6826 @ref{SPU Type Attributes}.
6828 @node V850 Variable Attributes
6829 @subsection V850 Variable Attributes
6831 These variable attributes are supported by the V850 back end:
6833 @table @code
6835 @item sda
6836 @cindex @code{sda} variable attribute, V850
6837 Use this attribute to explicitly place a variable in the small data area,
6838 which can hold up to 64 kilobytes.
6840 @item tda
6841 @cindex @code{tda} variable attribute, V850
6842 Use this attribute to explicitly place a variable in the tiny data area,
6843 which can hold up to 256 bytes in total.
6845 @item zda
6846 @cindex @code{zda} variable attribute, V850
6847 Use this attribute to explicitly place a variable in the first 32 kilobytes
6848 of memory.
6849 @end table
6851 @node x86 Variable Attributes
6852 @subsection x86 Variable Attributes
6854 Two attributes are currently defined for x86 configurations:
6855 @code{ms_struct} and @code{gcc_struct}.
6857 @table @code
6858 @item ms_struct
6859 @itemx gcc_struct
6860 @cindex @code{ms_struct} variable attribute, x86
6861 @cindex @code{gcc_struct} variable attribute, x86
6863 If @code{packed} is used on a structure, or if bit-fields are used,
6864 it may be that the Microsoft ABI lays out the structure differently
6865 than the way GCC normally does.  Particularly when moving packed
6866 data between functions compiled with GCC and the native Microsoft compiler
6867 (either via function call or as data in a file), it may be necessary to access
6868 either format.
6870 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6871 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6872 command-line options, respectively;
6873 see @ref{x86 Options}, for details of how structure layout is affected.
6874 @xref{x86 Type Attributes}, for information about the corresponding
6875 attributes on types.
6877 @end table
6879 @node Xstormy16 Variable Attributes
6880 @subsection Xstormy16 Variable Attributes
6882 One attribute is currently defined for xstormy16 configurations:
6883 @code{below100}.
6885 @table @code
6886 @item below100
6887 @cindex @code{below100} variable attribute, Xstormy16
6889 If a variable has the @code{below100} attribute (@code{BELOW100} is
6890 allowed also), GCC places the variable in the first 0x100 bytes of
6891 memory and use special opcodes to access it.  Such variables are
6892 placed in either the @code{.bss_below100} section or the
6893 @code{.data_below100} section.
6895 @end table
6897 @node Type Attributes
6898 @section Specifying Attributes of Types
6899 @cindex attribute of types
6900 @cindex type attributes
6902 The keyword @code{__attribute__} allows you to specify special
6903 attributes of types.  Some type attributes apply only to @code{struct}
6904 and @code{union} types, while others can apply to any type defined
6905 via a @code{typedef} declaration.  Other attributes are defined for
6906 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6907 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6908 statements (@pxref{Statement Attributes}), and for
6909 variables (@pxref{Variable Attributes}).
6911 The @code{__attribute__} keyword is followed by an attribute specification
6912 inside double parentheses.  
6914 You may specify type attributes in an enum, struct or union type
6915 declaration or definition by placing them immediately after the
6916 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6917 syntax is to place them just past the closing curly brace of the
6918 definition.
6920 You can also include type attributes in a @code{typedef} declaration.
6921 @xref{Attribute Syntax}, for details of the exact syntax for using
6922 attributes.
6924 @menu
6925 * Common Type Attributes::
6926 * ARC Type Attributes::
6927 * ARM Type Attributes::
6928 * MeP Type Attributes::
6929 * PowerPC Type Attributes::
6930 * SPU Type Attributes::
6931 * x86 Type Attributes::
6932 @end menu
6934 @node Common Type Attributes
6935 @subsection Common Type Attributes
6937 The following type attributes are supported on most targets.
6939 @table @code
6940 @cindex @code{aligned} type attribute
6941 @item aligned (@var{alignment})
6942 This attribute specifies a minimum alignment (in bytes) for variables
6943 of the specified type.  For example, the declarations:
6945 @smallexample
6946 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6947 typedef int more_aligned_int __attribute__ ((aligned (8)));
6948 @end smallexample
6950 @noindent
6951 force the compiler to ensure (as far as it can) that each variable whose
6952 type is @code{struct S} or @code{more_aligned_int} is allocated and
6953 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6954 variables of type @code{struct S} aligned to 8-byte boundaries allows
6955 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6956 store) instructions when copying one variable of type @code{struct S} to
6957 another, thus improving run-time efficiency.
6959 Note that the alignment of any given @code{struct} or @code{union} type
6960 is required by the ISO C standard to be at least a perfect multiple of
6961 the lowest common multiple of the alignments of all of the members of
6962 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6963 effectively adjust the alignment of a @code{struct} or @code{union}
6964 type by attaching an @code{aligned} attribute to any one of the members
6965 of such a type, but the notation illustrated in the example above is a
6966 more obvious, intuitive, and readable way to request the compiler to
6967 adjust the alignment of an entire @code{struct} or @code{union} type.
6969 As in the preceding example, you can explicitly specify the alignment
6970 (in bytes) that you wish the compiler to use for a given @code{struct}
6971 or @code{union} type.  Alternatively, you can leave out the alignment factor
6972 and just ask the compiler to align a type to the maximum
6973 useful alignment for the target machine you are compiling for.  For
6974 example, you could write:
6976 @smallexample
6977 struct S @{ short f[3]; @} __attribute__ ((aligned));
6978 @end smallexample
6980 Whenever you leave out the alignment factor in an @code{aligned}
6981 attribute specification, the compiler automatically sets the alignment
6982 for the type to the largest alignment that is ever used for any data
6983 type on the target machine you are compiling for.  Doing this can often
6984 make copy operations more efficient, because the compiler can use
6985 whatever instructions copy the biggest chunks of memory when performing
6986 copies to or from the variables that have types that you have aligned
6987 this way.
6989 In the example above, if the size of each @code{short} is 2 bytes, then
6990 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6991 power of two that is greater than or equal to that is 8, so the
6992 compiler sets the alignment for the entire @code{struct S} type to 8
6993 bytes.
6995 Note that although you can ask the compiler to select a time-efficient
6996 alignment for a given type and then declare only individual stand-alone
6997 objects of that type, the compiler's ability to select a time-efficient
6998 alignment is primarily useful only when you plan to create arrays of
6999 variables having the relevant (efficiently aligned) type.  If you
7000 declare or use arrays of variables of an efficiently-aligned type, then
7001 it is likely that your program also does pointer arithmetic (or
7002 subscripting, which amounts to the same thing) on pointers to the
7003 relevant type, and the code that the compiler generates for these
7004 pointer arithmetic operations is often more efficient for
7005 efficiently-aligned types than for other types.
7007 Note that the effectiveness of @code{aligned} attributes may be limited
7008 by inherent limitations in your linker.  On many systems, the linker is
7009 only able to arrange for variables to be aligned up to a certain maximum
7010 alignment.  (For some linkers, the maximum supported alignment may
7011 be very very small.)  If your linker is only able to align variables
7012 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
7013 in an @code{__attribute__} still only provides you with 8-byte
7014 alignment.  See your linker documentation for further information.
7016 The @code{aligned} attribute can only increase alignment.  Alignment
7017 can be decreased by specifying the @code{packed} attribute.  See below.
7019 @cindex @code{warn_if_not_aligned} type attribute
7020 @item warn_if_not_aligned (@var{alignment})
7021 This attribute specifies a threshold for the structure field, measured
7022 in bytes.  If the structure field is aligned below the threshold, a
7023 warning will be issued.  For example, the declaration:
7025 @smallexample
7026 typedef unsigned long long __u64
7027    __attribute__((aligned(4),warn_if_not_aligned(8)));
7029 struct foo
7031   int i1;
7032   int i2;
7033   __u64 x;
7035 @end smallexample
7037 @noindent
7038 causes the compiler to issue an warning on @code{struct foo}, like
7039 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7040 It is used to define @code{struct foo} in such a way that
7041 @code{struct foo} has the same layout and the structure field @code{x}
7042 has the same alignment when @code{__u64} is aligned at either 4 or
7043 8 bytes.  Align @code{struct foo} to 8 bytes:
7045 @smallexample
7046 struct foo
7048   int i1;
7049   int i2;
7050   __u64 x;
7051 @} __attribute__((aligned(8)));
7052 @end smallexample
7054 @noindent
7055 silences the warning.  The compiler also issues a warning, like
7056 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7057 when the structure field has the misaligned offset:
7059 @smallexample
7060 struct foo
7062   int i1;
7063   int i2;
7064   int i3;
7065   __u64 x;
7066 @} __attribute__((aligned(8)));
7067 @end smallexample
7069 This warning can be disabled by @option{-Wno-if-not-aligned}.
7071 @item deprecated
7072 @itemx deprecated (@var{msg})
7073 @cindex @code{deprecated} type attribute
7074 The @code{deprecated} attribute results in a warning if the type
7075 is used anywhere in the source file.  This is useful when identifying
7076 types that are expected to be removed in a future version of a program.
7077 If possible, the warning also includes the location of the declaration
7078 of the deprecated type, to enable users to easily find further
7079 information about why the type is deprecated, or what they should do
7080 instead.  Note that the warnings only occur for uses and then only
7081 if the type is being applied to an identifier that itself is not being
7082 declared as deprecated.
7084 @smallexample
7085 typedef int T1 __attribute__ ((deprecated));
7086 T1 x;
7087 typedef T1 T2;
7088 T2 y;
7089 typedef T1 T3 __attribute__ ((deprecated));
7090 T3 z __attribute__ ((deprecated));
7091 @end smallexample
7093 @noindent
7094 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7095 warning is issued for line 4 because T2 is not explicitly
7096 deprecated.  Line 5 has no warning because T3 is explicitly
7097 deprecated.  Similarly for line 6.  The optional @var{msg}
7098 argument, which must be a string, is printed in the warning if
7099 present.  Control characters in the string will be replaced with
7100 escape sequences, and if the @option{-fmessage-length} option is set
7101 to 0 (its default value) then any newline characters will be ignored.
7103 The @code{deprecated} attribute can also be used for functions and
7104 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7106 The message attached to the attribute is affected by the setting of
7107 the @option{-fmessage-length} option.
7109 @item designated_init
7110 @cindex @code{designated_init} type attribute
7111 This attribute may only be applied to structure types.  It indicates
7112 that any initialization of an object of this type must use designated
7113 initializers rather than positional initializers.  The intent of this
7114 attribute is to allow the programmer to indicate that a structure's
7115 layout may change, and that therefore relying on positional
7116 initialization will result in future breakage.
7118 GCC emits warnings based on this attribute by default; use
7119 @option{-Wno-designated-init} to suppress them.
7121 @item may_alias
7122 @cindex @code{may_alias} type attribute
7123 Accesses through pointers to types with this attribute are not subject
7124 to type-based alias analysis, but are instead assumed to be able to alias
7125 any other type of objects.
7126 In the context of section 6.5 paragraph 7 of the C99 standard,
7127 an lvalue expression
7128 dereferencing such a pointer is treated like having a character type.
7129 See @option{-fstrict-aliasing} for more information on aliasing issues.
7130 This extension exists to support some vector APIs, in which pointers to
7131 one vector type are permitted to alias pointers to a different vector type.
7133 Note that an object of a type with this attribute does not have any
7134 special semantics.
7136 Example of use:
7138 @smallexample
7139 typedef short __attribute__((__may_alias__)) short_a;
7142 main (void)
7144   int a = 0x12345678;
7145   short_a *b = (short_a *) &a;
7147   b[1] = 0;
7149   if (a == 0x12345678)
7150     abort();
7152   exit(0);
7154 @end smallexample
7156 @noindent
7157 If you replaced @code{short_a} with @code{short} in the variable
7158 declaration, the above program would abort when compiled with
7159 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7160 above.
7162 @item mode (@var{mode})
7163 @cindex @code{mode} type attribute
7164 This attribute specifies the data type for the declaration---whichever
7165 type corresponds to the mode @var{mode}.  This in effect lets you
7166 request an integer or floating-point type according to its width.
7168 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7169 for a list of the possible keywords for @var{mode}.
7170 You may also specify a mode of @code{byte} or @code{__byte__} to
7171 indicate the mode corresponding to a one-byte integer, @code{word} or
7172 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7173 or @code{__pointer__} for the mode used to represent pointers.
7175 @item packed
7176 @cindex @code{packed} type attribute
7177 This attribute, attached to @code{struct} or @code{union} type
7178 definition, specifies that each member (other than zero-width bit-fields)
7179 of the structure or union is placed to minimize the memory required.  When
7180 attached to an @code{enum} definition, it indicates that the smallest
7181 integral type should be used.
7183 @opindex fshort-enums
7184 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7185 types is equivalent to specifying the @code{packed} attribute on each
7186 of the structure or union members.  Specifying the @option{-fshort-enums}
7187 flag on the command line is equivalent to specifying the @code{packed}
7188 attribute on all @code{enum} definitions.
7190 In the following example @code{struct my_packed_struct}'s members are
7191 packed closely together, but the internal layout of its @code{s} member
7192 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7193 be packed too.
7195 @smallexample
7196 struct my_unpacked_struct
7197  @{
7198     char c;
7199     int i;
7200  @};
7202 struct __attribute__ ((__packed__)) my_packed_struct
7203   @{
7204      char c;
7205      int  i;
7206      struct my_unpacked_struct s;
7207   @};
7208 @end smallexample
7210 You may only specify the @code{packed} attribute attribute on the definition
7211 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7212 that does not also define the enumerated type, structure or union.
7214 @item scalar_storage_order ("@var{endianness}")
7215 @cindex @code{scalar_storage_order} type attribute
7216 When attached to a @code{union} or a @code{struct}, this attribute sets
7217 the storage order, aka endianness, of the scalar fields of the type, as
7218 well as the array fields whose component is scalar.  The supported
7219 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
7220 has no effects on fields which are themselves a @code{union}, a @code{struct}
7221 or an array whose component is a @code{union} or a @code{struct}, and it is
7222 possible for these fields to have a different scalar storage order than the
7223 enclosing type.
7225 This attribute is supported only for targets that use a uniform default
7226 scalar storage order (fortunately, most of them), i.e. targets that store
7227 the scalars either all in big-endian or all in little-endian.
7229 Additional restrictions are enforced for types with the reverse scalar
7230 storage order with regard to the scalar storage order of the target:
7232 @itemize
7233 @item Taking the address of a scalar field of a @code{union} or a
7234 @code{struct} with reverse scalar storage order is not permitted and yields
7235 an error.
7236 @item Taking the address of an array field, whose component is scalar, of
7237 a @code{union} or a @code{struct} with reverse scalar storage order is
7238 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7239 is specified.
7240 @item Taking the address of a @code{union} or a @code{struct} with reverse
7241 scalar storage order is permitted.
7242 @end itemize
7244 These restrictions exist because the storage order attribute is lost when
7245 the address of a scalar or the address of an array with scalar component is
7246 taken, so storing indirectly through this address generally does not work.
7247 The second case is nevertheless allowed to be able to perform a block copy
7248 from or to the array.
7250 Moreover, the use of type punning or aliasing to toggle the storage order
7251 is not supported; that is to say, a given scalar object cannot be accessed
7252 through distinct types that assign a different storage order to it.
7254 @item transparent_union
7255 @cindex @code{transparent_union} type attribute
7257 This attribute, attached to a @code{union} type definition, indicates
7258 that any function parameter having that union type causes calls to that
7259 function to be treated in a special way.
7261 First, the argument corresponding to a transparent union type can be of
7262 any type in the union; no cast is required.  Also, if the union contains
7263 a pointer type, the corresponding argument can be a null pointer
7264 constant or a void pointer expression; and if the union contains a void
7265 pointer type, the corresponding argument can be any pointer expression.
7266 If the union member type is a pointer, qualifiers like @code{const} on
7267 the referenced type must be respected, just as with normal pointer
7268 conversions.
7270 Second, the argument is passed to the function using the calling
7271 conventions of the first member of the transparent union, not the calling
7272 conventions of the union itself.  All members of the union must have the
7273 same machine representation; this is necessary for this argument passing
7274 to work properly.
7276 Transparent unions are designed for library functions that have multiple
7277 interfaces for compatibility reasons.  For example, suppose the
7278 @code{wait} function must accept either a value of type @code{int *} to
7279 comply with POSIX, or a value of type @code{union wait *} to comply with
7280 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7281 @code{wait} would accept both kinds of arguments, but it would also
7282 accept any other pointer type and this would make argument type checking
7283 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7284 as follows:
7286 @smallexample
7287 typedef union __attribute__ ((__transparent_union__))
7288   @{
7289     int *__ip;
7290     union wait *__up;
7291   @} wait_status_ptr_t;
7293 pid_t wait (wait_status_ptr_t);
7294 @end smallexample
7296 @noindent
7297 This interface allows either @code{int *} or @code{union wait *}
7298 arguments to be passed, using the @code{int *} calling convention.
7299 The program can call @code{wait} with arguments of either type:
7301 @smallexample
7302 int w1 () @{ int w; return wait (&w); @}
7303 int w2 () @{ union wait w; return wait (&w); @}
7304 @end smallexample
7306 @noindent
7307 With this interface, @code{wait}'s implementation might look like this:
7309 @smallexample
7310 pid_t wait (wait_status_ptr_t p)
7312   return waitpid (-1, p.__ip, 0);
7314 @end smallexample
7316 @item unused
7317 @cindex @code{unused} type attribute
7318 When attached to a type (including a @code{union} or a @code{struct}),
7319 this attribute means that variables of that type are meant to appear
7320 possibly unused.  GCC does not produce a warning for any variables of
7321 that type, even if the variable appears to do nothing.  This is often
7322 the case with lock or thread classes, which are usually defined and then
7323 not referenced, but contain constructors and destructors that have
7324 nontrivial bookkeeping functions.
7326 @item visibility
7327 @cindex @code{visibility} type attribute
7328 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7329 applied to class, struct, union and enum types.  Unlike other type
7330 attributes, the attribute must appear between the initial keyword and
7331 the name of the type; it cannot appear after the body of the type.
7333 Note that the type visibility is applied to vague linkage entities
7334 associated with the class (vtable, typeinfo node, etc.).  In
7335 particular, if a class is thrown as an exception in one shared object
7336 and caught in another, the class must have default visibility.
7337 Otherwise the two shared objects are unable to use the same
7338 typeinfo node and exception handling will break.
7340 @end table
7342 To specify multiple attributes, separate them by commas within the
7343 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7344 packed))}.
7346 @node ARC Type Attributes
7347 @subsection ARC Type Attributes
7349 @cindex @code{uncached} type attribute, ARC
7350 Declaring objects with @code{uncached} allows you to exclude
7351 data-cache participation in load and store operations on those objects
7352 without involving the additional semantic implications of
7353 @code{volatile}.  The @code{.di} instruction suffix is used for all
7354 loads and stores of data declared @code{uncached}.
7356 @node ARM Type Attributes
7357 @subsection ARM Type Attributes
7359 @cindex @code{notshared} type attribute, ARM
7360 On those ARM targets that support @code{dllimport} (such as Symbian
7361 OS), you can use the @code{notshared} attribute to indicate that the
7362 virtual table and other similar data for a class should not be
7363 exported from a DLL@.  For example:
7365 @smallexample
7366 class __declspec(notshared) C @{
7367 public:
7368   __declspec(dllimport) C();
7369   virtual void f();
7372 __declspec(dllexport)
7373 C::C() @{@}
7374 @end smallexample
7376 @noindent
7377 In this code, @code{C::C} is exported from the current DLL, but the
7378 virtual table for @code{C} is not exported.  (You can use
7379 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7380 most Symbian OS code uses @code{__declspec}.)
7382 @node MeP Type Attributes
7383 @subsection MeP Type Attributes
7385 @cindex @code{based} type attribute, MeP
7386 @cindex @code{tiny} type attribute, MeP
7387 @cindex @code{near} type attribute, MeP
7388 @cindex @code{far} type attribute, MeP
7389 Many of the MeP variable attributes may be applied to types as well.
7390 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7391 @code{far} attributes may be applied to either.  The @code{io} and
7392 @code{cb} attributes may not be applied to types.
7394 @node PowerPC Type Attributes
7395 @subsection PowerPC Type Attributes
7397 Three attributes currently are defined for PowerPC configurations:
7398 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7400 @cindex @code{ms_struct} type attribute, PowerPC
7401 @cindex @code{gcc_struct} type attribute, PowerPC
7402 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7403 attributes please see the documentation in @ref{x86 Type Attributes}.
7405 @cindex @code{altivec} type attribute, PowerPC
7406 The @code{altivec} attribute allows one to declare AltiVec vector data
7407 types supported by the AltiVec Programming Interface Manual.  The
7408 attribute requires an argument to specify one of three vector types:
7409 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7410 and @code{bool__} (always followed by unsigned).
7412 @smallexample
7413 __attribute__((altivec(vector__)))
7414 __attribute__((altivec(pixel__))) unsigned short
7415 __attribute__((altivec(bool__))) unsigned
7416 @end smallexample
7418 These attributes mainly are intended to support the @code{__vector},
7419 @code{__pixel}, and @code{__bool} AltiVec keywords.
7421 @node SPU Type Attributes
7422 @subsection SPU Type Attributes
7424 @cindex @code{spu_vector} type attribute, SPU
7425 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7426 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7427 Language Extensions Specification.  It is intended to support the
7428 @code{__vector} keyword.
7430 @node x86 Type Attributes
7431 @subsection x86 Type Attributes
7433 Two attributes are currently defined for x86 configurations:
7434 @code{ms_struct} and @code{gcc_struct}.
7436 @table @code
7438 @item ms_struct
7439 @itemx gcc_struct
7440 @cindex @code{ms_struct} type attribute, x86
7441 @cindex @code{gcc_struct} type attribute, x86
7443 If @code{packed} is used on a structure, or if bit-fields are used
7444 it may be that the Microsoft ABI packs them differently
7445 than GCC normally packs them.  Particularly when moving packed
7446 data between functions compiled with GCC and the native Microsoft compiler
7447 (either via function call or as data in a file), it may be necessary to access
7448 either format.
7450 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7451 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7452 command-line options, respectively;
7453 see @ref{x86 Options}, for details of how structure layout is affected.
7454 @xref{x86 Variable Attributes}, for information about the corresponding
7455 attributes on variables.
7457 @end table
7459 @node Label Attributes
7460 @section Label Attributes
7461 @cindex Label Attributes
7463 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7464 details of the exact syntax for using attributes.  Other attributes are 
7465 available for functions (@pxref{Function Attributes}), variables 
7466 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7467 statements (@pxref{Statement Attributes}), and for types
7468 (@pxref{Type Attributes}).
7470 This example uses the @code{cold} label attribute to indicate the 
7471 @code{ErrorHandling} branch is unlikely to be taken and that the
7472 @code{ErrorHandling} label is unused:
7474 @smallexample
7476    asm goto ("some asm" : : : : NoError);
7478 /* This branch (the fall-through from the asm) is less commonly used */
7479 ErrorHandling: 
7480    __attribute__((cold, unused)); /* Semi-colon is required here */
7481    printf("error\n");
7482    return 0;
7484 NoError:
7485    printf("no error\n");
7486    return 1;
7487 @end smallexample
7489 @table @code
7490 @item unused
7491 @cindex @code{unused} label attribute
7492 This feature is intended for program-generated code that may contain 
7493 unused labels, but which is compiled with @option{-Wall}.  It is
7494 not normally appropriate to use in it human-written code, though it
7495 could be useful in cases where the code that jumps to the label is
7496 contained within an @code{#ifdef} conditional.
7498 @item hot
7499 @cindex @code{hot} label attribute
7500 The @code{hot} attribute on a label is used to inform the compiler that
7501 the path following the label is more likely than paths that are not so
7502 annotated.  This attribute is used in cases where @code{__builtin_expect}
7503 cannot be used, for instance with computed goto or @code{asm goto}.
7505 @item cold
7506 @cindex @code{cold} label attribute
7507 The @code{cold} attribute on labels is used to inform the compiler that
7508 the path following the label is unlikely to be executed.  This attribute
7509 is used in cases where @code{__builtin_expect} cannot be used, for instance
7510 with computed goto or @code{asm goto}.
7512 @end table
7514 @node Enumerator Attributes
7515 @section Enumerator Attributes
7516 @cindex Enumerator Attributes
7518 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7519 details of the exact syntax for using attributes.  Other attributes are
7520 available for functions (@pxref{Function Attributes}), variables
7521 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7522 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7524 This example uses the @code{deprecated} enumerator attribute to indicate the
7525 @code{oldval} enumerator is deprecated:
7527 @smallexample
7528 enum E @{
7529   oldval __attribute__((deprecated)),
7530   newval
7534 fn (void)
7536   return oldval;
7538 @end smallexample
7540 @table @code
7541 @item deprecated
7542 @cindex @code{deprecated} enumerator attribute
7543 The @code{deprecated} attribute results in a warning if the enumerator
7544 is used anywhere in the source file.  This is useful when identifying
7545 enumerators that are expected to be removed in a future version of a
7546 program.  The warning also includes the location of the declaration
7547 of the deprecated enumerator, to enable users to easily find further
7548 information about why the enumerator is deprecated, or what they should
7549 do instead.  Note that the warnings only occurs for uses.
7551 @end table
7553 @node Statement Attributes
7554 @section Statement Attributes
7555 @cindex Statement Attributes
7557 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7558 for details of the exact syntax for using attributes.  Other attributes are
7559 available for functions (@pxref{Function Attributes}), variables
7560 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7561 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7563 This example uses the @code{fallthrough} statement attribute to indicate that
7564 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7566 @smallexample
7567 switch (cond)
7568   @{
7569   case 1:
7570     bar (1);
7571     __attribute__((fallthrough));
7572   case 2:
7573     @dots{}
7574   @}
7575 @end smallexample
7577 @table @code
7578 @item fallthrough
7579 @cindex @code{fallthrough} statement attribute
7580 The @code{fallthrough} attribute with a null statement serves as a
7581 fallthrough statement.  It hints to the compiler that a statement
7582 that falls through to another case label, or user-defined label
7583 in a switch statement is intentional and thus the
7584 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7585 fallthrough attribute may appear at most once in each attribute
7586 list, and may not be mixed with other attributes.  It can only
7587 be used in a switch statement (the compiler will issue an error
7588 otherwise), after a preceding statement and before a logically
7589 succeeding case label, or user-defined label.
7591 @end table
7593 @node Attribute Syntax
7594 @section Attribute Syntax
7595 @cindex attribute syntax
7597 This section describes the syntax with which @code{__attribute__} may be
7598 used, and the constructs to which attribute specifiers bind, for the C
7599 language.  Some details may vary for C++ and Objective-C@.  Because of
7600 infelicities in the grammar for attributes, some forms described here
7601 may not be successfully parsed in all cases.
7603 There are some problems with the semantics of attributes in C++.  For
7604 example, there are no manglings for attributes, although they may affect
7605 code generation, so problems may arise when attributed types are used in
7606 conjunction with templates or overloading.  Similarly, @code{typeid}
7607 does not distinguish between types with different attributes.  Support
7608 for attributes in C++ may be restricted in future to attributes on
7609 declarations only, but not on nested declarators.
7611 @xref{Function Attributes}, for details of the semantics of attributes
7612 applying to functions.  @xref{Variable Attributes}, for details of the
7613 semantics of attributes applying to variables.  @xref{Type Attributes},
7614 for details of the semantics of attributes applying to structure, union
7615 and enumerated types.
7616 @xref{Label Attributes}, for details of the semantics of attributes 
7617 applying to labels.
7618 @xref{Enumerator Attributes}, for details of the semantics of attributes
7619 applying to enumerators.
7620 @xref{Statement Attributes}, for details of the semantics of attributes
7621 applying to statements.
7623 An @dfn{attribute specifier} is of the form
7624 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7625 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7626 each attribute is one of the following:
7628 @itemize @bullet
7629 @item
7630 Empty.  Empty attributes are ignored.
7632 @item
7633 An attribute name
7634 (which may be an identifier such as @code{unused}, or a reserved
7635 word such as @code{const}).
7637 @item
7638 An attribute name followed by a parenthesized list of
7639 parameters for the attribute.
7640 These parameters take one of the following forms:
7642 @itemize @bullet
7643 @item
7644 An identifier.  For example, @code{mode} attributes use this form.
7646 @item
7647 An identifier followed by a comma and a non-empty comma-separated list
7648 of expressions.  For example, @code{format} attributes use this form.
7650 @item
7651 A possibly empty comma-separated list of expressions.  For example,
7652 @code{format_arg} attributes use this form with the list being a single
7653 integer constant expression, and @code{alias} attributes use this form
7654 with the list being a single string constant.
7655 @end itemize
7656 @end itemize
7658 An @dfn{attribute specifier list} is a sequence of one or more attribute
7659 specifiers, not separated by any other tokens.
7661 You may optionally specify attribute names with @samp{__}
7662 preceding and following the name.
7663 This allows you to use them in header files without
7664 being concerned about a possible macro of the same name.  For example,
7665 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7668 @subsubheading Label Attributes
7670 In GNU C, an attribute specifier list may appear after the colon following a
7671 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7672 attributes on labels if the attribute specifier is immediately
7673 followed by a semicolon (i.e., the label applies to an empty
7674 statement).  If the semicolon is missing, C++ label attributes are
7675 ambiguous, as it is permissible for a declaration, which could begin
7676 with an attribute list, to be labelled in C++.  Declarations cannot be
7677 labelled in C90 or C99, so the ambiguity does not arise there.
7679 @subsubheading Enumerator Attributes
7681 In GNU C, an attribute specifier list may appear as part of an enumerator.
7682 The attribute goes after the enumeration constant, before @code{=}, if
7683 present.  The optional attribute in the enumerator appertains to the
7684 enumeration constant.  It is not possible to place the attribute after
7685 the constant expression, if present.
7687 @subsubheading Statement Attributes
7688 In GNU C, an attribute specifier list may appear as part of a null
7689 statement.  The attribute goes before the semicolon.
7691 @subsubheading Type Attributes
7693 An attribute specifier list may appear as part of a @code{struct},
7694 @code{union} or @code{enum} specifier.  It may go either immediately
7695 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7696 the closing brace.  The former syntax is preferred.
7697 Where attribute specifiers follow the closing brace, they are considered
7698 to relate to the structure, union or enumerated type defined, not to any
7699 enclosing declaration the type specifier appears in, and the type
7700 defined is not complete until after the attribute specifiers.
7701 @c Otherwise, there would be the following problems: a shift/reduce
7702 @c conflict between attributes binding the struct/union/enum and
7703 @c binding to the list of specifiers/qualifiers; and "aligned"
7704 @c attributes could use sizeof for the structure, but the size could be
7705 @c changed later by "packed" attributes.
7708 @subsubheading All other attributes
7710 Otherwise, an attribute specifier appears as part of a declaration,
7711 counting declarations of unnamed parameters and type names, and relates
7712 to that declaration (which may be nested in another declaration, for
7713 example in the case of a parameter declaration), or to a particular declarator
7714 within a declaration.  Where an
7715 attribute specifier is applied to a parameter declared as a function or
7716 an array, it should apply to the function or array rather than the
7717 pointer to which the parameter is implicitly converted, but this is not
7718 yet correctly implemented.
7720 Any list of specifiers and qualifiers at the start of a declaration may
7721 contain attribute specifiers, whether or not such a list may in that
7722 context contain storage class specifiers.  (Some attributes, however,
7723 are essentially in the nature of storage class specifiers, and only make
7724 sense where storage class specifiers may be used; for example,
7725 @code{section}.)  There is one necessary limitation to this syntax: the
7726 first old-style parameter declaration in a function definition cannot
7727 begin with an attribute specifier, because such an attribute applies to
7728 the function instead by syntax described below (which, however, is not
7729 yet implemented in this case).  In some other cases, attribute
7730 specifiers are permitted by this grammar but not yet supported by the
7731 compiler.  All attribute specifiers in this place relate to the
7732 declaration as a whole.  In the obsolescent usage where a type of
7733 @code{int} is implied by the absence of type specifiers, such a list of
7734 specifiers and qualifiers may be an attribute specifier list with no
7735 other specifiers or qualifiers.
7737 At present, the first parameter in a function prototype must have some
7738 type specifier that is not an attribute specifier; this resolves an
7739 ambiguity in the interpretation of @code{void f(int
7740 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7741 the parentheses of a function declarator contain only attributes then
7742 those attributes are ignored, rather than yielding an error or warning
7743 or implying a single parameter of type int, but this is subject to
7744 change.
7746 An attribute specifier list may appear immediately before a declarator
7747 (other than the first) in a comma-separated list of declarators in a
7748 declaration of more than one identifier using a single list of
7749 specifiers and qualifiers.  Such attribute specifiers apply
7750 only to the identifier before whose declarator they appear.  For
7751 example, in
7753 @smallexample
7754 __attribute__((noreturn)) void d0 (void),
7755     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7756      d2 (void);
7757 @end smallexample
7759 @noindent
7760 the @code{noreturn} attribute applies to all the functions
7761 declared; the @code{format} attribute only applies to @code{d1}.
7763 An attribute specifier list may appear immediately before the comma,
7764 @code{=} or semicolon terminating the declaration of an identifier other
7765 than a function definition.  Such attribute specifiers apply
7766 to the declared object or function.  Where an
7767 assembler name for an object or function is specified (@pxref{Asm
7768 Labels}), the attribute must follow the @code{asm}
7769 specification.
7771 An attribute specifier list may, in future, be permitted to appear after
7772 the declarator in a function definition (before any old-style parameter
7773 declarations or the function body).
7775 Attribute specifiers may be mixed with type qualifiers appearing inside
7776 the @code{[]} of a parameter array declarator, in the C99 construct by
7777 which such qualifiers are applied to the pointer to which the array is
7778 implicitly converted.  Such attribute specifiers apply to the pointer,
7779 not to the array, but at present this is not implemented and they are
7780 ignored.
7782 An attribute specifier list may appear at the start of a nested
7783 declarator.  At present, there are some limitations in this usage: the
7784 attributes correctly apply to the declarator, but for most individual
7785 attributes the semantics this implies are not implemented.
7786 When attribute specifiers follow the @code{*} of a pointer
7787 declarator, they may be mixed with any type qualifiers present.
7788 The following describes the formal semantics of this syntax.  It makes the
7789 most sense if you are familiar with the formal specification of
7790 declarators in the ISO C standard.
7792 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7793 D1}, where @code{T} contains declaration specifiers that specify a type
7794 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7795 contains an identifier @var{ident}.  The type specified for @var{ident}
7796 for derived declarators whose type does not include an attribute
7797 specifier is as in the ISO C standard.
7799 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7800 and the declaration @code{T D} specifies the type
7801 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7802 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7803 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7805 If @code{D1} has the form @code{*
7806 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7807 declaration @code{T D} specifies the type
7808 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7809 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7810 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7811 @var{ident}.
7813 For example,
7815 @smallexample
7816 void (__attribute__((noreturn)) ****f) (void);
7817 @end smallexample
7819 @noindent
7820 specifies the type ``pointer to pointer to pointer to pointer to
7821 non-returning function returning @code{void}''.  As another example,
7823 @smallexample
7824 char *__attribute__((aligned(8))) *f;
7825 @end smallexample
7827 @noindent
7828 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7829 Note again that this does not work with most attributes; for example,
7830 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7831 is not yet supported.
7833 For compatibility with existing code written for compiler versions that
7834 did not implement attributes on nested declarators, some laxity is
7835 allowed in the placing of attributes.  If an attribute that only applies
7836 to types is applied to a declaration, it is treated as applying to
7837 the type of that declaration.  If an attribute that only applies to
7838 declarations is applied to the type of a declaration, it is treated
7839 as applying to that declaration; and, for compatibility with code
7840 placing the attributes immediately before the identifier declared, such
7841 an attribute applied to a function return type is treated as
7842 applying to the function type, and such an attribute applied to an array
7843 element type is treated as applying to the array type.  If an
7844 attribute that only applies to function types is applied to a
7845 pointer-to-function type, it is treated as applying to the pointer
7846 target type; if such an attribute is applied to a function return type
7847 that is not a pointer-to-function type, it is treated as applying
7848 to the function type.
7850 @node Function Prototypes
7851 @section Prototypes and Old-Style Function Definitions
7852 @cindex function prototype declarations
7853 @cindex old-style function definitions
7854 @cindex promotion of formal parameters
7856 GNU C extends ISO C to allow a function prototype to override a later
7857 old-style non-prototype definition.  Consider the following example:
7859 @smallexample
7860 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7861 #ifdef __STDC__
7862 #define P(x) x
7863 #else
7864 #define P(x) ()
7865 #endif
7867 /* @r{Prototype function declaration.}  */
7868 int isroot P((uid_t));
7870 /* @r{Old-style function definition.}  */
7872 isroot (x)   /* @r{??? lossage here ???} */
7873      uid_t x;
7875   return x == 0;
7877 @end smallexample
7879 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7880 not allow this example, because subword arguments in old-style
7881 non-prototype definitions are promoted.  Therefore in this example the
7882 function definition's argument is really an @code{int}, which does not
7883 match the prototype argument type of @code{short}.
7885 This restriction of ISO C makes it hard to write code that is portable
7886 to traditional C compilers, because the programmer does not know
7887 whether the @code{uid_t} type is @code{short}, @code{int}, or
7888 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7889 to override a later old-style definition.  More precisely, in GNU C, a
7890 function prototype argument type overrides the argument type specified
7891 by a later old-style definition if the former type is the same as the
7892 latter type before promotion.  Thus in GNU C the above example is
7893 equivalent to the following:
7895 @smallexample
7896 int isroot (uid_t);
7899 isroot (uid_t x)
7901   return x == 0;
7903 @end smallexample
7905 @noindent
7906 GNU C++ does not support old-style function definitions, so this
7907 extension is irrelevant.
7909 @node C++ Comments
7910 @section C++ Style Comments
7911 @cindex @code{//}
7912 @cindex C++ comments
7913 @cindex comments, C++ style
7915 In GNU C, you may use C++ style comments, which start with @samp{//} and
7916 continue until the end of the line.  Many other C implementations allow
7917 such comments, and they are included in the 1999 C standard.  However,
7918 C++ style comments are not recognized if you specify an @option{-std}
7919 option specifying a version of ISO C before C99, or @option{-ansi}
7920 (equivalent to @option{-std=c90}).
7922 @node Dollar Signs
7923 @section Dollar Signs in Identifier Names
7924 @cindex $
7925 @cindex dollar signs in identifier names
7926 @cindex identifier names, dollar signs in
7928 In GNU C, you may normally use dollar signs in identifier names.
7929 This is because many traditional C implementations allow such identifiers.
7930 However, dollar signs in identifiers are not supported on a few target
7931 machines, typically because the target assembler does not allow them.
7933 @node Character Escapes
7934 @section The Character @key{ESC} in Constants
7936 You can use the sequence @samp{\e} in a string or character constant to
7937 stand for the ASCII character @key{ESC}.
7939 @node Alignment
7940 @section Inquiring on Alignment of Types or Variables
7941 @cindex alignment
7942 @cindex type alignment
7943 @cindex variable alignment
7945 The keyword @code{__alignof__} allows you to inquire about how an object
7946 is aligned, or the minimum alignment usually required by a type.  Its
7947 syntax is just like @code{sizeof}.
7949 For example, if the target machine requires a @code{double} value to be
7950 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7951 This is true on many RISC machines.  On more traditional machine
7952 designs, @code{__alignof__ (double)} is 4 or even 2.
7954 Some machines never actually require alignment; they allow reference to any
7955 data type even at an odd address.  For these machines, @code{__alignof__}
7956 reports the smallest alignment that GCC gives the data type, usually as
7957 mandated by the target ABI.
7959 If the operand of @code{__alignof__} is an lvalue rather than a type,
7960 its value is the required alignment for its type, taking into account
7961 any minimum alignment specified with GCC's @code{__attribute__}
7962 extension (@pxref{Variable Attributes}).  For example, after this
7963 declaration:
7965 @smallexample
7966 struct foo @{ int x; char y; @} foo1;
7967 @end smallexample
7969 @noindent
7970 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7971 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7973 It is an error to ask for the alignment of an incomplete type.
7976 @node Inline
7977 @section An Inline Function is As Fast As a Macro
7978 @cindex inline functions
7979 @cindex integrating function code
7980 @cindex open coding
7981 @cindex macros, inline alternative
7983 By declaring a function inline, you can direct GCC to make
7984 calls to that function faster.  One way GCC can achieve this is to
7985 integrate that function's code into the code for its callers.  This
7986 makes execution faster by eliminating the function-call overhead; in
7987 addition, if any of the actual argument values are constant, their
7988 known values may permit simplifications at compile time so that not
7989 all of the inline function's code needs to be included.  The effect on
7990 code size is less predictable; object code may be larger or smaller
7991 with function inlining, depending on the particular case.  You can
7992 also direct GCC to try to integrate all ``simple enough'' functions
7993 into their callers with the option @option{-finline-functions}.
7995 GCC implements three different semantics of declaring a function
7996 inline.  One is available with @option{-std=gnu89} or
7997 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7998 on all inline declarations, another when
7999 @option{-std=c99},
8000 @option{-std=gnu99} or an option for a later C version is used
8001 (without @option{-fgnu89-inline}), and the third
8002 is used when compiling C++.
8004 To declare a function inline, use the @code{inline} keyword in its
8005 declaration, like this:
8007 @smallexample
8008 static inline int
8009 inc (int *a)
8011   return (*a)++;
8013 @end smallexample
8015 If you are writing a header file to be included in ISO C90 programs, write
8016 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
8018 The three types of inlining behave similarly in two important cases:
8019 when the @code{inline} keyword is used on a @code{static} function,
8020 like the example above, and when a function is first declared without
8021 using the @code{inline} keyword and then is defined with
8022 @code{inline}, like this:
8024 @smallexample
8025 extern int inc (int *a);
8026 inline int
8027 inc (int *a)
8029   return (*a)++;
8031 @end smallexample
8033 In both of these common cases, the program behaves the same as if you
8034 had not used the @code{inline} keyword, except for its speed.
8036 @cindex inline functions, omission of
8037 @opindex fkeep-inline-functions
8038 When a function is both inline and @code{static}, if all calls to the
8039 function are integrated into the caller, and the function's address is
8040 never used, then the function's own assembler code is never referenced.
8041 In this case, GCC does not actually output assembler code for the
8042 function, unless you specify the option @option{-fkeep-inline-functions}.
8043 If there is a nonintegrated call, then the function is compiled to
8044 assembler code as usual.  The function must also be compiled as usual if
8045 the program refers to its address, because that cannot be inlined.
8047 @opindex Winline
8048 Note that certain usages in a function definition can make it unsuitable
8049 for inline substitution.  Among these usages are: variadic functions,
8050 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8051 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8052 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8053 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
8054 function marked @code{inline} could not be substituted, and gives the
8055 reason for the failure.
8057 @cindex automatic @code{inline} for C++ member fns
8058 @cindex @code{inline} automatic for C++ member fns
8059 @cindex member fns, automatically @code{inline}
8060 @cindex C++ member fns, automatically @code{inline}
8061 @opindex fno-default-inline
8062 As required by ISO C++, GCC considers member functions defined within
8063 the body of a class to be marked inline even if they are
8064 not explicitly declared with the @code{inline} keyword.  You can
8065 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8066 Options,,Options Controlling C++ Dialect}.
8068 GCC does not inline any functions when not optimizing unless you specify
8069 the @samp{always_inline} attribute for the function, like this:
8071 @smallexample
8072 /* @r{Prototype.}  */
8073 inline void foo (const char) __attribute__((always_inline));
8074 @end smallexample
8076 The remainder of this section is specific to GNU C90 inlining.
8078 @cindex non-static inline function
8079 When an inline function is not @code{static}, then the compiler must assume
8080 that there may be calls from other source files; since a global symbol can
8081 be defined only once in any program, the function must not be defined in
8082 the other source files, so the calls therein cannot be integrated.
8083 Therefore, a non-@code{static} inline function is always compiled on its
8084 own in the usual fashion.
8086 If you specify both @code{inline} and @code{extern} in the function
8087 definition, then the definition is used only for inlining.  In no case
8088 is the function compiled on its own, not even if you refer to its
8089 address explicitly.  Such an address becomes an external reference, as
8090 if you had only declared the function, and had not defined it.
8092 This combination of @code{inline} and @code{extern} has almost the
8093 effect of a macro.  The way to use it is to put a function definition in
8094 a header file with these keywords, and put another copy of the
8095 definition (lacking @code{inline} and @code{extern}) in a library file.
8096 The definition in the header file causes most calls to the function
8097 to be inlined.  If any uses of the function remain, they refer to
8098 the single copy in the library.
8100 @node Volatiles
8101 @section When is a Volatile Object Accessed?
8102 @cindex accessing volatiles
8103 @cindex volatile read
8104 @cindex volatile write
8105 @cindex volatile access
8107 C has the concept of volatile objects.  These are normally accessed by
8108 pointers and used for accessing hardware or inter-thread
8109 communication.  The standard encourages compilers to refrain from
8110 optimizations concerning accesses to volatile objects, but leaves it
8111 implementation defined as to what constitutes a volatile access.  The
8112 minimum requirement is that at a sequence point all previous accesses
8113 to volatile objects have stabilized and no subsequent accesses have
8114 occurred.  Thus an implementation is free to reorder and combine
8115 volatile accesses that occur between sequence points, but cannot do
8116 so for accesses across a sequence point.  The use of volatile does
8117 not allow you to violate the restriction on updating objects multiple
8118 times between two sequence points.
8120 Accesses to non-volatile objects are not ordered with respect to
8121 volatile accesses.  You cannot use a volatile object as a memory
8122 barrier to order a sequence of writes to non-volatile memory.  For
8123 instance:
8125 @smallexample
8126 int *ptr = @var{something};
8127 volatile int vobj;
8128 *ptr = @var{something};
8129 vobj = 1;
8130 @end smallexample
8132 @noindent
8133 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8134 that the write to @var{*ptr} occurs by the time the update
8135 of @var{vobj} happens.  If you need this guarantee, you must use
8136 a stronger memory barrier such as:
8138 @smallexample
8139 int *ptr = @var{something};
8140 volatile int vobj;
8141 *ptr = @var{something};
8142 asm volatile ("" : : : "memory");
8143 vobj = 1;
8144 @end smallexample
8146 A scalar volatile object is read when it is accessed in a void context:
8148 @smallexample
8149 volatile int *src = @var{somevalue};
8150 *src;
8151 @end smallexample
8153 Such expressions are rvalues, and GCC implements this as a
8154 read of the volatile object being pointed to.
8156 Assignments are also expressions and have an rvalue.  However when
8157 assigning to a scalar volatile, the volatile object is not reread,
8158 regardless of whether the assignment expression's rvalue is used or
8159 not.  If the assignment's rvalue is used, the value is that assigned
8160 to the volatile object.  For instance, there is no read of @var{vobj}
8161 in all the following cases:
8163 @smallexample
8164 int obj;
8165 volatile int vobj;
8166 vobj = @var{something};
8167 obj = vobj = @var{something};
8168 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8169 obj = (@var{something}, vobj = @var{anotherthing});
8170 @end smallexample
8172 If you need to read the volatile object after an assignment has
8173 occurred, you must use a separate expression with an intervening
8174 sequence point.
8176 As bit-fields are not individually addressable, volatile bit-fields may
8177 be implicitly read when written to, or when adjacent bit-fields are
8178 accessed.  Bit-field operations may be optimized such that adjacent
8179 bit-fields are only partially accessed, if they straddle a storage unit
8180 boundary.  For these reasons it is unwise to use volatile bit-fields to
8181 access hardware.
8183 @node Using Assembly Language with C
8184 @section How to Use Inline Assembly Language in C Code
8185 @cindex @code{asm} keyword
8186 @cindex assembly language in C
8187 @cindex inline assembly language
8188 @cindex mixing assembly language and C
8190 The @code{asm} keyword allows you to embed assembler instructions
8191 within C code.  GCC provides two forms of inline @code{asm}
8192 statements.  A @dfn{basic @code{asm}} statement is one with no
8193 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8194 statement (@pxref{Extended Asm}) includes one or more operands.  
8195 The extended form is preferred for mixing C and assembly language
8196 within a function, but to include assembly language at
8197 top level you must use basic @code{asm}.
8199 You can also use the @code{asm} keyword to override the assembler name
8200 for a C symbol, or to place a C variable in a specific register.
8202 @menu
8203 * Basic Asm::          Inline assembler without operands.
8204 * Extended Asm::       Inline assembler with operands.
8205 * Constraints::        Constraints for @code{asm} operands
8206 * Asm Labels::         Specifying the assembler name to use for a C symbol.
8207 * Explicit Register Variables::  Defining variables residing in specified 
8208                        registers.
8209 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
8210 @end menu
8212 @node Basic Asm
8213 @subsection Basic Asm --- Assembler Instructions Without Operands
8214 @cindex basic @code{asm}
8215 @cindex assembly language in C, basic
8217 A basic @code{asm} statement has the following syntax:
8219 @example
8220 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8221 @end example
8223 The @code{asm} keyword is a GNU extension.
8224 When writing code that can be compiled with @option{-ansi} and the
8225 various @option{-std} options, use @code{__asm__} instead of 
8226 @code{asm} (@pxref{Alternate Keywords}).
8228 @subsubheading Qualifiers
8229 @table @code
8230 @item volatile
8231 The optional @code{volatile} qualifier has no effect. 
8232 All basic @code{asm} blocks are implicitly volatile.
8233 @end table
8235 @subsubheading Parameters
8236 @table @var
8238 @item AssemblerInstructions
8239 This is a literal string that specifies the assembler code. The string can 
8240 contain any instructions recognized by the assembler, including directives. 
8241 GCC does not parse the assembler instructions themselves and 
8242 does not know what they mean or even whether they are valid assembler input. 
8244 You may place multiple assembler instructions together in a single @code{asm} 
8245 string, separated by the characters normally used in assembly code for the 
8246 system. A combination that works in most places is a newline to break the 
8247 line, plus a tab character (written as @samp{\n\t}).
8248 Some assemblers allow semicolons as a line separator. However, 
8249 note that some assembler dialects use semicolons to start a comment. 
8250 @end table
8252 @subsubheading Remarks
8253 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8254 smaller, safer, and more efficient code, and in most cases it is a
8255 better solution than basic @code{asm}.  However, there are two
8256 situations where only basic @code{asm} can be used:
8258 @itemize @bullet
8259 @item
8260 Extended @code{asm} statements have to be inside a C
8261 function, so to write inline assembly language at file scope (``top-level''),
8262 outside of C functions, you must use basic @code{asm}.
8263 You can use this technique to emit assembler directives,
8264 define assembly language macros that can be invoked elsewhere in the file,
8265 or write entire functions in assembly language.
8267 @item
8268 Functions declared
8269 with the @code{naked} attribute also require basic @code{asm}
8270 (@pxref{Function Attributes}).
8271 @end itemize
8273 Safely accessing C data and calling functions from basic @code{asm} is more 
8274 complex than it may appear. To access C data, it is better to use extended 
8275 @code{asm}.
8277 Do not expect a sequence of @code{asm} statements to remain perfectly 
8278 consecutive after compilation. If certain instructions need to remain 
8279 consecutive in the output, put them in a single multi-instruction @code{asm}
8280 statement. Note that GCC's optimizers can move @code{asm} statements 
8281 relative to other code, including across jumps.
8283 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8284 GCC does not know about these jumps, and therefore cannot take 
8285 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8286 labels are only supported in extended @code{asm}.
8288 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8289 assembly code when optimizing. This can lead to unexpected duplicate 
8290 symbol errors during compilation if your assembly code defines symbols or 
8291 labels.
8293 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8294 making it a potential source of incompatibilities between compilers.  These
8295 incompatibilities may not produce compiler warnings/errors.
8297 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8298 means there is no way to communicate to the compiler what is happening
8299 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8300 discard them as unreferenced.  It also does not know about side effects of
8301 the assembler code, such as modifications to memory or registers.  Unlike
8302 some compilers, GCC assumes that no changes to general purpose registers
8303 occur.  This assumption may change in a future release.
8305 To avoid complications from future changes to the semantics and the
8306 compatibility issues between compilers, consider replacing basic @code{asm}
8307 with extended @code{asm}.  See
8308 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8309 from basic asm to extended asm} for information about how to perform this
8310 conversion.
8312 The compiler copies the assembler instructions in a basic @code{asm} 
8313 verbatim to the assembly language output file, without 
8314 processing dialects or any of the @samp{%} operators that are available with
8315 extended @code{asm}. This results in minor differences between basic 
8316 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8317 registers you might use @samp{%eax} in basic @code{asm} and
8318 @samp{%%eax} in extended @code{asm}.
8320 On targets such as x86 that support multiple assembler dialects,
8321 all basic @code{asm} blocks use the assembler dialect specified by the 
8322 @option{-masm} command-line option (@pxref{x86 Options}).  
8323 Basic @code{asm} provides no
8324 mechanism to provide different assembler strings for different dialects.
8326 For basic @code{asm} with non-empty assembler string GCC assumes
8327 the assembler block does not change any general purpose registers,
8328 but it may read or write any globally accessible variable.
8330 Here is an example of basic @code{asm} for i386:
8332 @example
8333 /* Note that this code will not compile with -masm=intel */
8334 #define DebugBreak() asm("int $3")
8335 @end example
8337 @node Extended Asm
8338 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8339 @cindex extended @code{asm}
8340 @cindex assembly language in C, extended
8342 With extended @code{asm} you can read and write C variables from 
8343 assembler and perform jumps from assembler code to C labels.  
8344 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8345 the operand parameters after the assembler template:
8347 @example
8348 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
8349                  : @var{OutputOperands} 
8350                  @r{[} : @var{InputOperands}
8351                  @r{[} : @var{Clobbers} @r{]} @r{]})
8353 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
8354                       : 
8355                       : @var{InputOperands}
8356                       : @var{Clobbers}
8357                       : @var{GotoLabels})
8358 @end example
8360 The @code{asm} keyword is a GNU extension.
8361 When writing code that can be compiled with @option{-ansi} and the
8362 various @option{-std} options, use @code{__asm__} instead of 
8363 @code{asm} (@pxref{Alternate Keywords}).
8365 @subsubheading Qualifiers
8366 @table @code
8368 @item volatile
8369 The typical use of extended @code{asm} statements is to manipulate input 
8370 values to produce output values. However, your @code{asm} statements may 
8371 also produce side effects. If so, you may need to use the @code{volatile} 
8372 qualifier to disable certain optimizations. @xref{Volatile}.
8374 @item goto
8375 This qualifier informs the compiler that the @code{asm} statement may 
8376 perform a jump to one of the labels listed in the @var{GotoLabels}.
8377 @xref{GotoLabels}.
8378 @end table
8380 @subsubheading Parameters
8381 @table @var
8382 @item AssemblerTemplate
8383 This is a literal string that is the template for the assembler code. It is a 
8384 combination of fixed text and tokens that refer to the input, output, 
8385 and goto parameters. @xref{AssemblerTemplate}.
8387 @item OutputOperands
8388 A comma-separated list of the C variables modified by the instructions in the 
8389 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8391 @item InputOperands
8392 A comma-separated list of C expressions read by the instructions in the 
8393 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8395 @item Clobbers
8396 A comma-separated list of registers or other values changed by the 
8397 @var{AssemblerTemplate}, beyond those listed as outputs.
8398 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8400 @item GotoLabels
8401 When you are using the @code{goto} form of @code{asm}, this section contains 
8402 the list of all C labels to which the code in the 
8403 @var{AssemblerTemplate} may jump. 
8404 @xref{GotoLabels}.
8406 @code{asm} statements may not perform jumps into other @code{asm} statements,
8407 only to the listed @var{GotoLabels}.
8408 GCC's optimizers do not know about other jumps; therefore they cannot take 
8409 account of them when deciding how to optimize.
8410 @end table
8412 The total number of input + output + goto operands is limited to 30.
8414 @subsubheading Remarks
8415 The @code{asm} statement allows you to include assembly instructions directly 
8416 within C code. This may help you to maximize performance in time-sensitive 
8417 code or to access assembly instructions that are not readily available to C 
8418 programs.
8420 Note that extended @code{asm} statements must be inside a function. Only 
8421 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8422 Functions declared with the @code{naked} attribute also require basic 
8423 @code{asm} (@pxref{Function Attributes}).
8425 While the uses of @code{asm} are many and varied, it may help to think of an 
8426 @code{asm} statement as a series of low-level instructions that convert input 
8427 parameters to output parameters. So a simple (if not particularly useful) 
8428 example for i386 using @code{asm} might look like this:
8430 @example
8431 int src = 1;
8432 int dst;   
8434 asm ("mov %1, %0\n\t"
8435     "add $1, %0"
8436     : "=r" (dst) 
8437     : "r" (src));
8439 printf("%d\n", dst);
8440 @end example
8442 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8444 @anchor{Volatile}
8445 @subsubsection Volatile
8446 @cindex volatile @code{asm}
8447 @cindex @code{asm} volatile
8449 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8450 there is no need for the output variables. Also, the optimizers may move 
8451 code out of loops if they believe that the code will always return the same 
8452 result (i.e. none of its input values change between calls). Using the 
8453 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8454 that have no output operands, including @code{asm goto} statements, 
8455 are implicitly volatile.
8457 This i386 code demonstrates a case that does not use (or require) the 
8458 @code{volatile} qualifier. If it is performing assertion checking, this code 
8459 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8460 unreferenced by any code. As a result, the optimizers can discard the 
8461 @code{asm} statement, which in turn removes the need for the entire 
8462 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8463 isn't needed you allow the optimizers to produce the most efficient code 
8464 possible.
8466 @example
8467 void DoCheck(uint32_t dwSomeValue)
8469    uint32_t dwRes;
8471    // Assumes dwSomeValue is not zero.
8472    asm ("bsfl %1,%0"
8473      : "=r" (dwRes)
8474      : "r" (dwSomeValue)
8475      : "cc");
8477    assert(dwRes > 3);
8479 @end example
8481 The next example shows a case where the optimizers can recognize that the input 
8482 (@code{dwSomeValue}) never changes during the execution of the function and can 
8483 therefore move the @code{asm} outside the loop to produce more efficient code. 
8484 Again, using @code{volatile} disables this type of optimization.
8486 @example
8487 void do_print(uint32_t dwSomeValue)
8489    uint32_t dwRes;
8491    for (uint32_t x=0; x < 5; x++)
8492    @{
8493       // Assumes dwSomeValue is not zero.
8494       asm ("bsfl %1,%0"
8495         : "=r" (dwRes)
8496         : "r" (dwSomeValue)
8497         : "cc");
8499       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8500    @}
8502 @end example
8504 The following example demonstrates a case where you need to use the 
8505 @code{volatile} qualifier. 
8506 It uses the x86 @code{rdtsc} instruction, which reads 
8507 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8508 the optimizers might assume that the @code{asm} block will always return the 
8509 same value and therefore optimize away the second call.
8511 @example
8512 uint64_t msr;
8514 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8515         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8516         "or %%rdx, %0"        // 'Or' in the lower bits.
8517         : "=a" (msr)
8518         : 
8519         : "rdx");
8521 printf("msr: %llx\n", msr);
8523 // Do other work...
8525 // Reprint the timestamp
8526 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8527         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8528         "or %%rdx, %0"        // 'Or' in the lower bits.
8529         : "=a" (msr)
8530         : 
8531         : "rdx");
8533 printf("msr: %llx\n", msr);
8534 @end example
8536 GCC's optimizers do not treat this code like the non-volatile code in the 
8537 earlier examples. They do not move it out of loops or omit it on the 
8538 assumption that the result from a previous call is still valid.
8540 Note that the compiler can move even volatile @code{asm} instructions relative 
8541 to other code, including across jump instructions. For example, on many 
8542 targets there is a system register that controls the rounding mode of 
8543 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8544 following PowerPC example, does not work reliably.
8546 @example
8547 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8548 sum = x + y;
8549 @end example
8551 The compiler may move the addition back before the volatile @code{asm}. To 
8552 make it work as expected, add an artificial dependency to the @code{asm} by 
8553 referencing a variable in the subsequent code, for example: 
8555 @example
8556 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8557 sum = x + y;
8558 @end example
8560 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8561 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8562 errors during compilation if your asm code defines symbols or labels. 
8563 Using @samp{%=} 
8564 (@pxref{AssemblerTemplate}) may help resolve this problem.
8566 @anchor{AssemblerTemplate}
8567 @subsubsection Assembler Template
8568 @cindex @code{asm} assembler template
8570 An assembler template is a literal string containing assembler instructions.
8571 The compiler replaces tokens in the template that refer 
8572 to inputs, outputs, and goto labels,
8573 and then outputs the resulting string to the assembler. The 
8574 string can contain any instructions recognized by the assembler, including 
8575 directives. GCC does not parse the assembler instructions 
8576 themselves and does not know what they mean or even whether they are valid 
8577 assembler input. However, it does count the statements 
8578 (@pxref{Size of an asm}).
8580 You may place multiple assembler instructions together in a single @code{asm} 
8581 string, separated by the characters normally used in assembly code for the 
8582 system. A combination that works in most places is a newline to break the 
8583 line, plus a tab character to move to the instruction field (written as 
8584 @samp{\n\t}). 
8585 Some assemblers allow semicolons as a line separator. However, note 
8586 that some assembler dialects use semicolons to start a comment. 
8588 Do not expect a sequence of @code{asm} statements to remain perfectly 
8589 consecutive after compilation, even when you are using the @code{volatile} 
8590 qualifier. If certain instructions need to remain consecutive in the output, 
8591 put them in a single multi-instruction asm statement.
8593 Accessing data from C programs without using input/output operands (such as 
8594 by using global symbols directly from the assembler template) may not work as 
8595 expected. Similarly, calling functions directly from an assembler template 
8596 requires a detailed understanding of the target assembler and ABI.
8598 Since GCC does not parse the assembler template,
8599 it has no visibility of any 
8600 symbols it references. This may result in GCC discarding those symbols as 
8601 unreferenced unless they are also listed as input, output, or goto operands.
8603 @subsubheading Special format strings
8605 In addition to the tokens described by the input, output, and goto operands, 
8606 these tokens have special meanings in the assembler template:
8608 @table @samp
8609 @item %% 
8610 Outputs a single @samp{%} into the assembler code.
8612 @item %= 
8613 Outputs a number that is unique to each instance of the @code{asm} 
8614 statement in the entire compilation. This option is useful when creating local 
8615 labels and referring to them multiple times in a single template that 
8616 generates multiple assembler instructions. 
8618 @item %@{
8619 @itemx %|
8620 @itemx %@}
8621 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8622 into the assembler code.  When unescaped, these characters have special
8623 meaning to indicate multiple assembler dialects, as described below.
8624 @end table
8626 @subsubheading Multiple assembler dialects in @code{asm} templates
8628 On targets such as x86, GCC supports multiple assembler dialects.
8629 The @option{-masm} option controls which dialect GCC uses as its 
8630 default for inline assembler. The target-specific documentation for the 
8631 @option{-masm} option contains the list of supported dialects, as well as the 
8632 default dialect if the option is not specified. This information may be 
8633 important to understand, since assembler code that works correctly when 
8634 compiled using one dialect will likely fail if compiled using another.
8635 @xref{x86 Options}.
8637 If your code needs to support multiple assembler dialects (for example, if 
8638 you are writing public headers that need to support a variety of compilation 
8639 options), use constructs of this form:
8641 @example
8642 @{ dialect0 | dialect1 | dialect2... @}
8643 @end example
8645 This construct outputs @code{dialect0} 
8646 when using dialect #0 to compile the code, 
8647 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8648 braces than the number of dialects the compiler supports, the construct 
8649 outputs nothing.
8651 For example, if an x86 compiler supports two dialects
8652 (@samp{att}, @samp{intel}), an 
8653 assembler template such as this:
8655 @example
8656 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8657 @end example
8659 @noindent
8660 is equivalent to one of
8662 @example
8663 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8664 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8665 @end example
8667 Using that same compiler, this code:
8669 @example
8670 "xchg@{l@}\t@{%%@}ebx, %1"
8671 @end example
8673 @noindent
8674 corresponds to either
8676 @example
8677 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8678 "xchg\tebx, %1"                    @r{/* intel dialect */}
8679 @end example
8681 There is no support for nesting dialect alternatives.
8683 @anchor{OutputOperands}
8684 @subsubsection Output Operands
8685 @cindex @code{asm} output operands
8687 An @code{asm} statement has zero or more output operands indicating the names
8688 of C variables modified by the assembler code.
8690 In this i386 example, @code{old} (referred to in the template string as 
8691 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8692 (@code{%2}) is an input:
8694 @example
8695 bool old;
8697 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8698          "sbb %0,%0"      // Use the CF to calculate old.
8699    : "=r" (old), "+rm" (*Base)
8700    : "Ir" (Offset)
8701    : "cc");
8703 return old;
8704 @end example
8706 Operands are separated by commas.  Each operand has this format:
8708 @example
8709 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8710 @end example
8712 @table @var
8713 @item asmSymbolicName
8714 Specifies a symbolic name for the operand.
8715 Reference the name in the assembler template 
8716 by enclosing it in square brackets 
8717 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8718 that contains the definition. Any valid C variable name is acceptable, 
8719 including names already defined in the surrounding code. No two operands 
8720 within the same @code{asm} statement can use the same symbolic name.
8722 When not using an @var{asmSymbolicName}, use the (zero-based) position
8723 of the operand 
8724 in the list of operands in the assembler template. For example if there are 
8725 three output operands, use @samp{%0} in the template to refer to the first, 
8726 @samp{%1} for the second, and @samp{%2} for the third. 
8728 @item constraint
8729 A string constant specifying constraints on the placement of the operand; 
8730 @xref{Constraints}, for details.
8732 Output constraints must begin with either @samp{=} (a variable overwriting an 
8733 existing value) or @samp{+} (when reading and writing). When using 
8734 @samp{=}, do not assume the location contains the existing value
8735 on entry to the @code{asm}, except 
8736 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8738 After the prefix, there must be one or more additional constraints 
8739 (@pxref{Constraints}) that describe where the value resides. Common 
8740 constraints include @samp{r} for register and @samp{m} for memory. 
8741 When you list more than one possible location (for example, @code{"=rm"}),
8742 the compiler chooses the most efficient one based on the current context. 
8743 If you list as many alternates as the @code{asm} statement allows, you permit 
8744 the optimizers to produce the best possible code. 
8745 If you must use a specific register, but your Machine Constraints do not
8746 provide sufficient control to select the specific register you want, 
8747 local register variables may provide a solution (@pxref{Local Register 
8748 Variables}).
8750 @item cvariablename
8751 Specifies a C lvalue expression to hold the output, typically a variable name.
8752 The enclosing parentheses are a required part of the syntax.
8754 @end table
8756 When the compiler selects the registers to use to 
8757 represent the output operands, it does not use any of the clobbered registers 
8758 (@pxref{Clobbers and Scratch Registers}).
8760 Output operand expressions must be lvalues. The compiler cannot check whether 
8761 the operands have data types that are reasonable for the instruction being 
8762 executed. For output expressions that are not directly addressable (for 
8763 example a bit-field), the constraint must allow a register. In that case, GCC 
8764 uses the register as the output of the @code{asm}, and then stores that 
8765 register into the output. 
8767 Operands using the @samp{+} constraint modifier count as two operands 
8768 (that is, both as input and output) towards the total maximum of 30 operands
8769 per @code{asm} statement.
8771 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8772 operands that must not overlap an input.  Otherwise, 
8773 GCC may allocate the output operand in the same register as an unrelated 
8774 input operand, on the assumption that the assembler code consumes its 
8775 inputs before producing outputs. This assumption may be false if the assembler 
8776 code actually consists of more than one instruction.
8778 The same problem can occur if one output parameter (@var{a}) allows a register 
8779 constraint and another output parameter (@var{b}) allows a memory constraint.
8780 The code generated by GCC to access the memory address in @var{b} can contain
8781 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8782 registers to be inputs to the asm. As above, GCC assumes that such input
8783 registers are consumed before any outputs are written. This assumption may 
8784 result in incorrect behavior if the asm writes to @var{a} before using 
8785 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8786 ensures that modifying @var{a} does not affect the address referenced by 
8787 @var{b}. Otherwise, the location of @var{b} 
8788 is undefined if @var{a} is modified before using @var{b}.
8790 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8791 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8792 dependent. The list of supported modifiers for x86 is found at 
8793 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8795 If the C code that follows the @code{asm} makes no use of any of the output 
8796 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8797 optimizers from discarding the @code{asm} statement as unneeded 
8798 (see @ref{Volatile}).
8800 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8801 references the first output operand as @code{%0} (were there a second, it 
8802 would be @code{%1}, etc). The number of the first input operand is one greater 
8803 than that of the last output operand. In this i386 example, that makes 
8804 @code{Mask} referenced as @code{%1}:
8806 @example
8807 uint32_t Mask = 1234;
8808 uint32_t Index;
8810   asm ("bsfl %1, %0"
8811      : "=r" (Index)
8812      : "r" (Mask)
8813      : "cc");
8814 @end example
8816 That code overwrites the variable @code{Index} (@samp{=}),
8817 placing the value in a register (@samp{r}).
8818 Using the generic @samp{r} constraint instead of a constraint for a specific 
8819 register allows the compiler to pick the register to use, which can result 
8820 in more efficient code. This may not be possible if an assembler instruction 
8821 requires a specific register.
8823 The following i386 example uses the @var{asmSymbolicName} syntax.
8824 It produces the 
8825 same result as the code above, but some may consider it more readable or more 
8826 maintainable since reordering index numbers is not necessary when adding or 
8827 removing operands. The names @code{aIndex} and @code{aMask}
8828 are only used in this example to emphasize which 
8829 names get used where.
8830 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8832 @example
8833 uint32_t Mask = 1234;
8834 uint32_t Index;
8836   asm ("bsfl %[aMask], %[aIndex]"
8837      : [aIndex] "=r" (Index)
8838      : [aMask] "r" (Mask)
8839      : "cc");
8840 @end example
8842 Here are some more examples of output operands.
8844 @example
8845 uint32_t c = 1;
8846 uint32_t d;
8847 uint32_t *e = &c;
8849 asm ("mov %[e], %[d]"
8850    : [d] "=rm" (d)
8851    : [e] "rm" (*e));
8852 @end example
8854 Here, @code{d} may either be in a register or in memory. Since the compiler 
8855 might already have the current value of the @code{uint32_t} location
8856 pointed to by @code{e}
8857 in a register, you can enable it to choose the best location
8858 for @code{d} by specifying both constraints.
8860 @anchor{FlagOutputOperands}
8861 @subsubsection Flag Output Operands
8862 @cindex @code{asm} flag output operands
8864 Some targets have a special register that holds the ``flags'' for the
8865 result of an operation or comparison.  Normally, the contents of that
8866 register are either unmodifed by the asm, or the asm is considered to
8867 clobber the contents.
8869 On some targets, a special form of output operand exists by which
8870 conditions in the flags register may be outputs of the asm.  The set of
8871 conditions supported are target specific, but the general rule is that
8872 the output variable must be a scalar integer, and the value is boolean.
8873 When supported, the target defines the preprocessor symbol
8874 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8876 Because of the special nature of the flag output operands, the constraint
8877 may not include alternatives.
8879 Most often, the target has only one flags register, and thus is an implied
8880 operand of many instructions.  In this case, the operand should not be
8881 referenced within the assembler template via @code{%0} etc, as there's
8882 no corresponding text in the assembly language.
8884 @table @asis
8885 @item x86 family
8886 The flag output constraints for the x86 family are of the form
8887 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8888 conditions defined in the ISA manual for @code{j@var{cc}} or
8889 @code{set@var{cc}}.
8891 @table @code
8892 @item a
8893 ``above'' or unsigned greater than
8894 @item ae
8895 ``above or equal'' or unsigned greater than or equal
8896 @item b
8897 ``below'' or unsigned less than
8898 @item be
8899 ``below or equal'' or unsigned less than or equal
8900 @item c
8901 carry flag set
8902 @item e
8903 @itemx z
8904 ``equal'' or zero flag set
8905 @item g
8906 signed greater than
8907 @item ge
8908 signed greater than or equal
8909 @item l
8910 signed less than
8911 @item le
8912 signed less than or equal
8913 @item o
8914 overflow flag set
8915 @item p
8916 parity flag set
8917 @item s
8918 sign flag set
8919 @item na
8920 @itemx nae
8921 @itemx nb
8922 @itemx nbe
8923 @itemx nc
8924 @itemx ne
8925 @itemx ng
8926 @itemx nge
8927 @itemx nl
8928 @itemx nle
8929 @itemx no
8930 @itemx np
8931 @itemx ns
8932 @itemx nz
8933 ``not'' @var{flag}, or inverted versions of those above
8934 @end table
8936 @end table
8938 @anchor{InputOperands}
8939 @subsubsection Input Operands
8940 @cindex @code{asm} input operands
8941 @cindex @code{asm} expressions
8943 Input operands make values from C variables and expressions available to the 
8944 assembly code.
8946 Operands are separated by commas.  Each operand has this format:
8948 @example
8949 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8950 @end example
8952 @table @var
8953 @item asmSymbolicName
8954 Specifies a symbolic name for the operand.
8955 Reference the name in the assembler template 
8956 by enclosing it in square brackets 
8957 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8958 that contains the definition. Any valid C variable name is acceptable, 
8959 including names already defined in the surrounding code. No two operands 
8960 within the same @code{asm} statement can use the same symbolic name.
8962 When not using an @var{asmSymbolicName}, use the (zero-based) position
8963 of the operand 
8964 in the list of operands in the assembler template. For example if there are
8965 two output operands and three inputs,
8966 use @samp{%2} in the template to refer to the first input operand,
8967 @samp{%3} for the second, and @samp{%4} for the third. 
8969 @item constraint
8970 A string constant specifying constraints on the placement of the operand; 
8971 @xref{Constraints}, for details.
8973 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8974 When you list more than one possible location (for example, @samp{"irm"}), 
8975 the compiler chooses the most efficient one based on the current context.
8976 If you must use a specific register, but your Machine Constraints do not
8977 provide sufficient control to select the specific register you want, 
8978 local register variables may provide a solution (@pxref{Local Register 
8979 Variables}).
8981 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8982 that the specified input must be in the same place as the output constraint 
8983 at the (zero-based) index in the output constraint list. 
8984 When using @var{asmSymbolicName} syntax for the output operands,
8985 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8987 @item cexpression
8988 This is the C variable or expression being passed to the @code{asm} statement 
8989 as input.  The enclosing parentheses are a required part of the syntax.
8991 @end table
8993 When the compiler selects the registers to use to represent the input 
8994 operands, it does not use any of the clobbered registers
8995 (@pxref{Clobbers and Scratch Registers}).
8997 If there are no output operands but there are input operands, place two 
8998 consecutive colons where the output operands would go:
9000 @example
9001 __asm__ ("some instructions"
9002    : /* No outputs. */
9003    : "r" (Offset / 8));
9004 @end example
9006 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
9007 (except for inputs tied to outputs). The compiler assumes that on exit from 
9008 the @code{asm} statement these operands contain the same values as they 
9009 had before executing the statement. 
9010 It is @emph{not} possible to use clobbers
9011 to inform the compiler that the values in these inputs are changing. One 
9012 common work-around is to tie the changing input variable to an output variable 
9013 that never gets used. Note, however, that if the code that follows the 
9014 @code{asm} statement makes no use of any of the output operands, the GCC 
9015 optimizers may discard the @code{asm} statement as unneeded 
9016 (see @ref{Volatile}).
9018 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
9019 instead of simply @samp{%2}). Typically these qualifiers are hardware 
9020 dependent. The list of supported modifiers for x86 is found at 
9021 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9023 In this example using the fictitious @code{combine} instruction, the 
9024 constraint @code{"0"} for input operand 1 says that it must occupy the same 
9025 location as output operand 0. Only input operands may use numbers in 
9026 constraints, and they must each refer to an output operand. Only a number (or 
9027 the symbolic assembler name) in the constraint can guarantee that one operand 
9028 is in the same place as another. The mere fact that @code{foo} is the value of 
9029 both operands is not enough to guarantee that they are in the same place in 
9030 the generated assembler code.
9032 @example
9033 asm ("combine %2, %0" 
9034    : "=r" (foo) 
9035    : "0" (foo), "g" (bar));
9036 @end example
9038 Here is an example using symbolic names.
9040 @example
9041 asm ("cmoveq %1, %2, %[result]" 
9042    : [result] "=r"(result) 
9043    : "r" (test), "r" (new), "[result]" (old));
9044 @end example
9046 @anchor{Clobbers and Scratch Registers}
9047 @subsubsection Clobbers and Scratch Registers
9048 @cindex @code{asm} clobbers
9049 @cindex @code{asm} scratch registers
9051 While the compiler is aware of changes to entries listed in the output 
9052 operands, the inline @code{asm} code may modify more than just the outputs. For 
9053 example, calculations may require additional registers, or the processor may 
9054 overwrite a register as a side effect of a particular assembler instruction. 
9055 In order to inform the compiler of these changes, list them in the clobber 
9056 list. Clobber list items are either register names or the special clobbers 
9057 (listed below). Each clobber list item is a string constant 
9058 enclosed in double quotes and separated by commas.
9060 Clobber descriptions may not in any way overlap with an input or output 
9061 operand. For example, you may not have an operand describing a register class 
9062 with one member when listing that register in the clobber list. Variables 
9063 declared to live in specific registers (@pxref{Explicit Register 
9064 Variables}) and used 
9065 as @code{asm} input or output operands must have no part mentioned in the 
9066 clobber description. In particular, there is no way to specify that input 
9067 operands get modified without also specifying them as output operands.
9069 When the compiler selects which registers to use to represent input and output 
9070 operands, it does not use any of the clobbered registers. As a result, 
9071 clobbered registers are available for any use in the assembler code.
9073 Here is a realistic example for the VAX showing the use of clobbered 
9074 registers: 
9076 @example
9077 asm volatile ("movc3 %0, %1, %2"
9078                    : /* No outputs. */
9079                    : "g" (from), "g" (to), "g" (count)
9080                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9081 @end example
9083 Also, there are two special clobber arguments:
9085 @table @code
9086 @item "cc"
9087 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
9088 register. On some machines, GCC represents the condition codes as a specific 
9089 hardware register; @code{"cc"} serves to name this register.
9090 On other machines, condition code handling is different, 
9091 and specifying @code{"cc"} has no effect. But 
9092 it is valid no matter what the target.
9094 @item "memory"
9095 The @code{"memory"} clobber tells the compiler that the assembly code
9096 performs memory 
9097 reads or writes to items other than those listed in the input and output 
9098 operands (for example, accessing the memory pointed to by one of the input 
9099 parameters). To ensure memory contains correct values, GCC may need to flush 
9100 specific register values to memory before executing the @code{asm}. Further, 
9101 the compiler does not assume that any values read from memory before an 
9102 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
9103 needed.  
9104 Using the @code{"memory"} clobber effectively forms a read/write
9105 memory barrier for the compiler.
9107 Note that this clobber does not prevent the @emph{processor} from doing 
9108 speculative reads past the @code{asm} statement. To prevent that, you need 
9109 processor-specific fence instructions.
9111 @end table
9113 Flushing registers to memory has performance implications and may be
9114 an issue for time-sensitive code.  You can provide better information
9115 to GCC to avoid this, as shown in the following examples.  At a
9116 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9117 need to be flushed.
9119 Here is a fictitious sum of squares instruction, that takes two
9120 pointers to floating point values in memory and produces a floating
9121 point register output.
9122 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9123 parameters, once to specify memory accessed, and once to specify a
9124 base register used by the @code{asm}.  You won't normally be wasting a
9125 register by doing this as GCC can use the same register for both
9126 purposes.  However, it would be foolish to use both @code{%1} and
9127 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9128 same.  In fact, @code{%3} may well not be a register.  It might be a
9129 symbolic memory reference to the object pointed to by @code{x}.
9131 @smallexample
9132 asm ("sumsq %0, %1, %2"
9133      : "+f" (result)
9134      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9135 @end smallexample
9137 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9138 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9139 must be specified as input/output because the @code{asm} modifies
9140 them.
9142 @smallexample
9143 asm ("vecmul %0, %1, %2"
9144      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9145      : "m" (*x), "m" (*y));
9146 @end smallexample
9148 An x86 example where the string memory argument is of unknown length.
9150 @smallexample
9151 asm("repne scasb"
9152     : "=c" (count), "+D" (p)
9153     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9154 @end smallexample
9156 If you know the above will only be reading a ten byte array then you
9157 could instead use a memory input like:
9158 @code{"m" (*(const char (*)[10]) p)}.
9160 Here is an example of a PowerPC vector scale implemented in assembly,
9161 complete with vector and condition code clobbers, and some initialized
9162 offset registers that are unchanged by the @code{asm}.
9164 @smallexample
9165 void
9166 dscal (size_t n, double *x, double alpha)
9168   asm ("/* lots of asm here */"
9169        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9170        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9171          "b" (80), "b" (96), "b" (112)
9172        : "cr0",
9173          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9174          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9176 @end smallexample
9178 Rather than allocating fixed registers via clobbers to provide scratch
9179 registers for an @code{asm} statement, an alternative is to define a
9180 variable and make it an early-clobber output as with @code{a2} and
9181 @code{a3} in the example below.  This gives the compiler register
9182 allocator more freedom.  You can also define a variable and make it an
9183 output tied to an input as with @code{a0} and @code{a1}, tied
9184 respectively to @code{ap} and @code{lda}.  Of course, with tied
9185 outputs your @code{asm} can't use the input value after modifying the
9186 output register since they are one and the same register.  What's
9187 more, if you omit the early-clobber on the output, it is possible that
9188 GCC might allocate the same register to another of the inputs if GCC
9189 could prove they had the same value on entry to the @code{asm}.  This
9190 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
9191 might conceivably be known to have the value 16 and without an
9192 early-clobber share the same register as @code{%11}.  On the other
9193 hand, @code{ap} can't be the same as any of the other inputs, so an
9194 early-clobber on @code{a0} is not needed.  It is also not desirable in
9195 this case.  An early-clobber on @code{a0} would cause GCC to allocate
9196 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9197 input.  Note that tying an input to an output is the way to set up an
9198 initialized temporary register modified by an @code{asm} statement.
9199 An input not tied to an output is assumed by GCC to be unchanged, for
9200 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9201 use that register in following code if the value 16 happened to be
9202 needed.  You can even use a normal @code{asm} output for a scratch if
9203 all inputs that might share the same register are consumed before the
9204 scratch is used.  The VSX registers clobbered by the @code{asm}
9205 statement could have used this technique except for GCC's limit on the
9206 number of @code{asm} parameters.
9208 @smallexample
9209 static void
9210 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9211                   const double *x, double *y, double alpha)
9213   double *a0;
9214   double *a1;
9215   double *a2;
9216   double *a3;
9218   __asm__
9219     (
9220      /* lots of asm here */
9221      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9222      "#a0=%3 a1=%4 a2=%5 a3=%6"
9223      :
9224        "+m" (*(double (*)[n]) y),
9225        "+&r" (n),       // 1
9226        "+b" (y),        // 2
9227        "=b" (a0),       // 3
9228        "=&b" (a1),      // 4
9229        "=&b" (a2),      // 5
9230        "=&b" (a3)       // 6
9231      :
9232        "m" (*(const double (*)[n]) x),
9233        "m" (*(const double (*)[]) ap),
9234        "d" (alpha),     // 9
9235        "r" (x),         // 10
9236        "b" (16),        // 11
9237        "3" (ap),        // 12
9238        "4" (lda)        // 13
9239      :
9240        "cr0",
9241        "vs32","vs33","vs34","vs35","vs36","vs37",
9242        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9243      );
9245 @end smallexample
9247 @anchor{GotoLabels}
9248 @subsubsection Goto Labels
9249 @cindex @code{asm} goto labels
9251 @code{asm goto} allows assembly code to jump to one or more C labels.  The
9252 @var{GotoLabels} section in an @code{asm goto} statement contains 
9253 a comma-separated 
9254 list of all C labels to which the assembler code may jump. GCC assumes that 
9255 @code{asm} execution falls through to the next statement (if this is not the 
9256 case, consider using the @code{__builtin_unreachable} intrinsic after the 
9257 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
9258 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
9259 Attributes}).
9261 An @code{asm goto} statement cannot have outputs.
9262 This is due to an internal restriction of 
9263 the compiler: control transfer instructions cannot have outputs. 
9264 If the assembler code does modify anything, use the @code{"memory"} clobber 
9265 to force the 
9266 optimizers to flush all register values to memory and reload them if 
9267 necessary after the @code{asm} statement.
9269 Also note that an @code{asm goto} statement is always implicitly
9270 considered volatile.
9272 To reference a label in the assembler template,
9273 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9274 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9275 operands.  For example, if the @code{asm} has three inputs and references two 
9276 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9278 Alternately, you can reference labels using the actual C label name enclosed
9279 in brackets.  For example, to reference a label named @code{carry}, you can
9280 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9281 section when using this approach.
9283 Here is an example of @code{asm goto} for i386:
9285 @example
9286 asm goto (
9287     "btl %1, %0\n\t"
9288     "jc %l2"
9289     : /* No outputs. */
9290     : "r" (p1), "r" (p2) 
9291     : "cc" 
9292     : carry);
9294 return 0;
9296 carry:
9297 return 1;
9298 @end example
9300 The following example shows an @code{asm goto} that uses a memory clobber.
9302 @example
9303 int frob(int x)
9305   int y;
9306   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9307             : /* No outputs. */
9308             : "r"(x), "r"(&y)
9309             : "r5", "memory" 
9310             : error);
9311   return y;
9312 error:
9313   return -1;
9315 @end example
9317 @anchor{x86Operandmodifiers}
9318 @subsubsection x86 Operand Modifiers
9320 References to input, output, and goto operands in the assembler template
9321 of extended @code{asm} statements can use 
9322 modifiers to affect the way the operands are formatted in 
9323 the code output to the assembler. For example, the 
9324 following code uses the @samp{h} and @samp{b} modifiers for x86:
9326 @example
9327 uint16_t  num;
9328 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9329 @end example
9331 @noindent
9332 These modifiers generate this assembler code:
9334 @example
9335 xchg %ah, %al
9336 @end example
9338 The rest of this discussion uses the following code for illustrative purposes.
9340 @example
9341 int main()
9343    int iInt = 1;
9345 top:
9347    asm volatile goto ("some assembler instructions here"
9348    : /* No outputs. */
9349    : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9350    : /* No clobbers. */
9351    : top);
9353 @end example
9355 With no modifiers, this is what the output from the operands would be
9356 for the @samp{att} and @samp{intel} dialects of assembler:
9358 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9359 @headitem Operand @tab @samp{att} @tab @samp{intel}
9360 @item @code{%0}
9361 @tab @code{%eax}
9362 @tab @code{eax}
9363 @item @code{%1}
9364 @tab @code{$2}
9365 @tab @code{2}
9366 @item @code{%3}
9367 @tab @code{$.L3}
9368 @tab @code{OFFSET FLAT:.L3}
9369 @end multitable
9371 The table below shows the list of supported modifiers and their effects.
9373 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9374 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9375 @item @code{a}
9376 @tab Print an absolute memory reference.
9377 @tab @code{%A0}
9378 @tab @code{*%rax}
9379 @tab @code{rax}
9380 @item @code{b}
9381 @tab Print the QImode name of the register.
9382 @tab @code{%b0}
9383 @tab @code{%al}
9384 @tab @code{al}
9385 @item @code{c}
9386 @tab Require a constant operand and print the constant expression with no punctuation.
9387 @tab @code{%c1}
9388 @tab @code{2}
9389 @tab @code{2}
9390 @item @code{E}
9391 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9392 Otherwise mode is unspecified (VOIDmode).
9393 @tab @code{%E1}
9394 @tab @code{%(rax)}
9395 @tab @code{[rax]}
9396 @item @code{h}
9397 @tab Print the QImode name for a ``high'' register.
9398 @tab @code{%h0}
9399 @tab @code{%ah}
9400 @tab @code{ah}
9401 @item @code{H}
9402 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9403 high 8 bytes of SSE values. For a memref in (%rax), it generates
9404 @tab @code{%H0}
9405 @tab @code{8(%rax)}
9406 @tab @code{8[rax]}
9407 @item @code{k}
9408 @tab Print the SImode name of the register.
9409 @tab @code{%k0}
9410 @tab @code{%eax}
9411 @tab @code{eax}
9412 @item @code{l}
9413 @tab Print the label name with no punctuation.
9414 @tab @code{%l3}
9415 @tab @code{.L3}
9416 @tab @code{.L3}
9417 @item @code{p}
9418 @tab Print raw symbol name (without syntax-specific prefixes).
9419 @tab @code{%p2}
9420 @tab @code{42}
9421 @tab @code{42}
9422 @item @code{P}
9423 @tab If used for a function, print the PLT suffix and generate PIC code.
9424 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9425 foo(). If used for a constant, drop all syntax-specific prefixes and
9426 issue the bare constant. See @code{p} above.
9427 @item @code{q}
9428 @tab Print the DImode name of the register.
9429 @tab @code{%q0}
9430 @tab @code{%rax}
9431 @tab @code{rax}
9432 @item @code{w}
9433 @tab Print the HImode name of the register.
9434 @tab @code{%w0}
9435 @tab @code{%ax}
9436 @tab @code{ax}
9437 @item @code{z}
9438 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9439 @tab @code{%z0}
9440 @tab @code{l}
9441 @tab 
9442 @end multitable
9444 @code{V} is a special modifier which prints the name of the full integer
9445 register without @code{%}.
9447 @anchor{x86floatingpointasmoperands}
9448 @subsubsection x86 Floating-Point @code{asm} Operands
9450 On x86 targets, there are several rules on the usage of stack-like registers
9451 in the operands of an @code{asm}.  These rules apply only to the operands
9452 that are stack-like registers:
9454 @enumerate
9455 @item
9456 Given a set of input registers that die in an @code{asm}, it is
9457 necessary to know which are implicitly popped by the @code{asm}, and
9458 which must be explicitly popped by GCC@.
9460 An input register that is implicitly popped by the @code{asm} must be
9461 explicitly clobbered, unless it is constrained to match an
9462 output operand.
9464 @item
9465 For any input register that is implicitly popped by an @code{asm}, it is
9466 necessary to know how to adjust the stack to compensate for the pop.
9467 If any non-popped input is closer to the top of the reg-stack than
9468 the implicitly popped register, it would not be possible to know what the
9469 stack looked like---it's not clear how the rest of the stack ``slides
9470 up''.
9472 All implicitly popped input registers must be closer to the top of
9473 the reg-stack than any input that is not implicitly popped.
9475 It is possible that if an input dies in an @code{asm}, the compiler might
9476 use the input register for an output reload.  Consider this example:
9478 @smallexample
9479 asm ("foo" : "=t" (a) : "f" (b));
9480 @end smallexample
9482 @noindent
9483 This code says that input @code{b} is not popped by the @code{asm}, and that
9484 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9485 deeper after the @code{asm} than it was before.  But, it is possible that
9486 reload may think that it can use the same register for both the input and
9487 the output.
9489 To prevent this from happening,
9490 if any input operand uses the @samp{f} constraint, all output register
9491 constraints must use the @samp{&} early-clobber modifier.
9493 The example above is correctly written as:
9495 @smallexample
9496 asm ("foo" : "=&t" (a) : "f" (b));
9497 @end smallexample
9499 @item
9500 Some operands need to be in particular places on the stack.  All
9501 output operands fall in this category---GCC has no other way to
9502 know which registers the outputs appear in unless you indicate
9503 this in the constraints.
9505 Output operands must specifically indicate which register an output
9506 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9507 constraints must select a class with a single register.
9509 @item
9510 Output operands may not be ``inserted'' between existing stack registers.
9511 Since no 387 opcode uses a read/write operand, all output operands
9512 are dead before the @code{asm}, and are pushed by the @code{asm}.
9513 It makes no sense to push anywhere but the top of the reg-stack.
9515 Output operands must start at the top of the reg-stack: output
9516 operands may not ``skip'' a register.
9518 @item
9519 Some @code{asm} statements may need extra stack space for internal
9520 calculations.  This can be guaranteed by clobbering stack registers
9521 unrelated to the inputs and outputs.
9523 @end enumerate
9525 This @code{asm}
9526 takes one input, which is internally popped, and produces two outputs.
9528 @smallexample
9529 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9530 @end smallexample
9532 @noindent
9533 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9534 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9535 for the compiler to know that @code{fyl2xp1} pops both inputs.
9537 @smallexample
9538 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9539 @end smallexample
9541 @lowersections
9542 @include md.texi
9543 @raisesections
9545 @node Asm Labels
9546 @subsection Controlling Names Used in Assembler Code
9547 @cindex assembler names for identifiers
9548 @cindex names used in assembler code
9549 @cindex identifiers, names in assembler code
9551 You can specify the name to be used in the assembler code for a C
9552 function or variable by writing the @code{asm} (or @code{__asm__})
9553 keyword after the declarator.
9554 It is up to you to make sure that the assembler names you choose do not
9555 conflict with any other assembler symbols, or reference registers.
9557 @subsubheading Assembler names for data:
9559 This sample shows how to specify the assembler name for data:
9561 @smallexample
9562 int foo asm ("myfoo") = 2;
9563 @end smallexample
9565 @noindent
9566 This specifies that the name to be used for the variable @code{foo} in
9567 the assembler code should be @samp{myfoo} rather than the usual
9568 @samp{_foo}.
9570 On systems where an underscore is normally prepended to the name of a C
9571 variable, this feature allows you to define names for the
9572 linker that do not start with an underscore.
9574 GCC does not support using this feature with a non-static local variable 
9575 since such variables do not have assembler names.  If you are
9576 trying to put the variable in a particular register, see 
9577 @ref{Explicit Register Variables}.
9579 @subsubheading Assembler names for functions:
9581 To specify the assembler name for functions, write a declaration for the 
9582 function before its definition and put @code{asm} there, like this:
9584 @smallexample
9585 int func (int x, int y) asm ("MYFUNC");
9586      
9587 int func (int x, int y)
9589    /* @r{@dots{}} */
9590 @end smallexample
9592 @noindent
9593 This specifies that the name to be used for the function @code{func} in
9594 the assembler code should be @code{MYFUNC}.
9596 @node Explicit Register Variables
9597 @subsection Variables in Specified Registers
9598 @anchor{Explicit Reg Vars}
9599 @cindex explicit register variables
9600 @cindex variables in specified registers
9601 @cindex specified registers
9603 GNU C allows you to associate specific hardware registers with C 
9604 variables.  In almost all cases, allowing the compiler to assign
9605 registers produces the best code.  However under certain unusual
9606 circumstances, more precise control over the variable storage is 
9607 required.
9609 Both global and local variables can be associated with a register.  The
9610 consequences of performing this association are very different between
9611 the two, as explained in the sections below.
9613 @menu
9614 * Global Register Variables::   Variables declared at global scope.
9615 * Local Register Variables::    Variables declared within a function.
9616 @end menu
9618 @node Global Register Variables
9619 @subsubsection Defining Global Register Variables
9620 @anchor{Global Reg Vars}
9621 @cindex global register variables
9622 @cindex registers, global variables in
9623 @cindex registers, global allocation
9625 You can define a global register variable and associate it with a specified 
9626 register like this:
9628 @smallexample
9629 register int *foo asm ("r12");
9630 @end smallexample
9632 @noindent
9633 Here @code{r12} is the name of the register that should be used. Note that 
9634 this is the same syntax used for defining local register variables, but for 
9635 a global variable the declaration appears outside a function. The 
9636 @code{register} keyword is required, and cannot be combined with 
9637 @code{static}. The register name must be a valid register name for the
9638 target platform.
9640 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9641 the outcome may be contrary to expectations.  In  particular, using the
9642 @code{volatile} qualifier does not fully prevent the compiler from
9643 optimizing accesses to the register.
9645 Registers are a scarce resource on most systems and allowing the 
9646 compiler to manage their usage usually results in the best code. However, 
9647 under special circumstances it can make sense to reserve some globally.
9648 For example this may be useful in programs such as programming language 
9649 interpreters that have a couple of global variables that are accessed 
9650 very often.
9652 After defining a global register variable, for the current compilation
9653 unit:
9655 @itemize @bullet
9656 @item If the register is a call-saved register, call ABI is affected:
9657 the register will not be restored in function epilogue sequences after
9658 the variable has been assigned.  Therefore, functions cannot safely
9659 return to callers that assume standard ABI.
9660 @item Conversely, if the register is a call-clobbered register, making
9661 calls to functions that use standard ABI may lose contents of the variable.
9662 Such calls may be created by the compiler even if none are evident in
9663 the original program, for example when libgcc functions are used to
9664 make up for unavailable instructions.
9665 @item Accesses to the variable may be optimized as usual and the register
9666 remains available for allocation and use in any computations, provided that
9667 observable values of the variable are not affected.
9668 @item If the variable is referenced in inline assembly, the type of access
9669 must be provided to the compiler via constraints (@pxref{Constraints}).
9670 Accesses from basic asms are not supported.
9671 @end itemize
9673 Note that these points @emph{only} apply to code that is compiled with the
9674 definition. The behavior of code that is merely linked in (for example 
9675 code from libraries) is not affected.
9677 If you want to recompile source files that do not actually use your global 
9678 register variable so they do not use the specified register for any other 
9679 purpose, you need not actually add the global register declaration to 
9680 their source code. It suffices to specify the compiler option 
9681 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9682 register.
9684 @subsubheading Declaring the variable
9686 Global register variables can not have initial values, because an
9687 executable file has no means to supply initial contents for a register.
9689 When selecting a register, choose one that is normally saved and 
9690 restored by function calls on your machine. This ensures that code
9691 which is unaware of this reservation (such as library routines) will 
9692 restore it before returning.
9694 On machines with register windows, be sure to choose a global
9695 register that is not affected magically by the function call mechanism.
9697 @subsubheading Using the variable
9699 @cindex @code{qsort}, and global register variables
9700 When calling routines that are not aware of the reservation, be 
9701 cautious if those routines call back into code which uses them. As an 
9702 example, if you call the system library version of @code{qsort}, it may 
9703 clobber your registers during execution, but (if you have selected 
9704 appropriate registers) it will restore them before returning. However 
9705 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9706 function. As a result, global values will not reliably be available to 
9707 the comparison function unless the @code{qsort} function itself is rebuilt.
9709 Similarly, it is not safe to access the global register variables from signal
9710 handlers or from more than one thread of control. Unless you recompile 
9711 them specially for the task at hand, the system library routines may 
9712 temporarily use the register for other things.  Furthermore, since the register
9713 is not reserved exclusively for the variable, accessing it from handlers of
9714 asynchronous signals may observe unrelated temporary values residing in the
9715 register.
9717 @cindex register variable after @code{longjmp}
9718 @cindex global register after @code{longjmp}
9719 @cindex value after @code{longjmp}
9720 @findex longjmp
9721 @findex setjmp
9722 On most machines, @code{longjmp} restores to each global register
9723 variable the value it had at the time of the @code{setjmp}. On some
9724 machines, however, @code{longjmp} does not change the value of global
9725 register variables. To be portable, the function that called @code{setjmp}
9726 should make other arrangements to save the values of the global register
9727 variables, and to restore them in a @code{longjmp}. This way, the same
9728 thing happens regardless of what @code{longjmp} does.
9730 @node Local Register Variables
9731 @subsubsection Specifying Registers for Local Variables
9732 @anchor{Local Reg Vars}
9733 @cindex local variables, specifying registers
9734 @cindex specifying registers for local variables
9735 @cindex registers for local variables
9737 You can define a local register variable and associate it with a specified 
9738 register like this:
9740 @smallexample
9741 register int *foo asm ("r12");
9742 @end smallexample
9744 @noindent
9745 Here @code{r12} is the name of the register that should be used.  Note
9746 that this is the same syntax used for defining global register variables, 
9747 but for a local variable the declaration appears within a function.  The 
9748 @code{register} keyword is required, and cannot be combined with 
9749 @code{static}.  The register name must be a valid register name for the
9750 target platform.
9752 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9753 the outcome may be contrary to expectations. In particular, when the
9754 @code{const} qualifier is used, the compiler may substitute the
9755 variable with its initializer in @code{asm} statements, which may cause
9756 the corresponding operand to appear in a different register.
9758 As with global register variables, it is recommended that you choose 
9759 a register that is normally saved and restored by function calls on your 
9760 machine, so that calls to library routines will not clobber it.
9762 The only supported use for this feature is to specify registers
9763 for input and output operands when calling Extended @code{asm} 
9764 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9765 particular machine don't provide sufficient control to select the desired 
9766 register.  To force an operand into a register, create a local variable 
9767 and specify the register name after the variable's declaration.  Then use 
9768 the local variable for the @code{asm} operand and specify any constraint 
9769 letter that matches the register:
9771 @smallexample
9772 register int *p1 asm ("r0") = @dots{};
9773 register int *p2 asm ("r1") = @dots{};
9774 register int *result asm ("r0");
9775 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9776 @end smallexample
9778 @emph{Warning:} In the above example, be aware that a register (for example 
9779 @code{r0}) can be call-clobbered by subsequent code, including function 
9780 calls and library calls for arithmetic operators on other variables (for 
9781 example the initialization of @code{p2}).  In this case, use temporary 
9782 variables for expressions between the register assignments:
9784 @smallexample
9785 int t1 = @dots{};
9786 register int *p1 asm ("r0") = @dots{};
9787 register int *p2 asm ("r1") = t1;
9788 register int *result asm ("r0");
9789 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9790 @end smallexample
9792 Defining a register variable does not reserve the register.  Other than
9793 when invoking the Extended @code{asm}, the contents of the specified 
9794 register are not guaranteed.  For this reason, the following uses 
9795 are explicitly @emph{not} supported.  If they appear to work, it is only 
9796 happenstance, and may stop working as intended due to (seemingly) 
9797 unrelated changes in surrounding code, or even minor changes in the 
9798 optimization of a future version of gcc:
9800 @itemize @bullet
9801 @item Passing parameters to or from Basic @code{asm}
9802 @item Passing parameters to or from Extended @code{asm} without using input 
9803 or output operands.
9804 @item Passing parameters to or from routines written in assembler (or
9805 other languages) using non-standard calling conventions.
9806 @end itemize
9808 Some developers use Local Register Variables in an attempt to improve 
9809 gcc's allocation of registers, especially in large functions.  In this 
9810 case the register name is essentially a hint to the register allocator.
9811 While in some instances this can generate better code, improvements are
9812 subject to the whims of the allocator/optimizers.  Since there are no
9813 guarantees that your improvements won't be lost, this usage of Local
9814 Register Variables is discouraged.
9816 On the MIPS platform, there is related use for local register variables 
9817 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9818 Defining coprocessor specifics for MIPS targets, gccint, 
9819 GNU Compiler Collection (GCC) Internals}).
9821 @node Size of an asm
9822 @subsection Size of an @code{asm}
9824 Some targets require that GCC track the size of each instruction used
9825 in order to generate correct code.  Because the final length of the
9826 code produced by an @code{asm} statement is only known by the
9827 assembler, GCC must make an estimate as to how big it will be.  It
9828 does this by counting the number of instructions in the pattern of the
9829 @code{asm} and multiplying that by the length of the longest
9830 instruction supported by that processor.  (When working out the number
9831 of instructions, it assumes that any occurrence of a newline or of
9832 whatever statement separator character is supported by the assembler --
9833 typically @samp{;} --- indicates the end of an instruction.)
9835 Normally, GCC's estimate is adequate to ensure that correct
9836 code is generated, but it is possible to confuse the compiler if you use
9837 pseudo instructions or assembler macros that expand into multiple real
9838 instructions, or if you use assembler directives that expand to more
9839 space in the object file than is needed for a single instruction.
9840 If this happens then the assembler may produce a diagnostic saying that
9841 a label is unreachable.
9843 @node Alternate Keywords
9844 @section Alternate Keywords
9845 @cindex alternate keywords
9846 @cindex keywords, alternate
9848 @option{-ansi} and the various @option{-std} options disable certain
9849 keywords.  This causes trouble when you want to use GNU C extensions, or
9850 a general-purpose header file that should be usable by all programs,
9851 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9852 @code{inline} are not available in programs compiled with
9853 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9854 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9855 ISO C99 keyword
9856 @code{restrict} is only available when @option{-std=gnu99} (which will
9857 eventually be the default) or @option{-std=c99} (or the equivalent
9858 @option{-std=iso9899:1999}), or an option for a later standard
9859 version, is used.
9861 The way to solve these problems is to put @samp{__} at the beginning and
9862 end of each problematical keyword.  For example, use @code{__asm__}
9863 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9865 Other C compilers won't accept these alternative keywords; if you want to
9866 compile with another compiler, you can define the alternate keywords as
9867 macros to replace them with the customary keywords.  It looks like this:
9869 @smallexample
9870 #ifndef __GNUC__
9871 #define __asm__ asm
9872 #endif
9873 @end smallexample
9875 @findex __extension__
9876 @opindex pedantic
9877 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9878 You can
9879 prevent such warnings within one expression by writing
9880 @code{__extension__} before the expression.  @code{__extension__} has no
9881 effect aside from this.
9883 @node Incomplete Enums
9884 @section Incomplete @code{enum} Types
9886 You can define an @code{enum} tag without specifying its possible values.
9887 This results in an incomplete type, much like what you get if you write
9888 @code{struct foo} without describing the elements.  A later declaration
9889 that does specify the possible values completes the type.
9891 You cannot allocate variables or storage using the type while it is
9892 incomplete.  However, you can work with pointers to that type.
9894 This extension may not be very useful, but it makes the handling of
9895 @code{enum} more consistent with the way @code{struct} and @code{union}
9896 are handled.
9898 This extension is not supported by GNU C++.
9900 @node Function Names
9901 @section Function Names as Strings
9902 @cindex @code{__func__} identifier
9903 @cindex @code{__FUNCTION__} identifier
9904 @cindex @code{__PRETTY_FUNCTION__} identifier
9906 GCC provides three magic constants that hold the name of the current
9907 function as a string.  In C++11 and later modes, all three are treated
9908 as constant expressions and can be used in @code{constexpr} constexts.
9909 The first of these constants is @code{__func__}, which is part of
9910 the C99 standard:
9912 The identifier @code{__func__} is implicitly declared by the translator
9913 as if, immediately following the opening brace of each function
9914 definition, the declaration
9916 @smallexample
9917 static const char __func__[] = "function-name";
9918 @end smallexample
9920 @noindent
9921 appeared, where function-name is the name of the lexically-enclosing
9922 function.  This name is the unadorned name of the function.  As an
9923 extension, at file (or, in C++, namespace scope), @code{__func__}
9924 evaluates to the empty string.
9926 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9927 backward compatibility with old versions of GCC.
9929 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9930 @code{__func__}, except that at file (or, in C++, namespace scope),
9931 it evaluates to the string @code{"top level"}.  In addition, in C++,
9932 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9933 well as its bare name.  For example, this program:
9935 @smallexample
9936 extern "C" int printf (const char *, ...);
9938 class a @{
9939  public:
9940   void sub (int i)
9941     @{
9942       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9943       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9944     @}
9948 main (void)
9950   a ax;
9951   ax.sub (0);
9952   return 0;
9954 @end smallexample
9956 @noindent
9957 gives this output:
9959 @smallexample
9960 __FUNCTION__ = sub
9961 __PRETTY_FUNCTION__ = void a::sub(int)
9962 @end smallexample
9964 These identifiers are variables, not preprocessor macros, and may not
9965 be used to initialize @code{char} arrays or be concatenated with string
9966 literals.
9968 @node Return Address
9969 @section Getting the Return or Frame Address of a Function
9971 These functions may be used to get information about the callers of a
9972 function.
9974 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9975 This function returns the return address of the current function, or of
9976 one of its callers.  The @var{level} argument is number of frames to
9977 scan up the call stack.  A value of @code{0} yields the return address
9978 of the current function, a value of @code{1} yields the return address
9979 of the caller of the current function, and so forth.  When inlining
9980 the expected behavior is that the function returns the address of
9981 the function that is returned to.  To work around this behavior use
9982 the @code{noinline} function attribute.
9984 The @var{level} argument must be a constant integer.
9986 On some machines it may be impossible to determine the return address of
9987 any function other than the current one; in such cases, or when the top
9988 of the stack has been reached, this function returns @code{0} or a
9989 random value.  In addition, @code{__builtin_frame_address} may be used
9990 to determine if the top of the stack has been reached.
9992 Additional post-processing of the returned value may be needed, see
9993 @code{__builtin_extract_return_addr}.
9995 Calling this function with a nonzero argument can have unpredictable
9996 effects, including crashing the calling program.  As a result, calls
9997 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9998 option is in effect.  Such calls should only be made in debugging
9999 situations.
10000 @end deftypefn
10002 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
10003 The address as returned by @code{__builtin_return_address} may have to be fed
10004 through this function to get the actual encoded address.  For example, on the
10005 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
10006 platforms an offset has to be added for the true next instruction to be
10007 executed.
10009 If no fixup is needed, this function simply passes through @var{addr}.
10010 @end deftypefn
10012 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10013 This function does the reverse of @code{__builtin_extract_return_addr}.
10014 @end deftypefn
10016 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10017 This function is similar to @code{__builtin_return_address}, but it
10018 returns the address of the function frame rather than the return address
10019 of the function.  Calling @code{__builtin_frame_address} with a value of
10020 @code{0} yields the frame address of the current function, a value of
10021 @code{1} yields the frame address of the caller of the current function,
10022 and so forth.
10024 The frame is the area on the stack that holds local variables and saved
10025 registers.  The frame address is normally the address of the first word
10026 pushed on to the stack by the function.  However, the exact definition
10027 depends upon the processor and the calling convention.  If the processor
10028 has a dedicated frame pointer register, and the function has a frame,
10029 then @code{__builtin_frame_address} returns the value of the frame
10030 pointer register.
10032 On some machines it may be impossible to determine the frame address of
10033 any function other than the current one; in such cases, or when the top
10034 of the stack has been reached, this function returns @code{0} if
10035 the first frame pointer is properly initialized by the startup code.
10037 Calling this function with a nonzero argument can have unpredictable
10038 effects, including crashing the calling program.  As a result, calls
10039 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10040 option is in effect.  Such calls should only be made in debugging
10041 situations.
10042 @end deftypefn
10044 @node Vector Extensions
10045 @section Using Vector Instructions through Built-in Functions
10047 On some targets, the instruction set contains SIMD vector instructions which
10048 operate on multiple values contained in one large register at the same time.
10049 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10050 this way.
10052 The first step in using these extensions is to provide the necessary data
10053 types.  This should be done using an appropriate @code{typedef}:
10055 @smallexample
10056 typedef int v4si __attribute__ ((vector_size (16)));
10057 @end smallexample
10059 @noindent
10060 The @code{int} type specifies the base type, while the attribute specifies
10061 the vector size for the variable, measured in bytes.  For example, the
10062 declaration above causes the compiler to set the mode for the @code{v4si}
10063 type to be 16 bytes wide and divided into @code{int} sized units.  For
10064 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10065 corresponding mode of @code{foo} is @acronym{V4SI}.
10067 The @code{vector_size} attribute is only applicable to integral and
10068 float scalars, although arrays, pointers, and function return values
10069 are allowed in conjunction with this construct. Only sizes that are
10070 a power of two are currently allowed.
10072 All the basic integer types can be used as base types, both as signed
10073 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10074 @code{long long}.  In addition, @code{float} and @code{double} can be
10075 used to build floating-point vector types.
10077 Specifying a combination that is not valid for the current architecture
10078 causes GCC to synthesize the instructions using a narrower mode.
10079 For example, if you specify a variable of type @code{V4SI} and your
10080 architecture does not allow for this specific SIMD type, GCC
10081 produces code that uses 4 @code{SIs}.
10083 The types defined in this manner can be used with a subset of normal C
10084 operations.  Currently, GCC allows using the following operators
10085 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10087 The operations behave like C++ @code{valarrays}.  Addition is defined as
10088 the addition of the corresponding elements of the operands.  For
10089 example, in the code below, each of the 4 elements in @var{a} is
10090 added to the corresponding 4 elements in @var{b} and the resulting
10091 vector is stored in @var{c}.
10093 @smallexample
10094 typedef int v4si __attribute__ ((vector_size (16)));
10096 v4si a, b, c;
10098 c = a + b;
10099 @end smallexample
10101 Subtraction, multiplication, division, and the logical operations
10102 operate in a similar manner.  Likewise, the result of using the unary
10103 minus or complement operators on a vector type is a vector whose
10104 elements are the negative or complemented values of the corresponding
10105 elements in the operand.
10107 It is possible to use shifting operators @code{<<}, @code{>>} on
10108 integer-type vectors. The operation is defined as following: @code{@{a0,
10109 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10110 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10111 elements. 
10113 For convenience, it is allowed to use a binary vector operation
10114 where one operand is a scalar. In that case the compiler transforms
10115 the scalar operand into a vector where each element is the scalar from
10116 the operation. The transformation happens only if the scalar could be
10117 safely converted to the vector-element type.
10118 Consider the following code.
10120 @smallexample
10121 typedef int v4si __attribute__ ((vector_size (16)));
10123 v4si a, b, c;
10124 long l;
10126 a = b + 1;    /* a = b + @{1,1,1,1@}; */
10127 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
10129 a = l + a;    /* Error, cannot convert long to int. */
10130 @end smallexample
10132 Vectors can be subscripted as if the vector were an array with
10133 the same number of elements and base type.  Out of bound accesses
10134 invoke undefined behavior at run time.  Warnings for out of bound
10135 accesses for vector subscription can be enabled with
10136 @option{-Warray-bounds}.
10138 Vector comparison is supported with standard comparison
10139 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10140 vector expressions of integer-type or real-type. Comparison between
10141 integer-type vectors and real-type vectors are not supported.  The
10142 result of the comparison is a vector of the same width and number of
10143 elements as the comparison operands with a signed integral element
10144 type.
10146 Vectors are compared element-wise producing 0 when comparison is false
10147 and -1 (constant of the appropriate type where all bits are set)
10148 otherwise. Consider the following example.
10150 @smallexample
10151 typedef int v4si __attribute__ ((vector_size (16)));
10153 v4si a = @{1,2,3,4@};
10154 v4si b = @{3,2,1,4@};
10155 v4si c;
10157 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
10158 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
10159 @end smallexample
10161 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10162 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10163 integer vector with the same number of elements of the same size as @code{b}
10164 and @code{c}, computes all three arguments and creates a vector
10165 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
10166 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10167 As in the case of binary operations, this syntax is also accepted when
10168 one of @code{b} or @code{c} is a scalar that is then transformed into a
10169 vector. If both @code{b} and @code{c} are scalars and the type of
10170 @code{true?b:c} has the same size as the element type of @code{a}, then
10171 @code{b} and @code{c} are converted to a vector type whose elements have
10172 this type and with the same number of elements as @code{a}.
10174 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10175 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10176 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10177 For mixed operations between a scalar @code{s} and a vector @code{v},
10178 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10179 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10181 @findex __builtin_shuffle
10182 Vector shuffling is available using functions
10183 @code{__builtin_shuffle (vec, mask)} and
10184 @code{__builtin_shuffle (vec0, vec1, mask)}.
10185 Both functions construct a permutation of elements from one or two
10186 vectors and return a vector of the same type as the input vector(s).
10187 The @var{mask} is an integral vector with the same width (@var{W})
10188 and element count (@var{N}) as the output vector.
10190 The elements of the input vectors are numbered in memory ordering of
10191 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
10192 elements of @var{mask} are considered modulo @var{N} in the single-operand
10193 case and modulo @math{2*@var{N}} in the two-operand case.
10195 Consider the following example,
10197 @smallexample
10198 typedef int v4si __attribute__ ((vector_size (16)));
10200 v4si a = @{1,2,3,4@};
10201 v4si b = @{5,6,7,8@};
10202 v4si mask1 = @{0,1,1,3@};
10203 v4si mask2 = @{0,4,2,5@};
10204 v4si res;
10206 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
10207 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
10208 @end smallexample
10210 Note that @code{__builtin_shuffle} is intentionally semantically
10211 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10213 You can declare variables and use them in function calls and returns, as
10214 well as in assignments and some casts.  You can specify a vector type as
10215 a return type for a function.  Vector types can also be used as function
10216 arguments.  It is possible to cast from one vector type to another,
10217 provided they are of the same size (in fact, you can also cast vectors
10218 to and from other datatypes of the same size).
10220 You cannot operate between vectors of different lengths or different
10221 signedness without a cast.
10223 @node Offsetof
10224 @section Support for @code{offsetof}
10225 @findex __builtin_offsetof
10227 GCC implements for both C and C++ a syntactic extension to implement
10228 the @code{offsetof} macro.
10230 @smallexample
10231 primary:
10232         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10234 offsetof_member_designator:
10235           @code{identifier}
10236         | offsetof_member_designator "." @code{identifier}
10237         | offsetof_member_designator "[" @code{expr} "]"
10238 @end smallexample
10240 This extension is sufficient such that
10242 @smallexample
10243 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
10244 @end smallexample
10246 @noindent
10247 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
10248 may be dependent.  In either case, @var{member} may consist of a single
10249 identifier, or a sequence of member accesses and array references.
10251 @node __sync Builtins
10252 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10254 The following built-in functions
10255 are intended to be compatible with those described
10256 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10257 section 7.4.  As such, they depart from normal GCC practice by not using
10258 the @samp{__builtin_} prefix and also by being overloaded so that they
10259 work on multiple types.
10261 The definition given in the Intel documentation allows only for the use of
10262 the types @code{int}, @code{long}, @code{long long} or their unsigned
10263 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10264 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10265 Operations on pointer arguments are performed as if the operands were
10266 of the @code{uintptr_t} type.  That is, they are not scaled by the size
10267 of the type to which the pointer points.
10269 These functions are implemented in terms of the @samp{__atomic}
10270 builtins (@pxref{__atomic Builtins}).  They should not be used for new
10271 code which should use the @samp{__atomic} builtins instead.
10273 Not all operations are supported by all target processors.  If a particular
10274 operation cannot be implemented on the target processor, a warning is
10275 generated and a call to an external function is generated.  The external
10276 function carries the same name as the built-in version,
10277 with an additional suffix
10278 @samp{_@var{n}} where @var{n} is the size of the data type.
10280 @c ??? Should we have a mechanism to suppress this warning?  This is almost
10281 @c useful for implementing the operation under the control of an external
10282 @c mutex.
10284 In most cases, these built-in functions are considered a @dfn{full barrier}.
10285 That is,
10286 no memory operand is moved across the operation, either forward or
10287 backward.  Further, instructions are issued as necessary to prevent the
10288 processor from speculating loads across the operation and from queuing stores
10289 after the operation.
10291 All of the routines are described in the Intel documentation to take
10292 ``an optional list of variables protected by the memory barrier''.  It's
10293 not clear what is meant by that; it could mean that @emph{only} the
10294 listed variables are protected, or it could mean a list of additional
10295 variables to be protected.  The list is ignored by GCC which treats it as
10296 empty.  GCC interprets an empty list as meaning that all globally
10297 accessible variables should be protected.
10299 @table @code
10300 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10301 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10302 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10303 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10304 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10305 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10306 @findex __sync_fetch_and_add
10307 @findex __sync_fetch_and_sub
10308 @findex __sync_fetch_and_or
10309 @findex __sync_fetch_and_and
10310 @findex __sync_fetch_and_xor
10311 @findex __sync_fetch_and_nand
10312 These built-in functions perform the operation suggested by the name, and
10313 returns the value that had previously been in memory.  That is, operations
10314 on integer operands have the following semantics.  Operations on pointer
10315 arguments are performed as if the operands were of the @code{uintptr_t}
10316 type.  That is, they are not scaled by the size of the type to which
10317 the pointer points.
10319 @smallexample
10320 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10321 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
10322 @end smallexample
10324 The object pointed to by the first argument must be of integer or pointer
10325 type.  It must not be a boolean type.
10327 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10328 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10330 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10331 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10332 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10333 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10334 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10335 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10336 @findex __sync_add_and_fetch
10337 @findex __sync_sub_and_fetch
10338 @findex __sync_or_and_fetch
10339 @findex __sync_and_and_fetch
10340 @findex __sync_xor_and_fetch
10341 @findex __sync_nand_and_fetch
10342 These built-in functions perform the operation suggested by the name, and
10343 return the new value.  That is, operations on integer operands have
10344 the following semantics.  Operations on pointer operands are performed as
10345 if the operand's type were @code{uintptr_t}.
10347 @smallexample
10348 @{ *ptr @var{op}= value; return *ptr; @}
10349 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10350 @end smallexample
10352 The same constraints on arguments apply as for the corresponding
10353 @code{__sync_op_and_fetch} built-in functions.
10355 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10356 as @code{*ptr = ~(*ptr & value)} instead of
10357 @code{*ptr = ~*ptr & value}.
10359 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10360 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10361 @findex __sync_bool_compare_and_swap
10362 @findex __sync_val_compare_and_swap
10363 These built-in functions perform an atomic compare and swap.
10364 That is, if the current
10365 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10366 @code{*@var{ptr}}.
10368 The ``bool'' version returns true if the comparison is successful and
10369 @var{newval} is written.  The ``val'' version returns the contents
10370 of @code{*@var{ptr}} before the operation.
10372 @item __sync_synchronize (...)
10373 @findex __sync_synchronize
10374 This built-in function issues a full memory barrier.
10376 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10377 @findex __sync_lock_test_and_set
10378 This built-in function, as described by Intel, is not a traditional test-and-set
10379 operation, but rather an atomic exchange operation.  It writes @var{value}
10380 into @code{*@var{ptr}}, and returns the previous contents of
10381 @code{*@var{ptr}}.
10383 Many targets have only minimal support for such locks, and do not support
10384 a full exchange operation.  In this case, a target may support reduced
10385 functionality here by which the @emph{only} valid value to store is the
10386 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10387 is implementation defined.
10389 This built-in function is not a full barrier,
10390 but rather an @dfn{acquire barrier}.
10391 This means that references after the operation cannot move to (or be
10392 speculated to) before the operation, but previous memory stores may not
10393 be globally visible yet, and previous memory loads may not yet be
10394 satisfied.
10396 @item void __sync_lock_release (@var{type} *ptr, ...)
10397 @findex __sync_lock_release
10398 This built-in function releases the lock acquired by
10399 @code{__sync_lock_test_and_set}.
10400 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10402 This built-in function is not a full barrier,
10403 but rather a @dfn{release barrier}.
10404 This means that all previous memory stores are globally visible, and all
10405 previous memory loads have been satisfied, but following memory reads
10406 are not prevented from being speculated to before the barrier.
10407 @end table
10409 @node __atomic Builtins
10410 @section Built-in Functions for Memory Model Aware Atomic Operations
10412 The following built-in functions approximately match the requirements
10413 for the C++11 memory model.  They are all
10414 identified by being prefixed with @samp{__atomic} and most are
10415 overloaded so that they work with multiple types.
10417 These functions are intended to replace the legacy @samp{__sync}
10418 builtins.  The main difference is that the memory order that is requested
10419 is a parameter to the functions.  New code should always use the
10420 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10422 Note that the @samp{__atomic} builtins assume that programs will
10423 conform to the C++11 memory model.  In particular, they assume
10424 that programs are free of data races.  See the C++11 standard for
10425 detailed requirements.
10427 The @samp{__atomic} builtins can be used with any integral scalar or
10428 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10429 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10430 supported by the architecture.
10432 The four non-arithmetic functions (load, store, exchange, and 
10433 compare_exchange) all have a generic version as well.  This generic
10434 version works on any data type.  It uses the lock-free built-in function
10435 if the specific data type size makes that possible; otherwise, an
10436 external call is left to be resolved at run time.  This external call is
10437 the same format with the addition of a @samp{size_t} parameter inserted
10438 as the first parameter indicating the size of the object being pointed to.
10439 All objects must be the same size.
10441 There are 6 different memory orders that can be specified.  These map
10442 to the C++11 memory orders with the same names, see the C++11 standard
10443 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10444 on atomic synchronization} for detailed definitions.  Individual
10445 targets may also support additional memory orders for use on specific
10446 architectures.  Refer to the target documentation for details of
10447 these.
10449 An atomic operation can both constrain code motion and
10450 be mapped to hardware instructions for synchronization between threads
10451 (e.g., a fence).  To which extent this happens is controlled by the
10452 memory orders, which are listed here in approximately ascending order of
10453 strength.  The description of each memory order is only meant to roughly
10454 illustrate the effects and is not a specification; see the C++11
10455 memory model for precise semantics.
10457 @table  @code
10458 @item __ATOMIC_RELAXED
10459 Implies no inter-thread ordering constraints.
10460 @item __ATOMIC_CONSUME
10461 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10462 memory order because of a deficiency in C++11's semantics for
10463 @code{memory_order_consume}.
10464 @item __ATOMIC_ACQUIRE
10465 Creates an inter-thread happens-before constraint from the release (or
10466 stronger) semantic store to this acquire load.  Can prevent hoisting
10467 of code to before the operation.
10468 @item __ATOMIC_RELEASE
10469 Creates an inter-thread happens-before constraint to acquire (or stronger)
10470 semantic loads that read from this release store.  Can prevent sinking
10471 of code to after the operation.
10472 @item __ATOMIC_ACQ_REL
10473 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10474 @code{__ATOMIC_RELEASE}.
10475 @item __ATOMIC_SEQ_CST
10476 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10477 @end table
10479 Note that in the C++11 memory model, @emph{fences} (e.g.,
10480 @samp{__atomic_thread_fence}) take effect in combination with other
10481 atomic operations on specific memory locations (e.g., atomic loads);
10482 operations on specific memory locations do not necessarily affect other
10483 operations in the same way.
10485 Target architectures are encouraged to provide their own patterns for
10486 each of the atomic built-in functions.  If no target is provided, the original
10487 non-memory model set of @samp{__sync} atomic built-in functions are
10488 used, along with any required synchronization fences surrounding it in
10489 order to achieve the proper behavior.  Execution in this case is subject
10490 to the same restrictions as those built-in functions.
10492 If there is no pattern or mechanism to provide a lock-free instruction
10493 sequence, a call is made to an external routine with the same parameters
10494 to be resolved at run time.
10496 When implementing patterns for these built-in functions, the memory order
10497 parameter can be ignored as long as the pattern implements the most
10498 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10499 orders execute correctly with this memory order but they may not execute as
10500 efficiently as they could with a more appropriate implementation of the
10501 relaxed requirements.
10503 Note that the C++11 standard allows for the memory order parameter to be
10504 determined at run time rather than at compile time.  These built-in
10505 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10506 than invoke a runtime library call or inline a switch statement.  This is
10507 standard compliant, safe, and the simplest approach for now.
10509 The memory order parameter is a signed int, but only the lower 16 bits are
10510 reserved for the memory order.  The remainder of the signed int is reserved
10511 for target use and should be 0.  Use of the predefined atomic values
10512 ensures proper usage.
10514 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10515 This built-in function implements an atomic load operation.  It returns the
10516 contents of @code{*@var{ptr}}.
10518 The valid memory order variants are
10519 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10520 and @code{__ATOMIC_CONSUME}.
10522 @end deftypefn
10524 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10525 This is the generic version of an atomic load.  It returns the
10526 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10528 @end deftypefn
10530 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10531 This built-in function implements an atomic store operation.  It writes 
10532 @code{@var{val}} into @code{*@var{ptr}}.  
10534 The valid memory order variants are
10535 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10537 @end deftypefn
10539 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10540 This is the generic version of an atomic store.  It stores the value
10541 of @code{*@var{val}} into @code{*@var{ptr}}.
10543 @end deftypefn
10545 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10546 This built-in function implements an atomic exchange operation.  It writes
10547 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10548 @code{*@var{ptr}}.
10550 The valid memory order variants are
10551 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10552 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10554 @end deftypefn
10556 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10557 This is the generic version of an atomic exchange.  It stores the
10558 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10559 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10561 @end deftypefn
10563 @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)
10564 This built-in function implements an atomic compare and exchange operation.
10565 This compares the contents of @code{*@var{ptr}} with the contents of
10566 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10567 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10568 equal, the operation is a @emph{read} and the current contents of
10569 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
10570 for weak compare_exchange, which may fail spuriously, and false for
10571 the strong variation, which never fails spuriously.  Many targets
10572 only offer the strong variation and ignore the parameter.  When in doubt, use
10573 the strong variation.
10575 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10576 and memory is affected according to the
10577 memory order specified by @var{success_memorder}.  There are no
10578 restrictions on what memory order can be used here.
10580 Otherwise, false is returned and memory is affected according
10581 to @var{failure_memorder}. This memory order cannot be
10582 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10583 stronger order than that specified by @var{success_memorder}.
10585 @end deftypefn
10587 @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)
10588 This built-in function implements the generic version of
10589 @code{__atomic_compare_exchange}.  The function is virtually identical to
10590 @code{__atomic_compare_exchange_n}, except the desired value is also a
10591 pointer.
10593 @end deftypefn
10595 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10596 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10597 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10598 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10599 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10600 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10601 These built-in functions perform the operation suggested by the name, and
10602 return the result of the operation.  Operations on pointer arguments are
10603 performed as if the operands were of the @code{uintptr_t} type.  That is,
10604 they are not scaled by the size of the type to which the pointer points.
10606 @smallexample
10607 @{ *ptr @var{op}= val; return *ptr; @}
10608 @end smallexample
10610 The object pointed to by the first argument must be of integer or pointer
10611 type.  It must not be a boolean type.  All memory orders are valid.
10613 @end deftypefn
10615 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10616 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10617 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10618 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10619 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10620 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10621 These built-in functions perform the operation suggested by the name, and
10622 return the value that had previously been in @code{*@var{ptr}}.  Operations
10623 on pointer arguments are performed as if the operands were of
10624 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10625 the type to which the pointer points.
10627 @smallexample
10628 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10629 @end smallexample
10631 The same constraints on arguments apply as for the corresponding
10632 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10634 @end deftypefn
10636 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10638 This built-in function performs an atomic test-and-set operation on
10639 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10640 defined nonzero ``set'' value and the return value is @code{true} if and only
10641 if the previous contents were ``set''.
10642 It should be only used for operands of type @code{bool} or @code{char}. For 
10643 other types only part of the value may be set.
10645 All memory orders are valid.
10647 @end deftypefn
10649 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10651 This built-in function performs an atomic clear operation on
10652 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10653 It should be only used for operands of type @code{bool} or @code{char} and 
10654 in conjunction with @code{__atomic_test_and_set}.
10655 For other types it may only clear partially. If the type is not @code{bool}
10656 prefer using @code{__atomic_store}.
10658 The valid memory order variants are
10659 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10660 @code{__ATOMIC_RELEASE}.
10662 @end deftypefn
10664 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10666 This built-in function acts as a synchronization fence between threads
10667 based on the specified memory order.
10669 All memory orders are valid.
10671 @end deftypefn
10673 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10675 This built-in function acts as a synchronization fence between a thread
10676 and signal handlers based in the same thread.
10678 All memory orders are valid.
10680 @end deftypefn
10682 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10684 This built-in function returns true if objects of @var{size} bytes always
10685 generate lock-free atomic instructions for the target architecture.
10686 @var{size} must resolve to a compile-time constant and the result also
10687 resolves to a compile-time constant.
10689 @var{ptr} is an optional pointer to the object that may be used to determine
10690 alignment.  A value of 0 indicates typical alignment should be used.  The 
10691 compiler may also ignore this parameter.
10693 @smallexample
10694 if (__atomic_always_lock_free (sizeof (long long), 0))
10695 @end smallexample
10697 @end deftypefn
10699 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10701 This built-in function returns true if objects of @var{size} bytes always
10702 generate lock-free atomic instructions for the target architecture.  If
10703 the built-in function is not known to be lock-free, a call is made to a
10704 runtime routine named @code{__atomic_is_lock_free}.
10706 @var{ptr} is an optional pointer to the object that may be used to determine
10707 alignment.  A value of 0 indicates typical alignment should be used.  The 
10708 compiler may also ignore this parameter.
10709 @end deftypefn
10711 @node Integer Overflow Builtins
10712 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10714 The following built-in functions allow performing simple arithmetic operations
10715 together with checking whether the operations overflowed.
10717 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10718 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10719 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10720 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10721 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10722 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10723 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10725 These built-in functions promote the first two operands into infinite precision signed
10726 type and perform addition on those promoted operands.  The result is then
10727 cast to the type the third pointer argument points to and stored there.
10728 If the stored result is equal to the infinite precision result, the built-in
10729 functions return false, otherwise they return true.  As the addition is
10730 performed in infinite signed precision, these built-in functions have fully defined
10731 behavior for all argument values.
10733 The first built-in function allows arbitrary integral types for operands and
10734 the result type must be pointer to some integral type other than enumerated or
10735 boolean type, the rest of the built-in functions have explicit integer types.
10737 The compiler will attempt to use hardware instructions to implement
10738 these built-in functions where possible, like conditional jump on overflow
10739 after addition, conditional jump on carry etc.
10741 @end deftypefn
10743 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10744 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10745 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10746 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10747 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10748 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10749 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10751 These built-in functions are similar to the add overflow checking built-in
10752 functions above, except they perform subtraction, subtract the second argument
10753 from the first one, instead of addition.
10755 @end deftypefn
10757 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10758 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10759 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10760 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10761 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10762 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10763 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10765 These built-in functions are similar to the add overflow checking built-in
10766 functions above, except they perform multiplication, instead of addition.
10768 @end deftypefn
10770 The following built-in functions allow checking if simple arithmetic operation
10771 would overflow.
10773 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10774 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10775 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10777 These built-in functions are similar to @code{__builtin_add_overflow},
10778 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10779 they don't store the result of the arithmetic operation anywhere and the
10780 last argument is not a pointer, but some expression with integral type other
10781 than enumerated or boolean type.
10783 The built-in functions promote the first two operands into infinite precision signed type
10784 and perform addition on those promoted operands. The result is then
10785 cast to the type of the third argument.  If the cast result is equal to the infinite
10786 precision result, the built-in functions return false, otherwise they return true.
10787 The value of the third argument is ignored, just the side effects in the third argument
10788 are evaluated, and no integral argument promotions are performed on the last argument.
10789 If the third argument is a bit-field, the type used for the result cast has the
10790 precision and signedness of the given bit-field, rather than precision and signedness
10791 of the underlying type.
10793 For example, the following macro can be used to portably check, at
10794 compile-time, whether or not adding two constant integers will overflow,
10795 and perform the addition only when it is known to be safe and not to trigger
10796 a @option{-Woverflow} warning.
10798 @smallexample
10799 #define INT_ADD_OVERFLOW_P(a, b) \
10800    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10802 enum @{
10803     A = INT_MAX, B = 3,
10804     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10805     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10807 @end smallexample
10809 The compiler will attempt to use hardware instructions to implement
10810 these built-in functions where possible, like conditional jump on overflow
10811 after addition, conditional jump on carry etc.
10813 @end deftypefn
10815 @node x86 specific memory model extensions for transactional memory
10816 @section x86-Specific Memory Model Extensions for Transactional Memory
10818 The x86 architecture supports additional memory ordering flags
10819 to mark critical sections for hardware lock elision. 
10820 These must be specified in addition to an existing memory order to
10821 atomic intrinsics.
10823 @table @code
10824 @item __ATOMIC_HLE_ACQUIRE
10825 Start lock elision on a lock variable.
10826 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10827 @item __ATOMIC_HLE_RELEASE
10828 End lock elision on a lock variable.
10829 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10830 @end table
10832 When a lock acquire fails, it is required for good performance to abort
10833 the transaction quickly. This can be done with a @code{_mm_pause}.
10835 @smallexample
10836 #include <immintrin.h> // For _mm_pause
10838 int lockvar;
10840 /* Acquire lock with lock elision */
10841 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10842     _mm_pause(); /* Abort failed transaction */
10844 /* Free lock with lock elision */
10845 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10846 @end smallexample
10848 @node Object Size Checking
10849 @section Object Size Checking Built-in Functions
10850 @findex __builtin_object_size
10851 @findex __builtin___memcpy_chk
10852 @findex __builtin___mempcpy_chk
10853 @findex __builtin___memmove_chk
10854 @findex __builtin___memset_chk
10855 @findex __builtin___strcpy_chk
10856 @findex __builtin___stpcpy_chk
10857 @findex __builtin___strncpy_chk
10858 @findex __builtin___strcat_chk
10859 @findex __builtin___strncat_chk
10860 @findex __builtin___sprintf_chk
10861 @findex __builtin___snprintf_chk
10862 @findex __builtin___vsprintf_chk
10863 @findex __builtin___vsnprintf_chk
10864 @findex __builtin___printf_chk
10865 @findex __builtin___vprintf_chk
10866 @findex __builtin___fprintf_chk
10867 @findex __builtin___vfprintf_chk
10869 GCC implements a limited buffer overflow protection mechanism that can
10870 prevent some buffer overflow attacks by determining the sizes of objects
10871 into which data is about to be written and preventing the writes when
10872 the size isn't sufficient.  The built-in functions described below yield
10873 the best results when used together and when optimization is enabled.
10874 For example, to detect object sizes across function boundaries or to
10875 follow pointer assignments through non-trivial control flow they rely
10876 on various optimization passes enabled with @option{-O2}.  However, to
10877 a limited extent, they can be used without optimization as well.
10879 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10880 is a built-in construct that returns a constant number of bytes from
10881 @var{ptr} to the end of the object @var{ptr} pointer points to
10882 (if known at compile time).  @code{__builtin_object_size} never evaluates
10883 its arguments for side effects.  If there are any side effects in them, it
10884 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10885 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10886 point to and all of them are known at compile time, the returned number
10887 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10888 0 and minimum if nonzero.  If it is not possible to determine which objects
10889 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10890 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10891 for @var{type} 2 or 3.
10893 @var{type} is an integer constant from 0 to 3.  If the least significant
10894 bit is clear, objects are whole variables, if it is set, a closest
10895 surrounding subobject is considered the object a pointer points to.
10896 The second bit determines if maximum or minimum of remaining bytes
10897 is computed.
10899 @smallexample
10900 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10901 char *p = &var.buf1[1], *q = &var.b;
10903 /* Here the object p points to is var.  */
10904 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10905 /* The subobject p points to is var.buf1.  */
10906 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10907 /* The object q points to is var.  */
10908 assert (__builtin_object_size (q, 0)
10909         == (char *) (&var + 1) - (char *) &var.b);
10910 /* The subobject q points to is var.b.  */
10911 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10912 @end smallexample
10913 @end deftypefn
10915 There are built-in functions added for many common string operation
10916 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10917 built-in is provided.  This built-in has an additional last argument,
10918 which is the number of bytes remaining in the object the @var{dest}
10919 argument points to or @code{(size_t) -1} if the size is not known.
10921 The built-in functions are optimized into the normal string functions
10922 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10923 it is known at compile time that the destination object will not
10924 be overflowed.  If the compiler can determine at compile time that the
10925 object will always be overflowed, it issues a warning.
10927 The intended use can be e.g.@:
10929 @smallexample
10930 #undef memcpy
10931 #define bos0(dest) __builtin_object_size (dest, 0)
10932 #define memcpy(dest, src, n) \
10933   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10935 char *volatile p;
10936 char buf[10];
10937 /* It is unknown what object p points to, so this is optimized
10938    into plain memcpy - no checking is possible.  */
10939 memcpy (p, "abcde", n);
10940 /* Destination is known and length too.  It is known at compile
10941    time there will be no overflow.  */
10942 memcpy (&buf[5], "abcde", 5);
10943 /* Destination is known, but the length is not known at compile time.
10944    This will result in __memcpy_chk call that can check for overflow
10945    at run time.  */
10946 memcpy (&buf[5], "abcde", n);
10947 /* Destination is known and it is known at compile time there will
10948    be overflow.  There will be a warning and __memcpy_chk call that
10949    will abort the program at run time.  */
10950 memcpy (&buf[6], "abcde", 5);
10951 @end smallexample
10953 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10954 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10955 @code{strcat} and @code{strncat}.
10957 There are also checking built-in functions for formatted output functions.
10958 @smallexample
10959 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10960 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10961                               const char *fmt, ...);
10962 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10963                               va_list ap);
10964 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10965                                const char *fmt, va_list ap);
10966 @end smallexample
10968 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10969 etc.@: functions and can contain implementation specific flags on what
10970 additional security measures the checking function might take, such as
10971 handling @code{%n} differently.
10973 The @var{os} argument is the object size @var{s} points to, like in the
10974 other built-in functions.  There is a small difference in the behavior
10975 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10976 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10977 the checking function is called with @var{os} argument set to
10978 @code{(size_t) -1}.
10980 In addition to this, there are checking built-in functions
10981 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10982 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10983 These have just one additional argument, @var{flag}, right before
10984 format string @var{fmt}.  If the compiler is able to optimize them to
10985 @code{fputc} etc.@: functions, it does, otherwise the checking function
10986 is called and the @var{flag} argument passed to it.
10988 @node Other Builtins
10989 @section Other Built-in Functions Provided by GCC
10990 @cindex built-in functions
10991 @findex __builtin_alloca
10992 @findex __builtin_alloca_with_align
10993 @findex __builtin_alloca_with_align_and_max
10994 @findex __builtin_call_with_static_chain
10995 @findex __builtin_extend_pointer
10996 @findex __builtin_fpclassify
10997 @findex __builtin_isfinite
10998 @findex __builtin_isnormal
10999 @findex __builtin_isgreater
11000 @findex __builtin_isgreaterequal
11001 @findex __builtin_isinf_sign
11002 @findex __builtin_isless
11003 @findex __builtin_islessequal
11004 @findex __builtin_islessgreater
11005 @findex __builtin_isunordered
11006 @findex __builtin_powi
11007 @findex __builtin_powif
11008 @findex __builtin_powil
11009 @findex __builtin_speculation_safe_value
11010 @findex _Exit
11011 @findex _exit
11012 @findex abort
11013 @findex abs
11014 @findex acos
11015 @findex acosf
11016 @findex acosh
11017 @findex acoshf
11018 @findex acoshl
11019 @findex acosl
11020 @findex alloca
11021 @findex asin
11022 @findex asinf
11023 @findex asinh
11024 @findex asinhf
11025 @findex asinhl
11026 @findex asinl
11027 @findex atan
11028 @findex atan2
11029 @findex atan2f
11030 @findex atan2l
11031 @findex atanf
11032 @findex atanh
11033 @findex atanhf
11034 @findex atanhl
11035 @findex atanl
11036 @findex bcmp
11037 @findex bzero
11038 @findex cabs
11039 @findex cabsf
11040 @findex cabsl
11041 @findex cacos
11042 @findex cacosf
11043 @findex cacosh
11044 @findex cacoshf
11045 @findex cacoshl
11046 @findex cacosl
11047 @findex calloc
11048 @findex carg
11049 @findex cargf
11050 @findex cargl
11051 @findex casin
11052 @findex casinf
11053 @findex casinh
11054 @findex casinhf
11055 @findex casinhl
11056 @findex casinl
11057 @findex catan
11058 @findex catanf
11059 @findex catanh
11060 @findex catanhf
11061 @findex catanhl
11062 @findex catanl
11063 @findex cbrt
11064 @findex cbrtf
11065 @findex cbrtl
11066 @findex ccos
11067 @findex ccosf
11068 @findex ccosh
11069 @findex ccoshf
11070 @findex ccoshl
11071 @findex ccosl
11072 @findex ceil
11073 @findex ceilf
11074 @findex ceill
11075 @findex cexp
11076 @findex cexpf
11077 @findex cexpl
11078 @findex cimag
11079 @findex cimagf
11080 @findex cimagl
11081 @findex clog
11082 @findex clogf
11083 @findex clogl
11084 @findex clog10
11085 @findex clog10f
11086 @findex clog10l
11087 @findex conj
11088 @findex conjf
11089 @findex conjl
11090 @findex copysign
11091 @findex copysignf
11092 @findex copysignl
11093 @findex cos
11094 @findex cosf
11095 @findex cosh
11096 @findex coshf
11097 @findex coshl
11098 @findex cosl
11099 @findex cpow
11100 @findex cpowf
11101 @findex cpowl
11102 @findex cproj
11103 @findex cprojf
11104 @findex cprojl
11105 @findex creal
11106 @findex crealf
11107 @findex creall
11108 @findex csin
11109 @findex csinf
11110 @findex csinh
11111 @findex csinhf
11112 @findex csinhl
11113 @findex csinl
11114 @findex csqrt
11115 @findex csqrtf
11116 @findex csqrtl
11117 @findex ctan
11118 @findex ctanf
11119 @findex ctanh
11120 @findex ctanhf
11121 @findex ctanhl
11122 @findex ctanl
11123 @findex dcgettext
11124 @findex dgettext
11125 @findex drem
11126 @findex dremf
11127 @findex dreml
11128 @findex erf
11129 @findex erfc
11130 @findex erfcf
11131 @findex erfcl
11132 @findex erff
11133 @findex erfl
11134 @findex exit
11135 @findex exp
11136 @findex exp10
11137 @findex exp10f
11138 @findex exp10l
11139 @findex exp2
11140 @findex exp2f
11141 @findex exp2l
11142 @findex expf
11143 @findex expl
11144 @findex expm1
11145 @findex expm1f
11146 @findex expm1l
11147 @findex fabs
11148 @findex fabsf
11149 @findex fabsl
11150 @findex fdim
11151 @findex fdimf
11152 @findex fdiml
11153 @findex ffs
11154 @findex floor
11155 @findex floorf
11156 @findex floorl
11157 @findex fma
11158 @findex fmaf
11159 @findex fmal
11160 @findex fmax
11161 @findex fmaxf
11162 @findex fmaxl
11163 @findex fmin
11164 @findex fminf
11165 @findex fminl
11166 @findex fmod
11167 @findex fmodf
11168 @findex fmodl
11169 @findex fprintf
11170 @findex fprintf_unlocked
11171 @findex fputs
11172 @findex fputs_unlocked
11173 @findex frexp
11174 @findex frexpf
11175 @findex frexpl
11176 @findex fscanf
11177 @findex gamma
11178 @findex gammaf
11179 @findex gammal
11180 @findex gamma_r
11181 @findex gammaf_r
11182 @findex gammal_r
11183 @findex gettext
11184 @findex hypot
11185 @findex hypotf
11186 @findex hypotl
11187 @findex ilogb
11188 @findex ilogbf
11189 @findex ilogbl
11190 @findex imaxabs
11191 @findex index
11192 @findex isalnum
11193 @findex isalpha
11194 @findex isascii
11195 @findex isblank
11196 @findex iscntrl
11197 @findex isdigit
11198 @findex isgraph
11199 @findex islower
11200 @findex isprint
11201 @findex ispunct
11202 @findex isspace
11203 @findex isupper
11204 @findex iswalnum
11205 @findex iswalpha
11206 @findex iswblank
11207 @findex iswcntrl
11208 @findex iswdigit
11209 @findex iswgraph
11210 @findex iswlower
11211 @findex iswprint
11212 @findex iswpunct
11213 @findex iswspace
11214 @findex iswupper
11215 @findex iswxdigit
11216 @findex isxdigit
11217 @findex j0
11218 @findex j0f
11219 @findex j0l
11220 @findex j1
11221 @findex j1f
11222 @findex j1l
11223 @findex jn
11224 @findex jnf
11225 @findex jnl
11226 @findex labs
11227 @findex ldexp
11228 @findex ldexpf
11229 @findex ldexpl
11230 @findex lgamma
11231 @findex lgammaf
11232 @findex lgammal
11233 @findex lgamma_r
11234 @findex lgammaf_r
11235 @findex lgammal_r
11236 @findex llabs
11237 @findex llrint
11238 @findex llrintf
11239 @findex llrintl
11240 @findex llround
11241 @findex llroundf
11242 @findex llroundl
11243 @findex log
11244 @findex log10
11245 @findex log10f
11246 @findex log10l
11247 @findex log1p
11248 @findex log1pf
11249 @findex log1pl
11250 @findex log2
11251 @findex log2f
11252 @findex log2l
11253 @findex logb
11254 @findex logbf
11255 @findex logbl
11256 @findex logf
11257 @findex logl
11258 @findex lrint
11259 @findex lrintf
11260 @findex lrintl
11261 @findex lround
11262 @findex lroundf
11263 @findex lroundl
11264 @findex malloc
11265 @findex memchr
11266 @findex memcmp
11267 @findex memcpy
11268 @findex mempcpy
11269 @findex memset
11270 @findex modf
11271 @findex modff
11272 @findex modfl
11273 @findex nearbyint
11274 @findex nearbyintf
11275 @findex nearbyintl
11276 @findex nextafter
11277 @findex nextafterf
11278 @findex nextafterl
11279 @findex nexttoward
11280 @findex nexttowardf
11281 @findex nexttowardl
11282 @findex pow
11283 @findex pow10
11284 @findex pow10f
11285 @findex pow10l
11286 @findex powf
11287 @findex powl
11288 @findex printf
11289 @findex printf_unlocked
11290 @findex putchar
11291 @findex puts
11292 @findex remainder
11293 @findex remainderf
11294 @findex remainderl
11295 @findex remquo
11296 @findex remquof
11297 @findex remquol
11298 @findex rindex
11299 @findex rint
11300 @findex rintf
11301 @findex rintl
11302 @findex round
11303 @findex roundf
11304 @findex roundl
11305 @findex scalb
11306 @findex scalbf
11307 @findex scalbl
11308 @findex scalbln
11309 @findex scalblnf
11310 @findex scalblnf
11311 @findex scalbn
11312 @findex scalbnf
11313 @findex scanfnl
11314 @findex signbit
11315 @findex signbitf
11316 @findex signbitl
11317 @findex signbitd32
11318 @findex signbitd64
11319 @findex signbitd128
11320 @findex significand
11321 @findex significandf
11322 @findex significandl
11323 @findex sin
11324 @findex sincos
11325 @findex sincosf
11326 @findex sincosl
11327 @findex sinf
11328 @findex sinh
11329 @findex sinhf
11330 @findex sinhl
11331 @findex sinl
11332 @findex snprintf
11333 @findex sprintf
11334 @findex sqrt
11335 @findex sqrtf
11336 @findex sqrtl
11337 @findex sscanf
11338 @findex stpcpy
11339 @findex stpncpy
11340 @findex strcasecmp
11341 @findex strcat
11342 @findex strchr
11343 @findex strcmp
11344 @findex strcpy
11345 @findex strcspn
11346 @findex strdup
11347 @findex strfmon
11348 @findex strftime
11349 @findex strlen
11350 @findex strncasecmp
11351 @findex strncat
11352 @findex strncmp
11353 @findex strncpy
11354 @findex strndup
11355 @findex strnlen
11356 @findex strpbrk
11357 @findex strrchr
11358 @findex strspn
11359 @findex strstr
11360 @findex tan
11361 @findex tanf
11362 @findex tanh
11363 @findex tanhf
11364 @findex tanhl
11365 @findex tanl
11366 @findex tgamma
11367 @findex tgammaf
11368 @findex tgammal
11369 @findex toascii
11370 @findex tolower
11371 @findex toupper
11372 @findex towlower
11373 @findex towupper
11374 @findex trunc
11375 @findex truncf
11376 @findex truncl
11377 @findex vfprintf
11378 @findex vfscanf
11379 @findex vprintf
11380 @findex vscanf
11381 @findex vsnprintf
11382 @findex vsprintf
11383 @findex vsscanf
11384 @findex y0
11385 @findex y0f
11386 @findex y0l
11387 @findex y1
11388 @findex y1f
11389 @findex y1l
11390 @findex yn
11391 @findex ynf
11392 @findex ynl
11394 GCC provides a large number of built-in functions other than the ones
11395 mentioned above.  Some of these are for internal use in the processing
11396 of exceptions or variable-length argument lists and are not
11397 documented here because they may change from time to time; we do not
11398 recommend general use of these functions.
11400 The remaining functions are provided for optimization purposes.
11402 With the exception of built-ins that have library equivalents such as
11403 the standard C library functions discussed below, or that expand to
11404 library calls, GCC built-in functions are always expanded inline and
11405 thus do not have corresponding entry points and their address cannot
11406 be obtained.  Attempting to use them in an expression other than
11407 a function call results in a compile-time error.
11409 @opindex fno-builtin
11410 GCC includes built-in versions of many of the functions in the standard
11411 C library.  These functions come in two forms: one whose names start with
11412 the @code{__builtin_} prefix, and the other without.  Both forms have the
11413 same type (including prototype), the same address (when their address is
11414 taken), and the same meaning as the C library functions even if you specify
11415 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11416 functions are only optimized in certain cases; if they are not optimized in
11417 a particular case, a call to the library function is emitted.
11419 @opindex ansi
11420 @opindex std
11421 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11422 @option{-std=c99} or @option{-std=c11}), the functions
11423 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11424 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11425 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11426 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11427 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11428 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11429 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11430 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11431 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11432 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11433 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11434 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11435 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11436 @code{significandl}, @code{significand}, @code{sincosf},
11437 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11438 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11439 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
11440 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11441 @code{yn}
11442 may be handled as built-in functions.
11443 All these functions have corresponding versions
11444 prefixed with @code{__builtin_}, which may be used even in strict C90
11445 mode.
11447 The ISO C99 functions
11448 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11449 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11450 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11451 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11452 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11453 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11454 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11455 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11456 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11457 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11458 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11459 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11460 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11461 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11462 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11463 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11464 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11465 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11466 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11467 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11468 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11469 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11470 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11471 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11472 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11473 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11474 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11475 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11476 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11477 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11478 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11479 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11480 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11481 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11482 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11483 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11484 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11485 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11486 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11487 are handled as built-in functions
11488 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11490 There are also built-in versions of the ISO C99 functions
11491 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11492 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11493 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11494 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11495 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11496 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11497 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11498 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11499 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11500 that are recognized in any mode since ISO C90 reserves these names for
11501 the purpose to which ISO C99 puts them.  All these functions have
11502 corresponding versions prefixed with @code{__builtin_}.
11504 There are also built-in functions @code{__builtin_fabsf@var{n}},
11505 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11506 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11507 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11508 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11509 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11511 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11512 @code{clog10l} which names are reserved by ISO C99 for future use.
11513 All these functions have versions prefixed with @code{__builtin_}.
11515 The ISO C94 functions
11516 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11517 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11518 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11519 @code{towupper}
11520 are handled as built-in functions
11521 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11523 The ISO C90 functions
11524 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11525 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11526 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11527 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11528 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11529 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11530 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11531 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11532 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11533 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11534 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11535 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11536 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11537 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11538 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11539 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11540 are all recognized as built-in functions unless
11541 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11542 is specified for an individual function).  All of these functions have
11543 corresponding versions prefixed with @code{__builtin_}.
11545 GCC provides built-in versions of the ISO C99 floating-point comparison
11546 macros that avoid raising exceptions for unordered operands.  They have
11547 the same names as the standard macros ( @code{isgreater},
11548 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11549 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11550 prefixed.  We intend for a library implementor to be able to simply
11551 @code{#define} each standard macro to its built-in equivalent.
11552 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11553 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11554 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11555 built-in functions appear both with and without the @code{__builtin_} prefix.
11557 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11558 The @code{__builtin_alloca} function must be called at block scope.
11559 The function allocates an object @var{size} bytes large on the stack
11560 of the calling function.  The object is aligned on the default stack
11561 alignment boundary for the target determined by the
11562 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11563 function returns a pointer to the first byte of the allocated object.
11564 The lifetime of the allocated object ends just before the calling
11565 function returns to its caller.   This is so even when
11566 @code{__builtin_alloca} is called within a nested block.
11568 For example, the following function allocates eight objects of @code{n}
11569 bytes each on the stack, storing a pointer to each in consecutive elements
11570 of the array @code{a}.  It then passes the array to function @code{g}
11571 which can safely use the storage pointed to by each of the array elements.
11573 @smallexample
11574 void f (unsigned n)
11576   void *a [8];
11577   for (int i = 0; i != 8; ++i)
11578     a [i] = __builtin_alloca (n);
11580   g (a, n);   // @r{safe}
11582 @end smallexample
11584 Since the @code{__builtin_alloca} function doesn't validate its argument
11585 it is the responsibility of its caller to make sure the argument doesn't
11586 cause it to exceed the stack size limit.
11587 The @code{__builtin_alloca} function is provided to make it possible to
11588 allocate on the stack arrays of bytes with an upper bound that may be
11589 computed at run time.  Since C99 Variable Length Arrays offer
11590 similar functionality under a portable, more convenient, and safer
11591 interface they are recommended instead, in both C99 and C++ programs
11592 where GCC provides them as an extension.
11593 @xref{Variable Length}, for details.
11595 @end deftypefn
11597 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11598 The @code{__builtin_alloca_with_align} function must be called at block
11599 scope.  The function allocates an object @var{size} bytes large on
11600 the stack of the calling function.  The allocated object is aligned on
11601 the boundary specified by the argument @var{alignment} whose unit is given
11602 in bits (not bytes).  The @var{size} argument must be positive and not
11603 exceed the stack size limit.  The @var{alignment} argument must be a constant
11604 integer expression that evaluates to a power of 2 greater than or equal to
11605 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11606 with other values are rejected with an error indicating the valid bounds.
11607 The function returns a pointer to the first byte of the allocated object.
11608 The lifetime of the allocated object ends at the end of the block in which
11609 the function was called.  The allocated storage is released no later than
11610 just before the calling function returns to its caller, but may be released
11611 at the end of the block in which the function was called.
11613 For example, in the following function the call to @code{g} is unsafe
11614 because when @code{overalign} is non-zero, the space allocated by
11615 @code{__builtin_alloca_with_align} may have been released at the end
11616 of the @code{if} statement in which it was called.
11618 @smallexample
11619 void f (unsigned n, bool overalign)
11621   void *p;
11622   if (overalign)
11623     p = __builtin_alloca_with_align (n, 64 /* bits */);
11624   else
11625     p = __builtin_alloc (n);
11627   g (p, n);   // @r{unsafe}
11629 @end smallexample
11631 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11632 @var{size} argument it is the responsibility of its caller to make sure
11633 the argument doesn't cause it to exceed the stack size limit.
11634 The @code{__builtin_alloca_with_align} function is provided to make
11635 it possible to allocate on the stack overaligned arrays of bytes with
11636 an upper bound that may be computed at run time.  Since C99
11637 Variable Length Arrays offer the same functionality under
11638 a portable, more convenient, and safer interface they are recommended
11639 instead, in both C99 and C++ programs where GCC provides them as
11640 an extension.  @xref{Variable Length}, for details.
11642 @end deftypefn
11644 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11645 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11646 specifying an upper bound for @var{size} in case its value cannot be computed
11647 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11648 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11649 expression, it has no effect on code generation and no attempt is made to
11650 check its compatibility with @var{size}.
11652 @end deftypefn
11654 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
11656 This built-in function can be used to help mitigate against unsafe
11657 speculative execution.  @var{type} may be any integral type or any
11658 pointer type.
11660 @enumerate
11661 @item
11662 If the CPU is not speculatively executing the code, then @var{val}
11663 is returned.
11664 @item
11665 If the CPU is executing speculatively then either:
11666 @itemize
11667 @item
11668 The function may cause execution to pause until it is known that the
11669 code is no-longer being executed speculatively (in which case
11670 @var{val} can be returned, as above); or
11671 @item
11672 The function may use target-dependent speculation tracking state to cause
11673 @var{failval} to be returned when it is known that speculative
11674 execution has incorrectly predicted a conditional branch operation.
11675 @end itemize
11676 @end enumerate
11678 The second argument, @var{failval}, is optional and defaults to zero
11679 if omitted.
11681 GCC defines the preprocessor macro
11682 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
11683 updated to support this builtin.
11685 The built-in function can be used where a variable appears to be used in a
11686 safe way, but the CPU, due to speculative execution may temporarily ignore
11687 the bounds checks.  Consider, for example, the following function:
11689 @smallexample
11690 int array[500];
11691 int f (unsigned untrusted_index)
11693   if (untrusted_index < 500)
11694     return array[untrusted_index];
11695   return 0;
11697 @end smallexample
11699 If the function is called repeatedly with @code{untrusted_index} less
11700 than the limit of 500, then a branch predictor will learn that the
11701 block of code that returns a value stored in @code{array} will be
11702 executed.  If the function is subsequently called with an
11703 out-of-range value it will still try to execute that block of code
11704 first until the CPU determines that the prediction was incorrect
11705 (the CPU will unwind any incorrect operations at that point).
11706 However, depending on how the result of the function is used, it might be
11707 possible to leave traces in the cache that can reveal what was stored
11708 at the out-of-bounds location.  The built-in function can be used to
11709 provide some protection against leaking data in this way by changing
11710 the code to:
11712 @smallexample
11713 int array[500];
11714 int f (unsigned untrusted_index)
11716   if (untrusted_index < 500)
11717     return array[__builtin_speculation_safe_value (untrusted_index)];
11718   return 0;
11720 @end smallexample
11722 The built-in function will either cause execution to stall until the
11723 conditional branch has been fully resolved, or it may permit
11724 speculative execution to continue, but using 0 instead of
11725 @code{untrusted_value} if that exceeds the limit.
11727 If accessing any memory location is potentially unsafe when speculative
11728 execution is incorrect, then the code can be rewritten as
11730 @smallexample
11731 int array[500];
11732 int f (unsigned untrusted_index)
11734   if (untrusted_index < 500)
11735     return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
11736   return 0;
11738 @end smallexample
11740 which will cause a @code{NULL} pointer to be used for the unsafe case.
11742 @end deftypefn
11744 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11746 You can use the built-in function @code{__builtin_types_compatible_p} to
11747 determine whether two types are the same.
11749 This built-in function returns 1 if the unqualified versions of the
11750 types @var{type1} and @var{type2} (which are types, not expressions) are
11751 compatible, 0 otherwise.  The result of this built-in function can be
11752 used in integer constant expressions.
11754 This built-in function ignores top level qualifiers (e.g., @code{const},
11755 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11756 int}.
11758 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11759 hand, @code{int} and @code{char *} are not compatible, even if the size
11760 of their types, on the particular architecture are the same.  Also, the
11761 amount of pointer indirection is taken into account when determining
11762 similarity.  Consequently, @code{short *} is not similar to
11763 @code{short **}.  Furthermore, two types that are typedefed are
11764 considered compatible if their underlying types are compatible.
11766 An @code{enum} type is not considered to be compatible with another
11767 @code{enum} type even if both are compatible with the same integer
11768 type; this is what the C standard specifies.
11769 For example, @code{enum @{foo, bar@}} is not similar to
11770 @code{enum @{hot, dog@}}.
11772 You typically use this function in code whose execution varies
11773 depending on the arguments' types.  For example:
11775 @smallexample
11776 #define foo(x)                                                  \
11777   (@{                                                           \
11778     typeof (x) tmp = (x);                                       \
11779     if (__builtin_types_compatible_p (typeof (x), long double)) \
11780       tmp = foo_long_double (tmp);                              \
11781     else if (__builtin_types_compatible_p (typeof (x), double)) \
11782       tmp = foo_double (tmp);                                   \
11783     else if (__builtin_types_compatible_p (typeof (x), float))  \
11784       tmp = foo_float (tmp);                                    \
11785     else                                                        \
11786       abort ();                                                 \
11787     tmp;                                                        \
11788   @})
11789 @end smallexample
11791 @emph{Note:} This construct is only available for C@.
11793 @end deftypefn
11795 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11797 The @var{call_exp} expression must be a function call, and the
11798 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11799 is passed to the function call in the target's static chain location.
11800 The result of builtin is the result of the function call.
11802 @emph{Note:} This builtin is only available for C@.
11803 This builtin can be used to call Go closures from C.
11805 @end deftypefn
11807 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11809 You can use the built-in function @code{__builtin_choose_expr} to
11810 evaluate code depending on the value of a constant expression.  This
11811 built-in function returns @var{exp1} if @var{const_exp}, which is an
11812 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11814 This built-in function is analogous to the @samp{? :} operator in C,
11815 except that the expression returned has its type unaltered by promotion
11816 rules.  Also, the built-in function does not evaluate the expression
11817 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11818 @var{exp2} is not evaluated even if it has side effects.
11820 This built-in function can return an lvalue if the chosen argument is an
11821 lvalue.
11823 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11824 type.  Similarly, if @var{exp2} is returned, its return type is the same
11825 as @var{exp2}.
11827 Example:
11829 @smallexample
11830 #define foo(x)                                                    \
11831   __builtin_choose_expr (                                         \
11832     __builtin_types_compatible_p (typeof (x), double),            \
11833     foo_double (x),                                               \
11834     __builtin_choose_expr (                                       \
11835       __builtin_types_compatible_p (typeof (x), float),           \
11836       foo_float (x),                                              \
11837       /* @r{The void expression results in a compile-time error}  \
11838          @r{when assigning the result to something.}  */          \
11839       (void)0))
11840 @end smallexample
11842 @emph{Note:} This construct is only available for C@.  Furthermore, the
11843 unused expression (@var{exp1} or @var{exp2} depending on the value of
11844 @var{const_exp}) may still generate syntax errors.  This may change in
11845 future revisions.
11847 @end deftypefn
11849 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11851 The built-in function @code{__builtin_tgmath}, available only for C
11852 and Objective-C, calls a function determined according to the rules of
11853 @code{<tgmath.h>} macros.  It is intended to be used in
11854 implementations of that header, so that expansions of macros from that
11855 header only expand each of their arguments once, to avoid problems
11856 when calls to such macros are nested inside the arguments of other
11857 calls to such macros; in addition, it results in better diagnostics
11858 for invalid calls to @code{<tgmath.h>} macros than implementations
11859 using other GNU C language features.  For example, the @code{pow}
11860 type-generic macro might be defined as:
11862 @smallexample
11863 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11864                                     cpowf, cpow, cpowl, a, b)
11865 @end smallexample
11867 The arguments to @code{__builtin_tgmath} are at least two pointers to
11868 functions, followed by the arguments to the type-generic macro (which
11869 will be passed as arguments to the selected function).  All the
11870 pointers to functions must be pointers to prototyped functions, none
11871 of which may have variable arguments, and all of which must have the
11872 same number of parameters; the number of parameters of the first
11873 function determines how many arguments to @code{__builtin_tgmath} are
11874 interpreted as function pointers, and how many as the arguments to the
11875 called function.
11877 The types of the specified functions must all be different, but
11878 related to each other in the same way as a set of functions that may
11879 be selected between by a macro in @code{<tgmath.h>}.  This means that
11880 the functions are parameterized by a floating-point type @var{t},
11881 different for each such function.  The function return types may all
11882 be the same type, or they may be @var{t} for each function, or they
11883 may be the real type corresponding to @var{t} for each function (if
11884 some of the types @var{t} are complex).  Likewise, for each parameter
11885 position, the type of the parameter in that position may always be the
11886 same type, or may be @var{t} for each function (this case must apply
11887 for at least one parameter position), or may be the real type
11888 corresponding to @var{t} for each function.
11890 The standard rules for @code{<tgmath.h>} macros are used to find a
11891 common type @var{u} from the types of the arguments for parameters
11892 whose types vary between the functions; complex integer types (a GNU
11893 extension) are treated like @code{_Complex double} for this purpose
11894 (or @code{_Complex _Float64} if all the function return types are the
11895 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
11896 If the function return types vary, or are all the same integer type,
11897 the function called is the one for which @var{t} is @var{u}, and it is
11898 an error if there is no such function.  If the function return types
11899 are all the same floating-point type, the type-generic macro is taken
11900 to be one of those from TS 18661 that rounds the result to a narrower
11901 type; if there is a function for which @var{t} is @var{u}, it is
11902 called, and otherwise the first function, if any, for which @var{t}
11903 has at least the range and precision of @var{u} is called, and it is
11904 an error if there is no such function.
11906 @end deftypefn
11908 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11910 The built-in function @code{__builtin_complex} is provided for use in
11911 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11912 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11913 real binary floating-point type, and the result has the corresponding
11914 complex type with real and imaginary parts @var{real} and @var{imag}.
11915 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11916 infinities, NaNs and negative zeros are involved.
11918 @end deftypefn
11920 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11921 You can use the built-in function @code{__builtin_constant_p} to
11922 determine if a value is known to be constant at compile time and hence
11923 that GCC can perform constant-folding on expressions involving that
11924 value.  The argument of the function is the value to test.  The function
11925 returns the integer 1 if the argument is known to be a compile-time
11926 constant and 0 if it is not known to be a compile-time constant.  A
11927 return of 0 does not indicate that the value is @emph{not} a constant,
11928 but merely that GCC cannot prove it is a constant with the specified
11929 value of the @option{-O} option.
11931 You typically use this function in an embedded application where
11932 memory is a critical resource.  If you have some complex calculation,
11933 you may want it to be folded if it involves constants, but need to call
11934 a function if it does not.  For example:
11936 @smallexample
11937 #define Scale_Value(X)      \
11938   (__builtin_constant_p (X) \
11939   ? ((X) * SCALE + OFFSET) : Scale (X))
11940 @end smallexample
11942 You may use this built-in function in either a macro or an inline
11943 function.  However, if you use it in an inlined function and pass an
11944 argument of the function as the argument to the built-in, GCC 
11945 never returns 1 when you call the inline function with a string constant
11946 or compound literal (@pxref{Compound Literals}) and does not return 1
11947 when you pass a constant numeric value to the inline function unless you
11948 specify the @option{-O} option.
11950 You may also use @code{__builtin_constant_p} in initializers for static
11951 data.  For instance, you can write
11953 @smallexample
11954 static const int table[] = @{
11955    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11956    /* @r{@dots{}} */
11958 @end smallexample
11960 @noindent
11961 This is an acceptable initializer even if @var{EXPRESSION} is not a
11962 constant expression, including the case where
11963 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11964 folded to a constant but @var{EXPRESSION} contains operands that are
11965 not otherwise permitted in a static initializer (for example,
11966 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11967 built-in in this case, because it has no opportunity to perform
11968 optimization.
11969 @end deftypefn
11971 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11972 @opindex fprofile-arcs
11973 You may use @code{__builtin_expect} to provide the compiler with
11974 branch prediction information.  In general, you should prefer to
11975 use actual profile feedback for this (@option{-fprofile-arcs}), as
11976 programmers are notoriously bad at predicting how their programs
11977 actually perform.  However, there are applications in which this
11978 data is hard to collect.
11980 The return value is the value of @var{exp}, which should be an integral
11981 expression.  The semantics of the built-in are that it is expected that
11982 @var{exp} == @var{c}.  For example:
11984 @smallexample
11985 if (__builtin_expect (x, 0))
11986   foo ();
11987 @end smallexample
11989 @noindent
11990 indicates that we do not expect to call @code{foo}, since
11991 we expect @code{x} to be zero.  Since you are limited to integral
11992 expressions for @var{exp}, you should use constructions such as
11994 @smallexample
11995 if (__builtin_expect (ptr != NULL, 1))
11996   foo (*ptr);
11997 @end smallexample
11999 @noindent
12000 when testing pointer or floating-point values.
12001 @end deftypefn
12003 @deftypefn {Built-in Function} long __builtin_expect_with_probability
12004 (long @var{exp}, long @var{c}, long @var{probability})
12006 The built-in has same semantics as @code{__builtin_expect_with_probability},
12007 but user can provide expected probability (in percent) for value of @var{exp}.
12008 Last argument @var{probability} is of float type and valid values
12009 are in inclusive range 0.0f and 1.0f.
12010 @end deftypefn
12012 @deftypefn {Built-in Function} void __builtin_trap (void)
12013 This function causes the program to exit abnormally.  GCC implements
12014 this function by using a target-dependent mechanism (such as
12015 intentionally executing an illegal instruction) or by calling
12016 @code{abort}.  The mechanism used may vary from release to release so
12017 you should not rely on any particular implementation.
12018 @end deftypefn
12020 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12021 If control flow reaches the point of the @code{__builtin_unreachable},
12022 the program is undefined.  It is useful in situations where the
12023 compiler cannot deduce the unreachability of the code.
12025 One such case is immediately following an @code{asm} statement that
12026 either never terminates, or one that transfers control elsewhere
12027 and never returns.  In this example, without the
12028 @code{__builtin_unreachable}, GCC issues a warning that control
12029 reaches the end of a non-void function.  It also generates code
12030 to return after the @code{asm}.
12032 @smallexample
12033 int f (int c, int v)
12035   if (c)
12036     @{
12037       return v;
12038     @}
12039   else
12040     @{
12041       asm("jmp error_handler");
12042       __builtin_unreachable ();
12043     @}
12045 @end smallexample
12047 @noindent
12048 Because the @code{asm} statement unconditionally transfers control out
12049 of the function, control never reaches the end of the function
12050 body.  The @code{__builtin_unreachable} is in fact unreachable and
12051 communicates this fact to the compiler.
12053 Another use for @code{__builtin_unreachable} is following a call a
12054 function that never returns but that is not declared
12055 @code{__attribute__((noreturn))}, as in this example:
12057 @smallexample
12058 void function_that_never_returns (void);
12060 int g (int c)
12062   if (c)
12063     @{
12064       return 1;
12065     @}
12066   else
12067     @{
12068       function_that_never_returns ();
12069       __builtin_unreachable ();
12070     @}
12072 @end smallexample
12074 @end deftypefn
12076 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12077 This function returns its first argument, and allows the compiler
12078 to assume that the returned pointer is at least @var{align} bytes
12079 aligned.  This built-in can have either two or three arguments,
12080 if it has three, the third argument should have integer type, and
12081 if it is nonzero means misalignment offset.  For example:
12083 @smallexample
12084 void *x = __builtin_assume_aligned (arg, 16);
12085 @end smallexample
12087 @noindent
12088 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12089 16-byte aligned, while:
12091 @smallexample
12092 void *x = __builtin_assume_aligned (arg, 32, 8);
12093 @end smallexample
12095 @noindent
12096 means that the compiler can assume for @code{x}, set to @code{arg}, that
12097 @code{(char *) x - 8} is 32-byte aligned.
12098 @end deftypefn
12100 @deftypefn {Built-in Function} int __builtin_LINE ()
12101 This function is the equivalent of the preprocessor @code{__LINE__}
12102 macro and returns a constant integer expression that evaluates to
12103 the line number of the invocation of the built-in.  When used as a C++
12104 default argument for a function @var{F}, it returns the line number
12105 of the call to @var{F}.
12106 @end deftypefn
12108 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12109 This function is the equivalent of the @code{__FUNCTION__} symbol
12110 and returns an address constant pointing to the name of the function
12111 from which the built-in was invoked, or the empty string if
12112 the invocation is not at function scope.  When used as a C++ default
12113 argument for a function @var{F}, it returns the name of @var{F}'s
12114 caller or the empty string if the call was not made at function
12115 scope.
12116 @end deftypefn
12118 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12119 This function is the equivalent of the preprocessor @code{__FILE__}
12120 macro and returns an address constant pointing to the file name
12121 containing the invocation of the built-in, or the empty string if
12122 the invocation is not at function scope.  When used as a C++ default
12123 argument for a function @var{F}, it returns the file name of the call
12124 to @var{F} or the empty string if the call was not made at function
12125 scope.
12127 For example, in the following, each call to function @code{foo} will
12128 print a line similar to @code{"file.c:123: foo: message"} with the name
12129 of the file and the line number of the @code{printf} call, the name of
12130 the function @code{foo}, followed by the word @code{message}.
12132 @smallexample
12133 const char*
12134 function (const char *func = __builtin_FUNCTION ())
12136   return func;
12139 void foo (void)
12141   printf ("%s:%i: %s: message\n", file (), line (), function ());
12143 @end smallexample
12145 @end deftypefn
12147 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12148 This function is used to flush the processor's instruction cache for
12149 the region of memory between @var{begin} inclusive and @var{end}
12150 exclusive.  Some targets require that the instruction cache be
12151 flushed, after modifying memory containing code, in order to obtain
12152 deterministic behavior.
12154 If the target does not require instruction cache flushes,
12155 @code{__builtin___clear_cache} has no effect.  Otherwise either
12156 instructions are emitted in-line to clear the instruction cache or a
12157 call to the @code{__clear_cache} function in libgcc is made.
12158 @end deftypefn
12160 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12161 This function is used to minimize cache-miss latency by moving data into
12162 a cache before it is accessed.
12163 You can insert calls to @code{__builtin_prefetch} into code for which
12164 you know addresses of data in memory that is likely to be accessed soon.
12165 If the target supports them, data prefetch instructions are generated.
12166 If the prefetch is done early enough before the access then the data will
12167 be in the cache by the time it is accessed.
12169 The value of @var{addr} is the address of the memory to prefetch.
12170 There are two optional arguments, @var{rw} and @var{locality}.
12171 The value of @var{rw} is a compile-time constant one or zero; one
12172 means that the prefetch is preparing for a write to the memory address
12173 and zero, the default, means that the prefetch is preparing for a read.
12174 The value @var{locality} must be a compile-time constant integer between
12175 zero and three.  A value of zero means that the data has no temporal
12176 locality, so it need not be left in the cache after the access.  A value
12177 of three means that the data has a high degree of temporal locality and
12178 should be left in all levels of cache possible.  Values of one and two
12179 mean, respectively, a low or moderate degree of temporal locality.  The
12180 default is three.
12182 @smallexample
12183 for (i = 0; i < n; i++)
12184   @{
12185     a[i] = a[i] + b[i];
12186     __builtin_prefetch (&a[i+j], 1, 1);
12187     __builtin_prefetch (&b[i+j], 0, 1);
12188     /* @r{@dots{}} */
12189   @}
12190 @end smallexample
12192 Data prefetch does not generate faults if @var{addr} is invalid, but
12193 the address expression itself must be valid.  For example, a prefetch
12194 of @code{p->next} does not fault if @code{p->next} is not a valid
12195 address, but evaluation faults if @code{p} is not a valid address.
12197 If the target does not support data prefetch, the address expression
12198 is evaluated if it includes side effects but no other code is generated
12199 and GCC does not issue a warning.
12200 @end deftypefn
12202 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12203 Returns a positive infinity, if supported by the floating-point format,
12204 else @code{DBL_MAX}.  This function is suitable for implementing the
12205 ISO C macro @code{HUGE_VAL}.
12206 @end deftypefn
12208 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12209 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12210 @end deftypefn
12212 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12213 Similar to @code{__builtin_huge_val}, except the return
12214 type is @code{long double}.
12215 @end deftypefn
12217 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12218 Similar to @code{__builtin_huge_val}, except the return type is
12219 @code{_Float@var{n}}.
12220 @end deftypefn
12222 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12223 Similar to @code{__builtin_huge_val}, except the return type is
12224 @code{_Float@var{n}x}.
12225 @end deftypefn
12227 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12228 This built-in implements the C99 fpclassify functionality.  The first
12229 five int arguments should be the target library's notion of the
12230 possible FP classes and are used for return values.  They must be
12231 constant values and they must appear in this order: @code{FP_NAN},
12232 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12233 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
12234 to classify.  GCC treats the last argument as type-generic, which
12235 means it does not do default promotion from float to double.
12236 @end deftypefn
12238 @deftypefn {Built-in Function} double __builtin_inf (void)
12239 Similar to @code{__builtin_huge_val}, except a warning is generated
12240 if the target floating-point format does not support infinities.
12241 @end deftypefn
12243 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12244 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12245 @end deftypefn
12247 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12248 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12249 @end deftypefn
12251 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12252 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12253 @end deftypefn
12255 @deftypefn {Built-in Function} float __builtin_inff (void)
12256 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12257 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12258 @end deftypefn
12260 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12261 Similar to @code{__builtin_inf}, except the return
12262 type is @code{long double}.
12263 @end deftypefn
12265 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12266 Similar to @code{__builtin_inf}, except the return
12267 type is @code{_Float@var{n}}.
12268 @end deftypefn
12270 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12271 Similar to @code{__builtin_inf}, except the return
12272 type is @code{_Float@var{n}x}.
12273 @end deftypefn
12275 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12276 Similar to @code{isinf}, except the return value is -1 for
12277 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12278 Note while the parameter list is an
12279 ellipsis, this function only accepts exactly one floating-point
12280 argument.  GCC treats this parameter as type-generic, which means it
12281 does not do default promotion from float to double.
12282 @end deftypefn
12284 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12285 This is an implementation of the ISO C99 function @code{nan}.
12287 Since ISO C99 defines this function in terms of @code{strtod}, which we
12288 do not implement, a description of the parsing is in order.  The string
12289 is parsed as by @code{strtol}; that is, the base is recognized by
12290 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12291 in the significand such that the least significant bit of the number
12292 is at the least significant bit of the significand.  The number is
12293 truncated to fit the significand field provided.  The significand is
12294 forced to be a quiet NaN@.
12296 This function, if given a string literal all of which would have been
12297 consumed by @code{strtol}, is evaluated early enough that it is considered a
12298 compile-time constant.
12299 @end deftypefn
12301 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12302 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12303 @end deftypefn
12305 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12306 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12307 @end deftypefn
12309 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12310 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12311 @end deftypefn
12313 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12314 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12315 @end deftypefn
12317 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12318 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12319 @end deftypefn
12321 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12322 Similar to @code{__builtin_nan}, except the return type is
12323 @code{_Float@var{n}}.
12324 @end deftypefn
12326 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12327 Similar to @code{__builtin_nan}, except the return type is
12328 @code{_Float@var{n}x}.
12329 @end deftypefn
12331 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12332 Similar to @code{__builtin_nan}, except the significand is forced
12333 to be a signaling NaN@.  The @code{nans} function is proposed by
12334 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12335 @end deftypefn
12337 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12338 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12339 @end deftypefn
12341 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12342 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12343 @end deftypefn
12345 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12346 Similar to @code{__builtin_nans}, except the return type is
12347 @code{_Float@var{n}}.
12348 @end deftypefn
12350 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12351 Similar to @code{__builtin_nans}, except the return type is
12352 @code{_Float@var{n}x}.
12353 @end deftypefn
12355 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12356 Returns one plus the index of the least significant 1-bit of @var{x}, or
12357 if @var{x} is zero, returns zero.
12358 @end deftypefn
12360 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12361 Returns the number of leading 0-bits in @var{x}, starting at the most
12362 significant bit position.  If @var{x} is 0, the result is undefined.
12363 @end deftypefn
12365 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12366 Returns the number of trailing 0-bits in @var{x}, starting at the least
12367 significant bit position.  If @var{x} is 0, the result is undefined.
12368 @end deftypefn
12370 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12371 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12372 number of bits following the most significant bit that are identical
12373 to it.  There are no special cases for 0 or other values. 
12374 @end deftypefn
12376 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12377 Returns the number of 1-bits in @var{x}.
12378 @end deftypefn
12380 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12381 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12382 modulo 2.
12383 @end deftypefn
12385 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12386 Similar to @code{__builtin_ffs}, except the argument type is
12387 @code{long}.
12388 @end deftypefn
12390 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12391 Similar to @code{__builtin_clz}, except the argument type is
12392 @code{unsigned long}.
12393 @end deftypefn
12395 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12396 Similar to @code{__builtin_ctz}, except the argument type is
12397 @code{unsigned long}.
12398 @end deftypefn
12400 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12401 Similar to @code{__builtin_clrsb}, except the argument type is
12402 @code{long}.
12403 @end deftypefn
12405 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12406 Similar to @code{__builtin_popcount}, except the argument type is
12407 @code{unsigned long}.
12408 @end deftypefn
12410 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12411 Similar to @code{__builtin_parity}, except the argument type is
12412 @code{unsigned long}.
12413 @end deftypefn
12415 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12416 Similar to @code{__builtin_ffs}, except the argument type is
12417 @code{long long}.
12418 @end deftypefn
12420 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12421 Similar to @code{__builtin_clz}, except the argument type is
12422 @code{unsigned long long}.
12423 @end deftypefn
12425 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12426 Similar to @code{__builtin_ctz}, except the argument type is
12427 @code{unsigned long long}.
12428 @end deftypefn
12430 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12431 Similar to @code{__builtin_clrsb}, except the argument type is
12432 @code{long long}.
12433 @end deftypefn
12435 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12436 Similar to @code{__builtin_popcount}, except the argument type is
12437 @code{unsigned long long}.
12438 @end deftypefn
12440 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12441 Similar to @code{__builtin_parity}, except the argument type is
12442 @code{unsigned long long}.
12443 @end deftypefn
12445 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12446 Returns the first argument raised to the power of the second.  Unlike the
12447 @code{pow} function no guarantees about precision and rounding are made.
12448 @end deftypefn
12450 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12451 Similar to @code{__builtin_powi}, except the argument and return types
12452 are @code{float}.
12453 @end deftypefn
12455 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12456 Similar to @code{__builtin_powi}, except the argument and return types
12457 are @code{long double}.
12458 @end deftypefn
12460 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12461 Returns @var{x} with the order of the bytes reversed; for example,
12462 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12463 exactly 8 bits.
12464 @end deftypefn
12466 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12467 Similar to @code{__builtin_bswap16}, except the argument and return types
12468 are 32 bit.
12469 @end deftypefn
12471 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12472 Similar to @code{__builtin_bswap32}, except the argument and return types
12473 are 64 bit.
12474 @end deftypefn
12476 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12477 On targets where the user visible pointer size is smaller than the size
12478 of an actual hardware address this function returns the extended user
12479 pointer.  Targets where this is true included ILP32 mode on x86_64 or
12480 Aarch64.  This function is mainly useful when writing inline assembly
12481 code.
12482 @end deftypefn
12484 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12485 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12486 0, 1 or 2.
12487 @end deftypefn
12489 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12490 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12491 0, 1 or 2.
12492 @end deftypefn
12494 @node Target Builtins
12495 @section Built-in Functions Specific to Particular Target Machines
12497 On some target machines, GCC supports many built-in functions specific
12498 to those machines.  Generally these generate calls to specific machine
12499 instructions, but allow the compiler to schedule those calls.
12501 @menu
12502 * AArch64 Built-in Functions::
12503 * Alpha Built-in Functions::
12504 * Altera Nios II Built-in Functions::
12505 * ARC Built-in Functions::
12506 * ARC SIMD Built-in Functions::
12507 * ARM iWMMXt Built-in Functions::
12508 * ARM C Language Extensions (ACLE)::
12509 * ARM Floating Point Status and Control Intrinsics::
12510 * ARM ARMv8-M Security Extensions::
12511 * AVR Built-in Functions::
12512 * Blackfin Built-in Functions::
12513 * FR-V Built-in Functions::
12514 * MIPS DSP Built-in Functions::
12515 * MIPS Paired-Single Support::
12516 * MIPS Loongson Built-in Functions::
12517 * MIPS SIMD Architecture (MSA) Support::
12518 * Other MIPS Built-in Functions::
12519 * MSP430 Built-in Functions::
12520 * NDS32 Built-in Functions::
12521 * picoChip Built-in Functions::
12522 * Basic PowerPC Built-in Functions::
12523 * PowerPC AltiVec/VSX Built-in Functions::
12524 * PowerPC Hardware Transactional Memory Built-in Functions::
12525 * PowerPC Atomic Memory Operation Functions::
12526 * RX Built-in Functions::
12527 * S/390 System z Built-in Functions::
12528 * SH Built-in Functions::
12529 * SPARC VIS Built-in Functions::
12530 * SPU Built-in Functions::
12531 * TI C6X Built-in Functions::
12532 * TILE-Gx Built-in Functions::
12533 * TILEPro Built-in Functions::
12534 * x86 Built-in Functions::
12535 * x86 transactional memory intrinsics::
12536 * x86 control-flow protection intrinsics::
12537 @end menu
12539 @node AArch64 Built-in Functions
12540 @subsection AArch64 Built-in Functions
12542 These built-in functions are available for the AArch64 family of
12543 processors.
12544 @smallexample
12545 unsigned int __builtin_aarch64_get_fpcr ()
12546 void __builtin_aarch64_set_fpcr (unsigned int)
12547 unsigned int __builtin_aarch64_get_fpsr ()
12548 void __builtin_aarch64_set_fpsr (unsigned int)
12549 @end smallexample
12551 @node Alpha Built-in Functions
12552 @subsection Alpha Built-in Functions
12554 These built-in functions are available for the Alpha family of
12555 processors, depending on the command-line switches used.
12557 The following built-in functions are always available.  They
12558 all generate the machine instruction that is part of the name.
12560 @smallexample
12561 long __builtin_alpha_implver (void)
12562 long __builtin_alpha_rpcc (void)
12563 long __builtin_alpha_amask (long)
12564 long __builtin_alpha_cmpbge (long, long)
12565 long __builtin_alpha_extbl (long, long)
12566 long __builtin_alpha_extwl (long, long)
12567 long __builtin_alpha_extll (long, long)
12568 long __builtin_alpha_extql (long, long)
12569 long __builtin_alpha_extwh (long, long)
12570 long __builtin_alpha_extlh (long, long)
12571 long __builtin_alpha_extqh (long, long)
12572 long __builtin_alpha_insbl (long, long)
12573 long __builtin_alpha_inswl (long, long)
12574 long __builtin_alpha_insll (long, long)
12575 long __builtin_alpha_insql (long, long)
12576 long __builtin_alpha_inswh (long, long)
12577 long __builtin_alpha_inslh (long, long)
12578 long __builtin_alpha_insqh (long, long)
12579 long __builtin_alpha_mskbl (long, long)
12580 long __builtin_alpha_mskwl (long, long)
12581 long __builtin_alpha_mskll (long, long)
12582 long __builtin_alpha_mskql (long, long)
12583 long __builtin_alpha_mskwh (long, long)
12584 long __builtin_alpha_msklh (long, long)
12585 long __builtin_alpha_mskqh (long, long)
12586 long __builtin_alpha_umulh (long, long)
12587 long __builtin_alpha_zap (long, long)
12588 long __builtin_alpha_zapnot (long, long)
12589 @end smallexample
12591 The following built-in functions are always with @option{-mmax}
12592 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12593 later.  They all generate the machine instruction that is part
12594 of the name.
12596 @smallexample
12597 long __builtin_alpha_pklb (long)
12598 long __builtin_alpha_pkwb (long)
12599 long __builtin_alpha_unpkbl (long)
12600 long __builtin_alpha_unpkbw (long)
12601 long __builtin_alpha_minub8 (long, long)
12602 long __builtin_alpha_minsb8 (long, long)
12603 long __builtin_alpha_minuw4 (long, long)
12604 long __builtin_alpha_minsw4 (long, long)
12605 long __builtin_alpha_maxub8 (long, long)
12606 long __builtin_alpha_maxsb8 (long, long)
12607 long __builtin_alpha_maxuw4 (long, long)
12608 long __builtin_alpha_maxsw4 (long, long)
12609 long __builtin_alpha_perr (long, long)
12610 @end smallexample
12612 The following built-in functions are always with @option{-mcix}
12613 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12614 later.  They all generate the machine instruction that is part
12615 of the name.
12617 @smallexample
12618 long __builtin_alpha_cttz (long)
12619 long __builtin_alpha_ctlz (long)
12620 long __builtin_alpha_ctpop (long)
12621 @end smallexample
12623 The following built-in functions are available on systems that use the OSF/1
12624 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12625 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12626 @code{rdval} and @code{wrval}.
12628 @smallexample
12629 void *__builtin_thread_pointer (void)
12630 void __builtin_set_thread_pointer (void *)
12631 @end smallexample
12633 @node Altera Nios II Built-in Functions
12634 @subsection Altera Nios II Built-in Functions
12636 These built-in functions are available for the Altera Nios II
12637 family of processors.
12639 The following built-in functions are always available.  They
12640 all generate the machine instruction that is part of the name.
12642 @example
12643 int __builtin_ldbio (volatile const void *)
12644 int __builtin_ldbuio (volatile const void *)
12645 int __builtin_ldhio (volatile const void *)
12646 int __builtin_ldhuio (volatile const void *)
12647 int __builtin_ldwio (volatile const void *)
12648 void __builtin_stbio (volatile void *, int)
12649 void __builtin_sthio (volatile void *, int)
12650 void __builtin_stwio (volatile void *, int)
12651 void __builtin_sync (void)
12652 int __builtin_rdctl (int) 
12653 int __builtin_rdprs (int, int)
12654 void __builtin_wrctl (int, int)
12655 void __builtin_flushd (volatile void *)
12656 void __builtin_flushda (volatile void *)
12657 int __builtin_wrpie (int);
12658 void __builtin_eni (int);
12659 int __builtin_ldex (volatile const void *)
12660 int __builtin_stex (volatile void *, int)
12661 int __builtin_ldsex (volatile const void *)
12662 int __builtin_stsex (volatile void *, int)
12663 @end example
12665 The following built-in functions are always available.  They
12666 all generate a Nios II Custom Instruction. The name of the
12667 function represents the types that the function takes and
12668 returns. The letter before the @code{n} is the return type
12669 or void if absent. The @code{n} represents the first parameter
12670 to all the custom instructions, the custom instruction number.
12671 The two letters after the @code{n} represent the up to two
12672 parameters to the function.
12674 The letters represent the following data types:
12675 @table @code
12676 @item <no letter>
12677 @code{void} for return type and no parameter for parameter types.
12679 @item i
12680 @code{int} for return type and parameter type
12682 @item f
12683 @code{float} for return type and parameter type
12685 @item p
12686 @code{void *} for return type and parameter type
12688 @end table
12690 And the function names are:
12691 @example
12692 void __builtin_custom_n (void)
12693 void __builtin_custom_ni (int)
12694 void __builtin_custom_nf (float)
12695 void __builtin_custom_np (void *)
12696 void __builtin_custom_nii (int, int)
12697 void __builtin_custom_nif (int, float)
12698 void __builtin_custom_nip (int, void *)
12699 void __builtin_custom_nfi (float, int)
12700 void __builtin_custom_nff (float, float)
12701 void __builtin_custom_nfp (float, void *)
12702 void __builtin_custom_npi (void *, int)
12703 void __builtin_custom_npf (void *, float)
12704 void __builtin_custom_npp (void *, void *)
12705 int __builtin_custom_in (void)
12706 int __builtin_custom_ini (int)
12707 int __builtin_custom_inf (float)
12708 int __builtin_custom_inp (void *)
12709 int __builtin_custom_inii (int, int)
12710 int __builtin_custom_inif (int, float)
12711 int __builtin_custom_inip (int, void *)
12712 int __builtin_custom_infi (float, int)
12713 int __builtin_custom_inff (float, float)
12714 int __builtin_custom_infp (float, void *)
12715 int __builtin_custom_inpi (void *, int)
12716 int __builtin_custom_inpf (void *, float)
12717 int __builtin_custom_inpp (void *, void *)
12718 float __builtin_custom_fn (void)
12719 float __builtin_custom_fni (int)
12720 float __builtin_custom_fnf (float)
12721 float __builtin_custom_fnp (void *)
12722 float __builtin_custom_fnii (int, int)
12723 float __builtin_custom_fnif (int, float)
12724 float __builtin_custom_fnip (int, void *)
12725 float __builtin_custom_fnfi (float, int)
12726 float __builtin_custom_fnff (float, float)
12727 float __builtin_custom_fnfp (float, void *)
12728 float __builtin_custom_fnpi (void *, int)
12729 float __builtin_custom_fnpf (void *, float)
12730 float __builtin_custom_fnpp (void *, void *)
12731 void * __builtin_custom_pn (void)
12732 void * __builtin_custom_pni (int)
12733 void * __builtin_custom_pnf (float)
12734 void * __builtin_custom_pnp (void *)
12735 void * __builtin_custom_pnii (int, int)
12736 void * __builtin_custom_pnif (int, float)
12737 void * __builtin_custom_pnip (int, void *)
12738 void * __builtin_custom_pnfi (float, int)
12739 void * __builtin_custom_pnff (float, float)
12740 void * __builtin_custom_pnfp (float, void *)
12741 void * __builtin_custom_pnpi (void *, int)
12742 void * __builtin_custom_pnpf (void *, float)
12743 void * __builtin_custom_pnpp (void *, void *)
12744 @end example
12746 @node ARC Built-in Functions
12747 @subsection ARC Built-in Functions
12749 The following built-in functions are provided for ARC targets.  The
12750 built-ins generate the corresponding assembly instructions.  In the
12751 examples given below, the generated code often requires an operand or
12752 result to be in a register.  Where necessary further code will be
12753 generated to ensure this is true, but for brevity this is not
12754 described in each case.
12756 @emph{Note:} Using a built-in to generate an instruction not supported
12757 by a target may cause problems. At present the compiler is not
12758 guaranteed to detect such misuse, and as a result an internal compiler
12759 error may be generated.
12761 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12762 Return 1 if @var{val} is known to have the byte alignment given
12763 by @var{alignval}, otherwise return 0.
12764 Note that this is different from
12765 @smallexample
12766 __alignof__(*(char *)@var{val}) >= alignval
12767 @end smallexample
12768 because __alignof__ sees only the type of the dereference, whereas
12769 __builtin_arc_align uses alignment information from the pointer
12770 as well as from the pointed-to type.
12771 The information available will depend on optimization level.
12772 @end deftypefn
12774 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12775 Generates
12776 @example
12778 @end example
12779 @end deftypefn
12781 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12782 The operand is the number of a register to be read.  Generates:
12783 @example
12784 mov  @var{dest}, r@var{regno}
12785 @end example
12786 where the value in @var{dest} will be the result returned from the
12787 built-in.
12788 @end deftypefn
12790 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12791 The first operand is the number of a register to be written, the
12792 second operand is a compile time constant to write into that
12793 register.  Generates:
12794 @example
12795 mov  r@var{regno}, @var{val}
12796 @end example
12797 @end deftypefn
12799 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12800 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12801 Generates:
12802 @example
12803 divaw  @var{dest}, @var{a}, @var{b}
12804 @end example
12805 where the value in @var{dest} will be the result returned from the
12806 built-in.
12807 @end deftypefn
12809 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12810 Generates
12811 @example
12812 flag  @var{a}
12813 @end example
12814 @end deftypefn
12816 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12817 The operand, @var{auxv}, is the address of an auxiliary register and
12818 must be a compile time constant.  Generates:
12819 @example
12820 lr  @var{dest}, [@var{auxr}]
12821 @end example
12822 Where the value in @var{dest} will be the result returned from the
12823 built-in.
12824 @end deftypefn
12826 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12827 Only available with @option{-mmul64}.  Generates:
12828 @example
12829 mul64  @var{a}, @var{b}
12830 @end example
12831 @end deftypefn
12833 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12834 Only available with @option{-mmul64}.  Generates:
12835 @example
12836 mulu64  @var{a}, @var{b}
12837 @end example
12838 @end deftypefn
12840 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12841 Generates:
12842 @example
12844 @end example
12845 @end deftypefn
12847 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12848 Only valid if the @samp{norm} instruction is available through the
12849 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12850 Generates:
12851 @example
12852 norm  @var{dest}, @var{src}
12853 @end example
12854 Where the value in @var{dest} will be the result returned from the
12855 built-in.
12856 @end deftypefn
12858 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12859 Only valid if the @samp{normw} instruction is available through the
12860 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12861 Generates:
12862 @example
12863 normw  @var{dest}, @var{src}
12864 @end example
12865 Where the value in @var{dest} will be the result returned from the
12866 built-in.
12867 @end deftypefn
12869 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12870 Generates:
12871 @example
12872 rtie
12873 @end example
12874 @end deftypefn
12876 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12877 Generates:
12878 @example
12879 sleep  @var{a}
12880 @end example
12881 @end deftypefn
12883 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12884 The first argument, @var{auxv}, is the address of an auxiliary
12885 register, the second argument, @var{val}, is a compile time constant
12886 to be written to the register.  Generates:
12887 @example
12888 sr  @var{auxr}, [@var{val}]
12889 @end example
12890 @end deftypefn
12892 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12893 Only valid with @option{-mswap}.  Generates:
12894 @example
12895 swap  @var{dest}, @var{src}
12896 @end example
12897 Where the value in @var{dest} will be the result returned from the
12898 built-in.
12899 @end deftypefn
12901 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12902 Generates:
12903 @example
12905 @end example
12906 @end deftypefn
12908 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12909 Only available with @option{-mcpu=ARC700}.  Generates:
12910 @example
12911 sync
12912 @end example
12913 @end deftypefn
12915 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12916 Only available with @option{-mcpu=ARC700}.  Generates:
12917 @example
12918 trap_s  @var{c}
12919 @end example
12920 @end deftypefn
12922 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12923 Only available with @option{-mcpu=ARC700}.  Generates:
12924 @example
12925 unimp_s
12926 @end example
12927 @end deftypefn
12929 The instructions generated by the following builtins are not
12930 considered as candidates for scheduling.  They are not moved around by
12931 the compiler during scheduling, and thus can be expected to appear
12932 where they are put in the C code:
12933 @example
12934 __builtin_arc_brk()
12935 __builtin_arc_core_read()
12936 __builtin_arc_core_write()
12937 __builtin_arc_flag()
12938 __builtin_arc_lr()
12939 __builtin_arc_sleep()
12940 __builtin_arc_sr()
12941 __builtin_arc_swi()
12942 @end example
12944 @node ARC SIMD Built-in Functions
12945 @subsection ARC SIMD Built-in Functions
12947 SIMD builtins provided by the compiler can be used to generate the
12948 vector instructions.  This section describes the available builtins
12949 and their usage in programs.  With the @option{-msimd} option, the
12950 compiler provides 128-bit vector types, which can be specified using
12951 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12952 can be included to use the following predefined types:
12953 @example
12954 typedef int __v4si   __attribute__((vector_size(16)));
12955 typedef short __v8hi __attribute__((vector_size(16)));
12956 @end example
12958 These types can be used to define 128-bit variables.  The built-in
12959 functions listed in the following section can be used on these
12960 variables to generate the vector operations.
12962 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12963 @file{arc-simd.h} also provides equivalent macros called
12964 @code{_@var{someinsn}} that can be used for programming ease and
12965 improved readability.  The following macros for DMA control are also
12966 provided:
12967 @example
12968 #define _setup_dma_in_channel_reg _vdiwr
12969 #define _setup_dma_out_channel_reg _vdowr
12970 @end example
12972 The following is a complete list of all the SIMD built-ins provided
12973 for ARC, grouped by calling signature.
12975 The following take two @code{__v8hi} arguments and return a
12976 @code{__v8hi} result:
12977 @example
12978 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12979 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12980 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12981 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12982 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12983 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12984 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12985 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12986 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12987 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12988 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12989 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12990 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12991 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12992 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12993 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12994 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12995 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12996 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12997 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12998 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12999 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13000 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13001 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13002 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13003 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13004 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13005 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13006 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13007 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13008 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13009 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13010 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13011 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13012 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13013 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13014 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13015 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13016 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13017 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13018 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13019 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13020 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13021 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13022 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13023 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13024 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13025 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13026 @end example
13028 The following take one @code{__v8hi} and one @code{int} argument and return a
13029 @code{__v8hi} result:
13031 @example
13032 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13033 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13034 __v8hi __builtin_arc_vbminw (__v8hi, int)
13035 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13036 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13037 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13038 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13039 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13040 @end example
13042 The following take one @code{__v8hi} argument and one @code{int} argument which
13043 must be a 3-bit compile time constant indicating a register number
13044 I0-I7.  They return a @code{__v8hi} result.
13045 @example
13046 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13047 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13048 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13049 @end example
13051 The following take one @code{__v8hi} argument and one @code{int}
13052 argument which must be a 6-bit compile time constant.  They return a
13053 @code{__v8hi} result.
13054 @example
13055 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13056 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13057 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13058 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13059 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13060 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13061 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13062 @end example
13064 The following take one @code{__v8hi} argument and one @code{int} argument which
13065 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13066 result.
13067 @example
13068 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13069 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13070 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13071 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13072 @end example
13074 The following take two @code{int} arguments, the second of which which
13075 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13076 result:
13077 @example
13078 __v8hi __builtin_arc_vmovaw (int, const int)
13079 __v8hi __builtin_arc_vmovw (int, const int)
13080 __v8hi __builtin_arc_vmovzw (int, const int)
13081 @end example
13083 The following take a single @code{__v8hi} argument and return a
13084 @code{__v8hi} result:
13085 @example
13086 __v8hi __builtin_arc_vabsaw (__v8hi)
13087 __v8hi __builtin_arc_vabsw (__v8hi)
13088 __v8hi __builtin_arc_vaddsuw (__v8hi)
13089 __v8hi __builtin_arc_vexch1 (__v8hi)
13090 __v8hi __builtin_arc_vexch2 (__v8hi)
13091 __v8hi __builtin_arc_vexch4 (__v8hi)
13092 __v8hi __builtin_arc_vsignw (__v8hi)
13093 __v8hi __builtin_arc_vupbaw (__v8hi)
13094 __v8hi __builtin_arc_vupbw (__v8hi)
13095 __v8hi __builtin_arc_vupsbaw (__v8hi)
13096 __v8hi __builtin_arc_vupsbw (__v8hi)
13097 @end example
13099 The following take two @code{int} arguments and return no result:
13100 @example
13101 void __builtin_arc_vdirun (int, int)
13102 void __builtin_arc_vdorun (int, int)
13103 @end example
13105 The following take two @code{int} arguments and return no result.  The
13106 first argument must a 3-bit compile time constant indicating one of
13107 the DR0-DR7 DMA setup channels:
13108 @example
13109 void __builtin_arc_vdiwr (const int, int)
13110 void __builtin_arc_vdowr (const int, int)
13111 @end example
13113 The following take an @code{int} argument and return no result:
13114 @example
13115 void __builtin_arc_vendrec (int)
13116 void __builtin_arc_vrec (int)
13117 void __builtin_arc_vrecrun (int)
13118 void __builtin_arc_vrun (int)
13119 @end example
13121 The following take a @code{__v8hi} argument and two @code{int}
13122 arguments and return a @code{__v8hi} result.  The second argument must
13123 be a 3-bit compile time constants, indicating one the registers I0-I7,
13124 and the third argument must be an 8-bit compile time constant.
13126 @emph{Note:} Although the equivalent hardware instructions do not take
13127 an SIMD register as an operand, these builtins overwrite the relevant
13128 bits of the @code{__v8hi} register provided as the first argument with
13129 the value loaded from the @code{[Ib, u8]} location in the SDM.
13131 @example
13132 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13133 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13134 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13135 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13136 @end example
13138 The following take two @code{int} arguments and return a @code{__v8hi}
13139 result.  The first argument must be a 3-bit compile time constants,
13140 indicating one the registers I0-I7, and the second argument must be an
13141 8-bit compile time constant.
13143 @example
13144 __v8hi __builtin_arc_vld128 (const int, const int)
13145 __v8hi __builtin_arc_vld64w (const int, const int)
13146 @end example
13148 The following take a @code{__v8hi} argument and two @code{int}
13149 arguments and return no result.  The second argument must be a 3-bit
13150 compile time constants, indicating one the registers I0-I7, and the
13151 third argument must be an 8-bit compile time constant.
13153 @example
13154 void __builtin_arc_vst128 (__v8hi, const int, const int)
13155 void __builtin_arc_vst64 (__v8hi, const int, const int)
13156 @end example
13158 The following take a @code{__v8hi} argument and three @code{int}
13159 arguments and return no result.  The second argument must be a 3-bit
13160 compile-time constant, identifying the 16-bit sub-register to be
13161 stored, the third argument must be a 3-bit compile time constants,
13162 indicating one the registers I0-I7, and the fourth argument must be an
13163 8-bit compile time constant.
13165 @example
13166 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13167 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13168 @end example
13170 @node ARM iWMMXt Built-in Functions
13171 @subsection ARM iWMMXt Built-in Functions
13173 These built-in functions are available for the ARM family of
13174 processors when the @option{-mcpu=iwmmxt} switch is used:
13176 @smallexample
13177 typedef int v2si __attribute__ ((vector_size (8)));
13178 typedef short v4hi __attribute__ ((vector_size (8)));
13179 typedef char v8qi __attribute__ ((vector_size (8)));
13181 int __builtin_arm_getwcgr0 (void)
13182 void __builtin_arm_setwcgr0 (int)
13183 int __builtin_arm_getwcgr1 (void)
13184 void __builtin_arm_setwcgr1 (int)
13185 int __builtin_arm_getwcgr2 (void)
13186 void __builtin_arm_setwcgr2 (int)
13187 int __builtin_arm_getwcgr3 (void)
13188 void __builtin_arm_setwcgr3 (int)
13189 int __builtin_arm_textrmsb (v8qi, int)
13190 int __builtin_arm_textrmsh (v4hi, int)
13191 int __builtin_arm_textrmsw (v2si, int)
13192 int __builtin_arm_textrmub (v8qi, int)
13193 int __builtin_arm_textrmuh (v4hi, int)
13194 int __builtin_arm_textrmuw (v2si, int)
13195 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13196 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13197 v2si __builtin_arm_tinsrw (v2si, int, int)
13198 long long __builtin_arm_tmia (long long, int, int)
13199 long long __builtin_arm_tmiabb (long long, int, int)
13200 long long __builtin_arm_tmiabt (long long, int, int)
13201 long long __builtin_arm_tmiaph (long long, int, int)
13202 long long __builtin_arm_tmiatb (long long, int, int)
13203 long long __builtin_arm_tmiatt (long long, int, int)
13204 int __builtin_arm_tmovmskb (v8qi)
13205 int __builtin_arm_tmovmskh (v4hi)
13206 int __builtin_arm_tmovmskw (v2si)
13207 long long __builtin_arm_waccb (v8qi)
13208 long long __builtin_arm_wacch (v4hi)
13209 long long __builtin_arm_waccw (v2si)
13210 v8qi __builtin_arm_waddb (v8qi, v8qi)
13211 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13212 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13213 v4hi __builtin_arm_waddh (v4hi, v4hi)
13214 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13215 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13216 v2si __builtin_arm_waddw (v2si, v2si)
13217 v2si __builtin_arm_waddwss (v2si, v2si)
13218 v2si __builtin_arm_waddwus (v2si, v2si)
13219 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13220 long long __builtin_arm_wand(long long, long long)
13221 long long __builtin_arm_wandn (long long, long long)
13222 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13223 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13224 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13225 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13226 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13227 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13228 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13229 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13230 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13231 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13232 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13233 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13234 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13235 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13236 long long __builtin_arm_wmacsz (v4hi, v4hi)
13237 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13238 long long __builtin_arm_wmacuz (v4hi, v4hi)
13239 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13240 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13241 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13242 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13243 v2si __builtin_arm_wmaxsw (v2si, v2si)
13244 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13245 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13246 v2si __builtin_arm_wmaxuw (v2si, v2si)
13247 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13248 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13249 v2si __builtin_arm_wminsw (v2si, v2si)
13250 v8qi __builtin_arm_wminub (v8qi, v8qi)
13251 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13252 v2si __builtin_arm_wminuw (v2si, v2si)
13253 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13254 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13255 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13256 long long __builtin_arm_wor (long long, long long)
13257 v2si __builtin_arm_wpackdss (long long, long long)
13258 v2si __builtin_arm_wpackdus (long long, long long)
13259 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13260 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13261 v4hi __builtin_arm_wpackwss (v2si, v2si)
13262 v4hi __builtin_arm_wpackwus (v2si, v2si)
13263 long long __builtin_arm_wrord (long long, long long)
13264 long long __builtin_arm_wrordi (long long, int)
13265 v4hi __builtin_arm_wrorh (v4hi, long long)
13266 v4hi __builtin_arm_wrorhi (v4hi, int)
13267 v2si __builtin_arm_wrorw (v2si, long long)
13268 v2si __builtin_arm_wrorwi (v2si, int)
13269 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13270 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13271 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13272 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13273 v4hi __builtin_arm_wshufh (v4hi, int)
13274 long long __builtin_arm_wslld (long long, long long)
13275 long long __builtin_arm_wslldi (long long, int)
13276 v4hi __builtin_arm_wsllh (v4hi, long long)
13277 v4hi __builtin_arm_wsllhi (v4hi, int)
13278 v2si __builtin_arm_wsllw (v2si, long long)
13279 v2si __builtin_arm_wsllwi (v2si, int)
13280 long long __builtin_arm_wsrad (long long, long long)
13281 long long __builtin_arm_wsradi (long long, int)
13282 v4hi __builtin_arm_wsrah (v4hi, long long)
13283 v4hi __builtin_arm_wsrahi (v4hi, int)
13284 v2si __builtin_arm_wsraw (v2si, long long)
13285 v2si __builtin_arm_wsrawi (v2si, int)
13286 long long __builtin_arm_wsrld (long long, long long)
13287 long long __builtin_arm_wsrldi (long long, int)
13288 v4hi __builtin_arm_wsrlh (v4hi, long long)
13289 v4hi __builtin_arm_wsrlhi (v4hi, int)
13290 v2si __builtin_arm_wsrlw (v2si, long long)
13291 v2si __builtin_arm_wsrlwi (v2si, int)
13292 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13293 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13294 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13295 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13296 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13297 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13298 v2si __builtin_arm_wsubw (v2si, v2si)
13299 v2si __builtin_arm_wsubwss (v2si, v2si)
13300 v2si __builtin_arm_wsubwus (v2si, v2si)
13301 v4hi __builtin_arm_wunpckehsb (v8qi)
13302 v2si __builtin_arm_wunpckehsh (v4hi)
13303 long long __builtin_arm_wunpckehsw (v2si)
13304 v4hi __builtin_arm_wunpckehub (v8qi)
13305 v2si __builtin_arm_wunpckehuh (v4hi)
13306 long long __builtin_arm_wunpckehuw (v2si)
13307 v4hi __builtin_arm_wunpckelsb (v8qi)
13308 v2si __builtin_arm_wunpckelsh (v4hi)
13309 long long __builtin_arm_wunpckelsw (v2si)
13310 v4hi __builtin_arm_wunpckelub (v8qi)
13311 v2si __builtin_arm_wunpckeluh (v4hi)
13312 long long __builtin_arm_wunpckeluw (v2si)
13313 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13314 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13315 v2si __builtin_arm_wunpckihw (v2si, v2si)
13316 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13317 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13318 v2si __builtin_arm_wunpckilw (v2si, v2si)
13319 long long __builtin_arm_wxor (long long, long long)
13320 long long __builtin_arm_wzero ()
13321 @end smallexample
13324 @node ARM C Language Extensions (ACLE)
13325 @subsection ARM C Language Extensions (ACLE)
13327 GCC implements extensions for C as described in the ARM C Language
13328 Extensions (ACLE) specification, which can be found at
13329 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13331 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13332 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13333 intrinsics can be found at
13334 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13335 The built-in intrinsics for the Advanced SIMD extension are available when
13336 NEON is enabled.
13338 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13339 back ends support CRC32 intrinsics and the ARM back end supports the
13340 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13341 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13342 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13343 intrinsics yet.
13345 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13346 availability of extensions.
13348 @node ARM Floating Point Status and Control Intrinsics
13349 @subsection ARM Floating Point Status and Control Intrinsics
13351 These built-in functions are available for the ARM family of
13352 processors with floating-point unit.
13354 @smallexample
13355 unsigned int __builtin_arm_get_fpscr ()
13356 void __builtin_arm_set_fpscr (unsigned int)
13357 @end smallexample
13359 @node ARM ARMv8-M Security Extensions
13360 @subsection ARM ARMv8-M Security Extensions
13362 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13363 Security Extensions: Requirements on Development Tools Engineering
13364 Specification, which can be found at
13365 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13367 As part of the Security Extensions GCC implements two new function attributes:
13368 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13370 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13371 is used here to mean any function pointer type.
13373 @smallexample
13374 cmse_address_info_t cmse_TT (void *)
13375 cmse_address_info_t cmse_TT_fptr (FPTR)
13376 cmse_address_info_t cmse_TTT (void *)
13377 cmse_address_info_t cmse_TTT_fptr (FPTR)
13378 cmse_address_info_t cmse_TTA (void *)
13379 cmse_address_info_t cmse_TTA_fptr (FPTR)
13380 cmse_address_info_t cmse_TTAT (void *)
13381 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13382 void * cmse_check_address_range (void *, size_t, int)
13383 typeof(p) cmse_nsfptr_create (FPTR p)
13384 intptr_t cmse_is_nsfptr (FPTR)
13385 int cmse_nonsecure_caller (void)
13386 @end smallexample
13388 @node AVR Built-in Functions
13389 @subsection AVR Built-in Functions
13391 For each built-in function for AVR, there is an equally named,
13392 uppercase built-in macro defined. That way users can easily query if
13393 or if not a specific built-in is implemented or not. For example, if
13394 @code{__builtin_avr_nop} is available the macro
13395 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13397 @table @code
13399 @item void __builtin_avr_nop (void)
13400 @itemx void __builtin_avr_sei (void)
13401 @itemx void __builtin_avr_cli (void)
13402 @itemx void __builtin_avr_sleep (void)
13403 @itemx void __builtin_avr_wdr (void)
13404 @itemx unsigned char __builtin_avr_swap (unsigned char)
13405 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13406 @itemx int __builtin_avr_fmuls (char, char)
13407 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13408 These built-in functions map to the respective machine
13409 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13410 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13411 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13412 as library call if no hardware multiplier is available.
13414 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13415 Delay execution for @var{ticks} cycles. Note that this
13416 built-in does not take into account the effect of interrupts that
13417 might increase delay time. @var{ticks} must be a compile-time
13418 integer constant; delays with a variable number of cycles are not supported.
13420 @item char __builtin_avr_flash_segment (const __memx void*)
13421 This built-in takes a byte address to the 24-bit
13422 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13423 the number of the flash segment (the 64 KiB chunk) where the address
13424 points to.  Counting starts at @code{0}.
13425 If the address does not point to flash memory, return @code{-1}.
13427 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13428 Insert bits from @var{bits} into @var{val} and return the resulting
13429 value. The nibbles of @var{map} determine how the insertion is
13430 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13431 @enumerate
13432 @item If @var{X} is @code{0xf},
13433 then the @var{n}-th bit of @var{val} is returned unaltered.
13435 @item If X is in the range 0@dots{}7,
13436 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13438 @item If X is in the range 8@dots{}@code{0xe},
13439 then the @var{n}-th result bit is undefined.
13440 @end enumerate
13442 @noindent
13443 One typical use case for this built-in is adjusting input and
13444 output values to non-contiguous port layouts. Some examples:
13446 @smallexample
13447 // same as val, bits is unused
13448 __builtin_avr_insert_bits (0xffffffff, bits, val)
13449 @end smallexample
13451 @smallexample
13452 // same as bits, val is unused
13453 __builtin_avr_insert_bits (0x76543210, bits, val)
13454 @end smallexample
13456 @smallexample
13457 // same as rotating bits by 4
13458 __builtin_avr_insert_bits (0x32107654, bits, 0)
13459 @end smallexample
13461 @smallexample
13462 // high nibble of result is the high nibble of val
13463 // low nibble of result is the low nibble of bits
13464 __builtin_avr_insert_bits (0xffff3210, bits, val)
13465 @end smallexample
13467 @smallexample
13468 // reverse the bit order of bits
13469 __builtin_avr_insert_bits (0x01234567, bits, 0)
13470 @end smallexample
13472 @item void __builtin_avr_nops (unsigned count)
13473 Insert @var{count} @code{NOP} instructions.
13474 The number of instructions must be a compile-time integer constant.
13476 @end table
13478 @noindent
13479 There are many more AVR-specific built-in functions that are used to
13480 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13481 section 7.18a.6.  You don't need to use these built-ins directly.
13482 Instead, use the declarations as supplied by the @code{stdfix.h} header
13483 with GNU-C99:
13485 @smallexample
13486 #include <stdfix.h>
13488 // Re-interpret the bit representation of unsigned 16-bit
13489 // integer @var{uval} as Q-format 0.16 value.
13490 unsigned fract get_bits (uint_ur_t uval)
13492     return urbits (uval);
13494 @end smallexample
13496 @node Blackfin Built-in Functions
13497 @subsection Blackfin Built-in Functions
13499 Currently, there are two Blackfin-specific built-in functions.  These are
13500 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13501 using inline assembly; by using these built-in functions the compiler can
13502 automatically add workarounds for hardware errata involving these
13503 instructions.  These functions are named as follows:
13505 @smallexample
13506 void __builtin_bfin_csync (void)
13507 void __builtin_bfin_ssync (void)
13508 @end smallexample
13510 @node FR-V Built-in Functions
13511 @subsection FR-V Built-in Functions
13513 GCC provides many FR-V-specific built-in functions.  In general,
13514 these functions are intended to be compatible with those described
13515 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13516 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13517 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13518 pointer rather than by value.
13520 Most of the functions are named after specific FR-V instructions.
13521 Such functions are said to be ``directly mapped'' and are summarized
13522 here in tabular form.
13524 @menu
13525 * Argument Types::
13526 * Directly-mapped Integer Functions::
13527 * Directly-mapped Media Functions::
13528 * Raw read/write Functions::
13529 * Other Built-in Functions::
13530 @end menu
13532 @node Argument Types
13533 @subsubsection Argument Types
13535 The arguments to the built-in functions can be divided into three groups:
13536 register numbers, compile-time constants and run-time values.  In order
13537 to make this classification clear at a glance, the arguments and return
13538 values are given the following pseudo types:
13540 @multitable @columnfractions .20 .30 .15 .35
13541 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13542 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13543 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13544 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13545 @item @code{uw2} @tab @code{unsigned long long} @tab No
13546 @tab an unsigned doubleword
13547 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13548 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13549 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13550 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13551 @end multitable
13553 These pseudo types are not defined by GCC, they are simply a notational
13554 convenience used in this manual.
13556 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13557 and @code{sw2} are evaluated at run time.  They correspond to
13558 register operands in the underlying FR-V instructions.
13560 @code{const} arguments represent immediate operands in the underlying
13561 FR-V instructions.  They must be compile-time constants.
13563 @code{acc} arguments are evaluated at compile time and specify the number
13564 of an accumulator register.  For example, an @code{acc} argument of 2
13565 selects the ACC2 register.
13567 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13568 number of an IACC register.  See @pxref{Other Built-in Functions}
13569 for more details.
13571 @node Directly-mapped Integer Functions
13572 @subsubsection Directly-Mapped Integer Functions
13574 The functions listed below map directly to FR-V I-type instructions.
13576 @multitable @columnfractions .45 .32 .23
13577 @item Function prototype @tab Example usage @tab Assembly output
13578 @item @code{sw1 __ADDSS (sw1, sw1)}
13579 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13580 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13581 @item @code{sw1 __SCAN (sw1, sw1)}
13582 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13583 @tab @code{SCAN @var{a},@var{b},@var{c}}
13584 @item @code{sw1 __SCUTSS (sw1)}
13585 @tab @code{@var{b} = __SCUTSS (@var{a})}
13586 @tab @code{SCUTSS @var{a},@var{b}}
13587 @item @code{sw1 __SLASS (sw1, sw1)}
13588 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13589 @tab @code{SLASS @var{a},@var{b},@var{c}}
13590 @item @code{void __SMASS (sw1, sw1)}
13591 @tab @code{__SMASS (@var{a}, @var{b})}
13592 @tab @code{SMASS @var{a},@var{b}}
13593 @item @code{void __SMSSS (sw1, sw1)}
13594 @tab @code{__SMSSS (@var{a}, @var{b})}
13595 @tab @code{SMSSS @var{a},@var{b}}
13596 @item @code{void __SMU (sw1, sw1)}
13597 @tab @code{__SMU (@var{a}, @var{b})}
13598 @tab @code{SMU @var{a},@var{b}}
13599 @item @code{sw2 __SMUL (sw1, sw1)}
13600 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13601 @tab @code{SMUL @var{a},@var{b},@var{c}}
13602 @item @code{sw1 __SUBSS (sw1, sw1)}
13603 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13604 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13605 @item @code{uw2 __UMUL (uw1, uw1)}
13606 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13607 @tab @code{UMUL @var{a},@var{b},@var{c}}
13608 @end multitable
13610 @node Directly-mapped Media Functions
13611 @subsubsection Directly-Mapped Media Functions
13613 The functions listed below map directly to FR-V M-type instructions.
13615 @multitable @columnfractions .45 .32 .23
13616 @item Function prototype @tab Example usage @tab Assembly output
13617 @item @code{uw1 __MABSHS (sw1)}
13618 @tab @code{@var{b} = __MABSHS (@var{a})}
13619 @tab @code{MABSHS @var{a},@var{b}}
13620 @item @code{void __MADDACCS (acc, acc)}
13621 @tab @code{__MADDACCS (@var{b}, @var{a})}
13622 @tab @code{MADDACCS @var{a},@var{b}}
13623 @item @code{sw1 __MADDHSS (sw1, sw1)}
13624 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13625 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13626 @item @code{uw1 __MADDHUS (uw1, uw1)}
13627 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13628 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13629 @item @code{uw1 __MAND (uw1, uw1)}
13630 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13631 @tab @code{MAND @var{a},@var{b},@var{c}}
13632 @item @code{void __MASACCS (acc, acc)}
13633 @tab @code{__MASACCS (@var{b}, @var{a})}
13634 @tab @code{MASACCS @var{a},@var{b}}
13635 @item @code{uw1 __MAVEH (uw1, uw1)}
13636 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13637 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13638 @item @code{uw2 __MBTOH (uw1)}
13639 @tab @code{@var{b} = __MBTOH (@var{a})}
13640 @tab @code{MBTOH @var{a},@var{b}}
13641 @item @code{void __MBTOHE (uw1 *, uw1)}
13642 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13643 @tab @code{MBTOHE @var{a},@var{b}}
13644 @item @code{void __MCLRACC (acc)}
13645 @tab @code{__MCLRACC (@var{a})}
13646 @tab @code{MCLRACC @var{a}}
13647 @item @code{void __MCLRACCA (void)}
13648 @tab @code{__MCLRACCA ()}
13649 @tab @code{MCLRACCA}
13650 @item @code{uw1 __Mcop1 (uw1, uw1)}
13651 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13652 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13653 @item @code{uw1 __Mcop2 (uw1, uw1)}
13654 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13655 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13656 @item @code{uw1 __MCPLHI (uw2, const)}
13657 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13658 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13659 @item @code{uw1 __MCPLI (uw2, const)}
13660 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13661 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13662 @item @code{void __MCPXIS (acc, sw1, sw1)}
13663 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13664 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13665 @item @code{void __MCPXIU (acc, uw1, uw1)}
13666 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13667 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13668 @item @code{void __MCPXRS (acc, sw1, sw1)}
13669 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13670 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13671 @item @code{void __MCPXRU (acc, uw1, uw1)}
13672 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13673 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13674 @item @code{uw1 __MCUT (acc, uw1)}
13675 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13676 @tab @code{MCUT @var{a},@var{b},@var{c}}
13677 @item @code{uw1 __MCUTSS (acc, sw1)}
13678 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13679 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13680 @item @code{void __MDADDACCS (acc, acc)}
13681 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13682 @tab @code{MDADDACCS @var{a},@var{b}}
13683 @item @code{void __MDASACCS (acc, acc)}
13684 @tab @code{__MDASACCS (@var{b}, @var{a})}
13685 @tab @code{MDASACCS @var{a},@var{b}}
13686 @item @code{uw2 __MDCUTSSI (acc, const)}
13687 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13688 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13689 @item @code{uw2 __MDPACKH (uw2, uw2)}
13690 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13691 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13692 @item @code{uw2 __MDROTLI (uw2, const)}
13693 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13694 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13695 @item @code{void __MDSUBACCS (acc, acc)}
13696 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13697 @tab @code{MDSUBACCS @var{a},@var{b}}
13698 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13699 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13700 @tab @code{MDUNPACKH @var{a},@var{b}}
13701 @item @code{uw2 __MEXPDHD (uw1, const)}
13702 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13703 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13704 @item @code{uw1 __MEXPDHW (uw1, const)}
13705 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13706 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13707 @item @code{uw1 __MHDSETH (uw1, const)}
13708 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13709 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13710 @item @code{sw1 __MHDSETS (const)}
13711 @tab @code{@var{b} = __MHDSETS (@var{a})}
13712 @tab @code{MHDSETS #@var{a},@var{b}}
13713 @item @code{uw1 __MHSETHIH (uw1, const)}
13714 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13715 @tab @code{MHSETHIH #@var{a},@var{b}}
13716 @item @code{sw1 __MHSETHIS (sw1, const)}
13717 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13718 @tab @code{MHSETHIS #@var{a},@var{b}}
13719 @item @code{uw1 __MHSETLOH (uw1, const)}
13720 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13721 @tab @code{MHSETLOH #@var{a},@var{b}}
13722 @item @code{sw1 __MHSETLOS (sw1, const)}
13723 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13724 @tab @code{MHSETLOS #@var{a},@var{b}}
13725 @item @code{uw1 __MHTOB (uw2)}
13726 @tab @code{@var{b} = __MHTOB (@var{a})}
13727 @tab @code{MHTOB @var{a},@var{b}}
13728 @item @code{void __MMACHS (acc, sw1, sw1)}
13729 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13730 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13731 @item @code{void __MMACHU (acc, uw1, uw1)}
13732 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13733 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13734 @item @code{void __MMRDHS (acc, sw1, sw1)}
13735 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13736 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13737 @item @code{void __MMRDHU (acc, uw1, uw1)}
13738 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13739 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13740 @item @code{void __MMULHS (acc, sw1, sw1)}
13741 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13742 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13743 @item @code{void __MMULHU (acc, uw1, uw1)}
13744 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13745 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13746 @item @code{void __MMULXHS (acc, sw1, sw1)}
13747 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13748 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13749 @item @code{void __MMULXHU (acc, uw1, uw1)}
13750 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13751 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13752 @item @code{uw1 __MNOT (uw1)}
13753 @tab @code{@var{b} = __MNOT (@var{a})}
13754 @tab @code{MNOT @var{a},@var{b}}
13755 @item @code{uw1 __MOR (uw1, uw1)}
13756 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13757 @tab @code{MOR @var{a},@var{b},@var{c}}
13758 @item @code{uw1 __MPACKH (uh, uh)}
13759 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13760 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13761 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13762 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13763 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13764 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13765 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13766 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13767 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13768 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13769 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13770 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13771 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13772 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13773 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13774 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13775 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13776 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13777 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13778 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13779 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13780 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13781 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13782 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13783 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13784 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13785 @item @code{void __MQMACHS (acc, sw2, sw2)}
13786 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13787 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13788 @item @code{void __MQMACHU (acc, uw2, uw2)}
13789 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13790 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13791 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13792 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13793 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13794 @item @code{void __MQMULHS (acc, sw2, sw2)}
13795 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13796 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13797 @item @code{void __MQMULHU (acc, uw2, uw2)}
13798 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13799 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13800 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13801 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13802 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13803 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13804 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13805 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13806 @item @code{sw2 __MQSATHS (sw2, sw2)}
13807 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13808 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13809 @item @code{uw2 __MQSLLHI (uw2, int)}
13810 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13811 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13812 @item @code{sw2 __MQSRAHI (sw2, int)}
13813 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13814 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13815 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13816 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13817 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13818 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13819 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13820 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13821 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13822 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13823 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13824 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13825 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13826 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13827 @item @code{uw1 __MRDACC (acc)}
13828 @tab @code{@var{b} = __MRDACC (@var{a})}
13829 @tab @code{MRDACC @var{a},@var{b}}
13830 @item @code{uw1 __MRDACCG (acc)}
13831 @tab @code{@var{b} = __MRDACCG (@var{a})}
13832 @tab @code{MRDACCG @var{a},@var{b}}
13833 @item @code{uw1 __MROTLI (uw1, const)}
13834 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13835 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13836 @item @code{uw1 __MROTRI (uw1, const)}
13837 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13838 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13839 @item @code{sw1 __MSATHS (sw1, sw1)}
13840 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13841 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13842 @item @code{uw1 __MSATHU (uw1, uw1)}
13843 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13844 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13845 @item @code{uw1 __MSLLHI (uw1, const)}
13846 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13847 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13848 @item @code{sw1 __MSRAHI (sw1, const)}
13849 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13850 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13851 @item @code{uw1 __MSRLHI (uw1, const)}
13852 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13853 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13854 @item @code{void __MSUBACCS (acc, acc)}
13855 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13856 @tab @code{MSUBACCS @var{a},@var{b}}
13857 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13858 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13859 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13860 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13861 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13862 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13863 @item @code{void __MTRAP (void)}
13864 @tab @code{__MTRAP ()}
13865 @tab @code{MTRAP}
13866 @item @code{uw2 __MUNPACKH (uw1)}
13867 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13868 @tab @code{MUNPACKH @var{a},@var{b}}
13869 @item @code{uw1 __MWCUT (uw2, uw1)}
13870 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13871 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13872 @item @code{void __MWTACC (acc, uw1)}
13873 @tab @code{__MWTACC (@var{b}, @var{a})}
13874 @tab @code{MWTACC @var{a},@var{b}}
13875 @item @code{void __MWTACCG (acc, uw1)}
13876 @tab @code{__MWTACCG (@var{b}, @var{a})}
13877 @tab @code{MWTACCG @var{a},@var{b}}
13878 @item @code{uw1 __MXOR (uw1, uw1)}
13879 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13880 @tab @code{MXOR @var{a},@var{b},@var{c}}
13881 @end multitable
13883 @node Raw read/write Functions
13884 @subsubsection Raw Read/Write Functions
13886 This sections describes built-in functions related to read and write
13887 instructions to access memory.  These functions generate
13888 @code{membar} instructions to flush the I/O load and stores where
13889 appropriate, as described in Fujitsu's manual described above.
13891 @table @code
13893 @item unsigned char __builtin_read8 (void *@var{data})
13894 @item unsigned short __builtin_read16 (void *@var{data})
13895 @item unsigned long __builtin_read32 (void *@var{data})
13896 @item unsigned long long __builtin_read64 (void *@var{data})
13898 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13899 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13900 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13901 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13902 @end table
13904 @node Other Built-in Functions
13905 @subsubsection Other Built-in Functions
13907 This section describes built-in functions that are not named after
13908 a specific FR-V instruction.
13910 @table @code
13911 @item sw2 __IACCreadll (iacc @var{reg})
13912 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13913 for future expansion and must be 0.
13915 @item sw1 __IACCreadl (iacc @var{reg})
13916 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13917 Other values of @var{reg} are rejected as invalid.
13919 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13920 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13921 is reserved for future expansion and must be 0.
13923 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13924 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13925 is 1.  Other values of @var{reg} are rejected as invalid.
13927 @item void __data_prefetch0 (const void *@var{x})
13928 Use the @code{dcpl} instruction to load the contents of address @var{x}
13929 into the data cache.
13931 @item void __data_prefetch (const void *@var{x})
13932 Use the @code{nldub} instruction to load the contents of address @var{x}
13933 into the data cache.  The instruction is issued in slot I1@.
13934 @end table
13936 @node MIPS DSP Built-in Functions
13937 @subsection MIPS DSP Built-in Functions
13939 The MIPS DSP Application-Specific Extension (ASE) includes new
13940 instructions that are designed to improve the performance of DSP and
13941 media applications.  It provides instructions that operate on packed
13942 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13944 GCC supports MIPS DSP operations using both the generic
13945 vector extensions (@pxref{Vector Extensions}) and a collection of
13946 MIPS-specific built-in functions.  Both kinds of support are
13947 enabled by the @option{-mdsp} command-line option.
13949 Revision 2 of the ASE was introduced in the second half of 2006.
13950 This revision adds extra instructions to the original ASE, but is
13951 otherwise backwards-compatible with it.  You can select revision 2
13952 using the command-line option @option{-mdspr2}; this option implies
13953 @option{-mdsp}.
13955 The SCOUNT and POS bits of the DSP control register are global.  The
13956 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13957 POS bits.  During optimization, the compiler does not delete these
13958 instructions and it does not delete calls to functions containing
13959 these instructions.
13961 At present, GCC only provides support for operations on 32-bit
13962 vectors.  The vector type associated with 8-bit integer data is
13963 usually called @code{v4i8}, the vector type associated with Q7
13964 is usually called @code{v4q7}, the vector type associated with 16-bit
13965 integer data is usually called @code{v2i16}, and the vector type
13966 associated with Q15 is usually called @code{v2q15}.  They can be
13967 defined in C as follows:
13969 @smallexample
13970 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13971 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13972 typedef short v2i16 __attribute__ ((vector_size(4)));
13973 typedef short v2q15 __attribute__ ((vector_size(4)));
13974 @end smallexample
13976 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13977 initialized in the same way as aggregates.  For example:
13979 @smallexample
13980 v4i8 a = @{1, 2, 3, 4@};
13981 v4i8 b;
13982 b = (v4i8) @{5, 6, 7, 8@};
13984 v2q15 c = @{0x0fcb, 0x3a75@};
13985 v2q15 d;
13986 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13987 @end smallexample
13989 @emph{Note:} The CPU's endianness determines the order in which values
13990 are packed.  On little-endian targets, the first value is the least
13991 significant and the last value is the most significant.  The opposite
13992 order applies to big-endian targets.  For example, the code above
13993 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13994 and @code{4} on big-endian targets.
13996 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13997 representation.  As shown in this example, the integer representation
13998 of a Q7 value can be obtained by multiplying the fractional value by
13999 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
14000 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
14001 @code{0x1.0p31}.
14003 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14004 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
14005 and @code{c} and @code{d} are @code{v2q15} values.
14007 @multitable @columnfractions .50 .50
14008 @item C code @tab MIPS instruction
14009 @item @code{a + b} @tab @code{addu.qb}
14010 @item @code{c + d} @tab @code{addq.ph}
14011 @item @code{a - b} @tab @code{subu.qb}
14012 @item @code{c - d} @tab @code{subq.ph}
14013 @end multitable
14015 The table below lists the @code{v2i16} operation for which
14016 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
14017 @code{v2i16} values.
14019 @multitable @columnfractions .50 .50
14020 @item C code @tab MIPS instruction
14021 @item @code{e * f} @tab @code{mul.ph}
14022 @end multitable
14024 It is easier to describe the DSP built-in functions if we first define
14025 the following types:
14027 @smallexample
14028 typedef int q31;
14029 typedef int i32;
14030 typedef unsigned int ui32;
14031 typedef long long a64;
14032 @end smallexample
14034 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14035 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14036 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
14037 @code{long long}, but we use @code{a64} to indicate values that are
14038 placed in one of the four DSP accumulators (@code{$ac0},
14039 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14041 Also, some built-in functions prefer or require immediate numbers as
14042 parameters, because the corresponding DSP instructions accept both immediate
14043 numbers and register operands, or accept immediate numbers only.  The
14044 immediate parameters are listed as follows.
14046 @smallexample
14047 imm0_3: 0 to 3.
14048 imm0_7: 0 to 7.
14049 imm0_15: 0 to 15.
14050 imm0_31: 0 to 31.
14051 imm0_63: 0 to 63.
14052 imm0_255: 0 to 255.
14053 imm_n32_31: -32 to 31.
14054 imm_n512_511: -512 to 511.
14055 @end smallexample
14057 The following built-in functions map directly to a particular MIPS DSP
14058 instruction.  Please refer to the architecture specification
14059 for details on what each instruction does.
14061 @smallexample
14062 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14063 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14064 q31 __builtin_mips_addq_s_w (q31, q31)
14065 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14066 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14067 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14068 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14069 q31 __builtin_mips_subq_s_w (q31, q31)
14070 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14071 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14072 i32 __builtin_mips_addsc (i32, i32)
14073 i32 __builtin_mips_addwc (i32, i32)
14074 i32 __builtin_mips_modsub (i32, i32)
14075 i32 __builtin_mips_raddu_w_qb (v4i8)
14076 v2q15 __builtin_mips_absq_s_ph (v2q15)
14077 q31 __builtin_mips_absq_s_w (q31)
14078 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14079 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14080 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14081 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14082 q31 __builtin_mips_preceq_w_phl (v2q15)
14083 q31 __builtin_mips_preceq_w_phr (v2q15)
14084 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14085 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14086 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14087 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14088 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14089 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14090 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14091 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14092 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14093 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14094 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14095 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14096 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14097 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14098 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14099 q31 __builtin_mips_shll_s_w (q31, i32)
14100 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14101 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14102 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14103 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14104 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14105 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14106 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14107 q31 __builtin_mips_shra_r_w (q31, i32)
14108 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14109 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14110 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14111 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14112 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14113 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14114 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14115 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14116 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14117 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14118 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14119 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14120 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14121 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14122 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14123 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14124 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14125 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14126 i32 __builtin_mips_bitrev (i32)
14127 i32 __builtin_mips_insv (i32, i32)
14128 v4i8 __builtin_mips_repl_qb (imm0_255)
14129 v4i8 __builtin_mips_repl_qb (i32)
14130 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14131 v2q15 __builtin_mips_repl_ph (i32)
14132 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14133 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14134 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14135 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14136 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14137 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14138 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14139 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14140 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14141 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14142 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14143 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14144 i32 __builtin_mips_extr_w (a64, imm0_31)
14145 i32 __builtin_mips_extr_w (a64, i32)
14146 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14147 i32 __builtin_mips_extr_s_h (a64, i32)
14148 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14149 i32 __builtin_mips_extr_rs_w (a64, i32)
14150 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14151 i32 __builtin_mips_extr_r_w (a64, i32)
14152 i32 __builtin_mips_extp (a64, imm0_31)
14153 i32 __builtin_mips_extp (a64, i32)
14154 i32 __builtin_mips_extpdp (a64, imm0_31)
14155 i32 __builtin_mips_extpdp (a64, i32)
14156 a64 __builtin_mips_shilo (a64, imm_n32_31)
14157 a64 __builtin_mips_shilo (a64, i32)
14158 a64 __builtin_mips_mthlip (a64, i32)
14159 void __builtin_mips_wrdsp (i32, imm0_63)
14160 i32 __builtin_mips_rddsp (imm0_63)
14161 i32 __builtin_mips_lbux (void *, i32)
14162 i32 __builtin_mips_lhx (void *, i32)
14163 i32 __builtin_mips_lwx (void *, i32)
14164 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14165 i32 __builtin_mips_bposge32 (void)
14166 a64 __builtin_mips_madd (a64, i32, i32);
14167 a64 __builtin_mips_maddu (a64, ui32, ui32);
14168 a64 __builtin_mips_msub (a64, i32, i32);
14169 a64 __builtin_mips_msubu (a64, ui32, ui32);
14170 a64 __builtin_mips_mult (i32, i32);
14171 a64 __builtin_mips_multu (ui32, ui32);
14172 @end smallexample
14174 The following built-in functions map directly to a particular MIPS DSP REV 2
14175 instruction.  Please refer to the architecture specification
14176 for details on what each instruction does.
14178 @smallexample
14179 v4q7 __builtin_mips_absq_s_qb (v4q7);
14180 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14181 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14182 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14183 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14184 i32 __builtin_mips_append (i32, i32, imm0_31);
14185 i32 __builtin_mips_balign (i32, i32, imm0_3);
14186 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14187 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14188 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14189 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14190 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14191 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14192 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14193 q31 __builtin_mips_mulq_rs_w (q31, q31);
14194 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14195 q31 __builtin_mips_mulq_s_w (q31, q31);
14196 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14197 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14198 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14199 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14200 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14201 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14202 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14203 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14204 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14205 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14206 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14207 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14208 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14209 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14210 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14211 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14212 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14213 q31 __builtin_mips_addqh_w (q31, q31);
14214 q31 __builtin_mips_addqh_r_w (q31, q31);
14215 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14216 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14217 q31 __builtin_mips_subqh_w (q31, q31);
14218 q31 __builtin_mips_subqh_r_w (q31, q31);
14219 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14220 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14221 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14222 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14223 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14224 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14225 @end smallexample
14228 @node MIPS Paired-Single Support
14229 @subsection MIPS Paired-Single Support
14231 The MIPS64 architecture includes a number of instructions that
14232 operate on pairs of single-precision floating-point values.
14233 Each pair is packed into a 64-bit floating-point register,
14234 with one element being designated the ``upper half'' and
14235 the other being designated the ``lower half''.
14237 GCC supports paired-single operations using both the generic
14238 vector extensions (@pxref{Vector Extensions}) and a collection of
14239 MIPS-specific built-in functions.  Both kinds of support are
14240 enabled by the @option{-mpaired-single} command-line option.
14242 The vector type associated with paired-single values is usually
14243 called @code{v2sf}.  It can be defined in C as follows:
14245 @smallexample
14246 typedef float v2sf __attribute__ ((vector_size (8)));
14247 @end smallexample
14249 @code{v2sf} values are initialized in the same way as aggregates.
14250 For example:
14252 @smallexample
14253 v2sf a = @{1.5, 9.1@};
14254 v2sf b;
14255 float e, f;
14256 b = (v2sf) @{e, f@};
14257 @end smallexample
14259 @emph{Note:} The CPU's endianness determines which value is stored in
14260 the upper half of a register and which value is stored in the lower half.
14261 On little-endian targets, the first value is the lower one and the second
14262 value is the upper one.  The opposite order applies to big-endian targets.
14263 For example, the code above sets the lower half of @code{a} to
14264 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14266 @node MIPS Loongson Built-in Functions
14267 @subsection MIPS Loongson Built-in Functions
14269 GCC provides intrinsics to access the SIMD instructions provided by the
14270 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
14271 available after inclusion of the @code{loongson.h} header file,
14272 operate on the following 64-bit vector types:
14274 @itemize
14275 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14276 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14277 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14278 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14279 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14280 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14281 @end itemize
14283 The intrinsics provided are listed below; each is named after the
14284 machine instruction to which it corresponds, with suffixes added as
14285 appropriate to distinguish intrinsics that expand to the same machine
14286 instruction yet have different argument types.  Refer to the architecture
14287 documentation for a description of the functionality of each
14288 instruction.
14290 @smallexample
14291 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14292 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14293 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14294 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14295 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14296 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14297 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14298 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14299 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14300 uint64_t paddd_u (uint64_t s, uint64_t t);
14301 int64_t paddd_s (int64_t s, int64_t t);
14302 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14303 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14304 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14305 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14306 uint64_t pandn_ud (uint64_t s, uint64_t t);
14307 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14308 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14309 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14310 int64_t pandn_sd (int64_t s, int64_t t);
14311 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14312 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14313 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14314 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14315 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14316 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14317 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14318 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14319 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14320 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14321 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14322 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14323 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14324 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14325 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14326 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14327 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14328 uint16x4_t pextrh_u (uint16x4_t s, int field);
14329 int16x4_t pextrh_s (int16x4_t s, int field);
14330 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14331 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14332 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14333 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14334 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14335 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14336 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14337 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14338 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14339 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14340 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14341 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14342 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14343 uint8x8_t pmovmskb_u (uint8x8_t s);
14344 int8x8_t pmovmskb_s (int8x8_t s);
14345 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14346 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14347 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14348 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14349 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14350 uint16x4_t biadd (uint8x8_t s);
14351 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14352 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14353 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14354 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14355 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14356 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14357 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14358 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14359 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14360 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14361 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14362 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14363 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14364 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14365 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14366 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14367 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14368 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14369 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14370 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14371 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14372 uint64_t psubd_u (uint64_t s, uint64_t t);
14373 int64_t psubd_s (int64_t s, int64_t t);
14374 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14375 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14376 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14377 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14378 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14379 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14380 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14381 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14382 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14383 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14384 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14385 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14386 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14387 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14388 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14389 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14390 @end smallexample
14392 @menu
14393 * Paired-Single Arithmetic::
14394 * Paired-Single Built-in Functions::
14395 * MIPS-3D Built-in Functions::
14396 @end menu
14398 @node Paired-Single Arithmetic
14399 @subsubsection Paired-Single Arithmetic
14401 The table below lists the @code{v2sf} operations for which hardware
14402 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14403 values and @code{x} is an integral value.
14405 @multitable @columnfractions .50 .50
14406 @item C code @tab MIPS instruction
14407 @item @code{a + b} @tab @code{add.ps}
14408 @item @code{a - b} @tab @code{sub.ps}
14409 @item @code{-a} @tab @code{neg.ps}
14410 @item @code{a * b} @tab @code{mul.ps}
14411 @item @code{a * b + c} @tab @code{madd.ps}
14412 @item @code{a * b - c} @tab @code{msub.ps}
14413 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14414 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14415 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14416 @end multitable
14418 Note that the multiply-accumulate instructions can be disabled
14419 using the command-line option @code{-mno-fused-madd}.
14421 @node Paired-Single Built-in Functions
14422 @subsubsection Paired-Single Built-in Functions
14424 The following paired-single functions map directly to a particular
14425 MIPS instruction.  Please refer to the architecture specification
14426 for details on what each instruction does.
14428 @table @code
14429 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14430 Pair lower lower (@code{pll.ps}).
14432 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14433 Pair upper lower (@code{pul.ps}).
14435 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14436 Pair lower upper (@code{plu.ps}).
14438 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14439 Pair upper upper (@code{puu.ps}).
14441 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14442 Convert pair to paired single (@code{cvt.ps.s}).
14444 @item float __builtin_mips_cvt_s_pl (v2sf)
14445 Convert pair lower to single (@code{cvt.s.pl}).
14447 @item float __builtin_mips_cvt_s_pu (v2sf)
14448 Convert pair upper to single (@code{cvt.s.pu}).
14450 @item v2sf __builtin_mips_abs_ps (v2sf)
14451 Absolute value (@code{abs.ps}).
14453 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14454 Align variable (@code{alnv.ps}).
14456 @emph{Note:} The value of the third parameter must be 0 or 4
14457 modulo 8, otherwise the result is unpredictable.  Please read the
14458 instruction description for details.
14459 @end table
14461 The following multi-instruction functions are also available.
14462 In each case, @var{cond} can be any of the 16 floating-point conditions:
14463 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14464 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14465 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14467 @table @code
14468 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14469 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14470 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14471 @code{movt.ps}/@code{movf.ps}).
14473 The @code{movt} functions return the value @var{x} computed by:
14475 @smallexample
14476 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14477 mov.ps @var{x},@var{c}
14478 movt.ps @var{x},@var{d},@var{cc}
14479 @end smallexample
14481 The @code{movf} functions are similar but use @code{movf.ps} instead
14482 of @code{movt.ps}.
14484 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14485 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14486 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14487 @code{bc1t}/@code{bc1f}).
14489 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14490 and return either the upper or lower half of the result.  For example:
14492 @smallexample
14493 v2sf a, b;
14494 if (__builtin_mips_upper_c_eq_ps (a, b))
14495   upper_halves_are_equal ();
14496 else
14497   upper_halves_are_unequal ();
14499 if (__builtin_mips_lower_c_eq_ps (a, b))
14500   lower_halves_are_equal ();
14501 else
14502   lower_halves_are_unequal ();
14503 @end smallexample
14504 @end table
14506 @node MIPS-3D Built-in Functions
14507 @subsubsection MIPS-3D Built-in Functions
14509 The MIPS-3D Application-Specific Extension (ASE) includes additional
14510 paired-single instructions that are designed to improve the performance
14511 of 3D graphics operations.  Support for these instructions is controlled
14512 by the @option{-mips3d} command-line option.
14514 The functions listed below map directly to a particular MIPS-3D
14515 instruction.  Please refer to the architecture specification for
14516 more details on what each instruction does.
14518 @table @code
14519 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14520 Reduction add (@code{addr.ps}).
14522 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14523 Reduction multiply (@code{mulr.ps}).
14525 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14526 Convert paired single to paired word (@code{cvt.pw.ps}).
14528 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14529 Convert paired word to paired single (@code{cvt.ps.pw}).
14531 @item float __builtin_mips_recip1_s (float)
14532 @itemx double __builtin_mips_recip1_d (double)
14533 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14534 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14536 @item float __builtin_mips_recip2_s (float, float)
14537 @itemx double __builtin_mips_recip2_d (double, double)
14538 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14539 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14541 @item float __builtin_mips_rsqrt1_s (float)
14542 @itemx double __builtin_mips_rsqrt1_d (double)
14543 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14544 Reduced-precision reciprocal square root (sequence step 1)
14545 (@code{rsqrt1.@var{fmt}}).
14547 @item float __builtin_mips_rsqrt2_s (float, float)
14548 @itemx double __builtin_mips_rsqrt2_d (double, double)
14549 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14550 Reduced-precision reciprocal square root (sequence step 2)
14551 (@code{rsqrt2.@var{fmt}}).
14552 @end table
14554 The following multi-instruction functions are also available.
14555 In each case, @var{cond} can be any of the 16 floating-point conditions:
14556 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14557 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14558 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14560 @table @code
14561 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14562 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14563 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14564 @code{bc1t}/@code{bc1f}).
14566 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14567 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14568 For example:
14570 @smallexample
14571 float a, b;
14572 if (__builtin_mips_cabs_eq_s (a, b))
14573   true ();
14574 else
14575   false ();
14576 @end smallexample
14578 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14579 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14580 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14581 @code{bc1t}/@code{bc1f}).
14583 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14584 and return either the upper or lower half of the result.  For example:
14586 @smallexample
14587 v2sf a, b;
14588 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14589   upper_halves_are_equal ();
14590 else
14591   upper_halves_are_unequal ();
14593 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14594   lower_halves_are_equal ();
14595 else
14596   lower_halves_are_unequal ();
14597 @end smallexample
14599 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14600 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14601 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14602 @code{movt.ps}/@code{movf.ps}).
14604 The @code{movt} functions return the value @var{x} computed by:
14606 @smallexample
14607 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14608 mov.ps @var{x},@var{c}
14609 movt.ps @var{x},@var{d},@var{cc}
14610 @end smallexample
14612 The @code{movf} functions are similar but use @code{movf.ps} instead
14613 of @code{movt.ps}.
14615 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14616 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14617 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14618 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14619 Comparison of two paired-single values
14620 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14621 @code{bc1any2t}/@code{bc1any2f}).
14623 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14624 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
14625 result is true and the @code{all} forms return true if both results are true.
14626 For example:
14628 @smallexample
14629 v2sf a, b;
14630 if (__builtin_mips_any_c_eq_ps (a, b))
14631   one_is_true ();
14632 else
14633   both_are_false ();
14635 if (__builtin_mips_all_c_eq_ps (a, b))
14636   both_are_true ();
14637 else
14638   one_is_false ();
14639 @end smallexample
14641 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14642 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14643 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14644 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14645 Comparison of four paired-single values
14646 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14647 @code{bc1any4t}/@code{bc1any4f}).
14649 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14650 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14651 The @code{any} forms return true if any of the four results are true
14652 and the @code{all} forms return true if all four results are true.
14653 For example:
14655 @smallexample
14656 v2sf a, b, c, d;
14657 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14658   some_are_true ();
14659 else
14660   all_are_false ();
14662 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14663   all_are_true ();
14664 else
14665   some_are_false ();
14666 @end smallexample
14667 @end table
14669 @node MIPS SIMD Architecture (MSA) Support
14670 @subsection MIPS SIMD Architecture (MSA) Support
14672 @menu
14673 * MIPS SIMD Architecture Built-in Functions::
14674 @end menu
14676 GCC provides intrinsics to access the SIMD instructions provided by the
14677 MSA MIPS SIMD Architecture.  The interface is made available by including
14678 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14679 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14680 @code{__msa_*}.
14682 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14683 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14684 data elements.  The following vectors typedefs are included in @code{msa.h}:
14685 @itemize
14686 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14687 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14688 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14689 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14690 @item @code{v4i32}, a vector of four signed 32-bit integers;
14691 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14692 @item @code{v2i64}, a vector of two signed 64-bit integers;
14693 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14694 @item @code{v4f32}, a vector of four 32-bit floats;
14695 @item @code{v2f64}, a vector of two 64-bit doubles.
14696 @end itemize
14698 Instructions and corresponding built-ins may have additional restrictions and/or
14699 input/output values manipulated:
14700 @itemize
14701 @item @code{imm0_1}, an integer literal in range 0 to 1;
14702 @item @code{imm0_3}, an integer literal in range 0 to 3;
14703 @item @code{imm0_7}, an integer literal in range 0 to 7;
14704 @item @code{imm0_15}, an integer literal in range 0 to 15;
14705 @item @code{imm0_31}, an integer literal in range 0 to 31;
14706 @item @code{imm0_63}, an integer literal in range 0 to 63;
14707 @item @code{imm0_255}, an integer literal in range 0 to 255;
14708 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14709 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14710 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14711 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14712 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14713 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14714 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14715 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14716 @item @code{imm1_4}, an integer literal in range 1 to 4;
14717 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14718 @end itemize
14720 @smallexample
14722 typedef int i32;
14723 #if __LONG_MAX__ == __LONG_LONG_MAX__
14724 typedef long i64;
14725 #else
14726 typedef long long i64;
14727 #endif
14729 typedef unsigned int u32;
14730 #if __LONG_MAX__ == __LONG_LONG_MAX__
14731 typedef unsigned long u64;
14732 #else
14733 typedef unsigned long long u64;
14734 #endif
14736 typedef double f64;
14737 typedef float f32;
14739 @end smallexample
14741 @node MIPS SIMD Architecture Built-in Functions
14742 @subsubsection MIPS SIMD Architecture Built-in Functions
14744 The intrinsics provided are listed below; each is named after the
14745 machine instruction.
14747 @smallexample
14748 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14749 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14750 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14751 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14753 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14754 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14755 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14756 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14758 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14759 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14760 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14761 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14763 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14764 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14765 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14766 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14768 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14769 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14770 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14771 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14773 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14774 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14775 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14776 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14778 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14780 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14782 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14783 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14784 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14785 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14787 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14788 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14789 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14790 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14792 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14793 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14794 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14795 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14797 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14798 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14799 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14800 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14802 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14803 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14804 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14805 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14807 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14808 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14809 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14810 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14812 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14813 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14814 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14815 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14817 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14818 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14819 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14820 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14822 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14823 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14824 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14825 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14827 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14828 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14829 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14830 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14832 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14833 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14834 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14835 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14837 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14838 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14839 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14840 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14842 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14844 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14846 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14848 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14850 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14851 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14852 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14853 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14855 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14856 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14857 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14858 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14860 i32 __builtin_msa_bnz_b (v16u8);
14861 i32 __builtin_msa_bnz_h (v8u16);
14862 i32 __builtin_msa_bnz_w (v4u32);
14863 i32 __builtin_msa_bnz_d (v2u64);
14865 i32 __builtin_msa_bnz_v (v16u8);
14867 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14869 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14871 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14872 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14873 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14874 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14876 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14877 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14878 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14879 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14881 i32 __builtin_msa_bz_b (v16u8);
14882 i32 __builtin_msa_bz_h (v8u16);
14883 i32 __builtin_msa_bz_w (v4u32);
14884 i32 __builtin_msa_bz_d (v2u64);
14886 i32 __builtin_msa_bz_v (v16u8);
14888 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14889 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14890 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14891 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14893 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14894 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14895 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14896 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14898 i32 __builtin_msa_cfcmsa (imm0_31);
14900 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14901 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14902 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14903 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14905 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14906 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14907 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14908 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14910 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14911 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14912 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14913 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14915 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14916 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14917 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14918 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14920 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14921 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14922 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14923 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14925 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14926 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14927 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14928 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14930 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14931 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14932 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14933 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14935 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14936 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14937 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14938 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14940 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14941 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14942 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14943 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14945 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14946 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14947 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14948 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14950 void __builtin_msa_ctcmsa (imm0_31, i32);
14952 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14953 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14954 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14955 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14957 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14958 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14959 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14960 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14962 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14963 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14964 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14966 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14967 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14968 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14970 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14971 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14972 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14974 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14975 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14976 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14978 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14979 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14980 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14982 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14983 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14984 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14986 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14987 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14989 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14990 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14992 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14993 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14995 v4i32 __builtin_msa_fclass_w (v4f32);
14996 v2i64 __builtin_msa_fclass_d (v2f64);
14998 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14999 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15001 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15002 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15004 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15005 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15007 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15008 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15010 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15011 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15013 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15014 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15016 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15017 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15019 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15020 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15022 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15023 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15025 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15026 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15028 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15029 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15031 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15032 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15034 v4f32 __builtin_msa_fexupl_w (v8i16);
15035 v2f64 __builtin_msa_fexupl_d (v4f32);
15037 v4f32 __builtin_msa_fexupr_w (v8i16);
15038 v2f64 __builtin_msa_fexupr_d (v4f32);
15040 v4f32 __builtin_msa_ffint_s_w (v4i32);
15041 v2f64 __builtin_msa_ffint_s_d (v2i64);
15043 v4f32 __builtin_msa_ffint_u_w (v4u32);
15044 v2f64 __builtin_msa_ffint_u_d (v2u64);
15046 v4f32 __builtin_msa_ffql_w (v8i16);
15047 v2f64 __builtin_msa_ffql_d (v4i32);
15049 v4f32 __builtin_msa_ffqr_w (v8i16);
15050 v2f64 __builtin_msa_ffqr_d (v4i32);
15052 v16i8 __builtin_msa_fill_b (i32);
15053 v8i16 __builtin_msa_fill_h (i32);
15054 v4i32 __builtin_msa_fill_w (i32);
15055 v2i64 __builtin_msa_fill_d (i64);
15057 v4f32 __builtin_msa_flog2_w (v4f32);
15058 v2f64 __builtin_msa_flog2_d (v2f64);
15060 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15061 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15063 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15064 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15066 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15067 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15069 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15070 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15072 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15073 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15075 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15076 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15078 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15079 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15081 v4f32 __builtin_msa_frint_w (v4f32);
15082 v2f64 __builtin_msa_frint_d (v2f64);
15084 v4f32 __builtin_msa_frcp_w (v4f32);
15085 v2f64 __builtin_msa_frcp_d (v2f64);
15087 v4f32 __builtin_msa_frsqrt_w (v4f32);
15088 v2f64 __builtin_msa_frsqrt_d (v2f64);
15090 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15091 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15093 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15094 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15096 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15097 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15099 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15100 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15102 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15103 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15105 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15106 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15108 v4f32 __builtin_msa_fsqrt_w (v4f32);
15109 v2f64 __builtin_msa_fsqrt_d (v2f64);
15111 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15112 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15114 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15115 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15117 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15118 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15120 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15121 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15123 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15124 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15126 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15127 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15129 v4i32 __builtin_msa_ftint_s_w (v4f32);
15130 v2i64 __builtin_msa_ftint_s_d (v2f64);
15132 v4u32 __builtin_msa_ftint_u_w (v4f32);
15133 v2u64 __builtin_msa_ftint_u_d (v2f64);
15135 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15136 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15138 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15139 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15141 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15142 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15144 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15145 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15146 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15148 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15149 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15150 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15152 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15153 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15154 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15156 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15157 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15158 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15160 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15161 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15162 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15163 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15165 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15166 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15167 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15168 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15170 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15171 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15172 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15173 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15175 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15176 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15177 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15178 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15180 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15181 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15182 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15183 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15185 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15186 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15187 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15188 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15190 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15191 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15192 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15193 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15195 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15196 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15197 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15198 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15200 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15201 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15203 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15204 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15206 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15207 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15208 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15209 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15211 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15212 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15213 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15214 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15216 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15217 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15218 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15219 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15221 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15222 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15223 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15224 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15226 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15227 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15228 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15229 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15231 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15232 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15233 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15234 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15236 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15237 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15238 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15239 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15241 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15242 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15243 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15244 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15246 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15247 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15248 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15249 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15251 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15252 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15253 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15254 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15256 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15257 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15258 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15259 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15261 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15262 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15263 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15264 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15266 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15267 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15268 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15269 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15271 v16i8 __builtin_msa_move_v (v16i8);
15273 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15274 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15276 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15277 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15279 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15280 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15281 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15282 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15284 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15285 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15287 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15288 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15290 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15291 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15292 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15293 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15295 v16i8 __builtin_msa_nloc_b (v16i8);
15296 v8i16 __builtin_msa_nloc_h (v8i16);
15297 v4i32 __builtin_msa_nloc_w (v4i32);
15298 v2i64 __builtin_msa_nloc_d (v2i64);
15300 v16i8 __builtin_msa_nlzc_b (v16i8);
15301 v8i16 __builtin_msa_nlzc_h (v8i16);
15302 v4i32 __builtin_msa_nlzc_w (v4i32);
15303 v2i64 __builtin_msa_nlzc_d (v2i64);
15305 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15307 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15309 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15311 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15313 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15314 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15315 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15316 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15318 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15319 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15320 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15321 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15323 v16i8 __builtin_msa_pcnt_b (v16i8);
15324 v8i16 __builtin_msa_pcnt_h (v8i16);
15325 v4i32 __builtin_msa_pcnt_w (v4i32);
15326 v2i64 __builtin_msa_pcnt_d (v2i64);
15328 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15329 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15330 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15331 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15333 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15334 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15335 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15336 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15338 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15339 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15340 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15342 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15343 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15344 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15345 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15347 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15348 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15349 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15350 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15352 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15353 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15354 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15355 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15357 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15358 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15359 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15360 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15362 v16i8 __builtin_msa_splat_b (v16i8, i32);
15363 v8i16 __builtin_msa_splat_h (v8i16, i32);
15364 v4i32 __builtin_msa_splat_w (v4i32, i32);
15365 v2i64 __builtin_msa_splat_d (v2i64, i32);
15367 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15368 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15369 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15370 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15372 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15373 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15374 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15375 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15377 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15378 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15379 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15380 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15382 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15383 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15384 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15385 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15387 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15388 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15389 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15390 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15392 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15393 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15394 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15395 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15397 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15398 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15399 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15400 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15402 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15403 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15404 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15405 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15407 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15408 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15409 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15410 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15412 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15413 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15414 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15415 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15417 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15418 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15419 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15420 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15422 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15423 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15424 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15425 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15427 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15428 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15429 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15430 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15432 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15433 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15434 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15435 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15437 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15438 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15439 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15440 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15442 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15443 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15444 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15445 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15447 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15448 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15449 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15450 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15452 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15454 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15455 @end smallexample
15457 @node Other MIPS Built-in Functions
15458 @subsection Other MIPS Built-in Functions
15460 GCC provides other MIPS-specific built-in functions:
15462 @table @code
15463 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15464 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15465 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15466 when this function is available.
15468 @item unsigned int __builtin_mips_get_fcsr (void)
15469 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15470 Get and set the contents of the floating-point control and status register
15471 (FPU control register 31).  These functions are only available in hard-float
15472 code but can be called in both MIPS16 and non-MIPS16 contexts.
15474 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15475 register except the condition codes, which GCC assumes are preserved.
15476 @end table
15478 @node MSP430 Built-in Functions
15479 @subsection MSP430 Built-in Functions
15481 GCC provides a couple of special builtin functions to aid in the
15482 writing of interrupt handlers in C.
15484 @table @code
15485 @item __bic_SR_register_on_exit (int @var{mask})
15486 This clears the indicated bits in the saved copy of the status register
15487 currently residing on the stack.  This only works inside interrupt
15488 handlers and the changes to the status register will only take affect
15489 once the handler returns.
15491 @item __bis_SR_register_on_exit (int @var{mask})
15492 This sets the indicated bits in the saved copy of the status register
15493 currently residing on the stack.  This only works inside interrupt
15494 handlers and the changes to the status register will only take affect
15495 once the handler returns.
15497 @item __delay_cycles (long long @var{cycles})
15498 This inserts an instruction sequence that takes exactly @var{cycles}
15499 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15500 may use jumps, loops, or no-ops, and does not interfere with any other
15501 instructions.  Note that @var{cycles} must be a compile-time constant
15502 integer - that is, you must pass a number, not a variable that may be
15503 optimized to a constant later.  The number of cycles delayed by this
15504 builtin is exact.
15505 @end table
15507 @node NDS32 Built-in Functions
15508 @subsection NDS32 Built-in Functions
15510 These built-in functions are available for the NDS32 target:
15512 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15513 Insert an ISYNC instruction into the instruction stream where
15514 @var{addr} is an instruction address for serialization.
15515 @end deftypefn
15517 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15518 Insert an ISB instruction into the instruction stream.
15519 @end deftypefn
15521 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15522 Return the content of a system register which is mapped by @var{sr}.
15523 @end deftypefn
15525 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15526 Return the content of a user space register which is mapped by @var{usr}.
15527 @end deftypefn
15529 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15530 Move the @var{value} to a system register which is mapped by @var{sr}.
15531 @end deftypefn
15533 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15534 Move the @var{value} to a user space register which is mapped by @var{usr}.
15535 @end deftypefn
15537 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15538 Enable global interrupt.
15539 @end deftypefn
15541 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15542 Disable global interrupt.
15543 @end deftypefn
15545 @node picoChip Built-in Functions
15546 @subsection picoChip Built-in Functions
15548 GCC provides an interface to selected machine instructions from the
15549 picoChip instruction set.
15551 @table @code
15552 @item int __builtin_sbc (int @var{value})
15553 Sign bit count.  Return the number of consecutive bits in @var{value}
15554 that have the same value as the sign bit.  The result is the number of
15555 leading sign bits minus one, giving the number of redundant sign bits in
15556 @var{value}.
15558 @item int __builtin_byteswap (int @var{value})
15559 Byte swap.  Return the result of swapping the upper and lower bytes of
15560 @var{value}.
15562 @item int __builtin_brev (int @var{value})
15563 Bit reversal.  Return the result of reversing the bits in
15564 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15565 and so on.
15567 @item int __builtin_adds (int @var{x}, int @var{y})
15568 Saturating addition.  Return the result of adding @var{x} and @var{y},
15569 storing the value 32767 if the result overflows.
15571 @item int __builtin_subs (int @var{x}, int @var{y})
15572 Saturating subtraction.  Return the result of subtracting @var{y} from
15573 @var{x}, storing the value @minus{}32768 if the result overflows.
15575 @item void __builtin_halt (void)
15576 Halt.  The processor stops execution.  This built-in is useful for
15577 implementing assertions.
15579 @end table
15581 @node Basic PowerPC Built-in Functions
15582 @subsection Basic PowerPC Built-in Functions
15584 @menu
15585 * Basic PowerPC Built-in Functions Available on all Configurations::
15586 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15587 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15588 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15589 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15590 @end menu
15592 This section describes PowerPC built-in functions that do not require
15593 the inclusion of any special header files to declare prototypes or
15594 provide macro definitions.  The sections that follow describe
15595 additional PowerPC built-in functions.
15597 @node Basic PowerPC Built-in Functions Available on all Configurations
15598 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15600 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15601 This function is a @code{nop} on the PowerPC platform and is included solely
15602 to maintain API compatibility with the x86 builtins.
15603 @end deftypefn
15605 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15606 This function returns a value of @code{1} if the run-time CPU is of type
15607 @var{cpuname} and returns @code{0} otherwise
15609 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15610 which exports the hardware capability bits.  GCC defines the macro
15611 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15612 built-in function is fully supported.
15614 If GCC was configured to use a GLIBC before 2.23, the built-in
15615 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15616 issues a warning.
15618 The following CPU names can be detected:
15620 @table @samp
15621 @item power9
15622 IBM POWER9 Server CPU.
15623 @item power8
15624 IBM POWER8 Server CPU.
15625 @item power7
15626 IBM POWER7 Server CPU.
15627 @item power6x
15628 IBM POWER6 Server CPU (RAW mode).
15629 @item power6
15630 IBM POWER6 Server CPU (Architected mode).
15631 @item power5+
15632 IBM POWER5+ Server CPU.
15633 @item power5
15634 IBM POWER5 Server CPU.
15635 @item ppc970
15636 IBM 970 Server CPU (ie, Apple G5).
15637 @item power4
15638 IBM POWER4 Server CPU.
15639 @item ppca2
15640 IBM A2 64-bit Embedded CPU
15641 @item ppc476
15642 IBM PowerPC 476FP 32-bit Embedded CPU.
15643 @item ppc464
15644 IBM PowerPC 464 32-bit Embedded CPU.
15645 @item ppc440
15646 PowerPC 440 32-bit Embedded CPU.
15647 @item ppc405
15648 PowerPC 405 32-bit Embedded CPU.
15649 @item ppc-cell-be
15650 IBM PowerPC Cell Broadband Engine Architecture CPU.
15651 @end table
15653 Here is an example:
15654 @smallexample
15655 #ifdef __BUILTIN_CPU_SUPPORTS__
15656   if (__builtin_cpu_is ("power8"))
15657     @{
15658        do_power8 (); // POWER8 specific implementation.
15659     @}
15660   else
15661 #endif
15662     @{
15663        do_generic (); // Generic implementation.
15664     @}
15665 @end smallexample
15666 @end deftypefn
15668 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15669 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15670 feature @var{feature} and returns @code{0} otherwise.
15672 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15673 newer which exports the hardware capability bits.  GCC defines the
15674 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15675 @code{__builtin_cpu_supports} built-in function is fully supported.
15677 If GCC was configured to use a GLIBC before 2.23, the built-in
15678 function @code{__builtin_cpu_suports} always returns a 0 and the
15679 compiler issues a warning.
15681 The following features can be
15682 detected:
15684 @table @samp
15685 @item 4xxmac
15686 4xx CPU has a Multiply Accumulator.
15687 @item altivec
15688 CPU has a SIMD/Vector Unit.
15689 @item arch_2_05
15690 CPU supports ISA 2.05 (eg, POWER6)
15691 @item arch_2_06
15692 CPU supports ISA 2.06 (eg, POWER7)
15693 @item arch_2_07
15694 CPU supports ISA 2.07 (eg, POWER8)
15695 @item arch_3_00
15696 CPU supports ISA 3.0 (eg, POWER9)
15697 @item archpmu
15698 CPU supports the set of compatible performance monitoring events.
15699 @item booke
15700 CPU supports the Embedded ISA category.
15701 @item cellbe
15702 CPU has a CELL broadband engine.
15703 @item darn
15704 CPU supports the @code{darn} (deliver a random number) instruction.
15705 @item dfp
15706 CPU has a decimal floating point unit.
15707 @item dscr
15708 CPU supports the data stream control register.
15709 @item ebb
15710 CPU supports event base branching.
15711 @item efpdouble
15712 CPU has a SPE double precision floating point unit.
15713 @item efpsingle
15714 CPU has a SPE single precision floating point unit.
15715 @item fpu
15716 CPU has a floating point unit.
15717 @item htm
15718 CPU has hardware transaction memory instructions.
15719 @item htm-nosc
15720 Kernel aborts hardware transactions when a syscall is made.
15721 @item htm-no-suspend
15722 CPU supports hardware transaction memory but does not support the
15723 @code{tsuspend.} instruction.
15724 @item ic_snoop
15725 CPU supports icache snooping capabilities.
15726 @item ieee128
15727 CPU supports 128-bit IEEE binary floating point instructions.
15728 @item isel
15729 CPU supports the integer select instruction.
15730 @item mmu
15731 CPU has a memory management unit.
15732 @item notb
15733 CPU does not have a timebase (eg, 601 and 403gx).
15734 @item pa6t
15735 CPU supports the PA Semi 6T CORE ISA.
15736 @item power4
15737 CPU supports ISA 2.00 (eg, POWER4)
15738 @item power5
15739 CPU supports ISA 2.02 (eg, POWER5)
15740 @item power5+
15741 CPU supports ISA 2.03 (eg, POWER5+)
15742 @item power6x
15743 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15744 @item ppc32
15745 CPU supports 32-bit mode execution.
15746 @item ppc601
15747 CPU supports the old POWER ISA (eg, 601)
15748 @item ppc64
15749 CPU supports 64-bit mode execution.
15750 @item ppcle
15751 CPU supports a little-endian mode that uses address swizzling.
15752 @item scv
15753 Kernel supports system call vectored.
15754 @item smt
15755 CPU support simultaneous multi-threading.
15756 @item spe
15757 CPU has a signal processing extension unit.
15758 @item tar
15759 CPU supports the target address register.
15760 @item true_le
15761 CPU supports true little-endian mode.
15762 @item ucache
15763 CPU has unified I/D cache.
15764 @item vcrypto
15765 CPU supports the vector cryptography instructions.
15766 @item vsx
15767 CPU supports the vector-scalar extension.
15768 @end table
15770 Here is an example:
15771 @smallexample
15772 #ifdef __BUILTIN_CPU_SUPPORTS__
15773   if (__builtin_cpu_supports ("fpu"))
15774     @{
15775        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15776     @}
15777   else
15778 #endif
15779     @{
15780        dst = __fadd (src1, src2); // Software FP addition function.
15781     @}
15782 @end smallexample
15783 @end deftypefn
15785 The following built-in functions are also available on all PowerPC
15786 processors:
15787 @smallexample
15788 uint64_t __builtin_ppc_get_timebase ();
15789 unsigned long __builtin_ppc_mftb ();
15790 __ibm128 __builtin_unpack_ibm128 (__ibm128, int);
15791 __ibm128 __builtin_pack_ibm128 (double, double);
15792 double __builtin_mffs (void);
15793 void __builtin_mtfsb0 (const int);
15794 void __builtin_mtfsb1 (const int);
15795 void __builtin_set_fpscr_rn (int);
15796 @end smallexample
15798 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15799 functions generate instructions to read the Time Base Register.  The
15800 @code{__builtin_ppc_get_timebase} function may generate multiple
15801 instructions and always returns the 64 bits of the Time Base Register.
15802 The @code{__builtin_ppc_mftb} function always generates one instruction and
15803 returns the Time Base Register value as an unsigned long, throwing away
15804 the most significant word on 32-bit environments.  The @code{__builtin_mffs}
15805 return the value of the FPSCR register.  Note, ISA 3.0 supports the
15806 @code{__builtin_mffsl()} which permits software to read the control and
15807 non-sticky status bits in the FSPCR without the higher latency associated with
15808 accessing the sticky status bits.  The
15809 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
15810 as an argument.  The valid bit range is between 0 and 31.  The builtins map to
15811 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
15812 add 32.  Hence these instructions only modify the FPSCR[32:63] bits by
15813 changing the specified bit to a zero or one respectively.  The
15814 @code{__builtin_set_fpscr_rn} builtin allows changing both of the floating
15815 point rounding mode bits.  The argument is a 2-bit value.  The argument can
15816 either be a const int or stored in a variable. The builtin uses the ISA 3.0
15817 instruction @code{mffscrn} if available, otherwise it reads the FPSCR, masks
15818 the current rounding mode bits out and OR's in the new value.
15820 @node Basic PowerPC Built-in Functions Available on ISA 2.05
15821 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
15823 The basic built-in functions described in this section are
15824 available on the PowerPC family of processors starting with ISA 2.05
15825 or later.  Unless specific options are explicitly disabled on the
15826 command line, specifying option @option{-mcpu=power6} has the effect of
15827 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
15828 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
15829 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
15830 @option{-mrecip-precision} options.  Specify the
15831 @option{-maltivec} and @option{-mfpgpr} options explicitly in
15832 combination with the above options if they are desired.
15834 The following functions require option @option{-mcmpb}.
15835 @smallexample
15836 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15837 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15838 @end smallexample
15840 The @code{__builtin_cmpb} function
15841 performs a byte-wise compare on the contents of its two arguments,
15842 returning the result of the byte-wise comparison as the returned
15843 value.  For each byte comparison, the corresponding byte of the return
15844 value holds 0xff if the input bytes are equal and 0 if the input bytes
15845 are not equal.  If either of the arguments to this built-in function
15846 is wider than 32 bits, the function call expands into the form that
15847 expects @code{unsigned long long int} arguments
15848 which is only available on 64-bit targets.
15850 The following built-in functions are available
15851 when hardware decimal floating point
15852 (@option{-mhard-dfp}) is available:
15853 @smallexample
15854 void __builtin_set_fpscr_drn(int);
15855 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15856 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15857 _Decimal64 __builtin_denbcd (int, _Decimal64);
15858 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15859 _Decimal64 __builtin_diex (long long, _Decimal64);
15860 _Decimal128 _builtin_diexq (long long, _Decimal128);
15861 _Decimal64 __builtin_dscli (_Decimal64, int);
15862 _Decimal128 __builtin_dscliq (_Decimal128, int);
15863 _Decimal64 __builtin_dscri (_Decimal64, int);
15864 _Decimal128 __builtin_dscriq (_Decimal128, int);
15865 long long __builtin_dxex (_Decimal64);
15866 long long __builtin_dxexq (_Decimal128);
15867 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15868 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15870 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
15871 floating point rounding mode bits.  The argument is a 3-bit value.  The
15872 argument can either be a const int or the value can be stored in a variable.
15873 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
15874 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
15875 mode bits out and OR's in the new value.
15877 @end smallexample
15879 The following functions require @option{-mhard-float},
15880 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
15882 @smallexample
15883 double __builtin_recipdiv (double, double);
15884 float __builtin_recipdivf (float, float);
15885 double __builtin_rsqrt (double);
15886 float __builtin_rsqrtf (float);
15887 @end smallexample
15889 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15890 @code{__builtin_rsqrtf} functions generate multiple instructions to
15891 implement the reciprocal sqrt functionality using reciprocal sqrt
15892 estimate instructions.
15894 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15895 functions generate multiple instructions to implement division using
15896 the reciprocal estimate instructions.
15898 The following functions require @option{-mhard-float} and
15899 @option{-mmultiple} options.
15901 The @code{__builtin_unpack_longdouble} function takes a
15902 @code{long double} argument and a compile time constant of 0 or 1.  If
15903 the constant is 0, the first @code{double} within the
15904 @code{long double} is returned, otherwise the second @code{double}
15905 is returned.  The @code{__builtin_unpack_longdouble} function is only
15906 availble if @code{long double} uses the IBM extended double
15907 representation.
15909 The @code{__builtin_pack_longdouble} function takes two @code{double}
15910 arguments and returns a @code{long double} value that combines the two
15911 arguments.  The @code{__builtin_pack_longdouble} function is only
15912 availble if @code{long double} uses the IBM extended double
15913 representation.
15915 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
15916 argument and a compile time constant of 0 or 1.  If the constant is 0,
15917 the first @code{double} within the @code{__ibm128} is returned,
15918 otherwise the second @code{double} is returned.
15920 The @code{__builtin_pack_ibm128} function takes two @code{double}
15921 arguments and returns a @code{__ibm128} value that combines the two
15922 arguments.
15924 Additional built-in functions are available for the 64-bit PowerPC
15925 family of processors, for efficient use of 128-bit floating point
15926 (@code{__float128}) values.
15928 @node Basic PowerPC Built-in Functions Available on ISA 2.06
15929 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
15931 The basic built-in functions described in this section are
15932 available on the PowerPC family of processors starting with ISA 2.05
15933 or later.  Unless specific options are explicitly disabled on the
15934 command line, specifying option @option{-mcpu=power7} has the effect of
15935 enabling all the same options as for @option{-mcpu=power6} in
15936 addition to the @option{-maltivec}, @option{-mpopcntd}, and
15937 @option{-mvsx} options.
15939 The following basic built-in functions require @option{-mpopcntd}:
15940 @smallexample
15941 unsigned int __builtin_addg6s (unsigned int, unsigned int);
15942 long long __builtin_bpermd (long long, long long);
15943 unsigned int __builtin_cbcdtd (unsigned int);
15944 unsigned int __builtin_cdtbcd (unsigned int);
15945 long long __builtin_divde (long long, long long);
15946 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
15947 int __builtin_divwe (int, int);
15948 unsigned int __builtin_divweu (unsigned int, unsigned int);
15949 vector __int128 __builtin_pack_vector_int128 (long long, long long);
15950 void __builtin_rs6000_speculation_barrier (void);
15951 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
15952 @end smallexample
15954 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
15955 require a 64-bit environment.
15957 The following basic built-in functions, which are also supported on
15958 x86 targets, require @option{-mfloat128}.
15959 @smallexample
15960 __float128 __builtin_fabsq (__float128);
15961 __float128 __builtin_copysignq (__float128, __float128);
15962 __float128 __builtin_infq (void);
15963 __float128 __builtin_huge_valq (void);
15964 __float128 __builtin_nanq (void);
15965 __float128 __builtin_nansq (void);
15967 __float128 __builtin_sqrtf128 (__float128);
15968 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
15969 @end smallexample
15971 @node Basic PowerPC Built-in Functions Available on ISA 2.07
15972 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
15974 The basic built-in functions described in this section are
15975 available on the PowerPC family of processors starting with ISA 2.07
15976 or later.  Unless specific options are explicitly disabled on the
15977 command line, specifying option @option{-mcpu=power8} has the effect of
15978 enabling all the same options as for @option{-mcpu=power7} in
15979 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
15980 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
15981 @option{-mquad-memory-atomic} options.
15983 This section intentionally empty.
15985 @node Basic PowerPC Built-in Functions Available on ISA 3.0
15986 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
15988 The basic built-in functions described in this section are
15989 available on the PowerPC family of processors starting with ISA 3.0
15990 or later.  Unless specific options are explicitly disabled on the
15991 command line, specifying option @option{-mcpu=power9} has the effect of
15992 enabling all the same options as for @option{-mcpu=power8} in
15993 addition to the @option{-misel} option.
15995 The following built-in functions are available on Linux 64-bit systems
15996 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
15998 @table @code
15999 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
16000 Perform a 128-bit IEEE floating point add using round to odd as the
16001 rounding mode.
16002 @findex __builtin_addf128_round_to_odd
16004 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
16005 Perform a 128-bit IEEE floating point subtract using round to odd as
16006 the rounding mode.
16007 @findex __builtin_subf128_round_to_odd
16009 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
16010 Perform a 128-bit IEEE floating point multiply using round to odd as
16011 the rounding mode.
16012 @findex __builtin_mulf128_round_to_odd
16014 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
16015 Perform a 128-bit IEEE floating point divide using round to odd as
16016 the rounding mode.
16017 @findex __builtin_divf128_round_to_odd
16019 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
16020 Perform a 128-bit IEEE floating point square root using round to odd
16021 as the rounding mode.
16022 @findex __builtin_sqrtf128_round_to_odd
16024 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
16025 Perform a 128-bit IEEE floating point fused multiply and add operation
16026 using round to odd as the rounding mode.
16027 @findex __builtin_fmaf128_round_to_odd
16029 @item double __builtin_truncf128_round_to_odd (__float128)
16030 Convert a 128-bit IEEE floating point value to @code{double} using
16031 round to odd as the rounding mode.
16032 @findex __builtin_truncf128_round_to_odd
16033 @end table
16035 The following additional built-in functions are also available for the
16036 PowerPC family of processors, starting with ISA 3.0 or later:
16037 @smallexample
16038 long long __builtin_darn (void);
16039 long long __builtin_darn_raw (void);
16040 int __builtin_darn_32 (void);
16041 @end smallexample
16043 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16044 functions require a
16045 64-bit environment supporting ISA 3.0 or later.
16046 The @code{__builtin_darn} function provides a 64-bit conditioned
16047 random number.  The @code{__builtin_darn_raw} function provides a
16048 64-bit raw random number.  The @code{__builtin_darn_32} function
16049 provides a 32-bit conditioned random number.
16051 The following additional built-in functions are also available for the
16052 PowerPC family of processors, starting with ISA 3.0 or later:
16054 @smallexample
16055 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
16056 int __builtin_byte_in_range (unsigned char u, unsigned int range);
16057 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
16059 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
16060 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
16061 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
16062 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
16064 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
16065 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
16066 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
16067 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
16069 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
16070 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
16071 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
16072 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
16074 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
16075 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
16076 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
16077 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
16079 double __builtin_mffsl(void);
16081 @end smallexample
16082 The @code{__builtin_byte_in_set} function requires a
16083 64-bit environment supporting ISA 3.0 or later.  This function returns
16084 a non-zero value if and only if its @code{u} argument exactly equals one of
16085 the eight bytes contained within its 64-bit @code{set} argument.
16087 The @code{__builtin_byte_in_range} and
16088 @code{__builtin_byte_in_either_range} require an environment
16089 supporting ISA 3.0 or later.  For these two functions, the
16090 @code{range} argument is encoded as 4 bytes, organized as
16091 @code{hi_1:lo_1:hi_2:lo_2}.
16092 The @code{__builtin_byte_in_range} function returns a
16093 non-zero value if and only if its @code{u} argument is within the
16094 range bounded between @code{lo_2} and @code{hi_2} inclusive.
16095 The @code{__builtin_byte_in_either_range} function returns non-zero if
16096 and only if its @code{u} argument is within either the range bounded
16097 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16098 between @code{lo_2} and @code{hi_2} inclusive.
16100 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16101 if and only if the number of signficant digits of its @code{value} argument
16102 is less than its @code{comparison} argument.  The
16103 @code{__builtin_dfp_dtstsfi_lt_dd} and
16104 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16105 require that the type of the @code{value} argument be
16106 @code{__Decimal64} and @code{__Decimal128} respectively.
16108 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16109 if and only if the number of signficant digits of its @code{value} argument
16110 is greater than its @code{comparison} argument.  The
16111 @code{__builtin_dfp_dtstsfi_gt_dd} and
16112 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16113 require that the type of the @code{value} argument be
16114 @code{__Decimal64} and @code{__Decimal128} respectively.
16116 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16117 if and only if the number of signficant digits of its @code{value} argument
16118 equals its @code{comparison} argument.  The
16119 @code{__builtin_dfp_dtstsfi_eq_dd} and
16120 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16121 require that the type of the @code{value} argument be
16122 @code{__Decimal64} and @code{__Decimal128} respectively.
16124 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16125 if and only if its @code{value} argument has an undefined number of
16126 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16127 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16128 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16129 require that the type of the @code{value} argument be
16130 @code{__Decimal64} and @code{__Decimal128} respectively.
16132 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
16133 the FPSCR.  The instruction is a lower latency version of the @code{mffs}
16134 instruction.  If the @code{mffsl} instruction is not available, then the
16135 builtin uses the older @code{mffs} instruction to read the FPSCR.
16138 @node PowerPC AltiVec/VSX Built-in Functions
16139 @subsection PowerPC AltiVec/VSX Built-in Functions
16141 GCC provides an interface for the PowerPC family of processors to access
16142 the AltiVec operations described in Motorola's AltiVec Programming
16143 Interface Manual.  The interface is made available by including
16144 @code{<altivec.h>} and using @option{-maltivec} and
16145 @option{-mabi=altivec}.  The interface supports the following vector
16146 types.
16148 @smallexample
16149 vector unsigned char
16150 vector signed char
16151 vector bool char
16153 vector unsigned short
16154 vector signed short
16155 vector bool short
16156 vector pixel
16158 vector unsigned int
16159 vector signed int
16160 vector bool int
16161 vector float
16162 @end smallexample
16164 GCC's implementation of the high-level language interface available from
16165 C and C++ code differs from Motorola's documentation in several ways.
16167 @itemize @bullet
16169 @item
16170 A vector constant is a list of constant expressions within curly braces.
16172 @item
16173 A vector initializer requires no cast if the vector constant is of the
16174 same type as the variable it is initializing.
16176 @item
16177 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16178 vector type is the default signedness of the base type.  The default
16179 varies depending on the operating system, so a portable program should
16180 always specify the signedness.
16182 @item
16183 Compiling with @option{-maltivec} adds keywords @code{__vector},
16184 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16185 @code{bool}.  When compiling ISO C, the context-sensitive substitution
16186 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16187 disabled.  To use them, you must include @code{<altivec.h>} instead.
16189 @item
16190 GCC allows using a @code{typedef} name as the type specifier for a
16191 vector type.
16193 @item
16194 For C, overloaded functions are implemented with macros so the following
16195 does not work:
16197 @smallexample
16198   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16199 @end smallexample
16201 @noindent
16202 Since @code{vec_add} is a macro, the vector constant in the example
16203 is treated as four separate arguments.  Wrap the entire argument in
16204 parentheses for this to work.
16205 @end itemize
16207 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16208 Internally, GCC uses built-in functions to achieve the functionality in
16209 the aforementioned header file, but they are not supported and are
16210 subject to change without notice.
16212 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16213 which may be found at
16214 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16215 Appendix A of this document lists the vector API interfaces that must be
16216 provided by compliant compilers.  Programmers should preferentially use
16217 the interfaces described therein.  However, historically GCC has provided
16218 additional interfaces for access to vector instructions.  These are
16219 briefly described below.
16221 @menu
16222 * PowerPC AltiVec Built-in Functions on ISA 2.05::
16223 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
16224 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
16225 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
16226 @end menu
16228 @node PowerPC AltiVec Built-in Functions on ISA 2.05
16229 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
16231 The following interfaces are supported for the generic and specific
16232 AltiVec operations and the AltiVec predicates.  In cases where there
16233 is a direct mapping between generic and specific operations, only the
16234 generic names are shown here, although the specific operations can also
16235 be used.
16237 Arguments that are documented as @code{const int} require literal
16238 integral values within the range required for that operation.
16240 @smallexample
16241 vector signed char vec_abs (vector signed char);
16242 vector signed short vec_abs (vector signed short);
16243 vector signed int vec_abs (vector signed int);
16244 vector float vec_abs (vector float);
16246 vector signed char vec_abss (vector signed char);
16247 vector signed short vec_abss (vector signed short);
16248 vector signed int vec_abss (vector signed int);
16250 vector signed char vec_add (vector bool char, vector signed char);
16251 vector signed char vec_add (vector signed char, vector bool char);
16252 vector signed char vec_add (vector signed char, vector signed char);
16253 vector unsigned char vec_add (vector bool char, vector unsigned char);
16254 vector unsigned char vec_add (vector unsigned char, vector bool char);
16255 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
16256 vector signed short vec_add (vector bool short, vector signed short);
16257 vector signed short vec_add (vector signed short, vector bool short);
16258 vector signed short vec_add (vector signed short, vector signed short);
16259 vector unsigned short vec_add (vector bool short, vector unsigned short);
16260 vector unsigned short vec_add (vector unsigned short, vector bool short);
16261 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
16262 vector signed int vec_add (vector bool int, vector signed int);
16263 vector signed int vec_add (vector signed int, vector bool int);
16264 vector signed int vec_add (vector signed int, vector signed int);
16265 vector unsigned int vec_add (vector bool int, vector unsigned int);
16266 vector unsigned int vec_add (vector unsigned int, vector bool int);
16267 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16268 vector float vec_add (vector float, vector float);
16270 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16272 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16273 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16274 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
16275 vector signed char vec_adds (vector bool char, vector signed char);
16276 vector signed char vec_adds (vector signed char, vector bool char);
16277 vector signed char vec_adds (vector signed char, vector signed char);
16278 vector unsigned short vec_adds (vector bool short, vector unsigned short);
16279 vector unsigned short vec_adds (vector unsigned short, vector bool short);
16280 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
16281 vector signed short vec_adds (vector bool short, vector signed short);
16282 vector signed short vec_adds (vector signed short, vector bool short);
16283 vector signed short vec_adds (vector signed short, vector signed short);
16284 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16285 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16286 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16287 vector signed int vec_adds (vector bool int, vector signed int);
16288 vector signed int vec_adds (vector signed int, vector bool int);
16289 vector signed int vec_adds (vector signed int, vector signed int);
16291 int vec_all_eq (vector signed char, vector bool char);
16292 int vec_all_eq (vector signed char, vector signed char);
16293 int vec_all_eq (vector unsigned char, vector bool char);
16294 int vec_all_eq (vector unsigned char, vector unsigned char);
16295 int vec_all_eq (vector bool char, vector bool char);
16296 int vec_all_eq (vector bool char, vector unsigned char);
16297 int vec_all_eq (vector bool char, vector signed char);
16298 int vec_all_eq (vector signed short, vector bool short);
16299 int vec_all_eq (vector signed short, vector signed short);
16300 int vec_all_eq (vector unsigned short, vector bool short);
16301 int vec_all_eq (vector unsigned short, vector unsigned short);
16302 int vec_all_eq (vector bool short, vector bool short);
16303 int vec_all_eq (vector bool short, vector unsigned short);
16304 int vec_all_eq (vector bool short, vector signed short);
16305 int vec_all_eq (vector pixel, vector pixel);
16306 int vec_all_eq (vector signed int, vector bool int);
16307 int vec_all_eq (vector signed int, vector signed int);
16308 int vec_all_eq (vector unsigned int, vector bool int);
16309 int vec_all_eq (vector unsigned int, vector unsigned int);
16310 int vec_all_eq (vector bool int, vector bool int);
16311 int vec_all_eq (vector bool int, vector unsigned int);
16312 int vec_all_eq (vector bool int, vector signed int);
16313 int vec_all_eq (vector float, vector float);
16315 int vec_all_ge (vector bool char, vector unsigned char);
16316 int vec_all_ge (vector unsigned char, vector bool char);
16317 int vec_all_ge (vector unsigned char, vector unsigned char);
16318 int vec_all_ge (vector bool char, vector signed char);
16319 int vec_all_ge (vector signed char, vector bool char);
16320 int vec_all_ge (vector signed char, vector signed char);
16321 int vec_all_ge (vector bool short, vector unsigned short);
16322 int vec_all_ge (vector unsigned short, vector bool short);
16323 int vec_all_ge (vector unsigned short, vector unsigned short);
16324 int vec_all_ge (vector signed short, vector signed short);
16325 int vec_all_ge (vector bool short, vector signed short);
16326 int vec_all_ge (vector signed short, vector bool short);
16327 int vec_all_ge (vector bool int, vector unsigned int);
16328 int vec_all_ge (vector unsigned int, vector bool int);
16329 int vec_all_ge (vector unsigned int, vector unsigned int);
16330 int vec_all_ge (vector bool int, vector signed int);
16331 int vec_all_ge (vector signed int, vector bool int);
16332 int vec_all_ge (vector signed int, vector signed int);
16333 int vec_all_ge (vector float, vector float);
16335 int vec_all_gt (vector bool char, vector unsigned char);
16336 int vec_all_gt (vector unsigned char, vector bool char);
16337 int vec_all_gt (vector unsigned char, vector unsigned char);
16338 int vec_all_gt (vector bool char, vector signed char);
16339 int vec_all_gt (vector signed char, vector bool char);
16340 int vec_all_gt (vector signed char, vector signed char);
16341 int vec_all_gt (vector bool short, vector unsigned short);
16342 int vec_all_gt (vector unsigned short, vector bool short);
16343 int vec_all_gt (vector unsigned short, vector unsigned short);
16344 int vec_all_gt (vector bool short, vector signed short);
16345 int vec_all_gt (vector signed short, vector bool short);
16346 int vec_all_gt (vector signed short, vector signed short);
16347 int vec_all_gt (vector bool int, vector unsigned int);
16348 int vec_all_gt (vector unsigned int, vector bool int);
16349 int vec_all_gt (vector unsigned int, vector unsigned int);
16350 int vec_all_gt (vector bool int, vector signed int);
16351 int vec_all_gt (vector signed int, vector bool int);
16352 int vec_all_gt (vector signed int, vector signed int);
16353 int vec_all_gt (vector float, vector float);
16355 int vec_all_in (vector float, vector float);
16357 int vec_all_le (vector bool char, vector unsigned char);
16358 int vec_all_le (vector unsigned char, vector bool char);
16359 int vec_all_le (vector unsigned char, vector unsigned char);
16360 int vec_all_le (vector bool char, vector signed char);
16361 int vec_all_le (vector signed char, vector bool char);
16362 int vec_all_le (vector signed char, vector signed char);
16363 int vec_all_le (vector bool short, vector unsigned short);
16364 int vec_all_le (vector unsigned short, vector bool short);
16365 int vec_all_le (vector unsigned short, vector unsigned short);
16366 int vec_all_le (vector bool short, vector signed short);
16367 int vec_all_le (vector signed short, vector bool short);
16368 int vec_all_le (vector signed short, vector signed short);
16369 int vec_all_le (vector bool int, vector unsigned int);
16370 int vec_all_le (vector unsigned int, vector bool int);
16371 int vec_all_le (vector unsigned int, vector unsigned int);
16372 int vec_all_le (vector bool int, vector signed int);
16373 int vec_all_le (vector signed int, vector bool int);
16374 int vec_all_le (vector signed int, vector signed int);
16375 int vec_all_le (vector float, vector float);
16377 int vec_all_lt (vector bool char, vector unsigned char);
16378 int vec_all_lt (vector unsigned char, vector bool char);
16379 int vec_all_lt (vector unsigned char, vector unsigned char);
16380 int vec_all_lt (vector bool char, vector signed char);
16381 int vec_all_lt (vector signed char, vector bool char);
16382 int vec_all_lt (vector signed char, vector signed char);
16383 int vec_all_lt (vector bool short, vector unsigned short);
16384 int vec_all_lt (vector unsigned short, vector bool short);
16385 int vec_all_lt (vector unsigned short, vector unsigned short);
16386 int vec_all_lt (vector bool short, vector signed short);
16387 int vec_all_lt (vector signed short, vector bool short);
16388 int vec_all_lt (vector signed short, vector signed short);
16389 int vec_all_lt (vector bool int, vector unsigned int);
16390 int vec_all_lt (vector unsigned int, vector bool int);
16391 int vec_all_lt (vector unsigned int, vector unsigned int);
16392 int vec_all_lt (vector bool int, vector signed int);
16393 int vec_all_lt (vector signed int, vector bool int);
16394 int vec_all_lt (vector signed int, vector signed int);
16395 int vec_all_lt (vector float, vector float);
16397 int vec_all_nan (vector float);
16399 int vec_all_ne (vector signed char, vector bool char);
16400 int vec_all_ne (vector signed char, vector signed char);
16401 int vec_all_ne (vector unsigned char, vector bool char);
16402 int vec_all_ne (vector unsigned char, vector unsigned char);
16403 int vec_all_ne (vector bool char, vector bool char);
16404 int vec_all_ne (vector bool char, vector unsigned char);
16405 int vec_all_ne (vector bool char, vector signed char);
16406 int vec_all_ne (vector signed short, vector bool short);
16407 int vec_all_ne (vector signed short, vector signed short);
16408 int vec_all_ne (vector unsigned short, vector bool short);
16409 int vec_all_ne (vector unsigned short, vector unsigned short);
16410 int vec_all_ne (vector bool short, vector bool short);
16411 int vec_all_ne (vector bool short, vector unsigned short);
16412 int vec_all_ne (vector bool short, vector signed short);
16413 int vec_all_ne (vector pixel, vector pixel);
16414 int vec_all_ne (vector signed int, vector bool int);
16415 int vec_all_ne (vector signed int, vector signed int);
16416 int vec_all_ne (vector unsigned int, vector bool int);
16417 int vec_all_ne (vector unsigned int, vector unsigned int);
16418 int vec_all_ne (vector bool int, vector bool int);
16419 int vec_all_ne (vector bool int, vector unsigned int);
16420 int vec_all_ne (vector bool int, vector signed int);
16421 int vec_all_ne (vector float, vector float);
16423 int vec_all_nge (vector float, vector float);
16425 int vec_all_ngt (vector float, vector float);
16427 int vec_all_nle (vector float, vector float);
16429 int vec_all_nlt (vector float, vector float);
16431 int vec_all_numeric (vector float);
16433 vector float vec_and (vector float, vector float);
16434 vector float vec_and (vector float, vector bool int);
16435 vector float vec_and (vector bool int, vector float);
16436 vector bool int vec_and (vector bool int, vector bool int);
16437 vector signed int vec_and (vector bool int, vector signed int);
16438 vector signed int vec_and (vector signed int, vector bool int);
16439 vector signed int vec_and (vector signed int, vector signed int);
16440 vector unsigned int vec_and (vector bool int, vector unsigned int);
16441 vector unsigned int vec_and (vector unsigned int, vector bool int);
16442 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16443 vector bool short vec_and (vector bool short, vector bool short);
16444 vector signed short vec_and (vector bool short, vector signed short);
16445 vector signed short vec_and (vector signed short, vector bool short);
16446 vector signed short vec_and (vector signed short, vector signed short);
16447 vector unsigned short vec_and (vector bool short, vector unsigned short);
16448 vector unsigned short vec_and (vector unsigned short, vector bool short);
16449 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
16450 vector signed char vec_and (vector bool char, vector signed char);
16451 vector bool char vec_and (vector bool char, vector bool char);
16452 vector signed char vec_and (vector signed char, vector bool char);
16453 vector signed char vec_and (vector signed char, vector signed char);
16454 vector unsigned char vec_and (vector bool char, vector unsigned char);
16455 vector unsigned char vec_and (vector unsigned char, vector bool char);
16456 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
16458 vector float vec_andc (vector float, vector float);
16459 vector float vec_andc (vector float, vector bool int);
16460 vector float vec_andc (vector bool int, vector float);
16461 vector bool int vec_andc (vector bool int, vector bool int);
16462 vector signed int vec_andc (vector bool int, vector signed int);
16463 vector signed int vec_andc (vector signed int, vector bool int);
16464 vector signed int vec_andc (vector signed int, vector signed int);
16465 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16466 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16467 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16468 vector bool short vec_andc (vector bool short, vector bool short);
16469 vector signed short vec_andc (vector bool short, vector signed short);
16470 vector signed short vec_andc (vector signed short, vector bool short);
16471 vector signed short vec_andc (vector signed short, vector signed short);
16472 vector unsigned short vec_andc (vector bool short, vector unsigned short);
16473 vector unsigned short vec_andc (vector unsigned short, vector bool short);
16474 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
16475 vector signed char vec_andc (vector bool char, vector signed char);
16476 vector bool char vec_andc (vector bool char, vector bool char);
16477 vector signed char vec_andc (vector signed char, vector bool char);
16478 vector signed char vec_andc (vector signed char, vector signed char);
16479 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16480 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16481 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
16483 int vec_any_eq (vector signed char, vector bool char);
16484 int vec_any_eq (vector signed char, vector signed char);
16485 int vec_any_eq (vector unsigned char, vector bool char);
16486 int vec_any_eq (vector unsigned char, vector unsigned char);
16487 int vec_any_eq (vector bool char, vector bool char);
16488 int vec_any_eq (vector bool char, vector unsigned char);
16489 int vec_any_eq (vector bool char, vector signed char);
16490 int vec_any_eq (vector signed short, vector bool short);
16491 int vec_any_eq (vector signed short, vector signed short);
16492 int vec_any_eq (vector unsigned short, vector bool short);
16493 int vec_any_eq (vector unsigned short, vector unsigned short);
16494 int vec_any_eq (vector bool short, vector bool short);
16495 int vec_any_eq (vector bool short, vector unsigned short);
16496 int vec_any_eq (vector bool short, vector signed short);
16497 int vec_any_eq (vector pixel, vector pixel);
16498 int vec_any_eq (vector signed int, vector bool int);
16499 int vec_any_eq (vector signed int, vector signed int);
16500 int vec_any_eq (vector unsigned int, vector bool int);
16501 int vec_any_eq (vector unsigned int, vector unsigned int);
16502 int vec_any_eq (vector bool int, vector bool int);
16503 int vec_any_eq (vector bool int, vector unsigned int);
16504 int vec_any_eq (vector bool int, vector signed int);
16505 int vec_any_eq (vector float, vector float);
16507 int vec_any_ge (vector signed char, vector bool char);
16508 int vec_any_ge (vector unsigned char, vector bool char);
16509 int vec_any_ge (vector unsigned char, vector unsigned char);
16510 int vec_any_ge (vector signed char, vector signed char);
16511 int vec_any_ge (vector bool char, vector unsigned char);
16512 int vec_any_ge (vector bool char, vector signed char);
16513 int vec_any_ge (vector unsigned short, vector bool short);
16514 int vec_any_ge (vector unsigned short, vector unsigned short);
16515 int vec_any_ge (vector signed short, vector signed short);
16516 int vec_any_ge (vector signed short, vector bool short);
16517 int vec_any_ge (vector bool short, vector unsigned short);
16518 int vec_any_ge (vector bool short, vector signed short);
16519 int vec_any_ge (vector signed int, vector bool int);
16520 int vec_any_ge (vector unsigned int, vector bool int);
16521 int vec_any_ge (vector unsigned int, vector unsigned int);
16522 int vec_any_ge (vector signed int, vector signed int);
16523 int vec_any_ge (vector bool int, vector unsigned int);
16524 int vec_any_ge (vector bool int, vector signed int);
16525 int vec_any_ge (vector float, vector float);
16527 int vec_any_gt (vector bool char, vector unsigned char);
16528 int vec_any_gt (vector unsigned char, vector bool char);
16529 int vec_any_gt (vector unsigned char, vector unsigned char);
16530 int vec_any_gt (vector bool char, vector signed char);
16531 int vec_any_gt (vector signed char, vector bool char);
16532 int vec_any_gt (vector signed char, vector signed char);
16533 int vec_any_gt (vector bool short, vector unsigned short);
16534 int vec_any_gt (vector unsigned short, vector bool short);
16535 int vec_any_gt (vector unsigned short, vector unsigned short);
16536 int vec_any_gt (vector bool short, vector signed short);
16537 int vec_any_gt (vector signed short, vector bool short);
16538 int vec_any_gt (vector signed short, vector signed short);
16539 int vec_any_gt (vector bool int, vector unsigned int);
16540 int vec_any_gt (vector unsigned int, vector bool int);
16541 int vec_any_gt (vector unsigned int, vector unsigned int);
16542 int vec_any_gt (vector bool int, vector signed int);
16543 int vec_any_gt (vector signed int, vector bool int);
16544 int vec_any_gt (vector signed int, vector signed int);
16545 int vec_any_gt (vector float, vector float);
16547 int vec_any_le (vector bool char, vector unsigned char);
16548 int vec_any_le (vector unsigned char, vector bool char);
16549 int vec_any_le (vector unsigned char, vector unsigned char);
16550 int vec_any_le (vector bool char, vector signed char);
16551 int vec_any_le (vector signed char, vector bool char);
16552 int vec_any_le (vector signed char, vector signed char);
16553 int vec_any_le (vector bool short, vector unsigned short);
16554 int vec_any_le (vector unsigned short, vector bool short);
16555 int vec_any_le (vector unsigned short, vector unsigned short);
16556 int vec_any_le (vector bool short, vector signed short);
16557 int vec_any_le (vector signed short, vector bool short);
16558 int vec_any_le (vector signed short, vector signed short);
16559 int vec_any_le (vector bool int, vector unsigned int);
16560 int vec_any_le (vector unsigned int, vector bool int);
16561 int vec_any_le (vector unsigned int, vector unsigned int);
16562 int vec_any_le (vector bool int, vector signed int);
16563 int vec_any_le (vector signed int, vector bool int);
16564 int vec_any_le (vector signed int, vector signed int);
16565 int vec_any_le (vector float, vector float);
16567 int vec_any_lt (vector bool char, vector unsigned char);
16568 int vec_any_lt (vector unsigned char, vector bool char);
16569 int vec_any_lt (vector unsigned char, vector unsigned char);
16570 int vec_any_lt (vector bool char, vector signed char);
16571 int vec_any_lt (vector signed char, vector bool char);
16572 int vec_any_lt (vector signed char, vector signed char);
16573 int vec_any_lt (vector bool short, vector unsigned short);
16574 int vec_any_lt (vector unsigned short, vector bool short);
16575 int vec_any_lt (vector unsigned short, vector unsigned short);
16576 int vec_any_lt (vector bool short, vector signed short);
16577 int vec_any_lt (vector signed short, vector bool short);
16578 int vec_any_lt (vector signed short, vector signed short);
16579 int vec_any_lt (vector bool int, vector unsigned int);
16580 int vec_any_lt (vector unsigned int, vector bool int);
16581 int vec_any_lt (vector unsigned int, vector unsigned int);
16582 int vec_any_lt (vector bool int, vector signed int);
16583 int vec_any_lt (vector signed int, vector bool int);
16584 int vec_any_lt (vector signed int, vector signed int);
16585 int vec_any_lt (vector float, vector float);
16587 int vec_any_nan (vector float);
16589 int vec_any_ne (vector signed char, vector bool char);
16590 int vec_any_ne (vector signed char, vector signed char);
16591 int vec_any_ne (vector unsigned char, vector bool char);
16592 int vec_any_ne (vector unsigned char, vector unsigned char);
16593 int vec_any_ne (vector bool char, vector bool char);
16594 int vec_any_ne (vector bool char, vector unsigned char);
16595 int vec_any_ne (vector bool char, vector signed char);
16596 int vec_any_ne (vector signed short, vector bool short);
16597 int vec_any_ne (vector signed short, vector signed short);
16598 int vec_any_ne (vector unsigned short, vector bool short);
16599 int vec_any_ne (vector unsigned short, vector unsigned short);
16600 int vec_any_ne (vector bool short, vector bool short);
16601 int vec_any_ne (vector bool short, vector unsigned short);
16602 int vec_any_ne (vector bool short, vector signed short);
16603 int vec_any_ne (vector pixel, vector pixel);
16604 int vec_any_ne (vector signed int, vector bool int);
16605 int vec_any_ne (vector signed int, vector signed int);
16606 int vec_any_ne (vector unsigned int, vector bool int);
16607 int vec_any_ne (vector unsigned int, vector unsigned int);
16608 int vec_any_ne (vector bool int, vector bool int);
16609 int vec_any_ne (vector bool int, vector unsigned int);
16610 int vec_any_ne (vector bool int, vector signed int);
16611 int vec_any_ne (vector float, vector float);
16613 int vec_any_nge (vector float, vector float);
16615 int vec_any_ngt (vector float, vector float);
16617 int vec_any_nle (vector float, vector float);
16619 int vec_any_nlt (vector float, vector float);
16621 int vec_any_numeric (vector float);
16623 int vec_any_out (vector float, vector float);
16625 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
16626 vector signed char vec_avg (vector signed char, vector signed char);
16627 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
16628 vector signed short vec_avg (vector signed short, vector signed short);
16629 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16630 vector signed int vec_avg (vector signed int, vector signed int);
16632 vector float vec_ceil (vector float);
16634 vector signed int vec_cmpb (vector float, vector float);
16636 vector bool char vec_cmpeq (vector bool char, vector bool char);
16637 vector bool short vec_cmpeq (vector bool short, vector bool short);
16638 vector bool int vec_cmpeq (vector bool int, vector bool int);
16639 vector bool char vec_cmpeq (vector signed char, vector signed char);
16640 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16641 vector bool short vec_cmpeq (vector signed short, vector signed short);
16642 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
16643 vector bool int vec_cmpeq (vector signed int, vector signed int);
16644 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16645 vector bool int vec_cmpeq (vector float, vector float);
16647 vector bool int vec_cmpge (vector float, vector float);
16649 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16650 vector bool char vec_cmpgt (vector signed char, vector signed char);
16651 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
16652 vector bool short vec_cmpgt (vector signed short, vector signed short);
16653 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16654 vector bool int vec_cmpgt (vector signed int, vector signed int);
16655 vector bool int vec_cmpgt (vector float, vector float);
16657 vector bool int vec_cmple (vector float, vector float);
16659 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16660 vector bool char vec_cmplt (vector signed char, vector signed char);
16661 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
16662 vector bool short vec_cmplt (vector signed short, vector signed short);
16663 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16664 vector bool int vec_cmplt (vector signed int, vector signed int);
16665 vector bool int vec_cmplt (vector float, vector float);
16667 vector float vec_cpsgn (vector float, vector float);
16669 vector float vec_ctf (vector unsigned int, const int);
16670 vector float vec_ctf (vector signed int, const int);
16672 vector signed int vec_cts (vector float, const int);
16674 vector unsigned int vec_ctu (vector float, const int);
16676 void vec_dss (const int);
16678 void vec_dssall (void);
16680 void vec_dst (const vector unsigned char *, int, const int);
16681 void vec_dst (const vector signed char *, int, const int);
16682 void vec_dst (const vector bool char *, int, const int);
16683 void vec_dst (const vector unsigned short *, int, const int);
16684 void vec_dst (const vector signed short *, int, const int);
16685 void vec_dst (const vector bool short *, int, const int);
16686 void vec_dst (const vector pixel *, int, const int);
16687 void vec_dst (const vector unsigned int *, int, const int);
16688 void vec_dst (const vector signed int *, int, const int);
16689 void vec_dst (const vector bool int *, int, const int);
16690 void vec_dst (const vector float *, int, const int);
16691 void vec_dst (const unsigned char *, int, const int);
16692 void vec_dst (const signed char *, int, const int);
16693 void vec_dst (const unsigned short *, int, const int);
16694 void vec_dst (const short *, int, const int);
16695 void vec_dst (const unsigned int *, int, const int);
16696 void vec_dst (const int *, int, const int);
16697 void vec_dst (const float *, int, const int);
16699 void vec_dstst (const vector unsigned char *, int, const int);
16700 void vec_dstst (const vector signed char *, int, const int);
16701 void vec_dstst (const vector bool char *, int, const int);
16702 void vec_dstst (const vector unsigned short *, int, const int);
16703 void vec_dstst (const vector signed short *, int, const int);
16704 void vec_dstst (const vector bool short *, int, const int);
16705 void vec_dstst (const vector pixel *, int, const int);
16706 void vec_dstst (const vector unsigned int *, int, const int);
16707 void vec_dstst (const vector signed int *, int, const int);
16708 void vec_dstst (const vector bool int *, int, const int);
16709 void vec_dstst (const vector float *, int, const int);
16710 void vec_dstst (const unsigned char *, int, const int);
16711 void vec_dstst (const signed char *, int, const int);
16712 void vec_dstst (const unsigned short *, int, const int);
16713 void vec_dstst (const short *, int, const int);
16714 void vec_dstst (const unsigned int *, int, const int);
16715 void vec_dstst (const int *, int, const int);
16716 void vec_dstst (const unsigned long *, int, const int);
16717 void vec_dstst (const long *, int, const int);
16718 void vec_dstst (const float *, int, const int);
16720 void vec_dststt (const vector unsigned char *, int, const int);
16721 void vec_dststt (const vector signed char *, int, const int);
16722 void vec_dststt (const vector bool char *, int, const int);
16723 void vec_dststt (const vector unsigned short *, int, const int);
16724 void vec_dststt (const vector signed short *, int, const int);
16725 void vec_dststt (const vector bool short *, int, const int);
16726 void vec_dststt (const vector pixel *, int, const int);
16727 void vec_dststt (const vector unsigned int *, int, const int);
16728 void vec_dststt (const vector signed int *, int, const int);
16729 void vec_dststt (const vector bool int *, int, const int);
16730 void vec_dststt (const vector float *, int, const int);
16731 void vec_dststt (const unsigned char *, int, const int);
16732 void vec_dststt (const signed char *, int, const int);
16733 void vec_dststt (const unsigned short *, int, const int);
16734 void vec_dststt (const short *, int, const int);
16735 void vec_dststt (const unsigned int *, int, const int);
16736 void vec_dststt (const int *, int, const int);
16737 void vec_dststt (const float *, int, const int);
16739 void vec_dstt (const vector unsigned char *, int, const int);
16740 void vec_dstt (const vector signed char *, int, const int);
16741 void vec_dstt (const vector bool char *, int, const int);
16742 void vec_dstt (const vector unsigned short *, int, const int);
16743 void vec_dstt (const vector signed short *, int, const int);
16744 void vec_dstt (const vector bool short *, int, const int);
16745 void vec_dstt (const vector pixel *, int, const int);
16746 void vec_dstt (const vector unsigned int *, int, const int);
16747 void vec_dstt (const vector signed int *, int, const int);
16748 void vec_dstt (const vector bool int *, int, const int);
16749 void vec_dstt (const vector float *, int, const int);
16750 void vec_dstt (const unsigned char *, int, const int);
16751 void vec_dstt (const signed char *, int, const int);
16752 void vec_dstt (const unsigned short *, int, const int);
16753 void vec_dstt (const short *, int, const int);
16754 void vec_dstt (const unsigned int *, int, const int);
16755 void vec_dstt (const int *, int, const int);
16756 void vec_dstt (const float *, int, const int);
16758 vector float vec_expte (vector float);
16760 vector float vec_floor (vector float);
16762 vector float vec_ld (int, const vector float *);
16763 vector float vec_ld (int, const float *);
16764 vector bool int vec_ld (int, const vector bool int *);
16765 vector signed int vec_ld (int, const vector signed int *);
16766 vector signed int vec_ld (int, const int *);
16767 vector unsigned int vec_ld (int, const vector unsigned int *);
16768 vector unsigned int vec_ld (int, const unsigned int *);
16769 vector bool short vec_ld (int, const vector bool short *);
16770 vector pixel vec_ld (int, const vector pixel *);
16771 vector signed short vec_ld (int, const vector signed short *);
16772 vector signed short vec_ld (int, const short *);
16773 vector unsigned short vec_ld (int, const vector unsigned short *);
16774 vector unsigned short vec_ld (int, const unsigned short *);
16775 vector bool char vec_ld (int, const vector bool char *);
16776 vector signed char vec_ld (int, const vector signed char *);
16777 vector signed char vec_ld (int, const signed char *);
16778 vector unsigned char vec_ld (int, const vector unsigned char *);
16779 vector unsigned char vec_ld (int, const unsigned char *);
16781 vector signed char vec_lde (int, const signed char *);
16782 vector unsigned char vec_lde (int, const unsigned char *);
16783 vector signed short vec_lde (int, const short *);
16784 vector unsigned short vec_lde (int, const unsigned short *);
16785 vector float vec_lde (int, const float *);
16786 vector signed int vec_lde (int, const int *);
16787 vector unsigned int vec_lde (int, const unsigned int *);
16789 vector float vec_ldl (int, const vector float *);
16790 vector float vec_ldl (int, const float *);
16791 vector bool int vec_ldl (int, const vector bool int *);
16792 vector signed int vec_ldl (int, const vector signed int *);
16793 vector signed int vec_ldl (int, const int *);
16794 vector unsigned int vec_ldl (int, const vector unsigned int *);
16795 vector unsigned int vec_ldl (int, const unsigned int *);
16796 vector bool short vec_ldl (int, const vector bool short *);
16797 vector pixel vec_ldl (int, const vector pixel *);
16798 vector signed short vec_ldl (int, const vector signed short *);
16799 vector signed short vec_ldl (int, const short *);
16800 vector unsigned short vec_ldl (int, const vector unsigned short *);
16801 vector unsigned short vec_ldl (int, const unsigned short *);
16802 vector bool char vec_ldl (int, const vector bool char *);
16803 vector signed char vec_ldl (int, const vector signed char *);
16804 vector signed char vec_ldl (int, const signed char *);
16805 vector unsigned char vec_ldl (int, const vector unsigned char *);
16806 vector unsigned char vec_ldl (int, const unsigned char *);
16808 vector float vec_loge (vector float);
16810 vector signed char vec_lvebx (int, char *);
16811 vector unsigned char vec_lvebx (int, unsigned char *);
16813 vector signed short vec_lvehx (int, short *);
16814 vector unsigned short vec_lvehx (int, unsigned short *);
16816 vector float vec_lvewx (int, float *);
16817 vector signed int vec_lvewx (int, int *);
16818 vector unsigned int vec_lvewx (int, unsigned int *);
16820 vector unsigned char vec_lvsl (int, const unsigned char *);
16821 vector unsigned char vec_lvsl (int, const signed char *);
16822 vector unsigned char vec_lvsl (int, const unsigned short *);
16823 vector unsigned char vec_lvsl (int, const short *);
16824 vector unsigned char vec_lvsl (int, const unsigned int *);
16825 vector unsigned char vec_lvsl (int, const int *);
16826 vector unsigned char vec_lvsl (int, const float *);
16828 vector unsigned char vec_lvsr (int, const unsigned char *);
16829 vector unsigned char vec_lvsr (int, const signed char *);
16830 vector unsigned char vec_lvsr (int, const unsigned short *);
16831 vector unsigned char vec_lvsr (int, const short *);
16832 vector unsigned char vec_lvsr (int, const unsigned int *);
16833 vector unsigned char vec_lvsr (int, const int *);
16834 vector unsigned char vec_lvsr (int, const float *);
16836 vector float vec_madd (vector float, vector float, vector float);
16838 vector signed short vec_madds (vector signed short, vector signed short,
16839                                vector signed short);
16841 vector unsigned char vec_max (vector bool char, vector unsigned char);
16842 vector unsigned char vec_max (vector unsigned char, vector bool char);
16843 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
16844 vector signed char vec_max (vector bool char, vector signed char);
16845 vector signed char vec_max (vector signed char, vector bool char);
16846 vector signed char vec_max (vector signed char, vector signed char);
16847 vector unsigned short vec_max (vector bool short, vector unsigned short);
16848 vector unsigned short vec_max (vector unsigned short, vector bool short);
16849 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
16850 vector signed short vec_max (vector bool short, vector signed short);
16851 vector signed short vec_max (vector signed short, vector bool short);
16852 vector signed short vec_max (vector signed short, vector signed short);
16853 vector unsigned int vec_max (vector bool int, vector unsigned int);
16854 vector unsigned int vec_max (vector unsigned int, vector bool int);
16855 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16856 vector signed int vec_max (vector bool int, vector signed int);
16857 vector signed int vec_max (vector signed int, vector bool int);
16858 vector signed int vec_max (vector signed int, vector signed int);
16859 vector float vec_max (vector float, vector float);
16861 vector bool char vec_mergeh (vector bool char, vector bool char);
16862 vector signed char vec_mergeh (vector signed char, vector signed char);
16863 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
16864 vector bool short vec_mergeh (vector bool short, vector bool short);
16865 vector pixel vec_mergeh (vector pixel, vector pixel);
16866 vector signed short vec_mergeh (vector signed short, vector signed short);
16867 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
16868 vector float vec_mergeh (vector float, vector float);
16869 vector bool int vec_mergeh (vector bool int, vector bool int);
16870 vector signed int vec_mergeh (vector signed int, vector signed int);
16871 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
16873 vector bool char vec_mergel (vector bool char, vector bool char);
16874 vector signed char vec_mergel (vector signed char, vector signed char);
16875 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
16876 vector bool short vec_mergel (vector bool short, vector bool short);
16877 vector pixel vec_mergel (vector pixel, vector pixel);
16878 vector signed short vec_mergel (vector signed short, vector signed short);
16879 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
16880 vector float vec_mergel (vector float, vector float);
16881 vector bool int vec_mergel (vector bool int, vector bool int);
16882 vector signed int vec_mergel (vector signed int, vector signed int);
16883 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
16885 vector unsigned short vec_mfvscr (void);
16887 vector unsigned char vec_min (vector bool char, vector unsigned char);
16888 vector unsigned char vec_min (vector unsigned char, vector bool char);
16889 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
16890 vector signed char vec_min (vector bool char, vector signed char);
16891 vector signed char vec_min (vector signed char, vector bool char);
16892 vector signed char vec_min (vector signed char, vector signed char);
16893 vector unsigned short vec_min (vector bool short, vector unsigned short);
16894 vector unsigned short vec_min (vector unsigned short, vector bool short);
16895 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
16896 vector signed short vec_min (vector bool short, vector signed short);
16897 vector signed short vec_min (vector signed short, vector bool short);
16898 vector signed short vec_min (vector signed short, vector signed short);
16899 vector unsigned int vec_min (vector bool int, vector unsigned int);
16900 vector unsigned int vec_min (vector unsigned int, vector bool int);
16901 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16902 vector signed int vec_min (vector bool int, vector signed int);
16903 vector signed int vec_min (vector signed int, vector bool int);
16904 vector signed int vec_min (vector signed int, vector signed int);
16905 vector float vec_min (vector float, vector float);
16907 vector signed short vec_mladd (vector signed short, vector signed short,
16908                                vector signed short);
16909 vector signed short vec_mladd (vector signed short, vector unsigned short,
16910                                vector unsigned short);
16911 vector signed short vec_mladd (vector unsigned short, vector signed short,
16912                                vector signed short);
16913 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
16914                                  vector unsigned short);
16916 vector signed short vec_mradds (vector signed short, vector signed short,
16917                                 vector signed short);
16919 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
16920                               vector unsigned int);
16921 vector signed int vec_msum (vector signed char, vector unsigned char,
16922                             vector signed int);
16923 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
16924                               vector unsigned int);
16925 vector signed int vec_msum (vector signed short, vector signed short,
16926                             vector signed int);
16928 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
16929                                vector unsigned int);
16930 vector signed int vec_msums (vector signed short, vector signed short,
16931                              vector signed int);
16933 void vec_mtvscr (vector signed int);
16934 void vec_mtvscr (vector unsigned int);
16935 void vec_mtvscr (vector bool int);
16936 void vec_mtvscr (vector signed short);
16937 void vec_mtvscr (vector unsigned short);
16938 void vec_mtvscr (vector bool short);
16939 void vec_mtvscr (vector pixel);
16940 void vec_mtvscr (vector signed char);
16941 void vec_mtvscr (vector unsigned char);
16942 void vec_mtvscr (vector bool char);
16944 vector float vec_mul (vector float, vector float);
16946 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
16947 vector signed short vec_mule (vector signed char, vector signed char);
16948 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
16949 vector signed int vec_mule (vector signed short, vector signed short);
16951 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
16952 vector signed short vec_mulo (vector signed char, vector signed char);
16953 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
16954 vector signed int vec_mulo (vector signed short, vector signed short);
16956 vector signed char vec_nabs (vector signed char);
16957 vector signed short vec_nabs (vector signed short);
16958 vector signed int vec_nabs (vector signed int);
16959 vector float vec_nabs (vector float);
16961 vector float vec_nmsub (vector float, vector float, vector float);
16963 vector float vec_nor (vector float, vector float);
16964 vector signed int vec_nor (vector signed int, vector signed int);
16965 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16966 vector bool int vec_nor (vector bool int, vector bool int);
16967 vector signed short vec_nor (vector signed short, vector signed short);
16968 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
16969 vector bool short vec_nor (vector bool short, vector bool short);
16970 vector signed char vec_nor (vector signed char, vector signed char);
16971 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
16972 vector bool char vec_nor (vector bool char, vector bool char);
16974 vector float vec_or (vector float, vector float);
16975 vector float vec_or (vector float, vector bool int);
16976 vector float vec_or (vector bool int, vector float);
16977 vector bool int vec_or (vector bool int, vector bool int);
16978 vector signed int vec_or (vector bool int, vector signed int);
16979 vector signed int vec_or (vector signed int, vector bool int);
16980 vector signed int vec_or (vector signed int, vector signed int);
16981 vector unsigned int vec_or (vector bool int, vector unsigned int);
16982 vector unsigned int vec_or (vector unsigned int, vector bool int);
16983 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16984 vector bool short vec_or (vector bool short, vector bool short);
16985 vector signed short vec_or (vector bool short, vector signed short);
16986 vector signed short vec_or (vector signed short, vector bool short);
16987 vector signed short vec_or (vector signed short, vector signed short);
16988 vector unsigned short vec_or (vector bool short, vector unsigned short);
16989 vector unsigned short vec_or (vector unsigned short, vector bool short);
16990 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
16991 vector signed char vec_or (vector bool char, vector signed char);
16992 vector bool char vec_or (vector bool char, vector bool char);
16993 vector signed char vec_or (vector signed char, vector bool char);
16994 vector signed char vec_or (vector signed char, vector signed char);
16995 vector unsigned char vec_or (vector bool char, vector unsigned char);
16996 vector unsigned char vec_or (vector unsigned char, vector bool char);
16997 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
16999 vector signed char vec_pack (vector signed short, vector signed short);
17000 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
17001 vector bool char vec_pack (vector bool short, vector bool short);
17002 vector signed short vec_pack (vector signed int, vector signed int);
17003 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
17004 vector bool short vec_pack (vector bool int, vector bool int);
17006 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17008 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
17009 vector signed char vec_packs (vector signed short, vector signed short);
17010 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
17011 vector signed short vec_packs (vector signed int, vector signed int);
17013 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
17014 vector unsigned char vec_packsu (vector signed short, vector signed short);
17015 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
17016 vector unsigned short vec_packsu (vector signed int, vector signed int);
17018 vector float vec_perm (vector float, vector float, vector unsigned char);
17019 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
17020 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
17021                               vector unsigned char);
17022 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
17023 vector signed short vec_perm (vector signed short, vector signed short,
17024                               vector unsigned char);
17025 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
17026                                 vector unsigned char);
17027 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
17028 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
17029 vector signed char vec_perm (vector signed char, vector signed char,
17030                              vector unsigned char);
17031 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
17032                                vector unsigned char);
17033 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
17035 vector float vec_re (vector float);
17037 vector bool char vec_reve (vector bool char);
17038 vector signed char vec_reve (vector signed char);
17039 vector unsigned char vec_reve (vector unsigned char);
17040 vector bool int vec_reve (vector bool int);
17041 vector signed int vec_reve (vector signed int);
17042 vector unsigned int vec_reve (vector unsigned int);
17043 vector bool short vec_reve (vector bool short);
17044 vector signed short vec_reve (vector signed short);
17045 vector unsigned short vec_reve (vector unsigned short);
17047 vector signed char vec_rl (vector signed char, vector unsigned char);
17048 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
17049 vector signed short vec_rl (vector signed short, vector unsigned short);
17050 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
17051 vector signed int vec_rl (vector signed int, vector unsigned int);
17052 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17054 vector float vec_round (vector float);
17056 vector float vec_rsqrt (vector float);
17058 vector float vec_rsqrte (vector float);
17060 vector float vec_sel (vector float, vector float, vector bool int);
17061 vector float vec_sel (vector float, vector float, vector unsigned int);
17062 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
17063 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
17064 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
17065 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
17066                              vector unsigned int);
17067 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
17068 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
17069 vector signed short vec_sel (vector signed short, vector signed short,
17070                              vector bool short);
17071 vector signed short vec_sel (vector signed short, vector signed short,
17072                              vector unsigned short);
17073 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17074                                vector bool short);
17075 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17076                                vector unsigned short);
17077 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
17078 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
17079 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
17080 vector signed char vec_sel (vector signed char, vector signed char,
17081                             vector unsigned char);
17082 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17083                               vector bool char);
17084 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17085                               vector unsigned char);
17086 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
17087 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
17089 vector signed char vec_sl (vector signed char, vector unsigned char);
17090 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
17091 vector signed short vec_sl (vector signed short, vector unsigned short);
17092 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
17093 vector signed int vec_sl (vector signed int, vector unsigned int);
17094 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17096 vector float vec_sld (vector float, vector float, const int);
17097 vector signed int vec_sld (vector signed int, vector signed int, const int);
17098 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
17099 vector bool int vec_sld (vector bool int, vector bool int, const int);
17100 vector signed short vec_sld (vector signed short, vector signed short, const int);
17101 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
17102 vector bool short vec_sld (vector bool short, vector bool short, const int);
17103 vector pixel vec_sld (vector pixel, vector pixel, const int);
17104 vector signed char vec_sld (vector signed char, vector signed char, const int);
17105 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
17106 vector bool char vec_sld (vector bool char, vector bool char, const int);
17108 vector signed int vec_sll (vector signed int, vector unsigned int);
17109 vector signed int vec_sll (vector signed int, vector unsigned short);
17110 vector signed int vec_sll (vector signed int, vector unsigned char);
17111 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
17112 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
17113 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
17114 vector bool int vec_sll (vector bool int, vector unsigned int);
17115 vector bool int vec_sll (vector bool int, vector unsigned short);
17116 vector bool int vec_sll (vector bool int, vector unsigned char);
17117 vector signed short vec_sll (vector signed short, vector unsigned int);
17118 vector signed short vec_sll (vector signed short, vector unsigned short);
17119 vector signed short vec_sll (vector signed short, vector unsigned char);
17120 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
17121 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
17122 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
17123 vector bool short vec_sll (vector bool short, vector unsigned int);
17124 vector bool short vec_sll (vector bool short, vector unsigned short);
17125 vector bool short vec_sll (vector bool short, vector unsigned char);
17126 vector pixel vec_sll (vector pixel, vector unsigned int);
17127 vector pixel vec_sll (vector pixel, vector unsigned short);
17128 vector pixel vec_sll (vector pixel, vector unsigned char);
17129 vector signed char vec_sll (vector signed char, vector unsigned int);
17130 vector signed char vec_sll (vector signed char, vector unsigned short);
17131 vector signed char vec_sll (vector signed char, vector unsigned char);
17132 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
17133 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
17134 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
17135 vector bool char vec_sll (vector bool char, vector unsigned int);
17136 vector bool char vec_sll (vector bool char, vector unsigned short);
17137 vector bool char vec_sll (vector bool char, vector unsigned char);
17139 vector float vec_slo (vector float, vector signed char);
17140 vector float vec_slo (vector float, vector unsigned char);
17141 vector signed int vec_slo (vector signed int, vector signed char);
17142 vector signed int vec_slo (vector signed int, vector unsigned char);
17143 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17144 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17145 vector signed short vec_slo (vector signed short, vector signed char);
17146 vector signed short vec_slo (vector signed short, vector unsigned char);
17147 vector unsigned short vec_slo (vector unsigned short, vector signed char);
17148 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
17149 vector pixel vec_slo (vector pixel, vector signed char);
17150 vector pixel vec_slo (vector pixel, vector unsigned char);
17151 vector signed char vec_slo (vector signed char, vector signed char);
17152 vector signed char vec_slo (vector signed char, vector unsigned char);
17153 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17154 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
17156 vector signed char vec_splat (vector signed char, const int);
17157 vector unsigned char vec_splat (vector unsigned char, const int);
17158 vector bool char vec_splat (vector bool char, const int);
17159 vector signed short vec_splat (vector signed short, const int);
17160 vector unsigned short vec_splat (vector unsigned short, const int);
17161 vector bool short vec_splat (vector bool short, const int);
17162 vector pixel vec_splat (vector pixel, const int);
17163 vector float vec_splat (vector float, const int);
17164 vector signed int vec_splat (vector signed int, const int);
17165 vector unsigned int vec_splat (vector unsigned int, const int);
17166 vector bool int vec_splat (vector bool int, const int);
17168 vector signed short vec_splat_s16 (const int);
17170 vector signed int vec_splat_s32 (const int);
17172 vector signed char vec_splat_s8 (const int);
17174 vector unsigned short vec_splat_u16 (const int);
17176 vector unsigned int vec_splat_u32 (const int);
17178 vector unsigned char vec_splat_u8 (const int);
17180 vector signed char vec_splats (signed char);
17181 vector unsigned char vec_splats (unsigned char);
17182 vector signed short vec_splats (signed short);
17183 vector unsigned short vec_splats (unsigned short);
17184 vector signed int vec_splats (signed int);
17185 vector unsigned int vec_splats (unsigned int);
17186 vector float vec_splats (float);
17188 vector signed char vec_sr (vector signed char, vector unsigned char);
17189 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
17190 vector signed short vec_sr (vector signed short, vector unsigned short);
17191 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
17192 vector signed int vec_sr (vector signed int, vector unsigned int);
17193 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17195 vector signed char vec_sra (vector signed char, vector unsigned char);
17196 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
17197 vector signed short vec_sra (vector signed short, vector unsigned short);
17198 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
17199 vector signed int vec_sra (vector signed int, vector unsigned int);
17200 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17202 vector signed int vec_srl (vector signed int, vector unsigned int);
17203 vector signed int vec_srl (vector signed int, vector unsigned short);
17204 vector signed int vec_srl (vector signed int, vector unsigned char);
17205 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17206 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
17207 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17208 vector bool int vec_srl (vector bool int, vector unsigned int);
17209 vector bool int vec_srl (vector bool int, vector unsigned short);
17210 vector bool int vec_srl (vector bool int, vector unsigned char);
17211 vector signed short vec_srl (vector signed short, vector unsigned int);
17212 vector signed short vec_srl (vector signed short, vector unsigned short);
17213 vector signed short vec_srl (vector signed short, vector unsigned char);
17214 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
17215 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
17216 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
17217 vector bool short vec_srl (vector bool short, vector unsigned int);
17218 vector bool short vec_srl (vector bool short, vector unsigned short);
17219 vector bool short vec_srl (vector bool short, vector unsigned char);
17220 vector pixel vec_srl (vector pixel, vector unsigned int);
17221 vector pixel vec_srl (vector pixel, vector unsigned short);
17222 vector pixel vec_srl (vector pixel, vector unsigned char);
17223 vector signed char vec_srl (vector signed char, vector unsigned int);
17224 vector signed char vec_srl (vector signed char, vector unsigned short);
17225 vector signed char vec_srl (vector signed char, vector unsigned char);
17226 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
17227 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
17228 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
17229 vector bool char vec_srl (vector bool char, vector unsigned int);
17230 vector bool char vec_srl (vector bool char, vector unsigned short);
17231 vector bool char vec_srl (vector bool char, vector unsigned char);
17233 vector float vec_sro (vector float, vector signed char);
17234 vector float vec_sro (vector float, vector unsigned char);
17235 vector signed int vec_sro (vector signed int, vector signed char);
17236 vector signed int vec_sro (vector signed int, vector unsigned char);
17237 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17238 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17239 vector signed short vec_sro (vector signed short, vector signed char);
17240 vector signed short vec_sro (vector signed short, vector unsigned char);
17241 vector unsigned short vec_sro (vector unsigned short, vector signed char);
17242 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
17243 vector pixel vec_sro (vector pixel, vector signed char);
17244 vector pixel vec_sro (vector pixel, vector unsigned char);
17245 vector signed char vec_sro (vector signed char, vector signed char);
17246 vector signed char vec_sro (vector signed char, vector unsigned char);
17247 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17248 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
17250 void vec_st (vector float, int, vector float *);
17251 void vec_st (vector float, int, float *);
17252 void vec_st (vector signed int, int, vector signed int *);
17253 void vec_st (vector signed int, int, int *);
17254 void vec_st (vector unsigned int, int, vector unsigned int *);
17255 void vec_st (vector unsigned int, int, unsigned int *);
17256 void vec_st (vector bool int, int, vector bool int *);
17257 void vec_st (vector bool int, int, unsigned int *);
17258 void vec_st (vector bool int, int, int *);
17259 void vec_st (vector signed short, int, vector signed short *);
17260 void vec_st (vector signed short, int, short *);
17261 void vec_st (vector unsigned short, int, vector unsigned short *);
17262 void vec_st (vector unsigned short, int, unsigned short *);
17263 void vec_st (vector bool short, int, vector bool short *);
17264 void vec_st (vector bool short, int, unsigned short *);
17265 void vec_st (vector pixel, int, vector pixel *);
17266 void vec_st (vector bool short, int, short *);
17267 void vec_st (vector signed char, int, vector signed char *);
17268 void vec_st (vector signed char, int, signed char *);
17269 void vec_st (vector unsigned char, int, vector unsigned char *);
17270 void vec_st (vector unsigned char, int, unsigned char *);
17271 void vec_st (vector bool char, int, vector bool char *);
17272 void vec_st (vector bool char, int, unsigned char *);
17273 void vec_st (vector bool char, int, signed char *);
17275 void vec_ste (vector signed char, int, signed char *);
17276 void vec_ste (vector unsigned char, int, unsigned char *);
17277 void vec_ste (vector bool char, int, signed char *);
17278 void vec_ste (vector bool char, int, unsigned char *);
17279 void vec_ste (vector signed short, int, short *);
17280 void vec_ste (vector unsigned short, int, unsigned short *);
17281 void vec_ste (vector bool short, int, short *);
17282 void vec_ste (vector bool short, int, unsigned short *);
17283 void vec_ste (vector pixel, int, short *);
17284 void vec_ste (vector pixel, int, unsigned short *);
17285 void vec_ste (vector float, int, float *);
17286 void vec_ste (vector signed int, int, int *);
17287 void vec_ste (vector unsigned int, int, unsigned int *);
17288 void vec_ste (vector bool int, int, int *);
17289 void vec_ste (vector bool int, int, unsigned int *);
17291 void vec_stl (vector float, int, vector float *);
17292 void vec_stl (vector float, int, float *);
17293 void vec_stl (vector signed int, int, vector signed int *);
17294 void vec_stl (vector signed int, int, int *);
17295 void vec_stl (vector unsigned int, int, vector unsigned int *);
17296 void vec_stl (vector unsigned int, int, unsigned int *);
17297 void vec_stl (vector bool int, int, vector bool int *);
17298 void vec_stl (vector bool int, int, unsigned int *);
17299 void vec_stl (vector bool int, int, int *);
17300 void vec_stl (vector signed short, int, vector signed short *);
17301 void vec_stl (vector signed short, int, short *);
17302 void vec_stl (vector unsigned short, int, vector unsigned short *);
17303 void vec_stl (vector unsigned short, int, unsigned short *);
17304 void vec_stl (vector bool short, int, vector bool short *);
17305 void vec_stl (vector bool short, int, unsigned short *);
17306 void vec_stl (vector bool short, int, short *);
17307 void vec_stl (vector pixel, int, vector pixel *);
17308 void vec_stl (vector signed char, int, vector signed char *);
17309 void vec_stl (vector signed char, int, signed char *);
17310 void vec_stl (vector unsigned char, int, vector unsigned char *);
17311 void vec_stl (vector unsigned char, int, unsigned char *);
17312 void vec_stl (vector bool char, int, vector bool char *);
17313 void vec_stl (vector bool char, int, unsigned char *);
17314 void vec_stl (vector bool char, int, signed char *);
17316 void vec_stvebx (vector signed char, int, signed char *);
17317 void vec_stvebx (vector unsigned char, int, unsigned char *);
17318 void vec_stvebx (vector bool char, int, signed char *);
17319 void vec_stvebx (vector bool char, int, unsigned char *);
17321 void vec_stvehx (vector signed short, int, short *);
17322 void vec_stvehx (vector unsigned short, int, unsigned short *);
17323 void vec_stvehx (vector bool short, int, short *);
17324 void vec_stvehx (vector bool short, int, unsigned short *);
17326 void vec_stvewx (vector float, int, float *);
17327 void vec_stvewx (vector signed int, int, int *);
17328 void vec_stvewx (vector unsigned int, int, unsigned int *);
17329 void vec_stvewx (vector bool int, int, int *);
17330 void vec_stvewx (vector bool int, int, unsigned int *);
17332 vector signed char vec_sub (vector bool char, vector signed char);
17333 vector signed char vec_sub (vector signed char, vector bool char);
17334 vector signed char vec_sub (vector signed char, vector signed char);
17335 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17336 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17337 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
17338 vector signed short vec_sub (vector bool short, vector signed short);
17339 vector signed short vec_sub (vector signed short, vector bool short);
17340 vector signed short vec_sub (vector signed short, vector signed short);
17341 vector unsigned short vec_sub (vector bool short, vector unsigned short);
17342 vector unsigned short vec_sub (vector unsigned short, vector bool short);
17343 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
17344 vector signed int vec_sub (vector bool int, vector signed int);
17345 vector signed int vec_sub (vector signed int, vector bool int);
17346 vector signed int vec_sub (vector signed int, vector signed int);
17347 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17348 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17349 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17350 vector float vec_sub (vector float, vector float);
17352 vector signed int vec_subc (vector signed int, vector signed int);
17353 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17355 vector signed int vec_sube (vector signed int, vector signed int,
17356                             vector signed int);
17357 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17358                               vector unsigned int);
17360 vector signed int vec_subec (vector signed int, vector signed int,
17361                              vector signed int);
17362 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17363                                vector unsigned int);
17365 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17366 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17367 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
17368 vector signed char vec_subs (vector bool char, vector signed char);
17369 vector signed char vec_subs (vector signed char, vector bool char);
17370 vector signed char vec_subs (vector signed char, vector signed char);
17371 vector unsigned short vec_subs (vector bool short, vector unsigned short);
17372 vector unsigned short vec_subs (vector unsigned short, vector bool short);
17373 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
17374 vector signed short vec_subs (vector bool short, vector signed short);
17375 vector signed short vec_subs (vector signed short, vector bool short);
17376 vector signed short vec_subs (vector signed short, vector signed short);
17377 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17378 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17379 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17380 vector signed int vec_subs (vector bool int, vector signed int);
17381 vector signed int vec_subs (vector signed int, vector bool int);
17382 vector signed int vec_subs (vector signed int, vector signed int);
17384 vector signed int vec_sum2s (vector signed int, vector signed int);
17386 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
17387 vector signed int vec_sum4s (vector signed char, vector signed int);
17388 vector signed int vec_sum4s (vector signed short, vector signed int);
17390 vector signed int vec_sums (vector signed int, vector signed int);
17392 vector float vec_trunc (vector float);
17394 vector signed short vec_unpackh (vector signed char);
17395 vector bool short vec_unpackh (vector bool char);
17396 vector signed int vec_unpackh (vector signed short);
17397 vector bool int vec_unpackh (vector bool short);
17398 vector unsigned int vec_unpackh (vector pixel);
17400 vector signed short vec_unpackl (vector signed char);
17401 vector bool short vec_unpackl (vector bool char);
17402 vector unsigned int vec_unpackl (vector pixel);
17403 vector signed int vec_unpackl (vector signed short);
17404 vector bool int vec_unpackl (vector bool short);
17406 vector float vec_vaddfp (vector float, vector float);
17408 vector signed char vec_vaddsbs (vector bool char, vector signed char);
17409 vector signed char vec_vaddsbs (vector signed char, vector bool char);
17410 vector signed char vec_vaddsbs (vector signed char, vector signed char);
17412 vector signed short vec_vaddshs (vector bool short, vector signed short);
17413 vector signed short vec_vaddshs (vector signed short, vector bool short);
17414 vector signed short vec_vaddshs (vector signed short, vector signed short);
17416 vector signed int vec_vaddsws (vector bool int, vector signed int);
17417 vector signed int vec_vaddsws (vector signed int, vector bool int);
17418 vector signed int vec_vaddsws (vector signed int, vector signed int);
17420 vector signed char vec_vaddubm (vector bool char, vector signed char);
17421 vector signed char vec_vaddubm (vector signed char, vector bool char);
17422 vector signed char vec_vaddubm (vector signed char, vector signed char);
17423 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
17424 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
17425 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
17427 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
17428 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
17429 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
17431 vector signed short vec_vadduhm (vector bool short, vector signed short);
17432 vector signed short vec_vadduhm (vector signed short, vector bool short);
17433 vector signed short vec_vadduhm (vector signed short, vector signed short);
17434 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
17435 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
17436 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
17438 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
17439 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
17440 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
17442 vector signed int vec_vadduwm (vector bool int, vector signed int);
17443 vector signed int vec_vadduwm (vector signed int, vector bool int);
17444 vector signed int vec_vadduwm (vector signed int, vector signed int);
17445 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
17446 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
17447 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
17449 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
17450 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
17451 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
17453 vector signed char vec_vavgsb (vector signed char, vector signed char);
17455 vector signed short vec_vavgsh (vector signed short, vector signed short);
17457 vector signed int vec_vavgsw (vector signed int, vector signed int);
17459 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
17461 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
17463 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
17465 vector float vec_vcfsx (vector signed int, const int);
17467 vector float vec_vcfux (vector unsigned int, const int);
17469 vector bool int vec_vcmpeqfp (vector float, vector float);
17471 vector bool char vec_vcmpequb (vector signed char, vector signed char);
17472 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
17474 vector bool short vec_vcmpequh (vector signed short, vector signed short);
17475 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
17477 vector bool int vec_vcmpequw (vector signed int, vector signed int);
17478 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
17480 vector bool int vec_vcmpgtfp (vector float, vector float);
17482 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
17484 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
17486 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
17488 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
17490 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
17492 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
17494 vector float vec_vmaxfp (vector float, vector float);
17496 vector signed char vec_vmaxsb (vector bool char, vector signed char);
17497 vector signed char vec_vmaxsb (vector signed char, vector bool char);
17498 vector signed char vec_vmaxsb (vector signed char, vector signed char);
17500 vector signed short vec_vmaxsh (vector bool short, vector signed short);
17501 vector signed short vec_vmaxsh (vector signed short, vector bool short);
17502 vector signed short vec_vmaxsh (vector signed short, vector signed short);
17504 vector signed int vec_vmaxsw (vector bool int, vector signed int);
17505 vector signed int vec_vmaxsw (vector signed int, vector bool int);
17506 vector signed int vec_vmaxsw (vector signed int, vector signed int);
17508 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
17509 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
17510 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
17512 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
17513 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
17514 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
17516 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
17517 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
17518 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
17520 vector float vec_vminfp (vector float, vector float);
17522 vector signed char vec_vminsb (vector bool char, vector signed char);
17523 vector signed char vec_vminsb (vector signed char, vector bool char);
17524 vector signed char vec_vminsb (vector signed char, vector signed char);
17526 vector signed short vec_vminsh (vector bool short, vector signed short);
17527 vector signed short vec_vminsh (vector signed short, vector bool short);
17528 vector signed short vec_vminsh (vector signed short, vector signed short);
17530 vector signed int vec_vminsw (vector bool int, vector signed int);
17531 vector signed int vec_vminsw (vector signed int, vector bool int);
17532 vector signed int vec_vminsw (vector signed int, vector signed int);
17534 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
17535 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
17536 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
17538 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
17539 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
17540 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
17542 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
17543 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
17544 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
17546 vector bool char vec_vmrghb (vector bool char, vector bool char);
17547 vector signed char vec_vmrghb (vector signed char, vector signed char);
17548 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
17550 vector bool short vec_vmrghh (vector bool short, vector bool short);
17551 vector signed short vec_vmrghh (vector signed short, vector signed short);
17552 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
17553 vector pixel vec_vmrghh (vector pixel, vector pixel);
17555 vector float vec_vmrghw (vector float, vector float);
17556 vector bool int vec_vmrghw (vector bool int, vector bool int);
17557 vector signed int vec_vmrghw (vector signed int, vector signed int);
17558 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
17560 vector bool char vec_vmrglb (vector bool char, vector bool char);
17561 vector signed char vec_vmrglb (vector signed char, vector signed char);
17562 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
17564 vector bool short vec_vmrglh (vector bool short, vector bool short);
17565 vector signed short vec_vmrglh (vector signed short, vector signed short);
17566 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
17567 vector pixel vec_vmrglh (vector pixel, vector pixel);
17569 vector float vec_vmrglw (vector float, vector float);
17570 vector signed int vec_vmrglw (vector signed int, vector signed int);
17571 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
17572 vector bool int vec_vmrglw (vector bool int, vector bool int);
17574 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
17575                                 vector signed int);
17577 vector signed int vec_vmsumshm (vector signed short, vector signed short,
17578                                 vector signed int);
17580 vector signed int vec_vmsumshs (vector signed short, vector signed short,
17581                                 vector signed int);
17583 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
17584                                   vector unsigned int);
17586 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
17587                                   vector unsigned int);
17589 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
17590                                   vector unsigned int);
17592 vector signed short vec_vmulesb (vector signed char, vector signed char);
17594 vector signed int vec_vmulesh (vector signed short, vector signed short);
17596 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
17598 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
17600 vector signed short vec_vmulosb (vector signed char, vector signed char);
17602 vector signed int vec_vmulosh (vector signed short, vector signed short);
17604 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
17606 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
17608 vector signed char vec_vpkshss (vector signed short, vector signed short);
17610 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
17612 vector signed short vec_vpkswss (vector signed int, vector signed int);
17614 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
17616 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17617 vector signed char vec_vpkuhum (vector signed short, vector signed short);
17618 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
17620 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
17622 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17623 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17624 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
17626 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
17628 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17629 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
17631 vector signed short vec_vrlh (vector signed short, vector unsigned short);
17632 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
17634 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17635 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17637 vector signed char vec_vslb (vector signed char, vector unsigned char);
17638 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
17640 vector signed short vec_vslh (vector signed short, vector unsigned short);
17641 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
17643 vector signed int vec_vslw (vector signed int, vector unsigned int);
17644 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17646 vector signed char vec_vspltb (vector signed char, const int);
17647 vector unsigned char vec_vspltb (vector unsigned char, const int);
17648 vector bool char vec_vspltb (vector bool char, const int);
17650 vector bool short vec_vsplth (vector bool short, const int);
17651 vector signed short vec_vsplth (vector signed short, const int);
17652 vector unsigned short vec_vsplth (vector unsigned short, const int);
17653 vector pixel vec_vsplth (vector pixel, const int);
17655 vector float vec_vspltw (vector float, const int);
17656 vector signed int vec_vspltw (vector signed int, const int);
17657 vector unsigned int vec_vspltw (vector unsigned int, const int);
17658 vector bool int vec_vspltw (vector bool int, const int);
17660 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17661 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
17663 vector signed short vec_vsrah (vector signed short, vector unsigned short);
17664 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
17666 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17667 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
17669 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17670 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
17672 vector signed short vec_vsrh (vector signed short, vector unsigned short);
17673 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
17675 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17676 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17678 vector float vec_vsubfp (vector float, vector float);
17680 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17681 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17682 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17684 vector signed short vec_vsubshs (vector bool short, vector signed short);
17685 vector signed short vec_vsubshs (vector signed short, vector bool short);
17686 vector signed short vec_vsubshs (vector signed short, vector signed short);
17688 vector signed int vec_vsubsws (vector bool int, vector signed int);
17689 vector signed int vec_vsubsws (vector signed int, vector bool int);
17690 vector signed int vec_vsubsws (vector signed int, vector signed int);
17692 vector signed char vec_vsububm (vector bool char, vector signed char);
17693 vector signed char vec_vsububm (vector signed char, vector bool char);
17694 vector signed char vec_vsububm (vector signed char, vector signed char);
17695 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
17696 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
17697 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
17699 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
17700 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
17701 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
17703 vector signed short vec_vsubuhm (vector bool short, vector signed short);
17704 vector signed short vec_vsubuhm (vector signed short, vector bool short);
17705 vector signed short vec_vsubuhm (vector signed short, vector signed short);
17706 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
17707 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
17708 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
17710 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
17711 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
17712 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
17714 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17715 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17716 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17717 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17718 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17719 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
17721 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17722 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17723 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
17725 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17727 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17729 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
17731 vector unsigned int vec_vupkhpx (vector pixel);
17733 vector bool short vec_vupkhsb (vector bool char);
17734 vector signed short vec_vupkhsb (vector signed char);
17736 vector bool int vec_vupkhsh (vector bool short);
17737 vector signed int vec_vupkhsh (vector signed short);
17739 vector unsigned int vec_vupklpx (vector pixel);
17741 vector bool short vec_vupklsb (vector bool char);
17742 vector signed short vec_vupklsb (vector signed char);
17744 vector bool int vec_vupklsh (vector bool short);
17745 vector signed int vec_vupklsh (vector signed short);
17747 vector float vec_xor (vector float, vector float);
17748 vector float vec_xor (vector float, vector bool int);
17749 vector float vec_xor (vector bool int, vector float);
17750 vector bool int vec_xor (vector bool int, vector bool int);
17751 vector signed int vec_xor (vector bool int, vector signed int);
17752 vector signed int vec_xor (vector signed int, vector bool int);
17753 vector signed int vec_xor (vector signed int, vector signed int);
17754 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17755 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17756 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17757 vector bool short vec_xor (vector bool short, vector bool short);
17758 vector signed short vec_xor (vector bool short, vector signed short);
17759 vector signed short vec_xor (vector signed short, vector bool short);
17760 vector signed short vec_xor (vector signed short, vector signed short);
17761 vector unsigned short vec_xor (vector bool short, vector unsigned short);
17762 vector unsigned short vec_xor (vector unsigned short, vector bool short);
17763 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
17764 vector signed char vec_xor (vector bool char, vector signed char);
17765 vector bool char vec_xor (vector bool char, vector bool char);
17766 vector signed char vec_xor (vector signed char, vector bool char);
17767 vector signed char vec_xor (vector signed char, vector signed char);
17768 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17769 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17770 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
17771 @end smallexample
17773 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
17774 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
17776 The AltiVec built-in functions described in this section are
17777 available on the PowerPC family of processors starting with ISA 2.06
17778 or later.  These are normally enabled by adding @option{-mvsx} to the
17779 command line.
17781 When @option{-mvsx} is used, the following additional vector types are
17782 implemented.
17784 @smallexample
17785 vector unsigned __int128
17786 vector signed __int128
17787 vector unsigned long long int
17788 vector signed long long int
17789 vector double
17790 @end smallexample
17792 The long long types are only implemented for 64-bit code generation.
17794 @smallexample
17796 vector bool long long vec_and (vector bool long long int, vector bool long long);
17798 vector double vec_ctf (vector unsigned long, const int);
17799 vector double vec_ctf (vector signed long, const int);
17801 vector signed long vec_cts (vector double, const int);
17803 vector unsigned long vec_ctu (vector double, const int);
17805 void vec_dst (const unsigned long *, int, const int);
17806 void vec_dst (const long *, int, const int);
17808 void vec_dststt (const unsigned long *, int, const int);
17809 void vec_dststt (const long *, int, const int);
17811 void vec_dstt (const unsigned long *, int, const int);
17812 void vec_dstt (const long *, int, const int);
17814 vector unsigned char vec_lvsl (int, const unsigned long *);
17815 vector unsigned char vec_lvsl (int, const long *);
17817 vector unsigned char vec_lvsr (int, const unsigned long *);
17818 vector unsigned char vec_lvsr (int, const long *);
17820 vector double vec_mul (vector double, vector double);
17821 vector long vec_mul (vector long, vector long);
17822 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17824 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
17825 vector signed long long vec_mule (vector signed int, vector signed int);
17827 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
17828 vector signed long long vec_mulo (vector signed int, vector signed int);
17830 vector double vec_nabs (vector double);
17832 vector bool long long vec_reve (vector bool long long);
17833 vector signed long long vec_reve (vector signed long long);
17834 vector unsigned long long vec_reve (vector unsigned long long);
17835 vector double vec_sld (vector double, vector double, const int);
17837 vector bool long long int vec_sld (vector bool long long int,
17838                                    vector bool long long int, const int);
17839 vector long long int vec_sld (vector long long int, vector  long long int, const int);
17840 vector unsigned long long int vec_sld (vector unsigned long long int,
17841                                        vector unsigned long long int, const int);
17843 vector long long int vec_sll (vector long long int, vector unsigned char);
17844 vector unsigned long long int vec_sll (vector unsigned long long int,
17845                                        vector unsigned char);
17847 vector signed long long vec_slo (vector signed long long, vector signed char);
17848 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17849 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17850 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17852 vector signed long vec_splat (vector signed long, const int);
17853 vector unsigned long vec_splat (vector unsigned long, const int);
17855 vector long long int vec_srl (vector long long int, vector unsigned char);
17856 vector unsigned long long int vec_srl (vector unsigned long long int,
17857                                        vector unsigned char);
17859 vector long long int vec_sro (vector long long int, vector char);
17860 vector long long int vec_sro (vector long long int, vector unsigned char);
17861 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
17862 vector unsigned long long int vec_sro (vector unsigned long long int,
17863                                        vector unsigned char);
17865 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
17866 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
17868 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
17869                                  vector signed __int128);
17870 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
17871                                    vector unsigned __int128);
17873 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
17874                                   vector signed __int128);
17875 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
17876                                     vector unsigned __int128);
17878 vector double vec_unpackh (vector float);
17880 vector double vec_unpackl (vector float);
17882 vector double vec_doublee (vector float);
17883 vector double vec_doublee (vector signed int);
17884 vector double vec_doublee (vector unsigned int);
17886 vector double vec_doubleo (vector float);
17887 vector double vec_doubleo (vector signed int);
17888 vector double vec_doubleo (vector unsigned int);
17890 vector double vec_doubleh (vector float);
17891 vector double vec_doubleh (vector signed int);
17892 vector double vec_doubleh (vector unsigned int);
17894 vector double vec_doublel (vector float);
17895 vector double vec_doublel (vector signed int);
17896 vector double vec_doublel (vector unsigned int);
17898 vector float vec_float (vector signed int);
17899 vector float vec_float (vector unsigned int);
17901 vector float vec_float2 (vector signed long long, vector signed long long);
17902 vector float vec_float2 (vector unsigned long long, vector signed long long);
17904 vector float vec_floate (vector double);
17905 vector float vec_floate (vector signed long long);
17906 vector float vec_floate (vector unsigned long long);
17908 vector float vec_floato (vector double);
17909 vector float vec_floato (vector signed long long);
17910 vector float vec_floato (vector unsigned long long);
17912 vector signed long long vec_signed (vector double);
17913 vector signed int vec_signed (vector float);
17915 vector signed int vec_signede (vector double);
17917 vector signed int vec_signedo (vector double);
17919 vector signed char vec_sldw (vector signed char, vector signed char, const int);
17920 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
17921 vector signed short vec_sldw (vector signed short, vector signed short, const int);
17922 vector unsigned short vec_sldw (vector unsigned short,
17923                                 vector unsigned short, const int);
17924 vector signed int vec_sldw (vector signed int, vector signed int, const int);
17925 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
17926 vector signed long long vec_sldw (vector signed long long,
17927                                   vector signed long long, const int);
17928 vector unsigned long long vec_sldw (vector unsigned long long,
17929                                     vector unsigned long long, const int);
17931 vector signed long long vec_unsigned (vector double);
17932 vector signed int vec_unsigned (vector float);
17934 vector signed int vec_unsignede (vector double);
17936 vector signed int vec_unsignedo (vector double);
17938 vector double vec_abs (vector double);
17939 vector double vec_add (vector double, vector double);
17940 vector double vec_and (vector double, vector double);
17941 vector double vec_and (vector double, vector bool long);
17942 vector double vec_and (vector bool long, vector double);
17943 vector long vec_and (vector long, vector long);
17944 vector long vec_and (vector long, vector bool long);
17945 vector long vec_and (vector bool long, vector long);
17946 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17947 vector unsigned long vec_and (vector unsigned long, vector bool long);
17948 vector unsigned long vec_and (vector bool long, vector unsigned long);
17949 vector double vec_andc (vector double, vector double);
17950 vector double vec_andc (vector double, vector bool long);
17951 vector double vec_andc (vector bool long, vector double);
17952 vector long vec_andc (vector long, vector long);
17953 vector long vec_andc (vector long, vector bool long);
17954 vector long vec_andc (vector bool long, vector long);
17955 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17956 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17957 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17958 vector double vec_ceil (vector double);
17959 vector bool long vec_cmpeq (vector double, vector double);
17960 vector bool long vec_cmpge (vector double, vector double);
17961 vector bool long vec_cmpgt (vector double, vector double);
17962 vector bool long vec_cmple (vector double, vector double);
17963 vector bool long vec_cmplt (vector double, vector double);
17964 vector double vec_cpsgn (vector double, vector double);
17965 vector float vec_div (vector float, vector float);
17966 vector double vec_div (vector double, vector double);
17967 vector long vec_div (vector long, vector long);
17968 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17969 vector double vec_floor (vector double);
17970 vector __int128 vec_ld (int, const vector __int128 *);
17971 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
17972 vector __int128 vec_ld (int, const __int128 *);
17973 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
17974 vector double vec_ld (int, const vector double *);
17975 vector double vec_ld (int, const double *);
17976 vector double vec_ldl (int, const vector double *);
17977 vector double vec_ldl (int, const double *);
17978 vector unsigned char vec_lvsl (int, const double *);
17979 vector unsigned char vec_lvsr (int, const double *);
17980 vector double vec_madd (vector double, vector double, vector double);
17981 vector double vec_max (vector double, vector double);
17982 vector signed long vec_mergeh (vector signed long, vector signed long);
17983 vector signed long vec_mergeh (vector signed long, vector bool long);
17984 vector signed long vec_mergeh (vector bool long, vector signed long);
17985 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17986 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17987 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17988 vector signed long vec_mergel (vector signed long, vector signed long);
17989 vector signed long vec_mergel (vector signed long, vector bool long);
17990 vector signed long vec_mergel (vector bool long, vector signed long);
17991 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17992 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17993 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17994 vector double vec_min (vector double, vector double);
17995 vector float vec_msub (vector float, vector float, vector float);
17996 vector double vec_msub (vector double, vector double, vector double);
17997 vector float vec_nearbyint (vector float);
17998 vector double vec_nearbyint (vector double);
17999 vector float vec_nmadd (vector float, vector float, vector float);
18000 vector double vec_nmadd (vector double, vector double, vector double);
18001 vector double vec_nmsub (vector double, vector double, vector double);
18002 vector double vec_nor (vector double, vector double);
18003 vector long vec_nor (vector long, vector long);
18004 vector long vec_nor (vector long, vector bool long);
18005 vector long vec_nor (vector bool long, vector long);
18006 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18007 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18008 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18009 vector double vec_or (vector double, vector double);
18010 vector double vec_or (vector double, vector bool long);
18011 vector double vec_or (vector bool long, vector double);
18012 vector long vec_or (vector long, vector long);
18013 vector long vec_or (vector long, vector bool long);
18014 vector long vec_or (vector bool long, vector long);
18015 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18016 vector unsigned long vec_or (vector unsigned long, vector bool long);
18017 vector unsigned long vec_or (vector bool long, vector unsigned long);
18018 vector double vec_perm (vector double, vector double, vector unsigned char);
18019 vector long vec_perm (vector long, vector long, vector unsigned char);
18020 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18021                                vector unsigned char);
18022 vector bool char vec_permxor (vector bool char, vector bool char,
18023                               vector bool char);
18024 vector unsigned char vec_permxor (vector signed char, vector signed char,
18025                                   vector signed char);
18026 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
18027                                   vector unsigned char);
18028 vector double vec_rint (vector double);
18029 vector double vec_recip (vector double, vector double);
18030 vector double vec_rsqrt (vector double);
18031 vector double vec_rsqrte (vector double);
18032 vector double vec_sel (vector double, vector double, vector bool long);
18033 vector double vec_sel (vector double, vector double, vector unsigned long);
18034 vector long vec_sel (vector long, vector long, vector long);
18035 vector long vec_sel (vector long, vector long, vector unsigned long);
18036 vector long vec_sel (vector long, vector long, vector bool long);
18037 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18038                               vector long);
18039 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18040                               vector unsigned long);
18041 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18042                               vector bool long);
18043 vector double vec_splats (double);
18044 vector signed long vec_splats (signed long);
18045 vector unsigned long vec_splats (unsigned long);
18046 vector float vec_sqrt (vector float);
18047 vector double vec_sqrt (vector double);
18048 void vec_st (vector double, int, vector double *);
18049 void vec_st (vector double, int, double *);
18050 vector double vec_sub (vector double, vector double);
18051 vector double vec_trunc (vector double);
18052 vector double vec_xl (int, vector double *);
18053 vector double vec_xl (int, double *);
18054 vector long long vec_xl (int, vector long long *);
18055 vector long long vec_xl (int, long long *);
18056 vector unsigned long long vec_xl (int, vector unsigned long long *);
18057 vector unsigned long long vec_xl (int, unsigned long long *);
18058 vector float vec_xl (int, vector float *);
18059 vector float vec_xl (int, float *);
18060 vector int vec_xl (int, vector int *);
18061 vector int vec_xl (int, int *);
18062 vector unsigned int vec_xl (int, vector unsigned int *);
18063 vector unsigned int vec_xl (int, unsigned int *);
18064 vector double vec_xor (vector double, vector double);
18065 vector double vec_xor (vector double, vector bool long);
18066 vector double vec_xor (vector bool long, vector double);
18067 vector long vec_xor (vector long, vector long);
18068 vector long vec_xor (vector long, vector bool long);
18069 vector long vec_xor (vector bool long, vector long);
18070 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18071 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18072 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18073 void vec_xst (vector double, int, vector double *);
18074 void vec_xst (vector double, int, double *);
18075 void vec_xst (vector long long, int, vector long long *);
18076 void vec_xst (vector long long, int, long long *);
18077 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18078 void vec_xst (vector unsigned long long, int, unsigned long long *);
18079 void vec_xst (vector float, int, vector float *);
18080 void vec_xst (vector float, int, float *);
18081 void vec_xst (vector int, int, vector int *);
18082 void vec_xst (vector int, int, int *);
18083 void vec_xst (vector unsigned int, int, vector unsigned int *);
18084 void vec_xst (vector unsigned int, int, unsigned int *);
18085 int vec_all_eq (vector double, vector double);
18086 int vec_all_ge (vector double, vector double);
18087 int vec_all_gt (vector double, vector double);
18088 int vec_all_le (vector double, vector double);
18089 int vec_all_lt (vector double, vector double);
18090 int vec_all_nan (vector double);
18091 int vec_all_ne (vector double, vector double);
18092 int vec_all_nge (vector double, vector double);
18093 int vec_all_ngt (vector double, vector double);
18094 int vec_all_nle (vector double, vector double);
18095 int vec_all_nlt (vector double, vector double);
18096 int vec_all_numeric (vector double);
18097 int vec_any_eq (vector double, vector double);
18098 int vec_any_ge (vector double, vector double);
18099 int vec_any_gt (vector double, vector double);
18100 int vec_any_le (vector double, vector double);
18101 int vec_any_lt (vector double, vector double);
18102 int vec_any_nan (vector double);
18103 int vec_any_ne (vector double, vector double);
18104 int vec_any_nge (vector double, vector double);
18105 int vec_any_ngt (vector double, vector double);
18106 int vec_any_nle (vector double, vector double);
18107 int vec_any_nlt (vector double, vector double);
18108 int vec_any_numeric (vector double);
18110 vector double vec_vsx_ld (int, const vector double *);
18111 vector double vec_vsx_ld (int, const double *);
18112 vector float vec_vsx_ld (int, const vector float *);
18113 vector float vec_vsx_ld (int, const float *);
18114 vector bool int vec_vsx_ld (int, const vector bool int *);
18115 vector signed int vec_vsx_ld (int, const vector signed int *);
18116 vector signed int vec_vsx_ld (int, const int *);
18117 vector signed int vec_vsx_ld (int, const long *);
18118 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18119 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18120 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18121 vector bool short vec_vsx_ld (int, const vector bool short *);
18122 vector pixel vec_vsx_ld (int, const vector pixel *);
18123 vector signed short vec_vsx_ld (int, const vector signed short *);
18124 vector signed short vec_vsx_ld (int, const short *);
18125 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18126 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18127 vector bool char vec_vsx_ld (int, const vector bool char *);
18128 vector signed char vec_vsx_ld (int, const vector signed char *);
18129 vector signed char vec_vsx_ld (int, const signed char *);
18130 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18131 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18133 void vec_vsx_st (vector double, int, vector double *);
18134 void vec_vsx_st (vector double, int, double *);
18135 void vec_vsx_st (vector float, int, vector float *);
18136 void vec_vsx_st (vector float, int, float *);
18137 void vec_vsx_st (vector signed int, int, vector signed int *);
18138 void vec_vsx_st (vector signed int, int, int *);
18139 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18140 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18141 void vec_vsx_st (vector bool int, int, vector bool int *);
18142 void vec_vsx_st (vector bool int, int, unsigned int *);
18143 void vec_vsx_st (vector bool int, int, int *);
18144 void vec_vsx_st (vector signed short, int, vector signed short *);
18145 void vec_vsx_st (vector signed short, int, short *);
18146 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18147 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18148 void vec_vsx_st (vector bool short, int, vector bool short *);
18149 void vec_vsx_st (vector bool short, int, unsigned short *);
18150 void vec_vsx_st (vector pixel, int, vector pixel *);
18151 void vec_vsx_st (vector pixel, int, unsigned short *);
18152 void vec_vsx_st (vector pixel, int, short *);
18153 void vec_vsx_st (vector bool short, int, short *);
18154 void vec_vsx_st (vector signed char, int, vector signed char *);
18155 void vec_vsx_st (vector signed char, int, signed char *);
18156 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18157 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18158 void vec_vsx_st (vector bool char, int, vector bool char *);
18159 void vec_vsx_st (vector bool char, int, unsigned char *);
18160 void vec_vsx_st (vector bool char, int, signed char *);
18162 vector double vec_xxpermdi (vector double, vector double, const int);
18163 vector float vec_xxpermdi (vector float, vector float, const int);
18164 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18165 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18166                                         vector unsigned long long, const int);
18167 vector int vec_xxpermdi (vector int, vector int, const int);
18168 vector unsigned int vec_xxpermdi (vector unsigned int,
18169                                   vector unsigned int, const int);
18170 vector short vec_xxpermdi (vector short, vector short, const int);
18171 vector unsigned short vec_xxpermdi (vector unsigned short,
18172                                     vector unsigned short, const int);
18173 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18174                                  const int);
18175 vector unsigned char vec_xxpermdi (vector unsigned char,
18176                                    vector unsigned char, const int);
18178 vector double vec_xxsldi (vector double, vector double, int);
18179 vector float vec_xxsldi (vector float, vector float, int);
18180 vector long long vec_xxsldi (vector long long, vector long long, int);
18181 vector unsigned long long vec_xxsldi (vector unsigned long long,
18182                                       vector unsigned long long, int);
18183 vector int vec_xxsldi (vector int, vector int, int);
18184 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18185 vector short vec_xxsldi (vector short, vector short, int);
18186 vector unsigned short vec_xxsldi (vector unsigned short,
18187                                   vector unsigned short, int);
18188 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18189 vector unsigned char vec_xxsldi (vector unsigned char,
18190                                  vector unsigned char, int);
18191 @end smallexample
18193 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18194 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18195 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
18196 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18197 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18199 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
18200 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
18202 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18203 instruction set are available, the following additional functions are
18204 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
18205 can use @var{vector long} instead of @var{vector long long},
18206 @var{vector bool long} instead of @var{vector bool long long}, and
18207 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18209 @smallexample
18210 vector signed char vec_neg (vector signed char);
18211 vector signed short vec_neg (vector signed short);
18212 vector signed int vec_neg (vector signed int);
18213 vector signed long long vec_neg (vector signed long long);
18214 vector float  char vec_neg (vector float);
18215 vector double vec_neg (vector double);
18217 vector signed int vec_signed2 (vector double, vector double);
18219 vector signed int vec_unsigned2 (vector double, vector double);
18221 vector long long vec_abs (vector long long);
18223 vector long long vec_add (vector long long, vector long long);
18224 vector unsigned long long vec_add (vector unsigned long long,
18225                                    vector unsigned long long);
18227 int vec_all_eq (vector long long, vector long long);
18228 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18229 int vec_all_ge (vector long long, vector long long);
18230 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18231 int vec_all_gt (vector long long, vector long long);
18232 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18233 int vec_all_le (vector long long, vector long long);
18234 int vec_all_le (vector unsigned long long, vector unsigned long long);
18235 int vec_all_lt (vector long long, vector long long);
18236 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18237 int vec_all_ne (vector long long, vector long long);
18238 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18240 int vec_any_eq (vector long long, vector long long);
18241 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18242 int vec_any_ge (vector long long, vector long long);
18243 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18244 int vec_any_gt (vector long long, vector long long);
18245 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18246 int vec_any_le (vector long long, vector long long);
18247 int vec_any_le (vector unsigned long long, vector unsigned long long);
18248 int vec_any_lt (vector long long, vector long long);
18249 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18250 int vec_any_ne (vector long long, vector long long);
18251 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18253 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18255 vector long long vec_eqv (vector long long, vector long long);
18256 vector long long vec_eqv (vector bool long long, vector long long);
18257 vector long long vec_eqv (vector long long, vector bool long long);
18258 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
18259 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
18260 vector unsigned long long vec_eqv (vector unsigned long long,
18261                                    vector bool long long);
18262 vector int vec_eqv (vector int, vector int);
18263 vector int vec_eqv (vector bool int, vector int);
18264 vector int vec_eqv (vector int, vector bool int);
18265 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18266 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
18267 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
18268 vector short vec_eqv (vector short, vector short);
18269 vector short vec_eqv (vector bool short, vector short);
18270 vector short vec_eqv (vector short, vector bool short);
18271 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18272 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
18273 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
18274 vector signed char vec_eqv (vector signed char, vector signed char);
18275 vector signed char vec_eqv (vector bool signed char, vector signed char);
18276 vector signed char vec_eqv (vector signed char, vector bool signed char);
18277 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18278 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18279 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18281 vector long long vec_max (vector long long, vector long long);
18282 vector unsigned long long vec_max (vector unsigned long long,
18283                                    vector unsigned long long);
18285 vector signed int vec_mergee (vector signed int, vector signed int);
18286 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18287 vector bool int vec_mergee (vector bool int, vector bool int);
18289 vector signed int vec_mergeo (vector signed int, vector signed int);
18290 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18291 vector bool int vec_mergeo (vector bool int, vector bool int);
18293 vector long long vec_min (vector long long, vector long long);
18294 vector unsigned long long vec_min (vector unsigned long long,
18295                                    vector unsigned long long);
18297 vector signed long long vec_nabs (vector signed long long);
18299 vector long long vec_nand (vector long long, vector long long);
18300 vector long long vec_nand (vector bool long long, vector long long);
18301 vector long long vec_nand (vector long long, vector bool long long);
18302 vector unsigned long long vec_nand (vector unsigned long long,
18303                                     vector unsigned long long);
18304 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
18305 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
18306 vector int vec_nand (vector int, vector int);
18307 vector int vec_nand (vector bool int, vector int);
18308 vector int vec_nand (vector int, vector bool int);
18309 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18310 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
18311 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
18312 vector short vec_nand (vector short, vector short);
18313 vector short vec_nand (vector bool short, vector short);
18314 vector short vec_nand (vector short, vector bool short);
18315 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18316 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
18317 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
18318 vector signed char vec_nand (vector signed char, vector signed char);
18319 vector signed char vec_nand (vector bool signed char, vector signed char);
18320 vector signed char vec_nand (vector signed char, vector bool signed char);
18321 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18322 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18323 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18325 vector long long vec_orc (vector long long, vector long long);
18326 vector long long vec_orc (vector bool long long, vector long long);
18327 vector long long vec_orc (vector long long, vector bool long long);
18328 vector unsigned long long vec_orc (vector unsigned long long,
18329                                    vector unsigned long long);
18330 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
18331 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
18332 vector int vec_orc (vector int, vector int);
18333 vector int vec_orc (vector bool int, vector int);
18334 vector int vec_orc (vector int, vector bool int);
18335 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18336 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
18337 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
18338 vector short vec_orc (vector short, vector short);
18339 vector short vec_orc (vector bool short, vector short);
18340 vector short vec_orc (vector short, vector bool short);
18341 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18342 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
18343 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
18344 vector signed char vec_orc (vector signed char, vector signed char);
18345 vector signed char vec_orc (vector bool signed char, vector signed char);
18346 vector signed char vec_orc (vector signed char, vector bool signed char);
18347 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18348 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18349 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18351 vector int vec_pack (vector long long, vector long long);
18352 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
18353 vector bool int vec_pack (vector bool long long, vector bool long long);
18354 vector float vec_pack (vector double, vector double);
18356 vector int vec_packs (vector long long, vector long long);
18357 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
18359 vector unsigned char vec_packsu (vector signed short, vector signed short)
18360 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
18361 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18362 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
18363 vector unsigned int vec_packsu (vector long long, vector long long);
18364 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
18365 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
18367 vector unsigned char vec_popcnt (vector signed char);
18368 vector unsigned char vec_popcnt (vector unsigned char);
18369 vector unsigned short vec_popcnt (vector signed short);
18370 vector unsigned short vec_popcnt (vector unsigned short);
18371 vector unsigned int vec_popcnt (vector signed int);
18372 vector unsigned int vec_popcnt (vector unsigned int);
18373 vector unsigned long long vec_popcnt (vector signed long long);
18374 vector unsigned long long vec_popcnt (vector unsigned long long);
18376 vector long long vec_rl (vector long long, vector unsigned long long);
18377 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
18379 vector long long vec_sl (vector long long, vector unsigned long long);
18380 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
18382 vector long long vec_sr (vector long long, vector unsigned long long);
18383 vector unsigned long long char vec_sr (vector unsigned long long,
18384                                        vector unsigned long long);
18386 vector long long vec_sra (vector long long, vector unsigned long long);
18387 vector unsigned long long vec_sra (vector unsigned long long,
18388                                    vector unsigned long long);
18390 vector long long vec_sub (vector long long, vector long long);
18391 vector unsigned long long vec_sub (vector unsigned long long,
18392                                    vector unsigned long long);
18394 vector long long vec_unpackh (vector int);
18395 vector unsigned long long vec_unpackh (vector unsigned int);
18397 vector long long vec_unpackl (vector int);
18398 vector unsigned long long vec_unpackl (vector unsigned int);
18400 vector long long vec_vaddudm (vector long long, vector long long);
18401 vector long long vec_vaddudm (vector bool long long, vector long long);
18402 vector long long vec_vaddudm (vector long long, vector bool long long);
18403 vector unsigned long long vec_vaddudm (vector unsigned long long,
18404                                        vector unsigned long long);
18405 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18406                                        vector unsigned long long);
18407 vector unsigned long long vec_vaddudm (vector unsigned long long,
18408                                        vector bool unsigned long long);
18410 vector long long vec_vbpermq (vector signed char, vector signed char);
18411 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18413 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18414 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
18415 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
18417 vector long long vec_cntlz (vector long long);
18418 vector unsigned long long vec_cntlz (vector unsigned long long);
18419 vector int vec_cntlz (vector int);
18420 vector unsigned int vec_cntlz (vector int);
18421 vector short vec_cntlz (vector short);
18422 vector unsigned short vec_cntlz (vector unsigned short);
18423 vector signed char vec_cntlz (vector signed char);
18424 vector unsigned char vec_cntlz (vector unsigned char);
18426 vector long long vec_vclz (vector long long);
18427 vector unsigned long long vec_vclz (vector unsigned long long);
18428 vector int vec_vclz (vector int);
18429 vector unsigned int vec_vclz (vector int);
18430 vector short vec_vclz (vector short);
18431 vector unsigned short vec_vclz (vector unsigned short);
18432 vector signed char vec_vclz (vector signed char);
18433 vector unsigned char vec_vclz (vector unsigned char);
18435 vector signed char vec_vclzb (vector signed char);
18436 vector unsigned char vec_vclzb (vector unsigned char);
18438 vector long long vec_vclzd (vector long long);
18439 vector unsigned long long vec_vclzd (vector unsigned long long);
18441 vector short vec_vclzh (vector short);
18442 vector unsigned short vec_vclzh (vector unsigned short);
18444 vector int vec_vclzw (vector int);
18445 vector unsigned int vec_vclzw (vector int);
18447 vector signed char vec_vgbbd (vector signed char);
18448 vector unsigned char vec_vgbbd (vector unsigned char);
18450 vector long long vec_vmaxsd (vector long long, vector long long);
18452 vector unsigned long long vec_vmaxud (vector unsigned long long,
18453                                       unsigned vector long long);
18455 vector long long vec_vminsd (vector long long, vector long long);
18457 vector unsigned long long vec_vminud (vector long long, vector long long);
18459 vector int vec_vpksdss (vector long long, vector long long);
18460 vector unsigned int vec_vpksdss (vector long long, vector long long);
18462 vector unsigned int vec_vpkudus (vector unsigned long long,
18463                                  vector unsigned long long);
18465 vector int vec_vpkudum (vector long long, vector long long);
18466 vector unsigned int vec_vpkudum (vector unsigned long long,
18467                                  vector unsigned long long);
18468 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18470 vector long long vec_vpopcnt (vector long long);
18471 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18472 vector int vec_vpopcnt (vector int);
18473 vector unsigned int vec_vpopcnt (vector int);
18474 vector short vec_vpopcnt (vector short);
18475 vector unsigned short vec_vpopcnt (vector unsigned short);
18476 vector signed char vec_vpopcnt (vector signed char);
18477 vector unsigned char vec_vpopcnt (vector unsigned char);
18479 vector signed char vec_vpopcntb (vector signed char);
18480 vector unsigned char vec_vpopcntb (vector unsigned char);
18482 vector long long vec_vpopcntd (vector long long);
18483 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18485 vector short vec_vpopcnth (vector short);
18486 vector unsigned short vec_vpopcnth (vector unsigned short);
18488 vector int vec_vpopcntw (vector int);
18489 vector unsigned int vec_vpopcntw (vector int);
18491 vector long long vec_vrld (vector long long, vector unsigned long long);
18492 vector unsigned long long vec_vrld (vector unsigned long long,
18493                                     vector unsigned long long);
18495 vector long long vec_vsld (vector long long, vector unsigned long long);
18496 vector long long vec_vsld (vector unsigned long long,
18497                            vector unsigned long long);
18499 vector long long vec_vsrad (vector long long, vector unsigned long long);
18500 vector unsigned long long vec_vsrad (vector unsigned long long,
18501                                      vector unsigned long long);
18503 vector long long vec_vsrd (vector long long, vector unsigned long long);
18504 vector unsigned long long char vec_vsrd (vector unsigned long long,
18505                                          vector unsigned long long);
18507 vector long long vec_vsubudm (vector long long, vector long long);
18508 vector long long vec_vsubudm (vector bool long long, vector long long);
18509 vector long long vec_vsubudm (vector long long, vector bool long long);
18510 vector unsigned long long vec_vsubudm (vector unsigned long long,
18511                                        vector unsigned long long);
18512 vector unsigned long long vec_vsubudm (vector bool long long,
18513                                        vector unsigned long long);
18514 vector unsigned long long vec_vsubudm (vector unsigned long long,
18515                                        vector bool long long);
18517 vector long long vec_vupkhsw (vector int);
18518 vector unsigned long long vec_vupkhsw (vector unsigned int);
18520 vector long long vec_vupklsw (vector int);
18521 vector unsigned long long vec_vupklsw (vector int);
18522 @end smallexample
18524 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18525 instruction set are available, the following additional functions are
18526 available for 64-bit targets.  New vector types
18527 (@var{vector __int128} and @var{vector __uint128}) are available
18528 to hold the @var{__int128} and @var{__uint128} types to use these
18529 builtins.
18531 The normal vector extract, and set operations work on
18532 @var{vector __int128} and @var{vector __uint128} types,
18533 but the index value must be 0.
18535 @smallexample
18536 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
18537 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
18539 vector __int128 vec_vadduqm (vector __int128, vector __int128);
18540 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
18542 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
18543                                 vector __int128);
18544 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
18545                                  vector __uint128);
18547 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
18548                                 vector __int128);
18549 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
18550                                  vector __uint128);
18552 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
18553                                 vector __int128);
18554 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
18555                                  vector __uint128);
18557 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
18558                                 vector __int128);
18559 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
18560                                  vector __uint128);
18562 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
18563 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
18565 __int128 vec_vsubuqm (__int128, __int128);
18566 __uint128 vec_vsubuqm (__uint128, __uint128);
18568 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
18569 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
18570 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
18571 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
18572 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
18573 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
18574 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
18575 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
18576 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
18577 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
18578 @end smallexample
18580 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
18581 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
18583 The following additional built-in functions are also available for the
18584 PowerPC family of processors, starting with ISA 3.0
18585 (@option{-mcpu=power9}) or later:
18586 @smallexample
18587 unsigned int scalar_extract_exp (double source);
18588 unsigned long long int scalar_extract_exp (__ieee128 source);
18590 unsigned long long int scalar_extract_sig (double source);
18591 unsigned __int128 scalar_extract_sig (__ieee128 source);
18593 double scalar_insert_exp (unsigned long long int significand,
18594                           unsigned long long int exponent);
18595 double scalar_insert_exp (double significand, unsigned long long int exponent);
18597 ieee_128 scalar_insert_exp (unsigned __int128 significand,
18598                             unsigned long long int exponent);
18599 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18601 int scalar_cmp_exp_gt (double arg1, double arg2);
18602 int scalar_cmp_exp_lt (double arg1, double arg2);
18603 int scalar_cmp_exp_eq (double arg1, double arg2);
18604 int scalar_cmp_exp_unordered (double arg1, double arg2);
18606 bool scalar_test_data_class (float source, const int condition);
18607 bool scalar_test_data_class (double source, const int condition);
18608 bool scalar_test_data_class (__ieee128 source, const int condition);
18610 bool scalar_test_neg (float source);
18611 bool scalar_test_neg (double source);
18612 bool scalar_test_neg (__ieee128 source);
18613 @end smallexample
18615 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18616 functions require a 64-bit environment supporting ISA 3.0 or later.
18617 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18618 functions return the significand and the biased exponent value
18619 respectively of their @code{source} arguments.
18620 When supplied with a 64-bit @code{source} argument, the
18621 result returned by @code{scalar_extract_sig} has
18622 the @code{0x0010000000000000} bit set if the
18623 function's @code{source} argument is in normalized form.
18624 Otherwise, this bit is set to 0.
18625 When supplied with a 128-bit @code{source} argument, the
18626 @code{0x00010000000000000000000000000000} bit of the result is
18627 treated similarly.
18628 Note that the sign of the significand is not represented in the result
18629 returned from the @code{scalar_extract_sig} function.  Use the
18630 @code{scalar_test_neg} function to test the sign of its @code{double}
18631 argument.
18633 The @code{scalar_insert_exp}
18634 functions require a 64-bit environment supporting ISA 3.0 or later.
18635 When supplied with a 64-bit first argument, the
18636 @code{scalar_insert_exp} built-in function returns a double-precision
18637 floating point value that is constructed by assembling the values of its
18638 @code{significand} and @code{exponent} arguments.  The sign of the
18639 result is copied from the most significant bit of the
18640 @code{significand} argument.  The significand and exponent components
18641 of the result are composed of the least significant 11 bits of the
18642 @code{exponent} argument and the least significant 52 bits of the
18643 @code{significand} argument respectively.
18645 When supplied with a 128-bit first argument, the
18646 @code{scalar_insert_exp} built-in function returns a quad-precision
18647 ieee floating point value.  The sign bit of the result is copied from
18648 the most significant bit of the @code{significand} argument.
18649 The significand and exponent components of the result are composed of
18650 the least significant 15 bits of the @code{exponent} argument and the
18651 least significant 112 bits of the @code{significand} argument respectively.
18653 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18654 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18655 functions return a non-zero value if @code{arg1} is greater than, less
18656 than, equal to, or not comparable to @code{arg2} respectively.  The
18657 arguments are not comparable if one or the other equals NaN (not a
18658 number). 
18660 The @code{scalar_test_data_class} built-in function returns 1
18661 if any of the condition tests enabled by the value of the
18662 @code{condition} variable are true, and 0 otherwise.  The
18663 @code{condition} argument must be a compile-time constant integer with
18664 value not exceeding 127.  The
18665 @code{condition} argument is encoded as a bitmask with each bit
18666 enabling the testing of a different condition, as characterized by the
18667 following:
18668 @smallexample
18669 0x40    Test for NaN
18670 0x20    Test for +Infinity
18671 0x10    Test for -Infinity
18672 0x08    Test for +Zero
18673 0x04    Test for -Zero
18674 0x02    Test for +Denormal
18675 0x01    Test for -Denormal
18676 @end smallexample
18678 The @code{scalar_test_neg} built-in function returns 1 if its
18679 @code{source} argument holds a negative value, 0 otherwise.
18681 The following built-in functions are also available for the PowerPC family
18682 of processors, starting with ISA 3.0 or later
18683 (@option{-mcpu=power9}).  These string functions are described
18684 separately in order to group the descriptions closer to the function
18685 prototypes:
18686 @smallexample
18687 int vec_all_nez (vector signed char, vector signed char);
18688 int vec_all_nez (vector unsigned char, vector unsigned char);
18689 int vec_all_nez (vector signed short, vector signed short);
18690 int vec_all_nez (vector unsigned short, vector unsigned short);
18691 int vec_all_nez (vector signed int, vector signed int);
18692 int vec_all_nez (vector unsigned int, vector unsigned int);
18694 int vec_any_eqz (vector signed char, vector signed char);
18695 int vec_any_eqz (vector unsigned char, vector unsigned char);
18696 int vec_any_eqz (vector signed short, vector signed short);
18697 int vec_any_eqz (vector unsigned short, vector unsigned short);
18698 int vec_any_eqz (vector signed int, vector signed int);
18699 int vec_any_eqz (vector unsigned int, vector unsigned int);
18701 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
18702 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
18703 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
18704 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
18705 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
18706 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
18708 vector signed char vec_cnttz (vector signed char);
18709 vector unsigned char vec_cnttz (vector unsigned char);
18710 vector signed short vec_cnttz (vector signed short);
18711 vector unsigned short vec_cnttz (vector unsigned short);
18712 vector signed int vec_cnttz (vector signed int);
18713 vector unsigned int vec_cnttz (vector unsigned int);
18714 vector signed long long vec_cnttz (vector signed long long);
18715 vector unsigned long long vec_cnttz (vector unsigned long long);
18717 signed int vec_cntlz_lsbb (vector signed char);
18718 signed int vec_cntlz_lsbb (vector unsigned char);
18720 signed int vec_cnttz_lsbb (vector signed char);
18721 signed int vec_cnttz_lsbb (vector unsigned char);
18723 unsigned int vec_first_match_index (vector signed char, vector signed char);
18724 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
18725 unsigned int vec_first_match_index (vector signed int, vector signed int);
18726 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
18727 unsigned int vec_first_match_index (vector signed short, vector signed short);
18728 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
18729 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
18730 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
18731 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
18732 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
18733 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
18734 unsigned int vec_first_match_or_eos_index (vector unsigned short,
18735                                            vector unsigned short);
18736 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
18737 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
18738 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
18739 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
18740 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
18741 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
18742 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
18743 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
18744                                               vector unsigned char);
18745 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
18746 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
18747 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
18748 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
18749                                               vector unsigned short);
18751 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
18753 vector signed char vec_xl_be (signed long long, signed char *);
18754 vector unsigned char vec_xl_be (signed long long, unsigned char *);
18755 vector signed int vec_xl_be (signed long long, signed int *);
18756 vector unsigned int vec_xl_be (signed long long, unsigned int *);
18757 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
18758 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
18759 vector signed long long vec_xl_be (signed long long, signed long long *);
18760 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
18761 vector signed short vec_xl_be (signed long long, signed short *);
18762 vector unsigned short vec_xl_be (signed long long, unsigned short *);
18763 vector double vec_xl_be (signed long long, double *);
18764 vector float vec_xl_be (signed long long, float *);
18766 vector signed char vec_xl_len (signed char *addr, size_t len);
18767 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
18768 vector signed int vec_xl_len (signed int *addr, size_t len);
18769 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
18770 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
18771 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
18772 vector signed long long vec_xl_len (signed long long *addr, size_t len);
18773 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
18774 vector signed short vec_xl_len (signed short *addr, size_t len);
18775 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
18776 vector double vec_xl_len (double *addr, size_t len);
18777 vector float vec_xl_len (float *addr, size_t len);
18779 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
18781 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
18782 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
18783 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
18784 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
18785 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
18786 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
18787 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
18788 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
18789 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
18790 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
18791 void vec_xst_len (vector double data, double *addr, size_t len);
18792 void vec_xst_len (vector float data, float *addr, size_t len);
18794 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
18796 signed char vec_xlx (unsigned int index, vector signed char data);
18797 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
18798 signed short vec_xlx (unsigned int index, vector signed short data);
18799 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
18800 signed int vec_xlx (unsigned int index, vector signed int data);
18801 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
18802 float vec_xlx (unsigned int index, vector float data);
18804 signed char vec_xrx (unsigned int index, vector signed char data);
18805 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
18806 signed short vec_xrx (unsigned int index, vector signed short data);
18807 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
18808 signed int vec_xrx (unsigned int index, vector signed int data);
18809 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
18810 float vec_xrx (unsigned int index, vector float data);
18811 @end smallexample
18813 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
18814 perform pairwise comparisons between the elements at the same
18815 positions within their two vector arguments.
18816 The @code{vec_all_nez} function returns a
18817 non-zero value if and only if all pairwise comparisons are not
18818 equal and no element of either vector argument contains a zero.
18819 The @code{vec_any_eqz} function returns a
18820 non-zero value if and only if at least one pairwise comparison is equal
18821 or if at least one element of either vector argument contains a zero.
18822 The @code{vec_cmpnez} function returns a vector of the same type as
18823 its two arguments, within which each element consists of all ones to
18824 denote that either the corresponding elements of the incoming arguments are
18825 not equal or that at least one of the corresponding elements contains
18826 zero.  Otherwise, the element of the returned vector contains all zeros.
18828 The @code{vec_cntlz_lsbb} function returns the count of the number of
18829 consecutive leading byte elements (starting from position 0 within the
18830 supplied vector argument) for which the least-significant bit
18831 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
18832 the number of consecutive trailing byte elements (starting from
18833 position 15 and counting backwards within the supplied vector
18834 argument) for which the least-significant bit equals zero.
18836 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
18837 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
18838 function loads a variable length vector from memory.  The
18839 @code{vec_xst_len} function stores a variable length vector to memory.
18840 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
18841 @code{addr} argument represents the memory address to or from which
18842 data will be transferred, and the
18843 @code{len} argument represents the number of bytes to be
18844 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
18845 If this expression's value is not a multiple of the vector element's
18846 size, the behavior of this function is undefined.
18847 In the case that the underlying computer is configured to run in
18848 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
18849 the corresponding vector.  In little-endian mode, the data transfer
18850 moves bytes @code{(16 - len)} to @code{15} of the corresponding
18851 vector.  For the load function, any bytes of the result vector that
18852 are not loaded from memory are set to zero.
18853 The value of the @code{addr} argument need not be aligned on a
18854 multiple of the vector's element size.
18856 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
18857 element selected by the @code{index} argument from the vector
18858 represented by the @code{data} argument.  The @code{index} argument
18859 always specifies a byte offset, regardless of the size of the vector
18860 element.  With @code{vec_xlx}, @code{index} is the offset of the first
18861 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
18862 represents the last byte of the element to be extracted, measured
18863 from the right end of the vector.  In other words, the last byte of
18864 the element to be extracted is found at position @code{(15 - index)}.
18865 There is no requirement that @code{index} be a multiple of the vector
18866 element size.  However, if the size of the vector element added to
18867 @code{index} is greater than 15, the content of the returned value is
18868 undefined.
18870 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18871 are available:
18873 @smallexample
18874 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
18876 vector bool char vec_cmpne (vector bool char, vector bool char);
18877 vector bool char vec_cmpne (vector signed char, vector signed char);
18878 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
18879 vector bool int vec_cmpne (vector bool int, vector bool int);
18880 vector bool int vec_cmpne (vector signed int, vector signed int);
18881 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
18882 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18883 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
18884 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
18885 vector bool short vec_cmpne (vector bool short, vector bool short);
18886 vector bool short vec_cmpne (vector signed short, vector signed short);
18887 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
18888 vector bool long long vec_cmpne (vector double, vector double);
18889 vector bool int vec_cmpne (vector float, vector float);
18891 vector float vec_extract_fp32_from_shorth (vector unsigned short);
18892 vector float vec_extract_fp32_from_shortl (vector unsigned short);
18894 vector long long vec_vctz (vector long long);
18895 vector unsigned long long vec_vctz (vector unsigned long long);
18896 vector int vec_vctz (vector int);
18897 vector unsigned int vec_vctz (vector int);
18898 vector short vec_vctz (vector short);
18899 vector unsigned short vec_vctz (vector unsigned short);
18900 vector signed char vec_vctz (vector signed char);
18901 vector unsigned char vec_vctz (vector unsigned char);
18903 vector signed char vec_vctzb (vector signed char);
18904 vector unsigned char vec_vctzb (vector unsigned char);
18906 vector long long vec_vctzd (vector long long);
18907 vector unsigned long long vec_vctzd (vector unsigned long long);
18909 vector short vec_vctzh (vector short);
18910 vector unsigned short vec_vctzh (vector unsigned short);
18912 vector int vec_vctzw (vector int);
18913 vector unsigned int vec_vctzw (vector int);
18915 vector unsigned long long vec_extract4b (vector unsigned char, const int);
18917 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
18918                                    const int);
18919 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18920                                    const int);
18922 vector unsigned int vec_parity_lsbb (vector signed int);
18923 vector unsigned int vec_parity_lsbb (vector unsigned int);
18924 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
18925 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
18926 vector unsigned long long vec_parity_lsbb (vector signed long long);
18927 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
18929 vector int vec_vprtyb (vector int);
18930 vector unsigned int vec_vprtyb (vector unsigned int);
18931 vector long long vec_vprtyb (vector long long);
18932 vector unsigned long long vec_vprtyb (vector unsigned long long);
18934 vector int vec_vprtybw (vector int);
18935 vector unsigned int vec_vprtybw (vector unsigned int);
18937 vector long long vec_vprtybd (vector long long);
18938 vector unsigned long long vec_vprtybd (vector unsigned long long);
18939 @end smallexample
18941 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18942 are available:
18944 @smallexample
18945 vector long vec_vprtyb (vector long);
18946 vector unsigned long vec_vprtyb (vector unsigned long);
18947 vector __int128 vec_vprtyb (vector __int128);
18948 vector __uint128 vec_vprtyb (vector __uint128);
18950 vector long vec_vprtybd (vector long);
18951 vector unsigned long vec_vprtybd (vector unsigned long);
18953 vector __int128 vec_vprtybq (vector __int128);
18954 vector __uint128 vec_vprtybd (vector __uint128);
18955 @end smallexample
18957 The following built-in vector functions are available for the PowerPC family
18958 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18959 @smallexample
18960 __vector unsigned char
18961 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18962 __vector unsigned char
18963 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18964 @end smallexample
18966 The @code{vec_slv} and @code{vec_srv} functions operate on
18967 all of the bytes of their @code{src} and @code{shift_distance}
18968 arguments in parallel.  The behavior of the @code{vec_slv} is as if
18969 there existed a temporary array of 17 unsigned characters
18970 @code{slv_array} within which elements 0 through 15 are the same as
18971 the entries in the @code{src} array and element 16 equals 0.  The
18972 result returned from the @code{vec_slv} function is a
18973 @code{__vector} of 16 unsigned characters within which element
18974 @code{i} is computed using the C expression
18975 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18976 shift_distance[i]))},
18977 with this resulting value coerced to the @code{unsigned char} type.
18978 The behavior of the @code{vec_srv} is as if
18979 there existed a temporary array of 17 unsigned characters
18980 @code{srv_array} within which element 0 equals zero and
18981 elements 1 through 16 equal the elements 0 through 15 of
18982 the @code{src} array.  The
18983 result returned from the @code{vec_srv} function is a
18984 @code{__vector} of 16 unsigned characters within which element
18985 @code{i} is computed using the C expression
18986 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18987 (0x07 & shift_distance[i]))},
18988 with this resulting value coerced to the @code{unsigned char} type.
18990 The following built-in functions are available for the PowerPC family
18991 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18992 @smallexample
18993 __vector unsigned char
18994 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18995 __vector unsigned short
18996 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18997 __vector unsigned int
18998 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19000 __vector unsigned char
19001 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19002 __vector unsigned short
19003 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19004 __vector unsigned int
19005 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19006 @end smallexample
19008 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19009 @code{vec_absdw} built-in functions each computes the absolute
19010 differences of the pairs of vector elements supplied in its two vector
19011 arguments, placing the absolute differences into the corresponding
19012 elements of the vector result.
19014 The following built-in functions are available for the PowerPC family
19015 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19016 @smallexample
19017 __vector unsigned int vec_extract_exp (__vector float source);
19018 __vector unsigned long long int vec_extract_exp (__vector double source);
19020 __vector unsigned int vec_extract_sig (__vector float source);
19021 __vector unsigned long long int vec_extract_sig (__vector double source);
19023 __vector float vec_insert_exp (__vector unsigned int significands,
19024                                __vector unsigned int exponents);
19025 __vector float vec_insert_exp (__vector unsigned float significands,
19026                                __vector unsigned int exponents);
19027 __vector double vec_insert_exp (__vector unsigned long long int significands,
19028                                 __vector unsigned long long int exponents);
19029 __vector double vec_insert_exp (__vector unsigned double significands,
19030                                 __vector unsigned long long int exponents);
19032 __vector bool int vec_test_data_class (__vector float source, const int condition);
19033 __vector bool long long int vec_test_data_class (__vector double source,
19034                                                  const int condition);
19035 @end smallexample
19037 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19038 functions return vectors representing the significands and biased
19039 exponent values of their @code{source} arguments respectively.
19040 Within the result vector returned by @code{vec_extract_sig}, the
19041 @code{0x800000} bit of each vector element returned when the
19042 function's @code{source} argument is of type @code{float} is set to 1
19043 if the corresponding floating point value is in normalized form.
19044 Otherwise, this bit is set to 0.  When the @code{source} argument is
19045 of type @code{double}, the @code{0x10000000000000} bit within each of
19046 the result vector's elements is set according to the same rules.
19047 Note that the sign of the significand is not represented in the result
19048 returned from the @code{vec_extract_sig} function.  To extract the
19049 sign bits, use the
19050 @code{vec_cpsgn} function, which returns a new vector within which all
19051 of the sign bits of its second argument vector are overwritten with the
19052 sign bits copied from the coresponding elements of its first argument
19053 vector, and all other (non-sign) bits of the second argument vector
19054 are copied unchanged into the result vector.
19056 The @code{vec_insert_exp} built-in functions return a vector of
19057 single- or double-precision floating
19058 point values constructed by assembling the values of their
19059 @code{significands} and @code{exponents} arguments into the
19060 corresponding elements of the returned vector.
19061 The sign of each
19062 element of the result is copied from the most significant bit of the
19063 corresponding entry within the @code{significands} argument.
19064 Note that the relevant
19065 bits of the @code{significands} argument are the same, for both integer
19066 and floating point types.
19068 significand and exponent components of each element of the result are
19069 composed of the least significant bits of the corresponding
19070 @code{significands} element and the least significant bits of the
19071 corresponding @code{exponents} element.
19073 The @code{vec_test_data_class} built-in function returns a vector
19074 representing the results of testing the @code{source} vector for the
19075 condition selected by the @code{condition} argument.  The
19076 @code{condition} argument must be a compile-time constant integer with
19077 value not exceeding 127.  The
19078 @code{condition} argument is encoded as a bitmask with each bit
19079 enabling the testing of a different condition, as characterized by the
19080 following:
19081 @smallexample
19082 0x40    Test for NaN
19083 0x20    Test for +Infinity
19084 0x10    Test for -Infinity
19085 0x08    Test for +Zero
19086 0x04    Test for -Zero
19087 0x02    Test for +Denormal
19088 0x01    Test for -Denormal
19089 @end smallexample
19091 If any of the enabled test conditions is true, the corresponding entry
19092 in the result vector is -1.  Otherwise (all of the enabled test
19093 conditions are false), the corresponding entry of the result vector is 0.
19095 The following built-in functions are available for the PowerPC family
19096 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19097 @smallexample
19098 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19099                               vector unsigned int);
19100 vector unsigned long long vec_rlmi (vector unsigned long long,
19101                                     vector unsigned long long,
19102                                     vector unsigned long long);
19103 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19104                               vector unsigned int);
19105 vector unsigned long long vec_rlnm (vector unsigned long long,
19106                                     vector unsigned long long,
19107                                     vector unsigned long long);
19108 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19109 vector unsigned long long vec_vrlnm (vector unsigned long long,
19110                                      vector unsigned long long);
19111 @end smallexample
19113 The result of @code{vec_rlmi} is obtained by rotating each element of
19114 the first argument vector left and inserting it under mask into the
19115 second argument vector.  The third argument vector contains the mask
19116 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19117 count in bits 27:31, of each element.
19119 The result of @code{vec_rlnm} is obtained by rotating each element of
19120 the first argument vector left and ANDing it with a mask specified by
19121 the second and third argument vectors.  The second argument vector
19122 contains the shift count for each element in the low-order byte.  The
19123 third argument vector contains the mask end for each element in the
19124 low-order byte, with the mask begin in the next higher byte.
19126 The result of @code{vec_vrlnm} is obtained by rotating each element
19127 of the first argument vector left and ANDing it with a mask.  The
19128 second argument vector contains the mask  beginning in bits 11:15,
19129 the mask end in bits 19:23, and the shift count in bits 27:31,
19130 of each element.
19132 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19133 are available:
19134 @smallexample
19135 vector signed bool char vec_revb (vector signed char);
19136 vector signed char vec_revb (vector signed char);
19137 vector unsigned char vec_revb (vector unsigned char);
19138 vector bool short vec_revb (vector bool short);
19139 vector short vec_revb (vector short);
19140 vector unsigned short vec_revb (vector unsigned short);
19141 vector bool int vec_revb (vector bool int);
19142 vector int vec_revb (vector int);
19143 vector unsigned int vec_revb (vector unsigned int);
19144 vector float vec_revb (vector float);
19145 vector bool long long vec_revb (vector bool long long);
19146 vector long long vec_revb (vector long long);
19147 vector unsigned long long vec_revb (vector unsigned long long);
19148 vector double vec_revb (vector double);
19149 @end smallexample
19151 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19152 are available:
19153 @smallexample
19154 vector long vec_revb (vector long);
19155 vector unsigned long vec_revb (vector unsigned long);
19156 vector __int128 vec_revb (vector __int128);
19157 vector __uint128 vec_revb (vector __uint128);
19158 @end smallexample
19160 The @code{vec_revb} built-in function reverses the bytes on an element
19161 by element basis.  A vector of @code{vector unsigned char} or
19162 @code{vector signed char} reverses the bytes in the whole word.
19164 If the cryptographic instructions are enabled (@option{-mcrypto} or
19165 @option{-mcpu=power8}), the following builtins are enabled.
19167 @smallexample
19168 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19170 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19171                                                     vector unsigned long long);
19173 vector unsigned long long __builtin_crypto_vcipherlast
19174                                      (vector unsigned long long,
19175                                       vector unsigned long long);
19177 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19178                                                      vector unsigned long long);
19180 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
19181                                                          vector unsigned long long);
19183 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19184                                                 vector unsigned char,
19185                                                 vector unsigned char);
19187 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19188                                                  vector unsigned short,
19189                                                  vector unsigned short);
19191 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19192                                                vector unsigned int,
19193                                                vector unsigned int);
19195 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19196                                                      vector unsigned long long,
19197                                                      vector unsigned long long);
19199 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19200                                                vector unsigned char);
19202 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19203                                                 vector unsigned short);
19205 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19206                                               vector unsigned int);
19208 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19209                                                     vector unsigned long long);
19211 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
19212                                                        int, int);
19214 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
19215 @end smallexample
19217 The second argument to @var{__builtin_crypto_vshasigmad} and
19218 @var{__builtin_crypto_vshasigmaw} must be a constant
19219 integer that is 0 or 1.  The third argument to these built-in functions
19220 must be a constant integer in the range of 0 to 15.
19222 If the ISA 3.0 instruction set additions 
19223 are enabled (@option{-mcpu=power9}), the following additional
19224 functions are available for both 32-bit and 64-bit targets.
19225 @smallexample
19226 vector short vec_xl (int, vector short *);
19227 vector short vec_xl (int, short *);
19228 vector unsigned short vec_xl (int, vector unsigned short *);
19229 vector unsigned short vec_xl (int, unsigned short *);
19230 vector char vec_xl (int, vector char *);
19231 vector char vec_xl (int, char *);
19232 vector unsigned char vec_xl (int, vector unsigned char *);
19233 vector unsigned char vec_xl (int, unsigned char *);
19235 void vec_xst (vector short, int, vector short *);
19236 void vec_xst (vector short, int, short *);
19237 void vec_xst (vector unsigned short, int, vector unsigned short *);
19238 void vec_xst (vector unsigned short, int, unsigned short *);
19239 void vec_xst (vector char, int, vector char *);
19240 void vec_xst (vector char, int, char *);
19241 void vec_xst (vector unsigned char, int, vector unsigned char *);
19242 void vec_xst (vector unsigned char, int, unsigned char *);
19243 @end smallexample
19244 @node PowerPC Hardware Transactional Memory Built-in Functions
19245 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19246 GCC provides two interfaces for accessing the Hardware Transactional
19247 Memory (HTM) instructions available on some of the PowerPC family
19248 of processors (eg, POWER8).  The two interfaces come in a low level
19249 interface, consisting of built-in functions specific to PowerPC and a
19250 higher level interface consisting of inline functions that are common
19251 between PowerPC and S/390.
19253 @subsubsection PowerPC HTM Low Level Built-in Functions
19255 The following low level built-in functions are available with
19256 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19257 They all generate the machine instruction that is part of the name.
19259 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19260 the full 4-bit condition register value set by their associated hardware
19261 instruction.  The header file @code{htmintrin.h} defines some macros that can
19262 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
19263 returns a simple true or false value depending on whether a transaction was
19264 successfully started or not.  The arguments of the builtins match exactly the
19265 type and order of the associated hardware instruction's operands, except for
19266 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19267 Refer to the ISA manual for a description of each instruction's operands.
19269 @smallexample
19270 unsigned int __builtin_tbegin (unsigned int)
19271 unsigned int __builtin_tend (unsigned int)
19273 unsigned int __builtin_tabort (unsigned int)
19274 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19275 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19276 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19277 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19279 unsigned int __builtin_tcheck (void)
19280 unsigned int __builtin_treclaim (unsigned int)
19281 unsigned int __builtin_trechkpt (void)
19282 unsigned int __builtin_tsr (unsigned int)
19283 @end smallexample
19285 In addition to the above HTM built-ins, we have added built-ins for
19286 some common extended mnemonics of the HTM instructions:
19288 @smallexample
19289 unsigned int __builtin_tendall (void)
19290 unsigned int __builtin_tresume (void)
19291 unsigned int __builtin_tsuspend (void)
19292 @end smallexample
19294 Note that the semantics of the above HTM builtins are required to mimic
19295 the locking semantics used for critical sections.  Builtins that are used
19296 to create a new transaction or restart a suspended transaction must have
19297 lock acquisition like semantics while those builtins that end or suspend a
19298 transaction must have lock release like semantics.  Specifically, this must
19299 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19300 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19301 that returns 0, and lock release is as-if an execution of
19302 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19303 implicit implementation-defined lock used for all transactions.  The HTM
19304 instructions associated with with the builtins inherently provide the
19305 correct acquisition and release hardware barriers required.  However,
19306 the compiler must also be prohibited from moving loads and stores across
19307 the builtins in a way that would violate their semantics.  This has been
19308 accomplished by adding memory barriers to the associated HTM instructions
19309 (which is a conservative approach to provide acquire and release semantics).
19310 Earlier versions of the compiler did not treat the HTM instructions as
19311 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19312 be used to determine whether the current compiler treats HTM instructions
19313 as memory barriers or not.  This allows the user to explicitly add memory
19314 barriers to their code when using an older version of the compiler.
19316 The following set of built-in functions are available to gain access
19317 to the HTM specific special purpose registers.
19319 @smallexample
19320 unsigned long __builtin_get_texasr (void)
19321 unsigned long __builtin_get_texasru (void)
19322 unsigned long __builtin_get_tfhar (void)
19323 unsigned long __builtin_get_tfiar (void)
19325 void __builtin_set_texasr (unsigned long);
19326 void __builtin_set_texasru (unsigned long);
19327 void __builtin_set_tfhar (unsigned long);
19328 void __builtin_set_tfiar (unsigned long);
19329 @end smallexample
19331 Example usage of these low level built-in functions may look like:
19333 @smallexample
19334 #include <htmintrin.h>
19336 int num_retries = 10;
19338 while (1)
19339   @{
19340     if (__builtin_tbegin (0))
19341       @{
19342         /* Transaction State Initiated.  */
19343         if (is_locked (lock))
19344           __builtin_tabort (0);
19345         ... transaction code...
19346         __builtin_tend (0);
19347         break;
19348       @}
19349     else
19350       @{
19351         /* Transaction State Failed.  Use locks if the transaction
19352            failure is "persistent" or we've tried too many times.  */
19353         if (num_retries-- <= 0
19354             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19355           @{
19356             acquire_lock (lock);
19357             ... non transactional fallback path...
19358             release_lock (lock);
19359             break;
19360           @}
19361       @}
19362   @}
19363 @end smallexample
19365 One final built-in function has been added that returns the value of
19366 the 2-bit Transaction State field of the Machine Status Register (MSR)
19367 as stored in @code{CR0}.
19369 @smallexample
19370 unsigned long __builtin_ttest (void)
19371 @end smallexample
19373 This built-in can be used to determine the current transaction state
19374 using the following code example:
19376 @smallexample
19377 #include <htmintrin.h>
19379 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19381 if (tx_state == _HTM_TRANSACTIONAL)
19382   @{
19383     /* Code to use in transactional state.  */
19384   @}
19385 else if (tx_state == _HTM_NONTRANSACTIONAL)
19386   @{
19387     /* Code to use in non-transactional state.  */
19388   @}
19389 else if (tx_state == _HTM_SUSPENDED)
19390   @{
19391     /* Code to use in transaction suspended state.  */
19392   @}
19393 @end smallexample
19395 @subsubsection PowerPC HTM High Level Inline Functions
19397 The following high level HTM interface is made available by including
19398 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19399 where CPU is `power8' or later.  This interface is common between PowerPC
19400 and S/390, allowing users to write one HTM source implementation that
19401 can be compiled and executed on either system.
19403 @smallexample
19404 long __TM_simple_begin (void)
19405 long __TM_begin (void* const TM_buff)
19406 long __TM_end (void)
19407 void __TM_abort (void)
19408 void __TM_named_abort (unsigned char const code)
19409 void __TM_resume (void)
19410 void __TM_suspend (void)
19412 long __TM_is_user_abort (void* const TM_buff)
19413 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19414 long __TM_is_illegal (void* const TM_buff)
19415 long __TM_is_footprint_exceeded (void* const TM_buff)
19416 long __TM_nesting_depth (void* const TM_buff)
19417 long __TM_is_nested_too_deep(void* const TM_buff)
19418 long __TM_is_conflict(void* const TM_buff)
19419 long __TM_is_failure_persistent(void* const TM_buff)
19420 long __TM_failure_address(void* const TM_buff)
19421 long long __TM_failure_code(void* const TM_buff)
19422 @end smallexample
19424 Using these common set of HTM inline functions, we can create
19425 a more portable version of the HTM example in the previous
19426 section that will work on either PowerPC or S/390:
19428 @smallexample
19429 #include <htmxlintrin.h>
19431 int num_retries = 10;
19432 TM_buff_type TM_buff;
19434 while (1)
19435   @{
19436     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19437       @{
19438         /* Transaction State Initiated.  */
19439         if (is_locked (lock))
19440           __TM_abort ();
19441         ... transaction code...
19442         __TM_end ();
19443         break;
19444       @}
19445     else
19446       @{
19447         /* Transaction State Failed.  Use locks if the transaction
19448            failure is "persistent" or we've tried too many times.  */
19449         if (num_retries-- <= 0
19450             || __TM_is_failure_persistent (TM_buff))
19451           @{
19452             acquire_lock (lock);
19453             ... non transactional fallback path...
19454             release_lock (lock);
19455             break;
19456           @}
19457       @}
19458   @}
19459 @end smallexample
19461 @node PowerPC Atomic Memory Operation Functions
19462 @subsection PowerPC Atomic Memory Operation Functions
19463 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19464 instructions.  GCC provides support for these instructions in 64-bit
19465 environments.  All of the functions are declared in the include file
19466 @code{amo.h}.
19468 The functions supported are:
19470 @smallexample
19471 #include <amo.h>
19473 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19474 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19475 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19476 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19477 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19478 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19479 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19481 int32_t amo_lwat_sadd (int32_t *, int32_t);
19482 int32_t amo_lwat_smax (int32_t *, int32_t);
19483 int32_t amo_lwat_smin (int32_t *, int32_t);
19484 int32_t amo_lwat_sswap (int32_t *, int32_t);
19486 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19487 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19488 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19489 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19490 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19491 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19492 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19494 int64_t amo_ldat_sadd (int64_t *, int64_t);
19495 int64_t amo_ldat_smax (int64_t *, int64_t);
19496 int64_t amo_ldat_smin (int64_t *, int64_t);
19497 int64_t amo_ldat_sswap (int64_t *, int64_t);
19499 void amo_stwat_add (uint32_t *, uint32_t);
19500 void amo_stwat_xor (uint32_t *, uint32_t);
19501 void amo_stwat_ior (uint32_t *, uint32_t);
19502 void amo_stwat_and (uint32_t *, uint32_t);
19503 void amo_stwat_umax (uint32_t *, uint32_t);
19504 void amo_stwat_umin (uint32_t *, uint32_t);
19506 void amo_stwat_sadd (int32_t *, int32_t);
19507 void amo_stwat_smax (int32_t *, int32_t);
19508 void amo_stwat_smin (int32_t *, int32_t);
19510 void amo_stdat_add (uint64_t *, uint64_t);
19511 void amo_stdat_xor (uint64_t *, uint64_t);
19512 void amo_stdat_ior (uint64_t *, uint64_t);
19513 void amo_stdat_and (uint64_t *, uint64_t);
19514 void amo_stdat_umax (uint64_t *, uint64_t);
19515 void amo_stdat_umin (uint64_t *, uint64_t);
19517 void amo_stdat_sadd (int64_t *, int64_t);
19518 void amo_stdat_smax (int64_t *, int64_t);
19519 void amo_stdat_smin (int64_t *, int64_t);
19520 @end smallexample
19522 @node RX Built-in Functions
19523 @subsection RX Built-in Functions
19524 GCC supports some of the RX instructions which cannot be expressed in
19525 the C programming language via the use of built-in functions.  The
19526 following functions are supported:
19528 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19529 Generates the @code{brk} machine instruction.
19530 @end deftypefn
19532 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19533 Generates the @code{clrpsw} machine instruction to clear the specified
19534 bit in the processor status word.
19535 @end deftypefn
19537 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19538 Generates the @code{int} machine instruction to generate an interrupt
19539 with the specified value.
19540 @end deftypefn
19542 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19543 Generates the @code{machi} machine instruction to add the result of
19544 multiplying the top 16 bits of the two arguments into the
19545 accumulator.
19546 @end deftypefn
19548 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19549 Generates the @code{maclo} machine instruction to add the result of
19550 multiplying the bottom 16 bits of the two arguments into the
19551 accumulator.
19552 @end deftypefn
19554 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19555 Generates the @code{mulhi} machine instruction to place the result of
19556 multiplying the top 16 bits of the two arguments into the
19557 accumulator.
19558 @end deftypefn
19560 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19561 Generates the @code{mullo} machine instruction to place the result of
19562 multiplying the bottom 16 bits of the two arguments into the
19563 accumulator.
19564 @end deftypefn
19566 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19567 Generates the @code{mvfachi} machine instruction to read the top
19568 32 bits of the accumulator.
19569 @end deftypefn
19571 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19572 Generates the @code{mvfacmi} machine instruction to read the middle
19573 32 bits of the accumulator.
19574 @end deftypefn
19576 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19577 Generates the @code{mvfc} machine instruction which reads the control
19578 register specified in its argument and returns its value.
19579 @end deftypefn
19581 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19582 Generates the @code{mvtachi} machine instruction to set the top
19583 32 bits of the accumulator.
19584 @end deftypefn
19586 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19587 Generates the @code{mvtaclo} machine instruction to set the bottom
19588 32 bits of the accumulator.
19589 @end deftypefn
19591 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19592 Generates the @code{mvtc} machine instruction which sets control
19593 register number @code{reg} to @code{val}.
19594 @end deftypefn
19596 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19597 Generates the @code{mvtipl} machine instruction set the interrupt
19598 priority level.
19599 @end deftypefn
19601 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19602 Generates the @code{racw} machine instruction to round the accumulator
19603 according to the specified mode.
19604 @end deftypefn
19606 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19607 Generates the @code{revw} machine instruction which swaps the bytes in
19608 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19609 and also bits 16--23 occupy bits 24--31 and vice versa.
19610 @end deftypefn
19612 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19613 Generates the @code{rmpa} machine instruction which initiates a
19614 repeated multiply and accumulate sequence.
19615 @end deftypefn
19617 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19618 Generates the @code{round} machine instruction which returns the
19619 floating-point argument rounded according to the current rounding mode
19620 set in the floating-point status word register.
19621 @end deftypefn
19623 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19624 Generates the @code{sat} machine instruction which returns the
19625 saturated value of the argument.
19626 @end deftypefn
19628 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19629 Generates the @code{setpsw} machine instruction to set the specified
19630 bit in the processor status word.
19631 @end deftypefn
19633 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19634 Generates the @code{wait} machine instruction.
19635 @end deftypefn
19637 @node S/390 System z Built-in Functions
19638 @subsection S/390 System z Built-in Functions
19639 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19640 Generates the @code{tbegin} machine instruction starting a
19641 non-constrained hardware transaction.  If the parameter is non-NULL the
19642 memory area is used to store the transaction diagnostic buffer and
19643 will be passed as first operand to @code{tbegin}.  This buffer can be
19644 defined using the @code{struct __htm_tdb} C struct defined in
19645 @code{htmintrin.h} and must reside on a double-word boundary.  The
19646 second tbegin operand is set to @code{0xff0c}. This enables
19647 save/restore of all GPRs and disables aborts for FPR and AR
19648 manipulations inside the transaction body.  The condition code set by
19649 the tbegin instruction is returned as integer value.  The tbegin
19650 instruction by definition overwrites the content of all FPRs.  The
19651 compiler will generate code which saves and restores the FPRs.  For
19652 soft-float code it is recommended to used the @code{*_nofloat}
19653 variant.  In order to prevent a TDB from being written it is required
19654 to pass a constant zero value as parameter.  Passing a zero value
19655 through a variable is not sufficient.  Although modifications of
19656 access registers inside the transaction will not trigger an
19657 transaction abort it is not supported to actually modify them.  Access
19658 registers do not get saved when entering a transaction. They will have
19659 undefined state when reaching the abort code.
19660 @end deftypefn
19662 Macros for the possible return codes of tbegin are defined in the
19663 @code{htmintrin.h} header file:
19665 @table @code
19666 @item _HTM_TBEGIN_STARTED
19667 @code{tbegin} has been executed as part of normal processing.  The
19668 transaction body is supposed to be executed.
19669 @item _HTM_TBEGIN_INDETERMINATE
19670 The transaction was aborted due to an indeterminate condition which
19671 might be persistent.
19672 @item _HTM_TBEGIN_TRANSIENT
19673 The transaction aborted due to a transient failure.  The transaction
19674 should be re-executed in that case.
19675 @item _HTM_TBEGIN_PERSISTENT
19676 The transaction aborted due to a persistent failure.  Re-execution
19677 under same circumstances will not be productive.
19678 @end table
19680 @defmac _HTM_FIRST_USER_ABORT_CODE
19681 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19682 specifies the first abort code which can be used for
19683 @code{__builtin_tabort}.  Values below this threshold are reserved for
19684 machine use.
19685 @end defmac
19687 @deftp {Data type} {struct __htm_tdb}
19688 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19689 the structure of the transaction diagnostic block as specified in the
19690 Principles of Operation manual chapter 5-91.
19691 @end deftp
19693 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19694 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19695 Using this variant in code making use of FPRs will leave the FPRs in
19696 undefined state when entering the transaction abort handler code.
19697 @end deftypefn
19699 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19700 In addition to @code{__builtin_tbegin} a loop for transient failures
19701 is generated.  If tbegin returns a condition code of 2 the transaction
19702 will be retried as often as specified in the second argument.  The
19703 perform processor assist instruction is used to tell the CPU about the
19704 number of fails so far.
19705 @end deftypefn
19707 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19708 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19709 restores.  Using this variant in code making use of FPRs will leave
19710 the FPRs in undefined state when entering the transaction abort
19711 handler code.
19712 @end deftypefn
19714 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19715 Generates the @code{tbeginc} machine instruction starting a constrained
19716 hardware transaction.  The second operand is set to @code{0xff08}.
19717 @end deftypefn
19719 @deftypefn {Built-in Function} int __builtin_tend (void)
19720 Generates the @code{tend} machine instruction finishing a transaction
19721 and making the changes visible to other threads.  The condition code
19722 generated by tend is returned as integer value.
19723 @end deftypefn
19725 @deftypefn {Built-in Function} void __builtin_tabort (int)
19726 Generates the @code{tabort} machine instruction with the specified
19727 abort code.  Abort codes from 0 through 255 are reserved and will
19728 result in an error message.
19729 @end deftypefn
19731 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19732 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19733 integer parameter is loaded into rX and a value of zero is loaded into
19734 rY.  The integer parameter specifies the number of times the
19735 transaction repeatedly aborted.
19736 @end deftypefn
19738 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19739 Generates the @code{etnd} machine instruction.  The current nesting
19740 depth is returned as integer value.  For a nesting depth of 0 the code
19741 is not executed as part of an transaction.
19742 @end deftypefn
19744 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19746 Generates the @code{ntstg} machine instruction.  The second argument
19747 is written to the first arguments location.  The store operation will
19748 not be rolled-back in case of an transaction abort.
19749 @end deftypefn
19751 @node SH Built-in Functions
19752 @subsection SH Built-in Functions
19753 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19754 families of processors:
19756 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19757 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
19758 used by system code that manages threads and execution contexts.  The compiler
19759 normally does not generate code that modifies the contents of @samp{GBR} and
19760 thus the value is preserved across function calls.  Changing the @samp{GBR}
19761 value in user code must be done with caution, since the compiler might use
19762 @samp{GBR} in order to access thread local variables.
19764 @end deftypefn
19766 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19767 Returns the value that is currently set in the @samp{GBR} register.
19768 Memory loads and stores that use the thread pointer as a base address are
19769 turned into @samp{GBR} based displacement loads and stores, if possible.
19770 For example:
19771 @smallexample
19772 struct my_tcb
19774    int a, b, c, d, e;
19777 int get_tcb_value (void)
19779   // Generate @samp{mov.l @@(8,gbr),r0} instruction
19780   return ((my_tcb*)__builtin_thread_pointer ())->c;
19783 @end smallexample
19784 @end deftypefn
19786 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19787 Returns the value that is currently set in the @samp{FPSCR} register.
19788 @end deftypefn
19790 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19791 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19792 preserving the current values of the FR, SZ and PR bits.
19793 @end deftypefn
19795 @node SPARC VIS Built-in Functions
19796 @subsection SPARC VIS Built-in Functions
19798 GCC supports SIMD operations on the SPARC using both the generic vector
19799 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19800 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
19801 switch, the VIS extension is exposed as the following built-in functions:
19803 @smallexample
19804 typedef int v1si __attribute__ ((vector_size (4)));
19805 typedef int v2si __attribute__ ((vector_size (8)));
19806 typedef short v4hi __attribute__ ((vector_size (8)));
19807 typedef short v2hi __attribute__ ((vector_size (4)));
19808 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19809 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19811 void __builtin_vis_write_gsr (int64_t);
19812 int64_t __builtin_vis_read_gsr (void);
19814 void * __builtin_vis_alignaddr (void *, long);
19815 void * __builtin_vis_alignaddrl (void *, long);
19816 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19817 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19818 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19819 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19821 v4hi __builtin_vis_fexpand (v4qi);
19823 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19824 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19825 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19826 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19827 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19828 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19829 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19831 v4qi __builtin_vis_fpack16 (v4hi);
19832 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19833 v2hi __builtin_vis_fpackfix (v2si);
19834 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19836 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19838 long __builtin_vis_edge8 (void *, void *);
19839 long __builtin_vis_edge8l (void *, void *);
19840 long __builtin_vis_edge16 (void *, void *);
19841 long __builtin_vis_edge16l (void *, void *);
19842 long __builtin_vis_edge32 (void *, void *);
19843 long __builtin_vis_edge32l (void *, void *);
19845 long __builtin_vis_fcmple16 (v4hi, v4hi);
19846 long __builtin_vis_fcmple32 (v2si, v2si);
19847 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19848 long __builtin_vis_fcmpne32 (v2si, v2si);
19849 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19850 long __builtin_vis_fcmpgt32 (v2si, v2si);
19851 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19852 long __builtin_vis_fcmpeq32 (v2si, v2si);
19854 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19855 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19856 v2si __builtin_vis_fpadd32 (v2si, v2si);
19857 v1si __builtin_vis_fpadd32s (v1si, v1si);
19858 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19859 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19860 v2si __builtin_vis_fpsub32 (v2si, v2si);
19861 v1si __builtin_vis_fpsub32s (v1si, v1si);
19863 long __builtin_vis_array8 (long, long);
19864 long __builtin_vis_array16 (long, long);
19865 long __builtin_vis_array32 (long, long);
19866 @end smallexample
19868 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19869 functions also become available:
19871 @smallexample
19872 long __builtin_vis_bmask (long, long);
19873 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19874 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19875 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19876 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19878 long __builtin_vis_edge8n (void *, void *);
19879 long __builtin_vis_edge8ln (void *, void *);
19880 long __builtin_vis_edge16n (void *, void *);
19881 long __builtin_vis_edge16ln (void *, void *);
19882 long __builtin_vis_edge32n (void *, void *);
19883 long __builtin_vis_edge32ln (void *, void *);
19884 @end smallexample
19886 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19887 functions also become available:
19889 @smallexample
19890 void __builtin_vis_cmask8 (long);
19891 void __builtin_vis_cmask16 (long);
19892 void __builtin_vis_cmask32 (long);
19894 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19896 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19897 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19898 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19899 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19900 v2si __builtin_vis_fsll16 (v2si, v2si);
19901 v2si __builtin_vis_fslas16 (v2si, v2si);
19902 v2si __builtin_vis_fsrl16 (v2si, v2si);
19903 v2si __builtin_vis_fsra16 (v2si, v2si);
19905 long __builtin_vis_pdistn (v8qi, v8qi);
19907 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19909 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19910 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19912 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19913 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19914 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19915 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19916 v2si __builtin_vis_fpadds32 (v2si, v2si);
19917 v1si __builtin_vis_fpadds32s (v1si, v1si);
19918 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19919 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19921 long __builtin_vis_fucmple8 (v8qi, v8qi);
19922 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19923 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19924 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19926 float __builtin_vis_fhadds (float, float);
19927 double __builtin_vis_fhaddd (double, double);
19928 float __builtin_vis_fhsubs (float, float);
19929 double __builtin_vis_fhsubd (double, double);
19930 float __builtin_vis_fnhadds (float, float);
19931 double __builtin_vis_fnhaddd (double, double);
19933 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19934 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19935 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19936 @end smallexample
19938 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19939 functions also become available:
19941 @smallexample
19942 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19943 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19944 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19945 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19947 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19948 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19949 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19950 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19952 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19953 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19954 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19955 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19956 long __builtin_vis_fpcmpule32 (v2si, v2si);
19957 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19959 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19960 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19961 v2si __builtin_vis_fpmax32 (v2si, v2si);
19963 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19964 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19965 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19968 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19969 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19970 v2si __builtin_vis_fpmin32 (v2si, v2si);
19972 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19973 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19974 v2si __builtin_vis_fpminu32 (v2si, v2si);
19975 @end smallexample
19977 When you use the @option{-mvis4b} switch, the VIS version 4.0B
19978 built-in functions also become available:
19980 @smallexample
19981 v8qi __builtin_vis_dictunpack8 (double, int);
19982 v4hi __builtin_vis_dictunpack16 (double, int);
19983 v2si __builtin_vis_dictunpack32 (double, int);
19985 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
19986 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
19987 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
19988 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
19990 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
19991 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
19992 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
19993 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
19995 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
19996 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
19997 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
19998 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20000 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20001 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20002 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20003 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20004 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20005 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20007 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20008 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20009 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20011 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20012 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20013 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20014 @end smallexample
20016 @node SPU Built-in Functions
20017 @subsection SPU Built-in Functions
20019 GCC provides extensions for the SPU processor as described in the
20020 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
20021 implementation differs in several ways.
20023 @itemize @bullet
20025 @item
20026 The optional extension of specifying vector constants in parentheses is
20027 not supported.
20029 @item
20030 A vector initializer requires no cast if the vector constant is of the
20031 same type as the variable it is initializing.
20033 @item
20034 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20035 vector type is the default signedness of the base type.  The default
20036 varies depending on the operating system, so a portable program should
20037 always specify the signedness.
20039 @item
20040 By default, the keyword @code{__vector} is added. The macro
20041 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20042 undefined.
20044 @item
20045 GCC allows using a @code{typedef} name as the type specifier for a
20046 vector type.
20048 @item
20049 For C, overloaded functions are implemented with macros so the following
20050 does not work:
20052 @smallexample
20053   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20054 @end smallexample
20056 @noindent
20057 Since @code{spu_add} is a macro, the vector constant in the example
20058 is treated as four separate arguments.  Wrap the entire argument in
20059 parentheses for this to work.
20061 @item
20062 The extended version of @code{__builtin_expect} is not supported.
20064 @end itemize
20066 @emph{Note:} Only the interface described in the aforementioned
20067 specification is supported. Internally, GCC uses built-in functions to
20068 implement the required functionality, but these are not supported and
20069 are subject to change without notice.
20071 @node TI C6X Built-in Functions
20072 @subsection TI C6X Built-in Functions
20074 GCC provides intrinsics to access certain instructions of the TI C6X
20075 processors.  These intrinsics, listed below, are available after
20076 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
20077 to C6X instructions.
20079 @smallexample
20081 int _sadd (int, int)
20082 int _ssub (int, int)
20083 int _sadd2 (int, int)
20084 int _ssub2 (int, int)
20085 long long _mpy2 (int, int)
20086 long long _smpy2 (int, int)
20087 int _add4 (int, int)
20088 int _sub4 (int, int)
20089 int _saddu4 (int, int)
20091 int _smpy (int, int)
20092 int _smpyh (int, int)
20093 int _smpyhl (int, int)
20094 int _smpylh (int, int)
20096 int _sshl (int, int)
20097 int _subc (int, int)
20099 int _avg2 (int, int)
20100 int _avgu4 (int, int)
20102 int _clrr (int, int)
20103 int _extr (int, int)
20104 int _extru (int, int)
20105 int _abs (int)
20106 int _abs2 (int)
20108 @end smallexample
20110 @node TILE-Gx Built-in Functions
20111 @subsection TILE-Gx Built-in Functions
20113 GCC provides intrinsics to access every instruction of the TILE-Gx
20114 processor.  The intrinsics are of the form:
20116 @smallexample
20118 unsigned long long __insn_@var{op} (...)
20120 @end smallexample
20122 Where @var{op} is the name of the instruction.  Refer to the ISA manual
20123 for the complete list of instructions.
20125 GCC also provides intrinsics to directly access the network registers.
20126 The intrinsics are:
20128 @smallexample
20130 unsigned long long __tile_idn0_receive (void)
20131 unsigned long long __tile_idn1_receive (void)
20132 unsigned long long __tile_udn0_receive (void)
20133 unsigned long long __tile_udn1_receive (void)
20134 unsigned long long __tile_udn2_receive (void)
20135 unsigned long long __tile_udn3_receive (void)
20136 void __tile_idn_send (unsigned long long)
20137 void __tile_udn_send (unsigned long long)
20139 @end smallexample
20141 The intrinsic @code{void __tile_network_barrier (void)} is used to
20142 guarantee that no network operations before it are reordered with
20143 those after it.
20145 @node TILEPro Built-in Functions
20146 @subsection TILEPro Built-in Functions
20148 GCC provides intrinsics to access every instruction of the TILEPro
20149 processor.  The intrinsics are of the form:
20151 @smallexample
20153 unsigned __insn_@var{op} (...)
20155 @end smallexample
20157 @noindent
20158 where @var{op} is the name of the instruction.  Refer to the ISA manual
20159 for the complete list of instructions.
20161 GCC also provides intrinsics to directly access the network registers.
20162 The intrinsics are:
20164 @smallexample
20166 unsigned __tile_idn0_receive (void)
20167 unsigned __tile_idn1_receive (void)
20168 unsigned __tile_sn_receive (void)
20169 unsigned __tile_udn0_receive (void)
20170 unsigned __tile_udn1_receive (void)
20171 unsigned __tile_udn2_receive (void)
20172 unsigned __tile_udn3_receive (void)
20173 void __tile_idn_send (unsigned)
20174 void __tile_sn_send (unsigned)
20175 void __tile_udn_send (unsigned)
20177 @end smallexample
20179 The intrinsic @code{void __tile_network_barrier (void)} is used to
20180 guarantee that no network operations before it are reordered with
20181 those after it.
20183 @node x86 Built-in Functions
20184 @subsection x86 Built-in Functions
20186 These built-in functions are available for the x86-32 and x86-64 family
20187 of computers, depending on the command-line switches used.
20189 If you specify command-line switches such as @option{-msse},
20190 the compiler could use the extended instruction sets even if the built-ins
20191 are not used explicitly in the program.  For this reason, applications
20192 that perform run-time CPU detection must compile separate files for each
20193 supported architecture, using the appropriate flags.  In particular,
20194 the file containing the CPU detection code should be compiled without
20195 these options.
20197 The following machine modes are available for use with MMX built-in functions
20198 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20199 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20200 vector of eight 8-bit integers.  Some of the built-in functions operate on
20201 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20203 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20204 of two 32-bit floating-point values.
20206 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20207 floating-point values.  Some instructions use a vector of four 32-bit
20208 integers, these use @code{V4SI}.  Finally, some instructions operate on an
20209 entire vector register, interpreting it as a 128-bit integer, these use mode
20210 @code{TI}.
20212 The x86-32 and x86-64 family of processors use additional built-in
20213 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20214 floating point and @code{TC} 128-bit complex floating-point values.
20216 The following floating-point built-in functions are always available.  All
20217 of them implement the function that is part of the name.
20219 @smallexample
20220 __float128 __builtin_fabsq (__float128)
20221 __float128 __builtin_copysignq (__float128, __float128)
20222 @end smallexample
20224 The following built-in functions are always available.
20226 @table @code
20227 @item __float128 __builtin_infq (void)
20228 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20229 @findex __builtin_infq
20231 @item __float128 __builtin_huge_valq (void)
20232 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20233 @findex __builtin_huge_valq
20235 @item __float128 __builtin_nanq (void)
20236 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20237 @findex __builtin_nanq
20239 @item __float128 __builtin_nansq (void)
20240 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20241 @findex __builtin_nansq
20242 @end table
20244 The following built-in function is always available.
20246 @table @code
20247 @item void __builtin_ia32_pause (void)
20248 Generates the @code{pause} machine instruction with a compiler memory
20249 barrier.
20250 @end table
20252 The following built-in functions are always available and can be used to
20253 check the target platform type.
20255 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20256 This function runs the CPU detection code to check the type of CPU and the
20257 features supported.  This built-in function needs to be invoked along with the built-in functions
20258 to check CPU type and features, @code{__builtin_cpu_is} and
20259 @code{__builtin_cpu_supports}, only when used in a function that is
20260 executed before any constructors are called.  The CPU detection code is
20261 automatically executed in a very high priority constructor.
20263 For example, this function has to be used in @code{ifunc} resolvers that
20264 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20265 and @code{__builtin_cpu_supports}, or in constructors on targets that
20266 don't support constructor priority.
20267 @smallexample
20269 static void (*resolve_memcpy (void)) (void)
20271   // ifunc resolvers fire before constructors, explicitly call the init
20272   // function.
20273   __builtin_cpu_init ();
20274   if (__builtin_cpu_supports ("ssse3"))
20275     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20276   else
20277     return default_memcpy;
20280 void *memcpy (void *, const void *, size_t)
20281      __attribute__ ((ifunc ("resolve_memcpy")));
20282 @end smallexample
20284 @end deftypefn
20286 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20287 This function returns a positive integer if the run-time CPU
20288 is of type @var{cpuname}
20289 and returns @code{0} otherwise. The following CPU names can be detected:
20291 @table @samp
20292 @item intel
20293 Intel CPU.
20295 @item atom
20296 Intel Atom CPU.
20298 @item core2
20299 Intel Core 2 CPU.
20301 @item corei7
20302 Intel Core i7 CPU.
20304 @item nehalem
20305 Intel Core i7 Nehalem CPU.
20307 @item westmere
20308 Intel Core i7 Westmere CPU.
20310 @item sandybridge
20311 Intel Core i7 Sandy Bridge CPU.
20313 @item amd
20314 AMD CPU.
20316 @item amdfam10h
20317 AMD Family 10h CPU.
20319 @item barcelona
20320 AMD Family 10h Barcelona CPU.
20322 @item shanghai
20323 AMD Family 10h Shanghai CPU.
20325 @item istanbul
20326 AMD Family 10h Istanbul CPU.
20328 @item btver1
20329 AMD Family 14h CPU.
20331 @item amdfam15h
20332 AMD Family 15h CPU.
20334 @item bdver1
20335 AMD Family 15h Bulldozer version 1.
20337 @item bdver2
20338 AMD Family 15h Bulldozer version 2.
20340 @item bdver3
20341 AMD Family 15h Bulldozer version 3.
20343 @item bdver4
20344 AMD Family 15h Bulldozer version 4.
20346 @item btver2
20347 AMD Family 16h CPU.
20349 @item amdfam17h
20350 AMD Family 17h CPU.
20352 @item znver1
20353 AMD Family 17h Zen version 1.
20354 @end table
20356 Here is an example:
20357 @smallexample
20358 if (__builtin_cpu_is ("corei7"))
20359   @{
20360      do_corei7 (); // Core i7 specific implementation.
20361   @}
20362 else
20363   @{
20364      do_generic (); // Generic implementation.
20365   @}
20366 @end smallexample
20367 @end deftypefn
20369 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20370 This function returns a positive integer if the run-time CPU
20371 supports @var{feature}
20372 and returns @code{0} otherwise. The following features can be detected:
20374 @table @samp
20375 @item cmov
20376 CMOV instruction.
20377 @item mmx
20378 MMX instructions.
20379 @item popcnt
20380 POPCNT instruction.
20381 @item sse
20382 SSE instructions.
20383 @item sse2
20384 SSE2 instructions.
20385 @item sse3
20386 SSE3 instructions.
20387 @item ssse3
20388 SSSE3 instructions.
20389 @item sse4.1
20390 SSE4.1 instructions.
20391 @item sse4.2
20392 SSE4.2 instructions.
20393 @item avx
20394 AVX instructions.
20395 @item avx2
20396 AVX2 instructions.
20397 @item avx512f
20398 AVX512F instructions.
20399 @end table
20401 Here is an example:
20402 @smallexample
20403 if (__builtin_cpu_supports ("popcnt"))
20404   @{
20405      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20406   @}
20407 else
20408   @{
20409      count = generic_countbits (n); //generic implementation.
20410   @}
20411 @end smallexample
20412 @end deftypefn
20415 The following built-in functions are made available by @option{-mmmx}.
20416 All of them generate the machine instruction that is part of the name.
20418 @smallexample
20419 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20420 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20421 v2si __builtin_ia32_paddd (v2si, v2si)
20422 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20423 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20424 v2si __builtin_ia32_psubd (v2si, v2si)
20425 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20426 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20427 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20428 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20429 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20430 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20431 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20432 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20433 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20434 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20435 di __builtin_ia32_pand (di, di)
20436 di __builtin_ia32_pandn (di,di)
20437 di __builtin_ia32_por (di, di)
20438 di __builtin_ia32_pxor (di, di)
20439 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20440 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20441 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20442 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20443 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20444 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20445 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20446 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20447 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20448 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20449 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20450 v2si __builtin_ia32_punpckldq (v2si, v2si)
20451 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20452 v4hi __builtin_ia32_packssdw (v2si, v2si)
20453 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20455 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20456 v2si __builtin_ia32_pslld (v2si, v2si)
20457 v1di __builtin_ia32_psllq (v1di, v1di)
20458 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20459 v2si __builtin_ia32_psrld (v2si, v2si)
20460 v1di __builtin_ia32_psrlq (v1di, v1di)
20461 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20462 v2si __builtin_ia32_psrad (v2si, v2si)
20463 v4hi __builtin_ia32_psllwi (v4hi, int)
20464 v2si __builtin_ia32_pslldi (v2si, int)
20465 v1di __builtin_ia32_psllqi (v1di, int)
20466 v4hi __builtin_ia32_psrlwi (v4hi, int)
20467 v2si __builtin_ia32_psrldi (v2si, int)
20468 v1di __builtin_ia32_psrlqi (v1di, int)
20469 v4hi __builtin_ia32_psrawi (v4hi, int)
20470 v2si __builtin_ia32_psradi (v2si, int)
20472 @end smallexample
20474 The following built-in functions are made available either with
20475 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20476 the machine instruction that is part of the name.
20478 @smallexample
20479 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20480 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20481 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20482 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20483 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20484 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20485 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20486 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20487 int __builtin_ia32_pmovmskb (v8qi)
20488 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20489 void __builtin_ia32_movntq (di *, di)
20490 void __builtin_ia32_sfence (void)
20491 @end smallexample
20493 The following built-in functions are available when @option{-msse} is used.
20494 All of them generate the machine instruction that is part of the name.
20496 @smallexample
20497 int __builtin_ia32_comieq (v4sf, v4sf)
20498 int __builtin_ia32_comineq (v4sf, v4sf)
20499 int __builtin_ia32_comilt (v4sf, v4sf)
20500 int __builtin_ia32_comile (v4sf, v4sf)
20501 int __builtin_ia32_comigt (v4sf, v4sf)
20502 int __builtin_ia32_comige (v4sf, v4sf)
20503 int __builtin_ia32_ucomieq (v4sf, v4sf)
20504 int __builtin_ia32_ucomineq (v4sf, v4sf)
20505 int __builtin_ia32_ucomilt (v4sf, v4sf)
20506 int __builtin_ia32_ucomile (v4sf, v4sf)
20507 int __builtin_ia32_ucomigt (v4sf, v4sf)
20508 int __builtin_ia32_ucomige (v4sf, v4sf)
20509 v4sf __builtin_ia32_addps (v4sf, v4sf)
20510 v4sf __builtin_ia32_subps (v4sf, v4sf)
20511 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20512 v4sf __builtin_ia32_divps (v4sf, v4sf)
20513 v4sf __builtin_ia32_addss (v4sf, v4sf)
20514 v4sf __builtin_ia32_subss (v4sf, v4sf)
20515 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20516 v4sf __builtin_ia32_divss (v4sf, v4sf)
20517 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20518 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20519 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20520 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20521 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20522 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20523 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20524 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20525 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20526 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20527 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20528 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20529 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20530 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20531 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20532 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20533 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20534 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20535 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20536 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20537 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20538 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20539 v4sf __builtin_ia32_minps (v4sf, v4sf)
20540 v4sf __builtin_ia32_minss (v4sf, v4sf)
20541 v4sf __builtin_ia32_andps (v4sf, v4sf)
20542 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20543 v4sf __builtin_ia32_orps (v4sf, v4sf)
20544 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20545 v4sf __builtin_ia32_movss (v4sf, v4sf)
20546 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20547 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20548 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20549 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20550 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20551 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20552 v2si __builtin_ia32_cvtps2pi (v4sf)
20553 int __builtin_ia32_cvtss2si (v4sf)
20554 v2si __builtin_ia32_cvttps2pi (v4sf)
20555 int __builtin_ia32_cvttss2si (v4sf)
20556 v4sf __builtin_ia32_rcpps (v4sf)
20557 v4sf __builtin_ia32_rsqrtps (v4sf)
20558 v4sf __builtin_ia32_sqrtps (v4sf)
20559 v4sf __builtin_ia32_rcpss (v4sf)
20560 v4sf __builtin_ia32_rsqrtss (v4sf)
20561 v4sf __builtin_ia32_sqrtss (v4sf)
20562 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20563 void __builtin_ia32_movntps (float *, v4sf)
20564 int __builtin_ia32_movmskps (v4sf)
20565 @end smallexample
20567 The following built-in functions are available when @option{-msse} is used.
20569 @table @code
20570 @item v4sf __builtin_ia32_loadups (float *)
20571 Generates the @code{movups} machine instruction as a load from memory.
20572 @item void __builtin_ia32_storeups (float *, v4sf)
20573 Generates the @code{movups} machine instruction as a store to memory.
20574 @item v4sf __builtin_ia32_loadss (float *)
20575 Generates the @code{movss} machine instruction as a load from memory.
20576 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20577 Generates the @code{movhps} machine instruction as a load from memory.
20578 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20579 Generates the @code{movlps} machine instruction as a load from memory
20580 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20581 Generates the @code{movhps} machine instruction as a store to memory.
20582 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20583 Generates the @code{movlps} machine instruction as a store to memory.
20584 @end table
20586 The following built-in functions are available when @option{-msse2} is used.
20587 All of them generate the machine instruction that is part of the name.
20589 @smallexample
20590 int __builtin_ia32_comisdeq (v2df, v2df)
20591 int __builtin_ia32_comisdlt (v2df, v2df)
20592 int __builtin_ia32_comisdle (v2df, v2df)
20593 int __builtin_ia32_comisdgt (v2df, v2df)
20594 int __builtin_ia32_comisdge (v2df, v2df)
20595 int __builtin_ia32_comisdneq (v2df, v2df)
20596 int __builtin_ia32_ucomisdeq (v2df, v2df)
20597 int __builtin_ia32_ucomisdlt (v2df, v2df)
20598 int __builtin_ia32_ucomisdle (v2df, v2df)
20599 int __builtin_ia32_ucomisdgt (v2df, v2df)
20600 int __builtin_ia32_ucomisdge (v2df, v2df)
20601 int __builtin_ia32_ucomisdneq (v2df, v2df)
20602 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20603 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20604 v2df __builtin_ia32_cmplepd (v2df, v2df)
20605 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20606 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20607 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20608 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20609 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20610 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20611 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20612 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20613 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20614 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20615 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20616 v2df __builtin_ia32_cmplesd (v2df, v2df)
20617 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20618 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20619 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20620 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20621 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20622 v2di __builtin_ia32_paddq (v2di, v2di)
20623 v2di __builtin_ia32_psubq (v2di, v2di)
20624 v2df __builtin_ia32_addpd (v2df, v2df)
20625 v2df __builtin_ia32_subpd (v2df, v2df)
20626 v2df __builtin_ia32_mulpd (v2df, v2df)
20627 v2df __builtin_ia32_divpd (v2df, v2df)
20628 v2df __builtin_ia32_addsd (v2df, v2df)
20629 v2df __builtin_ia32_subsd (v2df, v2df)
20630 v2df __builtin_ia32_mulsd (v2df, v2df)
20631 v2df __builtin_ia32_divsd (v2df, v2df)
20632 v2df __builtin_ia32_minpd (v2df, v2df)
20633 v2df __builtin_ia32_maxpd (v2df, v2df)
20634 v2df __builtin_ia32_minsd (v2df, v2df)
20635 v2df __builtin_ia32_maxsd (v2df, v2df)
20636 v2df __builtin_ia32_andpd (v2df, v2df)
20637 v2df __builtin_ia32_andnpd (v2df, v2df)
20638 v2df __builtin_ia32_orpd (v2df, v2df)
20639 v2df __builtin_ia32_xorpd (v2df, v2df)
20640 v2df __builtin_ia32_movsd (v2df, v2df)
20641 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20642 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20643 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20644 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20645 v4si __builtin_ia32_paddd128 (v4si, v4si)
20646 v2di __builtin_ia32_paddq128 (v2di, v2di)
20647 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20648 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20649 v4si __builtin_ia32_psubd128 (v4si, v4si)
20650 v2di __builtin_ia32_psubq128 (v2di, v2di)
20651 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20652 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20653 v2di __builtin_ia32_pand128 (v2di, v2di)
20654 v2di __builtin_ia32_pandn128 (v2di, v2di)
20655 v2di __builtin_ia32_por128 (v2di, v2di)
20656 v2di __builtin_ia32_pxor128 (v2di, v2di)
20657 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20658 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20659 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20660 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20661 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20662 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20663 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20664 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20665 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20666 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20667 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20668 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20669 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20670 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20671 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20672 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20673 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20674 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20675 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20676 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20677 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20678 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20679 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20680 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20681 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20682 v2df __builtin_ia32_loadupd (double *)
20683 void __builtin_ia32_storeupd (double *, v2df)
20684 v2df __builtin_ia32_loadhpd (v2df, double const *)
20685 v2df __builtin_ia32_loadlpd (v2df, double const *)
20686 int __builtin_ia32_movmskpd (v2df)
20687 int __builtin_ia32_pmovmskb128 (v16qi)
20688 void __builtin_ia32_movnti (int *, int)
20689 void __builtin_ia32_movnti64 (long long int *, long long int)
20690 void __builtin_ia32_movntpd (double *, v2df)
20691 void __builtin_ia32_movntdq (v2df *, v2df)
20692 v4si __builtin_ia32_pshufd (v4si, int)
20693 v8hi __builtin_ia32_pshuflw (v8hi, int)
20694 v8hi __builtin_ia32_pshufhw (v8hi, int)
20695 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20696 v2df __builtin_ia32_sqrtpd (v2df)
20697 v2df __builtin_ia32_sqrtsd (v2df)
20698 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20699 v2df __builtin_ia32_cvtdq2pd (v4si)
20700 v4sf __builtin_ia32_cvtdq2ps (v4si)
20701 v4si __builtin_ia32_cvtpd2dq (v2df)
20702 v2si __builtin_ia32_cvtpd2pi (v2df)
20703 v4sf __builtin_ia32_cvtpd2ps (v2df)
20704 v4si __builtin_ia32_cvttpd2dq (v2df)
20705 v2si __builtin_ia32_cvttpd2pi (v2df)
20706 v2df __builtin_ia32_cvtpi2pd (v2si)
20707 int __builtin_ia32_cvtsd2si (v2df)
20708 int __builtin_ia32_cvttsd2si (v2df)
20709 long long __builtin_ia32_cvtsd2si64 (v2df)
20710 long long __builtin_ia32_cvttsd2si64 (v2df)
20711 v4si __builtin_ia32_cvtps2dq (v4sf)
20712 v2df __builtin_ia32_cvtps2pd (v4sf)
20713 v4si __builtin_ia32_cvttps2dq (v4sf)
20714 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20715 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20716 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20717 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20718 void __builtin_ia32_clflush (const void *)
20719 void __builtin_ia32_lfence (void)
20720 void __builtin_ia32_mfence (void)
20721 v16qi __builtin_ia32_loaddqu (const char *)
20722 void __builtin_ia32_storedqu (char *, v16qi)
20723 v1di __builtin_ia32_pmuludq (v2si, v2si)
20724 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20725 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20726 v4si __builtin_ia32_pslld128 (v4si, v4si)
20727 v2di __builtin_ia32_psllq128 (v2di, v2di)
20728 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20729 v4si __builtin_ia32_psrld128 (v4si, v4si)
20730 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20731 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20732 v4si __builtin_ia32_psrad128 (v4si, v4si)
20733 v2di __builtin_ia32_pslldqi128 (v2di, int)
20734 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20735 v4si __builtin_ia32_pslldi128 (v4si, int)
20736 v2di __builtin_ia32_psllqi128 (v2di, int)
20737 v2di __builtin_ia32_psrldqi128 (v2di, int)
20738 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20739 v4si __builtin_ia32_psrldi128 (v4si, int)
20740 v2di __builtin_ia32_psrlqi128 (v2di, int)
20741 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20742 v4si __builtin_ia32_psradi128 (v4si, int)
20743 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20744 v2di __builtin_ia32_movq128 (v2di)
20745 @end smallexample
20747 The following built-in functions are available when @option{-msse3} is used.
20748 All of them generate the machine instruction that is part of the name.
20750 @smallexample
20751 v2df __builtin_ia32_addsubpd (v2df, v2df)
20752 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20753 v2df __builtin_ia32_haddpd (v2df, v2df)
20754 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20755 v2df __builtin_ia32_hsubpd (v2df, v2df)
20756 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20757 v16qi __builtin_ia32_lddqu (char const *)
20758 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20759 v4sf __builtin_ia32_movshdup (v4sf)
20760 v4sf __builtin_ia32_movsldup (v4sf)
20761 void __builtin_ia32_mwait (unsigned int, unsigned int)
20762 @end smallexample
20764 The following built-in functions are available when @option{-mssse3} is used.
20765 All of them generate the machine instruction that is part of the name.
20767 @smallexample
20768 v2si __builtin_ia32_phaddd (v2si, v2si)
20769 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20770 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20771 v2si __builtin_ia32_phsubd (v2si, v2si)
20772 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20773 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20774 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20775 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20776 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20777 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20778 v2si __builtin_ia32_psignd (v2si, v2si)
20779 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20780 v1di __builtin_ia32_palignr (v1di, v1di, int)
20781 v8qi __builtin_ia32_pabsb (v8qi)
20782 v2si __builtin_ia32_pabsd (v2si)
20783 v4hi __builtin_ia32_pabsw (v4hi)
20784 @end smallexample
20786 The following built-in functions are available when @option{-mssse3} is used.
20787 All of them generate the machine instruction that is part of the name.
20789 @smallexample
20790 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20791 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20792 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20793 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20794 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20795 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20796 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20797 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20798 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20799 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20800 v4si __builtin_ia32_psignd128 (v4si, v4si)
20801 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20802 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20803 v16qi __builtin_ia32_pabsb128 (v16qi)
20804 v4si __builtin_ia32_pabsd128 (v4si)
20805 v8hi __builtin_ia32_pabsw128 (v8hi)
20806 @end smallexample
20808 The following built-in functions are available when @option{-msse4.1} is
20809 used.  All of them generate the machine instruction that is part of the
20810 name.
20812 @smallexample
20813 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20814 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20815 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20816 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20817 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20818 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20819 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20820 v2di __builtin_ia32_movntdqa (v2di *);
20821 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20822 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20823 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20824 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20825 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20826 v8hi __builtin_ia32_phminposuw128 (v8hi)
20827 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20828 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20829 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20830 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20831 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20832 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20833 v4si __builtin_ia32_pminud128 (v4si, v4si)
20834 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20835 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20836 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20837 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20838 v2di __builtin_ia32_pmovsxdq128 (v4si)
20839 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20840 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20841 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20842 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20843 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20844 v2di __builtin_ia32_pmovzxdq128 (v4si)
20845 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20846 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20847 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20848 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20849 int __builtin_ia32_ptestc128 (v2di, v2di)
20850 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20851 int __builtin_ia32_ptestz128 (v2di, v2di)
20852 v2df __builtin_ia32_roundpd (v2df, const int)
20853 v4sf __builtin_ia32_roundps (v4sf, const int)
20854 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20855 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20856 @end smallexample
20858 The following built-in functions are available when @option{-msse4.1} is
20859 used.
20861 @table @code
20862 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20863 Generates the @code{insertps} machine instruction.
20864 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20865 Generates the @code{pextrb} machine instruction.
20866 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20867 Generates the @code{pinsrb} machine instruction.
20868 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20869 Generates the @code{pinsrd} machine instruction.
20870 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20871 Generates the @code{pinsrq} machine instruction in 64bit mode.
20872 @end table
20874 The following built-in functions are changed to generate new SSE4.1
20875 instructions when @option{-msse4.1} is used.
20877 @table @code
20878 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20879 Generates the @code{extractps} machine instruction.
20880 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20881 Generates the @code{pextrd} machine instruction.
20882 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20883 Generates the @code{pextrq} machine instruction in 64bit mode.
20884 @end table
20886 The following built-in functions are available when @option{-msse4.2} is
20887 used.  All of them generate the machine instruction that is part of the
20888 name.
20890 @smallexample
20891 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20892 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20893 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20894 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20895 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20896 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20897 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20898 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20899 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20900 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20901 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20902 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20903 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20904 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20905 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20906 @end smallexample
20908 The following built-in functions are available when @option{-msse4.2} is
20909 used.
20911 @table @code
20912 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20913 Generates the @code{crc32b} machine instruction.
20914 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20915 Generates the @code{crc32w} machine instruction.
20916 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20917 Generates the @code{crc32l} machine instruction.
20918 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20919 Generates the @code{crc32q} machine instruction.
20920 @end table
20922 The following built-in functions are changed to generate new SSE4.2
20923 instructions when @option{-msse4.2} is used.
20925 @table @code
20926 @item int __builtin_popcount (unsigned int)
20927 Generates the @code{popcntl} machine instruction.
20928 @item int __builtin_popcountl (unsigned long)
20929 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20930 depending on the size of @code{unsigned long}.
20931 @item int __builtin_popcountll (unsigned long long)
20932 Generates the @code{popcntq} machine instruction.
20933 @end table
20935 The following built-in functions are available when @option{-mavx} is
20936 used. All of them generate the machine instruction that is part of the
20937 name.
20939 @smallexample
20940 v4df __builtin_ia32_addpd256 (v4df,v4df)
20941 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20942 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20943 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20944 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20945 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20946 v4df __builtin_ia32_andpd256 (v4df,v4df)
20947 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20948 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20949 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20950 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20951 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20952 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20953 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20954 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20955 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20956 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20957 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20958 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20959 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20960 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20961 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20962 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20963 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20964 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20965 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20966 v4df __builtin_ia32_divpd256 (v4df,v4df)
20967 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20968 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20969 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20970 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20971 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20972 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20973 v32qi __builtin_ia32_lddqu256 (pcchar)
20974 v32qi __builtin_ia32_loaddqu256 (pcchar)
20975 v4df __builtin_ia32_loadupd256 (pcdouble)
20976 v8sf __builtin_ia32_loadups256 (pcfloat)
20977 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20978 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20979 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20980 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20981 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20982 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20983 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20984 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20985 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20986 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20987 v4df __builtin_ia32_minpd256 (v4df,v4df)
20988 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20989 v4df __builtin_ia32_movddup256 (v4df)
20990 int __builtin_ia32_movmskpd256 (v4df)
20991 int __builtin_ia32_movmskps256 (v8sf)
20992 v8sf __builtin_ia32_movshdup256 (v8sf)
20993 v8sf __builtin_ia32_movsldup256 (v8sf)
20994 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20995 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20996 v4df __builtin_ia32_orpd256 (v4df,v4df)
20997 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20998 v2df __builtin_ia32_pd_pd256 (v4df)
20999 v4df __builtin_ia32_pd256_pd (v2df)
21000 v4sf __builtin_ia32_ps_ps256 (v8sf)
21001 v8sf __builtin_ia32_ps256_ps (v4sf)
21002 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21003 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21004 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21005 v8sf __builtin_ia32_rcpps256 (v8sf)
21006 v4df __builtin_ia32_roundpd256 (v4df,int)
21007 v8sf __builtin_ia32_roundps256 (v8sf,int)
21008 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21009 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21010 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21011 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21012 v4si __builtin_ia32_si_si256 (v8si)
21013 v8si __builtin_ia32_si256_si (v4si)
21014 v4df __builtin_ia32_sqrtpd256 (v4df)
21015 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21016 v8sf __builtin_ia32_sqrtps256 (v8sf)
21017 void __builtin_ia32_storedqu256 (pchar,v32qi)
21018 void __builtin_ia32_storeupd256 (pdouble,v4df)
21019 void __builtin_ia32_storeups256 (pfloat,v8sf)
21020 v4df __builtin_ia32_subpd256 (v4df,v4df)
21021 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21022 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21023 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21024 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21025 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21026 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21027 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21028 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21029 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21030 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21031 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21032 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21033 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21034 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21035 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21036 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21037 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21038 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21039 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21040 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21041 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21042 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21043 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21044 v2df __builtin_ia32_vpermilpd (v2df,int)
21045 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21046 v4sf __builtin_ia32_vpermilps (v4sf,int)
21047 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21048 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21049 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21050 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21051 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21052 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21053 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21054 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21055 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21056 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21057 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21058 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21059 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21060 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21061 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21062 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21063 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21064 void __builtin_ia32_vzeroall (void)
21065 void __builtin_ia32_vzeroupper (void)
21066 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21067 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21068 @end smallexample
21070 The following built-in functions are available when @option{-mavx2} is
21071 used. All of them generate the machine instruction that is part of the
21072 name.
21074 @smallexample
21075 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21076 v32qi __builtin_ia32_pabsb256 (v32qi)
21077 v16hi __builtin_ia32_pabsw256 (v16hi)
21078 v8si __builtin_ia32_pabsd256 (v8si)
21079 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21080 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21081 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21082 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21083 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21084 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21085 v8si __builtin_ia32_paddd256 (v8si,v8si)
21086 v4di __builtin_ia32_paddq256 (v4di,v4di)
21087 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21088 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21089 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21090 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21091 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21092 v4di __builtin_ia32_andsi256 (v4di,v4di)
21093 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21094 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21095 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21096 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21097 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21098 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21099 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21100 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21101 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21102 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21103 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21104 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21105 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21106 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21107 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21108 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21109 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21110 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21111 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21112 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21113 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21114 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21115 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21116 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21117 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21118 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21119 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21120 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21121 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21122 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21123 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21124 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21125 v8si __builtin_ia32_pminud256 (v8si,v8si)
21126 int __builtin_ia32_pmovmskb256 (v32qi)
21127 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21128 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21129 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21130 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21131 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21132 v4di __builtin_ia32_pmovsxdq256 (v4si)
21133 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21134 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21135 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21136 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21137 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21138 v4di __builtin_ia32_pmovzxdq256 (v4si)
21139 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21140 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21141 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21142 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21143 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21144 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21145 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21146 v4di __builtin_ia32_por256 (v4di,v4di)
21147 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21148 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21149 v8si __builtin_ia32_pshufd256 (v8si,int)
21150 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21151 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21152 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21153 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21154 v8si __builtin_ia32_psignd256 (v8si,v8si)
21155 v4di __builtin_ia32_pslldqi256 (v4di,int)
21156 v16hi __builtin_ia32_psllwi256 (16hi,int)
21157 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21158 v8si __builtin_ia32_pslldi256 (v8si,int)
21159 v8si __builtin_ia32_pslld256(v8si,v4si)
21160 v4di __builtin_ia32_psllqi256 (v4di,int)
21161 v4di __builtin_ia32_psllq256(v4di,v2di)
21162 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21163 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21164 v8si __builtin_ia32_psradi256 (v8si,int)
21165 v8si __builtin_ia32_psrad256 (v8si,v4si)
21166 v4di __builtin_ia32_psrldqi256 (v4di, int)
21167 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21168 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21169 v8si __builtin_ia32_psrldi256 (v8si,int)
21170 v8si __builtin_ia32_psrld256 (v8si,v4si)
21171 v4di __builtin_ia32_psrlqi256 (v4di,int)
21172 v4di __builtin_ia32_psrlq256(v4di,v2di)
21173 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21174 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21175 v8si __builtin_ia32_psubd256 (v8si,v8si)
21176 v4di __builtin_ia32_psubq256 (v4di,v4di)
21177 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21178 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21179 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21180 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21181 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21182 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21183 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21184 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21185 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21186 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21187 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21188 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21189 v4di __builtin_ia32_pxor256 (v4di,v4di)
21190 v4di __builtin_ia32_movntdqa256 (pv4di)
21191 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21192 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21193 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21194 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21195 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21196 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21197 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21198 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21199 v8si __builtin_ia32_pbroadcastd256 (v4si)
21200 v4di __builtin_ia32_pbroadcastq256 (v2di)
21201 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21202 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21203 v4si __builtin_ia32_pbroadcastd128 (v4si)
21204 v2di __builtin_ia32_pbroadcastq128 (v2di)
21205 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21206 v4df __builtin_ia32_permdf256 (v4df,int)
21207 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21208 v4di __builtin_ia32_permdi256 (v4di,int)
21209 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21210 v4di __builtin_ia32_extract128i256 (v4di,int)
21211 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21212 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21213 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21214 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21215 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21216 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21217 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21218 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21219 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21220 v8si __builtin_ia32_psllv8si (v8si,v8si)
21221 v4si __builtin_ia32_psllv4si (v4si,v4si)
21222 v4di __builtin_ia32_psllv4di (v4di,v4di)
21223 v2di __builtin_ia32_psllv2di (v2di,v2di)
21224 v8si __builtin_ia32_psrav8si (v8si,v8si)
21225 v4si __builtin_ia32_psrav4si (v4si,v4si)
21226 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21227 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21228 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21229 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21230 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21231 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21232 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21233 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21234 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21235 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21236 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21237 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21238 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21239 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21240 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21241 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21242 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21243 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21244 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21245 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21246 @end smallexample
21248 The following built-in functions are available when @option{-maes} is
21249 used.  All of them generate the machine instruction that is part of the
21250 name.
21252 @smallexample
21253 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21254 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21255 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21256 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21257 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21258 v2di __builtin_ia32_aesimc128 (v2di)
21259 @end smallexample
21261 The following built-in function is available when @option{-mpclmul} is
21262 used.
21264 @table @code
21265 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21266 Generates the @code{pclmulqdq} machine instruction.
21267 @end table
21269 The following built-in function is available when @option{-mfsgsbase} is
21270 used.  All of them generate the machine instruction that is part of the
21271 name.
21273 @smallexample
21274 unsigned int __builtin_ia32_rdfsbase32 (void)
21275 unsigned long long __builtin_ia32_rdfsbase64 (void)
21276 unsigned int __builtin_ia32_rdgsbase32 (void)
21277 unsigned long long __builtin_ia32_rdgsbase64 (void)
21278 void _writefsbase_u32 (unsigned int)
21279 void _writefsbase_u64 (unsigned long long)
21280 void _writegsbase_u32 (unsigned int)
21281 void _writegsbase_u64 (unsigned long long)
21282 @end smallexample
21284 The following built-in function is available when @option{-mrdrnd} is
21285 used.  All of them generate the machine instruction that is part of the
21286 name.
21288 @smallexample
21289 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21290 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21291 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21292 @end smallexample
21294 The following built-in functions are available when @option{-msse4a} is used.
21295 All of them generate the machine instruction that is part of the name.
21297 @smallexample
21298 void __builtin_ia32_movntsd (double *, v2df)
21299 void __builtin_ia32_movntss (float *, v4sf)
21300 v2di __builtin_ia32_extrq  (v2di, v16qi)
21301 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21302 v2di __builtin_ia32_insertq (v2di, v2di)
21303 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21304 @end smallexample
21306 The following built-in functions are available when @option{-mxop} is used.
21307 @smallexample
21308 v2df __builtin_ia32_vfrczpd (v2df)
21309 v4sf __builtin_ia32_vfrczps (v4sf)
21310 v2df __builtin_ia32_vfrczsd (v2df)
21311 v4sf __builtin_ia32_vfrczss (v4sf)
21312 v4df __builtin_ia32_vfrczpd256 (v4df)
21313 v8sf __builtin_ia32_vfrczps256 (v8sf)
21314 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21315 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21316 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21317 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21318 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21319 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21320 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21321 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21322 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21323 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21324 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21325 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21326 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21327 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21328 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21329 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21330 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21331 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21332 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21333 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21334 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21335 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21336 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21337 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21338 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21339 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21340 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21341 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21342 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21343 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21344 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21345 v4si __builtin_ia32_vpcomged (v4si, v4si)
21346 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21347 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21348 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21349 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21350 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21351 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21352 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21353 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21354 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21355 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21356 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21357 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21358 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21359 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21360 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21361 v4si __builtin_ia32_vpcomled (v4si, v4si)
21362 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21363 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21364 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21365 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21366 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21367 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21368 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21369 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21370 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21371 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21372 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21373 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21374 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21375 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21376 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21377 v4si __builtin_ia32_vpcomned (v4si, v4si)
21378 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21379 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21380 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21381 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21382 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21383 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21384 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21385 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21386 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21387 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21388 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21389 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21390 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21391 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21392 v4si __builtin_ia32_vphaddbd (v16qi)
21393 v2di __builtin_ia32_vphaddbq (v16qi)
21394 v8hi __builtin_ia32_vphaddbw (v16qi)
21395 v2di __builtin_ia32_vphadddq (v4si)
21396 v4si __builtin_ia32_vphaddubd (v16qi)
21397 v2di __builtin_ia32_vphaddubq (v16qi)
21398 v8hi __builtin_ia32_vphaddubw (v16qi)
21399 v2di __builtin_ia32_vphaddudq (v4si)
21400 v4si __builtin_ia32_vphadduwd (v8hi)
21401 v2di __builtin_ia32_vphadduwq (v8hi)
21402 v4si __builtin_ia32_vphaddwd (v8hi)
21403 v2di __builtin_ia32_vphaddwq (v8hi)
21404 v8hi __builtin_ia32_vphsubbw (v16qi)
21405 v2di __builtin_ia32_vphsubdq (v4si)
21406 v4si __builtin_ia32_vphsubwd (v8hi)
21407 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21408 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21409 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21410 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21411 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21412 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21413 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21414 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21415 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21416 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21417 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21418 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21419 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21420 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21421 v4si __builtin_ia32_vprotd (v4si, v4si)
21422 v2di __builtin_ia32_vprotq (v2di, v2di)
21423 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21424 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21425 v4si __builtin_ia32_vpshad (v4si, v4si)
21426 v2di __builtin_ia32_vpshaq (v2di, v2di)
21427 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21428 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21429 v4si __builtin_ia32_vpshld (v4si, v4si)
21430 v2di __builtin_ia32_vpshlq (v2di, v2di)
21431 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21432 @end smallexample
21434 The following built-in functions are available when @option{-mfma4} is used.
21435 All of them generate the machine instruction that is part of the name.
21437 @smallexample
21438 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21439 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21440 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21441 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21442 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21443 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21444 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21445 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21446 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21447 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21448 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21449 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21450 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21451 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21452 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21453 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21454 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21455 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21456 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21457 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21458 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21459 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21460 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21461 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21462 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21463 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21464 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21465 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21466 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21467 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21468 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21469 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21471 @end smallexample
21473 The following built-in functions are available when @option{-mlwp} is used.
21475 @smallexample
21476 void __builtin_ia32_llwpcb16 (void *);
21477 void __builtin_ia32_llwpcb32 (void *);
21478 void __builtin_ia32_llwpcb64 (void *);
21479 void * __builtin_ia32_llwpcb16 (void);
21480 void * __builtin_ia32_llwpcb32 (void);
21481 void * __builtin_ia32_llwpcb64 (void);
21482 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21483 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21484 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21485 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21486 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21487 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21488 @end smallexample
21490 The following built-in functions are available when @option{-mbmi} is used.
21491 All of them generate the machine instruction that is part of the name.
21492 @smallexample
21493 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21494 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21495 @end smallexample
21497 The following built-in functions are available when @option{-mbmi2} is used.
21498 All of them generate the machine instruction that is part of the name.
21499 @smallexample
21500 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21501 unsigned int _pdep_u32 (unsigned int, unsigned int)
21502 unsigned int _pext_u32 (unsigned int, unsigned int)
21503 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21504 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21505 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21506 @end smallexample
21508 The following built-in functions are available when @option{-mlzcnt} is used.
21509 All of them generate the machine instruction that is part of the name.
21510 @smallexample
21511 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21512 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21513 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21514 @end smallexample
21516 The following built-in functions are available when @option{-mfxsr} is used.
21517 All of them generate the machine instruction that is part of the name.
21518 @smallexample
21519 void __builtin_ia32_fxsave (void *)
21520 void __builtin_ia32_fxrstor (void *)
21521 void __builtin_ia32_fxsave64 (void *)
21522 void __builtin_ia32_fxrstor64 (void *)
21523 @end smallexample
21525 The following built-in functions are available when @option{-mxsave} is used.
21526 All of them generate the machine instruction that is part of the name.
21527 @smallexample
21528 void __builtin_ia32_xsave (void *, long long)
21529 void __builtin_ia32_xrstor (void *, long long)
21530 void __builtin_ia32_xsave64 (void *, long long)
21531 void __builtin_ia32_xrstor64 (void *, long long)
21532 @end smallexample
21534 The following built-in functions are available when @option{-mxsaveopt} is used.
21535 All of them generate the machine instruction that is part of the name.
21536 @smallexample
21537 void __builtin_ia32_xsaveopt (void *, long long)
21538 void __builtin_ia32_xsaveopt64 (void *, long long)
21539 @end smallexample
21541 The following built-in functions are available when @option{-mtbm} is used.
21542 Both of them generate the immediate form of the bextr machine instruction.
21543 @smallexample
21544 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21545                                         const unsigned int);
21546 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21547                                               const unsigned long long);
21548 @end smallexample
21551 The following built-in functions are available when @option{-m3dnow} is used.
21552 All of them generate the machine instruction that is part of the name.
21554 @smallexample
21555 void __builtin_ia32_femms (void)
21556 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21557 v2si __builtin_ia32_pf2id (v2sf)
21558 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21559 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21560 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21561 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21562 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21563 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21564 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21565 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21566 v2sf __builtin_ia32_pfrcp (v2sf)
21567 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21568 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21569 v2sf __builtin_ia32_pfrsqrt (v2sf)
21570 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21571 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21572 v2sf __builtin_ia32_pi2fd (v2si)
21573 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21574 @end smallexample
21576 The following built-in functions are available when @option{-m3dnowa} is used.
21577 All of them generate the machine instruction that is part of the name.
21579 @smallexample
21580 v2si __builtin_ia32_pf2iw (v2sf)
21581 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21582 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21583 v2sf __builtin_ia32_pi2fw (v2si)
21584 v2sf __builtin_ia32_pswapdsf (v2sf)
21585 v2si __builtin_ia32_pswapdsi (v2si)
21586 @end smallexample
21588 The following built-in functions are available when @option{-mrtm} is used
21589 They are used for restricted transactional memory. These are the internal
21590 low level functions. Normally the functions in 
21591 @ref{x86 transactional memory intrinsics} should be used instead.
21593 @smallexample
21594 int __builtin_ia32_xbegin ()
21595 void __builtin_ia32_xend ()
21596 void __builtin_ia32_xabort (status)
21597 int __builtin_ia32_xtest ()
21598 @end smallexample
21600 The following built-in functions are available when @option{-mmwaitx} is used.
21601 All of them generate the machine instruction that is part of the name.
21602 @smallexample
21603 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21604 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21605 @end smallexample
21607 The following built-in functions are available when @option{-mclzero} is used.
21608 All of them generate the machine instruction that is part of the name.
21609 @smallexample
21610 void __builtin_i32_clzero (void *)
21611 @end smallexample
21613 The following built-in functions are available when @option{-mpku} is used.
21614 They generate reads and writes to PKRU.
21615 @smallexample
21616 void __builtin_ia32_wrpkru (unsigned int)
21617 unsigned int __builtin_ia32_rdpkru ()
21618 @end smallexample
21620 The following built-in functions are available when @option{-mcet} or
21621 @option{-mshstk} option is used.  They support shadow stack
21622 machine instructions from Intel Control-flow Enforcement Technology (CET).
21623 Each built-in function generates the  machine instruction that is part
21624 of the function's name.  These are the internal low-level functions.
21625 Normally the functions in @ref{x86 control-flow protection intrinsics}
21626 should be used instead.
21628 @smallexample
21629 unsigned int __builtin_ia32_rdsspd (void)
21630 unsigned long long __builtin_ia32_rdsspq (void)
21631 void __builtin_ia32_incsspd (unsigned int)
21632 void __builtin_ia32_incsspq (unsigned long long)
21633 void __builtin_ia32_saveprevssp(void);
21634 void __builtin_ia32_rstorssp(void *);
21635 void __builtin_ia32_wrssd(unsigned int, void *);
21636 void __builtin_ia32_wrssq(unsigned long long, void *);
21637 void __builtin_ia32_wrussd(unsigned int, void *);
21638 void __builtin_ia32_wrussq(unsigned long long, void *);
21639 void __builtin_ia32_setssbsy(void);
21640 void __builtin_ia32_clrssbsy(void *);
21641 @end smallexample
21643 @node x86 transactional memory intrinsics
21644 @subsection x86 Transactional Memory Intrinsics
21646 These hardware transactional memory intrinsics for x86 allow you to use
21647 memory transactions with RTM (Restricted Transactional Memory).
21648 This support is enabled with the @option{-mrtm} option.
21649 For using HLE (Hardware Lock Elision) see 
21650 @ref{x86 specific memory model extensions for transactional memory} instead.
21652 A memory transaction commits all changes to memory in an atomic way,
21653 as visible to other threads. If the transaction fails it is rolled back
21654 and all side effects discarded.
21656 Generally there is no guarantee that a memory transaction ever succeeds
21657 and suitable fallback code always needs to be supplied.
21659 @deftypefn {RTM Function} {unsigned} _xbegin ()
21660 Start a RTM (Restricted Transactional Memory) transaction. 
21661 Returns @code{_XBEGIN_STARTED} when the transaction
21662 started successfully (note this is not 0, so the constant has to be 
21663 explicitly tested).  
21665 If the transaction aborts, all side effects
21666 are undone and an abort code encoded as a bit mask is returned.
21667 The following macros are defined:
21669 @table @code
21670 @item _XABORT_EXPLICIT
21671 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
21672 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21673 @item _XABORT_RETRY
21674 Transaction retry is possible.
21675 @item _XABORT_CONFLICT
21676 Transaction abort due to a memory conflict with another thread.
21677 @item _XABORT_CAPACITY
21678 Transaction abort due to the transaction using too much memory.
21679 @item _XABORT_DEBUG
21680 Transaction abort due to a debug trap.
21681 @item _XABORT_NESTED
21682 Transaction abort in an inner nested transaction.
21683 @end table
21685 There is no guarantee
21686 any transaction ever succeeds, so there always needs to be a valid
21687 fallback path.
21688 @end deftypefn
21690 @deftypefn {RTM Function} {void} _xend ()
21691 Commit the current transaction. When no transaction is active this faults.
21692 All memory side effects of the transaction become visible
21693 to other threads in an atomic manner.
21694 @end deftypefn
21696 @deftypefn {RTM Function} {int} _xtest ()
21697 Return a nonzero value if a transaction is currently active, otherwise 0.
21698 @end deftypefn
21700 @deftypefn {RTM Function} {void} _xabort (status)
21701 Abort the current transaction. When no transaction is active this is a no-op.
21702 The @var{status} is an 8-bit constant; its value is encoded in the return 
21703 value from @code{_xbegin}.
21704 @end deftypefn
21706 Here is an example showing handling for @code{_XABORT_RETRY}
21707 and a fallback path for other failures:
21709 @smallexample
21710 #include <immintrin.h>
21712 int n_tries, max_tries;
21713 unsigned status = _XABORT_EXPLICIT;
21716 for (n_tries = 0; n_tries < max_tries; n_tries++) 
21717   @{
21718     status = _xbegin ();
21719     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21720       break;
21721   @}
21722 if (status == _XBEGIN_STARTED) 
21723   @{
21724     ... transaction code...
21725     _xend ();
21726   @} 
21727 else 
21728   @{
21729     ... non-transactional fallback path...
21730   @}
21731 @end smallexample
21733 @noindent
21734 Note that, in most cases, the transactional and non-transactional code
21735 must synchronize together to ensure consistency.
21737 @node x86 control-flow protection intrinsics
21738 @subsection x86 Control-Flow Protection Intrinsics
21740 @deftypefn {CET Function} {ret_type} _get_ssp (void)
21741 Get the current value of shadow stack pointer if shadow stack support
21742 from Intel CET is enabled in the hardware or @code{0} otherwise.
21743 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
21744 and @code{unsigned int} for 32-bit targets.
21745 @end deftypefn
21747 @deftypefn {CET Function} void _inc_ssp (unsigned int)
21748 Increment the current shadow stack pointer by the size specified by the
21749 function argument.  The argument is masked to a byte value for security
21750 reasons, so to increment by more than 255 bytes you must call the function
21751 multiple times.
21752 @end deftypefn
21754 The shadow stack unwind code looks like:
21756 @smallexample
21757 #include <immintrin.h>
21759 /* Unwind the shadow stack for EH.  */
21760 #define _Unwind_Frames_Extra(x)       \
21761   do                                  \
21762     @{                                \
21763       _Unwind_Word ssp = _get_ssp (); \
21764       if (ssp != 0)                   \
21765         @{                            \
21766           _Unwind_Word tmp = (x);     \
21767           while (tmp > 255)           \
21768             @{                        \
21769               _inc_ssp (tmp);         \
21770               tmp -= 255;             \
21771             @}                        \
21772           _inc_ssp (tmp);             \
21773         @}                            \
21774     @}                                \
21775     while (0)
21776 @end smallexample
21778 @noindent
21779 This code runs unconditionally on all 64-bit processors.  For 32-bit
21780 processors the code runs on those that support multi-byte NOP instructions.
21782 @node Target Format Checks
21783 @section Format Checks Specific to Particular Target Machines
21785 For some target machines, GCC supports additional options to the
21786 format attribute
21787 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
21789 @menu
21790 * Solaris Format Checks::
21791 * Darwin Format Checks::
21792 @end menu
21794 @node Solaris Format Checks
21795 @subsection Solaris Format Checks
21797 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
21798 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
21799 conversions, and the two-argument @code{%b} conversion for displaying
21800 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
21802 @node Darwin Format Checks
21803 @subsection Darwin Format Checks
21805 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
21806 attribute context.  Declarations made with such attribution are parsed for correct syntax
21807 and format argument types.  However, parsing of the format string itself is currently undefined
21808 and is not carried out by this version of the compiler.
21810 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
21811 also be used as format arguments.  Note that the relevant headers are only likely to be
21812 available on Darwin (OSX) installations.  On such installations, the XCode and system
21813 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
21814 associated functions.
21816 @node Pragmas
21817 @section Pragmas Accepted by GCC
21818 @cindex pragmas
21819 @cindex @code{#pragma}
21821 GCC supports several types of pragmas, primarily in order to compile
21822 code originally written for other compilers.  Note that in general
21823 we do not recommend the use of pragmas; @xref{Function Attributes},
21824 for further explanation.
21826 @menu
21827 * AArch64 Pragmas::
21828 * ARM Pragmas::
21829 * M32C Pragmas::
21830 * MeP Pragmas::
21831 * RS/6000 and PowerPC Pragmas::
21832 * S/390 Pragmas::
21833 * Darwin Pragmas::
21834 * Solaris Pragmas::
21835 * Symbol-Renaming Pragmas::
21836 * Structure-Layout Pragmas::
21837 * Weak Pragmas::
21838 * Diagnostic Pragmas::
21839 * Visibility Pragmas::
21840 * Push/Pop Macro Pragmas::
21841 * Function Specific Option Pragmas::
21842 * Loop-Specific Pragmas::
21843 @end menu
21845 @node AArch64 Pragmas
21846 @subsection AArch64 Pragmas
21848 The pragmas defined by the AArch64 target correspond to the AArch64
21849 target function attributes.  They can be specified as below:
21850 @smallexample
21851 #pragma GCC target("string")
21852 @end smallexample
21854 where @code{@var{string}} can be any string accepted as an AArch64 target
21855 attribute.  @xref{AArch64 Function Attributes}, for more details
21856 on the permissible values of @code{string}.
21858 @node ARM Pragmas
21859 @subsection ARM Pragmas
21861 The ARM target defines pragmas for controlling the default addition of
21862 @code{long_call} and @code{short_call} attributes to functions.
21863 @xref{Function Attributes}, for information about the effects of these
21864 attributes.
21866 @table @code
21867 @item long_calls
21868 @cindex pragma, long_calls
21869 Set all subsequent functions to have the @code{long_call} attribute.
21871 @item no_long_calls
21872 @cindex pragma, no_long_calls
21873 Set all subsequent functions to have the @code{short_call} attribute.
21875 @item long_calls_off
21876 @cindex pragma, long_calls_off
21877 Do not affect the @code{long_call} or @code{short_call} attributes of
21878 subsequent functions.
21879 @end table
21881 @node M32C Pragmas
21882 @subsection M32C Pragmas
21884 @table @code
21885 @item GCC memregs @var{number}
21886 @cindex pragma, memregs
21887 Overrides the command-line option @code{-memregs=} for the current
21888 file.  Use with care!  This pragma must be before any function in the
21889 file, and mixing different memregs values in different objects may
21890 make them incompatible.  This pragma is useful when a
21891 performance-critical function uses a memreg for temporary values,
21892 as it may allow you to reduce the number of memregs used.
21894 @item ADDRESS @var{name} @var{address}
21895 @cindex pragma, address
21896 For any declared symbols matching @var{name}, this does three things
21897 to that symbol: it forces the symbol to be located at the given
21898 address (a number), it forces the symbol to be volatile, and it
21899 changes the symbol's scope to be static.  This pragma exists for
21900 compatibility with other compilers, but note that the common
21901 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21902 instead).  Example:
21904 @smallexample
21905 #pragma ADDRESS port3 0x103
21906 char port3;
21907 @end smallexample
21909 @end table
21911 @node MeP Pragmas
21912 @subsection MeP Pragmas
21914 @table @code
21916 @item custom io_volatile (on|off)
21917 @cindex pragma, custom io_volatile
21918 Overrides the command-line option @code{-mio-volatile} for the current
21919 file.  Note that for compatibility with future GCC releases, this
21920 option should only be used once before any @code{io} variables in each
21921 file.
21923 @item GCC coprocessor available @var{registers}
21924 @cindex pragma, coprocessor available
21925 Specifies which coprocessor registers are available to the register
21926 allocator.  @var{registers} may be a single register, register range
21927 separated by ellipses, or comma-separated list of those.  Example:
21929 @smallexample
21930 #pragma GCC coprocessor available $c0...$c10, $c28
21931 @end smallexample
21933 @item GCC coprocessor call_saved @var{registers}
21934 @cindex pragma, coprocessor call_saved
21935 Specifies which coprocessor registers are to be saved and restored by
21936 any function using them.  @var{registers} may be a single register,
21937 register range separated by ellipses, or comma-separated list of
21938 those.  Example:
21940 @smallexample
21941 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21942 @end smallexample
21944 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21945 @cindex pragma, coprocessor subclass
21946 Creates and defines a register class.  These register classes can be
21947 used by inline @code{asm} constructs.  @var{registers} may be a single
21948 register, register range separated by ellipses, or comma-separated
21949 list of those.  Example:
21951 @smallexample
21952 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21954 asm ("cpfoo %0" : "=B" (x));
21955 @end smallexample
21957 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21958 @cindex pragma, disinterrupt
21959 For the named functions, the compiler adds code to disable interrupts
21960 for the duration of those functions.  If any functions so named 
21961 are not encountered in the source, a warning is emitted that the pragma is
21962 not used.  Examples:
21964 @smallexample
21965 #pragma disinterrupt foo
21966 #pragma disinterrupt bar, grill
21967 int foo () @{ @dots{} @}
21968 @end smallexample
21970 @item GCC call @var{name} , @var{name} @dots{}
21971 @cindex pragma, call
21972 For the named functions, the compiler always uses a register-indirect
21973 call model when calling the named functions.  Examples:
21975 @smallexample
21976 extern int foo ();
21977 #pragma call foo
21978 @end smallexample
21980 @end table
21982 @node RS/6000 and PowerPC Pragmas
21983 @subsection RS/6000 and PowerPC Pragmas
21985 The RS/6000 and PowerPC targets define one pragma for controlling
21986 whether or not the @code{longcall} attribute is added to function
21987 declarations by default.  This pragma overrides the @option{-mlongcall}
21988 option, but not the @code{longcall} and @code{shortcall} attributes.
21989 @xref{RS/6000 and PowerPC Options}, for more information about when long
21990 calls are and are not necessary.
21992 @table @code
21993 @item longcall (1)
21994 @cindex pragma, longcall
21995 Apply the @code{longcall} attribute to all subsequent function
21996 declarations.
21998 @item longcall (0)
21999 Do not apply the @code{longcall} attribute to subsequent function
22000 declarations.
22001 @end table
22003 @c Describe h8300 pragmas here.
22004 @c Describe sh pragmas here.
22005 @c Describe v850 pragmas here.
22007 @node S/390 Pragmas
22008 @subsection S/390 Pragmas
22010 The pragmas defined by the S/390 target correspond to the S/390
22011 target function attributes and some the additional options:
22013 @table @samp
22014 @item zvector
22015 @itemx no-zvector
22016 @end table
22018 Note that options of the pragma, unlike options of the target
22019 attribute, do change the value of preprocessor macros like
22020 @code{__VEC__}.  They can be specified as below:
22022 @smallexample
22023 #pragma GCC target("string[,string]...")
22024 #pragma GCC target("string"[,"string"]...)
22025 @end smallexample
22027 @node Darwin Pragmas
22028 @subsection Darwin Pragmas
22030 The following pragmas are available for all architectures running the
22031 Darwin operating system.  These are useful for compatibility with other
22032 Mac OS compilers.
22034 @table @code
22035 @item mark @var{tokens}@dots{}
22036 @cindex pragma, mark
22037 This pragma is accepted, but has no effect.
22039 @item options align=@var{alignment}
22040 @cindex pragma, options align
22041 This pragma sets the alignment of fields in structures.  The values of
22042 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22043 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
22044 properly; to restore the previous setting, use @code{reset} for the
22045 @var{alignment}.
22047 @item segment @var{tokens}@dots{}
22048 @cindex pragma, segment
22049 This pragma is accepted, but has no effect.
22051 @item unused (@var{var} [, @var{var}]@dots{})
22052 @cindex pragma, unused
22053 This pragma declares variables to be possibly unused.  GCC does not
22054 produce warnings for the listed variables.  The effect is similar to
22055 that of the @code{unused} attribute, except that this pragma may appear
22056 anywhere within the variables' scopes.
22057 @end table
22059 @node Solaris Pragmas
22060 @subsection Solaris Pragmas
22062 The Solaris target supports @code{#pragma redefine_extname}
22063 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
22064 @code{#pragma} directives for compatibility with the system compiler.
22066 @table @code
22067 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22068 @cindex pragma, align
22070 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22071 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22072 Attributes}).  Macro expansion occurs on the arguments to this pragma
22073 when compiling C and Objective-C@.  It does not currently occur when
22074 compiling C++, but this is a bug which may be fixed in a future
22075 release.
22077 @item fini (@var{function} [, @var{function}]...)
22078 @cindex pragma, fini
22080 This pragma causes each listed @var{function} to be called after
22081 main, or during shared module unloading, by adding a call to the
22082 @code{.fini} section.
22084 @item init (@var{function} [, @var{function}]...)
22085 @cindex pragma, init
22087 This pragma causes each listed @var{function} to be called during
22088 initialization (before @code{main}) or during shared module loading, by
22089 adding a call to the @code{.init} section.
22091 @end table
22093 @node Symbol-Renaming Pragmas
22094 @subsection Symbol-Renaming Pragmas
22096 GCC supports a @code{#pragma} directive that changes the name used in
22097 assembly for a given declaration. While this pragma is supported on all
22098 platforms, it is intended primarily to provide compatibility with the
22099 Solaris system headers. This effect can also be achieved using the asm
22100 labels extension (@pxref{Asm Labels}).
22102 @table @code
22103 @item redefine_extname @var{oldname} @var{newname}
22104 @cindex pragma, redefine_extname
22106 This pragma gives the C function @var{oldname} the assembly symbol
22107 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22108 is defined if this pragma is available (currently on all platforms).
22109 @end table
22111 This pragma and the asm labels extension interact in a complicated
22112 manner.  Here are some corner cases you may want to be aware of:
22114 @enumerate
22115 @item This pragma silently applies only to declarations with external
22116 linkage.  Asm labels do not have this restriction.
22118 @item In C++, this pragma silently applies only to declarations with
22119 ``C'' linkage.  Again, asm labels do not have this restriction.
22121 @item If either of the ways of changing the assembly name of a
22122 declaration are applied to a declaration whose assembly name has
22123 already been determined (either by a previous use of one of these
22124 features, or because the compiler needed the assembly name in order to
22125 generate code), and the new name is different, a warning issues and
22126 the name does not change.
22128 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22129 always the C-language name.
22130 @end enumerate
22132 @node Structure-Layout Pragmas
22133 @subsection Structure-Layout Pragmas
22135 For compatibility with Microsoft Windows compilers, GCC supports a
22136 set of @code{#pragma} directives that change the maximum alignment of
22137 members of structures (other than zero-width bit-fields), unions, and
22138 classes subsequently defined. The @var{n} value below always is required
22139 to be a small power of two and specifies the new alignment in bytes.
22141 @enumerate
22142 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22143 @item @code{#pragma pack()} sets the alignment to the one that was in
22144 effect when compilation started (see also command-line option
22145 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22146 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22147 setting on an internal stack and then optionally sets the new alignment.
22148 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22149 saved at the top of the internal stack (and removes that stack entry).
22150 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22151 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22152 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22153 @code{#pragma pack(pop)}.
22154 @end enumerate
22156 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22157 directive which lays out structures and unions subsequently defined as the
22158 documented @code{__attribute__ ((ms_struct))}.
22160 @enumerate
22161 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22162 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22163 @item @code{#pragma ms_struct reset} goes back to the default layout.
22164 @end enumerate
22166 Most targets also support the @code{#pragma scalar_storage_order} directive
22167 which lays out structures and unions subsequently defined as the documented
22168 @code{__attribute__ ((scalar_storage_order))}.
22170 @enumerate
22171 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22172 of the scalar fields to big-endian.
22173 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22174 of the scalar fields to little-endian.
22175 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22176 that was in effect when compilation started (see also command-line option
22177 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22178 @end enumerate
22180 @node Weak Pragmas
22181 @subsection Weak Pragmas
22183 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22184 directives for declaring symbols to be weak, and defining weak
22185 aliases.
22187 @table @code
22188 @item #pragma weak @var{symbol}
22189 @cindex pragma, weak
22190 This pragma declares @var{symbol} to be weak, as if the declaration
22191 had the attribute of the same name.  The pragma may appear before
22192 or after the declaration of @var{symbol}.  It is not an error for
22193 @var{symbol} to never be defined at all.
22195 @item #pragma weak @var{symbol1} = @var{symbol2}
22196 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22197 It is an error if @var{symbol2} is not defined in the current
22198 translation unit.
22199 @end table
22201 @node Diagnostic Pragmas
22202 @subsection Diagnostic Pragmas
22204 GCC allows the user to selectively enable or disable certain types of
22205 diagnostics, and change the kind of the diagnostic.  For example, a
22206 project's policy might require that all sources compile with
22207 @option{-Werror} but certain files might have exceptions allowing
22208 specific types of warnings.  Or, a project might selectively enable
22209 diagnostics and treat them as errors depending on which preprocessor
22210 macros are defined.
22212 @table @code
22213 @item #pragma GCC diagnostic @var{kind} @var{option}
22214 @cindex pragma, diagnostic
22216 Modifies the disposition of a diagnostic.  Note that not all
22217 diagnostics are modifiable; at the moment only warnings (normally
22218 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22219 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22220 are controllable and which option controls them.
22222 @var{kind} is @samp{error} to treat this diagnostic as an error,
22223 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22224 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22225 @var{option} is a double quoted string that matches the command-line
22226 option.
22228 @smallexample
22229 #pragma GCC diagnostic warning "-Wformat"
22230 #pragma GCC diagnostic error "-Wformat"
22231 #pragma GCC diagnostic ignored "-Wformat"
22232 @end smallexample
22234 Note that these pragmas override any command-line options.  GCC keeps
22235 track of the location of each pragma, and issues diagnostics according
22236 to the state as of that point in the source file.  Thus, pragmas occurring
22237 after a line do not affect diagnostics caused by that line.
22239 @item #pragma GCC diagnostic push
22240 @itemx #pragma GCC diagnostic pop
22242 Causes GCC to remember the state of the diagnostics as of each
22243 @code{push}, and restore to that point at each @code{pop}.  If a
22244 @code{pop} has no matching @code{push}, the command-line options are
22245 restored.
22247 @smallexample
22248 #pragma GCC diagnostic error "-Wuninitialized"
22249   foo(a);                       /* error is given for this one */
22250 #pragma GCC diagnostic push
22251 #pragma GCC diagnostic ignored "-Wuninitialized"
22252   foo(b);                       /* no diagnostic for this one */
22253 #pragma GCC diagnostic pop
22254   foo(c);                       /* error is given for this one */
22255 #pragma GCC diagnostic pop
22256   foo(d);                       /* depends on command-line options */
22257 @end smallexample
22259 @end table
22261 GCC also offers a simple mechanism for printing messages during
22262 compilation.
22264 @table @code
22265 @item #pragma message @var{string}
22266 @cindex pragma, diagnostic
22268 Prints @var{string} as a compiler message on compilation.  The message
22269 is informational only, and is neither a compilation warning nor an
22270 error.  Newlines can be included in the string by using the @samp{\n}
22271 escape sequence.
22273 @smallexample
22274 #pragma message "Compiling " __FILE__ "..."
22275 @end smallexample
22277 @var{string} may be parenthesized, and is printed with location
22278 information.  For example,
22280 @smallexample
22281 #define DO_PRAGMA(x) _Pragma (#x)
22282 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22284 TODO(Remember to fix this)
22285 @end smallexample
22287 @noindent
22288 prints @samp{/tmp/file.c:4: note: #pragma message:
22289 TODO - Remember to fix this}.
22291 @item #pragma GCC error @var{message}
22292 @cindex pragma, diagnostic
22293 Generates an error message.  This pragma @emph{is} considered to
22294 indicate an error in the compilation, and it will be treated as such.
22296 Newlines can be included in the string by using the @samp{\n}
22297 escape sequence.  They will be displayed as newlines even if the
22298 @option{-fmessage-length} option is set to zero.
22300 The error is only generated if the pragma is present in the code after
22301 pre-processing has been completed.  It does not matter however if the
22302 code containing the pragma is unreachable:
22304 @smallexample
22305 #if 0
22306 #pragma GCC error "this error is not seen"
22307 #endif
22308 void foo (void)
22310   return;
22311 #pragma GCC error "this error is seen"
22313 @end smallexample
22315 @item #pragma GCC warning @var{message}
22316 @cindex pragma, diagnostic
22317 This is just like @samp{pragma GCC error} except that a warning
22318 message is issued instead of an error message.  Unless
22319 @option{-Werror} is in effect, in which case this pragma will generate
22320 an error as well.
22322 @end table
22324 @node Visibility Pragmas
22325 @subsection Visibility Pragmas
22327 @table @code
22328 @item #pragma GCC visibility push(@var{visibility})
22329 @itemx #pragma GCC visibility pop
22330 @cindex pragma, visibility
22332 This pragma allows the user to set the visibility for multiple
22333 declarations without having to give each a visibility attribute
22334 (@pxref{Function Attributes}).
22336 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22337 declarations.  Class members and template specializations are not
22338 affected; if you want to override the visibility for a particular
22339 member or instantiation, you must use an attribute.
22341 @end table
22344 @node Push/Pop Macro Pragmas
22345 @subsection Push/Pop Macro Pragmas
22347 For compatibility with Microsoft Windows compilers, GCC supports
22348 @samp{#pragma push_macro(@var{"macro_name"})}
22349 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22351 @table @code
22352 @item #pragma push_macro(@var{"macro_name"})
22353 @cindex pragma, push_macro
22354 This pragma saves the value of the macro named as @var{macro_name} to
22355 the top of the stack for this macro.
22357 @item #pragma pop_macro(@var{"macro_name"})
22358 @cindex pragma, pop_macro
22359 This pragma sets the value of the macro named as @var{macro_name} to
22360 the value on top of the stack for this macro. If the stack for
22361 @var{macro_name} is empty, the value of the macro remains unchanged.
22362 @end table
22364 For example:
22366 @smallexample
22367 #define X  1
22368 #pragma push_macro("X")
22369 #undef X
22370 #define X -1
22371 #pragma pop_macro("X")
22372 int x [X];
22373 @end smallexample
22375 @noindent
22376 In this example, the definition of X as 1 is saved by @code{#pragma
22377 push_macro} and restored by @code{#pragma pop_macro}.
22379 @node Function Specific Option Pragmas
22380 @subsection Function Specific Option Pragmas
22382 @table @code
22383 @item #pragma GCC target (@var{"string"}...)
22384 @cindex pragma GCC target
22386 This pragma allows you to set target specific options for functions
22387 defined later in the source file.  One or more strings can be
22388 specified.  Each function that is defined after this point is as
22389 if @code{attribute((target("STRING")))} was specified for that
22390 function.  The parenthesis around the options is optional.
22391 @xref{Function Attributes}, for more information about the
22392 @code{target} attribute and the attribute syntax.
22394 The @code{#pragma GCC target} pragma is presently implemented for
22395 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22397 @item #pragma GCC optimize (@var{"string"}...)
22398 @cindex pragma GCC optimize
22400 This pragma allows you to set global optimization options for functions
22401 defined later in the source file.  One or more strings can be
22402 specified.  Each function that is defined after this point is as
22403 if @code{attribute((optimize("STRING")))} was specified for that
22404 function.  The parenthesis around the options is optional.
22405 @xref{Function Attributes}, for more information about the
22406 @code{optimize} attribute and the attribute syntax.
22408 @item #pragma GCC push_options
22409 @itemx #pragma GCC pop_options
22410 @cindex pragma GCC push_options
22411 @cindex pragma GCC pop_options
22413 These pragmas maintain a stack of the current target and optimization
22414 options.  It is intended for include files where you temporarily want
22415 to switch to using a different @samp{#pragma GCC target} or
22416 @samp{#pragma GCC optimize} and then to pop back to the previous
22417 options.
22419 @item #pragma GCC reset_options
22420 @cindex pragma GCC reset_options
22422 This pragma clears the current @code{#pragma GCC target} and
22423 @code{#pragma GCC optimize} to use the default switches as specified
22424 on the command line.
22426 @end table
22428 @node Loop-Specific Pragmas
22429 @subsection Loop-Specific Pragmas
22431 @table @code
22432 @item #pragma GCC ivdep
22433 @cindex pragma GCC ivdep
22435 With this pragma, the programmer asserts that there are no loop-carried
22436 dependencies which would prevent consecutive iterations of
22437 the following loop from executing concurrently with SIMD
22438 (single instruction multiple data) instructions.
22440 For example, the compiler can only unconditionally vectorize the following
22441 loop with the pragma:
22443 @smallexample
22444 void foo (int n, int *a, int *b, int *c)
22446   int i, j;
22447 #pragma GCC ivdep
22448   for (i = 0; i < n; ++i)
22449     a[i] = b[i] + c[i];
22451 @end smallexample
22453 @noindent
22454 In this example, using the @code{restrict} qualifier had the same
22455 effect. In the following example, that would not be possible. Assume
22456 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22457 that it can unconditionally vectorize the following loop:
22459 @smallexample
22460 void ignore_vec_dep (int *a, int k, int c, int m)
22462 #pragma GCC ivdep
22463   for (int i = 0; i < m; i++)
22464     a[i] = a[i + k] * c;
22466 @end smallexample
22468 @item #pragma GCC unroll @var{n}
22469 @cindex pragma GCC unroll @var{n}
22471 You can use this pragma to control how many times a loop should be unrolled.
22472 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22473 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22474 @var{n} is an integer constant expression specifying the unrolling factor.
22475 The values of @math{0} and @math{1} block any unrolling of the loop.
22477 @end table
22479 @node Unnamed Fields
22480 @section Unnamed Structure and Union Fields
22481 @cindex @code{struct}
22482 @cindex @code{union}
22484 As permitted by ISO C11 and for compatibility with other compilers,
22485 GCC allows you to define
22486 a structure or union that contains, as fields, structures and unions
22487 without names.  For example:
22489 @smallexample
22490 struct @{
22491   int a;
22492   union @{
22493     int b;
22494     float c;
22495   @};
22496   int d;
22497 @} foo;
22498 @end smallexample
22500 @noindent
22501 In this example, you are able to access members of the unnamed
22502 union with code like @samp{foo.b}.  Note that only unnamed structs and
22503 unions are allowed, you may not have, for example, an unnamed
22504 @code{int}.
22506 You must never create such structures that cause ambiguous field definitions.
22507 For example, in this structure:
22509 @smallexample
22510 struct @{
22511   int a;
22512   struct @{
22513     int a;
22514   @};
22515 @} foo;
22516 @end smallexample
22518 @noindent
22519 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22520 The compiler gives errors for such constructs.
22522 @opindex fms-extensions
22523 Unless @option{-fms-extensions} is used, the unnamed field must be a
22524 structure or union definition without a tag (for example, @samp{struct
22525 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22526 also be a definition with a tag such as @samp{struct foo @{ int a;
22527 @};}, a reference to a previously defined structure or union such as
22528 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22529 previously defined structure or union type.
22531 @opindex fplan9-extensions
22532 The option @option{-fplan9-extensions} enables
22533 @option{-fms-extensions} as well as two other extensions.  First, a
22534 pointer to a structure is automatically converted to a pointer to an
22535 anonymous field for assignments and function calls.  For example:
22537 @smallexample
22538 struct s1 @{ int a; @};
22539 struct s2 @{ struct s1; @};
22540 extern void f1 (struct s1 *);
22541 void f2 (struct s2 *p) @{ f1 (p); @}
22542 @end smallexample
22544 @noindent
22545 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22546 converted into a pointer to the anonymous field.
22548 Second, when the type of an anonymous field is a @code{typedef} for a
22549 @code{struct} or @code{union}, code may refer to the field using the
22550 name of the @code{typedef}.
22552 @smallexample
22553 typedef struct @{ int a; @} s1;
22554 struct s2 @{ s1; @};
22555 s1 f1 (struct s2 *p) @{ return p->s1; @}
22556 @end smallexample
22558 These usages are only permitted when they are not ambiguous.
22560 @node Thread-Local
22561 @section Thread-Local Storage
22562 @cindex Thread-Local Storage
22563 @cindex @acronym{TLS}
22564 @cindex @code{__thread}
22566 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22567 are allocated such that there is one instance of the variable per extant
22568 thread.  The runtime model GCC uses to implement this originates
22569 in the IA-64 processor-specific ABI, but has since been migrated
22570 to other processors as well.  It requires significant support from
22571 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22572 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22573 is not available everywhere.
22575 At the user level, the extension is visible with a new storage
22576 class keyword: @code{__thread}.  For example:
22578 @smallexample
22579 __thread int i;
22580 extern __thread struct state s;
22581 static __thread char *p;
22582 @end smallexample
22584 The @code{__thread} specifier may be used alone, with the @code{extern}
22585 or @code{static} specifiers, but with no other storage class specifier.
22586 When used with @code{extern} or @code{static}, @code{__thread} must appear
22587 immediately after the other storage class specifier.
22589 The @code{__thread} specifier may be applied to any global, file-scoped
22590 static, function-scoped static, or static data member of a class.  It may
22591 not be applied to block-scoped automatic or non-static data member.
22593 When the address-of operator is applied to a thread-local variable, it is
22594 evaluated at run time and returns the address of the current thread's
22595 instance of that variable.  An address so obtained may be used by any
22596 thread.  When a thread terminates, any pointers to thread-local variables
22597 in that thread become invalid.
22599 No static initialization may refer to the address of a thread-local variable.
22601 In C++, if an initializer is present for a thread-local variable, it must
22602 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22603 standard.
22605 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22606 ELF Handling For Thread-Local Storage} for a detailed explanation of
22607 the four thread-local storage addressing models, and how the runtime
22608 is expected to function.
22610 @menu
22611 * C99 Thread-Local Edits::
22612 * C++98 Thread-Local Edits::
22613 @end menu
22615 @node C99 Thread-Local Edits
22616 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22618 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22619 that document the exact semantics of the language extension.
22621 @itemize @bullet
22622 @item
22623 @cite{5.1.2  Execution environments}
22625 Add new text after paragraph 1
22627 @quotation
22628 Within either execution environment, a @dfn{thread} is a flow of
22629 control within a program.  It is implementation defined whether
22630 or not there may be more than one thread associated with a program.
22631 It is implementation defined how threads beyond the first are
22632 created, the name and type of the function called at thread
22633 startup, and how threads may be terminated.  However, objects
22634 with thread storage duration shall be initialized before thread
22635 startup.
22636 @end quotation
22638 @item
22639 @cite{6.2.4  Storage durations of objects}
22641 Add new text before paragraph 3
22643 @quotation
22644 An object whose identifier is declared with the storage-class
22645 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22646 Its lifetime is the entire execution of the thread, and its
22647 stored value is initialized only once, prior to thread startup.
22648 @end quotation
22650 @item
22651 @cite{6.4.1  Keywords}
22653 Add @code{__thread}.
22655 @item
22656 @cite{6.7.1  Storage-class specifiers}
22658 Add @code{__thread} to the list of storage class specifiers in
22659 paragraph 1.
22661 Change paragraph 2 to
22663 @quotation
22664 With the exception of @code{__thread}, at most one storage-class
22665 specifier may be given [@dots{}].  The @code{__thread} specifier may
22666 be used alone, or immediately following @code{extern} or
22667 @code{static}.
22668 @end quotation
22670 Add new text after paragraph 6
22672 @quotation
22673 The declaration of an identifier for a variable that has
22674 block scope that specifies @code{__thread} shall also
22675 specify either @code{extern} or @code{static}.
22677 The @code{__thread} specifier shall be used only with
22678 variables.
22679 @end quotation
22680 @end itemize
22682 @node C++98 Thread-Local Edits
22683 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22685 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22686 that document the exact semantics of the language extension.
22688 @itemize @bullet
22689 @item
22690 @b{[intro.execution]}
22692 New text after paragraph 4
22694 @quotation
22695 A @dfn{thread} is a flow of control within the abstract machine.
22696 It is implementation defined whether or not there may be more than
22697 one thread.
22698 @end quotation
22700 New text after paragraph 7
22702 @quotation
22703 It is unspecified whether additional action must be taken to
22704 ensure when and whether side effects are visible to other threads.
22705 @end quotation
22707 @item
22708 @b{[lex.key]}
22710 Add @code{__thread}.
22712 @item
22713 @b{[basic.start.main]}
22715 Add after paragraph 5
22717 @quotation
22718 The thread that begins execution at the @code{main} function is called
22719 the @dfn{main thread}.  It is implementation defined how functions
22720 beginning threads other than the main thread are designated or typed.
22721 A function so designated, as well as the @code{main} function, is called
22722 a @dfn{thread startup function}.  It is implementation defined what
22723 happens if a thread startup function returns.  It is implementation
22724 defined what happens to other threads when any thread calls @code{exit}.
22725 @end quotation
22727 @item
22728 @b{[basic.start.init]}
22730 Add after paragraph 4
22732 @quotation
22733 The storage for an object of thread storage duration shall be
22734 statically initialized before the first statement of the thread startup
22735 function.  An object of thread storage duration shall not require
22736 dynamic initialization.
22737 @end quotation
22739 @item
22740 @b{[basic.start.term]}
22742 Add after paragraph 3
22744 @quotation
22745 The type of an object with thread storage duration shall not have a
22746 non-trivial destructor, nor shall it be an array type whose elements
22747 (directly or indirectly) have non-trivial destructors.
22748 @end quotation
22750 @item
22751 @b{[basic.stc]}
22753 Add ``thread storage duration'' to the list in paragraph 1.
22755 Change paragraph 2
22757 @quotation
22758 Thread, static, and automatic storage durations are associated with
22759 objects introduced by declarations [@dots{}].
22760 @end quotation
22762 Add @code{__thread} to the list of specifiers in paragraph 3.
22764 @item
22765 @b{[basic.stc.thread]}
22767 New section before @b{[basic.stc.static]}
22769 @quotation
22770 The keyword @code{__thread} applied to a non-local object gives the
22771 object thread storage duration.
22773 A local variable or class data member declared both @code{static}
22774 and @code{__thread} gives the variable or member thread storage
22775 duration.
22776 @end quotation
22778 @item
22779 @b{[basic.stc.static]}
22781 Change paragraph 1
22783 @quotation
22784 All objects that have neither thread storage duration, dynamic
22785 storage duration nor are local [@dots{}].
22786 @end quotation
22788 @item
22789 @b{[dcl.stc]}
22791 Add @code{__thread} to the list in paragraph 1.
22793 Change paragraph 1
22795 @quotation
22796 With the exception of @code{__thread}, at most one
22797 @var{storage-class-specifier} shall appear in a given
22798 @var{decl-specifier-seq}.  The @code{__thread} specifier may
22799 be used alone, or immediately following the @code{extern} or
22800 @code{static} specifiers.  [@dots{}]
22801 @end quotation
22803 Add after paragraph 5
22805 @quotation
22806 The @code{__thread} specifier can be applied only to the names of objects
22807 and to anonymous unions.
22808 @end quotation
22810 @item
22811 @b{[class.mem]}
22813 Add after paragraph 6
22815 @quotation
22816 Non-@code{static} members shall not be @code{__thread}.
22817 @end quotation
22818 @end itemize
22820 @node Binary constants
22821 @section Binary Constants using the @samp{0b} Prefix
22822 @cindex Binary constants using the @samp{0b} prefix
22824 Integer constants can be written as binary constants, consisting of a
22825 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
22826 @samp{0B}.  This is particularly useful in environments that operate a
22827 lot on the bit level (like microcontrollers).
22829 The following statements are identical:
22831 @smallexample
22832 i =       42;
22833 i =     0x2a;
22834 i =      052;
22835 i = 0b101010;
22836 @end smallexample
22838 The type of these constants follows the same rules as for octal or
22839 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
22840 can be applied.
22842 @node C++ Extensions
22843 @chapter Extensions to the C++ Language
22844 @cindex extensions, C++ language
22845 @cindex C++ language extensions
22847 The GNU compiler provides these extensions to the C++ language (and you
22848 can also use most of the C language extensions in your C++ programs).  If you
22849 want to write code that checks whether these features are available, you can
22850 test for the GNU compiler the same way as for C programs: check for a
22851 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
22852 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
22853 Predefined Macros,cpp,The GNU C Preprocessor}).
22855 @menu
22856 * C++ Volatiles::       What constitutes an access to a volatile object.
22857 * Restricted Pointers:: C99 restricted pointers and references.
22858 * Vague Linkage::       Where G++ puts inlines, vtables and such.
22859 * C++ Interface::       You can use a single C++ header file for both
22860                         declarations and definitions.
22861 * Template Instantiation:: Methods for ensuring that exactly one copy of
22862                         each needed template instantiation is emitted.
22863 * Bound member functions:: You can extract a function pointer to the
22864                         method denoted by a @samp{->*} or @samp{.*} expression.
22865 * C++ Attributes::      Variable, function, and type attributes for C++ only.
22866 * Function Multiversioning::   Declaring multiple function versions.
22867 * Type Traits::         Compiler support for type traits.
22868 * C++ Concepts::        Improved support for generic programming.
22869 * Deprecated Features:: Things will disappear from G++.
22870 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22871 @end menu
22873 @node C++ Volatiles
22874 @section When is a Volatile C++ Object Accessed?
22875 @cindex accessing volatiles
22876 @cindex volatile read
22877 @cindex volatile write
22878 @cindex volatile access
22880 The C++ standard differs from the C standard in its treatment of
22881 volatile objects.  It fails to specify what constitutes a volatile
22882 access, except to say that C++ should behave in a similar manner to C
22883 with respect to volatiles, where possible.  However, the different
22884 lvalueness of expressions between C and C++ complicate the behavior.
22885 G++ behaves the same as GCC for volatile access, @xref{C
22886 Extensions,,Volatiles}, for a description of GCC's behavior.
22888 The C and C++ language specifications differ when an object is
22889 accessed in a void context:
22891 @smallexample
22892 volatile int *src = @var{somevalue};
22893 *src;
22894 @end smallexample
22896 The C++ standard specifies that such expressions do not undergo lvalue
22897 to rvalue conversion, and that the type of the dereferenced object may
22898 be incomplete.  The C++ standard does not specify explicitly that it
22899 is lvalue to rvalue conversion that is responsible for causing an
22900 access.  There is reason to believe that it is, because otherwise
22901 certain simple expressions become undefined.  However, because it
22902 would surprise most programmers, G++ treats dereferencing a pointer to
22903 volatile object of complete type as GCC would do for an equivalent
22904 type in C@.  When the object has incomplete type, G++ issues a
22905 warning; if you wish to force an error, you must force a conversion to
22906 rvalue with, for instance, a static cast.
22908 When using a reference to volatile, G++ does not treat equivalent
22909 expressions as accesses to volatiles, but instead issues a warning that
22910 no volatile is accessed.  The rationale for this is that otherwise it
22911 becomes difficult to determine where volatile access occur, and not
22912 possible to ignore the return value from functions returning volatile
22913 references.  Again, if you wish to force a read, cast the reference to
22914 an rvalue.
22916 G++ implements the same behavior as GCC does when assigning to a
22917 volatile object---there is no reread of the assigned-to object, the
22918 assigned rvalue is reused.  Note that in C++ assignment expressions
22919 are lvalues, and if used as an lvalue, the volatile object is
22920 referred to.  For instance, @var{vref} refers to @var{vobj}, as
22921 expected, in the following example:
22923 @smallexample
22924 volatile int vobj;
22925 volatile int &vref = vobj = @var{something};
22926 @end smallexample
22928 @node Restricted Pointers
22929 @section Restricting Pointer Aliasing
22930 @cindex restricted pointers
22931 @cindex restricted references
22932 @cindex restricted this pointer
22934 As with the C front end, G++ understands the C99 feature of restricted pointers,
22935 specified with the @code{__restrict__}, or @code{__restrict} type
22936 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
22937 language flag, @code{restrict} is not a keyword in C++.
22939 In addition to allowing restricted pointers, you can specify restricted
22940 references, which indicate that the reference is not aliased in the local
22941 context.
22943 @smallexample
22944 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22946   /* @r{@dots{}} */
22948 @end smallexample
22950 @noindent
22951 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22952 @var{rref} refers to a (different) unaliased integer.
22954 You may also specify whether a member function's @var{this} pointer is
22955 unaliased by using @code{__restrict__} as a member function qualifier.
22957 @smallexample
22958 void T::fn () __restrict__
22960   /* @r{@dots{}} */
22962 @end smallexample
22964 @noindent
22965 Within the body of @code{T::fn}, @var{this} has the effective
22966 definition @code{T *__restrict__ const this}.  Notice that the
22967 interpretation of a @code{__restrict__} member function qualifier is
22968 different to that of @code{const} or @code{volatile} qualifier, in that it
22969 is applied to the pointer rather than the object.  This is consistent with
22970 other compilers that implement restricted pointers.
22972 As with all outermost parameter qualifiers, @code{__restrict__} is
22973 ignored in function definition matching.  This means you only need to
22974 specify @code{__restrict__} in a function definition, rather than
22975 in a function prototype as well.
22977 @node Vague Linkage
22978 @section Vague Linkage
22979 @cindex vague linkage
22981 There are several constructs in C++ that require space in the object
22982 file but are not clearly tied to a single translation unit.  We say that
22983 these constructs have ``vague linkage''.  Typically such constructs are
22984 emitted wherever they are needed, though sometimes we can be more
22985 clever.
22987 @table @asis
22988 @item Inline Functions
22989 Inline functions are typically defined in a header file which can be
22990 included in many different compilations.  Hopefully they can usually be
22991 inlined, but sometimes an out-of-line copy is necessary, if the address
22992 of the function is taken or if inlining fails.  In general, we emit an
22993 out-of-line copy in all translation units where one is needed.  As an
22994 exception, we only emit inline virtual functions with the vtable, since
22995 it always requires a copy.
22997 Local static variables and string constants used in an inline function
22998 are also considered to have vague linkage, since they must be shared
22999 between all inlined and out-of-line instances of the function.
23001 @item VTables
23002 @cindex vtable
23003 C++ virtual functions are implemented in most compilers using a lookup
23004 table, known as a vtable.  The vtable contains pointers to the virtual
23005 functions provided by a class, and each object of the class contains a
23006 pointer to its vtable (or vtables, in some multiple-inheritance
23007 situations).  If the class declares any non-inline, non-pure virtual
23008 functions, the first one is chosen as the ``key method'' for the class,
23009 and the vtable is only emitted in the translation unit where the key
23010 method is defined.
23012 @emph{Note:} If the chosen key method is later defined as inline, the
23013 vtable is still emitted in every translation unit that defines it.
23014 Make sure that any inline virtuals are declared inline in the class
23015 body, even if they are not defined there.
23017 @item @code{type_info} objects
23018 @cindex @code{type_info}
23019 @cindex RTTI
23020 C++ requires information about types to be written out in order to
23021 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23022 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23023 object is written out along with the vtable so that @samp{dynamic_cast}
23024 can determine the dynamic type of a class object at run time.  For all
23025 other types, we write out the @samp{type_info} object when it is used: when
23026 applying @samp{typeid} to an expression, throwing an object, or
23027 referring to a type in a catch clause or exception specification.
23029 @item Template Instantiations
23030 Most everything in this section also applies to template instantiations,
23031 but there are other options as well.
23032 @xref{Template Instantiation,,Where's the Template?}.
23034 @end table
23036 When used with GNU ld version 2.8 or later on an ELF system such as
23037 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23038 these constructs will be discarded at link time.  This is known as
23039 COMDAT support.
23041 On targets that don't support COMDAT, but do support weak symbols, GCC
23042 uses them.  This way one copy overrides all the others, but
23043 the unused copies still take up space in the executable.
23045 For targets that do not support either COMDAT or weak symbols,
23046 most entities with vague linkage are emitted as local symbols to
23047 avoid duplicate definition errors from the linker.  This does not happen
23048 for local statics in inlines, however, as having multiple copies
23049 almost certainly breaks things.
23051 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23052 another way to control placement of these constructs.
23054 @node C++ Interface
23055 @section C++ Interface and Implementation Pragmas
23057 @cindex interface and implementation headers, C++
23058 @cindex C++ interface and implementation headers
23059 @cindex pragmas, interface and implementation
23061 @code{#pragma interface} and @code{#pragma implementation} provide the
23062 user with a way of explicitly directing the compiler to emit entities
23063 with vague linkage (and debugging information) in a particular
23064 translation unit.
23066 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23067 by COMDAT support and the ``key method'' heuristic
23068 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
23069 program to grow due to unnecessary out-of-line copies of inline
23070 functions.
23072 @table @code
23073 @item #pragma interface
23074 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23075 @kindex #pragma interface
23076 Use this directive in @emph{header files} that define object classes, to save
23077 space in most of the object files that use those classes.  Normally,
23078 local copies of certain information (backup copies of inline member
23079 functions, debugging information, and the internal tables that implement
23080 virtual functions) must be kept in each object file that includes class
23081 definitions.  You can use this pragma to avoid such duplication.  When a
23082 header file containing @samp{#pragma interface} is included in a
23083 compilation, this auxiliary information is not generated (unless
23084 the main input source file itself uses @samp{#pragma implementation}).
23085 Instead, the object files contain references to be resolved at link
23086 time.
23088 The second form of this directive is useful for the case where you have
23089 multiple headers with the same name in different directories.  If you
23090 use this form, you must specify the same string to @samp{#pragma
23091 implementation}.
23093 @item #pragma implementation
23094 @itemx #pragma implementation "@var{objects}.h"
23095 @kindex #pragma implementation
23096 Use this pragma in a @emph{main input file}, when you want full output from
23097 included header files to be generated (and made globally visible).  The
23098 included header file, in turn, should use @samp{#pragma interface}.
23099 Backup copies of inline member functions, debugging information, and the
23100 internal tables used to implement virtual functions are all generated in
23101 implementation files.
23103 @cindex implied @code{#pragma implementation}
23104 @cindex @code{#pragma implementation}, implied
23105 @cindex naming convention, implementation headers
23106 If you use @samp{#pragma implementation} with no argument, it applies to
23107 an include file with the same basename@footnote{A file's @dfn{basename}
23108 is the name stripped of all leading path information and of trailing
23109 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23110 file.  For example, in @file{allclass.cc}, giving just
23111 @samp{#pragma implementation}
23112 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23114 Use the string argument if you want a single implementation file to
23115 include code from multiple header files.  (You must also use
23116 @samp{#include} to include the header file; @samp{#pragma
23117 implementation} only specifies how to use the file---it doesn't actually
23118 include it.)
23120 There is no way to split up the contents of a single header file into
23121 multiple implementation files.
23122 @end table
23124 @cindex inlining and C++ pragmas
23125 @cindex C++ pragmas, effect on inlining
23126 @cindex pragmas in C++, effect on inlining
23127 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23128 effect on function inlining.
23130 If you define a class in a header file marked with @samp{#pragma
23131 interface}, the effect on an inline function defined in that class is
23132 similar to an explicit @code{extern} declaration---the compiler emits
23133 no code at all to define an independent version of the function.  Its
23134 definition is used only for inlining with its callers.
23136 @opindex fno-implement-inlines
23137 Conversely, when you include the same header file in a main source file
23138 that declares it as @samp{#pragma implementation}, the compiler emits
23139 code for the function itself; this defines a version of the function
23140 that can be found via pointers (or by callers compiled without
23141 inlining).  If all calls to the function can be inlined, you can avoid
23142 emitting the function by compiling with @option{-fno-implement-inlines}.
23143 If any calls are not inlined, you will get linker errors.
23145 @node Template Instantiation
23146 @section Where's the Template?
23147 @cindex template instantiation
23149 C++ templates were the first language feature to require more
23150 intelligence from the environment than was traditionally found on a UNIX
23151 system.  Somehow the compiler and linker have to make sure that each
23152 template instance occurs exactly once in the executable if it is needed,
23153 and not at all otherwise.  There are two basic approaches to this
23154 problem, which are referred to as the Borland model and the Cfront model.
23156 @table @asis
23157 @item Borland model
23158 Borland C++ solved the template instantiation problem by adding the code
23159 equivalent of common blocks to their linker; the compiler emits template
23160 instances in each translation unit that uses them, and the linker
23161 collapses them together.  The advantage of this model is that the linker
23162 only has to consider the object files themselves; there is no external
23163 complexity to worry about.  The disadvantage is that compilation time
23164 is increased because the template code is being compiled repeatedly.
23165 Code written for this model tends to include definitions of all
23166 templates in the header file, since they must be seen to be
23167 instantiated.
23169 @item Cfront model
23170 The AT&T C++ translator, Cfront, solved the template instantiation
23171 problem by creating the notion of a template repository, an
23172 automatically maintained place where template instances are stored.  A
23173 more modern version of the repository works as follows: As individual
23174 object files are built, the compiler places any template definitions and
23175 instantiations encountered in the repository.  At link time, the link
23176 wrapper adds in the objects in the repository and compiles any needed
23177 instances that were not previously emitted.  The advantages of this
23178 model are more optimal compilation speed and the ability to use the
23179 system linker; to implement the Borland model a compiler vendor also
23180 needs to replace the linker.  The disadvantages are vastly increased
23181 complexity, and thus potential for error; for some code this can be
23182 just as transparent, but in practice it can been very difficult to build
23183 multiple programs in one directory and one program in multiple
23184 directories.  Code written for this model tends to separate definitions
23185 of non-inline member templates into a separate file, which should be
23186 compiled separately.
23187 @end table
23189 G++ implements the Borland model on targets where the linker supports it,
23190 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23191 Otherwise G++ implements neither automatic model.
23193 You have the following options for dealing with template instantiations:
23195 @enumerate
23196 @item
23197 Do nothing.  Code written for the Borland model works fine, but
23198 each translation unit contains instances of each of the templates it
23199 uses.  The duplicate instances will be discarded by the linker, but in
23200 a large program, this can lead to an unacceptable amount of code
23201 duplication in object files or shared libraries.
23203 Duplicate instances of a template can be avoided by defining an explicit
23204 instantiation in one object file, and preventing the compiler from doing
23205 implicit instantiations in any other object files by using an explicit
23206 instantiation declaration, using the @code{extern template} syntax:
23208 @smallexample
23209 extern template int max (int, int);
23210 @end smallexample
23212 This syntax is defined in the C++ 2011 standard, but has been supported by
23213 G++ and other compilers since well before 2011.
23215 Explicit instantiations can be used for the largest or most frequently
23216 duplicated instances, without having to know exactly which other instances
23217 are used in the rest of the program.  You can scatter the explicit
23218 instantiations throughout your program, perhaps putting them in the
23219 translation units where the instances are used or the translation units
23220 that define the templates themselves; you can put all of the explicit
23221 instantiations you need into one big file; or you can create small files
23222 like
23224 @smallexample
23225 #include "Foo.h"
23226 #include "Foo.cc"
23228 template class Foo<int>;
23229 template ostream& operator <<
23230                 (ostream&, const Foo<int>&);
23231 @end smallexample
23233 @noindent
23234 for each of the instances you need, and create a template instantiation
23235 library from those.
23237 This is the simplest option, but also offers flexibility and
23238 fine-grained control when necessary. It is also the most portable
23239 alternative and programs using this approach will work with most modern
23240 compilers.
23242 @item
23243 @opindex frepo
23244 Compile your template-using code with @option{-frepo}.  The compiler
23245 generates files with the extension @samp{.rpo} listing all of the
23246 template instantiations used in the corresponding object files that
23247 could be instantiated there; the link wrapper, @samp{collect2},
23248 then updates the @samp{.rpo} files to tell the compiler where to place
23249 those instantiations and rebuild any affected object files.  The
23250 link-time overhead is negligible after the first pass, as the compiler
23251 continues to place the instantiations in the same files.
23253 This can be a suitable option for application code written for the Borland
23254 model, as it usually just works.  Code written for the Cfront model 
23255 needs to be modified so that the template definitions are available at
23256 one or more points of instantiation; usually this is as simple as adding
23257 @code{#include <tmethods.cc>} to the end of each template header.
23259 For library code, if you want the library to provide all of the template
23260 instantiations it needs, just try to link all of its object files
23261 together; the link will fail, but cause the instantiations to be
23262 generated as a side effect.  Be warned, however, that this may cause
23263 conflicts if multiple libraries try to provide the same instantiations.
23264 For greater control, use explicit instantiation as described in the next
23265 option.
23267 @item
23268 @opindex fno-implicit-templates
23269 Compile your code with @option{-fno-implicit-templates} to disable the
23270 implicit generation of template instances, and explicitly instantiate
23271 all the ones you use.  This approach requires more knowledge of exactly
23272 which instances you need than do the others, but it's less
23273 mysterious and allows greater control if you want to ensure that only
23274 the intended instances are used.
23276 If you are using Cfront-model code, you can probably get away with not
23277 using @option{-fno-implicit-templates} when compiling files that don't
23278 @samp{#include} the member template definitions.
23280 If you use one big file to do the instantiations, you may want to
23281 compile it without @option{-fno-implicit-templates} so you get all of the
23282 instances required by your explicit instantiations (but not by any
23283 other files) without having to specify them as well.
23285 In addition to forward declaration of explicit instantiations
23286 (with @code{extern}), G++ has extended the template instantiation
23287 syntax to support instantiation of the compiler support data for a
23288 template class (i.e.@: the vtable) without instantiating any of its
23289 members (with @code{inline}), and instantiation of only the static data
23290 members of a template class, without the support data or member
23291 functions (with @code{static}):
23293 @smallexample
23294 inline template class Foo<int>;
23295 static template class Foo<int>;
23296 @end smallexample
23297 @end enumerate
23299 @node Bound member functions
23300 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23301 @cindex pmf
23302 @cindex pointer to member function
23303 @cindex bound pointer to member function
23305 In C++, pointer to member functions (PMFs) are implemented using a wide
23306 pointer of sorts to handle all the possible call mechanisms; the PMF
23307 needs to store information about how to adjust the @samp{this} pointer,
23308 and if the function pointed to is virtual, where to find the vtable, and
23309 where in the vtable to look for the member function.  If you are using
23310 PMFs in an inner loop, you should really reconsider that decision.  If
23311 that is not an option, you can extract the pointer to the function that
23312 would be called for a given object/PMF pair and call it directly inside
23313 the inner loop, to save a bit of time.
23315 Note that you still pay the penalty for the call through a
23316 function pointer; on most modern architectures, such a call defeats the
23317 branch prediction features of the CPU@.  This is also true of normal
23318 virtual function calls.
23320 The syntax for this extension is
23322 @smallexample
23323 extern A a;
23324 extern int (A::*fp)();
23325 typedef int (*fptr)(A *);
23327 fptr p = (fptr)(a.*fp);
23328 @end smallexample
23330 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23331 no object is needed to obtain the address of the function.  They can be
23332 converted to function pointers directly:
23334 @smallexample
23335 fptr p1 = (fptr)(&A::foo);
23336 @end smallexample
23338 @opindex Wno-pmf-conversions
23339 You must specify @option{-Wno-pmf-conversions} to use this extension.
23341 @node C++ Attributes
23342 @section C++-Specific Variable, Function, and Type Attributes
23344 Some attributes only make sense for C++ programs.
23346 @table @code
23347 @item abi_tag ("@var{tag}", ...)
23348 @cindex @code{abi_tag} function attribute
23349 @cindex @code{abi_tag} variable attribute
23350 @cindex @code{abi_tag} type attribute
23351 The @code{abi_tag} attribute can be applied to a function, variable, or class
23352 declaration.  It modifies the mangled name of the entity to
23353 incorporate the tag name, in order to distinguish the function or
23354 class from an earlier version with a different ABI; perhaps the class
23355 has changed size, or the function has a different return type that is
23356 not encoded in the mangled name.
23358 The attribute can also be applied to an inline namespace, but does not
23359 affect the mangled name of the namespace; in this case it is only used
23360 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23361 variables.  Tagging inline namespaces is generally preferable to
23362 tagging individual declarations, but the latter is sometimes
23363 necessary, such as when only certain members of a class need to be
23364 tagged.
23366 The argument can be a list of strings of arbitrary length.  The
23367 strings are sorted on output, so the order of the list is
23368 unimportant.
23370 A redeclaration of an entity must not add new ABI tags,
23371 since doing so would change the mangled name.
23373 The ABI tags apply to a name, so all instantiations and
23374 specializations of a template have the same tags.  The attribute will
23375 be ignored if applied to an explicit specialization or instantiation.
23377 The @option{-Wabi-tag} flag enables a warning about a class which does
23378 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23379 that needs to coexist with an earlier ABI, using this option can help
23380 to find all affected types that need to be tagged.
23382 When a type involving an ABI tag is used as the type of a variable or
23383 return type of a function where that tag is not already present in the
23384 signature of the function, the tag is automatically applied to the
23385 variable or function.  @option{-Wabi-tag} also warns about this
23386 situation; this warning can be avoided by explicitly tagging the
23387 variable or function or moving it into a tagged inline namespace.
23389 @item init_priority (@var{priority})
23390 @cindex @code{init_priority} variable attribute
23392 In Standard C++, objects defined at namespace scope are guaranteed to be
23393 initialized in an order in strict accordance with that of their definitions
23394 @emph{in a given translation unit}.  No guarantee is made for initializations
23395 across translation units.  However, GNU C++ allows users to control the
23396 order of initialization of objects defined at namespace scope with the
23397 @code{init_priority} attribute by specifying a relative @var{priority},
23398 a constant integral expression currently bounded between 101 and 65535
23399 inclusive.  Lower numbers indicate a higher priority.
23401 In the following example, @code{A} would normally be created before
23402 @code{B}, but the @code{init_priority} attribute reverses that order:
23404 @smallexample
23405 Some_Class  A  __attribute__ ((init_priority (2000)));
23406 Some_Class  B  __attribute__ ((init_priority (543)));
23407 @end smallexample
23409 @noindent
23410 Note that the particular values of @var{priority} do not matter; only their
23411 relative ordering.
23413 @item warn_unused
23414 @cindex @code{warn_unused} type attribute
23416 For C++ types with non-trivial constructors and/or destructors it is
23417 impossible for the compiler to determine whether a variable of this
23418 type is truly unused if it is not referenced. This type attribute
23419 informs the compiler that variables of this type should be warned
23420 about if they appear to be unused, just like variables of fundamental
23421 types.
23423 This attribute is appropriate for types which just represent a value,
23424 such as @code{std::string}; it is not appropriate for types which
23425 control a resource, such as @code{std::lock_guard}.
23427 This attribute is also accepted in C, but it is unnecessary because C
23428 does not have constructors or destructors.
23430 @end table
23432 @node Function Multiversioning
23433 @section Function Multiversioning
23434 @cindex function versions
23436 With the GNU C++ front end, for x86 targets, you may specify multiple
23437 versions of a function, where each function is specialized for a
23438 specific target feature.  At runtime, the appropriate version of the
23439 function is automatically executed depending on the characteristics of
23440 the execution platform.  Here is an example.
23442 @smallexample
23443 __attribute__ ((target ("default")))
23444 int foo ()
23446   // The default version of foo.
23447   return 0;
23450 __attribute__ ((target ("sse4.2")))
23451 int foo ()
23453   // foo version for SSE4.2
23454   return 1;
23457 __attribute__ ((target ("arch=atom")))
23458 int foo ()
23460   // foo version for the Intel ATOM processor
23461   return 2;
23464 __attribute__ ((target ("arch=amdfam10")))
23465 int foo ()
23467   // foo version for the AMD Family 0x10 processors.
23468   return 3;
23471 int main ()
23473   int (*p)() = &foo;
23474   assert ((*p) () == foo ());
23475   return 0;
23477 @end smallexample
23479 In the above example, four versions of function foo are created. The
23480 first version of foo with the target attribute "default" is the default
23481 version.  This version gets executed when no other target specific
23482 version qualifies for execution on a particular platform. A new version
23483 of foo is created by using the same function signature but with a
23484 different target string.  Function foo is called or a pointer to it is
23485 taken just like a regular function.  GCC takes care of doing the
23486 dispatching to call the right version at runtime.  Refer to the
23487 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23488 Function Multiversioning} for more details.
23490 @node Type Traits
23491 @section Type Traits
23493 The C++ front end implements syntactic extensions that allow
23494 compile-time determination of 
23495 various characteristics of a type (or of a
23496 pair of types).
23498 @table @code
23499 @item __has_nothrow_assign (type)
23500 If @code{type} is const qualified or is a reference type then the trait is
23501 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23502 is true, else if @code{type} is a cv class or union type with copy assignment
23503 operators that are known not to throw an exception then the trait is true,
23504 else it is false.  Requires: @code{type} shall be a complete type,
23505 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23507 @item __has_nothrow_copy (type)
23508 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23509 @code{type} is a cv class or union type with copy constructors that
23510 are known not to throw an exception then the trait is true, else it is false.
23511 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23512 @code{void}, or an array of unknown bound.
23514 @item __has_nothrow_constructor (type)
23515 If @code{__has_trivial_constructor (type)} is true then the trait is
23516 true, else if @code{type} is a cv class or union type (or array
23517 thereof) with a default constructor that is known not to throw an
23518 exception then the trait is true, else it is false.  Requires:
23519 @code{type} shall be a complete type, (possibly cv-qualified)
23520 @code{void}, or an array of unknown bound.
23522 @item __has_trivial_assign (type)
23523 If @code{type} is const qualified or is a reference type then the trait is
23524 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
23525 true, else if @code{type} is a cv class or union type with a trivial
23526 copy assignment ([class.copy]) then the trait is true, else it is
23527 false.  Requires: @code{type} shall be a complete type, (possibly
23528 cv-qualified) @code{void}, or an array of unknown bound.
23530 @item __has_trivial_copy (type)
23531 If @code{__is_pod (type)} is true or @code{type} is a reference type
23532 then the trait is true, else if @code{type} is a cv class or union type
23533 with a trivial copy constructor ([class.copy]) then the trait
23534 is true, else it is false.  Requires: @code{type} shall be a complete
23535 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23537 @item __has_trivial_constructor (type)
23538 If @code{__is_pod (type)} is true then the trait is true, else if
23539 @code{type} is a cv class or union type (or array thereof) with a
23540 trivial default constructor ([class.ctor]) then the trait is true,
23541 else it is false.  Requires: @code{type} shall be a complete
23542 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23544 @item __has_trivial_destructor (type)
23545 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23546 the trait is true, else if @code{type} is a cv class or union type (or
23547 array thereof) with a trivial destructor ([class.dtor]) then the trait
23548 is true, else it is false.  Requires: @code{type} shall be a complete
23549 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23551 @item __has_virtual_destructor (type)
23552 If @code{type} is a class type with a virtual destructor
23553 ([class.dtor]) then the trait is true, else it is false.  Requires:
23554 @code{type} shall be a complete type, (possibly cv-qualified)
23555 @code{void}, or an array of unknown bound.
23557 @item __is_abstract (type)
23558 If @code{type} is an abstract class ([class.abstract]) then the trait
23559 is true, else it is false.  Requires: @code{type} shall be a complete
23560 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23562 @item __is_base_of (base_type, derived_type)
23563 If @code{base_type} is a base class of @code{derived_type}
23564 ([class.derived]) then the trait is true, otherwise it is false.
23565 Top-level cv qualifications of @code{base_type} and
23566 @code{derived_type} are ignored.  For the purposes of this trait, a
23567 class type is considered is own base.  Requires: if @code{__is_class
23568 (base_type)} and @code{__is_class (derived_type)} are true and
23569 @code{base_type} and @code{derived_type} are not the same type
23570 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23571 type.  A diagnostic is produced if this requirement is not met.
23573 @item __is_class (type)
23574 If @code{type} is a cv class type, and not a union type
23575 ([basic.compound]) the trait is true, else it is false.
23577 @item __is_empty (type)
23578 If @code{__is_class (type)} is false then the trait is false.
23579 Otherwise @code{type} is considered empty if and only if: @code{type}
23580 has no non-static data members, or all non-static data members, if
23581 any, are bit-fields of length 0, and @code{type} has no virtual
23582 members, and @code{type} has no virtual base classes, and @code{type}
23583 has no base classes @code{base_type} for which
23584 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
23585 be a complete type, (possibly cv-qualified) @code{void}, or an array
23586 of unknown bound.
23588 @item __is_enum (type)
23589 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23590 true, else it is false.
23592 @item __is_literal_type (type)
23593 If @code{type} is a literal type ([basic.types]) the trait is
23594 true, else it is false.  Requires: @code{type} shall be a complete type,
23595 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23597 @item __is_pod (type)
23598 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23599 else it is false.  Requires: @code{type} shall be a complete type,
23600 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23602 @item __is_polymorphic (type)
23603 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23604 is true, else it is false.  Requires: @code{type} shall be a complete
23605 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23607 @item __is_standard_layout (type)
23608 If @code{type} is a standard-layout type ([basic.types]) the trait is
23609 true, else it is false.  Requires: @code{type} shall be a complete
23610 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23612 @item __is_trivial (type)
23613 If @code{type} is a trivial type ([basic.types]) the trait is
23614 true, else it is false.  Requires: @code{type} shall be a complete
23615 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23617 @item __is_union (type)
23618 If @code{type} is a cv union type ([basic.compound]) the trait is
23619 true, else it is false.
23621 @item __underlying_type (type)
23622 The underlying type of @code{type}.  Requires: @code{type} shall be
23623 an enumeration type ([dcl.enum]).
23625 @item __integer_pack (length)
23626 When used as the pattern of a pack expansion within a template
23627 definition, expands to a template argument pack containing integers
23628 from @code{0} to @code{length-1}.  This is provided for efficient
23629 implementation of @code{std::make_integer_sequence}.
23631 @end table
23634 @node C++ Concepts
23635 @section C++ Concepts
23637 C++ concepts provide much-improved support for generic programming. In
23638 particular, they allow the specification of constraints on template arguments.
23639 The constraints are used to extend the usual overloading and partial
23640 specialization capabilities of the language, allowing generic data structures
23641 and algorithms to be ``refined'' based on their properties rather than their
23642 type names.
23644 The following keywords are reserved for concepts.
23646 @table @code
23647 @item assumes
23648 States an expression as an assumption, and if possible, verifies that the
23649 assumption is valid. For example, @code{assume(n > 0)}.
23651 @item axiom
23652 Introduces an axiom definition. Axioms introduce requirements on values.
23654 @item forall
23655 Introduces a universally quantified object in an axiom. For example,
23656 @code{forall (int n) n + 0 == n}).
23658 @item concept
23659 Introduces a concept definition. Concepts are sets of syntactic and semantic
23660 requirements on types and their values.
23662 @item requires
23663 Introduces constraints on template arguments or requirements for a member
23664 function of a class template.
23666 @end table
23668 The front end also exposes a number of internal mechanism that can be used
23669 to simplify the writing of type traits. Note that some of these traits are
23670 likely to be removed in the future.
23672 @table @code
23673 @item __is_same (type1, type2)
23674 A binary type trait: true whenever the type arguments are the same.
23676 @end table
23679 @node Deprecated Features
23680 @section Deprecated Features
23682 In the past, the GNU C++ compiler was extended to experiment with new
23683 features, at a time when the C++ language was still evolving.  Now that
23684 the C++ standard is complete, some of those features are superseded by
23685 superior alternatives.  Using the old features might cause a warning in
23686 some cases that the feature will be dropped in the future.  In other
23687 cases, the feature might be gone already.
23689 G++ allows a virtual function returning @samp{void *} to be overridden
23690 by one returning a different pointer type.  This extension to the
23691 covariant return type rules is now deprecated and will be removed from a
23692 future version.
23694 The use of default arguments in function pointers, function typedefs
23695 and other places where they are not permitted by the standard is
23696 deprecated and will be removed from a future version of G++.
23698 G++ allows floating-point literals to appear in integral constant expressions,
23699 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23700 This extension is deprecated and will be removed from a future version.
23702 G++ allows static data members of const floating-point type to be declared
23703 with an initializer in a class definition. The standard only allows
23704 initializers for static members of const integral types and const
23705 enumeration types so this extension has been deprecated and will be removed
23706 from a future version.
23708 G++ allows attributes to follow a parenthesized direct initializer,
23709 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
23710 has been ignored since G++ 3.3 and is deprecated.
23712 G++ allows anonymous structs and unions to have members that are not
23713 public non-static data members (i.e.@: fields).  These extensions are
23714 deprecated.
23716 @node Backwards Compatibility
23717 @section Backwards Compatibility
23718 @cindex Backwards Compatibility
23719 @cindex ARM [Annotated C++ Reference Manual]
23721 Now that there is a definitive ISO standard C++, G++ has a specification
23722 to adhere to.  The C++ language evolved over time, and features that
23723 used to be acceptable in previous drafts of the standard, such as the ARM
23724 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
23725 compilation of C++ written to such drafts, G++ contains some backwards
23726 compatibilities.  @emph{All such backwards compatibility features are
23727 liable to disappear in future versions of G++.} They should be considered
23728 deprecated.   @xref{Deprecated Features}.
23730 @table @code
23732 @item Implicit C language
23733 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23734 scope to set the language.  On such systems, all system header files are
23735 implicitly scoped inside a C language scope.  Such headers must
23736 correctly prototype function argument types, there is no leeway for
23737 @code{()} to indicate an unspecified set of arguments.
23739 @end table
23741 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
23742 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr