PR tree-optimization/81384 - built-in form of strnlen missing
[official-gcc.git] / gcc / doc / extend.texi
blobcf88175e7959a62fbc1772196f11cee9296a223a
1 c Copyright (C) 1988-2018 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax::    Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments::        C++ comments are recognized.
67 * Dollar Signs::        Dollar sign is allowed in identifiers.
68 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
69 * Alignment::           Inquiring about the alignment of a type or variable.
70 * Inline::              Defining inline functions (as fast as macros).
71 * Volatiles::           What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83                         arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86                         checking.
87 * 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 supports data types for integers that are at least 64 bits wide,
847 and as an extension GCC supports them in C90 mode and in C++.
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 supports floating-point numbers written not only in the usual
1125 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++.  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 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1541 last element of a structure that is really a header for a variable-length
1542 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 In ISO C90, you would have to give @code{contents} a length of 1, which
1556 means either you waste space or complicate the argument to @code{malloc}.
1558 In ISO C99, you would use a @dfn{flexible array member}, which is
1559 slightly different in syntax and semantics:
1561 @itemize @bullet
1562 @item
1563 Flexible array members are written as @code{contents[]} without
1564 the @code{0}.
1566 @item
1567 Flexible array members have incomplete type, and so the @code{sizeof}
1568 operator may not be applied.  As a quirk of the original implementation
1569 of zero-length arrays, @code{sizeof} evaluates to zero.
1571 @item
1572 Flexible array members may only appear as the last member of a
1573 @code{struct} that is otherwise non-empty.
1575 @item
1576 A structure containing a flexible array member, or a union containing
1577 such a structure (possibly recursively), may not be a member of a
1578 structure or an element of an array.  (However, these uses are
1579 permitted by GCC as extensions.)
1580 @end itemize
1582 Non-empty initialization of zero-length
1583 arrays is treated like any case where there are more initializer
1584 elements than the array holds, in that a suitable warning about ``excess
1585 elements in array'' is given, and the excess elements (all of them, in
1586 this case) are ignored.
1588 GCC allows static initialization of flexible array members.
1589 This is equivalent to defining a new structure containing the original
1590 structure followed by an array of sufficient size to contain the data.
1591 E.g.@: in the following, @code{f1} is constructed as if it were declared
1592 like @code{f2}.
1594 @smallexample
1595 struct f1 @{
1596   int x; int y[];
1597 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1599 struct f2 @{
1600   struct f1 f1; int data[3];
1601 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1602 @end smallexample
1604 @noindent
1605 The convenience of this extension is that @code{f1} has the desired
1606 type, eliminating the need to consistently refer to @code{f2.f1}.
1608 This has symmetry with normal static arrays, in that an array of
1609 unknown size is also written with @code{[]}.
1611 Of course, this extension only makes sense if the extra data comes at
1612 the end of a top-level object, as otherwise we would be overwriting
1613 data at subsequent offsets.  To avoid undue complication and confusion
1614 with initialization of deeply nested arrays, we simply disallow any
1615 non-empty initialization except when the structure is the top-level
1616 object.  For example:
1618 @smallexample
1619 struct foo @{ int x; int y[]; @};
1620 struct bar @{ struct foo z; @};
1622 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1623 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1624 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1625 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1626 @end smallexample
1628 @node Empty Structures
1629 @section Structures with No Members
1630 @cindex empty structures
1631 @cindex zero-size structures
1633 GCC permits a C structure to have no members:
1635 @smallexample
1636 struct empty @{
1638 @end smallexample
1640 The structure has size zero.  In C++, empty structures are part
1641 of the language.  G++ treats empty structures as if they had a single
1642 member of type @code{char}.
1644 @node Variable Length
1645 @section Arrays of Variable Length
1646 @cindex variable-length arrays
1647 @cindex arrays of variable length
1648 @cindex VLAs
1650 Variable-length automatic arrays are allowed in ISO C99, and as an
1651 extension GCC accepts them in C90 mode and in C++.  These arrays are
1652 declared like any other automatic arrays, but with a length that is not
1653 a constant expression.  The storage is allocated at the point of
1654 declaration and deallocated when the block scope containing the declaration
1655 exits.  For
1656 example:
1658 @smallexample
1659 FILE *
1660 concat_fopen (char *s1, char *s2, char *mode)
1662   char str[strlen (s1) + strlen (s2) + 1];
1663   strcpy (str, s1);
1664   strcat (str, s2);
1665   return fopen (str, mode);
1667 @end smallexample
1669 @cindex scope of a variable length array
1670 @cindex variable-length array scope
1671 @cindex deallocating variable length arrays
1672 Jumping or breaking out of the scope of the array name deallocates the
1673 storage.  Jumping into the scope is not allowed; you get an error
1674 message for it.
1676 @cindex variable-length array in a structure
1677 As an extension, GCC accepts variable-length arrays as a member of
1678 a structure or a union.  For example:
1680 @smallexample
1681 void
1682 foo (int n)
1684   struct S @{ int x[n]; @};
1686 @end smallexample
1688 @cindex @code{alloca} vs variable-length arrays
1689 You can use the function @code{alloca} to get an effect much like
1690 variable-length arrays.  The function @code{alloca} is available in
1691 many other C implementations (but not in all).  On the other hand,
1692 variable-length arrays are more elegant.
1694 There are other differences between these two methods.  Space allocated
1695 with @code{alloca} exists until the containing @emph{function} returns.
1696 The space for a variable-length array is deallocated as soon as the array
1697 name's scope ends, unless you also use @code{alloca} in this scope.
1699 You can also use variable-length arrays as arguments to functions:
1701 @smallexample
1702 struct entry
1703 tester (int len, char data[len][len])
1705   /* @r{@dots{}} */
1707 @end smallexample
1709 The length of an array is computed once when the storage is allocated
1710 and is remembered for the scope of the array in case you access it with
1711 @code{sizeof}.
1713 If you want to pass the array first and the length afterward, you can
1714 use a forward declaration in the parameter list---another GNU extension.
1716 @smallexample
1717 struct entry
1718 tester (int len; char data[len][len], int len)
1720   /* @r{@dots{}} */
1722 @end smallexample
1724 @cindex parameter forward declaration
1725 The @samp{int len} before the semicolon is a @dfn{parameter forward
1726 declaration}, and it serves the purpose of making the name @code{len}
1727 known when the declaration of @code{data} is parsed.
1729 You can write any number of such parameter forward declarations in the
1730 parameter list.  They can be separated by commas or semicolons, but the
1731 last one must end with a semicolon, which is followed by the ``real''
1732 parameter declarations.  Each forward declaration must match a ``real''
1733 declaration in parameter name and data type.  ISO C99 does not support
1734 parameter forward declarations.
1736 @node Variadic Macros
1737 @section Macros with a Variable Number of Arguments.
1738 @cindex variable number of arguments
1739 @cindex macro with variable arguments
1740 @cindex rest argument (in macro)
1741 @cindex variadic macros
1743 In the ISO C standard of 1999, a macro can be declared to accept a
1744 variable number of arguments much as a function can.  The syntax for
1745 defining the macro is similar to that of a function.  Here is an
1746 example:
1748 @smallexample
1749 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1750 @end smallexample
1752 @noindent
1753 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1754 such a macro, it represents the zero or more tokens until the closing
1755 parenthesis that ends the invocation, including any commas.  This set of
1756 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1757 wherever it appears.  See the CPP manual for more information.
1759 GCC has long supported variadic macros, and used a different syntax that
1760 allowed you to give a name to the variable arguments just like any other
1761 argument.  Here is an example:
1763 @smallexample
1764 #define debug(format, args...) fprintf (stderr, format, args)
1765 @end smallexample
1767 @noindent
1768 This is in all ways equivalent to the ISO C example above, but arguably
1769 more readable and descriptive.
1771 GNU CPP has two further variadic macro extensions, and permits them to
1772 be used with either of the above forms of macro definition.
1774 In standard C, you are not allowed to leave the variable argument out
1775 entirely; but you are allowed to pass an empty argument.  For example,
1776 this invocation is invalid in ISO C, because there is no comma after
1777 the string:
1779 @smallexample
1780 debug ("A message")
1781 @end smallexample
1783 GNU CPP permits you to completely omit the variable arguments in this
1784 way.  In the above examples, the compiler would complain, though since
1785 the expansion of the macro still has the extra comma after the format
1786 string.
1788 To help solve this problem, CPP behaves specially for variable arguments
1789 used with the token paste operator, @samp{##}.  If instead you write
1791 @smallexample
1792 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1793 @end smallexample
1795 @noindent
1796 and if the variable arguments are omitted or empty, the @samp{##}
1797 operator causes the preprocessor to remove the comma before it.  If you
1798 do provide some variable arguments in your macro invocation, GNU CPP
1799 does not complain about the paste operation and instead places the
1800 variable arguments after the comma.  Just like any other pasted macro
1801 argument, these arguments are not macro expanded.
1803 @node Escaped Newlines
1804 @section Slightly Looser Rules for Escaped Newlines
1805 @cindex escaped newlines
1806 @cindex newlines (escaped)
1808 The preprocessor treatment of escaped newlines is more relaxed 
1809 than that specified by the C90 standard, which requires the newline
1810 to immediately follow a backslash.  
1811 GCC's implementation allows whitespace in the form
1812 of spaces, horizontal and vertical tabs, and form feeds between the
1813 backslash and the subsequent newline.  The preprocessor issues a
1814 warning, but treats it as a valid escaped newline and combines the two
1815 lines to form a single logical line.  This works within comments and
1816 tokens, as well as between tokens.  Comments are @emph{not} treated as
1817 whitespace for the purposes of this relaxation, since they have not
1818 yet been replaced with spaces.
1820 @node Subscripting
1821 @section Non-Lvalue Arrays May Have Subscripts
1822 @cindex subscripting
1823 @cindex arrays, non-lvalue
1825 @cindex subscripting and function values
1826 In ISO C99, arrays that are not lvalues still decay to pointers, and
1827 may be subscripted, although they may not be modified or used after
1828 the next sequence point and the unary @samp{&} operator may not be
1829 applied to them.  As an extension, GNU C allows such arrays to be
1830 subscripted in C90 mode, though otherwise they do not decay to
1831 pointers outside C99 mode.  For example,
1832 this is valid in GNU C though not valid in C90:
1834 @smallexample
1835 @group
1836 struct foo @{int a[4];@};
1838 struct foo f();
1840 bar (int index)
1842   return f().a[index];
1844 @end group
1845 @end smallexample
1847 @node Pointer Arith
1848 @section Arithmetic on @code{void}- and Function-Pointers
1849 @cindex void pointers, arithmetic
1850 @cindex void, size of pointer to
1851 @cindex function pointers, arithmetic
1852 @cindex function, size of pointer to
1854 In GNU C, addition and subtraction operations are supported on pointers to
1855 @code{void} and on pointers to functions.  This is done by treating the
1856 size of a @code{void} or of a function as 1.
1858 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1859 and on function types, and returns 1.
1861 @opindex Wpointer-arith
1862 The option @option{-Wpointer-arith} requests a warning if these extensions
1863 are used.
1865 @node Pointers to Arrays
1866 @section Pointers to Arrays with Qualifiers Work as Expected
1867 @cindex pointers to arrays
1868 @cindex const qualifier
1870 In GNU C, pointers to arrays with qualifiers work similar to pointers
1871 to other qualified types. For example, a value of type @code{int (*)[5]}
1872 can be used to initialize a variable of type @code{const int (*)[5]}.
1873 These types are incompatible in ISO C because the @code{const} qualifier
1874 is formally attached to the element type of the array and not the
1875 array itself.
1877 @smallexample
1878 extern void
1879 transpose (int N, int M, double out[M][N], const double in[N][M]);
1880 double x[3][2];
1881 double y[2][3];
1882 @r{@dots{}}
1883 transpose(3, 2, y, x);
1884 @end smallexample
1886 @node Initializers
1887 @section Non-Constant Initializers
1888 @cindex initializers, non-constant
1889 @cindex non-constant initializers
1891 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1892 automatic variable are not required to be constant expressions in GNU C@.
1893 Here is an example of an initializer with run-time varying elements:
1895 @smallexample
1896 foo (float f, float g)
1898   float beat_freqs[2] = @{ f-g, f+g @};
1899   /* @r{@dots{}} */
1901 @end smallexample
1903 @node Compound Literals
1904 @section Compound Literals
1905 @cindex constructor expressions
1906 @cindex initializations in expressions
1907 @cindex structures, constructor expression
1908 @cindex expressions, constructor
1909 @cindex compound literals
1910 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1912 A compound literal looks like a cast of a brace-enclosed aggregate
1913 initializer list.  Its value is an object of the type specified in
1914 the cast, containing the elements specified in the initializer.
1915 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1916 C99 and later support compound literals.  As an extension, GCC
1917 supports compound literals also in C90 mode and in C++, although
1918 as explained below, the C++ semantics are somewhat different.
1920 Usually, the specified type of a compound literal is a structure.  Assume
1921 that @code{struct foo} and @code{structure} are declared as shown:
1923 @smallexample
1924 struct foo @{int a; char b[2];@} structure;
1925 @end smallexample
1927 @noindent
1928 Here is an example of constructing a @code{struct foo} with a compound literal:
1930 @smallexample
1931 structure = ((struct foo) @{x + y, 'a', 0@});
1932 @end smallexample
1934 @noindent
1935 This is equivalent to writing the following:
1937 @smallexample
1939   struct foo temp = @{x + y, 'a', 0@};
1940   structure = temp;
1942 @end smallexample
1944 You can also construct an array, though this is dangerous in C++, as
1945 explained below.  If all the elements of the compound literal are
1946 (made up of) simple constant expressions suitable for use in
1947 initializers of objects of static storage duration, then the compound
1948 literal can be coerced to a pointer to its first element and used in
1949 such an initializer, as shown here:
1951 @smallexample
1952 char **foo = (char *[]) @{ "x", "y", "z" @};
1953 @end smallexample
1955 Compound literals for scalar types and union types are also allowed.  In
1956 the following example the variable @code{i} is initialized to the value
1957 @code{2}, the result of incrementing the unnamed object created by
1958 the compound literal.
1960 @smallexample
1961 int i = ++(int) @{ 1 @};
1962 @end smallexample
1964 As a GNU extension, GCC allows initialization of objects with static storage
1965 duration by compound literals (which is not possible in ISO C99 because
1966 the initializer is not a constant).
1967 It is handled as if the object were initialized only with the brace-enclosed
1968 list if the types of the compound literal and the object match.
1969 The elements of the compound literal must be constant.
1970 If the object being initialized has array type of unknown size, the size is
1971 determined by the size of the compound literal.
1973 @smallexample
1974 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1975 static int y[] = (int []) @{1, 2, 3@};
1976 static int z[] = (int [3]) @{1@};
1977 @end smallexample
1979 @noindent
1980 The above lines are equivalent to the following:
1981 @smallexample
1982 static struct foo x = @{1, 'a', 'b'@};
1983 static int y[] = @{1, 2, 3@};
1984 static int z[] = @{1, 0, 0@};
1985 @end smallexample
1987 In C, a compound literal designates an unnamed object with static or
1988 automatic storage duration.  In C++, a compound literal designates a
1989 temporary object that only lives until the end of its full-expression.
1990 As a result, well-defined C code that takes the address of a subobject
1991 of a compound literal can be undefined in C++, so G++ rejects
1992 the conversion of a temporary array to a pointer.  For instance, if
1993 the array compound literal example above appeared inside a function,
1994 any subsequent use of @code{foo} in C++ would have undefined behavior
1995 because the lifetime of the array ends after the declaration of @code{foo}.
1997 As an optimization, G++ sometimes gives array compound literals longer
1998 lifetimes: when the array either appears outside a function or has
1999 a @code{const}-qualified type.  If @code{foo} and its initializer had
2000 elements of type @code{char *const} rather than @code{char *}, or if
2001 @code{foo} were a global variable, the array would have static storage
2002 duration.  But it is probably safest just to avoid the use of array
2003 compound literals in C++ code.
2005 @node Designated Inits
2006 @section Designated Initializers
2007 @cindex initializers with labeled elements
2008 @cindex labeled elements in initializers
2009 @cindex case labels in initializers
2010 @cindex designated initializers
2012 Standard C90 requires the elements of an initializer to appear in a fixed
2013 order, the same as the order of the elements in the array or structure
2014 being initialized.
2016 In ISO C99 you can give the elements in any order, specifying the array
2017 indices or structure field names they apply to, and GNU C allows this as
2018 an extension in C90 mode as well.  This extension is not
2019 implemented in GNU C++.
2021 To specify an array index, write
2022 @samp{[@var{index}] =} before the element value.  For example,
2024 @smallexample
2025 int a[6] = @{ [4] = 29, [2] = 15 @};
2026 @end smallexample
2028 @noindent
2029 is equivalent to
2031 @smallexample
2032 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2033 @end smallexample
2035 @noindent
2036 The index values must be constant expressions, even if the array being
2037 initialized is automatic.
2039 An alternative syntax for this that has been obsolete since GCC 2.5 but
2040 GCC still accepts is to write @samp{[@var{index}]} before the element
2041 value, with no @samp{=}.
2043 To initialize a range of elements to the same value, write
2044 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2045 extension.  For example,
2047 @smallexample
2048 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2049 @end smallexample
2051 @noindent
2052 If the value in it has side effects, the side effects happen only once,
2053 not for each initialized field by the range initializer.
2055 @noindent
2056 Note that the length of the array is the highest value specified
2057 plus one.
2059 In a structure initializer, specify the name of a field to initialize
2060 with @samp{.@var{fieldname} =} before the element value.  For example,
2061 given the following structure,
2063 @smallexample
2064 struct point @{ int x, y; @};
2065 @end smallexample
2067 @noindent
2068 the following initialization
2070 @smallexample
2071 struct point p = @{ .y = yvalue, .x = xvalue @};
2072 @end smallexample
2074 @noindent
2075 is equivalent to
2077 @smallexample
2078 struct point p = @{ xvalue, yvalue @};
2079 @end smallexample
2081 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2082 @samp{@var{fieldname}:}, as shown here:
2084 @smallexample
2085 struct point p = @{ y: yvalue, x: xvalue @};
2086 @end smallexample
2088 Omitted field members are implicitly initialized the same as objects
2089 that have static storage duration.
2091 @cindex designators
2092 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2093 @dfn{designator}.  You can also use a designator (or the obsolete colon
2094 syntax) when initializing a union, to specify which element of the union
2095 should be used.  For example,
2097 @smallexample
2098 union foo @{ int i; double d; @};
2100 union foo f = @{ .d = 4 @};
2101 @end smallexample
2103 @noindent
2104 converts 4 to a @code{double} to store it in the union using
2105 the second element.  By contrast, casting 4 to type @code{union foo}
2106 stores it into the union as the integer @code{i}, since it is
2107 an integer.  @xref{Cast to Union}.
2109 You can combine this technique of naming elements with ordinary C
2110 initialization of successive elements.  Each initializer element that
2111 does not have a designator applies to the next consecutive element of the
2112 array or structure.  For example,
2114 @smallexample
2115 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2116 @end smallexample
2118 @noindent
2119 is equivalent to
2121 @smallexample
2122 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2123 @end smallexample
2125 Labeling the elements of an array initializer is especially useful
2126 when the indices are characters or belong to an @code{enum} type.
2127 For example:
2129 @smallexample
2130 int whitespace[256]
2131   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2132       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2133 @end smallexample
2135 @cindex designator lists
2136 You can also write a series of @samp{.@var{fieldname}} and
2137 @samp{[@var{index}]} designators before an @samp{=} to specify a
2138 nested subobject to initialize; the list is taken relative to the
2139 subobject corresponding to the closest surrounding brace pair.  For
2140 example, with the @samp{struct point} declaration above:
2142 @smallexample
2143 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2144 @end smallexample
2146 @noindent
2147 If the same field is initialized multiple times, it has the value from
2148 the last initialization.  If any such overridden initialization has
2149 side effect, it is unspecified whether the side effect happens or not.
2150 Currently, GCC discards them and issues a warning.
2152 @node Case Ranges
2153 @section Case Ranges
2154 @cindex case ranges
2155 @cindex ranges in case statements
2157 You can specify a range of consecutive values in a single @code{case} label,
2158 like this:
2160 @smallexample
2161 case @var{low} ... @var{high}:
2162 @end smallexample
2164 @noindent
2165 This has the same effect as the proper number of individual @code{case}
2166 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2168 This feature is especially useful for ranges of ASCII character codes:
2170 @smallexample
2171 case 'A' ... 'Z':
2172 @end smallexample
2174 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2175 it may be parsed wrong when you use it with integer values.  For example,
2176 write this:
2178 @smallexample
2179 case 1 ... 5:
2180 @end smallexample
2182 @noindent
2183 rather than this:
2185 @smallexample
2186 case 1...5:
2187 @end smallexample
2189 @node Cast to Union
2190 @section Cast to a Union Type
2191 @cindex cast to a union
2192 @cindex union, casting to a
2194 A cast to union type looks similar to other casts, except that the type
2195 specified is a union type.  You can specify the type either with the
2196 @code{union} keyword or with a @code{typedef} name that refers to
2197 a union.  A cast to a union actually creates a compound literal and
2198 yields an lvalue, not an rvalue like true casts do.
2199 @xref{Compound Literals}.
2201 The types that may be cast to the union type are those of the members
2202 of the union.  Thus, given the following union and variables:
2204 @smallexample
2205 union foo @{ int i; double d; @};
2206 int x;
2207 double y;
2208 @end smallexample
2210 @noindent
2211 both @code{x} and @code{y} can be cast to type @code{union foo}.
2213 Using the cast as the right-hand side of an assignment to a variable of
2214 union type is equivalent to storing in a member of the union:
2216 @smallexample
2217 union foo u;
2218 /* @r{@dots{}} */
2219 u = (union foo) x  @equiv{}  u.i = x
2220 u = (union foo) y  @equiv{}  u.d = y
2221 @end smallexample
2223 You can also use the union cast as a function argument:
2225 @smallexample
2226 void hack (union foo);
2227 /* @r{@dots{}} */
2228 hack ((union foo) x);
2229 @end smallexample
2231 @node Mixed Declarations
2232 @section Mixed Declarations and Code
2233 @cindex mixed declarations and code
2234 @cindex declarations, mixed with code
2235 @cindex code, mixed with declarations
2237 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2238 within compound statements.  As an extension, GNU C also allows this in
2239 C90 mode.  For example, you could do:
2241 @smallexample
2242 int i;
2243 /* @r{@dots{}} */
2244 i++;
2245 int j = i + 2;
2246 @end smallexample
2248 Each identifier is visible from where it is declared until the end of
2249 the enclosing block.
2251 @node Function Attributes
2252 @section Declaring Attributes of Functions
2253 @cindex function attributes
2254 @cindex declaring attributes of functions
2255 @cindex @code{volatile} applied to function
2256 @cindex @code{const} applied to function
2258 In GNU C, you can use function attributes to declare certain things
2259 about functions called in your program which help the compiler
2260 optimize calls and check your code more carefully.  For example, you
2261 can use attributes to declare that a function never returns
2262 (@code{noreturn}), returns a value depending only on its arguments
2263 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2265 You can also use attributes to control memory placement, code
2266 generation options or call/return conventions within the function
2267 being annotated.  Many of these attributes are target-specific.  For
2268 example, many targets support attributes for defining interrupt
2269 handler functions, which typically must follow special register usage
2270 and return conventions.
2272 Function attributes are introduced by the @code{__attribute__} keyword
2273 on a declaration, followed by an attribute specification inside double
2274 parentheses.  You can specify multiple attributes in a declaration by
2275 separating them by commas within the double parentheses or by
2276 immediately following an attribute declaration with another attribute
2277 declaration.  @xref{Attribute Syntax}, for the exact rules on attribute
2278 syntax and placement.  Compatible attribute specifications on distinct
2279 declarations of the same function are merged.  An attribute specification
2280 that is not compatible with attributes already applied to a declaration
2281 of the same function is ignored with a warning.
2283 GCC also supports attributes on
2284 variable declarations (@pxref{Variable Attributes}),
2285 labels (@pxref{Label Attributes}),
2286 enumerators (@pxref{Enumerator Attributes}),
2287 statements (@pxref{Statement Attributes}),
2288 and types (@pxref{Type Attributes}).
2290 There is some overlap between the purposes of attributes and pragmas
2291 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2292 found convenient to use @code{__attribute__} to achieve a natural
2293 attachment of attributes to their corresponding declarations, whereas
2294 @code{#pragma} is of use for compatibility with other compilers
2295 or constructs that do not naturally form part of the grammar.
2297 In addition to the attributes documented here,
2298 GCC plugins may provide their own attributes.
2300 @menu
2301 * Common Function Attributes::
2302 * AArch64 Function Attributes::
2303 * ARC Function Attributes::
2304 * ARM Function Attributes::
2305 * AVR Function Attributes::
2306 * Blackfin Function Attributes::
2307 * CR16 Function Attributes::
2308 * Epiphany Function Attributes::
2309 * H8/300 Function Attributes::
2310 * IA-64 Function Attributes::
2311 * M32C Function Attributes::
2312 * M32R/D Function Attributes::
2313 * m68k Function Attributes::
2314 * MCORE Function Attributes::
2315 * MeP Function Attributes::
2316 * MicroBlaze Function Attributes::
2317 * Microsoft Windows Function Attributes::
2318 * MIPS Function Attributes::
2319 * MSP430 Function Attributes::
2320 * NDS32 Function Attributes::
2321 * Nios II Function Attributes::
2322 * Nvidia PTX Function Attributes::
2323 * PowerPC Function Attributes::
2324 * RISC-V Function Attributes::
2325 * RL78 Function Attributes::
2326 * RX Function Attributes::
2327 * S/390 Function Attributes::
2328 * SH Function Attributes::
2329 * SPU Function Attributes::
2330 * Symbian OS Function Attributes::
2331 * V850 Function Attributes::
2332 * Visium Function Attributes::
2333 * x86 Function Attributes::
2334 * Xstormy16 Function Attributes::
2335 @end menu
2337 @node Common Function Attributes
2338 @subsection Common Function Attributes
2340 The following attributes are supported on most targets.
2342 @table @code
2343 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2345 @item alias ("@var{target}")
2346 @cindex @code{alias} function attribute
2347 The @code{alias} attribute causes the declaration to be emitted as an
2348 alias for another symbol, which must be specified.  For instance,
2350 @smallexample
2351 void __f () @{ /* @r{Do something.} */; @}
2352 void f () __attribute__ ((weak, alias ("__f")));
2353 @end smallexample
2355 @noindent
2356 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2357 mangled name for the target must be used.  It is an error if @samp{__f}
2358 is not defined in the same translation unit.
2360 This attribute requires assembler and object file support,
2361 and may not be available on all targets.
2363 @item aligned (@var{alignment})
2364 @cindex @code{aligned} function attribute
2365 This attribute specifies a minimum alignment for the function,
2366 measured in bytes.
2368 You cannot use this attribute to decrease the alignment of a function,
2369 only to increase it.  However, when you explicitly specify a function
2370 alignment this overrides the effect of the
2371 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2372 function.
2374 Note that the effectiveness of @code{aligned} attributes may be
2375 limited by inherent limitations in your linker.  On many systems, the
2376 linker is only able to arrange for functions to be aligned up to a
2377 certain maximum alignment.  (For some linkers, the maximum supported
2378 alignment may be very very small.)  See your linker documentation for
2379 further information.
2381 The @code{aligned} attribute can also be used for variables and fields
2382 (@pxref{Variable Attributes}.)
2384 @item alloc_align
2385 @cindex @code{alloc_align} function attribute
2386 The @code{alloc_align} attribute is used to tell the compiler that the
2387 function return value points to memory, where the returned pointer minimum
2388 alignment is given by one of the functions parameters.  GCC uses this
2389 information to improve pointer alignment analysis.
2391 The function parameter denoting the allocated alignment is specified by
2392 one integer argument, whose number is the argument of the attribute.
2393 Argument numbering starts at one.
2395 For instance,
2397 @smallexample
2398 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2399 @end smallexample
2401 @noindent
2402 declares that @code{my_memalign} returns memory with minimum alignment
2403 given by parameter 1.
2405 @item alloc_size
2406 @cindex @code{alloc_size} function attribute
2407 The @code{alloc_size} attribute is used to tell the compiler that the
2408 function return value points to memory, where the size is given by
2409 one or two of the functions parameters.  GCC uses this
2410 information to improve the correctness of @code{__builtin_object_size}.
2412 The function parameter(s) denoting the allocated size are specified by
2413 one or two integer arguments supplied to the attribute.  The allocated size
2414 is either the value of the single function argument specified or the product
2415 of the two function arguments specified.  Argument numbering starts at
2416 one.
2418 For instance,
2420 @smallexample
2421 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2422 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2423 @end smallexample
2425 @noindent
2426 declares that @code{my_calloc} returns memory of the size given by
2427 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2428 of the size given by parameter 2.
2430 @item always_inline
2431 @cindex @code{always_inline} function attribute
2432 Generally, functions are not inlined unless optimization is specified.
2433 For functions declared inline, this attribute inlines the function
2434 independent of any restrictions that otherwise apply to inlining.
2435 Failure to inline such a function is diagnosed as an error.
2436 Note that if such a function is called indirectly the compiler may
2437 or may not inline it depending on optimization level and a failure
2438 to inline an indirect call may or may not be diagnosed.
2440 @item artificial
2441 @cindex @code{artificial} function attribute
2442 This attribute is useful for small inline wrappers that if possible
2443 should appear during debugging as a unit.  Depending on the debug
2444 info format it either means marking the function as artificial
2445 or using the caller location for all instructions within the inlined
2446 body.
2448 @item assume_aligned
2449 @cindex @code{assume_aligned} function attribute
2450 The @code{assume_aligned} attribute is used to tell the compiler that the
2451 function return value points to memory, where the returned pointer minimum
2452 alignment is given by the first argument.
2453 If the attribute has two arguments, the second argument is misalignment offset.
2455 For instance
2457 @smallexample
2458 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2459 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2460 @end smallexample
2462 @noindent
2463 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2464 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2465 to 8.
2467 @item cold
2468 @cindex @code{cold} function attribute
2469 The @code{cold} attribute on functions is used to inform the compiler that
2470 the function is unlikely to be executed.  The function is optimized for
2471 size rather than speed and on many targets it is placed into a special
2472 subsection of the text section so all cold functions appear close together,
2473 improving code locality of non-cold parts of program.  The paths leading
2474 to calls of cold functions within code are marked as unlikely by the branch
2475 prediction mechanism.  It is thus useful to mark functions used to handle
2476 unlikely conditions, such as @code{perror}, as cold to improve optimization
2477 of hot functions that do call marked functions in rare occasions.
2479 When profile feedback is available, via @option{-fprofile-use}, cold functions
2480 are automatically detected and this attribute is ignored.
2482 @item const
2483 @cindex @code{const} function attribute
2484 @cindex functions that have no side effects
2485 Many functions do not examine any values except their arguments, and
2486 have no effects except to return a value.  Calls to such functions lend
2487 themselves to optimization such as common subexpression elimination.
2488 The @code{const} attribute imposes greater restrictions on a function's
2489 definition than the similar @code{pure} attribute below because it prohibits
2490 the function from reading global variables.  Consequently, the presence of
2491 the attribute on a function declaration allows GCC to emit more efficient
2492 code for some calls to the function.  Decorating the same function with
2493 both the @code{const} and the @code{pure} attribute is diagnosed.
2495 @cindex pointer arguments
2496 Note that a function that has pointer arguments and examines the data
2497 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2498 function that calls a non-@code{const} function usually must not be
2499 @code{const}.  Because a @code{const} function cannot have any side
2500 effects it does not make sense for such a function to return @code{void}.
2501 Declaring such a function is diagnosed.
2503 @item constructor
2504 @itemx destructor
2505 @itemx constructor (@var{priority})
2506 @itemx destructor (@var{priority})
2507 @cindex @code{constructor} function attribute
2508 @cindex @code{destructor} function attribute
2509 The @code{constructor} attribute causes the function to be called
2510 automatically before execution enters @code{main ()}.  Similarly, the
2511 @code{destructor} attribute causes the function to be called
2512 automatically after @code{main ()} completes or @code{exit ()} is
2513 called.  Functions with these attributes are useful for
2514 initializing data that is used implicitly during the execution of
2515 the program.
2517 You may provide an optional integer priority to control the order in
2518 which constructor and destructor functions are run.  A constructor
2519 with a smaller priority number runs before a constructor with a larger
2520 priority number; the opposite relationship holds for destructors.  So,
2521 if you have a constructor that allocates a resource and a destructor
2522 that deallocates the same resource, both functions typically have the
2523 same priority.  The priorities for constructor and destructor
2524 functions are the same as those specified for namespace-scope C++
2525 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2526 constructors for C++ objects with static storage duration and functions
2527 decorated with attribute @code{constructor} are invoked is unspecified.
2528 In mixed declarations, attribute @code{init_priority} can be used to
2529 impose a specific ordering.
2531 @item deprecated
2532 @itemx deprecated (@var{msg})
2533 @cindex @code{deprecated} function attribute
2534 The @code{deprecated} attribute results in a warning if the function
2535 is used anywhere in the source file.  This is useful when identifying
2536 functions that are expected to be removed in a future version of a
2537 program.  The warning also includes the location of the declaration
2538 of the deprecated function, to enable users to easily find further
2539 information about why the function is deprecated, or what they should
2540 do instead.  Note that the warnings only occurs for uses:
2542 @smallexample
2543 int old_fn () __attribute__ ((deprecated));
2544 int old_fn ();
2545 int (*fn_ptr)() = old_fn;
2546 @end smallexample
2548 @noindent
2549 results in a warning on line 3 but not line 2.  The optional @var{msg}
2550 argument, which must be a string, is printed in the warning if
2551 present.
2553 The @code{deprecated} attribute can also be used for variables and
2554 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2556 The message attached to the attribute is affected by the setting of
2557 the @option{-fmessage-length} option.
2559 @item error ("@var{message}")
2560 @itemx warning ("@var{message}")
2561 @cindex @code{error} function attribute
2562 @cindex @code{warning} function attribute
2563 If the @code{error} or @code{warning} attribute 
2564 is used on a function declaration and a call to such a function
2565 is not eliminated through dead code elimination or other optimizations, 
2566 an error or warning (respectively) that includes @var{message} is diagnosed.  
2567 This is useful
2568 for compile-time checking, especially together with @code{__builtin_constant_p}
2569 and inline functions where checking the inline function arguments is not
2570 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2572 While it is possible to leave the function undefined and thus invoke
2573 a link failure (to define the function with
2574 a message in @code{.gnu.warning*} section),
2575 when using these attributes the problem is diagnosed
2576 earlier and with exact location of the call even in presence of inline
2577 functions or when not emitting debugging information.
2579 @item externally_visible
2580 @cindex @code{externally_visible} function attribute
2581 This attribute, attached to a global variable or function, nullifies
2582 the effect of the @option{-fwhole-program} command-line option, so the
2583 object remains visible outside the current compilation unit.
2585 If @option{-fwhole-program} is used together with @option{-flto} and 
2586 @command{gold} is used as the linker plugin, 
2587 @code{externally_visible} attributes are automatically added to functions 
2588 (not variable yet due to a current @command{gold} issue) 
2589 that are accessed outside of LTO objects according to resolution file
2590 produced by @command{gold}.
2591 For other linkers that cannot generate resolution file,
2592 explicit @code{externally_visible} attributes are still necessary.
2594 @item flatten
2595 @cindex @code{flatten} function attribute
2596 Generally, inlining into a function is limited.  For a function marked with
2597 this attribute, every call inside this function is inlined, if possible.
2598 Whether the function itself is considered for inlining depends on its size and
2599 the current inlining parameters.
2601 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2602 @cindex @code{format} function attribute
2603 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2604 @opindex Wformat
2605 The @code{format} attribute specifies that a function takes @code{printf},
2606 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2607 should be type-checked against a format string.  For example, the
2608 declaration:
2610 @smallexample
2611 extern int
2612 my_printf (void *my_object, const char *my_format, ...)
2613       __attribute__ ((format (printf, 2, 3)));
2614 @end smallexample
2616 @noindent
2617 causes the compiler to check the arguments in calls to @code{my_printf}
2618 for consistency with the @code{printf} style format string argument
2619 @code{my_format}.
2621 The parameter @var{archetype} determines how the format string is
2622 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2623 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2624 @code{strfmon}.  (You can also use @code{__printf__},
2625 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2626 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2627 @code{ms_strftime} are also present.
2628 @var{archetype} values such as @code{printf} refer to the formats accepted
2629 by the system's C runtime library,
2630 while values prefixed with @samp{gnu_} always refer
2631 to the formats accepted by the GNU C Library.  On Microsoft Windows
2632 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2633 @file{msvcrt.dll} library.
2634 The parameter @var{string-index}
2635 specifies which argument is the format string argument (starting
2636 from 1), while @var{first-to-check} is the number of the first
2637 argument to check against the format string.  For functions
2638 where the arguments are not available to be checked (such as
2639 @code{vprintf}), specify the third parameter as zero.  In this case the
2640 compiler only checks the format string for consistency.  For
2641 @code{strftime} formats, the third parameter is required to be zero.
2642 Since non-static C++ methods have an implicit @code{this} argument, the
2643 arguments of such methods should be counted from two, not one, when
2644 giving values for @var{string-index} and @var{first-to-check}.
2646 In the example above, the format string (@code{my_format}) is the second
2647 argument of the function @code{my_print}, and the arguments to check
2648 start with the third argument, so the correct parameters for the format
2649 attribute are 2 and 3.
2651 @opindex ffreestanding
2652 @opindex fno-builtin
2653 The @code{format} attribute allows you to identify your own functions
2654 that take format strings as arguments, so that GCC can check the
2655 calls to these functions for errors.  The compiler always (unless
2656 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2657 for the standard library functions @code{printf}, @code{fprintf},
2658 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2659 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2660 warnings are requested (using @option{-Wformat}), so there is no need to
2661 modify the header file @file{stdio.h}.  In C99 mode, the functions
2662 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2663 @code{vsscanf} are also checked.  Except in strictly conforming C
2664 standard modes, the X/Open function @code{strfmon} is also checked as
2665 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2666 @xref{C Dialect Options,,Options Controlling C Dialect}.
2668 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2669 recognized in the same context.  Declarations including these format attributes
2670 are parsed for correct syntax, however the result of checking of such format
2671 strings is not yet defined, and is not carried out by this version of the
2672 compiler.
2674 The target may also provide additional types of format checks.
2675 @xref{Target Format Checks,,Format Checks Specific to Particular
2676 Target Machines}.
2678 @item format_arg (@var{string-index})
2679 @cindex @code{format_arg} function attribute
2680 @opindex Wformat-nonliteral
2681 The @code{format_arg} attribute specifies that a function takes a format
2682 string for a @code{printf}, @code{scanf}, @code{strftime} or
2683 @code{strfmon} style function and modifies it (for example, to translate
2684 it into another language), so the result can be passed to a
2685 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2686 function (with the remaining arguments to the format function the same
2687 as they would have been for the unmodified string).  For example, the
2688 declaration:
2690 @smallexample
2691 extern char *
2692 my_dgettext (char *my_domain, const char *my_format)
2693       __attribute__ ((format_arg (2)));
2694 @end smallexample
2696 @noindent
2697 causes the compiler to check the arguments in calls to a @code{printf},
2698 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2699 format string argument is a call to the @code{my_dgettext} function, for
2700 consistency with the format string argument @code{my_format}.  If the
2701 @code{format_arg} attribute had not been specified, all the compiler
2702 could tell in such calls to format functions would be that the format
2703 string argument is not constant; this would generate a warning when
2704 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2705 without the attribute.
2707 The parameter @var{string-index} specifies which argument is the format
2708 string argument (starting from one).  Since non-static C++ methods have
2709 an implicit @code{this} argument, the arguments of such methods should
2710 be counted from two.
2712 The @code{format_arg} attribute allows you to identify your own
2713 functions that modify format strings, so that GCC can check the
2714 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2715 type function whose operands are a call to one of your own function.
2716 The compiler always treats @code{gettext}, @code{dgettext}, and
2717 @code{dcgettext} in this manner except when strict ISO C support is
2718 requested by @option{-ansi} or an appropriate @option{-std} option, or
2719 @option{-ffreestanding} or @option{-fno-builtin}
2720 is used.  @xref{C Dialect Options,,Options
2721 Controlling C Dialect}.
2723 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2724 @code{NSString} reference for compatibility with the @code{format} attribute
2725 above.
2727 The target may also allow additional types in @code{format-arg} attributes.
2728 @xref{Target Format Checks,,Format Checks Specific to Particular
2729 Target Machines}.
2731 @item gnu_inline
2732 @cindex @code{gnu_inline} function attribute
2733 This attribute should be used with a function that is also declared
2734 with the @code{inline} keyword.  It directs GCC to treat the function
2735 as if it were defined in gnu90 mode even when compiling in C99 or
2736 gnu99 mode.
2738 If the function is declared @code{extern}, then this definition of the
2739 function is used only for inlining.  In no case is the function
2740 compiled as a standalone function, not even if you take its address
2741 explicitly.  Such an address becomes an external reference, as if you
2742 had only declared the function, and had not defined it.  This has
2743 almost the effect of a macro.  The way to use this is to put a
2744 function definition in a header file with this attribute, and put
2745 another copy of the function, without @code{extern}, in a library
2746 file.  The definition in the header file causes most calls to the
2747 function to be inlined.  If any uses of the function remain, they
2748 refer to the single copy in the library.  Note that the two
2749 definitions of the functions need not be precisely the same, although
2750 if they do not have the same effect your program may behave oddly.
2752 In C, if the function is neither @code{extern} nor @code{static}, then
2753 the function is compiled as a standalone function, as well as being
2754 inlined where possible.
2756 This is how GCC traditionally handled functions declared
2757 @code{inline}.  Since ISO C99 specifies a different semantics for
2758 @code{inline}, this function attribute is provided as a transition
2759 measure and as a useful feature in its own right.  This attribute is
2760 available in GCC 4.1.3 and later.  It is available if either of the
2761 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2762 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2763 Function is As Fast As a Macro}.
2765 In C++, this attribute does not depend on @code{extern} in any way,
2766 but it still requires the @code{inline} keyword to enable its special
2767 behavior.
2769 @item hot
2770 @cindex @code{hot} function attribute
2771 The @code{hot} attribute on a function is used to inform the compiler that
2772 the function is a hot spot of the compiled program.  The function is
2773 optimized more aggressively and on many targets it is placed into a special
2774 subsection of the text section so all hot functions appear close together,
2775 improving locality.
2777 When profile feedback is available, via @option{-fprofile-use}, hot functions
2778 are automatically detected and this attribute is ignored.
2780 @item ifunc ("@var{resolver}")
2781 @cindex @code{ifunc} function attribute
2782 @cindex indirect functions
2783 @cindex functions that are dynamically resolved
2784 The @code{ifunc} attribute is used to mark a function as an indirect
2785 function using the STT_GNU_IFUNC symbol type extension to the ELF
2786 standard.  This allows the resolution of the symbol value to be
2787 determined dynamically at load time, and an optimized version of the
2788 routine to be selected for the particular processor or other system
2789 characteristics determined then.  To use this attribute, first define
2790 the implementation functions available, and a resolver function that
2791 returns a pointer to the selected implementation function.  The
2792 implementation functions' declarations must match the API of the
2793 function being implemented.  The resolver should be declared to
2794 be a function taking no arguments and returning a pointer to
2795 a function of the same type as the implementation.  For example:
2797 @smallexample
2798 void *my_memcpy (void *dst, const void *src, size_t len)
2800   @dots{}
2801   return dst;
2804 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2806   return my_memcpy; // we will just always select this routine
2808 @end smallexample
2810 @noindent
2811 The exported header file declaring the function the user calls would
2812 contain:
2814 @smallexample
2815 extern void *memcpy (void *, const void *, size_t);
2816 @end smallexample
2818 @noindent
2819 allowing the user to call @code{memcpy} as a regular function, unaware of
2820 the actual implementation.  Finally, the indirect function needs to be
2821 defined in the same translation unit as the resolver function:
2823 @smallexample
2824 void *memcpy (void *, const void *, size_t)
2825      __attribute__ ((ifunc ("resolve_memcpy")));
2826 @end smallexample
2828 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2829 of the resolver function.  A C++ resolver for a non-static member function
2830 of class @code{C} should be declared to return a pointer to a non-member
2831 function taking pointer to @code{C} as the first argument, followed by
2832 the same arguments as of the implementation function.  G++ checks
2833 the signatures of the two functions and issues
2834 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2835 for the necessary cast from a pointer to the implementation member function
2836 to the type of the corresponding non-member function use
2837 the @option{-Wno-pmf-conversions} option.  For example:
2839 @smallexample
2840 class S
2842 private:
2843   int debug_impl (int);
2844   int optimized_impl (int);
2846   typedef int Func (S*, int);
2848   static Func* resolver ();
2849 public:
2851   int interface (int);
2854 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2855 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2857 S::Func* S::resolver ()
2859   int (S::*pimpl) (int)
2860     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2862   // Cast triggers -Wno-pmf-conversions.
2863   return reinterpret_cast<Func*>(pimpl);
2866 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2867 @end smallexample
2869 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2870 and GNU C Library version 2.11.1 are required to use this feature.
2872 @item interrupt
2873 @itemx interrupt_handler
2874 Many GCC back ends support attributes to indicate that a function is
2875 an interrupt handler, which tells the compiler to generate function
2876 entry and exit sequences that differ from those from regular
2877 functions.  The exact syntax and behavior are target-specific;
2878 refer to the following subsections for details.
2880 @item leaf
2881 @cindex @code{leaf} function attribute
2882 Calls to external functions with this attribute must return to the
2883 current compilation unit only by return or by exception handling.  In
2884 particular, a leaf function is not allowed to invoke callback functions
2885 passed to it from the current compilation unit, directly call functions
2886 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2887 might still call functions from other compilation units and thus they
2888 are not necessarily leaf in the sense that they contain no function
2889 calls at all.
2891 The attribute is intended for library functions to improve dataflow
2892 analysis.  The compiler takes the hint that any data not escaping the
2893 current compilation unit cannot be used or modified by the leaf
2894 function.  For example, the @code{sin} function is a leaf function, but
2895 @code{qsort} is not.
2897 Note that leaf functions might indirectly run a signal handler defined
2898 in the current compilation unit that uses static variables.  Similarly,
2899 when lazy symbol resolution is in effect, leaf functions might invoke
2900 indirect functions whose resolver function or implementation function is
2901 defined in the current compilation unit and uses static variables.  There
2902 is no standard-compliant way to write such a signal handler, resolver
2903 function, or implementation function, and the best that you can do is to
2904 remove the @code{leaf} attribute or mark all such static variables
2905 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2906 interposition, care should be taken that functions defined in the
2907 current compilation unit do not unexpectedly interpose other symbols
2908 based on the defined standards mode and defined feature test macros;
2909 otherwise an inadvertent callback would be added.
2911 The attribute has no effect on functions defined within the current
2912 compilation unit.  This is to allow easy merging of multiple compilation
2913 units into one, for example, by using the link-time optimization.  For
2914 this reason the attribute is not allowed on types to annotate indirect
2915 calls.
2917 @item malloc
2918 @cindex @code{malloc} function attribute
2919 @cindex functions that behave like malloc
2920 This tells the compiler that a function is @code{malloc}-like, i.e.,
2921 that the pointer @var{P} returned by the function cannot alias any
2922 other pointer valid when the function returns, and moreover no
2923 pointers to valid objects occur in any storage addressed by @var{P}.
2925 Using this attribute can improve optimization.  Functions like
2926 @code{malloc} and @code{calloc} have this property because they return
2927 a pointer to uninitialized or zeroed-out storage.  However, functions
2928 like @code{realloc} do not have this property, as they can return a
2929 pointer to storage containing pointers.
2931 @item no_icf
2932 @cindex @code{no_icf} function attribute
2933 This function attribute prevents a functions from being merged with another
2934 semantically equivalent function.
2936 @item no_instrument_function
2937 @cindex @code{no_instrument_function} function attribute
2938 @opindex finstrument-functions
2939 If @option{-finstrument-functions} is given, profiling function calls are
2940 generated at entry and exit of most user-compiled functions.
2941 Functions with this attribute are not so instrumented.
2943 @item no_profile_instrument_function
2944 @cindex @code{no_profile_instrument_function} function attribute
2945 The @code{no_profile_instrument_function} attribute on functions is used
2946 to inform the compiler that it should not process any profile feedback based
2947 optimization code instrumentation.
2949 @item no_reorder
2950 @cindex @code{no_reorder} function attribute
2951 Do not reorder functions or variables marked @code{no_reorder}
2952 against each other or top level assembler statements the executable.
2953 The actual order in the program will depend on the linker command
2954 line. Static variables marked like this are also not removed.
2955 This has a similar effect
2956 as the @option{-fno-toplevel-reorder} option, but only applies to the
2957 marked symbols.
2959 @item no_sanitize ("@var{sanitize_option}")
2960 @cindex @code{no_sanitize} function attribute
2961 The @code{no_sanitize} attribute on functions is used
2962 to inform the compiler that it should not do sanitization of all options
2963 mentioned in @var{sanitize_option}.  A list of values acceptable by
2964 @option{-fsanitize} option can be provided.
2966 @smallexample
2967 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2968 f () @{ /* @r{Do something.} */; @}
2969 void __attribute__ ((no_sanitize ("alignment,object-size")))
2970 g () @{ /* @r{Do something.} */; @}
2971 @end smallexample
2973 @item no_sanitize_address
2974 @itemx no_address_safety_analysis
2975 @cindex @code{no_sanitize_address} function attribute
2976 The @code{no_sanitize_address} attribute on functions is used
2977 to inform the compiler that it should not instrument memory accesses
2978 in the function when compiling with the @option{-fsanitize=address} option.
2979 The @code{no_address_safety_analysis} is a deprecated alias of the
2980 @code{no_sanitize_address} attribute, new code should use
2981 @code{no_sanitize_address}.
2983 @item no_sanitize_thread
2984 @cindex @code{no_sanitize_thread} function attribute
2985 The @code{no_sanitize_thread} attribute on functions is used
2986 to inform the compiler that it should not instrument memory accesses
2987 in the function when compiling with the @option{-fsanitize=thread} option.
2989 @item no_sanitize_undefined
2990 @cindex @code{no_sanitize_undefined} function attribute
2991 The @code{no_sanitize_undefined} attribute on functions is used
2992 to inform the compiler that it should not check for undefined behavior
2993 in the function when compiling with the @option{-fsanitize=undefined} option.
2995 @item no_split_stack
2996 @cindex @code{no_split_stack} function attribute
2997 @opindex fsplit-stack
2998 If @option{-fsplit-stack} is given, functions have a small
2999 prologue which decides whether to split the stack.  Functions with the
3000 @code{no_split_stack} attribute do not have that prologue, and thus
3001 may run with only a small amount of stack space available.
3003 @item no_stack_limit
3004 @cindex @code{no_stack_limit} function attribute
3005 This attribute locally overrides the @option{-fstack-limit-register}
3006 and @option{-fstack-limit-symbol} command-line options; it has the effect
3007 of disabling stack limit checking in the function it applies to.
3009 @item noclone
3010 @cindex @code{noclone} function attribute
3011 This function attribute prevents a function from being considered for
3012 cloning---a mechanism that produces specialized copies of functions
3013 and which is (currently) performed by interprocedural constant
3014 propagation.
3016 @item noinline
3017 @cindex @code{noinline} function attribute
3018 This function attribute prevents a function from being considered for
3019 inlining.
3020 @c Don't enumerate the optimizations by name here; we try to be
3021 @c future-compatible with this mechanism.
3022 If the function does not have side effects, there are optimizations
3023 other than inlining that cause function calls to be optimized away,
3024 although the function call is live.  To keep such calls from being
3025 optimized away, put
3026 @smallexample
3027 asm ("");
3028 @end smallexample
3030 @noindent
3031 (@pxref{Extended Asm}) in the called function, to serve as a special
3032 side effect.
3034 @item noipa
3035 @cindex @code{noipa} function attribute
3036 Disable interprocedural optimizations between the function with this
3037 attribute and its callers, as if the body of the function is not available
3038 when optimizing callers and the callers are unavailable when optimizing
3039 the body.  This attribute implies @code{noinline}, @code{noclone} and
3040 @code{no_icf} attributes.    However, this attribute is not equivalent
3041 to a combination of other attributes, because its purpose is to suppress
3042 existing and future optimizations employing interprocedural analysis,
3043 including those that do not have an attribute suitable for disabling
3044 them individually.  This attribute is supported mainly for the purpose
3045 of testing the compiler.
3047 @item nonnull (@var{arg-index}, @dots{})
3048 @cindex @code{nonnull} function attribute
3049 @cindex functions with non-null pointer arguments
3050 The @code{nonnull} attribute specifies that some function parameters should
3051 be non-null pointers.  For instance, the declaration:
3053 @smallexample
3054 extern void *
3055 my_memcpy (void *dest, const void *src, size_t len)
3056         __attribute__((nonnull (1, 2)));
3057 @end smallexample
3059 @noindent
3060 causes the compiler to check that, in calls to @code{my_memcpy},
3061 arguments @var{dest} and @var{src} are non-null.  If the compiler
3062 determines that a null pointer is passed in an argument slot marked
3063 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3064 is issued.  The compiler may also choose to make optimizations based
3065 on the knowledge that certain function arguments will never be null.
3067 If no argument index list is given to the @code{nonnull} attribute,
3068 all pointer arguments are marked as non-null.  To illustrate, the
3069 following declaration is equivalent to the previous example:
3071 @smallexample
3072 extern void *
3073 my_memcpy (void *dest, const void *src, size_t len)
3074         __attribute__((nonnull));
3075 @end smallexample
3077 @item noplt
3078 @cindex @code{noplt} function attribute
3079 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3080 Calls to functions marked with this attribute in position-independent code
3081 do not use the PLT.
3083 @smallexample
3084 @group
3085 /* Externally defined function foo.  */
3086 int foo () __attribute__ ((noplt));
3089 main (/* @r{@dots{}} */)
3091   /* @r{@dots{}} */
3092   foo ();
3093   /* @r{@dots{}} */
3095 @end group
3096 @end smallexample
3098 The @code{noplt} attribute on function @code{foo}
3099 tells the compiler to assume that
3100 the function @code{foo} is externally defined and that the call to
3101 @code{foo} must avoid the PLT
3102 in position-independent code.
3104 In position-dependent code, a few targets also convert calls to
3105 functions that are marked to not use the PLT to use the GOT instead.
3107 @item noreturn
3108 @cindex @code{noreturn} function attribute
3109 @cindex functions that never return
3110 A few standard library functions, such as @code{abort} and @code{exit},
3111 cannot return.  GCC knows this automatically.  Some programs define
3112 their own functions that never return.  You can declare them
3113 @code{noreturn} to tell the compiler this fact.  For example,
3115 @smallexample
3116 @group
3117 void fatal () __attribute__ ((noreturn));
3119 void
3120 fatal (/* @r{@dots{}} */)
3122   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3123   exit (1);
3125 @end group
3126 @end smallexample
3128 The @code{noreturn} keyword tells the compiler to assume that
3129 @code{fatal} cannot return.  It can then optimize without regard to what
3130 would happen if @code{fatal} ever did return.  This makes slightly
3131 better code.  More importantly, it helps avoid spurious warnings of
3132 uninitialized variables.
3134 The @code{noreturn} keyword does not affect the exceptional path when that
3135 applies: a @code{noreturn}-marked function may still return to the caller
3136 by throwing an exception or calling @code{longjmp}.
3138 Do not assume that registers saved by the calling function are
3139 restored before calling the @code{noreturn} function.
3141 It does not make sense for a @code{noreturn} function to have a return
3142 type other than @code{void}.
3144 @item nothrow
3145 @cindex @code{nothrow} function attribute
3146 The @code{nothrow} attribute is used to inform the compiler that a
3147 function cannot throw an exception.  For example, most functions in
3148 the standard C library can be guaranteed not to throw an exception
3149 with the notable exceptions of @code{qsort} and @code{bsearch} that
3150 take function pointer arguments.
3152 @item optimize
3153 @cindex @code{optimize} function attribute
3154 The @code{optimize} attribute is used to specify that a function is to
3155 be compiled with different optimization options than specified on the
3156 command line.  Arguments can either be numbers or strings.  Numbers
3157 are assumed to be an optimization level.  Strings that begin with
3158 @code{O} are assumed to be an optimization option, while other options
3159 are assumed to be used with a @code{-f} prefix.  You can also use the
3160 @samp{#pragma GCC optimize} pragma to set the optimization options
3161 that affect more than one function.
3162 @xref{Function Specific Option Pragmas}, for details about the
3163 @samp{#pragma GCC optimize} pragma.
3165 This attribute should be used for debugging purposes only.  It is not
3166 suitable in production code.
3168 @item patchable_function_entry
3169 @cindex @code{patchable_function_entry} function attribute
3170 @cindex extra NOP instructions at the function entry point
3171 In case the target's text segment can be made writable at run time by
3172 any means, padding the function entry with a number of NOPs can be
3173 used to provide a universal tool for instrumentation.
3175 The @code{patchable_function_entry} function attribute can be used to
3176 change the number of NOPs to any desired value.  The two-value syntax
3177 is the same as for the command-line switch
3178 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3179 the function entry point before the @var{M}th NOP instruction.
3180 @var{M} defaults to 0 if omitted e.g. function entry point is before
3181 the first NOP.
3183 If patchable function entries are enabled globally using the command-line
3184 option @option{-fpatchable-function-entry=N,M}, then you must disable
3185 instrumentation on all functions that are part of the instrumentation
3186 framework with the attribute @code{patchable_function_entry (0)}
3187 to prevent recursion.
3189 @item pure
3190 @cindex @code{pure} function attribute
3191 @cindex functions that have no side effects
3192 Many functions have no effects except the return value and their
3193 return value depends only on the parameters and/or global variables.
3194 Calls to such functions can be subject
3195 to common subexpression elimination and loop optimization just as an
3196 arithmetic operator would be.  These functions should be declared
3197 with the attribute @code{pure}.  For example,
3199 @smallexample
3200 int square (int) __attribute__ ((pure));
3201 @end smallexample
3203 @noindent
3204 says that the hypothetical function @code{square} is safe to call
3205 fewer times than the program says.
3207 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3208 Interesting non-pure functions are functions with infinite loops or those
3209 depending on volatile memory or other system resource, that may change between
3210 two consecutive calls (such as @code{feof} in a multithreading environment).
3212 The @code{pure} attribute imposes similar but looser restrictions on
3213 a function's defintion than the @code{const} attribute: it allows the
3214 function to read global variables.  Decorating the same function with
3215 both the @code{pure} and the @code{const} attribute is diagnosed.
3216 Because a @code{pure} function cannot have any side effects it does not
3217 make sense for such a function to return @code{void}.  Declaring such
3218 a function is diagnosed.
3220 @item returns_nonnull
3221 @cindex @code{returns_nonnull} function attribute
3222 The @code{returns_nonnull} attribute specifies that the function
3223 return value should be a non-null pointer.  For instance, the declaration:
3225 @smallexample
3226 extern void *
3227 mymalloc (size_t len) __attribute__((returns_nonnull));
3228 @end smallexample
3230 @noindent
3231 lets the compiler optimize callers based on the knowledge
3232 that the return value will never be null.
3234 @item returns_twice
3235 @cindex @code{returns_twice} function attribute
3236 @cindex functions that return more than once
3237 The @code{returns_twice} attribute tells the compiler that a function may
3238 return more than one time.  The compiler ensures that all registers
3239 are dead before calling such a function and emits a warning about
3240 the variables that may be clobbered after the second return from the
3241 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3242 The @code{longjmp}-like counterpart of such function, if any, might need
3243 to be marked with the @code{noreturn} attribute.
3245 @item section ("@var{section-name}")
3246 @cindex @code{section} function attribute
3247 @cindex functions in arbitrary sections
3248 Normally, the compiler places the code it generates in the @code{text} section.
3249 Sometimes, however, you need additional sections, or you need certain
3250 particular functions to appear in special sections.  The @code{section}
3251 attribute specifies that a function lives in a particular section.
3252 For example, the declaration:
3254 @smallexample
3255 extern void foobar (void) __attribute__ ((section ("bar")));
3256 @end smallexample
3258 @noindent
3259 puts the function @code{foobar} in the @code{bar} section.
3261 Some file formats do not support arbitrary sections so the @code{section}
3262 attribute is not available on all platforms.
3263 If you need to map the entire contents of a module to a particular
3264 section, consider using the facilities of the linker instead.
3266 @item sentinel
3267 @cindex @code{sentinel} function attribute
3268 This function attribute ensures that a parameter in a function call is
3269 an explicit @code{NULL}.  The attribute is only valid on variadic
3270 functions.  By default, the sentinel is located at position zero, the
3271 last parameter of the function call.  If an optional integer position
3272 argument P is supplied to the attribute, the sentinel must be located at
3273 position P counting backwards from the end of the argument list.
3275 @smallexample
3276 __attribute__ ((sentinel))
3277 is equivalent to
3278 __attribute__ ((sentinel(0)))
3279 @end smallexample
3281 The attribute is automatically set with a position of 0 for the built-in
3282 functions @code{execl} and @code{execlp}.  The built-in function
3283 @code{execle} has the attribute set with a position of 1.
3285 A valid @code{NULL} in this context is defined as zero with any pointer
3286 type.  If your system defines the @code{NULL} macro with an integer type
3287 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3288 with a copy that redefines NULL appropriately.
3290 The warnings for missing or incorrect sentinels are enabled with
3291 @option{-Wformat}.
3293 @item simd
3294 @itemx simd("@var{mask}")
3295 @cindex @code{simd} function attribute
3296 This attribute enables creation of one or more function versions that
3297 can process multiple arguments using SIMD instructions from a
3298 single invocation.  Specifying this attribute allows compiler to
3299 assume that such versions are available at link time (provided
3300 in the same or another translation unit).  Generated versions are
3301 target-dependent and described in the corresponding Vector ABI document.  For
3302 x86_64 target this document can be found
3303 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3305 The optional argument @var{mask} may have the value
3306 @code{notinbranch} or @code{inbranch},
3307 and instructs the compiler to generate non-masked or masked
3308 clones correspondingly. By default, all clones are generated.
3310 If the attribute is specified and @code{#pragma omp declare simd} is
3311 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3312 switch is specified, then the attribute is ignored.
3314 @item stack_protect
3315 @cindex @code{stack_protect} function attribute
3316 This attribute adds stack protection code to the function if 
3317 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3318 or @option{-fstack-protector-explicit} are set.
3320 @item target (@var{options})
3321 @cindex @code{target} function attribute
3322 Multiple target back ends implement the @code{target} attribute
3323 to specify that a function is to
3324 be compiled with different target options than specified on the
3325 command line.  This can be used for instance to have functions
3326 compiled with a different ISA (instruction set architecture) than the
3327 default.  You can also use the @samp{#pragma GCC target} pragma to set
3328 more than one function to be compiled with specific target options.
3329 @xref{Function Specific Option Pragmas}, for details about the
3330 @samp{#pragma GCC target} pragma.
3332 For instance, on an x86, you could declare one function with the
3333 @code{target("sse4.1,arch=core2")} attribute and another with
3334 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3335 compiling the first function with @option{-msse4.1} and
3336 @option{-march=core2} options, and the second function with
3337 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3338 to make sure that a function is only invoked on a machine that
3339 supports the particular ISA it is compiled for (for example by using
3340 @code{cpuid} on x86 to determine what feature bits and architecture
3341 family are used).
3343 @smallexample
3344 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3345 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3346 @end smallexample
3348 You can either use multiple
3349 strings separated by commas to specify multiple options,
3350 or separate the options with a comma (@samp{,}) within a single string.
3352 The options supported are specific to each target; refer to @ref{x86
3353 Function Attributes}, @ref{PowerPC Function Attributes},
3354 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3355 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3356 for details.
3358 @item target_clones (@var{options})
3359 @cindex @code{target_clones} function attribute
3360 The @code{target_clones} attribute is used to specify that a function
3361 be cloned into multiple versions compiled with different target options
3362 than specified on the command line.  The supported options and restrictions
3363 are the same as for @code{target} attribute.
3365 For instance, on an x86, you could compile a function with
3366 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3367 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3369 On a PowerPC, you can compile a function with
3370 @code{target_clones("cpu=power9,default")}.  GCC will create two
3371 function clones, one compiled with @option{-mcpu=power9} and another
3372 with the default options.  GCC must be configured to use GLIBC 2.23 or
3373 newer in order to use the @code{target_clones} attribute.
3375 It also creates a resolver function (see
3376 the @code{ifunc} attribute above) that dynamically selects a clone
3377 suitable for current architecture.  The resolver is created only if there
3378 is a usage of a function with @code{target_clones} attribute.
3380 @item unused
3381 @cindex @code{unused} function attribute
3382 This attribute, attached to a function, means that the function is meant
3383 to be possibly unused.  GCC does not produce a warning for this
3384 function.
3386 @item used
3387 @cindex @code{used} function attribute
3388 This attribute, attached to a function, means that code must be emitted
3389 for the function even if it appears that the function is not referenced.
3390 This is useful, for example, when the function is referenced only in
3391 inline assembly.
3393 When applied to a member function of a C++ class template, the
3394 attribute also means that the function is instantiated if the
3395 class itself is instantiated.
3397 @item visibility ("@var{visibility_type}")
3398 @cindex @code{visibility} function attribute
3399 This attribute affects the linkage of the declaration to which it is attached.
3400 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3401 (@pxref{Common Type Attributes}) as well as functions.
3403 There are four supported @var{visibility_type} values: default,
3404 hidden, protected or internal visibility.
3406 @smallexample
3407 void __attribute__ ((visibility ("protected")))
3408 f () @{ /* @r{Do something.} */; @}
3409 int i __attribute__ ((visibility ("hidden")));
3410 @end smallexample
3412 The possible values of @var{visibility_type} correspond to the
3413 visibility settings in the ELF gABI.
3415 @table @code
3416 @c keep this list of visibilities in alphabetical order.
3418 @item default
3419 Default visibility is the normal case for the object file format.
3420 This value is available for the visibility attribute to override other
3421 options that may change the assumed visibility of entities.
3423 On ELF, default visibility means that the declaration is visible to other
3424 modules and, in shared libraries, means that the declared entity may be
3425 overridden.
3427 On Darwin, default visibility means that the declaration is visible to
3428 other modules.
3430 Default visibility corresponds to ``external linkage'' in the language.
3432 @item hidden
3433 Hidden visibility indicates that the entity declared has a new
3434 form of linkage, which we call ``hidden linkage''.  Two
3435 declarations of an object with hidden linkage refer to the same object
3436 if they are in the same shared object.
3438 @item internal
3439 Internal visibility is like hidden visibility, but with additional
3440 processor specific semantics.  Unless otherwise specified by the
3441 psABI, GCC defines internal visibility to mean that a function is
3442 @emph{never} called from another module.  Compare this with hidden
3443 functions which, while they cannot be referenced directly by other
3444 modules, can be referenced indirectly via function pointers.  By
3445 indicating that a function cannot be called from outside the module,
3446 GCC may for instance omit the load of a PIC register since it is known
3447 that the calling function loaded the correct value.
3449 @item protected
3450 Protected visibility is like default visibility except that it
3451 indicates that references within the defining module bind to the
3452 definition in that module.  That is, the declared entity cannot be
3453 overridden by another module.
3455 @end table
3457 All visibilities are supported on many, but not all, ELF targets
3458 (supported when the assembler supports the @samp{.visibility}
3459 pseudo-op).  Default visibility is supported everywhere.  Hidden
3460 visibility is supported on Darwin targets.
3462 The visibility attribute should be applied only to declarations that
3463 would otherwise have external linkage.  The attribute should be applied
3464 consistently, so that the same entity should not be declared with
3465 different settings of the attribute.
3467 In C++, the visibility attribute applies to types as well as functions
3468 and objects, because in C++ types have linkage.  A class must not have
3469 greater visibility than its non-static data member types and bases,
3470 and class members default to the visibility of their class.  Also, a
3471 declaration without explicit visibility is limited to the visibility
3472 of its type.
3474 In C++, you can mark member functions and static member variables of a
3475 class with the visibility attribute.  This is useful if you know a
3476 particular method or static member variable should only be used from
3477 one shared object; then you can mark it hidden while the rest of the
3478 class has default visibility.  Care must be taken to avoid breaking
3479 the One Definition Rule; for example, it is usually not useful to mark
3480 an inline method as hidden without marking the whole class as hidden.
3482 A C++ namespace declaration can also have the visibility attribute.
3484 @smallexample
3485 namespace nspace1 __attribute__ ((visibility ("protected")))
3486 @{ /* @r{Do something.} */; @}
3487 @end smallexample
3489 This attribute applies only to the particular namespace body, not to
3490 other definitions of the same namespace; it is equivalent to using
3491 @samp{#pragma GCC visibility} before and after the namespace
3492 definition (@pxref{Visibility Pragmas}).
3494 In C++, if a template argument has limited visibility, this
3495 restriction is implicitly propagated to the template instantiation.
3496 Otherwise, template instantiations and specializations default to the
3497 visibility of their template.
3499 If both the template and enclosing class have explicit visibility, the
3500 visibility from the template is used.
3502 @item warn_unused_result
3503 @cindex @code{warn_unused_result} function attribute
3504 The @code{warn_unused_result} attribute causes a warning to be emitted
3505 if a caller of the function with this attribute does not use its
3506 return value.  This is useful for functions where not checking
3507 the result is either a security problem or always a bug, such as
3508 @code{realloc}.
3510 @smallexample
3511 int fn () __attribute__ ((warn_unused_result));
3512 int foo ()
3514   if (fn () < 0) return -1;
3515   fn ();
3516   return 0;
3518 @end smallexample
3520 @noindent
3521 results in warning on line 5.
3523 @item weak
3524 @cindex @code{weak} function attribute
3525 The @code{weak} attribute causes the declaration to be emitted as a weak
3526 symbol rather than a global.  This is primarily useful in defining
3527 library functions that can be overridden in user code, though it can
3528 also be used with non-function declarations.  Weak symbols are supported
3529 for ELF targets, and also for a.out targets when using the GNU assembler
3530 and linker.
3532 @item weakref
3533 @itemx weakref ("@var{target}")
3534 @cindex @code{weakref} function attribute
3535 The @code{weakref} attribute marks a declaration as a weak reference.
3536 Without arguments, it should be accompanied by an @code{alias} attribute
3537 naming the target symbol.  Optionally, the @var{target} may be given as
3538 an argument to @code{weakref} itself.  In either case, @code{weakref}
3539 implicitly marks the declaration as @code{weak}.  Without a
3540 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3541 @code{weakref} is equivalent to @code{weak}.
3543 @smallexample
3544 static int x() __attribute__ ((weakref ("y")));
3545 /* is equivalent to... */
3546 static int x() __attribute__ ((weak, weakref, alias ("y")));
3547 /* and to... */
3548 static int x() __attribute__ ((weakref));
3549 static int x() __attribute__ ((alias ("y")));
3550 @end smallexample
3552 A weak reference is an alias that does not by itself require a
3553 definition to be given for the target symbol.  If the target symbol is
3554 only referenced through weak references, then it becomes a @code{weak}
3555 undefined symbol.  If it is directly referenced, however, then such
3556 strong references prevail, and a definition is required for the
3557 symbol, not necessarily in the same translation unit.
3559 The effect is equivalent to moving all references to the alias to a
3560 separate translation unit, renaming the alias to the aliased symbol,
3561 declaring it as weak, compiling the two separate translation units and
3562 performing a reloadable link on them.
3564 At present, a declaration to which @code{weakref} is attached can
3565 only be @code{static}.
3568 @end table
3570 @c This is the end of the target-independent attribute table
3572 @node AArch64 Function Attributes
3573 @subsection AArch64 Function Attributes
3575 The following target-specific function attributes are available for the
3576 AArch64 target.  For the most part, these options mirror the behavior of
3577 similar command-line options (@pxref{AArch64 Options}), but on a
3578 per-function basis.
3580 @table @code
3581 @item general-regs-only
3582 @cindex @code{general-regs-only} function attribute, AArch64
3583 Indicates that no floating-point or Advanced SIMD registers should be
3584 used when generating code for this function.  If the function explicitly
3585 uses floating-point code, then the compiler gives an error.  This is
3586 the same behavior as that of the command-line option
3587 @option{-mgeneral-regs-only}.
3589 @item fix-cortex-a53-835769
3590 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3591 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3592 applied to this function.  To explicitly disable the workaround for this
3593 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3594 This corresponds to the behavior of the command line options
3595 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3597 @item cmodel=
3598 @cindex @code{cmodel=} function attribute, AArch64
3599 Indicates that code should be generated for a particular code model for
3600 this function.  The behavior and permissible arguments are the same as
3601 for the command line option @option{-mcmodel=}.
3603 @item strict-align
3604 @itemx no-strict-align
3605 @cindex @code{strict-align} function attribute, AArch64
3606 @code{strict-align} indicates that the compiler should not assume that unaligned
3607 memory references are handled by the system.  To allow the compiler to assume
3608 that aligned memory references are handled by the system, the inverse attribute
3609 @code{no-strict-align} can be specified.  The behavior is same as for the
3610 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3612 @item omit-leaf-frame-pointer
3613 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3614 Indicates that the frame pointer should be omitted for a leaf function call.
3615 To keep the frame pointer, the inverse attribute
3616 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3617 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3618 and @option{-mno-omit-leaf-frame-pointer}.
3620 @item tls-dialect=
3621 @cindex @code{tls-dialect=} function attribute, AArch64
3622 Specifies the TLS dialect to use for this function.  The behavior and
3623 permissible arguments are the same as for the command-line option
3624 @option{-mtls-dialect=}.
3626 @item arch=
3627 @cindex @code{arch=} function attribute, AArch64
3628 Specifies the architecture version and architectural extensions to use
3629 for this function.  The behavior and permissible arguments are the same as
3630 for the @option{-march=} command-line option.
3632 @item tune=
3633 @cindex @code{tune=} function attribute, AArch64
3634 Specifies the core for which to tune the performance of this function.
3635 The behavior and permissible arguments are the same as for the @option{-mtune=}
3636 command-line option.
3638 @item cpu=
3639 @cindex @code{cpu=} function attribute, AArch64
3640 Specifies the core for which to tune the performance of this function and also
3641 whose architectural features to use.  The behavior and valid arguments are the
3642 same as for the @option{-mcpu=} command-line option.
3644 @item sign-return-address
3645 @cindex @code{sign-return-address} function attribute, AArch64
3646 Select the function scope on which return address signing will be applied.  The
3647 behavior and permissible arguments are the same as for the command-line option
3648 @option{-msign-return-address=}.  The default value is @code{none}.
3650 @end table
3652 The above target attributes can be specified as follows:
3654 @smallexample
3655 __attribute__((target("@var{attr-string}")))
3657 f (int a)
3659   return a + 5;
3661 @end smallexample
3663 where @code{@var{attr-string}} is one of the attribute strings specified above.
3665 Additionally, the architectural extension string may be specified on its
3666 own.  This can be used to turn on and off particular architectural extensions
3667 without having to specify a particular architecture version or core.  Example:
3669 @smallexample
3670 __attribute__((target("+crc+nocrypto")))
3672 foo (int a)
3674   return a + 5;
3676 @end smallexample
3678 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3679 extension and disables the @code{crypto} extension for the function @code{foo}
3680 without modifying an existing @option{-march=} or @option{-mcpu} option.
3682 Multiple target function attributes can be specified by separating them with
3683 a comma.  For example:
3684 @smallexample
3685 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3687 foo (int a)
3689   return a + 5;
3691 @end smallexample
3693 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3694 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3696 @subsubsection Inlining rules
3697 Specifying target attributes on individual functions or performing link-time
3698 optimization across translation units compiled with different target options
3699 can affect function inlining rules:
3701 In particular, a caller function can inline a callee function only if the
3702 architectural features available to the callee are a subset of the features
3703 available to the caller.
3704 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3705 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3706 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3707 because the all the architectural features that function @code{bar} requires
3708 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3709 inline function @code{foo}.
3711 Additionally inlining a function compiled with @option{-mstrict-align} into a
3712 function compiled without @code{-mstrict-align} is not allowed.
3713 However, inlining a function compiled without @option{-mstrict-align} into a
3714 function compiled with @option{-mstrict-align} is allowed.
3716 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3717 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3718 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3719 architectural feature rules specified above.
3721 @node ARC Function Attributes
3722 @subsection ARC Function Attributes
3724 These function attributes are supported by the ARC back end:
3726 @table @code
3727 @item interrupt
3728 @cindex @code{interrupt} function attribute, ARC
3729 Use this attribute to indicate
3730 that the specified function is an interrupt handler.  The compiler generates
3731 function entry and exit sequences suitable for use in an interrupt handler
3732 when this attribute is present.
3734 On the ARC, you must specify the kind of interrupt to be handled
3735 in a parameter to the interrupt attribute like this:
3737 @smallexample
3738 void f () __attribute__ ((interrupt ("ilink1")));
3739 @end smallexample
3741 Permissible values for this parameter are: @w{@code{ilink1}} and
3742 @w{@code{ilink2}}.
3744 @item long_call
3745 @itemx medium_call
3746 @itemx short_call
3747 @cindex @code{long_call} function attribute, ARC
3748 @cindex @code{medium_call} function attribute, ARC
3749 @cindex @code{short_call} function attribute, ARC
3750 @cindex indirect calls, ARC
3751 These attributes specify how a particular function is called.
3752 These attributes override the
3753 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3754 command-line switches and @code{#pragma long_calls} settings.
3756 For ARC, a function marked with the @code{long_call} attribute is
3757 always called using register-indirect jump-and-link instructions,
3758 thereby enabling the called function to be placed anywhere within the
3759 32-bit address space.  A function marked with the @code{medium_call}
3760 attribute will always be close enough to be called with an unconditional
3761 branch-and-link instruction, which has a 25-bit offset from
3762 the call site.  A function marked with the @code{short_call}
3763 attribute will always be close enough to be called with a conditional
3764 branch-and-link instruction, which has a 21-bit offset from
3765 the call site.
3767 @item jli_always
3768 @cindex @code{jli_always} function attribute, ARC
3769 Forces a particular function to be called using @code{jli}
3770 instruction.  The @code{jli} instruction makes use of a table stored
3771 into @code{.jlitab} section, which holds the location of the functions
3772 which are addressed using this instruction.
3774 @item jli_fixed
3775 @cindex @code{jli_fixed} function attribute, ARC
3776 Identical like the above one, but the location of the function in the
3777 @code{jli} table is known and given as an attribute parameter.
3779 @item secure_call
3780 @cindex @code{secure_call} function attribute, ARC
3781 This attribute allows one to mark secure-code functions that are
3782 callable from normal mode.  The location of the secure call function
3783 into the @code{sjli} table needs to be passed as argument.
3785 @end table
3787 @node ARM Function Attributes
3788 @subsection ARM Function Attributes
3790 These function attributes are supported for ARM targets:
3792 @table @code
3793 @item interrupt
3794 @cindex @code{interrupt} function attribute, ARM
3795 Use this attribute to indicate
3796 that the specified function is an interrupt handler.  The compiler generates
3797 function entry and exit sequences suitable for use in an interrupt handler
3798 when this attribute is present.
3800 You can specify the kind of interrupt to be handled by
3801 adding an optional parameter to the interrupt attribute like this:
3803 @smallexample
3804 void f () __attribute__ ((interrupt ("IRQ")));
3805 @end smallexample
3807 @noindent
3808 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3809 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3811 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3812 may be called with a word-aligned stack pointer.
3814 @item isr
3815 @cindex @code{isr} function attribute, ARM
3816 Use this attribute on ARM to write Interrupt Service Routines. This is an
3817 alias to the @code{interrupt} attribute above.
3819 @item long_call
3820 @itemx short_call
3821 @cindex @code{long_call} function attribute, ARM
3822 @cindex @code{short_call} function attribute, ARM
3823 @cindex indirect calls, ARM
3824 These attributes specify how a particular function is called.
3825 These attributes override the
3826 @option{-mlong-calls} (@pxref{ARM Options})
3827 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3828 @code{long_call} attribute indicates that the function might be far
3829 away from the call site and require a different (more expensive)
3830 calling sequence.   The @code{short_call} attribute always places
3831 the offset to the function from the call site into the @samp{BL}
3832 instruction directly.
3834 @item naked
3835 @cindex @code{naked} function attribute, ARM
3836 This attribute allows the compiler to construct the
3837 requisite function declaration, while allowing the body of the
3838 function to be assembly code. The specified function will not have
3839 prologue/epilogue sequences generated by the compiler. Only basic
3840 @code{asm} statements can safely be included in naked functions
3841 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3842 basic @code{asm} and C code may appear to work, they cannot be
3843 depended upon to work reliably and are not supported.
3845 @item pcs
3846 @cindex @code{pcs} function attribute, ARM
3848 The @code{pcs} attribute can be used to control the calling convention
3849 used for a function on ARM.  The attribute takes an argument that specifies
3850 the calling convention to use.
3852 When compiling using the AAPCS ABI (or a variant of it) then valid
3853 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3854 order to use a variant other than @code{"aapcs"} then the compiler must
3855 be permitted to use the appropriate co-processor registers (i.e., the
3856 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3857 For example,
3859 @smallexample
3860 /* Argument passed in r0, and result returned in r0+r1.  */
3861 double f2d (float) __attribute__((pcs("aapcs")));
3862 @end smallexample
3864 Variadic functions always use the @code{"aapcs"} calling convention and
3865 the compiler rejects attempts to specify an alternative.
3867 @item target (@var{options})
3868 @cindex @code{target} function attribute
3869 As discussed in @ref{Common Function Attributes}, this attribute 
3870 allows specification of target-specific compilation options.
3872 On ARM, the following options are allowed:
3874 @table @samp
3875 @item thumb
3876 @cindex @code{target("thumb")} function attribute, ARM
3877 Force code generation in the Thumb (T16/T32) ISA, depending on the
3878 architecture level.
3880 @item arm
3881 @cindex @code{target("arm")} function attribute, ARM
3882 Force code generation in the ARM (A32) ISA.
3884 Functions from different modes can be inlined in the caller's mode.
3886 @item fpu=
3887 @cindex @code{target("fpu=")} function attribute, ARM
3888 Specifies the fpu for which to tune the performance of this function.
3889 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3890 command-line option.
3892 @item arch=
3893 @cindex @code{arch=} function attribute, ARM
3894 Specifies the architecture version and architectural extensions to use
3895 for this function.  The behavior and permissible arguments are the same as
3896 for the @option{-march=} command-line option.
3898 The above target attributes can be specified as follows:
3900 @smallexample
3901 __attribute__((target("arch=armv8-a+crc")))
3903 f (int a)
3905   return a + 5;
3907 @end smallexample
3909 Additionally, the architectural extension string may be specified on its
3910 own.  This can be used to turn on and off particular architectural extensions
3911 without having to specify a particular architecture version or core.  Example:
3913 @smallexample
3914 __attribute__((target("+crc+nocrypto")))
3916 foo (int a)
3918   return a + 5;
3920 @end smallexample
3922 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3923 extension and disables the @code{crypto} extension for the function @code{foo}
3924 without modifying an existing @option{-march=} or @option{-mcpu} option.
3926 @end table
3928 @end table
3930 @node AVR Function Attributes
3931 @subsection AVR Function Attributes
3933 These function attributes are supported by the AVR back end:
3935 @table @code
3936 @item interrupt
3937 @cindex @code{interrupt} function attribute, AVR
3938 Use this attribute to indicate
3939 that the specified function is an interrupt handler.  The compiler generates
3940 function entry and exit sequences suitable for use in an interrupt handler
3941 when this attribute is present.
3943 On the AVR, the hardware globally disables interrupts when an
3944 interrupt is executed.  The first instruction of an interrupt handler
3945 declared with this attribute is a @code{SEI} instruction to
3946 re-enable interrupts.  See also the @code{signal} function attribute
3947 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3948 @code{interrupt} are specified for the same function, @code{signal}
3949 is silently ignored.
3951 @item naked
3952 @cindex @code{naked} function attribute, AVR
3953 This attribute allows the compiler to construct the
3954 requisite function declaration, while allowing the body of the
3955 function to be assembly code. The specified function will not have
3956 prologue/epilogue sequences generated by the compiler. Only basic
3957 @code{asm} statements can safely be included in naked functions
3958 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3959 basic @code{asm} and C code may appear to work, they cannot be
3960 depended upon to work reliably and are not supported.
3962 @item no_gccisr
3963 @cindex @code{no_gccisr} function attribute, AVR
3964 Do not use @code{__gcc_isr} pseudo instructions in a function with
3965 the @code{interrupt} or @code{signal} attribute aka. interrupt
3966 service routine (ISR).
3967 Use this attribute if the preamble of the ISR prologue should always read
3968 @example
3969 push  __zero_reg__
3970 push  __tmp_reg__
3971 in    __tmp_reg__, __SREG__
3972 push  __tmp_reg__
3973 clr   __zero_reg__
3974 @end example
3975 and accordingly for the postamble of the epilogue --- no matter whether
3976 the mentioned registers are actually used in the ISR or not.
3977 Situations where you might want to use this attribute include:
3978 @itemize @bullet
3979 @item
3980 Code that (effectively) clobbers bits of @code{SREG} other than the
3981 @code{I}-flag by writing to the memory location of @code{SREG}.
3982 @item
3983 Code that uses inline assembler to jump to a different function which
3984 expects (parts of) the prologue code as outlined above to be present.
3985 @end itemize
3986 To disable @code{__gcc_isr} generation for the whole compilation unit,
3987 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
3989 @item OS_main
3990 @itemx OS_task
3991 @cindex @code{OS_main} function attribute, AVR
3992 @cindex @code{OS_task} function attribute, AVR
3993 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3994 do not save/restore any call-saved register in their prologue/epilogue.
3996 The @code{OS_main} attribute can be used when there @emph{is
3997 guarantee} that interrupts are disabled at the time when the function
3998 is entered.  This saves resources when the stack pointer has to be
3999 changed to set up a frame for local variables.
4001 The @code{OS_task} attribute can be used when there is @emph{no
4002 guarantee} that interrupts are disabled at that time when the function
4003 is entered like for, e@.g@. task functions in a multi-threading operating
4004 system. In that case, changing the stack pointer register is
4005 guarded by save/clear/restore of the global interrupt enable flag.
4007 The differences to the @code{naked} function attribute are:
4008 @itemize @bullet
4009 @item @code{naked} functions do not have a return instruction whereas 
4010 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4011 @code{RETI} return instruction.
4012 @item @code{naked} functions do not set up a frame for local variables
4013 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4014 as needed.
4015 @end itemize
4017 @item signal
4018 @cindex @code{signal} function attribute, AVR
4019 Use this attribute on the AVR to indicate that the specified
4020 function is an interrupt handler.  The compiler generates function
4021 entry and exit sequences suitable for use in an interrupt handler when this
4022 attribute is present.
4024 See also the @code{interrupt} function attribute. 
4026 The AVR hardware globally disables interrupts when an interrupt is executed.
4027 Interrupt handler functions defined with the @code{signal} attribute
4028 do not re-enable interrupts.  It is save to enable interrupts in a
4029 @code{signal} handler.  This ``save'' only applies to the code
4030 generated by the compiler and not to the IRQ layout of the
4031 application which is responsibility of the application.
4033 If both @code{signal} and @code{interrupt} are specified for the same
4034 function, @code{signal} is silently ignored.
4035 @end table
4037 @node Blackfin Function Attributes
4038 @subsection Blackfin Function Attributes
4040 These function attributes are supported by the Blackfin back end:
4042 @table @code
4044 @item exception_handler
4045 @cindex @code{exception_handler} function attribute
4046 @cindex exception handler functions, Blackfin
4047 Use this attribute on the Blackfin to indicate that the specified function
4048 is an exception handler.  The compiler generates function entry and
4049 exit sequences suitable for use in an exception handler when this
4050 attribute is present.
4052 @item interrupt_handler
4053 @cindex @code{interrupt_handler} function attribute, Blackfin
4054 Use this attribute to
4055 indicate that the specified function is an interrupt handler.  The compiler
4056 generates function entry and exit sequences suitable for use in an
4057 interrupt handler when this attribute is present.
4059 @item kspisusp
4060 @cindex @code{kspisusp} function attribute, Blackfin
4061 @cindex User stack pointer in interrupts on the Blackfin
4062 When used together with @code{interrupt_handler}, @code{exception_handler}
4063 or @code{nmi_handler}, code is generated to load the stack pointer
4064 from the USP register in the function prologue.
4066 @item l1_text
4067 @cindex @code{l1_text} function attribute, Blackfin
4068 This attribute specifies a function to be placed into L1 Instruction
4069 SRAM@. The function is put into a specific section named @code{.l1.text}.
4070 With @option{-mfdpic}, function calls with a such function as the callee
4071 or caller uses inlined PLT.
4073 @item l2
4074 @cindex @code{l2} function attribute, Blackfin
4075 This attribute specifies a function to be placed into L2
4076 SRAM. The function is put into a specific section named
4077 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4078 an inlined PLT.
4080 @item longcall
4081 @itemx shortcall
4082 @cindex indirect calls, Blackfin
4083 @cindex @code{longcall} function attribute, Blackfin
4084 @cindex @code{shortcall} function attribute, Blackfin
4085 The @code{longcall} attribute
4086 indicates that the function might be far away from the call site and
4087 require a different (more expensive) calling sequence.  The
4088 @code{shortcall} attribute indicates that the function is always close
4089 enough for the shorter calling sequence to be used.  These attributes
4090 override the @option{-mlongcall} switch.
4092 @item nesting
4093 @cindex @code{nesting} function attribute, Blackfin
4094 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4095 Use this attribute together with @code{interrupt_handler},
4096 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4097 entry code should enable nested interrupts or exceptions.
4099 @item nmi_handler
4100 @cindex @code{nmi_handler} function attribute, Blackfin
4101 @cindex NMI handler functions on the Blackfin processor
4102 Use this attribute on the Blackfin to indicate that the specified function
4103 is an NMI handler.  The compiler generates function entry and
4104 exit sequences suitable for use in an NMI handler when this
4105 attribute is present.
4107 @item saveall
4108 @cindex @code{saveall} function attribute, Blackfin
4109 @cindex save all registers on the Blackfin
4110 Use this attribute to indicate that
4111 all registers except the stack pointer should be saved in the prologue
4112 regardless of whether they are used or not.
4113 @end table
4115 @node CR16 Function Attributes
4116 @subsection CR16 Function Attributes
4118 These function attributes are supported by the CR16 back end:
4120 @table @code
4121 @item interrupt
4122 @cindex @code{interrupt} function attribute, CR16
4123 Use this attribute to indicate
4124 that the specified function is an interrupt handler.  The compiler generates
4125 function entry and exit sequences suitable for use in an interrupt handler
4126 when this attribute is present.
4127 @end table
4129 @node Epiphany Function Attributes
4130 @subsection Epiphany Function Attributes
4132 These function attributes are supported by the Epiphany back end:
4134 @table @code
4135 @item disinterrupt
4136 @cindex @code{disinterrupt} function attribute, Epiphany
4137 This attribute causes the compiler to emit
4138 instructions to disable interrupts for the duration of the given
4139 function.
4141 @item forwarder_section
4142 @cindex @code{forwarder_section} function attribute, Epiphany
4143 This attribute modifies the behavior of an interrupt handler.
4144 The interrupt handler may be in external memory which cannot be
4145 reached by a branch instruction, so generate a local memory trampoline
4146 to transfer control.  The single parameter identifies the section where
4147 the trampoline is placed.
4149 @item interrupt
4150 @cindex @code{interrupt} function attribute, Epiphany
4151 Use this attribute to indicate
4152 that the specified function is an interrupt handler.  The compiler generates
4153 function entry and exit sequences suitable for use in an interrupt handler
4154 when this attribute is present.  It may also generate
4155 a special section with code to initialize the interrupt vector table.
4157 On Epiphany targets one or more optional parameters can be added like this:
4159 @smallexample
4160 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4161 @end smallexample
4163 Permissible values for these parameters are: @w{@code{reset}},
4164 @w{@code{software_exception}}, @w{@code{page_miss}},
4165 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4166 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4167 Multiple parameters indicate that multiple entries in the interrupt
4168 vector table should be initialized for this function, i.e.@: for each
4169 parameter @w{@var{name}}, a jump to the function is emitted in
4170 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4171 entirely, in which case no interrupt vector table entry is provided.
4173 Note that interrupts are enabled inside the function
4174 unless the @code{disinterrupt} attribute is also specified.
4176 The following examples are all valid uses of these attributes on
4177 Epiphany targets:
4178 @smallexample
4179 void __attribute__ ((interrupt)) universal_handler ();
4180 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4181 void __attribute__ ((interrupt ("dma0, dma1"))) 
4182   universal_dma_handler ();
4183 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4184   fast_timer_handler ();
4185 void __attribute__ ((interrupt ("dma0, dma1"), 
4186                      forwarder_section ("tramp")))
4187   external_dma_handler ();
4188 @end smallexample
4190 @item long_call
4191 @itemx short_call
4192 @cindex @code{long_call} function attribute, Epiphany
4193 @cindex @code{short_call} function attribute, Epiphany
4194 @cindex indirect calls, Epiphany
4195 These attributes specify how a particular function is called.
4196 These attributes override the
4197 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4198 command-line switch and @code{#pragma long_calls} settings.
4199 @end table
4202 @node H8/300 Function Attributes
4203 @subsection H8/300 Function Attributes
4205 These function attributes are available for H8/300 targets:
4207 @table @code
4208 @item function_vector
4209 @cindex @code{function_vector} function attribute, H8/300
4210 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4211 that the specified function should be called through the function vector.
4212 Calling a function through the function vector reduces code size; however,
4213 the function vector has a limited size (maximum 128 entries on the H8/300
4214 and 64 entries on the H8/300H and H8S)
4215 and shares space with the interrupt vector.
4217 @item interrupt_handler
4218 @cindex @code{interrupt_handler} function attribute, H8/300
4219 Use this attribute on the H8/300, H8/300H, and H8S to
4220 indicate that the specified function is an interrupt handler.  The compiler
4221 generates function entry and exit sequences suitable for use in an
4222 interrupt handler when this attribute is present.
4224 @item saveall
4225 @cindex @code{saveall} function attribute, H8/300
4226 @cindex save all registers on the H8/300, H8/300H, and H8S
4227 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4228 all registers except the stack pointer should be saved in the prologue
4229 regardless of whether they are used or not.
4230 @end table
4232 @node IA-64 Function Attributes
4233 @subsection IA-64 Function Attributes
4235 These function attributes are supported on IA-64 targets:
4237 @table @code
4238 @item syscall_linkage
4239 @cindex @code{syscall_linkage} function attribute, IA-64
4240 This attribute is used to modify the IA-64 calling convention by marking
4241 all input registers as live at all function exits.  This makes it possible
4242 to restart a system call after an interrupt without having to save/restore
4243 the input registers.  This also prevents kernel data from leaking into
4244 application code.
4246 @item version_id
4247 @cindex @code{version_id} function attribute, IA-64
4248 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4249 symbol to contain a version string, thus allowing for function level
4250 versioning.  HP-UX system header files may use function level versioning
4251 for some system calls.
4253 @smallexample
4254 extern int foo () __attribute__((version_id ("20040821")));
4255 @end smallexample
4257 @noindent
4258 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4259 @end table
4261 @node M32C Function Attributes
4262 @subsection M32C Function Attributes
4264 These function attributes are supported by the M32C back end:
4266 @table @code
4267 @item bank_switch
4268 @cindex @code{bank_switch} function attribute, M32C
4269 When added to an interrupt handler with the M32C port, causes the
4270 prologue and epilogue to use bank switching to preserve the registers
4271 rather than saving them on the stack.
4273 @item fast_interrupt
4274 @cindex @code{fast_interrupt} function attribute, M32C
4275 Use this attribute on the M32C port to indicate that the specified
4276 function is a fast interrupt handler.  This is just like the
4277 @code{interrupt} attribute, except that @code{freit} is used to return
4278 instead of @code{reit}.
4280 @item function_vector
4281 @cindex @code{function_vector} function attribute, M16C/M32C
4282 On M16C/M32C targets, the @code{function_vector} attribute declares a
4283 special page subroutine call function. Use of this attribute reduces
4284 the code size by 2 bytes for each call generated to the
4285 subroutine. The argument to the attribute is the vector number entry
4286 from the special page vector table which contains the 16 low-order
4287 bits of the subroutine's entry address. Each vector table has special
4288 page number (18 to 255) that is used in @code{jsrs} instructions.
4289 Jump addresses of the routines are generated by adding 0x0F0000 (in
4290 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4291 2-byte addresses set in the vector table. Therefore you need to ensure
4292 that all the special page vector routines should get mapped within the
4293 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4294 (for M32C).
4296 In the following example 2 bytes are saved for each call to
4297 function @code{foo}.
4299 @smallexample
4300 void foo (void) __attribute__((function_vector(0x18)));
4301 void foo (void)
4305 void bar (void)
4307     foo();
4309 @end smallexample
4311 If functions are defined in one file and are called in another file,
4312 then be sure to write this declaration in both files.
4314 This attribute is ignored for R8C target.
4316 @item interrupt
4317 @cindex @code{interrupt} function attribute, M32C
4318 Use this attribute to indicate
4319 that the specified function is an interrupt handler.  The compiler generates
4320 function entry and exit sequences suitable for use in an interrupt handler
4321 when this attribute is present.
4322 @end table
4324 @node M32R/D Function Attributes
4325 @subsection M32R/D Function Attributes
4327 These function attributes are supported by the M32R/D back end:
4329 @table @code
4330 @item interrupt
4331 @cindex @code{interrupt} function attribute, M32R/D
4332 Use this attribute to indicate
4333 that the specified function is an interrupt handler.  The compiler generates
4334 function entry and exit sequences suitable for use in an interrupt handler
4335 when this attribute is present.
4337 @item model (@var{model-name})
4338 @cindex @code{model} function attribute, M32R/D
4339 @cindex function addressability on the M32R/D
4341 On the M32R/D, use this attribute to set the addressability of an
4342 object, and of the code generated for a function.  The identifier
4343 @var{model-name} is one of @code{small}, @code{medium}, or
4344 @code{large}, representing each of the code models.
4346 Small model objects live in the lower 16MB of memory (so that their
4347 addresses can be loaded with the @code{ld24} instruction), and are
4348 callable with the @code{bl} instruction.
4350 Medium model objects may live anywhere in the 32-bit address space (the
4351 compiler generates @code{seth/add3} instructions to load their addresses),
4352 and are callable with the @code{bl} instruction.
4354 Large model objects may live anywhere in the 32-bit address space (the
4355 compiler generates @code{seth/add3} instructions to load their addresses),
4356 and may not be reachable with the @code{bl} instruction (the compiler
4357 generates the much slower @code{seth/add3/jl} instruction sequence).
4358 @end table
4360 @node m68k Function Attributes
4361 @subsection m68k Function Attributes
4363 These function attributes are supported by the m68k back end:
4365 @table @code
4366 @item interrupt
4367 @itemx interrupt_handler
4368 @cindex @code{interrupt} function attribute, m68k
4369 @cindex @code{interrupt_handler} function attribute, m68k
4370 Use this attribute to
4371 indicate that the specified function is an interrupt handler.  The compiler
4372 generates function entry and exit sequences suitable for use in an
4373 interrupt handler when this attribute is present.  Either name may be used.
4375 @item interrupt_thread
4376 @cindex @code{interrupt_thread} function attribute, fido
4377 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4378 that the specified function is an interrupt handler that is designed
4379 to run as a thread.  The compiler omits generate prologue/epilogue
4380 sequences and replaces the return instruction with a @code{sleep}
4381 instruction.  This attribute is available only on fido.
4382 @end table
4384 @node MCORE Function Attributes
4385 @subsection MCORE Function Attributes
4387 These function attributes are supported by the MCORE back end:
4389 @table @code
4390 @item naked
4391 @cindex @code{naked} function attribute, MCORE
4392 This attribute allows the compiler to construct the
4393 requisite function declaration, while allowing the body of the
4394 function to be assembly code. The specified function will not have
4395 prologue/epilogue sequences generated by the compiler. Only basic
4396 @code{asm} statements can safely be included in naked functions
4397 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4398 basic @code{asm} and C code may appear to work, they cannot be
4399 depended upon to work reliably and are not supported.
4400 @end table
4402 @node MeP Function Attributes
4403 @subsection MeP Function Attributes
4405 These function attributes are supported by the MeP back end:
4407 @table @code
4408 @item disinterrupt
4409 @cindex @code{disinterrupt} function attribute, MeP
4410 On MeP targets, this attribute causes the compiler to emit
4411 instructions to disable interrupts for the duration of the given
4412 function.
4414 @item interrupt
4415 @cindex @code{interrupt} function attribute, MeP
4416 Use this attribute to indicate
4417 that the specified function is an interrupt handler.  The compiler generates
4418 function entry and exit sequences suitable for use in an interrupt handler
4419 when this attribute is present.
4421 @item near
4422 @cindex @code{near} function attribute, MeP
4423 This attribute causes the compiler to assume the called
4424 function is close enough to use the normal calling convention,
4425 overriding the @option{-mtf} command-line option.
4427 @item far
4428 @cindex @code{far} function attribute, MeP
4429 On MeP targets this causes the compiler to use a calling convention
4430 that assumes the called function is too far away for the built-in
4431 addressing modes.
4433 @item vliw
4434 @cindex @code{vliw} function attribute, MeP
4435 The @code{vliw} attribute tells the compiler to emit
4436 instructions in VLIW mode instead of core mode.  Note that this
4437 attribute is not allowed unless a VLIW coprocessor has been configured
4438 and enabled through command-line options.
4439 @end table
4441 @node MicroBlaze Function Attributes
4442 @subsection MicroBlaze Function Attributes
4444 These function attributes are supported on MicroBlaze targets:
4446 @table @code
4447 @item save_volatiles
4448 @cindex @code{save_volatiles} function attribute, MicroBlaze
4449 Use this attribute to indicate that the function is
4450 an interrupt handler.  All volatile registers (in addition to non-volatile
4451 registers) are saved in the function prologue.  If the function is a leaf
4452 function, only volatiles used by the function are saved.  A normal function
4453 return is generated instead of a return from interrupt.
4455 @item break_handler
4456 @cindex @code{break_handler} function attribute, MicroBlaze
4457 @cindex break handler functions
4458 Use this attribute to indicate that
4459 the specified function is a break handler.  The compiler generates function
4460 entry and exit sequences suitable for use in an break handler when this
4461 attribute is present. The return from @code{break_handler} is done through
4462 the @code{rtbd} instead of @code{rtsd}.
4464 @smallexample
4465 void f () __attribute__ ((break_handler));
4466 @end smallexample
4468 @item interrupt_handler
4469 @itemx fast_interrupt 
4470 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4471 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4472 These attributes indicate that the specified function is an interrupt
4473 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4474 used in low-latency interrupt mode, and @code{interrupt_handler} for
4475 interrupts that do not use low-latency handlers.  In both cases, GCC
4476 emits appropriate prologue code and generates a return from the handler
4477 using @code{rtid} instead of @code{rtsd}.
4478 @end table
4480 @node Microsoft Windows Function Attributes
4481 @subsection Microsoft Windows Function Attributes
4483 The following attributes are available on Microsoft Windows and Symbian OS
4484 targets.
4486 @table @code
4487 @item dllexport
4488 @cindex @code{dllexport} function attribute
4489 @cindex @code{__declspec(dllexport)}
4490 On Microsoft Windows targets and Symbian OS targets the
4491 @code{dllexport} attribute causes the compiler to provide a global
4492 pointer to a pointer in a DLL, so that it can be referenced with the
4493 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4494 name is formed by combining @code{_imp__} and the function or variable
4495 name.
4497 You can use @code{__declspec(dllexport)} as a synonym for
4498 @code{__attribute__ ((dllexport))} for compatibility with other
4499 compilers.
4501 On systems that support the @code{visibility} attribute, this
4502 attribute also implies ``default'' visibility.  It is an error to
4503 explicitly specify any other visibility.
4505 GCC's default behavior is to emit all inline functions with the
4506 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4507 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4508 ignore the attribute for inlined functions unless the 
4509 @option{-fkeep-inline-functions} flag is used instead.
4511 The attribute is ignored for undefined symbols.
4513 When applied to C++ classes, the attribute marks defined non-inlined
4514 member functions and static data members as exports.  Static consts
4515 initialized in-class are not marked unless they are also defined
4516 out-of-class.
4518 For Microsoft Windows targets there are alternative methods for
4519 including the symbol in the DLL's export table such as using a
4520 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4521 the @option{--export-all} linker flag.
4523 @item dllimport
4524 @cindex @code{dllimport} function attribute
4525 @cindex @code{__declspec(dllimport)}
4526 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4527 attribute causes the compiler to reference a function or variable via
4528 a global pointer to a pointer that is set up by the DLL exporting the
4529 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4530 targets, the pointer name is formed by combining @code{_imp__} and the
4531 function or variable name.
4533 You can use @code{__declspec(dllimport)} as a synonym for
4534 @code{__attribute__ ((dllimport))} for compatibility with other
4535 compilers.
4537 On systems that support the @code{visibility} attribute, this
4538 attribute also implies ``default'' visibility.  It is an error to
4539 explicitly specify any other visibility.
4541 Currently, the attribute is ignored for inlined functions.  If the
4542 attribute is applied to a symbol @emph{definition}, an error is reported.
4543 If a symbol previously declared @code{dllimport} is later defined, the
4544 attribute is ignored in subsequent references, and a warning is emitted.
4545 The attribute is also overridden by a subsequent declaration as
4546 @code{dllexport}.
4548 When applied to C++ classes, the attribute marks non-inlined
4549 member functions and static data members as imports.  However, the
4550 attribute is ignored for virtual methods to allow creation of vtables
4551 using thunks.
4553 On the SH Symbian OS target the @code{dllimport} attribute also has
4554 another affect---it can cause the vtable and run-time type information
4555 for a class to be exported.  This happens when the class has a
4556 dllimported constructor or a non-inline, non-pure virtual function
4557 and, for either of those two conditions, the class also has an inline
4558 constructor or destructor and has a key function that is defined in
4559 the current translation unit.
4561 For Microsoft Windows targets the use of the @code{dllimport}
4562 attribute on functions is not necessary, but provides a small
4563 performance benefit by eliminating a thunk in the DLL@.  The use of the
4564 @code{dllimport} attribute on imported variables can be avoided by passing the
4565 @option{--enable-auto-import} switch to the GNU linker.  As with
4566 functions, using the attribute for a variable eliminates a thunk in
4567 the DLL@.
4569 One drawback to using this attribute is that a pointer to a
4570 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4571 address. However, a pointer to a @emph{function} with the
4572 @code{dllimport} attribute can be used as a constant initializer; in
4573 this case, the address of a stub function in the import lib is
4574 referenced.  On Microsoft Windows targets, the attribute can be disabled
4575 for functions by setting the @option{-mnop-fun-dllimport} flag.
4576 @end table
4578 @node MIPS Function Attributes
4579 @subsection MIPS Function Attributes
4581 These function attributes are supported by the MIPS back end:
4583 @table @code
4584 @item interrupt
4585 @cindex @code{interrupt} function attribute, MIPS
4586 Use this attribute to indicate that the specified function is an interrupt
4587 handler.  The compiler generates function entry and exit sequences suitable
4588 for use in an interrupt handler when this attribute is present.
4589 An optional argument is supported for the interrupt attribute which allows
4590 the interrupt mode to be described.  By default GCC assumes the external
4591 interrupt controller (EIC) mode is in use, this can be explicitly set using
4592 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4593 Priority Level (IPL) is copied to the current IPL which has the effect of only
4594 enabling higher priority interrupts.  To use vectored interrupt mode use
4595 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4596 the behavior of the non-masked interrupt support and GCC will arrange to mask
4597 all interrupts from sw0 up to and including the specified interrupt vector.
4599 You can use the following attributes to modify the behavior
4600 of an interrupt handler:
4601 @table @code
4602 @item use_shadow_register_set
4603 @cindex @code{use_shadow_register_set} function attribute, MIPS
4604 Assume that the handler uses a shadow register set, instead of
4605 the main general-purpose registers.  An optional argument @code{intstack} is
4606 supported to indicate that the shadow register set contains a valid stack
4607 pointer.
4609 @item keep_interrupts_masked
4610 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4611 Keep interrupts masked for the whole function.  Without this attribute,
4612 GCC tries to reenable interrupts for as much of the function as it can.
4614 @item use_debug_exception_return
4615 @cindex @code{use_debug_exception_return} function attribute, MIPS
4616 Return using the @code{deret} instruction.  Interrupt handlers that don't
4617 have this attribute return using @code{eret} instead.
4618 @end table
4620 You can use any combination of these attributes, as shown below:
4621 @smallexample
4622 void __attribute__ ((interrupt)) v0 ();
4623 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4624 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4625 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4626 void __attribute__ ((interrupt, use_shadow_register_set,
4627                      keep_interrupts_masked)) v4 ();
4628 void __attribute__ ((interrupt, use_shadow_register_set,
4629                      use_debug_exception_return)) v5 ();
4630 void __attribute__ ((interrupt, keep_interrupts_masked,
4631                      use_debug_exception_return)) v6 ();
4632 void __attribute__ ((interrupt, use_shadow_register_set,
4633                      keep_interrupts_masked,
4634                      use_debug_exception_return)) v7 ();
4635 void __attribute__ ((interrupt("eic"))) v8 ();
4636 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4637 @end smallexample
4639 @item long_call
4640 @itemx short_call
4641 @itemx near
4642 @itemx far
4643 @cindex indirect calls, MIPS
4644 @cindex @code{long_call} function attribute, MIPS
4645 @cindex @code{short_call} function attribute, MIPS
4646 @cindex @code{near} function attribute, MIPS
4647 @cindex @code{far} function attribute, MIPS
4648 These attributes specify how a particular function is called on MIPS@.
4649 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4650 command-line switch.  The @code{long_call} and @code{far} attributes are
4651 synonyms, and cause the compiler to always call
4652 the function by first loading its address into a register, and then using
4653 the contents of that register.  The @code{short_call} and @code{near}
4654 attributes are synonyms, and have the opposite
4655 effect; they specify that non-PIC calls should be made using the more
4656 efficient @code{jal} instruction.
4658 @item mips16
4659 @itemx nomips16
4660 @cindex @code{mips16} function attribute, MIPS
4661 @cindex @code{nomips16} function attribute, MIPS
4663 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4664 function attributes to locally select or turn off MIPS16 code generation.
4665 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4666 while MIPS16 code generation is disabled for functions with the
4667 @code{nomips16} attribute.  These attributes override the
4668 @option{-mips16} and @option{-mno-mips16} options on the command line
4669 (@pxref{MIPS Options}).
4671 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4672 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4673 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4674 may interact badly with some GCC extensions such as @code{__builtin_apply}
4675 (@pxref{Constructing Calls}).
4677 @item micromips, MIPS
4678 @itemx nomicromips, MIPS
4679 @cindex @code{micromips} function attribute
4680 @cindex @code{nomicromips} function attribute
4682 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4683 function attributes to locally select or turn off microMIPS code generation.
4684 A function with the @code{micromips} attribute is emitted as microMIPS code,
4685 while microMIPS code generation is disabled for functions with the
4686 @code{nomicromips} attribute.  These attributes override the
4687 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4688 (@pxref{MIPS Options}).
4690 When compiling files containing mixed microMIPS and non-microMIPS code, the
4691 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4692 command line,
4693 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4694 may interact badly with some GCC extensions such as @code{__builtin_apply}
4695 (@pxref{Constructing Calls}).
4697 @item nocompression
4698 @cindex @code{nocompression} function attribute, MIPS
4699 On MIPS targets, you can use the @code{nocompression} function attribute
4700 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4701 overrides the @option{-mips16} and @option{-mmicromips} options on the
4702 command line (@pxref{MIPS Options}).
4703 @end table
4705 @node MSP430 Function Attributes
4706 @subsection MSP430 Function Attributes
4708 These function attributes are supported by the MSP430 back end:
4710 @table @code
4711 @item critical
4712 @cindex @code{critical} function attribute, MSP430
4713 Critical functions disable interrupts upon entry and restore the
4714 previous interrupt state upon exit.  Critical functions cannot also
4715 have the @code{naked} or @code{reentrant} attributes.  They can have
4716 the @code{interrupt} attribute.
4718 @item interrupt
4719 @cindex @code{interrupt} function attribute, MSP430
4720 Use this attribute to indicate
4721 that the specified function is an interrupt handler.  The compiler generates
4722 function entry and exit sequences suitable for use in an interrupt handler
4723 when this attribute is present.
4725 You can provide an argument to the interrupt
4726 attribute which specifies a name or number.  If the argument is a
4727 number it indicates the slot in the interrupt vector table (0 - 31) to
4728 which this handler should be assigned.  If the argument is a name it
4729 is treated as a symbolic name for the vector slot.  These names should
4730 match up with appropriate entries in the linker script.  By default
4731 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4732 @code{reset} for vector 31 are recognized.
4734 @item naked
4735 @cindex @code{naked} function attribute, MSP430
4736 This attribute allows the compiler to construct the
4737 requisite function declaration, while allowing the body of the
4738 function to be assembly code. The specified function will not have
4739 prologue/epilogue sequences generated by the compiler. Only basic
4740 @code{asm} statements can safely be included in naked functions
4741 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4742 basic @code{asm} and C code may appear to work, they cannot be
4743 depended upon to work reliably and are not supported.
4745 @item reentrant
4746 @cindex @code{reentrant} function attribute, MSP430
4747 Reentrant functions disable interrupts upon entry and enable them
4748 upon exit.  Reentrant functions cannot also have the @code{naked}
4749 or @code{critical} attributes.  They can have the @code{interrupt}
4750 attribute.
4752 @item wakeup
4753 @cindex @code{wakeup} function attribute, MSP430
4754 This attribute only applies to interrupt functions.  It is silently
4755 ignored if applied to a non-interrupt function.  A wakeup interrupt
4756 function will rouse the processor from any low-power state that it
4757 might be in when the function exits.
4759 @item lower
4760 @itemx upper
4761 @itemx either
4762 @cindex @code{lower} function attribute, MSP430
4763 @cindex @code{upper} function attribute, MSP430
4764 @cindex @code{either} function attribute, MSP430
4765 On the MSP430 target these attributes can be used to specify whether
4766 the function or variable should be placed into low memory, high
4767 memory, or the placement should be left to the linker to decide.  The
4768 attributes are only significant if compiling for the MSP430X
4769 architecture.
4771 The attributes work in conjunction with a linker script that has been
4772 augmented to specify where to place sections with a @code{.lower} and
4773 a @code{.upper} prefix.  So, for example, as well as placing the
4774 @code{.data} section, the script also specifies the placement of a
4775 @code{.lower.data} and a @code{.upper.data} section.  The intention
4776 is that @code{lower} sections are placed into a small but easier to
4777 access memory region and the upper sections are placed into a larger, but
4778 slower to access, region.
4780 The @code{either} attribute is special.  It tells the linker to place
4781 the object into the corresponding @code{lower} section if there is
4782 room for it.  If there is insufficient room then the object is placed
4783 into the corresponding @code{upper} section instead.  Note that the
4784 placement algorithm is not very sophisticated.  It does not attempt to
4785 find an optimal packing of the @code{lower} sections.  It just makes
4786 one pass over the objects and does the best that it can.  Using the
4787 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4788 options can help the packing, however, since they produce smaller,
4789 easier to pack regions.
4790 @end table
4792 @node NDS32 Function Attributes
4793 @subsection NDS32 Function Attributes
4795 These function attributes are supported by the NDS32 back end:
4797 @table @code
4798 @item exception
4799 @cindex @code{exception} function attribute
4800 @cindex exception handler functions, NDS32
4801 Use this attribute on the NDS32 target to indicate that the specified function
4802 is an exception handler.  The compiler will generate corresponding sections
4803 for use in an exception handler.
4805 @item interrupt
4806 @cindex @code{interrupt} function attribute, NDS32
4807 On NDS32 target, this attribute indicates that the specified function
4808 is an interrupt handler.  The compiler generates corresponding sections
4809 for use in an interrupt handler.  You can use the following attributes
4810 to modify the behavior:
4811 @table @code
4812 @item nested
4813 @cindex @code{nested} function attribute, NDS32
4814 This interrupt service routine is interruptible.
4815 @item not_nested
4816 @cindex @code{not_nested} function attribute, NDS32
4817 This interrupt service routine is not interruptible.
4818 @item nested_ready
4819 @cindex @code{nested_ready} function attribute, NDS32
4820 This interrupt service routine is interruptible after @code{PSW.GIE}
4821 (global interrupt enable) is set.  This allows interrupt service routine to
4822 finish some short critical code before enabling interrupts.
4823 @item save_all
4824 @cindex @code{save_all} function attribute, NDS32
4825 The system will help save all registers into stack before entering
4826 interrupt handler.
4827 @item partial_save
4828 @cindex @code{partial_save} function attribute, NDS32
4829 The system will help save caller registers into stack before entering
4830 interrupt handler.
4831 @end table
4833 @item naked
4834 @cindex @code{naked} function attribute, NDS32
4835 This attribute allows the compiler to construct the
4836 requisite function declaration, while allowing the body of the
4837 function to be assembly code. The specified function will not have
4838 prologue/epilogue sequences generated by the compiler. Only basic
4839 @code{asm} statements can safely be included in naked functions
4840 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4841 basic @code{asm} and C code may appear to work, they cannot be
4842 depended upon to work reliably and are not supported.
4844 @item reset
4845 @cindex @code{reset} function attribute, NDS32
4846 @cindex reset handler functions
4847 Use this attribute on the NDS32 target to indicate that the specified function
4848 is a reset handler.  The compiler will generate corresponding sections
4849 for use in a reset handler.  You can use the following attributes
4850 to provide extra exception handling:
4851 @table @code
4852 @item nmi
4853 @cindex @code{nmi} function attribute, NDS32
4854 Provide a user-defined function to handle NMI exception.
4855 @item warm
4856 @cindex @code{warm} function attribute, NDS32
4857 Provide a user-defined function to handle warm reset exception.
4858 @end table
4859 @end table
4861 @node Nios II Function Attributes
4862 @subsection Nios II Function Attributes
4864 These function attributes are supported by the Nios II back end:
4866 @table @code
4867 @item target (@var{options})
4868 @cindex @code{target} function attribute
4869 As discussed in @ref{Common Function Attributes}, this attribute 
4870 allows specification of target-specific compilation options.
4872 When compiling for Nios II, the following options are allowed:
4874 @table @samp
4875 @item custom-@var{insn}=@var{N}
4876 @itemx no-custom-@var{insn}
4877 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4878 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4879 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4880 custom instruction with encoding @var{N} when generating code that uses 
4881 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4882 the custom instruction @var{insn}.
4883 These target attributes correspond to the
4884 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4885 command-line options, and support the same set of @var{insn} keywords.
4886 @xref{Nios II Options}, for more information.
4888 @item custom-fpu-cfg=@var{name}
4889 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4890 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4891 command-line option, to select a predefined set of custom instructions
4892 named @var{name}.
4893 @xref{Nios II Options}, for more information.
4894 @end table
4895 @end table
4897 @node Nvidia PTX Function Attributes
4898 @subsection Nvidia PTX Function Attributes
4900 These function attributes are supported by the Nvidia PTX back end:
4902 @table @code
4903 @item kernel
4904 @cindex @code{kernel} attribute, Nvidia PTX
4905 This attribute indicates that the corresponding function should be compiled
4906 as a kernel function, which can be invoked from the host via the CUDA RT 
4907 library.
4908 By default functions are only callable only from other PTX functions.
4910 Kernel functions must have @code{void} return type.
4911 @end table
4913 @node PowerPC Function Attributes
4914 @subsection PowerPC Function Attributes
4916 These function attributes are supported by the PowerPC back end:
4918 @table @code
4919 @item longcall
4920 @itemx shortcall
4921 @cindex indirect calls, PowerPC
4922 @cindex @code{longcall} function attribute, PowerPC
4923 @cindex @code{shortcall} function attribute, PowerPC
4924 The @code{longcall} attribute
4925 indicates that the function might be far away from the call site and
4926 require a different (more expensive) calling sequence.  The
4927 @code{shortcall} attribute indicates that the function is always close
4928 enough for the shorter calling sequence to be used.  These attributes
4929 override both the @option{-mlongcall} switch and
4930 the @code{#pragma longcall} setting.
4932 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4933 calls are necessary.
4935 @item target (@var{options})
4936 @cindex @code{target} function attribute
4937 As discussed in @ref{Common Function Attributes}, this attribute 
4938 allows specification of target-specific compilation options.
4940 On the PowerPC, the following options are allowed:
4942 @table @samp
4943 @item altivec
4944 @itemx no-altivec
4945 @cindex @code{target("altivec")} function attribute, PowerPC
4946 Generate code that uses (does not use) AltiVec instructions.  In
4947 32-bit code, you cannot enable AltiVec instructions unless
4948 @option{-mabi=altivec} is used on the command line.
4950 @item cmpb
4951 @itemx no-cmpb
4952 @cindex @code{target("cmpb")} function attribute, PowerPC
4953 Generate code that uses (does not use) the compare bytes instruction
4954 implemented on the POWER6 processor and other processors that support
4955 the PowerPC V2.05 architecture.
4957 @item dlmzb
4958 @itemx no-dlmzb
4959 @cindex @code{target("dlmzb")} function attribute, PowerPC
4960 Generate code that uses (does not use) the string-search @samp{dlmzb}
4961 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4962 generated by default when targeting those processors.
4964 @item fprnd
4965 @itemx no-fprnd
4966 @cindex @code{target("fprnd")} function attribute, PowerPC
4967 Generate code that uses (does not use) the FP round to integer
4968 instructions implemented on the POWER5+ processor and other processors
4969 that support the PowerPC V2.03 architecture.
4971 @item hard-dfp
4972 @itemx no-hard-dfp
4973 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4974 Generate code that uses (does not use) the decimal floating-point
4975 instructions implemented on some POWER processors.
4977 @item isel
4978 @itemx no-isel
4979 @cindex @code{target("isel")} function attribute, PowerPC
4980 Generate code that uses (does not use) ISEL instruction.
4982 @item mfcrf
4983 @itemx no-mfcrf
4984 @cindex @code{target("mfcrf")} function attribute, PowerPC
4985 Generate code that uses (does not use) the move from condition
4986 register field instruction implemented on the POWER4 processor and
4987 other processors that support the PowerPC V2.01 architecture.
4989 @item mfpgpr
4990 @itemx no-mfpgpr
4991 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4992 Generate code that uses (does not use) the FP move to/from general
4993 purpose register instructions implemented on the POWER6X processor and
4994 other processors that support the extended PowerPC V2.05 architecture.
4996 @item mulhw
4997 @itemx no-mulhw
4998 @cindex @code{target("mulhw")} function attribute, PowerPC
4999 Generate code that uses (does not use) the half-word multiply and
5000 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5001 These instructions are generated by default when targeting those
5002 processors.
5004 @item multiple
5005 @itemx no-multiple
5006 @cindex @code{target("multiple")} function attribute, PowerPC
5007 Generate code that uses (does not use) the load multiple word
5008 instructions and the store multiple word instructions.
5010 @item update
5011 @itemx no-update
5012 @cindex @code{target("update")} function attribute, PowerPC
5013 Generate code that uses (does not use) the load or store instructions
5014 that update the base register to the address of the calculated memory
5015 location.
5017 @item popcntb
5018 @itemx no-popcntb
5019 @cindex @code{target("popcntb")} function attribute, PowerPC
5020 Generate code that uses (does not use) the popcount and double-precision
5021 FP reciprocal estimate instruction implemented on the POWER5
5022 processor and other processors that support the PowerPC V2.02
5023 architecture.
5025 @item popcntd
5026 @itemx no-popcntd
5027 @cindex @code{target("popcntd")} function attribute, PowerPC
5028 Generate code that uses (does not use) the popcount instruction
5029 implemented on the POWER7 processor and other processors that support
5030 the PowerPC V2.06 architecture.
5032 @item powerpc-gfxopt
5033 @itemx no-powerpc-gfxopt
5034 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5035 Generate code that uses (does not use) the optional PowerPC
5036 architecture instructions in the Graphics group, including
5037 floating-point select.
5039 @item powerpc-gpopt
5040 @itemx no-powerpc-gpopt
5041 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5042 Generate code that uses (does not use) the optional PowerPC
5043 architecture instructions in the General Purpose group, including
5044 floating-point square root.
5046 @item recip-precision
5047 @itemx no-recip-precision
5048 @cindex @code{target("recip-precision")} function attribute, PowerPC
5049 Assume (do not assume) that the reciprocal estimate instructions
5050 provide higher-precision estimates than is mandated by the PowerPC
5051 ABI.
5053 @item string
5054 @itemx no-string
5055 @cindex @code{target("string")} function attribute, PowerPC
5056 Generate code that uses (does not use) the load string instructions
5057 and the store string word instructions to save multiple registers and
5058 do small block moves.
5060 @item vsx
5061 @itemx no-vsx
5062 @cindex @code{target("vsx")} function attribute, PowerPC
5063 Generate code that uses (does not use) vector/scalar (VSX)
5064 instructions, and also enable the use of built-in functions that allow
5065 more direct access to the VSX instruction set.  In 32-bit code, you
5066 cannot enable VSX or AltiVec instructions unless
5067 @option{-mabi=altivec} is used on the command line.
5069 @item friz
5070 @itemx no-friz
5071 @cindex @code{target("friz")} function attribute, PowerPC
5072 Generate (do not generate) the @code{friz} instruction when the
5073 @option{-funsafe-math-optimizations} option is used to optimize
5074 rounding a floating-point value to 64-bit integer and back to floating
5075 point.  The @code{friz} instruction does not return the same value if
5076 the floating-point number is too large to fit in an integer.
5078 @item avoid-indexed-addresses
5079 @itemx no-avoid-indexed-addresses
5080 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5081 Generate code that tries to avoid (not avoid) the use of indexed load
5082 or store instructions.
5084 @item paired
5085 @itemx no-paired
5086 @cindex @code{target("paired")} function attribute, PowerPC
5087 Generate code that uses (does not use) the generation of PAIRED simd
5088 instructions.
5090 @item longcall
5091 @itemx no-longcall
5092 @cindex @code{target("longcall")} function attribute, PowerPC
5093 Generate code that assumes (does not assume) that all calls are far
5094 away so that a longer more expensive calling sequence is required.
5096 @item cpu=@var{CPU}
5097 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5098 Specify the architecture to generate code for when compiling the
5099 function.  If you select the @code{target("cpu=power7")} attribute when
5100 generating 32-bit code, VSX and AltiVec instructions are not generated
5101 unless you use the @option{-mabi=altivec} option on the command line.
5103 @item tune=@var{TUNE}
5104 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5105 Specify the architecture to tune for when compiling the function.  If
5106 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5107 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5108 compilation tunes for the @var{CPU} architecture, and not the
5109 default tuning specified on the command line.
5110 @end table
5112 On the PowerPC, the inliner does not inline a
5113 function that has different target options than the caller, unless the
5114 callee has a subset of the target options of the caller.
5115 @end table
5117 @node RISC-V Function Attributes
5118 @subsection RISC-V Function Attributes
5120 These function attributes are supported by the RISC-V back end:
5122 @table @code
5123 @item naked
5124 @cindex @code{naked} function attribute, RISC-V
5125 This attribute allows the compiler to construct the
5126 requisite function declaration, while allowing the body of the
5127 function to be assembly code. The specified function will not have
5128 prologue/epilogue sequences generated by the compiler. Only basic
5129 @code{asm} statements can safely be included in naked functions
5130 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5131 basic @code{asm} and C code may appear to work, they cannot be
5132 depended upon to work reliably and are not supported.
5134 @item interrupt
5135 @cindex @code{interrupt} function attribute, RISC-V
5136 Use this attribute to indicate that the specified function is an interrupt
5137 handler.  The compiler generates function entry and exit sequences suitable
5138 for use in an interrupt handler when this attribute is present.
5140 You can specify the kind of interrupt to be handled by adding an optional
5141 parameter to the interrupt attribute like this:
5143 @smallexample
5144 void f (void) __attribute__ ((interrupt ("user")));
5145 @end smallexample
5147 Permissible values for this parameter are @code{user}, @code{supervisor},
5148 and @code{machine}.  If there is no parameter, then it defaults to
5149 @code{machine}.
5150 @end table
5152 @node RL78 Function Attributes
5153 @subsection RL78 Function Attributes
5155 These function attributes are supported by the RL78 back end:
5157 @table @code
5158 @item interrupt
5159 @itemx brk_interrupt
5160 @cindex @code{interrupt} function attribute, RL78
5161 @cindex @code{brk_interrupt} function attribute, RL78
5162 These attributes indicate
5163 that the specified function is an interrupt handler.  The compiler generates
5164 function entry and exit sequences suitable for use in an interrupt handler
5165 when this attribute is present.
5167 Use @code{brk_interrupt} instead of @code{interrupt} for
5168 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5169 that must end with @code{RETB} instead of @code{RETI}).
5171 @item naked
5172 @cindex @code{naked} function attribute, RL78
5173 This attribute allows the compiler to construct the
5174 requisite function declaration, while allowing the body of the
5175 function to be assembly code. The specified function will not have
5176 prologue/epilogue sequences generated by the compiler. Only basic
5177 @code{asm} statements can safely be included in naked functions
5178 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5179 basic @code{asm} and C code may appear to work, they cannot be
5180 depended upon to work reliably and are not supported.
5181 @end table
5183 @node RX Function Attributes
5184 @subsection RX Function Attributes
5186 These function attributes are supported by the RX back end:
5188 @table @code
5189 @item fast_interrupt
5190 @cindex @code{fast_interrupt} function attribute, RX
5191 Use this attribute on the RX port to indicate that the specified
5192 function is a fast interrupt handler.  This is just like the
5193 @code{interrupt} attribute, except that @code{freit} is used to return
5194 instead of @code{reit}.
5196 @item interrupt
5197 @cindex @code{interrupt} function attribute, RX
5198 Use this attribute to indicate
5199 that the specified function is an interrupt handler.  The compiler generates
5200 function entry and exit sequences suitable for use in an interrupt handler
5201 when this attribute is present.
5203 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5204 to the attribute, as well as naming an alternate table name.
5205 Parameters are handled sequentially, so one handler can be assigned to
5206 multiple entries in multiple tables.  One may also pass the magic
5207 string @code{"$default"} which causes the function to be used for any
5208 unfilled slots in the current table.
5210 This example shows a simple assignment of a function to one vector in
5211 the default table (note that preprocessor macros may be used for
5212 chip-specific symbolic vector names):
5213 @smallexample
5214 void __attribute__ ((interrupt (5))) txd1_handler ();
5215 @end smallexample
5217 This example assigns a function to two slots in the default table
5218 (using preprocessor macros defined elsewhere) and makes it the default
5219 for the @code{dct} table:
5220 @smallexample
5221 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5222         txd1_handler ();
5223 @end smallexample
5225 @item naked
5226 @cindex @code{naked} function attribute, RX
5227 This attribute allows the compiler to construct the
5228 requisite function declaration, while allowing the body of the
5229 function to be assembly code. The specified function will not have
5230 prologue/epilogue sequences generated by the compiler. Only basic
5231 @code{asm} statements can safely be included in naked functions
5232 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5233 basic @code{asm} and C code may appear to work, they cannot be
5234 depended upon to work reliably and are not supported.
5236 @item vector
5237 @cindex @code{vector} function attribute, RX
5238 This RX attribute is similar to the @code{interrupt} attribute, including its
5239 parameters, but does not make the function an interrupt-handler type
5240 function (i.e. it retains the normal C function calling ABI).  See the
5241 @code{interrupt} attribute for a description of its arguments.
5242 @end table
5244 @node S/390 Function Attributes
5245 @subsection S/390 Function Attributes
5247 These function attributes are supported on the S/390:
5249 @table @code
5250 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5251 @cindex @code{hotpatch} function attribute, S/390
5253 On S/390 System z targets, you can use this function attribute to
5254 make GCC generate a ``hot-patching'' function prologue.  If the
5255 @option{-mhotpatch=} command-line option is used at the same time,
5256 the @code{hotpatch} attribute takes precedence.  The first of the
5257 two arguments specifies the number of halfwords to be added before
5258 the function label.  A second argument can be used to specify the
5259 number of halfwords to be added after the function label.  For
5260 both arguments the maximum allowed value is 1000000.
5262 If both arguments are zero, hotpatching is disabled.
5264 @item target (@var{options})
5265 @cindex @code{target} function attribute
5266 As discussed in @ref{Common Function Attributes}, this attribute
5267 allows specification of target-specific compilation options.
5269 On S/390, the following options are supported:
5271 @table @samp
5272 @item arch=
5273 @item tune=
5274 @item stack-guard=
5275 @item stack-size=
5276 @item branch-cost=
5277 @item warn-framesize=
5278 @item backchain
5279 @itemx no-backchain
5280 @item hard-dfp
5281 @itemx no-hard-dfp
5282 @item hard-float
5283 @itemx soft-float
5284 @item htm
5285 @itemx no-htm
5286 @item vx
5287 @itemx no-vx
5288 @item packed-stack
5289 @itemx no-packed-stack
5290 @item small-exec
5291 @itemx no-small-exec
5292 @item mvcle
5293 @itemx no-mvcle
5294 @item warn-dynamicstack
5295 @itemx no-warn-dynamicstack
5296 @end table
5298 The options work exactly like the S/390 specific command line
5299 options (without the prefix @option{-m}) except that they do not
5300 change any feature macros.  For example,
5302 @smallexample
5303 @code{target("no-vx")}
5304 @end smallexample
5306 does not undefine the @code{__VEC__} macro.
5307 @end table
5309 @node SH Function Attributes
5310 @subsection SH Function Attributes
5312 These function attributes are supported on the SH family of processors:
5314 @table @code
5315 @item function_vector
5316 @cindex @code{function_vector} function attribute, SH
5317 @cindex calling functions through the function vector on SH2A
5318 On SH2A targets, this attribute declares a function to be called using the
5319 TBR relative addressing mode.  The argument to this attribute is the entry
5320 number of the same function in a vector table containing all the TBR
5321 relative addressable functions.  For correct operation the TBR must be setup
5322 accordingly to point to the start of the vector table before any functions with
5323 this attribute are invoked.  Usually a good place to do the initialization is
5324 the startup routine.  The TBR relative vector table can have at max 256 function
5325 entries.  The jumps to these functions are generated using a SH2A specific,
5326 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5327 from GNU binutils version 2.7 or later for this attribute to work correctly.
5329 In an application, for a function being called once, this attribute
5330 saves at least 8 bytes of code; and if other successive calls are being
5331 made to the same function, it saves 2 bytes of code per each of these
5332 calls.
5334 @item interrupt_handler
5335 @cindex @code{interrupt_handler} function attribute, SH
5336 Use this attribute to
5337 indicate that the specified function is an interrupt handler.  The compiler
5338 generates function entry and exit sequences suitable for use in an
5339 interrupt handler when this attribute is present.
5341 @item nosave_low_regs
5342 @cindex @code{nosave_low_regs} function attribute, SH
5343 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5344 function should not save and restore registers R0..R7.  This can be used on SH3*
5345 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5346 interrupt handlers.
5348 @item renesas
5349 @cindex @code{renesas} function attribute, SH
5350 On SH targets this attribute specifies that the function or struct follows the
5351 Renesas ABI.
5353 @item resbank
5354 @cindex @code{resbank} function attribute, SH
5355 On the SH2A target, this attribute enables the high-speed register
5356 saving and restoration using a register bank for @code{interrupt_handler}
5357 routines.  Saving to the bank is performed automatically after the CPU
5358 accepts an interrupt that uses a register bank.
5360 The nineteen 32-bit registers comprising general register R0 to R14,
5361 control register GBR, and system registers MACH, MACL, and PR and the
5362 vector table address offset are saved into a register bank.  Register
5363 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5364 from the bank is executed by issuing a RESBANK instruction.
5366 @item sp_switch
5367 @cindex @code{sp_switch} function attribute, SH
5368 Use this attribute on the SH to indicate an @code{interrupt_handler}
5369 function should switch to an alternate stack.  It expects a string
5370 argument that names a global variable holding the address of the
5371 alternate stack.
5373 @smallexample
5374 void *alt_stack;
5375 void f () __attribute__ ((interrupt_handler,
5376                           sp_switch ("alt_stack")));
5377 @end smallexample
5379 @item trap_exit
5380 @cindex @code{trap_exit} function attribute, SH
5381 Use this attribute on the SH for an @code{interrupt_handler} to return using
5382 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5383 argument specifying the trap number to be used.
5385 @item trapa_handler
5386 @cindex @code{trapa_handler} function attribute, SH
5387 On SH targets this function attribute is similar to @code{interrupt_handler}
5388 but it does not save and restore all registers.
5389 @end table
5391 @node SPU Function Attributes
5392 @subsection SPU Function Attributes
5394 These function attributes are supported by the SPU back end:
5396 @table @code
5397 @item naked
5398 @cindex @code{naked} function attribute, SPU
5399 This attribute allows the compiler to construct the
5400 requisite function declaration, while allowing the body of the
5401 function to be assembly code. The specified function will not have
5402 prologue/epilogue sequences generated by the compiler. Only basic
5403 @code{asm} statements can safely be included in naked functions
5404 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5405 basic @code{asm} and C code may appear to work, they cannot be
5406 depended upon to work reliably and are not supported.
5407 @end table
5409 @node Symbian OS Function Attributes
5410 @subsection Symbian OS Function Attributes
5412 @xref{Microsoft Windows Function Attributes}, for discussion of the
5413 @code{dllexport} and @code{dllimport} attributes.
5415 @node V850 Function Attributes
5416 @subsection V850 Function Attributes
5418 The V850 back end supports these function attributes:
5420 @table @code
5421 @item interrupt
5422 @itemx interrupt_handler
5423 @cindex @code{interrupt} function attribute, V850
5424 @cindex @code{interrupt_handler} function attribute, V850
5425 Use these attributes to indicate
5426 that the specified function is an interrupt handler.  The compiler generates
5427 function entry and exit sequences suitable for use in an interrupt handler
5428 when either attribute is present.
5429 @end table
5431 @node Visium Function Attributes
5432 @subsection Visium Function Attributes
5434 These function attributes are supported by the Visium back end:
5436 @table @code
5437 @item interrupt
5438 @cindex @code{interrupt} function attribute, Visium
5439 Use this attribute to indicate
5440 that the specified function is an interrupt handler.  The compiler generates
5441 function entry and exit sequences suitable for use in an interrupt handler
5442 when this attribute is present.
5443 @end table
5445 @node x86 Function Attributes
5446 @subsection x86 Function Attributes
5448 These function attributes are supported by the x86 back end:
5450 @table @code
5451 @item cdecl
5452 @cindex @code{cdecl} function attribute, x86-32
5453 @cindex functions that pop the argument stack on x86-32
5454 @opindex mrtd
5455 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5456 assume that the calling function pops off the stack space used to
5457 pass arguments.  This is
5458 useful to override the effects of the @option{-mrtd} switch.
5460 @item fastcall
5461 @cindex @code{fastcall} function attribute, x86-32
5462 @cindex functions that pop the argument stack on x86-32
5463 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5464 pass the first argument (if of integral type) in the register ECX and
5465 the second argument (if of integral type) in the register EDX@.  Subsequent
5466 and other typed arguments are passed on the stack.  The called function
5467 pops the arguments off the stack.  If the number of arguments is variable all
5468 arguments are pushed on the stack.
5470 @item thiscall
5471 @cindex @code{thiscall} function attribute, x86-32
5472 @cindex functions that pop the argument stack on x86-32
5473 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5474 pass the first argument (if of integral type) in the register ECX.
5475 Subsequent and other typed arguments are passed on the stack. The called
5476 function pops the arguments off the stack.
5477 If the number of arguments is variable all arguments are pushed on the
5478 stack.
5479 The @code{thiscall} attribute is intended for C++ non-static member functions.
5480 As a GCC extension, this calling convention can be used for C functions
5481 and for static member methods.
5483 @item ms_abi
5484 @itemx sysv_abi
5485 @cindex @code{ms_abi} function attribute, x86
5486 @cindex @code{sysv_abi} function attribute, x86
5488 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5489 to indicate which calling convention should be used for a function.  The
5490 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5491 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5492 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5493 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5495 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5496 requires the @option{-maccumulate-outgoing-args} option.
5498 @item callee_pop_aggregate_return (@var{number})
5499 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5501 On x86-32 targets, you can use this attribute to control how
5502 aggregates are returned in memory.  If the caller is responsible for
5503 popping the hidden pointer together with the rest of the arguments, specify
5504 @var{number} equal to zero.  If callee is responsible for popping the
5505 hidden pointer, specify @var{number} equal to one.  
5507 The default x86-32 ABI assumes that the callee pops the
5508 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5509 the compiler assumes that the
5510 caller pops the stack for hidden pointer.
5512 @item ms_hook_prologue
5513 @cindex @code{ms_hook_prologue} function attribute, x86
5515 On 32-bit and 64-bit x86 targets, you can use
5516 this function attribute to make GCC generate the ``hot-patching'' function
5517 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5518 and newer.
5520 @item naked
5521 @cindex @code{naked} function attribute, x86
5522 This attribute allows the compiler to construct the
5523 requisite function declaration, while allowing the body of the
5524 function to be assembly code. The specified function will not have
5525 prologue/epilogue sequences generated by the compiler. Only basic
5526 @code{asm} statements can safely be included in naked functions
5527 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5528 basic @code{asm} and C code may appear to work, they cannot be
5529 depended upon to work reliably and are not supported.
5531 @item regparm (@var{number})
5532 @cindex @code{regparm} function attribute, x86
5533 @cindex functions that are passed arguments in registers on x86-32
5534 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5535 pass arguments number one to @var{number} if they are of integral type
5536 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5537 take a variable number of arguments continue to be passed all of their
5538 arguments on the stack.
5540 Beware that on some ELF systems this attribute is unsuitable for
5541 global functions in shared libraries with lazy binding (which is the
5542 default).  Lazy binding sends the first call via resolving code in
5543 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5544 per the standard calling conventions.  Solaris 8 is affected by this.
5545 Systems with the GNU C Library version 2.1 or higher
5546 and FreeBSD are believed to be
5547 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5548 disabled with the linker or the loader if desired, to avoid the
5549 problem.)
5551 @item sseregparm
5552 @cindex @code{sseregparm} function attribute, x86
5553 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5554 causes the compiler to pass up to 3 floating-point arguments in
5555 SSE registers instead of on the stack.  Functions that take a
5556 variable number of arguments continue to pass all of their
5557 floating-point arguments on the stack.
5559 @item force_align_arg_pointer
5560 @cindex @code{force_align_arg_pointer} function attribute, x86
5561 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5562 applied to individual function definitions, generating an alternate
5563 prologue and epilogue that realigns the run-time stack if necessary.
5564 This supports mixing legacy codes that run with a 4-byte aligned stack
5565 with modern codes that keep a 16-byte stack for SSE compatibility.
5567 @item stdcall
5568 @cindex @code{stdcall} function attribute, x86-32
5569 @cindex functions that pop the argument stack on x86-32
5570 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5571 assume that the called function pops off the stack space used to
5572 pass arguments, unless it takes a variable number of arguments.
5574 @item no_caller_saved_registers
5575 @cindex @code{no_caller_saved_registers} function attribute, x86
5576 Use this attribute to indicate that the specified function has no
5577 caller-saved registers. That is, all registers are callee-saved. For
5578 example, this attribute can be used for a function called from an
5579 interrupt handler. The compiler generates proper function entry and
5580 exit sequences to save and restore any modified registers, except for
5581 the EFLAGS register.  Since GCC doesn't preserve SSE, MMX nor x87
5582 states, the GCC option @option{-mgeneral-regs-only} should be used to
5583 compile functions with @code{no_caller_saved_registers} attribute.
5585 @item interrupt
5586 @cindex @code{interrupt} function attribute, x86
5587 Use this attribute to indicate that the specified function is an
5588 interrupt handler or an exception handler (depending on parameters passed
5589 to the function, explained further).  The compiler generates function
5590 entry and exit sequences suitable for use in an interrupt handler when
5591 this attribute is present.  The @code{IRET} instruction, instead of the
5592 @code{RET} instruction, is used to return from interrupt handlers.  All
5593 registers, except for the EFLAGS register which is restored by the
5594 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5595 doesn't preserve SSE, MMX nor x87 states, the GCC option
5596 @option{-mgeneral-regs-only} should be used to compile interrupt and
5597 exception handlers.
5599 Any interruptible-without-stack-switch code must be compiled with
5600 @option{-mno-red-zone} since interrupt handlers can and will, because
5601 of the hardware design, touch the red zone.
5603 An interrupt handler must be declared with a mandatory pointer
5604 argument:
5606 @smallexample
5607 struct interrupt_frame;
5609 __attribute__ ((interrupt))
5610 void
5611 f (struct interrupt_frame *frame)
5614 @end smallexample
5616 @noindent
5617 and you must define @code{struct interrupt_frame} as described in the
5618 processor's manual.
5620 Exception handlers differ from interrupt handlers because the system
5621 pushes an error code on the stack.  An exception handler declaration is
5622 similar to that for an interrupt handler, but with a different mandatory
5623 function signature.  The compiler arranges to pop the error code off the
5624 stack before the @code{IRET} instruction.
5626 @smallexample
5627 #ifdef __x86_64__
5628 typedef unsigned long long int uword_t;
5629 #else
5630 typedef unsigned int uword_t;
5631 #endif
5633 struct interrupt_frame;
5635 __attribute__ ((interrupt))
5636 void
5637 f (struct interrupt_frame *frame, uword_t error_code)
5639   ...
5641 @end smallexample
5643 Exception handlers should only be used for exceptions that push an error
5644 code; you should use an interrupt handler in other cases.  The system
5645 will crash if the wrong kind of handler is used.
5647 @item target (@var{options})
5648 @cindex @code{target} function attribute
5649 As discussed in @ref{Common Function Attributes}, this attribute 
5650 allows specification of target-specific compilation options.
5652 On the x86, the following options are allowed:
5653 @table @samp
5654 @item abm
5655 @itemx no-abm
5656 @cindex @code{target("abm")} function attribute, x86
5657 Enable/disable the generation of the advanced bit instructions.
5659 @item aes
5660 @itemx no-aes
5661 @cindex @code{target("aes")} function attribute, x86
5662 Enable/disable the generation of the AES instructions.
5664 @item default
5665 @cindex @code{target("default")} function attribute, x86
5666 @xref{Function Multiversioning}, where it is used to specify the
5667 default function version.
5669 @item mmx
5670 @itemx no-mmx
5671 @cindex @code{target("mmx")} function attribute, x86
5672 Enable/disable the generation of the MMX instructions.
5674 @item pclmul
5675 @itemx no-pclmul
5676 @cindex @code{target("pclmul")} function attribute, x86
5677 Enable/disable the generation of the PCLMUL instructions.
5679 @item popcnt
5680 @itemx no-popcnt
5681 @cindex @code{target("popcnt")} function attribute, x86
5682 Enable/disable the generation of the POPCNT instruction.
5684 @item sse
5685 @itemx no-sse
5686 @cindex @code{target("sse")} function attribute, x86
5687 Enable/disable the generation of the SSE instructions.
5689 @item sse2
5690 @itemx no-sse2
5691 @cindex @code{target("sse2")} function attribute, x86
5692 Enable/disable the generation of the SSE2 instructions.
5694 @item sse3
5695 @itemx no-sse3
5696 @cindex @code{target("sse3")} function attribute, x86
5697 Enable/disable the generation of the SSE3 instructions.
5699 @item sse4
5700 @itemx no-sse4
5701 @cindex @code{target("sse4")} function attribute, x86
5702 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5703 and SSE4.2).
5705 @item sse4.1
5706 @itemx no-sse4.1
5707 @cindex @code{target("sse4.1")} function attribute, x86
5708 Enable/disable the generation of the sse4.1 instructions.
5710 @item sse4.2
5711 @itemx no-sse4.2
5712 @cindex @code{target("sse4.2")} function attribute, x86
5713 Enable/disable the generation of the sse4.2 instructions.
5715 @item sse4a
5716 @itemx no-sse4a
5717 @cindex @code{target("sse4a")} function attribute, x86
5718 Enable/disable the generation of the SSE4A instructions.
5720 @item fma4
5721 @itemx no-fma4
5722 @cindex @code{target("fma4")} function attribute, x86
5723 Enable/disable the generation of the FMA4 instructions.
5725 @item xop
5726 @itemx no-xop
5727 @cindex @code{target("xop")} function attribute, x86
5728 Enable/disable the generation of the XOP instructions.
5730 @item lwp
5731 @itemx no-lwp
5732 @cindex @code{target("lwp")} function attribute, x86
5733 Enable/disable the generation of the LWP instructions.
5735 @item ssse3
5736 @itemx no-ssse3
5737 @cindex @code{target("ssse3")} function attribute, x86
5738 Enable/disable the generation of the SSSE3 instructions.
5740 @item cld
5741 @itemx no-cld
5742 @cindex @code{target("cld")} function attribute, x86
5743 Enable/disable the generation of the CLD before string moves.
5745 @item fancy-math-387
5746 @itemx no-fancy-math-387
5747 @cindex @code{target("fancy-math-387")} function attribute, x86
5748 Enable/disable the generation of the @code{sin}, @code{cos}, and
5749 @code{sqrt} instructions on the 387 floating-point unit.
5751 @item ieee-fp
5752 @itemx no-ieee-fp
5753 @cindex @code{target("ieee-fp")} function attribute, x86
5754 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5756 @item inline-all-stringops
5757 @itemx no-inline-all-stringops
5758 @cindex @code{target("inline-all-stringops")} function attribute, x86
5759 Enable/disable inlining of string operations.
5761 @item inline-stringops-dynamically
5762 @itemx no-inline-stringops-dynamically
5763 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5764 Enable/disable the generation of the inline code to do small string
5765 operations and calling the library routines for large operations.
5767 @item align-stringops
5768 @itemx no-align-stringops
5769 @cindex @code{target("align-stringops")} function attribute, x86
5770 Do/do not align destination of inlined string operations.
5772 @item recip
5773 @itemx no-recip
5774 @cindex @code{target("recip")} function attribute, x86
5775 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5776 instructions followed an additional Newton-Raphson step instead of
5777 doing a floating-point division.
5779 @item arch=@var{ARCH}
5780 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5781 Specify the architecture to generate code for in compiling the function.
5783 @item tune=@var{TUNE}
5784 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5785 Specify the architecture to tune for in compiling the function.
5787 @item fpmath=@var{FPMATH}
5788 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5789 Specify which floating-point unit to use.  You must specify the
5790 @code{target("fpmath=sse,387")} option as
5791 @code{target("fpmath=sse+387")} because the comma would separate
5792 different options.
5794 @item indirect_branch("@var{choice}")
5795 @cindex @code{indirect_branch} function attribute, x86
5796 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5797 to convert indirect call and jump with @var{choice}.  @samp{keep}
5798 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
5799 call and jump to call and return thunk.  @samp{thunk-inline} converts
5800 indirect call and jump to inlined call and return thunk.
5801 @samp{thunk-extern} converts indirect call and jump to external call
5802 and return thunk provided in a separate object file.
5804 @item function_return("@var{choice}")
5805 @cindex @code{function_return} function attribute, x86
5806 On x86 targets, the @code{function_return} attribute causes the compiler
5807 to convert function return with @var{choice}.  @samp{keep} keeps function
5808 return unmodified.  @samp{thunk} converts function return to call and
5809 return thunk.  @samp{thunk-inline} converts function return to inlined
5810 call and return thunk.  @samp{thunk-extern} converts function return to
5811 external call and return thunk provided in a separate object file.
5813 @item nocf_check
5814 @cindex @code{nocf_check} function attribute
5815 The @code{nocf_check} attribute on a function is used to inform the
5816 compiler that the function's prologue should not be instrumented when
5817 compiled with the @option{-fcf-protection=branch} option.  The
5818 compiler assumes that the function's address is a valid target for a
5819 control-flow transfer.
5821 The @code{nocf_check} attribute on a type of pointer to function is
5822 used to inform the compiler that a call through the pointer should
5823 not be instrumented when compiled with the
5824 @option{-fcf-protection=branch} option.  The compiler assumes
5825 that the function's address from the pointer is a valid target for
5826 a control-flow transfer.  A direct function call through a function
5827 name is assumed to be a safe call thus direct calls are not
5828 instrumented by the compiler.
5830 The @code{nocf_check} attribute is applied to an object's type.
5831 In case of assignment of a function address or a function pointer to
5832 another pointer, the attribute is not carried over from the right-hand
5833 object's type; the type of left-hand object stays unchanged.  The
5834 compiler checks for @code{nocf_check} attribute mismatch and reports
5835 a warning in case of mismatch.
5837 @smallexample
5839 int foo (void) __attribute__(nocf_check);
5840 void (*foo1)(void) __attribute__(nocf_check);
5841 void (*foo2)(void);
5843 /* foo's address is assumed to be valid.  */
5845 foo (void) 
5847   /* This call site is not checked for control-flow 
5848      validity.  */
5849   (*foo1)();
5851   /* A warning is issued about attribute mismatch.  */
5852   foo1 = foo2; 
5854   /* This call site is still not checked.  */
5855   (*foo1)();
5857   /* This call site is checked.  */
5858   (*foo2)();
5860   /* A warning is issued about attribute mismatch.  */
5861   foo2 = foo1; 
5863   /* This call site is still checked.  */
5864   (*foo2)();
5866   return 0;
5868 @end smallexample
5870 @end table
5872 On the x86, the inliner does not inline a
5873 function that has different target options than the caller, unless the
5874 callee has a subset of the target options of the caller.  For example
5875 a function declared with @code{target("sse3")} can inline a function
5876 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5877 @end table
5879 @node Xstormy16 Function Attributes
5880 @subsection Xstormy16 Function Attributes
5882 These function attributes are supported by the Xstormy16 back end:
5884 @table @code
5885 @item interrupt
5886 @cindex @code{interrupt} function attribute, Xstormy16
5887 Use this attribute to indicate
5888 that the specified function is an interrupt handler.  The compiler generates
5889 function entry and exit sequences suitable for use in an interrupt handler
5890 when this attribute is present.
5891 @end table
5893 @node Variable Attributes
5894 @section Specifying Attributes of Variables
5895 @cindex attribute of variables
5896 @cindex variable attributes
5898 The keyword @code{__attribute__} allows you to specify special
5899 attributes of variables or structure fields.  This keyword is followed
5900 by an attribute specification inside double parentheses.  Some
5901 attributes are currently defined generically for variables.
5902 Other attributes are defined for variables on particular target
5903 systems.  Other attributes are available for functions
5904 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5905 enumerators (@pxref{Enumerator Attributes}), statements
5906 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5907 Other front ends might define more attributes
5908 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5910 @xref{Attribute Syntax}, for details of the exact syntax for using
5911 attributes.
5913 @menu
5914 * Common Variable Attributes::
5915 * ARC Variable Attributes::
5916 * AVR Variable Attributes::
5917 * Blackfin Variable Attributes::
5918 * H8/300 Variable Attributes::
5919 * IA-64 Variable Attributes::
5920 * M32R/D Variable Attributes::
5921 * MeP Variable Attributes::
5922 * Microsoft Windows Variable Attributes::
5923 * MSP430 Variable Attributes::
5924 * Nvidia PTX Variable Attributes::
5925 * PowerPC Variable Attributes::
5926 * RL78 Variable Attributes::
5927 * SPU Variable Attributes::
5928 * V850 Variable Attributes::
5929 * x86 Variable Attributes::
5930 * Xstormy16 Variable Attributes::
5931 @end menu
5933 @node Common Variable Attributes
5934 @subsection Common Variable Attributes
5936 The following attributes are supported on most targets.
5938 @table @code
5939 @cindex @code{aligned} variable attribute
5940 @item aligned (@var{alignment})
5941 This attribute specifies a minimum alignment for the variable or
5942 structure field, measured in bytes.  For example, the declaration:
5944 @smallexample
5945 int x __attribute__ ((aligned (16))) = 0;
5946 @end smallexample
5948 @noindent
5949 causes the compiler to allocate the global variable @code{x} on a
5950 16-byte boundary.  On a 68040, this could be used in conjunction with
5951 an @code{asm} expression to access the @code{move16} instruction which
5952 requires 16-byte aligned operands.
5954 You can also specify the alignment of structure fields.  For example, to
5955 create a double-word aligned @code{int} pair, you could write:
5957 @smallexample
5958 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5959 @end smallexample
5961 @noindent
5962 This is an alternative to creating a union with a @code{double} member,
5963 which forces the union to be double-word aligned.
5965 As in the preceding examples, you can explicitly specify the alignment
5966 (in bytes) that you wish the compiler to use for a given variable or
5967 structure field.  Alternatively, you can leave out the alignment factor
5968 and just ask the compiler to align a variable or field to the
5969 default alignment for the target architecture you are compiling for.
5970 The default alignment is sufficient for all scalar types, but may not be
5971 enough for all vector types on a target that supports vector operations.
5972 The default alignment is fixed for a particular target ABI.
5974 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5975 which is the largest alignment ever used for any data type on the
5976 target machine you are compiling for.  For example, you could write:
5978 @smallexample
5979 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5980 @end smallexample
5982 The compiler automatically sets the alignment for the declared
5983 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5984 often make copy operations more efficient, because the compiler can
5985 use whatever instructions copy the biggest chunks of memory when
5986 performing copies to or from the variables or fields that you have
5987 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5988 may change depending on command-line options.
5990 When used on a struct, or struct member, the @code{aligned} attribute can
5991 only increase the alignment; in order to decrease it, the @code{packed}
5992 attribute must be specified as well.  When used as part of a typedef, the
5993 @code{aligned} attribute can both increase and decrease alignment, and
5994 specifying the @code{packed} attribute generates a warning.
5996 Note that the effectiveness of @code{aligned} attributes may be limited
5997 by inherent limitations in your linker.  On many systems, the linker is
5998 only able to arrange for variables to be aligned up to a certain maximum
5999 alignment.  (For some linkers, the maximum supported alignment may
6000 be very very small.)  If your linker is only able to align variables
6001 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6002 in an @code{__attribute__} still only provides you with 8-byte
6003 alignment.  See your linker documentation for further information.
6005 The @code{aligned} attribute can also be used for functions
6006 (@pxref{Common Function Attributes}.)
6008 @cindex @code{warn_if_not_aligned} variable attribute
6009 @item warn_if_not_aligned (@var{alignment})
6010 This attribute specifies a threshold for the structure field, measured
6011 in bytes.  If the structure field is aligned below the threshold, a
6012 warning will be issued.  For example, the declaration:
6014 @smallexample
6015 struct foo
6017   int i1;
6018   int i2;
6019   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6021 @end smallexample
6023 @noindent
6024 causes the compiler to issue an warning on @code{struct foo}, like
6025 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6026 The compiler also issues a warning, like @samp{warning: 'x' offset
6027 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6028 the misaligned offset:
6030 @smallexample
6031 struct foo
6033   int i1;
6034   int i2;
6035   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6036 @} __attribute__((aligned(16)));
6037 @end smallexample
6039 This warning can be disabled by @option{-Wno-if-not-aligned}.
6040 The @code{warn_if_not_aligned} attribute can also be used for types
6041 (@pxref{Common Type Attributes}.)
6043 @item cleanup (@var{cleanup_function})
6044 @cindex @code{cleanup} variable attribute
6045 The @code{cleanup} attribute runs a function when the variable goes
6046 out of scope.  This attribute can only be applied to auto function
6047 scope variables; it may not be applied to parameters or variables
6048 with static storage duration.  The function must take one parameter,
6049 a pointer to a type compatible with the variable.  The return value
6050 of the function (if any) is ignored.
6052 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6053 is run during the stack unwinding that happens during the
6054 processing of the exception.  Note that the @code{cleanup} attribute
6055 does not allow the exception to be caught, only to perform an action.
6056 It is undefined what happens if @var{cleanup_function} does not
6057 return normally.
6059 @item common
6060 @itemx nocommon
6061 @cindex @code{common} variable attribute
6062 @cindex @code{nocommon} variable attribute
6063 @opindex fcommon
6064 @opindex fno-common
6065 The @code{common} attribute requests GCC to place a variable in
6066 ``common'' storage.  The @code{nocommon} attribute requests the
6067 opposite---to allocate space for it directly.
6069 These attributes override the default chosen by the
6070 @option{-fno-common} and @option{-fcommon} flags respectively.
6072 @item deprecated
6073 @itemx deprecated (@var{msg})
6074 @cindex @code{deprecated} variable attribute
6075 The @code{deprecated} attribute results in a warning if the variable
6076 is used anywhere in the source file.  This is useful when identifying
6077 variables that are expected to be removed in a future version of a
6078 program.  The warning also includes the location of the declaration
6079 of the deprecated variable, to enable users to easily find further
6080 information about why the variable is deprecated, or what they should
6081 do instead.  Note that the warning only occurs for uses:
6083 @smallexample
6084 extern int old_var __attribute__ ((deprecated));
6085 extern int old_var;
6086 int new_fn () @{ return old_var; @}
6087 @end smallexample
6089 @noindent
6090 results in a warning on line 3 but not line 2.  The optional @var{msg}
6091 argument, which must be a string, is printed in the warning if
6092 present.
6094 The @code{deprecated} attribute can also be used for functions and
6095 types (@pxref{Common Function Attributes},
6096 @pxref{Common Type Attributes}).
6098 The message attached to the attribute is affected by the setting of
6099 the @option{-fmessage-length} option.
6101 @item nonstring
6102 @cindex @code{nonstring} variable attribute
6103 The @code{nonstring} variable attribute specifies that an object or member
6104 declaration with type array of @code{char}, @code{signed char}, or
6105 @code{unsigned char}, or pointer to such a type is intended to store
6106 character arrays that do not necessarily contain a terminating @code{NUL}.
6107 This is useful in detecting uses of such arrays or pointers with functions
6108 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6109 an array or pointer is used as an argument to a bounded string manipulation
6110 function such as @code{strncpy}.  For example, without the attribute, GCC
6111 will issue a warning for the @code{strncpy} call below because it may
6112 truncate the copy without appending the terminating @code{NUL} character.
6113 Using the attribute makes it possible to suppress the warning.  However,
6114 when the array is declared with the attribute the call to @code{strlen} is
6115 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6116 string the call is undefined.  To copy, compare, of search non-string
6117 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6118 and other functions that operate on arrays of bytes.  In addition,
6119 calling @code{strnlen} and @code{strndup} with such arrays is safe
6120 provided a suitable bound is specified, and not diagnosed.
6122 @smallexample
6123 struct Data
6125   char name [32] __attribute__ ((nonstring));
6128 int f (struct Data *pd, const char *s)
6130   strncpy (pd->name, s, sizeof pd->name);
6131   @dots{}
6132   return strlen (pd->name);   // unsafe, gets a warning
6134 @end smallexample
6136 @item mode (@var{mode})
6137 @cindex @code{mode} variable attribute
6138 This attribute specifies the data type for the declaration---whichever
6139 type corresponds to the mode @var{mode}.  This in effect lets you
6140 request an integer or floating-point type according to its width.
6142 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6143 for a list of the possible keywords for @var{mode}.
6144 You may also specify a mode of @code{byte} or @code{__byte__} to
6145 indicate the mode corresponding to a one-byte integer, @code{word} or
6146 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6147 or @code{__pointer__} for the mode used to represent pointers.
6149 @item packed
6150 @cindex @code{packed} variable attribute
6151 The @code{packed} attribute specifies that a variable or structure field
6152 should have the smallest possible alignment---one byte for a variable,
6153 and one bit for a field, unless you specify a larger value with the
6154 @code{aligned} attribute.
6156 Here is a structure in which the field @code{x} is packed, so that it
6157 immediately follows @code{a}:
6159 @smallexample
6160 struct foo
6162   char a;
6163   int x[2] __attribute__ ((packed));
6165 @end smallexample
6167 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6168 @code{packed} attribute on bit-fields of type @code{char}.  This has
6169 been fixed in GCC 4.4 but the change can lead to differences in the
6170 structure layout.  See the documentation of
6171 @option{-Wpacked-bitfield-compat} for more information.
6173 @item section ("@var{section-name}")
6174 @cindex @code{section} variable attribute
6175 Normally, the compiler places the objects it generates in sections like
6176 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6177 or you need certain particular variables to appear in special sections,
6178 for example to map to special hardware.  The @code{section}
6179 attribute specifies that a variable (or function) lives in a particular
6180 section.  For example, this small program uses several specific section names:
6182 @smallexample
6183 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6184 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6185 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6186 int init_data __attribute__ ((section ("INITDATA")));
6188 main()
6190   /* @r{Initialize stack pointer} */
6191   init_sp (stack + sizeof (stack));
6193   /* @r{Initialize initialized data} */
6194   memcpy (&init_data, &data, &edata - &data);
6196   /* @r{Turn on the serial ports} */
6197   init_duart (&a);
6198   init_duart (&b);
6200 @end smallexample
6202 @noindent
6203 Use the @code{section} attribute with
6204 @emph{global} variables and not @emph{local} variables,
6205 as shown in the example.
6207 You may use the @code{section} attribute with initialized or
6208 uninitialized global variables but the linker requires
6209 each object be defined once, with the exception that uninitialized
6210 variables tentatively go in the @code{common} (or @code{bss}) section
6211 and can be multiply ``defined''.  Using the @code{section} attribute
6212 changes what section the variable goes into and may cause the
6213 linker to issue an error if an uninitialized variable has multiple
6214 definitions.  You can force a variable to be initialized with the
6215 @option{-fno-common} flag or the @code{nocommon} attribute.
6217 Some file formats do not support arbitrary sections so the @code{section}
6218 attribute is not available on all platforms.
6219 If you need to map the entire contents of a module to a particular
6220 section, consider using the facilities of the linker instead.
6222 @item tls_model ("@var{tls_model}")
6223 @cindex @code{tls_model} variable attribute
6224 The @code{tls_model} attribute sets thread-local storage model
6225 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6226 overriding @option{-ftls-model=} command-line switch on a per-variable
6227 basis.
6228 The @var{tls_model} argument should be one of @code{global-dynamic},
6229 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6231 Not all targets support this attribute.
6233 @item unused
6234 @cindex @code{unused} variable attribute
6235 This attribute, attached to a variable, means that the variable is meant
6236 to be possibly unused.  GCC does not produce a warning for this
6237 variable.
6239 @item used
6240 @cindex @code{used} variable attribute
6241 This attribute, attached to a variable with static storage, means that
6242 the variable must be emitted even if it appears that the variable is not
6243 referenced.
6245 When applied to a static data member of a C++ class template, the
6246 attribute also means that the member is instantiated if the
6247 class itself is instantiated.
6249 @item vector_size (@var{bytes})
6250 @cindex @code{vector_size} variable attribute
6251 This attribute specifies the vector size for the variable, measured in
6252 bytes.  For example, the declaration:
6254 @smallexample
6255 int foo __attribute__ ((vector_size (16)));
6256 @end smallexample
6258 @noindent
6259 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6260 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6261 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6263 This attribute is only applicable to integral and float scalars,
6264 although arrays, pointers, and function return values are allowed in
6265 conjunction with this construct.
6267 Aggregates with this attribute are invalid, even if they are of the same
6268 size as a corresponding scalar.  For example, the declaration:
6270 @smallexample
6271 struct S @{ int a; @};
6272 struct S  __attribute__ ((vector_size (16))) foo;
6273 @end smallexample
6275 @noindent
6276 is invalid even if the size of the structure is the same as the size of
6277 the @code{int}.
6279 @item visibility ("@var{visibility_type}")
6280 @cindex @code{visibility} variable attribute
6281 This attribute affects the linkage of the declaration to which it is attached.
6282 The @code{visibility} attribute is described in
6283 @ref{Common Function Attributes}.
6285 @item weak
6286 @cindex @code{weak} variable attribute
6287 The @code{weak} attribute is described in
6288 @ref{Common Function Attributes}.
6290 @end table
6292 @node ARC Variable Attributes
6293 @subsection ARC Variable Attributes
6295 @table @code
6296 @item aux
6297 @cindex @code{aux} variable attribute, ARC
6298 The @code{aux} attribute is used to directly access the ARC's
6299 auxiliary register space from C.  The auxilirary register number is
6300 given via attribute argument.
6302 @end table
6304 @node AVR Variable Attributes
6305 @subsection AVR Variable Attributes
6307 @table @code
6308 @item progmem
6309 @cindex @code{progmem} variable attribute, AVR
6310 The @code{progmem} attribute is used on the AVR to place read-only
6311 data in the non-volatile program memory (flash). The @code{progmem}
6312 attribute accomplishes this by putting respective variables into a
6313 section whose name starts with @code{.progmem}.
6315 This attribute works similar to the @code{section} attribute
6316 but adds additional checking.
6318 @table @asis
6319 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6320 @code{progmem} affects the location
6321 of the data but not how this data is accessed.
6322 In order to read data located with the @code{progmem} attribute
6323 (inline) assembler must be used.
6324 @smallexample
6325 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6326 #include <avr/pgmspace.h> 
6328 /* Locate var in flash memory */
6329 const int var[2] PROGMEM = @{ 1, 2 @};
6331 int read_var (int i)
6333     /* Access var[] by accessor macro from avr/pgmspace.h */
6334     return (int) pgm_read_word (& var[i]);
6336 @end smallexample
6338 AVR is a Harvard architecture processor and data and read-only data
6339 normally resides in the data memory (RAM).
6341 See also the @ref{AVR Named Address Spaces} section for
6342 an alternate way to locate and access data in flash memory.
6344 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6345 On such devices, there is no need for attribute @code{progmem} or
6346 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6347 Just use standard C / C++.  The compiler will generate @code{LD*}
6348 instructions.  As flash memory is visible in the RAM address range,
6349 and the default linker script does @emph{not} locate @code{.rodata} in
6350 RAM, no special features are needed in order not to waste RAM for
6351 read-only data or to read from flash.  You might even get slightly better
6352 performance by
6353 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6354 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6355 an overview.
6357 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6358 The compiler adds @code{0x4000}
6359 to the addresses of objects and declarations in @code{progmem} and locates
6360 the objects in flash memory, namely in section @code{.progmem.data}.
6361 The offset is needed because the flash memory is visible in the RAM
6362 address space starting at address @code{0x4000}.
6364 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6365 no special functions or macros are needed.
6367 @smallexample
6368 /* var is located in flash memory */
6369 extern const int var[2] __attribute__((progmem));
6371 int read_var (int i)
6373     return var[i];
6375 @end smallexample
6377 Please notice that on these devices, there is no need for @code{progmem}
6378 at all.
6380 @end table
6382 @item io
6383 @itemx io (@var{addr})
6384 @cindex @code{io} variable attribute, AVR
6385 Variables with the @code{io} attribute are used to address
6386 memory-mapped peripherals in the io address range.
6387 If an address is specified, the variable
6388 is assigned that address, and the value is interpreted as an
6389 address in the data address space.
6390 Example:
6392 @smallexample
6393 volatile int porta __attribute__((io (0x22)));
6394 @end smallexample
6396 The address specified in the address in the data address range.
6398 Otherwise, the variable it is not assigned an address, but the
6399 compiler will still use in/out instructions where applicable,
6400 assuming some other module assigns an address in the io address range.
6401 Example:
6403 @smallexample
6404 extern volatile int porta __attribute__((io));
6405 @end smallexample
6407 @item io_low
6408 @itemx io_low (@var{addr})
6409 @cindex @code{io_low} variable attribute, AVR
6410 This is like the @code{io} attribute, but additionally it informs the
6411 compiler that the object lies in the lower half of the I/O area,
6412 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6413 instructions.
6415 @item address
6416 @itemx address (@var{addr})
6417 @cindex @code{address} variable attribute, AVR
6418 Variables with the @code{address} attribute are used to address
6419 memory-mapped peripherals that may lie outside the io address range.
6421 @smallexample
6422 volatile int porta __attribute__((address (0x600)));
6423 @end smallexample
6425 @item absdata
6426 @cindex @code{absdata} variable attribute, AVR
6427 Variables in static storage and with the @code{absdata} attribute can
6428 be accessed by the @code{LDS} and @code{STS} instructions which take
6429 absolute addresses.
6431 @itemize @bullet
6432 @item
6433 This attribute is only supported for the reduced AVR Tiny core
6434 like ATtiny40.
6436 @item
6437 You must make sure that respective data is located in the
6438 address range @code{0x40}@dots{}@code{0xbf} accessible by
6439 @code{LDS} and @code{STS}.  One way to achieve this as an
6440 appropriate linker description file.
6442 @item
6443 If the location does not fit the address range of @code{LDS}
6444 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6445 warning like
6446 @quotation
6447 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6448 @end quotation
6450 @end itemize
6452 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6454 @end table
6456 @node Blackfin Variable Attributes
6457 @subsection Blackfin Variable Attributes
6459 Three attributes are currently defined for the Blackfin.
6461 @table @code
6462 @item l1_data
6463 @itemx l1_data_A
6464 @itemx l1_data_B
6465 @cindex @code{l1_data} variable attribute, Blackfin
6466 @cindex @code{l1_data_A} variable attribute, Blackfin
6467 @cindex @code{l1_data_B} variable attribute, Blackfin
6468 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6469 Variables with @code{l1_data} attribute are put into the specific section
6470 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6471 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6472 attribute are put into the specific section named @code{.l1.data.B}.
6474 @item l2
6475 @cindex @code{l2} variable attribute, Blackfin
6476 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6477 Variables with @code{l2} attribute are put into the specific section
6478 named @code{.l2.data}.
6479 @end table
6481 @node H8/300 Variable Attributes
6482 @subsection H8/300 Variable Attributes
6484 These variable attributes are available for H8/300 targets:
6486 @table @code
6487 @item eightbit_data
6488 @cindex @code{eightbit_data} variable attribute, H8/300
6489 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6490 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6491 variable should be placed into the eight-bit data section.
6492 The compiler generates more efficient code for certain operations
6493 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6494 256 bytes of data.
6496 You must use GAS and GLD from GNU binutils version 2.7 or later for
6497 this attribute to work correctly.
6499 @item tiny_data
6500 @cindex @code{tiny_data} variable attribute, H8/300
6501 @cindex tiny data section on the H8/300H and H8S
6502 Use this attribute on the H8/300H and H8S to indicate that the specified
6503 variable should be placed into the tiny data section.
6504 The compiler generates more efficient code for loads and stores
6505 on data in the tiny data section.  Note the tiny data area is limited to
6506 slightly under 32KB of data.
6508 @end table
6510 @node IA-64 Variable Attributes
6511 @subsection IA-64 Variable Attributes
6513 The IA-64 back end supports the following variable attribute:
6515 @table @code
6516 @item model (@var{model-name})
6517 @cindex @code{model} variable attribute, IA-64
6519 On IA-64, use this attribute to set the addressability of an object.
6520 At present, the only supported identifier for @var{model-name} is
6521 @code{small}, indicating addressability via ``small'' (22-bit)
6522 addresses (so that their addresses can be loaded with the @code{addl}
6523 instruction).  Caveat: such addressing is by definition not position
6524 independent and hence this attribute must not be used for objects
6525 defined by shared libraries.
6527 @end table
6529 @node M32R/D Variable Attributes
6530 @subsection M32R/D Variable Attributes
6532 One attribute is currently defined for the M32R/D@.
6534 @table @code
6535 @item model (@var{model-name})
6536 @cindex @code{model-name} variable attribute, M32R/D
6537 @cindex variable addressability on the M32R/D
6538 Use this attribute on the M32R/D to set the addressability of an object.
6539 The identifier @var{model-name} is one of @code{small}, @code{medium},
6540 or @code{large}, representing each of the code models.
6542 Small model objects live in the lower 16MB of memory (so that their
6543 addresses can be loaded with the @code{ld24} instruction).
6545 Medium and large model objects may live anywhere in the 32-bit address space
6546 (the compiler generates @code{seth/add3} instructions to load their
6547 addresses).
6548 @end table
6550 @node MeP Variable Attributes
6551 @subsection MeP Variable Attributes
6553 The MeP target has a number of addressing modes and busses.  The
6554 @code{near} space spans the standard memory space's first 16 megabytes
6555 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6556 The @code{based} space is a 128-byte region in the memory space that
6557 is addressed relative to the @code{$tp} register.  The @code{tiny}
6558 space is a 65536-byte region relative to the @code{$gp} register.  In
6559 addition to these memory regions, the MeP target has a separate 16-bit
6560 control bus which is specified with @code{cb} attributes.
6562 @table @code
6564 @item based
6565 @cindex @code{based} variable attribute, MeP
6566 Any variable with the @code{based} attribute is assigned to the
6567 @code{.based} section, and is accessed with relative to the
6568 @code{$tp} register.
6570 @item tiny
6571 @cindex @code{tiny} variable attribute, MeP
6572 Likewise, the @code{tiny} attribute assigned variables to the
6573 @code{.tiny} section, relative to the @code{$gp} register.
6575 @item near
6576 @cindex @code{near} variable attribute, MeP
6577 Variables with the @code{near} attribute are assumed to have addresses
6578 that fit in a 24-bit addressing mode.  This is the default for large
6579 variables (@code{-mtiny=4} is the default) but this attribute can
6580 override @code{-mtiny=} for small variables, or override @code{-ml}.
6582 @item far
6583 @cindex @code{far} variable attribute, MeP
6584 Variables with the @code{far} attribute are addressed using a full
6585 32-bit address.  Since this covers the entire memory space, this
6586 allows modules to make no assumptions about where variables might be
6587 stored.
6589 @item io
6590 @cindex @code{io} variable attribute, MeP
6591 @itemx io (@var{addr})
6592 Variables with the @code{io} attribute are used to address
6593 memory-mapped peripherals.  If an address is specified, the variable
6594 is assigned that address, else it is not assigned an address (it is
6595 assumed some other module assigns an address).  Example:
6597 @smallexample
6598 int timer_count __attribute__((io(0x123)));
6599 @end smallexample
6601 @item cb
6602 @itemx cb (@var{addr})
6603 @cindex @code{cb} variable attribute, MeP
6604 Variables with the @code{cb} attribute are used to access the control
6605 bus, using special instructions.  @code{addr} indicates the control bus
6606 address.  Example:
6608 @smallexample
6609 int cpu_clock __attribute__((cb(0x123)));
6610 @end smallexample
6612 @end table
6614 @node Microsoft Windows Variable Attributes
6615 @subsection Microsoft Windows Variable Attributes
6617 You can use these attributes on Microsoft Windows targets.
6618 @ref{x86 Variable Attributes} for additional Windows compatibility
6619 attributes available on all x86 targets.
6621 @table @code
6622 @item dllimport
6623 @itemx dllexport
6624 @cindex @code{dllimport} variable attribute
6625 @cindex @code{dllexport} variable attribute
6626 The @code{dllimport} and @code{dllexport} attributes are described in
6627 @ref{Microsoft Windows Function Attributes}.
6629 @item selectany
6630 @cindex @code{selectany} variable attribute
6631 The @code{selectany} attribute causes an initialized global variable to
6632 have link-once semantics.  When multiple definitions of the variable are
6633 encountered by the linker, the first is selected and the remainder are
6634 discarded.  Following usage by the Microsoft compiler, the linker is told
6635 @emph{not} to warn about size or content differences of the multiple
6636 definitions.
6638 Although the primary usage of this attribute is for POD types, the
6639 attribute can also be applied to global C++ objects that are initialized
6640 by a constructor.  In this case, the static initialization and destruction
6641 code for the object is emitted in each translation defining the object,
6642 but the calls to the constructor and destructor are protected by a
6643 link-once guard variable.
6645 The @code{selectany} attribute is only available on Microsoft Windows
6646 targets.  You can use @code{__declspec (selectany)} as a synonym for
6647 @code{__attribute__ ((selectany))} for compatibility with other
6648 compilers.
6650 @item shared
6651 @cindex @code{shared} variable attribute
6652 On Microsoft Windows, in addition to putting variable definitions in a named
6653 section, the section can also be shared among all running copies of an
6654 executable or DLL@.  For example, this small program defines shared data
6655 by putting it in a named section @code{shared} and marking the section
6656 shareable:
6658 @smallexample
6659 int foo __attribute__((section ("shared"), shared)) = 0;
6662 main()
6664   /* @r{Read and write foo.  All running
6665      copies see the same value.}  */
6666   return 0;
6668 @end smallexample
6670 @noindent
6671 You may only use the @code{shared} attribute along with @code{section}
6672 attribute with a fully-initialized global definition because of the way
6673 linkers work.  See @code{section} attribute for more information.
6675 The @code{shared} attribute is only available on Microsoft Windows@.
6677 @end table
6679 @node MSP430 Variable Attributes
6680 @subsection MSP430 Variable Attributes
6682 @table @code
6683 @item noinit
6684 @cindex @code{noinit} variable attribute, MSP430 
6685 Any data with the @code{noinit} attribute will not be initialised by
6686 the C runtime startup code, or the program loader.  Not initialising
6687 data in this way can reduce program startup times.
6689 @item persistent
6690 @cindex @code{persistent} variable attribute, MSP430 
6691 Any variable with the @code{persistent} attribute will not be
6692 initialised by the C runtime startup code.  Instead its value will be
6693 set once, when the application is loaded, and then never initialised
6694 again, even if the processor is reset or the program restarts.
6695 Persistent data is intended to be placed into FLASH RAM, where its
6696 value will be retained across resets.  The linker script being used to
6697 create the application should ensure that persistent data is correctly
6698 placed.
6700 @item lower
6701 @itemx upper
6702 @itemx either
6703 @cindex @code{lower} variable attribute, MSP430 
6704 @cindex @code{upper} variable attribute, MSP430 
6705 @cindex @code{either} variable attribute, MSP430 
6706 These attributes are the same as the MSP430 function attributes of the
6707 same name (@pxref{MSP430 Function Attributes}).  
6708 These attributes can be applied to both functions and variables.
6709 @end table
6711 @node Nvidia PTX Variable Attributes
6712 @subsection Nvidia PTX Variable Attributes
6714 These variable attributes are supported by the Nvidia PTX back end:
6716 @table @code
6717 @item shared
6718 @cindex @code{shared} attribute, Nvidia PTX
6719 Use this attribute to place a variable in the @code{.shared} memory space.
6720 This memory space is private to each cooperative thread array; only threads
6721 within one thread block refer to the same instance of the variable.
6722 The runtime does not initialize variables in this memory space.
6723 @end table
6725 @node PowerPC Variable Attributes
6726 @subsection PowerPC Variable Attributes
6728 Three attributes currently are defined for PowerPC configurations:
6729 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6731 @cindex @code{ms_struct} variable attribute, PowerPC
6732 @cindex @code{gcc_struct} variable attribute, PowerPC
6733 For full documentation of the struct attributes please see the
6734 documentation in @ref{x86 Variable Attributes}.
6736 @cindex @code{altivec} variable attribute, PowerPC
6737 For documentation of @code{altivec} attribute please see the
6738 documentation in @ref{PowerPC Type Attributes}.
6740 @node RL78 Variable Attributes
6741 @subsection RL78 Variable Attributes
6743 @cindex @code{saddr} variable attribute, RL78
6744 The RL78 back end supports the @code{saddr} variable attribute.  This
6745 specifies placement of the corresponding variable in the SADDR area,
6746 which can be accessed more efficiently than the default memory region.
6748 @node SPU Variable Attributes
6749 @subsection SPU Variable Attributes
6751 @cindex @code{spu_vector} variable attribute, SPU
6752 The SPU supports the @code{spu_vector} attribute for variables.  For
6753 documentation of this attribute please see the documentation in
6754 @ref{SPU Type Attributes}.
6756 @node V850 Variable Attributes
6757 @subsection V850 Variable Attributes
6759 These variable attributes are supported by the V850 back end:
6761 @table @code
6763 @item sda
6764 @cindex @code{sda} variable attribute, V850
6765 Use this attribute to explicitly place a variable in the small data area,
6766 which can hold up to 64 kilobytes.
6768 @item tda
6769 @cindex @code{tda} variable attribute, V850
6770 Use this attribute to explicitly place a variable in the tiny data area,
6771 which can hold up to 256 bytes in total.
6773 @item zda
6774 @cindex @code{zda} variable attribute, V850
6775 Use this attribute to explicitly place a variable in the first 32 kilobytes
6776 of memory.
6777 @end table
6779 @node x86 Variable Attributes
6780 @subsection x86 Variable Attributes
6782 Two attributes are currently defined for x86 configurations:
6783 @code{ms_struct} and @code{gcc_struct}.
6785 @table @code
6786 @item ms_struct
6787 @itemx gcc_struct
6788 @cindex @code{ms_struct} variable attribute, x86
6789 @cindex @code{gcc_struct} variable attribute, x86
6791 If @code{packed} is used on a structure, or if bit-fields are used,
6792 it may be that the Microsoft ABI lays out the structure differently
6793 than the way GCC normally does.  Particularly when moving packed
6794 data between functions compiled with GCC and the native Microsoft compiler
6795 (either via function call or as data in a file), it may be necessary to access
6796 either format.
6798 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6799 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6800 command-line options, respectively;
6801 see @ref{x86 Options}, for details of how structure layout is affected.
6802 @xref{x86 Type Attributes}, for information about the corresponding
6803 attributes on types.
6805 @end table
6807 @node Xstormy16 Variable Attributes
6808 @subsection Xstormy16 Variable Attributes
6810 One attribute is currently defined for xstormy16 configurations:
6811 @code{below100}.
6813 @table @code
6814 @item below100
6815 @cindex @code{below100} variable attribute, Xstormy16
6817 If a variable has the @code{below100} attribute (@code{BELOW100} is
6818 allowed also), GCC places the variable in the first 0x100 bytes of
6819 memory and use special opcodes to access it.  Such variables are
6820 placed in either the @code{.bss_below100} section or the
6821 @code{.data_below100} section.
6823 @end table
6825 @node Type Attributes
6826 @section Specifying Attributes of Types
6827 @cindex attribute of types
6828 @cindex type attributes
6830 The keyword @code{__attribute__} allows you to specify special
6831 attributes of types.  Some type attributes apply only to @code{struct}
6832 and @code{union} types, while others can apply to any type defined
6833 via a @code{typedef} declaration.  Other attributes are defined for
6834 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6835 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6836 statements (@pxref{Statement Attributes}), and for
6837 variables (@pxref{Variable Attributes}).
6839 The @code{__attribute__} keyword is followed by an attribute specification
6840 inside double parentheses.  
6842 You may specify type attributes in an enum, struct or union type
6843 declaration or definition by placing them immediately after the
6844 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6845 syntax is to place them just past the closing curly brace of the
6846 definition.
6848 You can also include type attributes in a @code{typedef} declaration.
6849 @xref{Attribute Syntax}, for details of the exact syntax for using
6850 attributes.
6852 @menu
6853 * Common Type Attributes::
6854 * ARC Type Attributes::
6855 * ARM Type Attributes::
6856 * MeP Type Attributes::
6857 * PowerPC Type Attributes::
6858 * SPU Type Attributes::
6859 * x86 Type Attributes::
6860 @end menu
6862 @node Common Type Attributes
6863 @subsection Common Type Attributes
6865 The following type attributes are supported on most targets.
6867 @table @code
6868 @cindex @code{aligned} type attribute
6869 @item aligned (@var{alignment})
6870 This attribute specifies a minimum alignment (in bytes) for variables
6871 of the specified type.  For example, the declarations:
6873 @smallexample
6874 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6875 typedef int more_aligned_int __attribute__ ((aligned (8)));
6876 @end smallexample
6878 @noindent
6879 force the compiler to ensure (as far as it can) that each variable whose
6880 type is @code{struct S} or @code{more_aligned_int} is allocated and
6881 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6882 variables of type @code{struct S} aligned to 8-byte boundaries allows
6883 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6884 store) instructions when copying one variable of type @code{struct S} to
6885 another, thus improving run-time efficiency.
6887 Note that the alignment of any given @code{struct} or @code{union} type
6888 is required by the ISO C standard to be at least a perfect multiple of
6889 the lowest common multiple of the alignments of all of the members of
6890 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6891 effectively adjust the alignment of a @code{struct} or @code{union}
6892 type by attaching an @code{aligned} attribute to any one of the members
6893 of such a type, but the notation illustrated in the example above is a
6894 more obvious, intuitive, and readable way to request the compiler to
6895 adjust the alignment of an entire @code{struct} or @code{union} type.
6897 As in the preceding example, you can explicitly specify the alignment
6898 (in bytes) that you wish the compiler to use for a given @code{struct}
6899 or @code{union} type.  Alternatively, you can leave out the alignment factor
6900 and just ask the compiler to align a type to the maximum
6901 useful alignment for the target machine you are compiling for.  For
6902 example, you could write:
6904 @smallexample
6905 struct S @{ short f[3]; @} __attribute__ ((aligned));
6906 @end smallexample
6908 Whenever you leave out the alignment factor in an @code{aligned}
6909 attribute specification, the compiler automatically sets the alignment
6910 for the type to the largest alignment that is ever used for any data
6911 type on the target machine you are compiling for.  Doing this can often
6912 make copy operations more efficient, because the compiler can use
6913 whatever instructions copy the biggest chunks of memory when performing
6914 copies to or from the variables that have types that you have aligned
6915 this way.
6917 In the example above, if the size of each @code{short} is 2 bytes, then
6918 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6919 power of two that is greater than or equal to that is 8, so the
6920 compiler sets the alignment for the entire @code{struct S} type to 8
6921 bytes.
6923 Note that although you can ask the compiler to select a time-efficient
6924 alignment for a given type and then declare only individual stand-alone
6925 objects of that type, the compiler's ability to select a time-efficient
6926 alignment is primarily useful only when you plan to create arrays of
6927 variables having the relevant (efficiently aligned) type.  If you
6928 declare or use arrays of variables of an efficiently-aligned type, then
6929 it is likely that your program also does pointer arithmetic (or
6930 subscripting, which amounts to the same thing) on pointers to the
6931 relevant type, and the code that the compiler generates for these
6932 pointer arithmetic operations is often more efficient for
6933 efficiently-aligned types than for other types.
6935 Note that the effectiveness of @code{aligned} attributes may be limited
6936 by inherent limitations in your linker.  On many systems, the linker is
6937 only able to arrange for variables to be aligned up to a certain maximum
6938 alignment.  (For some linkers, the maximum supported alignment may
6939 be very very small.)  If your linker is only able to align variables
6940 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6941 in an @code{__attribute__} still only provides you with 8-byte
6942 alignment.  See your linker documentation for further information.
6944 The @code{aligned} attribute can only increase alignment.  Alignment
6945 can be decreased by specifying the @code{packed} attribute.  See below.
6947 @cindex @code{warn_if_not_aligned} type attribute
6948 @item warn_if_not_aligned (@var{alignment})
6949 This attribute specifies a threshold for the structure field, measured
6950 in bytes.  If the structure field is aligned below the threshold, a
6951 warning will be issued.  For example, the declaration:
6953 @smallexample
6954 typedef unsigned long long __u64
6955    __attribute__((aligned(4),warn_if_not_aligned(8)));
6957 struct foo
6959   int i1;
6960   int i2;
6961   __u64 x;
6963 @end smallexample
6965 @noindent
6966 causes the compiler to issue an warning on @code{struct foo}, like
6967 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
6968 It is used to define @code{struct foo} in such a way that
6969 @code{struct foo} has the same layout and the structure field @code{x}
6970 has the same alignment when @code{__u64} is aligned at either 4 or
6971 8 bytes.  Align @code{struct foo} to 8 bytes:
6973 @smallexample
6974 struct foo
6976   int i1;
6977   int i2;
6978   __u64 x;
6979 @} __attribute__((aligned(8)));
6980 @end smallexample
6982 @noindent
6983 silences the warning.  The compiler also issues a warning, like
6984 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
6985 when the structure field has the misaligned offset:
6987 @smallexample
6988 struct foo
6990   int i1;
6991   int i2;
6992   int i3;
6993   __u64 x;
6994 @} __attribute__((aligned(8)));
6995 @end smallexample
6997 This warning can be disabled by @option{-Wno-if-not-aligned}.
6999 @item deprecated
7000 @itemx deprecated (@var{msg})
7001 @cindex @code{deprecated} type attribute
7002 The @code{deprecated} attribute results in a warning if the type
7003 is used anywhere in the source file.  This is useful when identifying
7004 types that are expected to be removed in a future version of a program.
7005 If possible, the warning also includes the location of the declaration
7006 of the deprecated type, to enable users to easily find further
7007 information about why the type is deprecated, or what they should do
7008 instead.  Note that the warnings only occur for uses and then only
7009 if the type is being applied to an identifier that itself is not being
7010 declared as deprecated.
7012 @smallexample
7013 typedef int T1 __attribute__ ((deprecated));
7014 T1 x;
7015 typedef T1 T2;
7016 T2 y;
7017 typedef T1 T3 __attribute__ ((deprecated));
7018 T3 z __attribute__ ((deprecated));
7019 @end smallexample
7021 @noindent
7022 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7023 warning is issued for line 4 because T2 is not explicitly
7024 deprecated.  Line 5 has no warning because T3 is explicitly
7025 deprecated.  Similarly for line 6.  The optional @var{msg}
7026 argument, which must be a string, is printed in the warning if
7027 present.  Control characters in the string will be replaced with
7028 escape sequences, and if the @option{-fmessage-length} option is set
7029 to 0 (its default value) then any newline characters will be ignored.
7031 The @code{deprecated} attribute can also be used for functions and
7032 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7034 The message attached to the attribute is affected by the setting of
7035 the @option{-fmessage-length} option.
7037 @item designated_init
7038 @cindex @code{designated_init} type attribute
7039 This attribute may only be applied to structure types.  It indicates
7040 that any initialization of an object of this type must use designated
7041 initializers rather than positional initializers.  The intent of this
7042 attribute is to allow the programmer to indicate that a structure's
7043 layout may change, and that therefore relying on positional
7044 initialization will result in future breakage.
7046 GCC emits warnings based on this attribute by default; use
7047 @option{-Wno-designated-init} to suppress them.
7049 @item may_alias
7050 @cindex @code{may_alias} type attribute
7051 Accesses through pointers to types with this attribute are not subject
7052 to type-based alias analysis, but are instead assumed to be able to alias
7053 any other type of objects.
7054 In the context of section 6.5 paragraph 7 of the C99 standard,
7055 an lvalue expression
7056 dereferencing such a pointer is treated like having a character type.
7057 See @option{-fstrict-aliasing} for more information on aliasing issues.
7058 This extension exists to support some vector APIs, in which pointers to
7059 one vector type are permitted to alias pointers to a different vector type.
7061 Note that an object of a type with this attribute does not have any
7062 special semantics.
7064 Example of use:
7066 @smallexample
7067 typedef short __attribute__((__may_alias__)) short_a;
7070 main (void)
7072   int a = 0x12345678;
7073   short_a *b = (short_a *) &a;
7075   b[1] = 0;
7077   if (a == 0x12345678)
7078     abort();
7080   exit(0);
7082 @end smallexample
7084 @noindent
7085 If you replaced @code{short_a} with @code{short} in the variable
7086 declaration, the above program would abort when compiled with
7087 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7088 above.
7090 @item packed
7091 @cindex @code{packed} type attribute
7092 This attribute, attached to @code{struct} or @code{union} type
7093 definition, specifies that each member (other than zero-width bit-fields)
7094 of the structure or union is placed to minimize the memory required.  When
7095 attached to an @code{enum} definition, it indicates that the smallest
7096 integral type should be used.
7098 @opindex fshort-enums
7099 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7100 types is equivalent to specifying the @code{packed} attribute on each
7101 of the structure or union members.  Specifying the @option{-fshort-enums}
7102 flag on the command line is equivalent to specifying the @code{packed}
7103 attribute on all @code{enum} definitions.
7105 In the following example @code{struct my_packed_struct}'s members are
7106 packed closely together, but the internal layout of its @code{s} member
7107 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7108 be packed too.
7110 @smallexample
7111 struct my_unpacked_struct
7112  @{
7113     char c;
7114     int i;
7115  @};
7117 struct __attribute__ ((__packed__)) my_packed_struct
7118   @{
7119      char c;
7120      int  i;
7121      struct my_unpacked_struct s;
7122   @};
7123 @end smallexample
7125 You may only specify the @code{packed} attribute attribute on the definition
7126 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7127 that does not also define the enumerated type, structure or union.
7129 @item scalar_storage_order ("@var{endianness}")
7130 @cindex @code{scalar_storage_order} type attribute
7131 When attached to a @code{union} or a @code{struct}, this attribute sets
7132 the storage order, aka endianness, of the scalar fields of the type, as
7133 well as the array fields whose component is scalar.  The supported
7134 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
7135 has no effects on fields which are themselves a @code{union}, a @code{struct}
7136 or an array whose component is a @code{union} or a @code{struct}, and it is
7137 possible for these fields to have a different scalar storage order than the
7138 enclosing type.
7140 This attribute is supported only for targets that use a uniform default
7141 scalar storage order (fortunately, most of them), i.e. targets that store
7142 the scalars either all in big-endian or all in little-endian.
7144 Additional restrictions are enforced for types with the reverse scalar
7145 storage order with regard to the scalar storage order of the target:
7147 @itemize
7148 @item Taking the address of a scalar field of a @code{union} or a
7149 @code{struct} with reverse scalar storage order is not permitted and yields
7150 an error.
7151 @item Taking the address of an array field, whose component is scalar, of
7152 a @code{union} or a @code{struct} with reverse scalar storage order is
7153 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7154 is specified.
7155 @item Taking the address of a @code{union} or a @code{struct} with reverse
7156 scalar storage order is permitted.
7157 @end itemize
7159 These restrictions exist because the storage order attribute is lost when
7160 the address of a scalar or the address of an array with scalar component is
7161 taken, so storing indirectly through this address generally does not work.
7162 The second case is nevertheless allowed to be able to perform a block copy
7163 from or to the array.
7165 Moreover, the use of type punning or aliasing to toggle the storage order
7166 is not supported; that is to say, a given scalar object cannot be accessed
7167 through distinct types that assign a different storage order to it.
7169 @item transparent_union
7170 @cindex @code{transparent_union} type attribute
7172 This attribute, attached to a @code{union} type definition, indicates
7173 that any function parameter having that union type causes calls to that
7174 function to be treated in a special way.
7176 First, the argument corresponding to a transparent union type can be of
7177 any type in the union; no cast is required.  Also, if the union contains
7178 a pointer type, the corresponding argument can be a null pointer
7179 constant or a void pointer expression; and if the union contains a void
7180 pointer type, the corresponding argument can be any pointer expression.
7181 If the union member type is a pointer, qualifiers like @code{const} on
7182 the referenced type must be respected, just as with normal pointer
7183 conversions.
7185 Second, the argument is passed to the function using the calling
7186 conventions of the first member of the transparent union, not the calling
7187 conventions of the union itself.  All members of the union must have the
7188 same machine representation; this is necessary for this argument passing
7189 to work properly.
7191 Transparent unions are designed for library functions that have multiple
7192 interfaces for compatibility reasons.  For example, suppose the
7193 @code{wait} function must accept either a value of type @code{int *} to
7194 comply with POSIX, or a value of type @code{union wait *} to comply with
7195 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7196 @code{wait} would accept both kinds of arguments, but it would also
7197 accept any other pointer type and this would make argument type checking
7198 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7199 as follows:
7201 @smallexample
7202 typedef union __attribute__ ((__transparent_union__))
7203   @{
7204     int *__ip;
7205     union wait *__up;
7206   @} wait_status_ptr_t;
7208 pid_t wait (wait_status_ptr_t);
7209 @end smallexample
7211 @noindent
7212 This interface allows either @code{int *} or @code{union wait *}
7213 arguments to be passed, using the @code{int *} calling convention.
7214 The program can call @code{wait} with arguments of either type:
7216 @smallexample
7217 int w1 () @{ int w; return wait (&w); @}
7218 int w2 () @{ union wait w; return wait (&w); @}
7219 @end smallexample
7221 @noindent
7222 With this interface, @code{wait}'s implementation might look like this:
7224 @smallexample
7225 pid_t wait (wait_status_ptr_t p)
7227   return waitpid (-1, p.__ip, 0);
7229 @end smallexample
7231 @item unused
7232 @cindex @code{unused} type attribute
7233 When attached to a type (including a @code{union} or a @code{struct}),
7234 this attribute means that variables of that type are meant to appear
7235 possibly unused.  GCC does not produce a warning for any variables of
7236 that type, even if the variable appears to do nothing.  This is often
7237 the case with lock or thread classes, which are usually defined and then
7238 not referenced, but contain constructors and destructors that have
7239 nontrivial bookkeeping functions.
7241 @item visibility
7242 @cindex @code{visibility} type attribute
7243 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7244 applied to class, struct, union and enum types.  Unlike other type
7245 attributes, the attribute must appear between the initial keyword and
7246 the name of the type; it cannot appear after the body of the type.
7248 Note that the type visibility is applied to vague linkage entities
7249 associated with the class (vtable, typeinfo node, etc.).  In
7250 particular, if a class is thrown as an exception in one shared object
7251 and caught in another, the class must have default visibility.
7252 Otherwise the two shared objects are unable to use the same
7253 typeinfo node and exception handling will break.
7255 @end table
7257 To specify multiple attributes, separate them by commas within the
7258 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7259 packed))}.
7261 @node ARC Type Attributes
7262 @subsection ARC Type Attributes
7264 @cindex @code{uncached} type attribute, ARC
7265 Declaring objects with @code{uncached} allows you to exclude
7266 data-cache participation in load and store operations on those objects
7267 without involving the additional semantic implications of
7268 @code{volatile}.  The @code{.di} instruction suffix is used for all
7269 loads and stores of data declared @code{uncached}.
7271 @node ARM Type Attributes
7272 @subsection ARM Type Attributes
7274 @cindex @code{notshared} type attribute, ARM
7275 On those ARM targets that support @code{dllimport} (such as Symbian
7276 OS), you can use the @code{notshared} attribute to indicate that the
7277 virtual table and other similar data for a class should not be
7278 exported from a DLL@.  For example:
7280 @smallexample
7281 class __declspec(notshared) C @{
7282 public:
7283   __declspec(dllimport) C();
7284   virtual void f();
7287 __declspec(dllexport)
7288 C::C() @{@}
7289 @end smallexample
7291 @noindent
7292 In this code, @code{C::C} is exported from the current DLL, but the
7293 virtual table for @code{C} is not exported.  (You can use
7294 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7295 most Symbian OS code uses @code{__declspec}.)
7297 @node MeP Type Attributes
7298 @subsection MeP Type Attributes
7300 @cindex @code{based} type attribute, MeP
7301 @cindex @code{tiny} type attribute, MeP
7302 @cindex @code{near} type attribute, MeP
7303 @cindex @code{far} type attribute, MeP
7304 Many of the MeP variable attributes may be applied to types as well.
7305 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7306 @code{far} attributes may be applied to either.  The @code{io} and
7307 @code{cb} attributes may not be applied to types.
7309 @node PowerPC Type Attributes
7310 @subsection PowerPC Type Attributes
7312 Three attributes currently are defined for PowerPC configurations:
7313 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7315 @cindex @code{ms_struct} type attribute, PowerPC
7316 @cindex @code{gcc_struct} type attribute, PowerPC
7317 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7318 attributes please see the documentation in @ref{x86 Type Attributes}.
7320 @cindex @code{altivec} type attribute, PowerPC
7321 The @code{altivec} attribute allows one to declare AltiVec vector data
7322 types supported by the AltiVec Programming Interface Manual.  The
7323 attribute requires an argument to specify one of three vector types:
7324 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7325 and @code{bool__} (always followed by unsigned).
7327 @smallexample
7328 __attribute__((altivec(vector__)))
7329 __attribute__((altivec(pixel__))) unsigned short
7330 __attribute__((altivec(bool__))) unsigned
7331 @end smallexample
7333 These attributes mainly are intended to support the @code{__vector},
7334 @code{__pixel}, and @code{__bool} AltiVec keywords.
7336 @node SPU Type Attributes
7337 @subsection SPU Type Attributes
7339 @cindex @code{spu_vector} type attribute, SPU
7340 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7341 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7342 Language Extensions Specification.  It is intended to support the
7343 @code{__vector} keyword.
7345 @node x86 Type Attributes
7346 @subsection x86 Type Attributes
7348 Two attributes are currently defined for x86 configurations:
7349 @code{ms_struct} and @code{gcc_struct}.
7351 @table @code
7353 @item ms_struct
7354 @itemx gcc_struct
7355 @cindex @code{ms_struct} type attribute, x86
7356 @cindex @code{gcc_struct} type attribute, x86
7358 If @code{packed} is used on a structure, or if bit-fields are used
7359 it may be that the Microsoft ABI packs them differently
7360 than GCC normally packs them.  Particularly when moving packed
7361 data between functions compiled with GCC and the native Microsoft compiler
7362 (either via function call or as data in a file), it may be necessary to access
7363 either format.
7365 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7366 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7367 command-line options, respectively;
7368 see @ref{x86 Options}, for details of how structure layout is affected.
7369 @xref{x86 Variable Attributes}, for information about the corresponding
7370 attributes on variables.
7372 @end table
7374 @node Label Attributes
7375 @section Label Attributes
7376 @cindex Label Attributes
7378 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7379 details of the exact syntax for using attributes.  Other attributes are 
7380 available for functions (@pxref{Function Attributes}), variables 
7381 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7382 statements (@pxref{Statement Attributes}), and for types
7383 (@pxref{Type Attributes}).
7385 This example uses the @code{cold} label attribute to indicate the 
7386 @code{ErrorHandling} branch is unlikely to be taken and that the
7387 @code{ErrorHandling} label is unused:
7389 @smallexample
7391    asm goto ("some asm" : : : : NoError);
7393 /* This branch (the fall-through from the asm) is less commonly used */
7394 ErrorHandling: 
7395    __attribute__((cold, unused)); /* Semi-colon is required here */
7396    printf("error\n");
7397    return 0;
7399 NoError:
7400    printf("no error\n");
7401    return 1;
7402 @end smallexample
7404 @table @code
7405 @item unused
7406 @cindex @code{unused} label attribute
7407 This feature is intended for program-generated code that may contain 
7408 unused labels, but which is compiled with @option{-Wall}.  It is
7409 not normally appropriate to use in it human-written code, though it
7410 could be useful in cases where the code that jumps to the label is
7411 contained within an @code{#ifdef} conditional.
7413 @item hot
7414 @cindex @code{hot} label attribute
7415 The @code{hot} attribute on a label is used to inform the compiler that
7416 the path following the label is more likely than paths that are not so
7417 annotated.  This attribute is used in cases where @code{__builtin_expect}
7418 cannot be used, for instance with computed goto or @code{asm goto}.
7420 @item cold
7421 @cindex @code{cold} label attribute
7422 The @code{cold} attribute on labels is used to inform the compiler that
7423 the path following the label is unlikely to be executed.  This attribute
7424 is used in cases where @code{__builtin_expect} cannot be used, for instance
7425 with computed goto or @code{asm goto}.
7427 @end table
7429 @node Enumerator Attributes
7430 @section Enumerator Attributes
7431 @cindex Enumerator Attributes
7433 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7434 details of the exact syntax for using attributes.  Other attributes are
7435 available for functions (@pxref{Function Attributes}), variables
7436 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7437 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7439 This example uses the @code{deprecated} enumerator attribute to indicate the
7440 @code{oldval} enumerator is deprecated:
7442 @smallexample
7443 enum E @{
7444   oldval __attribute__((deprecated)),
7445   newval
7449 fn (void)
7451   return oldval;
7453 @end smallexample
7455 @table @code
7456 @item deprecated
7457 @cindex @code{deprecated} enumerator attribute
7458 The @code{deprecated} attribute results in a warning if the enumerator
7459 is used anywhere in the source file.  This is useful when identifying
7460 enumerators that are expected to be removed in a future version of a
7461 program.  The warning also includes the location of the declaration
7462 of the deprecated enumerator, to enable users to easily find further
7463 information about why the enumerator is deprecated, or what they should
7464 do instead.  Note that the warnings only occurs for uses.
7466 @end table
7468 @node Statement Attributes
7469 @section Statement Attributes
7470 @cindex Statement Attributes
7472 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7473 for details of the exact syntax for using attributes.  Other attributes are
7474 available for functions (@pxref{Function Attributes}), variables
7475 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7476 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7478 This example uses the @code{fallthrough} statement attribute to indicate that
7479 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7481 @smallexample
7482 switch (cond)
7483   @{
7484   case 1:
7485     bar (1);
7486     __attribute__((fallthrough));
7487   case 2:
7488     @dots{}
7489   @}
7490 @end smallexample
7492 @table @code
7493 @item fallthrough
7494 @cindex @code{fallthrough} statement attribute
7495 The @code{fallthrough} attribute with a null statement serves as a
7496 fallthrough statement.  It hints to the compiler that a statement
7497 that falls through to another case label, or user-defined label
7498 in a switch statement is intentional and thus the
7499 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7500 fallthrough attribute may appear at most once in each attribute
7501 list, and may not be mixed with other attributes.  It can only
7502 be used in a switch statement (the compiler will issue an error
7503 otherwise), after a preceding statement and before a logically
7504 succeeding case label, or user-defined label.
7506 @end table
7508 @node Attribute Syntax
7509 @section Attribute Syntax
7510 @cindex attribute syntax
7512 This section describes the syntax with which @code{__attribute__} may be
7513 used, and the constructs to which attribute specifiers bind, for the C
7514 language.  Some details may vary for C++ and Objective-C@.  Because of
7515 infelicities in the grammar for attributes, some forms described here
7516 may not be successfully parsed in all cases.
7518 There are some problems with the semantics of attributes in C++.  For
7519 example, there are no manglings for attributes, although they may affect
7520 code generation, so problems may arise when attributed types are used in
7521 conjunction with templates or overloading.  Similarly, @code{typeid}
7522 does not distinguish between types with different attributes.  Support
7523 for attributes in C++ may be restricted in future to attributes on
7524 declarations only, but not on nested declarators.
7526 @xref{Function Attributes}, for details of the semantics of attributes
7527 applying to functions.  @xref{Variable Attributes}, for details of the
7528 semantics of attributes applying to variables.  @xref{Type Attributes},
7529 for details of the semantics of attributes applying to structure, union
7530 and enumerated types.
7531 @xref{Label Attributes}, for details of the semantics of attributes 
7532 applying to labels.
7533 @xref{Enumerator Attributes}, for details of the semantics of attributes
7534 applying to enumerators.
7535 @xref{Statement Attributes}, for details of the semantics of attributes
7536 applying to statements.
7538 An @dfn{attribute specifier} is of the form
7539 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7540 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7541 each attribute is one of the following:
7543 @itemize @bullet
7544 @item
7545 Empty.  Empty attributes are ignored.
7547 @item
7548 An attribute name
7549 (which may be an identifier such as @code{unused}, or a reserved
7550 word such as @code{const}).
7552 @item
7553 An attribute name followed by a parenthesized list of
7554 parameters for the attribute.
7555 These parameters take one of the following forms:
7557 @itemize @bullet
7558 @item
7559 An identifier.  For example, @code{mode} attributes use this form.
7561 @item
7562 An identifier followed by a comma and a non-empty comma-separated list
7563 of expressions.  For example, @code{format} attributes use this form.
7565 @item
7566 A possibly empty comma-separated list of expressions.  For example,
7567 @code{format_arg} attributes use this form with the list being a single
7568 integer constant expression, and @code{alias} attributes use this form
7569 with the list being a single string constant.
7570 @end itemize
7571 @end itemize
7573 An @dfn{attribute specifier list} is a sequence of one or more attribute
7574 specifiers, not separated by any other tokens.
7576 You may optionally specify attribute names with @samp{__}
7577 preceding and following the name.
7578 This allows you to use them in header files without
7579 being concerned about a possible macro of the same name.  For example,
7580 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7583 @subsubheading Label Attributes
7585 In GNU C, an attribute specifier list may appear after the colon following a
7586 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7587 attributes on labels if the attribute specifier is immediately
7588 followed by a semicolon (i.e., the label applies to an empty
7589 statement).  If the semicolon is missing, C++ label attributes are
7590 ambiguous, as it is permissible for a declaration, which could begin
7591 with an attribute list, to be labelled in C++.  Declarations cannot be
7592 labelled in C90 or C99, so the ambiguity does not arise there.
7594 @subsubheading Enumerator Attributes
7596 In GNU C, an attribute specifier list may appear as part of an enumerator.
7597 The attribute goes after the enumeration constant, before @code{=}, if
7598 present.  The optional attribute in the enumerator appertains to the
7599 enumeration constant.  It is not possible to place the attribute after
7600 the constant expression, if present.
7602 @subsubheading Statement Attributes
7603 In GNU C, an attribute specifier list may appear as part of a null
7604 statement.  The attribute goes before the semicolon.
7606 @subsubheading Type Attributes
7608 An attribute specifier list may appear as part of a @code{struct},
7609 @code{union} or @code{enum} specifier.  It may go either immediately
7610 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7611 the closing brace.  The former syntax is preferred.
7612 Where attribute specifiers follow the closing brace, they are considered
7613 to relate to the structure, union or enumerated type defined, not to any
7614 enclosing declaration the type specifier appears in, and the type
7615 defined is not complete until after the attribute specifiers.
7616 @c Otherwise, there would be the following problems: a shift/reduce
7617 @c conflict between attributes binding the struct/union/enum and
7618 @c binding to the list of specifiers/qualifiers; and "aligned"
7619 @c attributes could use sizeof for the structure, but the size could be
7620 @c changed later by "packed" attributes.
7623 @subsubheading All other attributes
7625 Otherwise, an attribute specifier appears as part of a declaration,
7626 counting declarations of unnamed parameters and type names, and relates
7627 to that declaration (which may be nested in another declaration, for
7628 example in the case of a parameter declaration), or to a particular declarator
7629 within a declaration.  Where an
7630 attribute specifier is applied to a parameter declared as a function or
7631 an array, it should apply to the function or array rather than the
7632 pointer to which the parameter is implicitly converted, but this is not
7633 yet correctly implemented.
7635 Any list of specifiers and qualifiers at the start of a declaration may
7636 contain attribute specifiers, whether or not such a list may in that
7637 context contain storage class specifiers.  (Some attributes, however,
7638 are essentially in the nature of storage class specifiers, and only make
7639 sense where storage class specifiers may be used; for example,
7640 @code{section}.)  There is one necessary limitation to this syntax: the
7641 first old-style parameter declaration in a function definition cannot
7642 begin with an attribute specifier, because such an attribute applies to
7643 the function instead by syntax described below (which, however, is not
7644 yet implemented in this case).  In some other cases, attribute
7645 specifiers are permitted by this grammar but not yet supported by the
7646 compiler.  All attribute specifiers in this place relate to the
7647 declaration as a whole.  In the obsolescent usage where a type of
7648 @code{int} is implied by the absence of type specifiers, such a list of
7649 specifiers and qualifiers may be an attribute specifier list with no
7650 other specifiers or qualifiers.
7652 At present, the first parameter in a function prototype must have some
7653 type specifier that is not an attribute specifier; this resolves an
7654 ambiguity in the interpretation of @code{void f(int
7655 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7656 the parentheses of a function declarator contain only attributes then
7657 those attributes are ignored, rather than yielding an error or warning
7658 or implying a single parameter of type int, but this is subject to
7659 change.
7661 An attribute specifier list may appear immediately before a declarator
7662 (other than the first) in a comma-separated list of declarators in a
7663 declaration of more than one identifier using a single list of
7664 specifiers and qualifiers.  Such attribute specifiers apply
7665 only to the identifier before whose declarator they appear.  For
7666 example, in
7668 @smallexample
7669 __attribute__((noreturn)) void d0 (void),
7670     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7671      d2 (void);
7672 @end smallexample
7674 @noindent
7675 the @code{noreturn} attribute applies to all the functions
7676 declared; the @code{format} attribute only applies to @code{d1}.
7678 An attribute specifier list may appear immediately before the comma,
7679 @code{=} or semicolon terminating the declaration of an identifier other
7680 than a function definition.  Such attribute specifiers apply
7681 to the declared object or function.  Where an
7682 assembler name for an object or function is specified (@pxref{Asm
7683 Labels}), the attribute must follow the @code{asm}
7684 specification.
7686 An attribute specifier list may, in future, be permitted to appear after
7687 the declarator in a function definition (before any old-style parameter
7688 declarations or the function body).
7690 Attribute specifiers may be mixed with type qualifiers appearing inside
7691 the @code{[]} of a parameter array declarator, in the C99 construct by
7692 which such qualifiers are applied to the pointer to which the array is
7693 implicitly converted.  Such attribute specifiers apply to the pointer,
7694 not to the array, but at present this is not implemented and they are
7695 ignored.
7697 An attribute specifier list may appear at the start of a nested
7698 declarator.  At present, there are some limitations in this usage: the
7699 attributes correctly apply to the declarator, but for most individual
7700 attributes the semantics this implies are not implemented.
7701 When attribute specifiers follow the @code{*} of a pointer
7702 declarator, they may be mixed with any type qualifiers present.
7703 The following describes the formal semantics of this syntax.  It makes the
7704 most sense if you are familiar with the formal specification of
7705 declarators in the ISO C standard.
7707 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7708 D1}, where @code{T} contains declaration specifiers that specify a type
7709 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7710 contains an identifier @var{ident}.  The type specified for @var{ident}
7711 for derived declarators whose type does not include an attribute
7712 specifier is as in the ISO C standard.
7714 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7715 and the declaration @code{T D} specifies the type
7716 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7717 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7718 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7720 If @code{D1} has the form @code{*
7721 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7722 declaration @code{T D} specifies the type
7723 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7724 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7725 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7726 @var{ident}.
7728 For example,
7730 @smallexample
7731 void (__attribute__((noreturn)) ****f) (void);
7732 @end smallexample
7734 @noindent
7735 specifies the type ``pointer to pointer to pointer to pointer to
7736 non-returning function returning @code{void}''.  As another example,
7738 @smallexample
7739 char *__attribute__((aligned(8))) *f;
7740 @end smallexample
7742 @noindent
7743 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7744 Note again that this does not work with most attributes; for example,
7745 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7746 is not yet supported.
7748 For compatibility with existing code written for compiler versions that
7749 did not implement attributes on nested declarators, some laxity is
7750 allowed in the placing of attributes.  If an attribute that only applies
7751 to types is applied to a declaration, it is treated as applying to
7752 the type of that declaration.  If an attribute that only applies to
7753 declarations is applied to the type of a declaration, it is treated
7754 as applying to that declaration; and, for compatibility with code
7755 placing the attributes immediately before the identifier declared, such
7756 an attribute applied to a function return type is treated as
7757 applying to the function type, and such an attribute applied to an array
7758 element type is treated as applying to the array type.  If an
7759 attribute that only applies to function types is applied to a
7760 pointer-to-function type, it is treated as applying to the pointer
7761 target type; if such an attribute is applied to a function return type
7762 that is not a pointer-to-function type, it is treated as applying
7763 to the function type.
7765 @node Function Prototypes
7766 @section Prototypes and Old-Style Function Definitions
7767 @cindex function prototype declarations
7768 @cindex old-style function definitions
7769 @cindex promotion of formal parameters
7771 GNU C extends ISO C to allow a function prototype to override a later
7772 old-style non-prototype definition.  Consider the following example:
7774 @smallexample
7775 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7776 #ifdef __STDC__
7777 #define P(x) x
7778 #else
7779 #define P(x) ()
7780 #endif
7782 /* @r{Prototype function declaration.}  */
7783 int isroot P((uid_t));
7785 /* @r{Old-style function definition.}  */
7787 isroot (x)   /* @r{??? lossage here ???} */
7788      uid_t x;
7790   return x == 0;
7792 @end smallexample
7794 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7795 not allow this example, because subword arguments in old-style
7796 non-prototype definitions are promoted.  Therefore in this example the
7797 function definition's argument is really an @code{int}, which does not
7798 match the prototype argument type of @code{short}.
7800 This restriction of ISO C makes it hard to write code that is portable
7801 to traditional C compilers, because the programmer does not know
7802 whether the @code{uid_t} type is @code{short}, @code{int}, or
7803 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7804 to override a later old-style definition.  More precisely, in GNU C, a
7805 function prototype argument type overrides the argument type specified
7806 by a later old-style definition if the former type is the same as the
7807 latter type before promotion.  Thus in GNU C the above example is
7808 equivalent to the following:
7810 @smallexample
7811 int isroot (uid_t);
7814 isroot (uid_t x)
7816   return x == 0;
7818 @end smallexample
7820 @noindent
7821 GNU C++ does not support old-style function definitions, so this
7822 extension is irrelevant.
7824 @node C++ Comments
7825 @section C++ Style Comments
7826 @cindex @code{//}
7827 @cindex C++ comments
7828 @cindex comments, C++ style
7830 In GNU C, you may use C++ style comments, which start with @samp{//} and
7831 continue until the end of the line.  Many other C implementations allow
7832 such comments, and they are included in the 1999 C standard.  However,
7833 C++ style comments are not recognized if you specify an @option{-std}
7834 option specifying a version of ISO C before C99, or @option{-ansi}
7835 (equivalent to @option{-std=c90}).
7837 @node Dollar Signs
7838 @section Dollar Signs in Identifier Names
7839 @cindex $
7840 @cindex dollar signs in identifier names
7841 @cindex identifier names, dollar signs in
7843 In GNU C, you may normally use dollar signs in identifier names.
7844 This is because many traditional C implementations allow such identifiers.
7845 However, dollar signs in identifiers are not supported on a few target
7846 machines, typically because the target assembler does not allow them.
7848 @node Character Escapes
7849 @section The Character @key{ESC} in Constants
7851 You can use the sequence @samp{\e} in a string or character constant to
7852 stand for the ASCII character @key{ESC}.
7854 @node Alignment
7855 @section Inquiring on Alignment of Types or Variables
7856 @cindex alignment
7857 @cindex type alignment
7858 @cindex variable alignment
7860 The keyword @code{__alignof__} allows you to inquire about how an object
7861 is aligned, or the minimum alignment usually required by a type.  Its
7862 syntax is just like @code{sizeof}.
7864 For example, if the target machine requires a @code{double} value to be
7865 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7866 This is true on many RISC machines.  On more traditional machine
7867 designs, @code{__alignof__ (double)} is 4 or even 2.
7869 Some machines never actually require alignment; they allow reference to any
7870 data type even at an odd address.  For these machines, @code{__alignof__}
7871 reports the smallest alignment that GCC gives the data type, usually as
7872 mandated by the target ABI.
7874 If the operand of @code{__alignof__} is an lvalue rather than a type,
7875 its value is the required alignment for its type, taking into account
7876 any minimum alignment specified with GCC's @code{__attribute__}
7877 extension (@pxref{Variable Attributes}).  For example, after this
7878 declaration:
7880 @smallexample
7881 struct foo @{ int x; char y; @} foo1;
7882 @end smallexample
7884 @noindent
7885 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7886 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7888 It is an error to ask for the alignment of an incomplete type.
7891 @node Inline
7892 @section An Inline Function is As Fast As a Macro
7893 @cindex inline functions
7894 @cindex integrating function code
7895 @cindex open coding
7896 @cindex macros, inline alternative
7898 By declaring a function inline, you can direct GCC to make
7899 calls to that function faster.  One way GCC can achieve this is to
7900 integrate that function's code into the code for its callers.  This
7901 makes execution faster by eliminating the function-call overhead; in
7902 addition, if any of the actual argument values are constant, their
7903 known values may permit simplifications at compile time so that not
7904 all of the inline function's code needs to be included.  The effect on
7905 code size is less predictable; object code may be larger or smaller
7906 with function inlining, depending on the particular case.  You can
7907 also direct GCC to try to integrate all ``simple enough'' functions
7908 into their callers with the option @option{-finline-functions}.
7910 GCC implements three different semantics of declaring a function
7911 inline.  One is available with @option{-std=gnu89} or
7912 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7913 on all inline declarations, another when
7914 @option{-std=c99},
7915 @option{-std=gnu99} or an option for a later C version is used
7916 (without @option{-fgnu89-inline}), and the third
7917 is used when compiling C++.
7919 To declare a function inline, use the @code{inline} keyword in its
7920 declaration, like this:
7922 @smallexample
7923 static inline int
7924 inc (int *a)
7926   return (*a)++;
7928 @end smallexample
7930 If you are writing a header file to be included in ISO C90 programs, write
7931 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7933 The three types of inlining behave similarly in two important cases:
7934 when the @code{inline} keyword is used on a @code{static} function,
7935 like the example above, and when a function is first declared without
7936 using the @code{inline} keyword and then is defined with
7937 @code{inline}, like this:
7939 @smallexample
7940 extern int inc (int *a);
7941 inline int
7942 inc (int *a)
7944   return (*a)++;
7946 @end smallexample
7948 In both of these common cases, the program behaves the same as if you
7949 had not used the @code{inline} keyword, except for its speed.
7951 @cindex inline functions, omission of
7952 @opindex fkeep-inline-functions
7953 When a function is both inline and @code{static}, if all calls to the
7954 function are integrated into the caller, and the function's address is
7955 never used, then the function's own assembler code is never referenced.
7956 In this case, GCC does not actually output assembler code for the
7957 function, unless you specify the option @option{-fkeep-inline-functions}.
7958 If there is a nonintegrated call, then the function is compiled to
7959 assembler code as usual.  The function must also be compiled as usual if
7960 the program refers to its address, because that cannot be inlined.
7962 @opindex Winline
7963 Note that certain usages in a function definition can make it unsuitable
7964 for inline substitution.  Among these usages are: variadic functions,
7965 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7966 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7967 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7968 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7969 function marked @code{inline} could not be substituted, and gives the
7970 reason for the failure.
7972 @cindex automatic @code{inline} for C++ member fns
7973 @cindex @code{inline} automatic for C++ member fns
7974 @cindex member fns, automatically @code{inline}
7975 @cindex C++ member fns, automatically @code{inline}
7976 @opindex fno-default-inline
7977 As required by ISO C++, GCC considers member functions defined within
7978 the body of a class to be marked inline even if they are
7979 not explicitly declared with the @code{inline} keyword.  You can
7980 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7981 Options,,Options Controlling C++ Dialect}.
7983 GCC does not inline any functions when not optimizing unless you specify
7984 the @samp{always_inline} attribute for the function, like this:
7986 @smallexample
7987 /* @r{Prototype.}  */
7988 inline void foo (const char) __attribute__((always_inline));
7989 @end smallexample
7991 The remainder of this section is specific to GNU C90 inlining.
7993 @cindex non-static inline function
7994 When an inline function is not @code{static}, then the compiler must assume
7995 that there may be calls from other source files; since a global symbol can
7996 be defined only once in any program, the function must not be defined in
7997 the other source files, so the calls therein cannot be integrated.
7998 Therefore, a non-@code{static} inline function is always compiled on its
7999 own in the usual fashion.
8001 If you specify both @code{inline} and @code{extern} in the function
8002 definition, then the definition is used only for inlining.  In no case
8003 is the function compiled on its own, not even if you refer to its
8004 address explicitly.  Such an address becomes an external reference, as
8005 if you had only declared the function, and had not defined it.
8007 This combination of @code{inline} and @code{extern} has almost the
8008 effect of a macro.  The way to use it is to put a function definition in
8009 a header file with these keywords, and put another copy of the
8010 definition (lacking @code{inline} and @code{extern}) in a library file.
8011 The definition in the header file causes most calls to the function
8012 to be inlined.  If any uses of the function remain, they refer to
8013 the single copy in the library.
8015 @node Volatiles
8016 @section When is a Volatile Object Accessed?
8017 @cindex accessing volatiles
8018 @cindex volatile read
8019 @cindex volatile write
8020 @cindex volatile access
8022 C has the concept of volatile objects.  These are normally accessed by
8023 pointers and used for accessing hardware or inter-thread
8024 communication.  The standard encourages compilers to refrain from
8025 optimizations concerning accesses to volatile objects, but leaves it
8026 implementation defined as to what constitutes a volatile access.  The
8027 minimum requirement is that at a sequence point all previous accesses
8028 to volatile objects have stabilized and no subsequent accesses have
8029 occurred.  Thus an implementation is free to reorder and combine
8030 volatile accesses that occur between sequence points, but cannot do
8031 so for accesses across a sequence point.  The use of volatile does
8032 not allow you to violate the restriction on updating objects multiple
8033 times between two sequence points.
8035 Accesses to non-volatile objects are not ordered with respect to
8036 volatile accesses.  You cannot use a volatile object as a memory
8037 barrier to order a sequence of writes to non-volatile memory.  For
8038 instance:
8040 @smallexample
8041 int *ptr = @var{something};
8042 volatile int vobj;
8043 *ptr = @var{something};
8044 vobj = 1;
8045 @end smallexample
8047 @noindent
8048 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8049 that the write to @var{*ptr} occurs by the time the update
8050 of @var{vobj} happens.  If you need this guarantee, you must use
8051 a stronger memory barrier such as:
8053 @smallexample
8054 int *ptr = @var{something};
8055 volatile int vobj;
8056 *ptr = @var{something};
8057 asm volatile ("" : : : "memory");
8058 vobj = 1;
8059 @end smallexample
8061 A scalar volatile object is read when it is accessed in a void context:
8063 @smallexample
8064 volatile int *src = @var{somevalue};
8065 *src;
8066 @end smallexample
8068 Such expressions are rvalues, and GCC implements this as a
8069 read of the volatile object being pointed to.
8071 Assignments are also expressions and have an rvalue.  However when
8072 assigning to a scalar volatile, the volatile object is not reread,
8073 regardless of whether the assignment expression's rvalue is used or
8074 not.  If the assignment's rvalue is used, the value is that assigned
8075 to the volatile object.  For instance, there is no read of @var{vobj}
8076 in all the following cases:
8078 @smallexample
8079 int obj;
8080 volatile int vobj;
8081 vobj = @var{something};
8082 obj = vobj = @var{something};
8083 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8084 obj = (@var{something}, vobj = @var{anotherthing});
8085 @end smallexample
8087 If you need to read the volatile object after an assignment has
8088 occurred, you must use a separate expression with an intervening
8089 sequence point.
8091 As bit-fields are not individually addressable, volatile bit-fields may
8092 be implicitly read when written to, or when adjacent bit-fields are
8093 accessed.  Bit-field operations may be optimized such that adjacent
8094 bit-fields are only partially accessed, if they straddle a storage unit
8095 boundary.  For these reasons it is unwise to use volatile bit-fields to
8096 access hardware.
8098 @node Using Assembly Language with C
8099 @section How to Use Inline Assembly Language in C Code
8100 @cindex @code{asm} keyword
8101 @cindex assembly language in C
8102 @cindex inline assembly language
8103 @cindex mixing assembly language and C
8105 The @code{asm} keyword allows you to embed assembler instructions
8106 within C code.  GCC provides two forms of inline @code{asm}
8107 statements.  A @dfn{basic @code{asm}} statement is one with no
8108 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8109 statement (@pxref{Extended Asm}) includes one or more operands.  
8110 The extended form is preferred for mixing C and assembly language
8111 within a function, but to include assembly language at
8112 top level you must use basic @code{asm}.
8114 You can also use the @code{asm} keyword to override the assembler name
8115 for a C symbol, or to place a C variable in a specific register.
8117 @menu
8118 * Basic Asm::          Inline assembler without operands.
8119 * Extended Asm::       Inline assembler with operands.
8120 * Constraints::        Constraints for @code{asm} operands
8121 * Asm Labels::         Specifying the assembler name to use for a C symbol.
8122 * Explicit Register Variables::  Defining variables residing in specified 
8123                        registers.
8124 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
8125 @end menu
8127 @node Basic Asm
8128 @subsection Basic Asm --- Assembler Instructions Without Operands
8129 @cindex basic @code{asm}
8130 @cindex assembly language in C, basic
8132 A basic @code{asm} statement has the following syntax:
8134 @example
8135 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8136 @end example
8138 The @code{asm} keyword is a GNU extension.
8139 When writing code that can be compiled with @option{-ansi} and the
8140 various @option{-std} options, use @code{__asm__} instead of 
8141 @code{asm} (@pxref{Alternate Keywords}).
8143 @subsubheading Qualifiers
8144 @table @code
8145 @item volatile
8146 The optional @code{volatile} qualifier has no effect. 
8147 All basic @code{asm} blocks are implicitly volatile.
8148 @end table
8150 @subsubheading Parameters
8151 @table @var
8153 @item AssemblerInstructions
8154 This is a literal string that specifies the assembler code. The string can 
8155 contain any instructions recognized by the assembler, including directives. 
8156 GCC does not parse the assembler instructions themselves and 
8157 does not know what they mean or even whether they are valid assembler input. 
8159 You may place multiple assembler instructions together in a single @code{asm} 
8160 string, separated by the characters normally used in assembly code for the 
8161 system. A combination that works in most places is a newline to break the 
8162 line, plus a tab character (written as @samp{\n\t}).
8163 Some assemblers allow semicolons as a line separator. However, 
8164 note that some assembler dialects use semicolons to start a comment. 
8165 @end table
8167 @subsubheading Remarks
8168 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8169 smaller, safer, and more efficient code, and in most cases it is a
8170 better solution than basic @code{asm}.  However, there are two
8171 situations where only basic @code{asm} can be used:
8173 @itemize @bullet
8174 @item
8175 Extended @code{asm} statements have to be inside a C
8176 function, so to write inline assembly language at file scope (``top-level''),
8177 outside of C functions, you must use basic @code{asm}.
8178 You can use this technique to emit assembler directives,
8179 define assembly language macros that can be invoked elsewhere in the file,
8180 or write entire functions in assembly language.
8182 @item
8183 Functions declared
8184 with the @code{naked} attribute also require basic @code{asm}
8185 (@pxref{Function Attributes}).
8186 @end itemize
8188 Safely accessing C data and calling functions from basic @code{asm} is more 
8189 complex than it may appear. To access C data, it is better to use extended 
8190 @code{asm}.
8192 Do not expect a sequence of @code{asm} statements to remain perfectly 
8193 consecutive after compilation. If certain instructions need to remain 
8194 consecutive in the output, put them in a single multi-instruction @code{asm}
8195 statement. Note that GCC's optimizers can move @code{asm} statements 
8196 relative to other code, including across jumps.
8198 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8199 GCC does not know about these jumps, and therefore cannot take 
8200 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8201 labels are only supported in extended @code{asm}.
8203 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8204 assembly code when optimizing. This can lead to unexpected duplicate 
8205 symbol errors during compilation if your assembly code defines symbols or 
8206 labels.
8208 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8209 making it a potential source of incompatibilities between compilers.  These
8210 incompatibilities may not produce compiler warnings/errors.
8212 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8213 means there is no way to communicate to the compiler what is happening
8214 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8215 discard them as unreferenced.  It also does not know about side effects of
8216 the assembler code, such as modifications to memory or registers.  Unlike
8217 some compilers, GCC assumes that no changes to general purpose registers
8218 occur.  This assumption may change in a future release.
8220 To avoid complications from future changes to the semantics and the
8221 compatibility issues between compilers, consider replacing basic @code{asm}
8222 with extended @code{asm}.  See
8223 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8224 from basic asm to extended asm} for information about how to perform this
8225 conversion.
8227 The compiler copies the assembler instructions in a basic @code{asm} 
8228 verbatim to the assembly language output file, without 
8229 processing dialects or any of the @samp{%} operators that are available with
8230 extended @code{asm}. This results in minor differences between basic 
8231 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8232 registers you might use @samp{%eax} in basic @code{asm} and
8233 @samp{%%eax} in extended @code{asm}.
8235 On targets such as x86 that support multiple assembler dialects,
8236 all basic @code{asm} blocks use the assembler dialect specified by the 
8237 @option{-masm} command-line option (@pxref{x86 Options}).  
8238 Basic @code{asm} provides no
8239 mechanism to provide different assembler strings for different dialects.
8241 For basic @code{asm} with non-empty assembler string GCC assumes
8242 the assembler block does not change any general purpose registers,
8243 but it may read or write any globally accessible variable.
8245 Here is an example of basic @code{asm} for i386:
8247 @example
8248 /* Note that this code will not compile with -masm=intel */
8249 #define DebugBreak() asm("int $3")
8250 @end example
8252 @node Extended Asm
8253 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8254 @cindex extended @code{asm}
8255 @cindex assembly language in C, extended
8257 With extended @code{asm} you can read and write C variables from 
8258 assembler and perform jumps from assembler code to C labels.  
8259 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8260 the operand parameters after the assembler template:
8262 @example
8263 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
8264                  : @var{OutputOperands} 
8265                  @r{[} : @var{InputOperands}
8266                  @r{[} : @var{Clobbers} @r{]} @r{]})
8268 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
8269                       : 
8270                       : @var{InputOperands}
8271                       : @var{Clobbers}
8272                       : @var{GotoLabels})
8273 @end example
8275 The @code{asm} keyword is a GNU extension.
8276 When writing code that can be compiled with @option{-ansi} and the
8277 various @option{-std} options, use @code{__asm__} instead of 
8278 @code{asm} (@pxref{Alternate Keywords}).
8280 @subsubheading Qualifiers
8281 @table @code
8283 @item volatile
8284 The typical use of extended @code{asm} statements is to manipulate input 
8285 values to produce output values. However, your @code{asm} statements may 
8286 also produce side effects. If so, you may need to use the @code{volatile} 
8287 qualifier to disable certain optimizations. @xref{Volatile}.
8289 @item goto
8290 This qualifier informs the compiler that the @code{asm} statement may 
8291 perform a jump to one of the labels listed in the @var{GotoLabels}.
8292 @xref{GotoLabels}.
8293 @end table
8295 @subsubheading Parameters
8296 @table @var
8297 @item AssemblerTemplate
8298 This is a literal string that is the template for the assembler code. It is a 
8299 combination of fixed text and tokens that refer to the input, output, 
8300 and goto parameters. @xref{AssemblerTemplate}.
8302 @item OutputOperands
8303 A comma-separated list of the C variables modified by the instructions in the 
8304 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8306 @item InputOperands
8307 A comma-separated list of C expressions read by the instructions in the 
8308 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8310 @item Clobbers
8311 A comma-separated list of registers or other values changed by the 
8312 @var{AssemblerTemplate}, beyond those listed as outputs.
8313 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8315 @item GotoLabels
8316 When you are using the @code{goto} form of @code{asm}, this section contains 
8317 the list of all C labels to which the code in the 
8318 @var{AssemblerTemplate} may jump. 
8319 @xref{GotoLabels}.
8321 @code{asm} statements may not perform jumps into other @code{asm} statements,
8322 only to the listed @var{GotoLabels}.
8323 GCC's optimizers do not know about other jumps; therefore they cannot take 
8324 account of them when deciding how to optimize.
8325 @end table
8327 The total number of input + output + goto operands is limited to 30.
8329 @subsubheading Remarks
8330 The @code{asm} statement allows you to include assembly instructions directly 
8331 within C code. This may help you to maximize performance in time-sensitive 
8332 code or to access assembly instructions that are not readily available to C 
8333 programs.
8335 Note that extended @code{asm} statements must be inside a function. Only 
8336 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8337 Functions declared with the @code{naked} attribute also require basic 
8338 @code{asm} (@pxref{Function Attributes}).
8340 While the uses of @code{asm} are many and varied, it may help to think of an 
8341 @code{asm} statement as a series of low-level instructions that convert input 
8342 parameters to output parameters. So a simple (if not particularly useful) 
8343 example for i386 using @code{asm} might look like this:
8345 @example
8346 int src = 1;
8347 int dst;   
8349 asm ("mov %1, %0\n\t"
8350     "add $1, %0"
8351     : "=r" (dst) 
8352     : "r" (src));
8354 printf("%d\n", dst);
8355 @end example
8357 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8359 @anchor{Volatile}
8360 @subsubsection Volatile
8361 @cindex volatile @code{asm}
8362 @cindex @code{asm} volatile
8364 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8365 there is no need for the output variables. Also, the optimizers may move 
8366 code out of loops if they believe that the code will always return the same 
8367 result (i.e. none of its input values change between calls). Using the 
8368 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8369 that have no output operands, including @code{asm goto} statements, 
8370 are implicitly volatile.
8372 This i386 code demonstrates a case that does not use (or require) the 
8373 @code{volatile} qualifier. If it is performing assertion checking, this code 
8374 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8375 unreferenced by any code. As a result, the optimizers can discard the 
8376 @code{asm} statement, which in turn removes the need for the entire 
8377 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8378 isn't needed you allow the optimizers to produce the most efficient code 
8379 possible.
8381 @example
8382 void DoCheck(uint32_t dwSomeValue)
8384    uint32_t dwRes;
8386    // Assumes dwSomeValue is not zero.
8387    asm ("bsfl %1,%0"
8388      : "=r" (dwRes)
8389      : "r" (dwSomeValue)
8390      : "cc");
8392    assert(dwRes > 3);
8394 @end example
8396 The next example shows a case where the optimizers can recognize that the input 
8397 (@code{dwSomeValue}) never changes during the execution of the function and can 
8398 therefore move the @code{asm} outside the loop to produce more efficient code. 
8399 Again, using @code{volatile} disables this type of optimization.
8401 @example
8402 void do_print(uint32_t dwSomeValue)
8404    uint32_t dwRes;
8406    for (uint32_t x=0; x < 5; x++)
8407    @{
8408       // Assumes dwSomeValue is not zero.
8409       asm ("bsfl %1,%0"
8410         : "=r" (dwRes)
8411         : "r" (dwSomeValue)
8412         : "cc");
8414       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8415    @}
8417 @end example
8419 The following example demonstrates a case where you need to use the 
8420 @code{volatile} qualifier. 
8421 It uses the x86 @code{rdtsc} instruction, which reads 
8422 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8423 the optimizers might assume that the @code{asm} block will always return the 
8424 same value and therefore optimize away the second call.
8426 @example
8427 uint64_t msr;
8429 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8430         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8431         "or %%rdx, %0"        // 'Or' in the lower bits.
8432         : "=a" (msr)
8433         : 
8434         : "rdx");
8436 printf("msr: %llx\n", msr);
8438 // Do other work...
8440 // Reprint the timestamp
8441 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8442         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8443         "or %%rdx, %0"        // 'Or' in the lower bits.
8444         : "=a" (msr)
8445         : 
8446         : "rdx");
8448 printf("msr: %llx\n", msr);
8449 @end example
8451 GCC's optimizers do not treat this code like the non-volatile code in the 
8452 earlier examples. They do not move it out of loops or omit it on the 
8453 assumption that the result from a previous call is still valid.
8455 Note that the compiler can move even volatile @code{asm} instructions relative 
8456 to other code, including across jump instructions. For example, on many 
8457 targets there is a system register that controls the rounding mode of 
8458 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8459 following PowerPC example, does not work reliably.
8461 @example
8462 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8463 sum = x + y;
8464 @end example
8466 The compiler may move the addition back before the volatile @code{asm}. To 
8467 make it work as expected, add an artificial dependency to the @code{asm} by 
8468 referencing a variable in the subsequent code, for example: 
8470 @example
8471 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8472 sum = x + y;
8473 @end example
8475 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8476 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8477 errors during compilation if your asm code defines symbols or labels. 
8478 Using @samp{%=} 
8479 (@pxref{AssemblerTemplate}) may help resolve this problem.
8481 @anchor{AssemblerTemplate}
8482 @subsubsection Assembler Template
8483 @cindex @code{asm} assembler template
8485 An assembler template is a literal string containing assembler instructions.
8486 The compiler replaces tokens in the template that refer 
8487 to inputs, outputs, and goto labels,
8488 and then outputs the resulting string to the assembler. The 
8489 string can contain any instructions recognized by the assembler, including 
8490 directives. GCC does not parse the assembler instructions 
8491 themselves and does not know what they mean or even whether they are valid 
8492 assembler input. However, it does count the statements 
8493 (@pxref{Size of an asm}).
8495 You may place multiple assembler instructions together in a single @code{asm} 
8496 string, separated by the characters normally used in assembly code for the 
8497 system. A combination that works in most places is a newline to break the 
8498 line, plus a tab character to move to the instruction field (written as 
8499 @samp{\n\t}). 
8500 Some assemblers allow semicolons as a line separator. However, note 
8501 that some assembler dialects use semicolons to start a comment. 
8503 Do not expect a sequence of @code{asm} statements to remain perfectly 
8504 consecutive after compilation, even when you are using the @code{volatile} 
8505 qualifier. If certain instructions need to remain consecutive in the output, 
8506 put them in a single multi-instruction asm statement.
8508 Accessing data from C programs without using input/output operands (such as 
8509 by using global symbols directly from the assembler template) may not work as 
8510 expected. Similarly, calling functions directly from an assembler template 
8511 requires a detailed understanding of the target assembler and ABI.
8513 Since GCC does not parse the assembler template,
8514 it has no visibility of any 
8515 symbols it references. This may result in GCC discarding those symbols as 
8516 unreferenced unless they are also listed as input, output, or goto operands.
8518 @subsubheading Special format strings
8520 In addition to the tokens described by the input, output, and goto operands, 
8521 these tokens have special meanings in the assembler template:
8523 @table @samp
8524 @item %% 
8525 Outputs a single @samp{%} into the assembler code.
8527 @item %= 
8528 Outputs a number that is unique to each instance of the @code{asm} 
8529 statement in the entire compilation. This option is useful when creating local 
8530 labels and referring to them multiple times in a single template that 
8531 generates multiple assembler instructions. 
8533 @item %@{
8534 @itemx %|
8535 @itemx %@}
8536 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8537 into the assembler code.  When unescaped, these characters have special
8538 meaning to indicate multiple assembler dialects, as described below.
8539 @end table
8541 @subsubheading Multiple assembler dialects in @code{asm} templates
8543 On targets such as x86, GCC supports multiple assembler dialects.
8544 The @option{-masm} option controls which dialect GCC uses as its 
8545 default for inline assembler. The target-specific documentation for the 
8546 @option{-masm} option contains the list of supported dialects, as well as the 
8547 default dialect if the option is not specified. This information may be 
8548 important to understand, since assembler code that works correctly when 
8549 compiled using one dialect will likely fail if compiled using another.
8550 @xref{x86 Options}.
8552 If your code needs to support multiple assembler dialects (for example, if 
8553 you are writing public headers that need to support a variety of compilation 
8554 options), use constructs of this form:
8556 @example
8557 @{ dialect0 | dialect1 | dialect2... @}
8558 @end example
8560 This construct outputs @code{dialect0} 
8561 when using dialect #0 to compile the code, 
8562 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8563 braces than the number of dialects the compiler supports, the construct 
8564 outputs nothing.
8566 For example, if an x86 compiler supports two dialects
8567 (@samp{att}, @samp{intel}), an 
8568 assembler template such as this:
8570 @example
8571 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8572 @end example
8574 @noindent
8575 is equivalent to one of
8577 @example
8578 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8579 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8580 @end example
8582 Using that same compiler, this code:
8584 @example
8585 "xchg@{l@}\t@{%%@}ebx, %1"
8586 @end example
8588 @noindent
8589 corresponds to either
8591 @example
8592 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8593 "xchg\tebx, %1"                    @r{/* intel dialect */}
8594 @end example
8596 There is no support for nesting dialect alternatives.
8598 @anchor{OutputOperands}
8599 @subsubsection Output Operands
8600 @cindex @code{asm} output operands
8602 An @code{asm} statement has zero or more output operands indicating the names
8603 of C variables modified by the assembler code.
8605 In this i386 example, @code{old} (referred to in the template string as 
8606 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8607 (@code{%2}) is an input:
8609 @example
8610 bool old;
8612 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8613          "sbb %0,%0"      // Use the CF to calculate old.
8614    : "=r" (old), "+rm" (*Base)
8615    : "Ir" (Offset)
8616    : "cc");
8618 return old;
8619 @end example
8621 Operands are separated by commas.  Each operand has this format:
8623 @example
8624 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8625 @end example
8627 @table @var
8628 @item asmSymbolicName
8629 Specifies a symbolic name for the operand.
8630 Reference the name in the assembler template 
8631 by enclosing it in square brackets 
8632 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8633 that contains the definition. Any valid C variable name is acceptable, 
8634 including names already defined in the surrounding code. No two operands 
8635 within the same @code{asm} statement can use the same symbolic name.
8637 When not using an @var{asmSymbolicName}, use the (zero-based) position
8638 of the operand 
8639 in the list of operands in the assembler template. For example if there are 
8640 three output operands, use @samp{%0} in the template to refer to the first, 
8641 @samp{%1} for the second, and @samp{%2} for the third. 
8643 @item constraint
8644 A string constant specifying constraints on the placement of the operand; 
8645 @xref{Constraints}, for details.
8647 Output constraints must begin with either @samp{=} (a variable overwriting an 
8648 existing value) or @samp{+} (when reading and writing). When using 
8649 @samp{=}, do not assume the location contains the existing value
8650 on entry to the @code{asm}, except 
8651 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8653 After the prefix, there must be one or more additional constraints 
8654 (@pxref{Constraints}) that describe where the value resides. Common 
8655 constraints include @samp{r} for register and @samp{m} for memory. 
8656 When you list more than one possible location (for example, @code{"=rm"}),
8657 the compiler chooses the most efficient one based on the current context. 
8658 If you list as many alternates as the @code{asm} statement allows, you permit 
8659 the optimizers to produce the best possible code. 
8660 If you must use a specific register, but your Machine Constraints do not
8661 provide sufficient control to select the specific register you want, 
8662 local register variables may provide a solution (@pxref{Local Register 
8663 Variables}).
8665 @item cvariablename
8666 Specifies a C lvalue expression to hold the output, typically a variable name.
8667 The enclosing parentheses are a required part of the syntax.
8669 @end table
8671 When the compiler selects the registers to use to 
8672 represent the output operands, it does not use any of the clobbered registers 
8673 (@pxref{Clobbers and Scratch Registers}).
8675 Output operand expressions must be lvalues. The compiler cannot check whether 
8676 the operands have data types that are reasonable for the instruction being 
8677 executed. For output expressions that are not directly addressable (for 
8678 example a bit-field), the constraint must allow a register. In that case, GCC 
8679 uses the register as the output of the @code{asm}, and then stores that 
8680 register into the output. 
8682 Operands using the @samp{+} constraint modifier count as two operands 
8683 (that is, both as input and output) towards the total maximum of 30 operands
8684 per @code{asm} statement.
8686 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8687 operands that must not overlap an input.  Otherwise, 
8688 GCC may allocate the output operand in the same register as an unrelated 
8689 input operand, on the assumption that the assembler code consumes its 
8690 inputs before producing outputs. This assumption may be false if the assembler 
8691 code actually consists of more than one instruction.
8693 The same problem can occur if one output parameter (@var{a}) allows a register 
8694 constraint and another output parameter (@var{b}) allows a memory constraint.
8695 The code generated by GCC to access the memory address in @var{b} can contain
8696 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8697 registers to be inputs to the asm. As above, GCC assumes that such input
8698 registers are consumed before any outputs are written. This assumption may 
8699 result in incorrect behavior if the asm writes to @var{a} before using 
8700 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8701 ensures that modifying @var{a} does not affect the address referenced by 
8702 @var{b}. Otherwise, the location of @var{b} 
8703 is undefined if @var{a} is modified before using @var{b}.
8705 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8706 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8707 dependent. The list of supported modifiers for x86 is found at 
8708 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8710 If the C code that follows the @code{asm} makes no use of any of the output 
8711 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8712 optimizers from discarding the @code{asm} statement as unneeded 
8713 (see @ref{Volatile}).
8715 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8716 references the first output operand as @code{%0} (were there a second, it 
8717 would be @code{%1}, etc). The number of the first input operand is one greater 
8718 than that of the last output operand. In this i386 example, that makes 
8719 @code{Mask} referenced as @code{%1}:
8721 @example
8722 uint32_t Mask = 1234;
8723 uint32_t Index;
8725   asm ("bsfl %1, %0"
8726      : "=r" (Index)
8727      : "r" (Mask)
8728      : "cc");
8729 @end example
8731 That code overwrites the variable @code{Index} (@samp{=}),
8732 placing the value in a register (@samp{r}).
8733 Using the generic @samp{r} constraint instead of a constraint for a specific 
8734 register allows the compiler to pick the register to use, which can result 
8735 in more efficient code. This may not be possible if an assembler instruction 
8736 requires a specific register.
8738 The following i386 example uses the @var{asmSymbolicName} syntax.
8739 It produces the 
8740 same result as the code above, but some may consider it more readable or more 
8741 maintainable since reordering index numbers is not necessary when adding or 
8742 removing operands. The names @code{aIndex} and @code{aMask}
8743 are only used in this example to emphasize which 
8744 names get used where.
8745 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8747 @example
8748 uint32_t Mask = 1234;
8749 uint32_t Index;
8751   asm ("bsfl %[aMask], %[aIndex]"
8752      : [aIndex] "=r" (Index)
8753      : [aMask] "r" (Mask)
8754      : "cc");
8755 @end example
8757 Here are some more examples of output operands.
8759 @example
8760 uint32_t c = 1;
8761 uint32_t d;
8762 uint32_t *e = &c;
8764 asm ("mov %[e], %[d]"
8765    : [d] "=rm" (d)
8766    : [e] "rm" (*e));
8767 @end example
8769 Here, @code{d} may either be in a register or in memory. Since the compiler 
8770 might already have the current value of the @code{uint32_t} location
8771 pointed to by @code{e}
8772 in a register, you can enable it to choose the best location
8773 for @code{d} by specifying both constraints.
8775 @anchor{FlagOutputOperands}
8776 @subsubsection Flag Output Operands
8777 @cindex @code{asm} flag output operands
8779 Some targets have a special register that holds the ``flags'' for the
8780 result of an operation or comparison.  Normally, the contents of that
8781 register are either unmodifed by the asm, or the asm is considered to
8782 clobber the contents.
8784 On some targets, a special form of output operand exists by which
8785 conditions in the flags register may be outputs of the asm.  The set of
8786 conditions supported are target specific, but the general rule is that
8787 the output variable must be a scalar integer, and the value is boolean.
8788 When supported, the target defines the preprocessor symbol
8789 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8791 Because of the special nature of the flag output operands, the constraint
8792 may not include alternatives.
8794 Most often, the target has only one flags register, and thus is an implied
8795 operand of many instructions.  In this case, the operand should not be
8796 referenced within the assembler template via @code{%0} etc, as there's
8797 no corresponding text in the assembly language.
8799 @table @asis
8800 @item x86 family
8801 The flag output constraints for the x86 family are of the form
8802 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8803 conditions defined in the ISA manual for @code{j@var{cc}} or
8804 @code{set@var{cc}}.
8806 @table @code
8807 @item a
8808 ``above'' or unsigned greater than
8809 @item ae
8810 ``above or equal'' or unsigned greater than or equal
8811 @item b
8812 ``below'' or unsigned less than
8813 @item be
8814 ``below or equal'' or unsigned less than or equal
8815 @item c
8816 carry flag set
8817 @item e
8818 @itemx z
8819 ``equal'' or zero flag set
8820 @item g
8821 signed greater than
8822 @item ge
8823 signed greater than or equal
8824 @item l
8825 signed less than
8826 @item le
8827 signed less than or equal
8828 @item o
8829 overflow flag set
8830 @item p
8831 parity flag set
8832 @item s
8833 sign flag set
8834 @item na
8835 @itemx nae
8836 @itemx nb
8837 @itemx nbe
8838 @itemx nc
8839 @itemx ne
8840 @itemx ng
8841 @itemx nge
8842 @itemx nl
8843 @itemx nle
8844 @itemx no
8845 @itemx np
8846 @itemx ns
8847 @itemx nz
8848 ``not'' @var{flag}, or inverted versions of those above
8849 @end table
8851 @end table
8853 @anchor{InputOperands}
8854 @subsubsection Input Operands
8855 @cindex @code{asm} input operands
8856 @cindex @code{asm} expressions
8858 Input operands make values from C variables and expressions available to the 
8859 assembly code.
8861 Operands are separated by commas.  Each operand has this format:
8863 @example
8864 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8865 @end example
8867 @table @var
8868 @item asmSymbolicName
8869 Specifies a symbolic name for the operand.
8870 Reference the name in the assembler template 
8871 by enclosing it in square brackets 
8872 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8873 that contains the definition. Any valid C variable name is acceptable, 
8874 including names already defined in the surrounding code. No two operands 
8875 within the same @code{asm} statement can use the same symbolic name.
8877 When not using an @var{asmSymbolicName}, use the (zero-based) position
8878 of the operand 
8879 in the list of operands in the assembler template. For example if there are
8880 two output operands and three inputs,
8881 use @samp{%2} in the template to refer to the first input operand,
8882 @samp{%3} for the second, and @samp{%4} for the third. 
8884 @item constraint
8885 A string constant specifying constraints on the placement of the operand; 
8886 @xref{Constraints}, for details.
8888 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8889 When you list more than one possible location (for example, @samp{"irm"}), 
8890 the compiler chooses the most efficient one based on the current context.
8891 If you must use a specific register, but your Machine Constraints do not
8892 provide sufficient control to select the specific register you want, 
8893 local register variables may provide a solution (@pxref{Local Register 
8894 Variables}).
8896 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8897 that the specified input must be in the same place as the output constraint 
8898 at the (zero-based) index in the output constraint list. 
8899 When using @var{asmSymbolicName} syntax for the output operands,
8900 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8902 @item cexpression
8903 This is the C variable or expression being passed to the @code{asm} statement 
8904 as input.  The enclosing parentheses are a required part of the syntax.
8906 @end table
8908 When the compiler selects the registers to use to represent the input 
8909 operands, it does not use any of the clobbered registers
8910 (@pxref{Clobbers and Scratch Registers}).
8912 If there are no output operands but there are input operands, place two 
8913 consecutive colons where the output operands would go:
8915 @example
8916 __asm__ ("some instructions"
8917    : /* No outputs. */
8918    : "r" (Offset / 8));
8919 @end example
8921 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8922 (except for inputs tied to outputs). The compiler assumes that on exit from 
8923 the @code{asm} statement these operands contain the same values as they 
8924 had before executing the statement. 
8925 It is @emph{not} possible to use clobbers
8926 to inform the compiler that the values in these inputs are changing. One 
8927 common work-around is to tie the changing input variable to an output variable 
8928 that never gets used. Note, however, that if the code that follows the 
8929 @code{asm} statement makes no use of any of the output operands, the GCC 
8930 optimizers may discard the @code{asm} statement as unneeded 
8931 (see @ref{Volatile}).
8933 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8934 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8935 dependent. The list of supported modifiers for x86 is found at 
8936 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8938 In this example using the fictitious @code{combine} instruction, the 
8939 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8940 location as output operand 0. Only input operands may use numbers in 
8941 constraints, and they must each refer to an output operand. Only a number (or 
8942 the symbolic assembler name) in the constraint can guarantee that one operand 
8943 is in the same place as another. The mere fact that @code{foo} is the value of 
8944 both operands is not enough to guarantee that they are in the same place in 
8945 the generated assembler code.
8947 @example
8948 asm ("combine %2, %0" 
8949    : "=r" (foo) 
8950    : "0" (foo), "g" (bar));
8951 @end example
8953 Here is an example using symbolic names.
8955 @example
8956 asm ("cmoveq %1, %2, %[result]" 
8957    : [result] "=r"(result) 
8958    : "r" (test), "r" (new), "[result]" (old));
8959 @end example
8961 @anchor{Clobbers and Scratch Registers}
8962 @subsubsection Clobbers and Scratch Registers
8963 @cindex @code{asm} clobbers
8964 @cindex @code{asm} scratch registers
8966 While the compiler is aware of changes to entries listed in the output 
8967 operands, the inline @code{asm} code may modify more than just the outputs. For 
8968 example, calculations may require additional registers, or the processor may 
8969 overwrite a register as a side effect of a particular assembler instruction. 
8970 In order to inform the compiler of these changes, list them in the clobber 
8971 list. Clobber list items are either register names or the special clobbers 
8972 (listed below). Each clobber list item is a string constant 
8973 enclosed in double quotes and separated by commas.
8975 Clobber descriptions may not in any way overlap with an input or output 
8976 operand. For example, you may not have an operand describing a register class 
8977 with one member when listing that register in the clobber list. Variables 
8978 declared to live in specific registers (@pxref{Explicit Register 
8979 Variables}) and used 
8980 as @code{asm} input or output operands must have no part mentioned in the 
8981 clobber description. In particular, there is no way to specify that input 
8982 operands get modified without also specifying them as output operands.
8984 When the compiler selects which registers to use to represent input and output 
8985 operands, it does not use any of the clobbered registers. As a result, 
8986 clobbered registers are available for any use in the assembler code.
8988 Here is a realistic example for the VAX showing the use of clobbered 
8989 registers: 
8991 @example
8992 asm volatile ("movc3 %0, %1, %2"
8993                    : /* No outputs. */
8994                    : "g" (from), "g" (to), "g" (count)
8995                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
8996 @end example
8998 Also, there are two special clobber arguments:
9000 @table @code
9001 @item "cc"
9002 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
9003 register. On some machines, GCC represents the condition codes as a specific 
9004 hardware register; @code{"cc"} serves to name this register.
9005 On other machines, condition code handling is different, 
9006 and specifying @code{"cc"} has no effect. But 
9007 it is valid no matter what the target.
9009 @item "memory"
9010 The @code{"memory"} clobber tells the compiler that the assembly code
9011 performs memory 
9012 reads or writes to items other than those listed in the input and output 
9013 operands (for example, accessing the memory pointed to by one of the input 
9014 parameters). To ensure memory contains correct values, GCC may need to flush 
9015 specific register values to memory before executing the @code{asm}. Further, 
9016 the compiler does not assume that any values read from memory before an 
9017 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
9018 needed.  
9019 Using the @code{"memory"} clobber effectively forms a read/write
9020 memory barrier for the compiler.
9022 Note that this clobber does not prevent the @emph{processor} from doing 
9023 speculative reads past the @code{asm} statement. To prevent that, you need 
9024 processor-specific fence instructions.
9026 @end table
9028 Flushing registers to memory has performance implications and may be
9029 an issue for time-sensitive code.  You can provide better information
9030 to GCC to avoid this, as shown in the following examples.  At a
9031 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9032 need to be flushed.
9034 Here is a fictitious sum of squares instruction, that takes two
9035 pointers to floating point values in memory and produces a floating
9036 point register output.
9037 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9038 parameters, once to specify memory accessed, and once to specify a
9039 base register used by the @code{asm}.  You won't normally be wasting a
9040 register by doing this as GCC can use the same register for both
9041 purposes.  However, it would be foolish to use both @code{%1} and
9042 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9043 same.  In fact, @code{%3} may well not be a register.  It might be a
9044 symbolic memory reference to the object pointed to by @code{x}.
9046 @smallexample
9047 asm ("sumsq %0, %1, %2"
9048      : "+f" (result)
9049      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9050 @end smallexample
9052 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9053 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9054 must be specified as input/output because the @code{asm} modifies
9055 them.
9057 @smallexample
9058 asm ("vecmul %0, %1, %2"
9059      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9060      : "m" (*x), "m" (*y));
9061 @end smallexample
9063 An x86 example where the string memory argument is of unknown length.
9065 @smallexample
9066 asm("repne scasb"
9067     : "=c" (count), "+D" (p)
9068     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9069 @end smallexample
9071 If you know the above will only be reading a ten byte array then you
9072 could instead use a memory input like:
9073 @code{"m" (*(const char (*)[10]) p)}.
9075 Here is an example of a PowerPC vector scale implemented in assembly,
9076 complete with vector and condition code clobbers, and some initialized
9077 offset registers that are unchanged by the @code{asm}.
9079 @smallexample
9080 void
9081 dscal (size_t n, double *x, double alpha)
9083   asm ("/* lots of asm here */"
9084        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9085        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9086          "b" (80), "b" (96), "b" (112)
9087        : "cr0",
9088          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9089          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9091 @end smallexample
9093 Rather than allocating fixed registers via clobbers to provide scratch
9094 registers for an @code{asm} statement, an alternative is to define a
9095 variable and make it an early-clobber output as with @code{a2} and
9096 @code{a3} in the example below.  This gives the compiler register
9097 allocator more freedom.  You can also define a variable and make it an
9098 output tied to an input as with @code{a0} and @code{a1}, tied
9099 respectively to @code{ap} and @code{lda}.  Of course, with tied
9100 outputs your @code{asm} can't use the input value after modifying the
9101 output register since they are one and the same register.  What's
9102 more, if you omit the early-clobber on the output, it is possible that
9103 GCC might allocate the same register to another of the inputs if GCC
9104 could prove they had the same value on entry to the @code{asm}.  This
9105 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
9106 might conceivably be known to have the value 16 and without an
9107 early-clobber share the same register as @code{%11}.  On the other
9108 hand, @code{ap} can't be the same as any of the other inputs, so an
9109 early-clobber on @code{a0} is not needed.  It is also not desirable in
9110 this case.  An early-clobber on @code{a0} would cause GCC to allocate
9111 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9112 input.  Note that tying an input to an output is the way to set up an
9113 initialized temporary register modified by an @code{asm} statement.
9114 An input not tied to an output is assumed by GCC to be unchanged, for
9115 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9116 use that register in following code if the value 16 happened to be
9117 needed.  You can even use a normal @code{asm} output for a scratch if
9118 all inputs that might share the same register are consumed before the
9119 scratch is used.  The VSX registers clobbered by the @code{asm}
9120 statement could have used this technique except for GCC's limit on the
9121 number of @code{asm} parameters.
9123 @smallexample
9124 static void
9125 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9126                   const double *x, double *y, double alpha)
9128   double *a0;
9129   double *a1;
9130   double *a2;
9131   double *a3;
9133   __asm__
9134     (
9135      /* lots of asm here */
9136      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9137      "#a0=%3 a1=%4 a2=%5 a3=%6"
9138      :
9139        "+m" (*(double (*)[n]) y),
9140        "+&r" (n),       // 1
9141        "+b" (y),        // 2
9142        "=b" (a0),       // 3
9143        "=&b" (a1),      // 4
9144        "=&b" (a2),      // 5
9145        "=&b" (a3)       // 6
9146      :
9147        "m" (*(const double (*)[n]) x),
9148        "m" (*(const double (*)[]) ap),
9149        "d" (alpha),     // 9
9150        "r" (x),         // 10
9151        "b" (16),        // 11
9152        "3" (ap),        // 12
9153        "4" (lda)        // 13
9154      :
9155        "cr0",
9156        "vs32","vs33","vs34","vs35","vs36","vs37",
9157        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9158      );
9160 @end smallexample
9162 @anchor{GotoLabels}
9163 @subsubsection Goto Labels
9164 @cindex @code{asm} goto labels
9166 @code{asm goto} allows assembly code to jump to one or more C labels.  The
9167 @var{GotoLabels} section in an @code{asm goto} statement contains 
9168 a comma-separated 
9169 list of all C labels to which the assembler code may jump. GCC assumes that 
9170 @code{asm} execution falls through to the next statement (if this is not the 
9171 case, consider using the @code{__builtin_unreachable} intrinsic after the 
9172 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
9173 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
9174 Attributes}).
9176 An @code{asm goto} statement cannot have outputs.
9177 This is due to an internal restriction of 
9178 the compiler: control transfer instructions cannot have outputs. 
9179 If the assembler code does modify anything, use the @code{"memory"} clobber 
9180 to force the 
9181 optimizers to flush all register values to memory and reload them if 
9182 necessary after the @code{asm} statement.
9184 Also note that an @code{asm goto} statement is always implicitly
9185 considered volatile.
9187 To reference a label in the assembler template,
9188 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9189 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9190 operands.  For example, if the @code{asm} has three inputs and references two 
9191 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9193 Alternately, you can reference labels using the actual C label name enclosed
9194 in brackets.  For example, to reference a label named @code{carry}, you can
9195 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9196 section when using this approach.
9198 Here is an example of @code{asm goto} for i386:
9200 @example
9201 asm goto (
9202     "btl %1, %0\n\t"
9203     "jc %l2"
9204     : /* No outputs. */
9205     : "r" (p1), "r" (p2) 
9206     : "cc" 
9207     : carry);
9209 return 0;
9211 carry:
9212 return 1;
9213 @end example
9215 The following example shows an @code{asm goto} that uses a memory clobber.
9217 @example
9218 int frob(int x)
9220   int y;
9221   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9222             : /* No outputs. */
9223             : "r"(x), "r"(&y)
9224             : "r5", "memory" 
9225             : error);
9226   return y;
9227 error:
9228   return -1;
9230 @end example
9232 @anchor{x86Operandmodifiers}
9233 @subsubsection x86 Operand Modifiers
9235 References to input, output, and goto operands in the assembler template
9236 of extended @code{asm} statements can use 
9237 modifiers to affect the way the operands are formatted in 
9238 the code output to the assembler. For example, the 
9239 following code uses the @samp{h} and @samp{b} modifiers for x86:
9241 @example
9242 uint16_t  num;
9243 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9244 @end example
9246 @noindent
9247 These modifiers generate this assembler code:
9249 @example
9250 xchg %ah, %al
9251 @end example
9253 The rest of this discussion uses the following code for illustrative purposes.
9255 @example
9256 int main()
9258    int iInt = 1;
9260 top:
9262    asm volatile goto ("some assembler instructions here"
9263    : /* No outputs. */
9264    : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9265    : /* No clobbers. */
9266    : top);
9268 @end example
9270 With no modifiers, this is what the output from the operands would be
9271 for the @samp{att} and @samp{intel} dialects of assembler:
9273 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9274 @headitem Operand @tab @samp{att} @tab @samp{intel}
9275 @item @code{%0}
9276 @tab @code{%eax}
9277 @tab @code{eax}
9278 @item @code{%1}
9279 @tab @code{$2}
9280 @tab @code{2}
9281 @item @code{%3}
9282 @tab @code{$.L3}
9283 @tab @code{OFFSET FLAT:.L3}
9284 @end multitable
9286 The table below shows the list of supported modifiers and their effects.
9288 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9289 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9290 @item @code{a}
9291 @tab Print an absolute memory reference.
9292 @tab @code{%A0}
9293 @tab @code{*%rax}
9294 @tab @code{rax}
9295 @item @code{b}
9296 @tab Print the QImode name of the register.
9297 @tab @code{%b0}
9298 @tab @code{%al}
9299 @tab @code{al}
9300 @item @code{c}
9301 @tab Require a constant operand and print the constant expression with no punctuation.
9302 @tab @code{%c1}
9303 @tab @code{2}
9304 @tab @code{2}
9305 @item @code{E}
9306 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9307 Otherwise mode is unspecified (VOIDmode).
9308 @tab @code{%E1}
9309 @tab @code{%(rax)}
9310 @tab @code{[rax]}
9311 @item @code{h}
9312 @tab Print the QImode name for a ``high'' register.
9313 @tab @code{%h0}
9314 @tab @code{%ah}
9315 @tab @code{ah}
9316 @item @code{H}
9317 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9318 high 8 bytes of SSE values. For a memref in (%rax), it generates
9319 @tab @code{%H0}
9320 @tab @code{8(%rax)}
9321 @tab @code{8[rax]}
9322 @item @code{k}
9323 @tab Print the SImode name of the register.
9324 @tab @code{%k0}
9325 @tab @code{%eax}
9326 @tab @code{eax}
9327 @item @code{l}
9328 @tab Print the label name with no punctuation.
9329 @tab @code{%l3}
9330 @tab @code{.L3}
9331 @tab @code{.L3}
9332 @item @code{p}
9333 @tab Print raw symbol name (without syntax-specific prefixes).
9334 @tab @code{%p2}
9335 @tab @code{42}
9336 @tab @code{42}
9337 @item @code{P}
9338 @tab If used for a function, print the PLT suffix and generate PIC code.
9339 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9340 foo(). If used for a constant, drop all syntax-specific prefixes and
9341 issue the bare constant. See @code{p} above.
9342 @item @code{q}
9343 @tab Print the DImode name of the register.
9344 @tab @code{%q0}
9345 @tab @code{%rax}
9346 @tab @code{rax}
9347 @item @code{w}
9348 @tab Print the HImode name of the register.
9349 @tab @code{%w0}
9350 @tab @code{%ax}
9351 @tab @code{ax}
9352 @item @code{z}
9353 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9354 @tab @code{%z0}
9355 @tab @code{l}
9356 @tab 
9357 @end multitable
9359 @code{V} is a special modifier which prints the name of the full integer
9360 register without @code{%}.
9362 @anchor{x86floatingpointasmoperands}
9363 @subsubsection x86 Floating-Point @code{asm} Operands
9365 On x86 targets, there are several rules on the usage of stack-like registers
9366 in the operands of an @code{asm}.  These rules apply only to the operands
9367 that are stack-like registers:
9369 @enumerate
9370 @item
9371 Given a set of input registers that die in an @code{asm}, it is
9372 necessary to know which are implicitly popped by the @code{asm}, and
9373 which must be explicitly popped by GCC@.
9375 An input register that is implicitly popped by the @code{asm} must be
9376 explicitly clobbered, unless it is constrained to match an
9377 output operand.
9379 @item
9380 For any input register that is implicitly popped by an @code{asm}, it is
9381 necessary to know how to adjust the stack to compensate for the pop.
9382 If any non-popped input is closer to the top of the reg-stack than
9383 the implicitly popped register, it would not be possible to know what the
9384 stack looked like---it's not clear how the rest of the stack ``slides
9385 up''.
9387 All implicitly popped input registers must be closer to the top of
9388 the reg-stack than any input that is not implicitly popped.
9390 It is possible that if an input dies in an @code{asm}, the compiler might
9391 use the input register for an output reload.  Consider this example:
9393 @smallexample
9394 asm ("foo" : "=t" (a) : "f" (b));
9395 @end smallexample
9397 @noindent
9398 This code says that input @code{b} is not popped by the @code{asm}, and that
9399 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9400 deeper after the @code{asm} than it was before.  But, it is possible that
9401 reload may think that it can use the same register for both the input and
9402 the output.
9404 To prevent this from happening,
9405 if any input operand uses the @samp{f} constraint, all output register
9406 constraints must use the @samp{&} early-clobber modifier.
9408 The example above is correctly written as:
9410 @smallexample
9411 asm ("foo" : "=&t" (a) : "f" (b));
9412 @end smallexample
9414 @item
9415 Some operands need to be in particular places on the stack.  All
9416 output operands fall in this category---GCC has no other way to
9417 know which registers the outputs appear in unless you indicate
9418 this in the constraints.
9420 Output operands must specifically indicate which register an output
9421 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9422 constraints must select a class with a single register.
9424 @item
9425 Output operands may not be ``inserted'' between existing stack registers.
9426 Since no 387 opcode uses a read/write operand, all output operands
9427 are dead before the @code{asm}, and are pushed by the @code{asm}.
9428 It makes no sense to push anywhere but the top of the reg-stack.
9430 Output operands must start at the top of the reg-stack: output
9431 operands may not ``skip'' a register.
9433 @item
9434 Some @code{asm} statements may need extra stack space for internal
9435 calculations.  This can be guaranteed by clobbering stack registers
9436 unrelated to the inputs and outputs.
9438 @end enumerate
9440 This @code{asm}
9441 takes one input, which is internally popped, and produces two outputs.
9443 @smallexample
9444 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9445 @end smallexample
9447 @noindent
9448 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9449 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9450 for the compiler to know that @code{fyl2xp1} pops both inputs.
9452 @smallexample
9453 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9454 @end smallexample
9456 @lowersections
9457 @include md.texi
9458 @raisesections
9460 @node Asm Labels
9461 @subsection Controlling Names Used in Assembler Code
9462 @cindex assembler names for identifiers
9463 @cindex names used in assembler code
9464 @cindex identifiers, names in assembler code
9466 You can specify the name to be used in the assembler code for a C
9467 function or variable by writing the @code{asm} (or @code{__asm__})
9468 keyword after the declarator.
9469 It is up to you to make sure that the assembler names you choose do not
9470 conflict with any other assembler symbols, or reference registers.
9472 @subsubheading Assembler names for data:
9474 This sample shows how to specify the assembler name for data:
9476 @smallexample
9477 int foo asm ("myfoo") = 2;
9478 @end smallexample
9480 @noindent
9481 This specifies that the name to be used for the variable @code{foo} in
9482 the assembler code should be @samp{myfoo} rather than the usual
9483 @samp{_foo}.
9485 On systems where an underscore is normally prepended to the name of a C
9486 variable, this feature allows you to define names for the
9487 linker that do not start with an underscore.
9489 GCC does not support using this feature with a non-static local variable 
9490 since such variables do not have assembler names.  If you are
9491 trying to put the variable in a particular register, see 
9492 @ref{Explicit Register Variables}.
9494 @subsubheading Assembler names for functions:
9496 To specify the assembler name for functions, write a declaration for the 
9497 function before its definition and put @code{asm} there, like this:
9499 @smallexample
9500 int func (int x, int y) asm ("MYFUNC");
9501      
9502 int func (int x, int y)
9504    /* @r{@dots{}} */
9505 @end smallexample
9507 @noindent
9508 This specifies that the name to be used for the function @code{func} in
9509 the assembler code should be @code{MYFUNC}.
9511 @node Explicit Register Variables
9512 @subsection Variables in Specified Registers
9513 @anchor{Explicit Reg Vars}
9514 @cindex explicit register variables
9515 @cindex variables in specified registers
9516 @cindex specified registers
9518 GNU C allows you to associate specific hardware registers with C 
9519 variables.  In almost all cases, allowing the compiler to assign
9520 registers produces the best code.  However under certain unusual
9521 circumstances, more precise control over the variable storage is 
9522 required.
9524 Both global and local variables can be associated with a register.  The
9525 consequences of performing this association are very different between
9526 the two, as explained in the sections below.
9528 @menu
9529 * Global Register Variables::   Variables declared at global scope.
9530 * Local Register Variables::    Variables declared within a function.
9531 @end menu
9533 @node Global Register Variables
9534 @subsubsection Defining Global Register Variables
9535 @anchor{Global Reg Vars}
9536 @cindex global register variables
9537 @cindex registers, global variables in
9538 @cindex registers, global allocation
9540 You can define a global register variable and associate it with a specified 
9541 register like this:
9543 @smallexample
9544 register int *foo asm ("r12");
9545 @end smallexample
9547 @noindent
9548 Here @code{r12} is the name of the register that should be used. Note that 
9549 this is the same syntax used for defining local register variables, but for 
9550 a global variable the declaration appears outside a function. The 
9551 @code{register} keyword is required, and cannot be combined with 
9552 @code{static}. The register name must be a valid register name for the
9553 target platform.
9555 Registers are a scarce resource on most systems and allowing the 
9556 compiler to manage their usage usually results in the best code. However, 
9557 under special circumstances it can make sense to reserve some globally.
9558 For example this may be useful in programs such as programming language 
9559 interpreters that have a couple of global variables that are accessed 
9560 very often.
9562 After defining a global register variable, for the current compilation
9563 unit:
9565 @itemize @bullet
9566 @item If the register is a call-saved register, call ABI is affected:
9567 the register will not be restored in function epilogue sequences after
9568 the variable has been assigned.  Therefore, functions cannot safely
9569 return to callers that assume standard ABI.
9570 @item Conversely, if the register is a call-clobbered register, making
9571 calls to functions that use standard ABI may lose contents of the variable.
9572 Such calls may be created by the compiler even if none are evident in
9573 the original program, for example when libgcc functions are used to
9574 make up for unavailable instructions.
9575 @item Accesses to the variable may be optimized as usual and the register
9576 remains available for allocation and use in any computations, provided that
9577 observable values of the variable are not affected.
9578 @item If the variable is referenced in inline assembly, the type of access
9579 must be provided to the compiler via constraints (@pxref{Constraints}).
9580 Accesses from basic asms are not supported.
9581 @end itemize
9583 Note that these points @emph{only} apply to code that is compiled with the
9584 definition. The behavior of code that is merely linked in (for example 
9585 code from libraries) is not affected.
9587 If you want to recompile source files that do not actually use your global 
9588 register variable so they do not use the specified register for any other 
9589 purpose, you need not actually add the global register declaration to 
9590 their source code. It suffices to specify the compiler option 
9591 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9592 register.
9594 @subsubheading Declaring the variable
9596 Global register variables can not have initial values, because an
9597 executable file has no means to supply initial contents for a register.
9599 When selecting a register, choose one that is normally saved and 
9600 restored by function calls on your machine. This ensures that code
9601 which is unaware of this reservation (such as library routines) will 
9602 restore it before returning.
9604 On machines with register windows, be sure to choose a global
9605 register that is not affected magically by the function call mechanism.
9607 @subsubheading Using the variable
9609 @cindex @code{qsort}, and global register variables
9610 When calling routines that are not aware of the reservation, be 
9611 cautious if those routines call back into code which uses them. As an 
9612 example, if you call the system library version of @code{qsort}, it may 
9613 clobber your registers during execution, but (if you have selected 
9614 appropriate registers) it will restore them before returning. However 
9615 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9616 function. As a result, global values will not reliably be available to 
9617 the comparison function unless the @code{qsort} function itself is rebuilt.
9619 Similarly, it is not safe to access the global register variables from signal
9620 handlers or from more than one thread of control. Unless you recompile 
9621 them specially for the task at hand, the system library routines may 
9622 temporarily use the register for other things.  Furthermore, since the register
9623 is not reserved exclusively for the variable, accessing it from handlers of
9624 asynchronous signals may observe unrelated temporary values residing in the
9625 register.
9627 @cindex register variable after @code{longjmp}
9628 @cindex global register after @code{longjmp}
9629 @cindex value after @code{longjmp}
9630 @findex longjmp
9631 @findex setjmp
9632 On most machines, @code{longjmp} restores to each global register
9633 variable the value it had at the time of the @code{setjmp}. On some
9634 machines, however, @code{longjmp} does not change the value of global
9635 register variables. To be portable, the function that called @code{setjmp}
9636 should make other arrangements to save the values of the global register
9637 variables, and to restore them in a @code{longjmp}. This way, the same
9638 thing happens regardless of what @code{longjmp} does.
9640 @node Local Register Variables
9641 @subsubsection Specifying Registers for Local Variables
9642 @anchor{Local Reg Vars}
9643 @cindex local variables, specifying registers
9644 @cindex specifying registers for local variables
9645 @cindex registers for local variables
9647 You can define a local register variable and associate it with a specified 
9648 register like this:
9650 @smallexample
9651 register int *foo asm ("r12");
9652 @end smallexample
9654 @noindent
9655 Here @code{r12} is the name of the register that should be used.  Note
9656 that this is the same syntax used for defining global register variables, 
9657 but for a local variable the declaration appears within a function.  The 
9658 @code{register} keyword is required, and cannot be combined with 
9659 @code{static}.  The register name must be a valid register name for the
9660 target platform.
9662 As with global register variables, it is recommended that you choose 
9663 a register that is normally saved and restored by function calls on your 
9664 machine, so that calls to library routines will not clobber it.
9666 The only supported use for this feature is to specify registers
9667 for input and output operands when calling Extended @code{asm} 
9668 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9669 particular machine don't provide sufficient control to select the desired 
9670 register.  To force an operand into a register, create a local variable 
9671 and specify the register name after the variable's declaration.  Then use 
9672 the local variable for the @code{asm} operand and specify any constraint 
9673 letter that matches the register:
9675 @smallexample
9676 register int *p1 asm ("r0") = @dots{};
9677 register int *p2 asm ("r1") = @dots{};
9678 register int *result asm ("r0");
9679 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9680 @end smallexample
9682 @emph{Warning:} In the above example, be aware that a register (for example 
9683 @code{r0}) can be call-clobbered by subsequent code, including function 
9684 calls and library calls for arithmetic operators on other variables (for 
9685 example the initialization of @code{p2}).  In this case, use temporary 
9686 variables for expressions between the register assignments:
9688 @smallexample
9689 int t1 = @dots{};
9690 register int *p1 asm ("r0") = @dots{};
9691 register int *p2 asm ("r1") = t1;
9692 register int *result asm ("r0");
9693 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9694 @end smallexample
9696 Defining a register variable does not reserve the register.  Other than
9697 when invoking the Extended @code{asm}, the contents of the specified 
9698 register are not guaranteed.  For this reason, the following uses 
9699 are explicitly @emph{not} supported.  If they appear to work, it is only 
9700 happenstance, and may stop working as intended due to (seemingly) 
9701 unrelated changes in surrounding code, or even minor changes in the 
9702 optimization of a future version of gcc:
9704 @itemize @bullet
9705 @item Passing parameters to or from Basic @code{asm}
9706 @item Passing parameters to or from Extended @code{asm} without using input 
9707 or output operands.
9708 @item Passing parameters to or from routines written in assembler (or
9709 other languages) using non-standard calling conventions.
9710 @end itemize
9712 Some developers use Local Register Variables in an attempt to improve 
9713 gcc's allocation of registers, especially in large functions.  In this 
9714 case the register name is essentially a hint to the register allocator.
9715 While in some instances this can generate better code, improvements are
9716 subject to the whims of the allocator/optimizers.  Since there are no
9717 guarantees that your improvements won't be lost, this usage of Local
9718 Register Variables is discouraged.
9720 On the MIPS platform, there is related use for local register variables 
9721 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9722 Defining coprocessor specifics for MIPS targets, gccint, 
9723 GNU Compiler Collection (GCC) Internals}).
9725 @node Size of an asm
9726 @subsection Size of an @code{asm}
9728 Some targets require that GCC track the size of each instruction used
9729 in order to generate correct code.  Because the final length of the
9730 code produced by an @code{asm} statement is only known by the
9731 assembler, GCC must make an estimate as to how big it will be.  It
9732 does this by counting the number of instructions in the pattern of the
9733 @code{asm} and multiplying that by the length of the longest
9734 instruction supported by that processor.  (When working out the number
9735 of instructions, it assumes that any occurrence of a newline or of
9736 whatever statement separator character is supported by the assembler --
9737 typically @samp{;} --- indicates the end of an instruction.)
9739 Normally, GCC's estimate is adequate to ensure that correct
9740 code is generated, but it is possible to confuse the compiler if you use
9741 pseudo instructions or assembler macros that expand into multiple real
9742 instructions, or if you use assembler directives that expand to more
9743 space in the object file than is needed for a single instruction.
9744 If this happens then the assembler may produce a diagnostic saying that
9745 a label is unreachable.
9747 @node Alternate Keywords
9748 @section Alternate Keywords
9749 @cindex alternate keywords
9750 @cindex keywords, alternate
9752 @option{-ansi} and the various @option{-std} options disable certain
9753 keywords.  This causes trouble when you want to use GNU C extensions, or
9754 a general-purpose header file that should be usable by all programs,
9755 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9756 @code{inline} are not available in programs compiled with
9757 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9758 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9759 ISO C99 keyword
9760 @code{restrict} is only available when @option{-std=gnu99} (which will
9761 eventually be the default) or @option{-std=c99} (or the equivalent
9762 @option{-std=iso9899:1999}), or an option for a later standard
9763 version, is used.
9765 The way to solve these problems is to put @samp{__} at the beginning and
9766 end of each problematical keyword.  For example, use @code{__asm__}
9767 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9769 Other C compilers won't accept these alternative keywords; if you want to
9770 compile with another compiler, you can define the alternate keywords as
9771 macros to replace them with the customary keywords.  It looks like this:
9773 @smallexample
9774 #ifndef __GNUC__
9775 #define __asm__ asm
9776 #endif
9777 @end smallexample
9779 @findex __extension__
9780 @opindex pedantic
9781 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9782 You can
9783 prevent such warnings within one expression by writing
9784 @code{__extension__} before the expression.  @code{__extension__} has no
9785 effect aside from this.
9787 @node Incomplete Enums
9788 @section Incomplete @code{enum} Types
9790 You can define an @code{enum} tag without specifying its possible values.
9791 This results in an incomplete type, much like what you get if you write
9792 @code{struct foo} without describing the elements.  A later declaration
9793 that does specify the possible values completes the type.
9795 You cannot allocate variables or storage using the type while it is
9796 incomplete.  However, you can work with pointers to that type.
9798 This extension may not be very useful, but it makes the handling of
9799 @code{enum} more consistent with the way @code{struct} and @code{union}
9800 are handled.
9802 This extension is not supported by GNU C++.
9804 @node Function Names
9805 @section Function Names as Strings
9806 @cindex @code{__func__} identifier
9807 @cindex @code{__FUNCTION__} identifier
9808 @cindex @code{__PRETTY_FUNCTION__} identifier
9810 GCC provides three magic constants that hold the name of the current
9811 function as a string.  In C++11 and later modes, all three are treated
9812 as constant expressions and can be used in @code{constexpr} constexts.
9813 The first of these constants is @code{__func__}, which is part of
9814 the C99 standard:
9816 The identifier @code{__func__} is implicitly declared by the translator
9817 as if, immediately following the opening brace of each function
9818 definition, the declaration
9820 @smallexample
9821 static const char __func__[] = "function-name";
9822 @end smallexample
9824 @noindent
9825 appeared, where function-name is the name of the lexically-enclosing
9826 function.  This name is the unadorned name of the function.  As an
9827 extension, at file (or, in C++, namespace scope), @code{__func__}
9828 evaluates to the empty string.
9830 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9831 backward compatibility with old versions of GCC.
9833 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9834 @code{__func__}, except that at file (or, in C++, namespace scope),
9835 it evaluates to the string @code{"top level"}.  In addition, in C++,
9836 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9837 well as its bare name.  For example, this program:
9839 @smallexample
9840 extern "C" int printf (const char *, ...);
9842 class a @{
9843  public:
9844   void sub (int i)
9845     @{
9846       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9847       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9848     @}
9852 main (void)
9854   a ax;
9855   ax.sub (0);
9856   return 0;
9858 @end smallexample
9860 @noindent
9861 gives this output:
9863 @smallexample
9864 __FUNCTION__ = sub
9865 __PRETTY_FUNCTION__ = void a::sub(int)
9866 @end smallexample
9868 These identifiers are variables, not preprocessor macros, and may not
9869 be used to initialize @code{char} arrays or be concatenated with string
9870 literals.
9872 @node Return Address
9873 @section Getting the Return or Frame Address of a Function
9875 These functions may be used to get information about the callers of a
9876 function.
9878 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9879 This function returns the return address of the current function, or of
9880 one of its callers.  The @var{level} argument is number of frames to
9881 scan up the call stack.  A value of @code{0} yields the return address
9882 of the current function, a value of @code{1} yields the return address
9883 of the caller of the current function, and so forth.  When inlining
9884 the expected behavior is that the function returns the address of
9885 the function that is returned to.  To work around this behavior use
9886 the @code{noinline} function attribute.
9888 The @var{level} argument must be a constant integer.
9890 On some machines it may be impossible to determine the return address of
9891 any function other than the current one; in such cases, or when the top
9892 of the stack has been reached, this function returns @code{0} or a
9893 random value.  In addition, @code{__builtin_frame_address} may be used
9894 to determine if the top of the stack has been reached.
9896 Additional post-processing of the returned value may be needed, see
9897 @code{__builtin_extract_return_addr}.
9899 Calling this function with a nonzero argument can have unpredictable
9900 effects, including crashing the calling program.  As a result, calls
9901 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9902 option is in effect.  Such calls should only be made in debugging
9903 situations.
9904 @end deftypefn
9906 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9907 The address as returned by @code{__builtin_return_address} may have to be fed
9908 through this function to get the actual encoded address.  For example, on the
9909 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9910 platforms an offset has to be added for the true next instruction to be
9911 executed.
9913 If no fixup is needed, this function simply passes through @var{addr}.
9914 @end deftypefn
9916 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9917 This function does the reverse of @code{__builtin_extract_return_addr}.
9918 @end deftypefn
9920 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9921 This function is similar to @code{__builtin_return_address}, but it
9922 returns the address of the function frame rather than the return address
9923 of the function.  Calling @code{__builtin_frame_address} with a value of
9924 @code{0} yields the frame address of the current function, a value of
9925 @code{1} yields the frame address of the caller of the current function,
9926 and so forth.
9928 The frame is the area on the stack that holds local variables and saved
9929 registers.  The frame address is normally the address of the first word
9930 pushed on to the stack by the function.  However, the exact definition
9931 depends upon the processor and the calling convention.  If the processor
9932 has a dedicated frame pointer register, and the function has a frame,
9933 then @code{__builtin_frame_address} returns the value of the frame
9934 pointer register.
9936 On some machines it may be impossible to determine the frame address of
9937 any function other than the current one; in such cases, or when the top
9938 of the stack has been reached, this function returns @code{0} if
9939 the first frame pointer is properly initialized by the startup code.
9941 Calling this function with a nonzero argument can have unpredictable
9942 effects, including crashing the calling program.  As a result, calls
9943 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9944 option is in effect.  Such calls should only be made in debugging
9945 situations.
9946 @end deftypefn
9948 @node Vector Extensions
9949 @section Using Vector Instructions through Built-in Functions
9951 On some targets, the instruction set contains SIMD vector instructions which
9952 operate on multiple values contained in one large register at the same time.
9953 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9954 this way.
9956 The first step in using these extensions is to provide the necessary data
9957 types.  This should be done using an appropriate @code{typedef}:
9959 @smallexample
9960 typedef int v4si __attribute__ ((vector_size (16)));
9961 @end smallexample
9963 @noindent
9964 The @code{int} type specifies the base type, while the attribute specifies
9965 the vector size for the variable, measured in bytes.  For example, the
9966 declaration above causes the compiler to set the mode for the @code{v4si}
9967 type to be 16 bytes wide and divided into @code{int} sized units.  For
9968 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9969 corresponding mode of @code{foo} is @acronym{V4SI}.
9971 The @code{vector_size} attribute is only applicable to integral and
9972 float scalars, although arrays, pointers, and function return values
9973 are allowed in conjunction with this construct. Only sizes that are
9974 a power of two are currently allowed.
9976 All the basic integer types can be used as base types, both as signed
9977 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9978 @code{long long}.  In addition, @code{float} and @code{double} can be
9979 used to build floating-point vector types.
9981 Specifying a combination that is not valid for the current architecture
9982 causes GCC to synthesize the instructions using a narrower mode.
9983 For example, if you specify a variable of type @code{V4SI} and your
9984 architecture does not allow for this specific SIMD type, GCC
9985 produces code that uses 4 @code{SIs}.
9987 The types defined in this manner can be used with a subset of normal C
9988 operations.  Currently, GCC allows using the following operators
9989 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9991 The operations behave like C++ @code{valarrays}.  Addition is defined as
9992 the addition of the corresponding elements of the operands.  For
9993 example, in the code below, each of the 4 elements in @var{a} is
9994 added to the corresponding 4 elements in @var{b} and the resulting
9995 vector is stored in @var{c}.
9997 @smallexample
9998 typedef int v4si __attribute__ ((vector_size (16)));
10000 v4si a, b, c;
10002 c = a + b;
10003 @end smallexample
10005 Subtraction, multiplication, division, and the logical operations
10006 operate in a similar manner.  Likewise, the result of using the unary
10007 minus or complement operators on a vector type is a vector whose
10008 elements are the negative or complemented values of the corresponding
10009 elements in the operand.
10011 It is possible to use shifting operators @code{<<}, @code{>>} on
10012 integer-type vectors. The operation is defined as following: @code{@{a0,
10013 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10014 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10015 elements. 
10017 For convenience, it is allowed to use a binary vector operation
10018 where one operand is a scalar. In that case the compiler transforms
10019 the scalar operand into a vector where each element is the scalar from
10020 the operation. The transformation happens only if the scalar could be
10021 safely converted to the vector-element type.
10022 Consider the following code.
10024 @smallexample
10025 typedef int v4si __attribute__ ((vector_size (16)));
10027 v4si a, b, c;
10028 long l;
10030 a = b + 1;    /* a = b + @{1,1,1,1@}; */
10031 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
10033 a = l + a;    /* Error, cannot convert long to int. */
10034 @end smallexample
10036 Vectors can be subscripted as if the vector were an array with
10037 the same number of elements and base type.  Out of bound accesses
10038 invoke undefined behavior at run time.  Warnings for out of bound
10039 accesses for vector subscription can be enabled with
10040 @option{-Warray-bounds}.
10042 Vector comparison is supported with standard comparison
10043 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10044 vector expressions of integer-type or real-type. Comparison between
10045 integer-type vectors and real-type vectors are not supported.  The
10046 result of the comparison is a vector of the same width and number of
10047 elements as the comparison operands with a signed integral element
10048 type.
10050 Vectors are compared element-wise producing 0 when comparison is false
10051 and -1 (constant of the appropriate type where all bits are set)
10052 otherwise. Consider the following example.
10054 @smallexample
10055 typedef int v4si __attribute__ ((vector_size (16)));
10057 v4si a = @{1,2,3,4@};
10058 v4si b = @{3,2,1,4@};
10059 v4si c;
10061 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
10062 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
10063 @end smallexample
10065 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10066 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10067 integer vector with the same number of elements of the same size as @code{b}
10068 and @code{c}, computes all three arguments and creates a vector
10069 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
10070 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10071 As in the case of binary operations, this syntax is also accepted when
10072 one of @code{b} or @code{c} is a scalar that is then transformed into a
10073 vector. If both @code{b} and @code{c} are scalars and the type of
10074 @code{true?b:c} has the same size as the element type of @code{a}, then
10075 @code{b} and @code{c} are converted to a vector type whose elements have
10076 this type and with the same number of elements as @code{a}.
10078 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10079 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10080 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10081 For mixed operations between a scalar @code{s} and a vector @code{v},
10082 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10083 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10085 @findex __builtin_shuffle
10086 Vector shuffling is available using functions
10087 @code{__builtin_shuffle (vec, mask)} and
10088 @code{__builtin_shuffle (vec0, vec1, mask)}.
10089 Both functions construct a permutation of elements from one or two
10090 vectors and return a vector of the same type as the input vector(s).
10091 The @var{mask} is an integral vector with the same width (@var{W})
10092 and element count (@var{N}) as the output vector.
10094 The elements of the input vectors are numbered in memory ordering of
10095 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
10096 elements of @var{mask} are considered modulo @var{N} in the single-operand
10097 case and modulo @math{2*@var{N}} in the two-operand case.
10099 Consider the following example,
10101 @smallexample
10102 typedef int v4si __attribute__ ((vector_size (16)));
10104 v4si a = @{1,2,3,4@};
10105 v4si b = @{5,6,7,8@};
10106 v4si mask1 = @{0,1,1,3@};
10107 v4si mask2 = @{0,4,2,5@};
10108 v4si res;
10110 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
10111 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
10112 @end smallexample
10114 Note that @code{__builtin_shuffle} is intentionally semantically
10115 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10117 You can declare variables and use them in function calls and returns, as
10118 well as in assignments and some casts.  You can specify a vector type as
10119 a return type for a function.  Vector types can also be used as function
10120 arguments.  It is possible to cast from one vector type to another,
10121 provided they are of the same size (in fact, you can also cast vectors
10122 to and from other datatypes of the same size).
10124 You cannot operate between vectors of different lengths or different
10125 signedness without a cast.
10127 @node Offsetof
10128 @section Support for @code{offsetof}
10129 @findex __builtin_offsetof
10131 GCC implements for both C and C++ a syntactic extension to implement
10132 the @code{offsetof} macro.
10134 @smallexample
10135 primary:
10136         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10138 offsetof_member_designator:
10139           @code{identifier}
10140         | offsetof_member_designator "." @code{identifier}
10141         | offsetof_member_designator "[" @code{expr} "]"
10142 @end smallexample
10144 This extension is sufficient such that
10146 @smallexample
10147 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
10148 @end smallexample
10150 @noindent
10151 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
10152 may be dependent.  In either case, @var{member} may consist of a single
10153 identifier, or a sequence of member accesses and array references.
10155 @node __sync Builtins
10156 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10158 The following built-in functions
10159 are intended to be compatible with those described
10160 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10161 section 7.4.  As such, they depart from normal GCC practice by not using
10162 the @samp{__builtin_} prefix and also by being overloaded so that they
10163 work on multiple types.
10165 The definition given in the Intel documentation allows only for the use of
10166 the types @code{int}, @code{long}, @code{long long} or their unsigned
10167 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10168 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10169 Operations on pointer arguments are performed as if the operands were
10170 of the @code{uintptr_t} type.  That is, they are not scaled by the size
10171 of the type to which the pointer points.
10173 These functions are implemented in terms of the @samp{__atomic}
10174 builtins (@pxref{__atomic Builtins}).  They should not be used for new
10175 code which should use the @samp{__atomic} builtins instead.
10177 Not all operations are supported by all target processors.  If a particular
10178 operation cannot be implemented on the target processor, a warning is
10179 generated and a call to an external function is generated.  The external
10180 function carries the same name as the built-in version,
10181 with an additional suffix
10182 @samp{_@var{n}} where @var{n} is the size of the data type.
10184 @c ??? Should we have a mechanism to suppress this warning?  This is almost
10185 @c useful for implementing the operation under the control of an external
10186 @c mutex.
10188 In most cases, these built-in functions are considered a @dfn{full barrier}.
10189 That is,
10190 no memory operand is moved across the operation, either forward or
10191 backward.  Further, instructions are issued as necessary to prevent the
10192 processor from speculating loads across the operation and from queuing stores
10193 after the operation.
10195 All of the routines are described in the Intel documentation to take
10196 ``an optional list of variables protected by the memory barrier''.  It's
10197 not clear what is meant by that; it could mean that @emph{only} the
10198 listed variables are protected, or it could mean a list of additional
10199 variables to be protected.  The list is ignored by GCC which treats it as
10200 empty.  GCC interprets an empty list as meaning that all globally
10201 accessible variables should be protected.
10203 @table @code
10204 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10205 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10206 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10207 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10208 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10209 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10210 @findex __sync_fetch_and_add
10211 @findex __sync_fetch_and_sub
10212 @findex __sync_fetch_and_or
10213 @findex __sync_fetch_and_and
10214 @findex __sync_fetch_and_xor
10215 @findex __sync_fetch_and_nand
10216 These built-in functions perform the operation suggested by the name, and
10217 returns the value that had previously been in memory.  That is, operations
10218 on integer operands have the following semantics.  Operations on pointer
10219 arguments are performed as if the operands were of the @code{uintptr_t}
10220 type.  That is, they are not scaled by the size of the type to which
10221 the pointer points.
10223 @smallexample
10224 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10225 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
10226 @end smallexample
10228 The object pointed to by the first argument must be of integer or pointer
10229 type.  It must not be a boolean type.
10231 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10232 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10234 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10235 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10236 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10237 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10238 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10239 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10240 @findex __sync_add_and_fetch
10241 @findex __sync_sub_and_fetch
10242 @findex __sync_or_and_fetch
10243 @findex __sync_and_and_fetch
10244 @findex __sync_xor_and_fetch
10245 @findex __sync_nand_and_fetch
10246 These built-in functions perform the operation suggested by the name, and
10247 return the new value.  That is, operations on integer operands have
10248 the following semantics.  Operations on pointer operands are performed as
10249 if the operand's type were @code{uintptr_t}.
10251 @smallexample
10252 @{ *ptr @var{op}= value; return *ptr; @}
10253 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10254 @end smallexample
10256 The same constraints on arguments apply as for the corresponding
10257 @code{__sync_op_and_fetch} built-in functions.
10259 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10260 as @code{*ptr = ~(*ptr & value)} instead of
10261 @code{*ptr = ~*ptr & value}.
10263 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10264 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10265 @findex __sync_bool_compare_and_swap
10266 @findex __sync_val_compare_and_swap
10267 These built-in functions perform an atomic compare and swap.
10268 That is, if the current
10269 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10270 @code{*@var{ptr}}.
10272 The ``bool'' version returns true if the comparison is successful and
10273 @var{newval} is written.  The ``val'' version returns the contents
10274 of @code{*@var{ptr}} before the operation.
10276 @item __sync_synchronize (...)
10277 @findex __sync_synchronize
10278 This built-in function issues a full memory barrier.
10280 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10281 @findex __sync_lock_test_and_set
10282 This built-in function, as described by Intel, is not a traditional test-and-set
10283 operation, but rather an atomic exchange operation.  It writes @var{value}
10284 into @code{*@var{ptr}}, and returns the previous contents of
10285 @code{*@var{ptr}}.
10287 Many targets have only minimal support for such locks, and do not support
10288 a full exchange operation.  In this case, a target may support reduced
10289 functionality here by which the @emph{only} valid value to store is the
10290 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10291 is implementation defined.
10293 This built-in function is not a full barrier,
10294 but rather an @dfn{acquire barrier}.
10295 This means that references after the operation cannot move to (or be
10296 speculated to) before the operation, but previous memory stores may not
10297 be globally visible yet, and previous memory loads may not yet be
10298 satisfied.
10300 @item void __sync_lock_release (@var{type} *ptr, ...)
10301 @findex __sync_lock_release
10302 This built-in function releases the lock acquired by
10303 @code{__sync_lock_test_and_set}.
10304 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10306 This built-in function is not a full barrier,
10307 but rather a @dfn{release barrier}.
10308 This means that all previous memory stores are globally visible, and all
10309 previous memory loads have been satisfied, but following memory reads
10310 are not prevented from being speculated to before the barrier.
10311 @end table
10313 @node __atomic Builtins
10314 @section Built-in Functions for Memory Model Aware Atomic Operations
10316 The following built-in functions approximately match the requirements
10317 for the C++11 memory model.  They are all
10318 identified by being prefixed with @samp{__atomic} and most are
10319 overloaded so that they work with multiple types.
10321 These functions are intended to replace the legacy @samp{__sync}
10322 builtins.  The main difference is that the memory order that is requested
10323 is a parameter to the functions.  New code should always use the
10324 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10326 Note that the @samp{__atomic} builtins assume that programs will
10327 conform to the C++11 memory model.  In particular, they assume
10328 that programs are free of data races.  See the C++11 standard for
10329 detailed requirements.
10331 The @samp{__atomic} builtins can be used with any integral scalar or
10332 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10333 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10334 supported by the architecture.
10336 The four non-arithmetic functions (load, store, exchange, and 
10337 compare_exchange) all have a generic version as well.  This generic
10338 version works on any data type.  It uses the lock-free built-in function
10339 if the specific data type size makes that possible; otherwise, an
10340 external call is left to be resolved at run time.  This external call is
10341 the same format with the addition of a @samp{size_t} parameter inserted
10342 as the first parameter indicating the size of the object being pointed to.
10343 All objects must be the same size.
10345 There are 6 different memory orders that can be specified.  These map
10346 to the C++11 memory orders with the same names, see the C++11 standard
10347 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10348 on atomic synchronization} for detailed definitions.  Individual
10349 targets may also support additional memory orders for use on specific
10350 architectures.  Refer to the target documentation for details of
10351 these.
10353 An atomic operation can both constrain code motion and
10354 be mapped to hardware instructions for synchronization between threads
10355 (e.g., a fence).  To which extent this happens is controlled by the
10356 memory orders, which are listed here in approximately ascending order of
10357 strength.  The description of each memory order is only meant to roughly
10358 illustrate the effects and is not a specification; see the C++11
10359 memory model for precise semantics.
10361 @table  @code
10362 @item __ATOMIC_RELAXED
10363 Implies no inter-thread ordering constraints.
10364 @item __ATOMIC_CONSUME
10365 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10366 memory order because of a deficiency in C++11's semantics for
10367 @code{memory_order_consume}.
10368 @item __ATOMIC_ACQUIRE
10369 Creates an inter-thread happens-before constraint from the release (or
10370 stronger) semantic store to this acquire load.  Can prevent hoisting
10371 of code to before the operation.
10372 @item __ATOMIC_RELEASE
10373 Creates an inter-thread happens-before constraint to acquire (or stronger)
10374 semantic loads that read from this release store.  Can prevent sinking
10375 of code to after the operation.
10376 @item __ATOMIC_ACQ_REL
10377 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10378 @code{__ATOMIC_RELEASE}.
10379 @item __ATOMIC_SEQ_CST
10380 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10381 @end table
10383 Note that in the C++11 memory model, @emph{fences} (e.g.,
10384 @samp{__atomic_thread_fence}) take effect in combination with other
10385 atomic operations on specific memory locations (e.g., atomic loads);
10386 operations on specific memory locations do not necessarily affect other
10387 operations in the same way.
10389 Target architectures are encouraged to provide their own patterns for
10390 each of the atomic built-in functions.  If no target is provided, the original
10391 non-memory model set of @samp{__sync} atomic built-in functions are
10392 used, along with any required synchronization fences surrounding it in
10393 order to achieve the proper behavior.  Execution in this case is subject
10394 to the same restrictions as those built-in functions.
10396 If there is no pattern or mechanism to provide a lock-free instruction
10397 sequence, a call is made to an external routine with the same parameters
10398 to be resolved at run time.
10400 When implementing patterns for these built-in functions, the memory order
10401 parameter can be ignored as long as the pattern implements the most
10402 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10403 orders execute correctly with this memory order but they may not execute as
10404 efficiently as they could with a more appropriate implementation of the
10405 relaxed requirements.
10407 Note that the C++11 standard allows for the memory order parameter to be
10408 determined at run time rather than at compile time.  These built-in
10409 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10410 than invoke a runtime library call or inline a switch statement.  This is
10411 standard compliant, safe, and the simplest approach for now.
10413 The memory order parameter is a signed int, but only the lower 16 bits are
10414 reserved for the memory order.  The remainder of the signed int is reserved
10415 for target use and should be 0.  Use of the predefined atomic values
10416 ensures proper usage.
10418 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10419 This built-in function implements an atomic load operation.  It returns the
10420 contents of @code{*@var{ptr}}.
10422 The valid memory order variants are
10423 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10424 and @code{__ATOMIC_CONSUME}.
10426 @end deftypefn
10428 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10429 This is the generic version of an atomic load.  It returns the
10430 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10432 @end deftypefn
10434 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10435 This built-in function implements an atomic store operation.  It writes 
10436 @code{@var{val}} into @code{*@var{ptr}}.  
10438 The valid memory order variants are
10439 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10441 @end deftypefn
10443 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10444 This is the generic version of an atomic store.  It stores the value
10445 of @code{*@var{val}} into @code{*@var{ptr}}.
10447 @end deftypefn
10449 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10450 This built-in function implements an atomic exchange operation.  It writes
10451 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10452 @code{*@var{ptr}}.
10454 The valid memory order variants are
10455 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10456 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10458 @end deftypefn
10460 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10461 This is the generic version of an atomic exchange.  It stores the
10462 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10463 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10465 @end deftypefn
10467 @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)
10468 This built-in function implements an atomic compare and exchange operation.
10469 This compares the contents of @code{*@var{ptr}} with the contents of
10470 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10471 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10472 equal, the operation is a @emph{read} and the current contents of
10473 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
10474 for weak compare_exchange, which may fail spuriously, and false for
10475 the strong variation, which never fails spuriously.  Many targets
10476 only offer the strong variation and ignore the parameter.  When in doubt, use
10477 the strong variation.
10479 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10480 and memory is affected according to the
10481 memory order specified by @var{success_memorder}.  There are no
10482 restrictions on what memory order can be used here.
10484 Otherwise, false is returned and memory is affected according
10485 to @var{failure_memorder}. This memory order cannot be
10486 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10487 stronger order than that specified by @var{success_memorder}.
10489 @end deftypefn
10491 @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)
10492 This built-in function implements the generic version of
10493 @code{__atomic_compare_exchange}.  The function is virtually identical to
10494 @code{__atomic_compare_exchange_n}, except the desired value is also a
10495 pointer.
10497 @end deftypefn
10499 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10500 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10501 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10502 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10503 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10504 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10505 These built-in functions perform the operation suggested by the name, and
10506 return the result of the operation.  Operations on pointer arguments are
10507 performed as if the operands were of the @code{uintptr_t} type.  That is,
10508 they are not scaled by the size of the type to which the pointer points.
10510 @smallexample
10511 @{ *ptr @var{op}= val; return *ptr; @}
10512 @end smallexample
10514 The object pointed to by the first argument must be of integer or pointer
10515 type.  It must not be a boolean type.  All memory orders are valid.
10517 @end deftypefn
10519 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10520 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10521 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10522 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10523 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10524 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10525 These built-in functions perform the operation suggested by the name, and
10526 return the value that had previously been in @code{*@var{ptr}}.  Operations
10527 on pointer arguments are performed as if the operands were of
10528 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10529 the type to which the pointer points.
10531 @smallexample
10532 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10533 @end smallexample
10535 The same constraints on arguments apply as for the corresponding
10536 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10538 @end deftypefn
10540 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10542 This built-in function performs an atomic test-and-set operation on
10543 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10544 defined nonzero ``set'' value and the return value is @code{true} if and only
10545 if the previous contents were ``set''.
10546 It should be only used for operands of type @code{bool} or @code{char}. For 
10547 other types only part of the value may be set.
10549 All memory orders are valid.
10551 @end deftypefn
10553 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10555 This built-in function performs an atomic clear operation on
10556 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10557 It should be only used for operands of type @code{bool} or @code{char} and 
10558 in conjunction with @code{__atomic_test_and_set}.
10559 For other types it may only clear partially. If the type is not @code{bool}
10560 prefer using @code{__atomic_store}.
10562 The valid memory order variants are
10563 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10564 @code{__ATOMIC_RELEASE}.
10566 @end deftypefn
10568 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10570 This built-in function acts as a synchronization fence between threads
10571 based on the specified memory order.
10573 All memory orders are valid.
10575 @end deftypefn
10577 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10579 This built-in function acts as a synchronization fence between a thread
10580 and signal handlers based in the same thread.
10582 All memory orders are valid.
10584 @end deftypefn
10586 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10588 This built-in function returns true if objects of @var{size} bytes always
10589 generate lock-free atomic instructions for the target architecture.
10590 @var{size} must resolve to a compile-time constant and the result also
10591 resolves to a compile-time constant.
10593 @var{ptr} is an optional pointer to the object that may be used to determine
10594 alignment.  A value of 0 indicates typical alignment should be used.  The 
10595 compiler may also ignore this parameter.
10597 @smallexample
10598 if (__atomic_always_lock_free (sizeof (long long), 0))
10599 @end smallexample
10601 @end deftypefn
10603 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10605 This built-in function returns true if objects of @var{size} bytes always
10606 generate lock-free atomic instructions for the target architecture.  If
10607 the built-in function is not known to be lock-free, a call is made to a
10608 runtime routine named @code{__atomic_is_lock_free}.
10610 @var{ptr} is an optional pointer to the object that may be used to determine
10611 alignment.  A value of 0 indicates typical alignment should be used.  The 
10612 compiler may also ignore this parameter.
10613 @end deftypefn
10615 @node Integer Overflow Builtins
10616 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10618 The following built-in functions allow performing simple arithmetic operations
10619 together with checking whether the operations overflowed.
10621 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10622 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10623 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10624 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10625 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10626 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10627 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10629 These built-in functions promote the first two operands into infinite precision signed
10630 type and perform addition on those promoted operands.  The result is then
10631 cast to the type the third pointer argument points to and stored there.
10632 If the stored result is equal to the infinite precision result, the built-in
10633 functions return false, otherwise they return true.  As the addition is
10634 performed in infinite signed precision, these built-in functions have fully defined
10635 behavior for all argument values.
10637 The first built-in function allows arbitrary integral types for operands and
10638 the result type must be pointer to some integral type other than enumerated or
10639 boolean type, the rest of the built-in functions have explicit integer types.
10641 The compiler will attempt to use hardware instructions to implement
10642 these built-in functions where possible, like conditional jump on overflow
10643 after addition, conditional jump on carry etc.
10645 @end deftypefn
10647 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10648 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10649 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10650 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10651 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10652 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10653 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10655 These built-in functions are similar to the add overflow checking built-in
10656 functions above, except they perform subtraction, subtract the second argument
10657 from the first one, instead of addition.
10659 @end deftypefn
10661 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10662 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10663 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10664 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10665 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10666 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10667 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10669 These built-in functions are similar to the add overflow checking built-in
10670 functions above, except they perform multiplication, instead of addition.
10672 @end deftypefn
10674 The following built-in functions allow checking if simple arithmetic operation
10675 would overflow.
10677 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10678 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10679 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10681 These built-in functions are similar to @code{__builtin_add_overflow},
10682 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10683 they don't store the result of the arithmetic operation anywhere and the
10684 last argument is not a pointer, but some expression with integral type other
10685 than enumerated or boolean type.
10687 The built-in functions promote the first two operands into infinite precision signed type
10688 and perform addition on those promoted operands. The result is then
10689 cast to the type of the third argument.  If the cast result is equal to the infinite
10690 precision result, the built-in functions return false, otherwise they return true.
10691 The value of the third argument is ignored, just the side effects in the third argument
10692 are evaluated, and no integral argument promotions are performed on the last argument.
10693 If the third argument is a bit-field, the type used for the result cast has the
10694 precision and signedness of the given bit-field, rather than precision and signedness
10695 of the underlying type.
10697 For example, the following macro can be used to portably check, at
10698 compile-time, whether or not adding two constant integers will overflow,
10699 and perform the addition only when it is known to be safe and not to trigger
10700 a @option{-Woverflow} warning.
10702 @smallexample
10703 #define INT_ADD_OVERFLOW_P(a, b) \
10704    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10706 enum @{
10707     A = INT_MAX, B = 3,
10708     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10709     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10711 @end smallexample
10713 The compiler will attempt to use hardware instructions to implement
10714 these built-in functions where possible, like conditional jump on overflow
10715 after addition, conditional jump on carry etc.
10717 @end deftypefn
10719 @node x86 specific memory model extensions for transactional memory
10720 @section x86-Specific Memory Model Extensions for Transactional Memory
10722 The x86 architecture supports additional memory ordering flags
10723 to mark critical sections for hardware lock elision. 
10724 These must be specified in addition to an existing memory order to
10725 atomic intrinsics.
10727 @table @code
10728 @item __ATOMIC_HLE_ACQUIRE
10729 Start lock elision on a lock variable.
10730 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10731 @item __ATOMIC_HLE_RELEASE
10732 End lock elision on a lock variable.
10733 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10734 @end table
10736 When a lock acquire fails, it is required for good performance to abort
10737 the transaction quickly. This can be done with a @code{_mm_pause}.
10739 @smallexample
10740 #include <immintrin.h> // For _mm_pause
10742 int lockvar;
10744 /* Acquire lock with lock elision */
10745 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10746     _mm_pause(); /* Abort failed transaction */
10748 /* Free lock with lock elision */
10749 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10750 @end smallexample
10752 @node Object Size Checking
10753 @section Object Size Checking Built-in Functions
10754 @findex __builtin_object_size
10755 @findex __builtin___memcpy_chk
10756 @findex __builtin___mempcpy_chk
10757 @findex __builtin___memmove_chk
10758 @findex __builtin___memset_chk
10759 @findex __builtin___strcpy_chk
10760 @findex __builtin___stpcpy_chk
10761 @findex __builtin___strncpy_chk
10762 @findex __builtin___strcat_chk
10763 @findex __builtin___strncat_chk
10764 @findex __builtin___sprintf_chk
10765 @findex __builtin___snprintf_chk
10766 @findex __builtin___vsprintf_chk
10767 @findex __builtin___vsnprintf_chk
10768 @findex __builtin___printf_chk
10769 @findex __builtin___vprintf_chk
10770 @findex __builtin___fprintf_chk
10771 @findex __builtin___vfprintf_chk
10773 GCC implements a limited buffer overflow protection mechanism that can
10774 prevent some buffer overflow attacks by determining the sizes of objects
10775 into which data is about to be written and preventing the writes when
10776 the size isn't sufficient.  The built-in functions described below yield
10777 the best results when used together and when optimization is enabled.
10778 For example, to detect object sizes across function boundaries or to
10779 follow pointer assignments through non-trivial control flow they rely
10780 on various optimization passes enabled with @option{-O2}.  However, to
10781 a limited extent, they can be used without optimization as well.
10783 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10784 is a built-in construct that returns a constant number of bytes from
10785 @var{ptr} to the end of the object @var{ptr} pointer points to
10786 (if known at compile time).  @code{__builtin_object_size} never evaluates
10787 its arguments for side effects.  If there are any side effects in them, it
10788 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10789 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10790 point to and all of them are known at compile time, the returned number
10791 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10792 0 and minimum if nonzero.  If it is not possible to determine which objects
10793 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10794 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10795 for @var{type} 2 or 3.
10797 @var{type} is an integer constant from 0 to 3.  If the least significant
10798 bit is clear, objects are whole variables, if it is set, a closest
10799 surrounding subobject is considered the object a pointer points to.
10800 The second bit determines if maximum or minimum of remaining bytes
10801 is computed.
10803 @smallexample
10804 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10805 char *p = &var.buf1[1], *q = &var.b;
10807 /* Here the object p points to is var.  */
10808 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10809 /* The subobject p points to is var.buf1.  */
10810 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10811 /* The object q points to is var.  */
10812 assert (__builtin_object_size (q, 0)
10813         == (char *) (&var + 1) - (char *) &var.b);
10814 /* The subobject q points to is var.b.  */
10815 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10816 @end smallexample
10817 @end deftypefn
10819 There are built-in functions added for many common string operation
10820 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10821 built-in is provided.  This built-in has an additional last argument,
10822 which is the number of bytes remaining in the object the @var{dest}
10823 argument points to or @code{(size_t) -1} if the size is not known.
10825 The built-in functions are optimized into the normal string functions
10826 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10827 it is known at compile time that the destination object will not
10828 be overflowed.  If the compiler can determine at compile time that the
10829 object will always be overflowed, it issues a warning.
10831 The intended use can be e.g.@:
10833 @smallexample
10834 #undef memcpy
10835 #define bos0(dest) __builtin_object_size (dest, 0)
10836 #define memcpy(dest, src, n) \
10837   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10839 char *volatile p;
10840 char buf[10];
10841 /* It is unknown what object p points to, so this is optimized
10842    into plain memcpy - no checking is possible.  */
10843 memcpy (p, "abcde", n);
10844 /* Destination is known and length too.  It is known at compile
10845    time there will be no overflow.  */
10846 memcpy (&buf[5], "abcde", 5);
10847 /* Destination is known, but the length is not known at compile time.
10848    This will result in __memcpy_chk call that can check for overflow
10849    at run time.  */
10850 memcpy (&buf[5], "abcde", n);
10851 /* Destination is known and it is known at compile time there will
10852    be overflow.  There will be a warning and __memcpy_chk call that
10853    will abort the program at run time.  */
10854 memcpy (&buf[6], "abcde", 5);
10855 @end smallexample
10857 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10858 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10859 @code{strcat} and @code{strncat}.
10861 There are also checking built-in functions for formatted output functions.
10862 @smallexample
10863 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10864 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10865                               const char *fmt, ...);
10866 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10867                               va_list ap);
10868 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10869                                const char *fmt, va_list ap);
10870 @end smallexample
10872 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10873 etc.@: functions and can contain implementation specific flags on what
10874 additional security measures the checking function might take, such as
10875 handling @code{%n} differently.
10877 The @var{os} argument is the object size @var{s} points to, like in the
10878 other built-in functions.  There is a small difference in the behavior
10879 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10880 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10881 the checking function is called with @var{os} argument set to
10882 @code{(size_t) -1}.
10884 In addition to this, there are checking built-in functions
10885 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10886 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10887 These have just one additional argument, @var{flag}, right before
10888 format string @var{fmt}.  If the compiler is able to optimize them to
10889 @code{fputc} etc.@: functions, it does, otherwise the checking function
10890 is called and the @var{flag} argument passed to it.
10892 @node Other Builtins
10893 @section Other Built-in Functions Provided by GCC
10894 @cindex built-in functions
10895 @findex __builtin_alloca
10896 @findex __builtin_alloca_with_align
10897 @findex __builtin_alloca_with_align_and_max
10898 @findex __builtin_call_with_static_chain
10899 @findex __builtin_extend_pointer
10900 @findex __builtin_fpclassify
10901 @findex __builtin_isfinite
10902 @findex __builtin_isnormal
10903 @findex __builtin_isgreater
10904 @findex __builtin_isgreaterequal
10905 @findex __builtin_isinf_sign
10906 @findex __builtin_isless
10907 @findex __builtin_islessequal
10908 @findex __builtin_islessgreater
10909 @findex __builtin_isunordered
10910 @findex __builtin_powi
10911 @findex __builtin_powif
10912 @findex __builtin_powil
10913 @findex _Exit
10914 @findex _exit
10915 @findex abort
10916 @findex abs
10917 @findex acos
10918 @findex acosf
10919 @findex acosh
10920 @findex acoshf
10921 @findex acoshl
10922 @findex acosl
10923 @findex alloca
10924 @findex asin
10925 @findex asinf
10926 @findex asinh
10927 @findex asinhf
10928 @findex asinhl
10929 @findex asinl
10930 @findex atan
10931 @findex atan2
10932 @findex atan2f
10933 @findex atan2l
10934 @findex atanf
10935 @findex atanh
10936 @findex atanhf
10937 @findex atanhl
10938 @findex atanl
10939 @findex bcmp
10940 @findex bzero
10941 @findex cabs
10942 @findex cabsf
10943 @findex cabsl
10944 @findex cacos
10945 @findex cacosf
10946 @findex cacosh
10947 @findex cacoshf
10948 @findex cacoshl
10949 @findex cacosl
10950 @findex calloc
10951 @findex carg
10952 @findex cargf
10953 @findex cargl
10954 @findex casin
10955 @findex casinf
10956 @findex casinh
10957 @findex casinhf
10958 @findex casinhl
10959 @findex casinl
10960 @findex catan
10961 @findex catanf
10962 @findex catanh
10963 @findex catanhf
10964 @findex catanhl
10965 @findex catanl
10966 @findex cbrt
10967 @findex cbrtf
10968 @findex cbrtl
10969 @findex ccos
10970 @findex ccosf
10971 @findex ccosh
10972 @findex ccoshf
10973 @findex ccoshl
10974 @findex ccosl
10975 @findex ceil
10976 @findex ceilf
10977 @findex ceill
10978 @findex cexp
10979 @findex cexpf
10980 @findex cexpl
10981 @findex cimag
10982 @findex cimagf
10983 @findex cimagl
10984 @findex clog
10985 @findex clogf
10986 @findex clogl
10987 @findex clog10
10988 @findex clog10f
10989 @findex clog10l
10990 @findex conj
10991 @findex conjf
10992 @findex conjl
10993 @findex copysign
10994 @findex copysignf
10995 @findex copysignl
10996 @findex cos
10997 @findex cosf
10998 @findex cosh
10999 @findex coshf
11000 @findex coshl
11001 @findex cosl
11002 @findex cpow
11003 @findex cpowf
11004 @findex cpowl
11005 @findex cproj
11006 @findex cprojf
11007 @findex cprojl
11008 @findex creal
11009 @findex crealf
11010 @findex creall
11011 @findex csin
11012 @findex csinf
11013 @findex csinh
11014 @findex csinhf
11015 @findex csinhl
11016 @findex csinl
11017 @findex csqrt
11018 @findex csqrtf
11019 @findex csqrtl
11020 @findex ctan
11021 @findex ctanf
11022 @findex ctanh
11023 @findex ctanhf
11024 @findex ctanhl
11025 @findex ctanl
11026 @findex dcgettext
11027 @findex dgettext
11028 @findex drem
11029 @findex dremf
11030 @findex dreml
11031 @findex erf
11032 @findex erfc
11033 @findex erfcf
11034 @findex erfcl
11035 @findex erff
11036 @findex erfl
11037 @findex exit
11038 @findex exp
11039 @findex exp10
11040 @findex exp10f
11041 @findex exp10l
11042 @findex exp2
11043 @findex exp2f
11044 @findex exp2l
11045 @findex expf
11046 @findex expl
11047 @findex expm1
11048 @findex expm1f
11049 @findex expm1l
11050 @findex fabs
11051 @findex fabsf
11052 @findex fabsl
11053 @findex fdim
11054 @findex fdimf
11055 @findex fdiml
11056 @findex ffs
11057 @findex floor
11058 @findex floorf
11059 @findex floorl
11060 @findex fma
11061 @findex fmaf
11062 @findex fmal
11063 @findex fmax
11064 @findex fmaxf
11065 @findex fmaxl
11066 @findex fmin
11067 @findex fminf
11068 @findex fminl
11069 @findex fmod
11070 @findex fmodf
11071 @findex fmodl
11072 @findex fprintf
11073 @findex fprintf_unlocked
11074 @findex fputs
11075 @findex fputs_unlocked
11076 @findex frexp
11077 @findex frexpf
11078 @findex frexpl
11079 @findex fscanf
11080 @findex gamma
11081 @findex gammaf
11082 @findex gammal
11083 @findex gamma_r
11084 @findex gammaf_r
11085 @findex gammal_r
11086 @findex gettext
11087 @findex hypot
11088 @findex hypotf
11089 @findex hypotl
11090 @findex ilogb
11091 @findex ilogbf
11092 @findex ilogbl
11093 @findex imaxabs
11094 @findex index
11095 @findex isalnum
11096 @findex isalpha
11097 @findex isascii
11098 @findex isblank
11099 @findex iscntrl
11100 @findex isdigit
11101 @findex isgraph
11102 @findex islower
11103 @findex isprint
11104 @findex ispunct
11105 @findex isspace
11106 @findex isupper
11107 @findex iswalnum
11108 @findex iswalpha
11109 @findex iswblank
11110 @findex iswcntrl
11111 @findex iswdigit
11112 @findex iswgraph
11113 @findex iswlower
11114 @findex iswprint
11115 @findex iswpunct
11116 @findex iswspace
11117 @findex iswupper
11118 @findex iswxdigit
11119 @findex isxdigit
11120 @findex j0
11121 @findex j0f
11122 @findex j0l
11123 @findex j1
11124 @findex j1f
11125 @findex j1l
11126 @findex jn
11127 @findex jnf
11128 @findex jnl
11129 @findex labs
11130 @findex ldexp
11131 @findex ldexpf
11132 @findex ldexpl
11133 @findex lgamma
11134 @findex lgammaf
11135 @findex lgammal
11136 @findex lgamma_r
11137 @findex lgammaf_r
11138 @findex lgammal_r
11139 @findex llabs
11140 @findex llrint
11141 @findex llrintf
11142 @findex llrintl
11143 @findex llround
11144 @findex llroundf
11145 @findex llroundl
11146 @findex log
11147 @findex log10
11148 @findex log10f
11149 @findex log10l
11150 @findex log1p
11151 @findex log1pf
11152 @findex log1pl
11153 @findex log2
11154 @findex log2f
11155 @findex log2l
11156 @findex logb
11157 @findex logbf
11158 @findex logbl
11159 @findex logf
11160 @findex logl
11161 @findex lrint
11162 @findex lrintf
11163 @findex lrintl
11164 @findex lround
11165 @findex lroundf
11166 @findex lroundl
11167 @findex malloc
11168 @findex memchr
11169 @findex memcmp
11170 @findex memcpy
11171 @findex mempcpy
11172 @findex memset
11173 @findex modf
11174 @findex modff
11175 @findex modfl
11176 @findex nearbyint
11177 @findex nearbyintf
11178 @findex nearbyintl
11179 @findex nextafter
11180 @findex nextafterf
11181 @findex nextafterl
11182 @findex nexttoward
11183 @findex nexttowardf
11184 @findex nexttowardl
11185 @findex pow
11186 @findex pow10
11187 @findex pow10f
11188 @findex pow10l
11189 @findex powf
11190 @findex powl
11191 @findex printf
11192 @findex printf_unlocked
11193 @findex putchar
11194 @findex puts
11195 @findex remainder
11196 @findex remainderf
11197 @findex remainderl
11198 @findex remquo
11199 @findex remquof
11200 @findex remquol
11201 @findex rindex
11202 @findex rint
11203 @findex rintf
11204 @findex rintl
11205 @findex round
11206 @findex roundf
11207 @findex roundl
11208 @findex scalb
11209 @findex scalbf
11210 @findex scalbl
11211 @findex scalbln
11212 @findex scalblnf
11213 @findex scalblnf
11214 @findex scalbn
11215 @findex scalbnf
11216 @findex scanfnl
11217 @findex signbit
11218 @findex signbitf
11219 @findex signbitl
11220 @findex signbitd32
11221 @findex signbitd64
11222 @findex signbitd128
11223 @findex significand
11224 @findex significandf
11225 @findex significandl
11226 @findex sin
11227 @findex sincos
11228 @findex sincosf
11229 @findex sincosl
11230 @findex sinf
11231 @findex sinh
11232 @findex sinhf
11233 @findex sinhl
11234 @findex sinl
11235 @findex snprintf
11236 @findex sprintf
11237 @findex sqrt
11238 @findex sqrtf
11239 @findex sqrtl
11240 @findex sscanf
11241 @findex stpcpy
11242 @findex stpncpy
11243 @findex strcasecmp
11244 @findex strcat
11245 @findex strchr
11246 @findex strcmp
11247 @findex strcpy
11248 @findex strcspn
11249 @findex strdup
11250 @findex strfmon
11251 @findex strftime
11252 @findex strlen
11253 @findex strncasecmp
11254 @findex strncat
11255 @findex strncmp
11256 @findex strncpy
11257 @findex strndup
11258 @findex strnlen
11259 @findex strpbrk
11260 @findex strrchr
11261 @findex strspn
11262 @findex strstr
11263 @findex tan
11264 @findex tanf
11265 @findex tanh
11266 @findex tanhf
11267 @findex tanhl
11268 @findex tanl
11269 @findex tgamma
11270 @findex tgammaf
11271 @findex tgammal
11272 @findex toascii
11273 @findex tolower
11274 @findex toupper
11275 @findex towlower
11276 @findex towupper
11277 @findex trunc
11278 @findex truncf
11279 @findex truncl
11280 @findex vfprintf
11281 @findex vfscanf
11282 @findex vprintf
11283 @findex vscanf
11284 @findex vsnprintf
11285 @findex vsprintf
11286 @findex vsscanf
11287 @findex y0
11288 @findex y0f
11289 @findex y0l
11290 @findex y1
11291 @findex y1f
11292 @findex y1l
11293 @findex yn
11294 @findex ynf
11295 @findex ynl
11297 GCC provides a large number of built-in functions other than the ones
11298 mentioned above.  Some of these are for internal use in the processing
11299 of exceptions or variable-length argument lists and are not
11300 documented here because they may change from time to time; we do not
11301 recommend general use of these functions.
11303 The remaining functions are provided for optimization purposes.
11305 With the exception of built-ins that have library equivalents such as
11306 the standard C library functions discussed below, or that expand to
11307 library calls, GCC built-in functions are always expanded inline and
11308 thus do not have corresponding entry points and their address cannot
11309 be obtained.  Attempting to use them in an expression other than
11310 a function call results in a compile-time error.
11312 @opindex fno-builtin
11313 GCC includes built-in versions of many of the functions in the standard
11314 C library.  These functions come in two forms: one whose names start with
11315 the @code{__builtin_} prefix, and the other without.  Both forms have the
11316 same type (including prototype), the same address (when their address is
11317 taken), and the same meaning as the C library functions even if you specify
11318 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11319 functions are only optimized in certain cases; if they are not optimized in
11320 a particular case, a call to the library function is emitted.
11322 @opindex ansi
11323 @opindex std
11324 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11325 @option{-std=c99} or @option{-std=c11}), the functions
11326 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11327 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11328 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11329 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11330 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11331 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11332 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11333 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11334 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11335 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11336 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11337 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11338 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11339 @code{significandl}, @code{significand}, @code{sincosf},
11340 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11341 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11342 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
11343 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11344 @code{yn}
11345 may be handled as built-in functions.
11346 All these functions have corresponding versions
11347 prefixed with @code{__builtin_}, which may be used even in strict C90
11348 mode.
11350 The ISO C99 functions
11351 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11352 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11353 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11354 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11355 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11356 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11357 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11358 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11359 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11360 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11361 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11362 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11363 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11364 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11365 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11366 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11367 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11368 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11369 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11370 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11371 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11372 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11373 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11374 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11375 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11376 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11377 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11378 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11379 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11380 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11381 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11382 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11383 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11384 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11385 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11386 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11387 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11388 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11389 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11390 are handled as built-in functions
11391 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11393 There are also built-in versions of the ISO C99 functions
11394 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11395 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11396 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11397 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11398 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11399 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11400 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11401 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11402 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11403 that are recognized in any mode since ISO C90 reserves these names for
11404 the purpose to which ISO C99 puts them.  All these functions have
11405 corresponding versions prefixed with @code{__builtin_}.
11407 There are also built-in functions @code{__builtin_fabsf@var{n}},
11408 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11409 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11410 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11411 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11412 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11414 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11415 @code{clog10l} which names are reserved by ISO C99 for future use.
11416 All these functions have versions prefixed with @code{__builtin_}.
11418 The ISO C94 functions
11419 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11420 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11421 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11422 @code{towupper}
11423 are handled as built-in functions
11424 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11426 The ISO C90 functions
11427 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11428 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11429 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11430 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11431 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11432 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11433 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11434 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11435 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11436 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11437 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11438 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11439 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11440 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11441 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11442 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11443 are all recognized as built-in functions unless
11444 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11445 is specified for an individual function).  All of these functions have
11446 corresponding versions prefixed with @code{__builtin_}.
11448 GCC provides built-in versions of the ISO C99 floating-point comparison
11449 macros that avoid raising exceptions for unordered operands.  They have
11450 the same names as the standard macros ( @code{isgreater},
11451 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11452 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11453 prefixed.  We intend for a library implementor to be able to simply
11454 @code{#define} each standard macro to its built-in equivalent.
11455 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11456 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11457 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11458 built-in functions appear both with and without the @code{__builtin_} prefix.
11460 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11461 The @code{__builtin_alloca} function must be called at block scope.
11462 The function allocates an object @var{size} bytes large on the stack
11463 of the calling function.  The object is aligned on the default stack
11464 alignment boundary for the target determined by the
11465 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11466 function returns a pointer to the first byte of the allocated object.
11467 The lifetime of the allocated object ends just before the calling
11468 function returns to its caller.   This is so even when
11469 @code{__builtin_alloca} is called within a nested block.
11471 For example, the following function allocates eight objects of @code{n}
11472 bytes each on the stack, storing a pointer to each in consecutive elements
11473 of the array @code{a}.  It then passes the array to function @code{g}
11474 which can safely use the storage pointed to by each of the array elements.
11476 @smallexample
11477 void f (unsigned n)
11479   void *a [8];
11480   for (int i = 0; i != 8; ++i)
11481     a [i] = __builtin_alloca (n);
11483   g (a, n);   // @r{safe}
11485 @end smallexample
11487 Since the @code{__builtin_alloca} function doesn't validate its argument
11488 it is the responsibility of its caller to make sure the argument doesn't
11489 cause it to exceed the stack size limit.
11490 The @code{__builtin_alloca} function is provided to make it possible to
11491 allocate on the stack arrays of bytes with an upper bound that may be
11492 computed at run time.  Since C99 Variable Length Arrays offer
11493 similar functionality under a portable, more convenient, and safer
11494 interface they are recommended instead, in both C99 and C++ programs
11495 where GCC provides them as an extension.
11496 @xref{Variable Length}, for details.
11498 @end deftypefn
11500 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11501 The @code{__builtin_alloca_with_align} function must be called at block
11502 scope.  The function allocates an object @var{size} bytes large on
11503 the stack of the calling function.  The allocated object is aligned on
11504 the boundary specified by the argument @var{alignment} whose unit is given
11505 in bits (not bytes).  The @var{size} argument must be positive and not
11506 exceed the stack size limit.  The @var{alignment} argument must be a constant
11507 integer expression that evaluates to a power of 2 greater than or equal to
11508 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11509 with other values are rejected with an error indicating the valid bounds.
11510 The function returns a pointer to the first byte of the allocated object.
11511 The lifetime of the allocated object ends at the end of the block in which
11512 the function was called.  The allocated storage is released no later than
11513 just before the calling function returns to its caller, but may be released
11514 at the end of the block in which the function was called.
11516 For example, in the following function the call to @code{g} is unsafe
11517 because when @code{overalign} is non-zero, the space allocated by
11518 @code{__builtin_alloca_with_align} may have been released at the end
11519 of the @code{if} statement in which it was called.
11521 @smallexample
11522 void f (unsigned n, bool overalign)
11524   void *p;
11525   if (overalign)
11526     p = __builtin_alloca_with_align (n, 64 /* bits */);
11527   else
11528     p = __builtin_alloc (n);
11530   g (p, n);   // @r{unsafe}
11532 @end smallexample
11534 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11535 @var{size} argument it is the responsibility of its caller to make sure
11536 the argument doesn't cause it to exceed the stack size limit.
11537 The @code{__builtin_alloca_with_align} function is provided to make
11538 it possible to allocate on the stack overaligned arrays of bytes with
11539 an upper bound that may be computed at run time.  Since C99
11540 Variable Length Arrays offer the same functionality under
11541 a portable, more convenient, and safer interface they are recommended
11542 instead, in both C99 and C++ programs where GCC provides them as
11543 an extension.  @xref{Variable Length}, for details.
11545 @end deftypefn
11547 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11548 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11549 specifying an upper bound for @var{size} in case its value cannot be computed
11550 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11551 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11552 expression, it has no effect on code generation and no attempt is made to
11553 check its compatibility with @var{size}.
11555 @end deftypefn
11557 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11559 You can use the built-in function @code{__builtin_types_compatible_p} to
11560 determine whether two types are the same.
11562 This built-in function returns 1 if the unqualified versions of the
11563 types @var{type1} and @var{type2} (which are types, not expressions) are
11564 compatible, 0 otherwise.  The result of this built-in function can be
11565 used in integer constant expressions.
11567 This built-in function ignores top level qualifiers (e.g., @code{const},
11568 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11569 int}.
11571 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11572 hand, @code{int} and @code{char *} are not compatible, even if the size
11573 of their types, on the particular architecture are the same.  Also, the
11574 amount of pointer indirection is taken into account when determining
11575 similarity.  Consequently, @code{short *} is not similar to
11576 @code{short **}.  Furthermore, two types that are typedefed are
11577 considered compatible if their underlying types are compatible.
11579 An @code{enum} type is not considered to be compatible with another
11580 @code{enum} type even if both are compatible with the same integer
11581 type; this is what the C standard specifies.
11582 For example, @code{enum @{foo, bar@}} is not similar to
11583 @code{enum @{hot, dog@}}.
11585 You typically use this function in code whose execution varies
11586 depending on the arguments' types.  For example:
11588 @smallexample
11589 #define foo(x)                                                  \
11590   (@{                                                           \
11591     typeof (x) tmp = (x);                                       \
11592     if (__builtin_types_compatible_p (typeof (x), long double)) \
11593       tmp = foo_long_double (tmp);                              \
11594     else if (__builtin_types_compatible_p (typeof (x), double)) \
11595       tmp = foo_double (tmp);                                   \
11596     else if (__builtin_types_compatible_p (typeof (x), float))  \
11597       tmp = foo_float (tmp);                                    \
11598     else                                                        \
11599       abort ();                                                 \
11600     tmp;                                                        \
11601   @})
11602 @end smallexample
11604 @emph{Note:} This construct is only available for C@.
11606 @end deftypefn
11608 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11610 The @var{call_exp} expression must be a function call, and the
11611 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11612 is passed to the function call in the target's static chain location.
11613 The result of builtin is the result of the function call.
11615 @emph{Note:} This builtin is only available for C@.
11616 This builtin can be used to call Go closures from C.
11618 @end deftypefn
11620 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11622 You can use the built-in function @code{__builtin_choose_expr} to
11623 evaluate code depending on the value of a constant expression.  This
11624 built-in function returns @var{exp1} if @var{const_exp}, which is an
11625 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11627 This built-in function is analogous to the @samp{? :} operator in C,
11628 except that the expression returned has its type unaltered by promotion
11629 rules.  Also, the built-in function does not evaluate the expression
11630 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11631 @var{exp2} is not evaluated even if it has side effects.
11633 This built-in function can return an lvalue if the chosen argument is an
11634 lvalue.
11636 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11637 type.  Similarly, if @var{exp2} is returned, its return type is the same
11638 as @var{exp2}.
11640 Example:
11642 @smallexample
11643 #define foo(x)                                                    \
11644   __builtin_choose_expr (                                         \
11645     __builtin_types_compatible_p (typeof (x), double),            \
11646     foo_double (x),                                               \
11647     __builtin_choose_expr (                                       \
11648       __builtin_types_compatible_p (typeof (x), float),           \
11649       foo_float (x),                                              \
11650       /* @r{The void expression results in a compile-time error}  \
11651          @r{when assigning the result to something.}  */          \
11652       (void)0))
11653 @end smallexample
11655 @emph{Note:} This construct is only available for C@.  Furthermore, the
11656 unused expression (@var{exp1} or @var{exp2} depending on the value of
11657 @var{const_exp}) may still generate syntax errors.  This may change in
11658 future revisions.
11660 @end deftypefn
11662 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11664 The built-in function @code{__builtin_tgmath}, available only for C
11665 and Objective-C, calls a function determined according to the rules of
11666 @code{<tgmath.h>} macros.  It is intended to be used in
11667 implementations of that header, so that expansions of macros from that
11668 header only expand each of their arguments once, to avoid problems
11669 when calls to such macros are nested inside the arguments of other
11670 calls to such macros; in addition, it results in better diagnostics
11671 for invalid calls to @code{<tgmath.h>} macros than implementations
11672 using other GNU C language features.  For example, the @code{pow}
11673 type-generic macro might be defined as:
11675 @smallexample
11676 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11677                                     cpowf, cpow, cpowl, a, b)
11678 @end smallexample
11680 The arguments to @code{__builtin_tgmath} are at least two pointers to
11681 functions, followed by the arguments to the type-generic macro (which
11682 will be passed as arguments to the selected function).  All the
11683 pointers to functions must be pointers to prototyped functions, none
11684 of which may have variable arguments, and all of which must have the
11685 same number of parameters; the number of parameters of the first
11686 function determines how many arguments to @code{__builtin_tgmath} are
11687 interpreted as function pointers, and how many as the arguments to the
11688 called function.
11690 The types of the specified functions must all be different, but
11691 related to each other in the same way as a set of functions that may
11692 be selected between by a macro in @code{<tgmath.h>}.  This means that
11693 the functions are parameterized by a floating-point type @var{t},
11694 different for each such function.  The function return types may all
11695 be the same type, or they may be @var{t} for each function, or they
11696 may be the real type corresponding to @var{t} for each function (if
11697 some of the types @var{t} are complex).  Likewise, for each parameter
11698 position, the type of the parameter in that position may always be the
11699 same type, or may be @var{t} for each function (this case must apply
11700 for at least one parameter position), or may be the real type
11701 corresponding to @var{t} for each function.
11703 The standard rules for @code{<tgmath.h>} macros are used to find a
11704 common type @var{u} from the types of the arguments for parameters
11705 whose types vary between the functions; complex integer types (a GNU
11706 extension) are treated like @code{_Complex double} for this purpose
11707 (or @code{_Complex _Float64} if all the function return types are the
11708 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
11709 If the function return types vary, or are all the same integer type,
11710 the function called is the one for which @var{t} is @var{u}, and it is
11711 an error if there is no such function.  If the function return types
11712 are all the same floating-point type, the type-generic macro is taken
11713 to be one of those from TS 18661 that rounds the result to a narrower
11714 type; if there is a function for which @var{t} is @var{u}, it is
11715 called, and otherwise the first function, if any, for which @var{t}
11716 has at least the range and precision of @var{u} is called, and it is
11717 an error if there is no such function.
11719 @end deftypefn
11721 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11723 The built-in function @code{__builtin_complex} is provided for use in
11724 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11725 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11726 real binary floating-point type, and the result has the corresponding
11727 complex type with real and imaginary parts @var{real} and @var{imag}.
11728 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11729 infinities, NaNs and negative zeros are involved.
11731 @end deftypefn
11733 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11734 You can use the built-in function @code{__builtin_constant_p} to
11735 determine if a value is known to be constant at compile time and hence
11736 that GCC can perform constant-folding on expressions involving that
11737 value.  The argument of the function is the value to test.  The function
11738 returns the integer 1 if the argument is known to be a compile-time
11739 constant and 0 if it is not known to be a compile-time constant.  A
11740 return of 0 does not indicate that the value is @emph{not} a constant,
11741 but merely that GCC cannot prove it is a constant with the specified
11742 value of the @option{-O} option.
11744 You typically use this function in an embedded application where
11745 memory is a critical resource.  If you have some complex calculation,
11746 you may want it to be folded if it involves constants, but need to call
11747 a function if it does not.  For example:
11749 @smallexample
11750 #define Scale_Value(X)      \
11751   (__builtin_constant_p (X) \
11752   ? ((X) * SCALE + OFFSET) : Scale (X))
11753 @end smallexample
11755 You may use this built-in function in either a macro or an inline
11756 function.  However, if you use it in an inlined function and pass an
11757 argument of the function as the argument to the built-in, GCC 
11758 never returns 1 when you call the inline function with a string constant
11759 or compound literal (@pxref{Compound Literals}) and does not return 1
11760 when you pass a constant numeric value to the inline function unless you
11761 specify the @option{-O} option.
11763 You may also use @code{__builtin_constant_p} in initializers for static
11764 data.  For instance, you can write
11766 @smallexample
11767 static const int table[] = @{
11768    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11769    /* @r{@dots{}} */
11771 @end smallexample
11773 @noindent
11774 This is an acceptable initializer even if @var{EXPRESSION} is not a
11775 constant expression, including the case where
11776 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11777 folded to a constant but @var{EXPRESSION} contains operands that are
11778 not otherwise permitted in a static initializer (for example,
11779 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11780 built-in in this case, because it has no opportunity to perform
11781 optimization.
11782 @end deftypefn
11784 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11785 @opindex fprofile-arcs
11786 You may use @code{__builtin_expect} to provide the compiler with
11787 branch prediction information.  In general, you should prefer to
11788 use actual profile feedback for this (@option{-fprofile-arcs}), as
11789 programmers are notoriously bad at predicting how their programs
11790 actually perform.  However, there are applications in which this
11791 data is hard to collect.
11793 The return value is the value of @var{exp}, which should be an integral
11794 expression.  The semantics of the built-in are that it is expected that
11795 @var{exp} == @var{c}.  For example:
11797 @smallexample
11798 if (__builtin_expect (x, 0))
11799   foo ();
11800 @end smallexample
11802 @noindent
11803 indicates that we do not expect to call @code{foo}, since
11804 we expect @code{x} to be zero.  Since you are limited to integral
11805 expressions for @var{exp}, you should use constructions such as
11807 @smallexample
11808 if (__builtin_expect (ptr != NULL, 1))
11809   foo (*ptr);
11810 @end smallexample
11812 @noindent
11813 when testing pointer or floating-point values.
11814 @end deftypefn
11816 @deftypefn {Built-in Function} void __builtin_trap (void)
11817 This function causes the program to exit abnormally.  GCC implements
11818 this function by using a target-dependent mechanism (such as
11819 intentionally executing an illegal instruction) or by calling
11820 @code{abort}.  The mechanism used may vary from release to release so
11821 you should not rely on any particular implementation.
11822 @end deftypefn
11824 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11825 If control flow reaches the point of the @code{__builtin_unreachable},
11826 the program is undefined.  It is useful in situations where the
11827 compiler cannot deduce the unreachability of the code.
11829 One such case is immediately following an @code{asm} statement that
11830 either never terminates, or one that transfers control elsewhere
11831 and never returns.  In this example, without the
11832 @code{__builtin_unreachable}, GCC issues a warning that control
11833 reaches the end of a non-void function.  It also generates code
11834 to return after the @code{asm}.
11836 @smallexample
11837 int f (int c, int v)
11839   if (c)
11840     @{
11841       return v;
11842     @}
11843   else
11844     @{
11845       asm("jmp error_handler");
11846       __builtin_unreachable ();
11847     @}
11849 @end smallexample
11851 @noindent
11852 Because the @code{asm} statement unconditionally transfers control out
11853 of the function, control never reaches the end of the function
11854 body.  The @code{__builtin_unreachable} is in fact unreachable and
11855 communicates this fact to the compiler.
11857 Another use for @code{__builtin_unreachable} is following a call a
11858 function that never returns but that is not declared
11859 @code{__attribute__((noreturn))}, as in this example:
11861 @smallexample
11862 void function_that_never_returns (void);
11864 int g (int c)
11866   if (c)
11867     @{
11868       return 1;
11869     @}
11870   else
11871     @{
11872       function_that_never_returns ();
11873       __builtin_unreachable ();
11874     @}
11876 @end smallexample
11878 @end deftypefn
11880 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11881 This function returns its first argument, and allows the compiler
11882 to assume that the returned pointer is at least @var{align} bytes
11883 aligned.  This built-in can have either two or three arguments,
11884 if it has three, the third argument should have integer type, and
11885 if it is nonzero means misalignment offset.  For example:
11887 @smallexample
11888 void *x = __builtin_assume_aligned (arg, 16);
11889 @end smallexample
11891 @noindent
11892 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11893 16-byte aligned, while:
11895 @smallexample
11896 void *x = __builtin_assume_aligned (arg, 32, 8);
11897 @end smallexample
11899 @noindent
11900 means that the compiler can assume for @code{x}, set to @code{arg}, that
11901 @code{(char *) x - 8} is 32-byte aligned.
11902 @end deftypefn
11904 @deftypefn {Built-in Function} int __builtin_LINE ()
11905 This function is the equivalent of the preprocessor @code{__LINE__}
11906 macro and returns a constant integer expression that evaluates to
11907 the line number of the invocation of the built-in.  When used as a C++
11908 default argument for a function @var{F}, it returns the line number
11909 of the call to @var{F}.
11910 @end deftypefn
11912 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11913 This function is the equivalent of the @code{__FUNCTION__} symbol
11914 and returns an address constant pointing to the name of the function
11915 from which the built-in was invoked, or the empty string if
11916 the invocation is not at function scope.  When used as a C++ default
11917 argument for a function @var{F}, it returns the name of @var{F}'s
11918 caller or the empty string if the call was not made at function
11919 scope.
11920 @end deftypefn
11922 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11923 This function is the equivalent of the preprocessor @code{__FILE__}
11924 macro and returns an address constant pointing to the file name
11925 containing the invocation of the built-in, or the empty string if
11926 the invocation is not at function scope.  When used as a C++ default
11927 argument for a function @var{F}, it returns the file name of the call
11928 to @var{F} or the empty string if the call was not made at function
11929 scope.
11931 For example, in the following, each call to function @code{foo} will
11932 print a line similar to @code{"file.c:123: foo: message"} with the name
11933 of the file and the line number of the @code{printf} call, the name of
11934 the function @code{foo}, followed by the word @code{message}.
11936 @smallexample
11937 const char*
11938 function (const char *func = __builtin_FUNCTION ())
11940   return func;
11943 void foo (void)
11945   printf ("%s:%i: %s: message\n", file (), line (), function ());
11947 @end smallexample
11949 @end deftypefn
11951 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11952 This function is used to flush the processor's instruction cache for
11953 the region of memory between @var{begin} inclusive and @var{end}
11954 exclusive.  Some targets require that the instruction cache be
11955 flushed, after modifying memory containing code, in order to obtain
11956 deterministic behavior.
11958 If the target does not require instruction cache flushes,
11959 @code{__builtin___clear_cache} has no effect.  Otherwise either
11960 instructions are emitted in-line to clear the instruction cache or a
11961 call to the @code{__clear_cache} function in libgcc is made.
11962 @end deftypefn
11964 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11965 This function is used to minimize cache-miss latency by moving data into
11966 a cache before it is accessed.
11967 You can insert calls to @code{__builtin_prefetch} into code for which
11968 you know addresses of data in memory that is likely to be accessed soon.
11969 If the target supports them, data prefetch instructions are generated.
11970 If the prefetch is done early enough before the access then the data will
11971 be in the cache by the time it is accessed.
11973 The value of @var{addr} is the address of the memory to prefetch.
11974 There are two optional arguments, @var{rw} and @var{locality}.
11975 The value of @var{rw} is a compile-time constant one or zero; one
11976 means that the prefetch is preparing for a write to the memory address
11977 and zero, the default, means that the prefetch is preparing for a read.
11978 The value @var{locality} must be a compile-time constant integer between
11979 zero and three.  A value of zero means that the data has no temporal
11980 locality, so it need not be left in the cache after the access.  A value
11981 of three means that the data has a high degree of temporal locality and
11982 should be left in all levels of cache possible.  Values of one and two
11983 mean, respectively, a low or moderate degree of temporal locality.  The
11984 default is three.
11986 @smallexample
11987 for (i = 0; i < n; i++)
11988   @{
11989     a[i] = a[i] + b[i];
11990     __builtin_prefetch (&a[i+j], 1, 1);
11991     __builtin_prefetch (&b[i+j], 0, 1);
11992     /* @r{@dots{}} */
11993   @}
11994 @end smallexample
11996 Data prefetch does not generate faults if @var{addr} is invalid, but
11997 the address expression itself must be valid.  For example, a prefetch
11998 of @code{p->next} does not fault if @code{p->next} is not a valid
11999 address, but evaluation faults if @code{p} is not a valid address.
12001 If the target does not support data prefetch, the address expression
12002 is evaluated if it includes side effects but no other code is generated
12003 and GCC does not issue a warning.
12004 @end deftypefn
12006 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12007 Returns a positive infinity, if supported by the floating-point format,
12008 else @code{DBL_MAX}.  This function is suitable for implementing the
12009 ISO C macro @code{HUGE_VAL}.
12010 @end deftypefn
12012 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12013 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12014 @end deftypefn
12016 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12017 Similar to @code{__builtin_huge_val}, except the return
12018 type is @code{long double}.
12019 @end deftypefn
12021 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12022 Similar to @code{__builtin_huge_val}, except the return type is
12023 @code{_Float@var{n}}.
12024 @end deftypefn
12026 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12027 Similar to @code{__builtin_huge_val}, except the return type is
12028 @code{_Float@var{n}x}.
12029 @end deftypefn
12031 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12032 This built-in implements the C99 fpclassify functionality.  The first
12033 five int arguments should be the target library's notion of the
12034 possible FP classes and are used for return values.  They must be
12035 constant values and they must appear in this order: @code{FP_NAN},
12036 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12037 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
12038 to classify.  GCC treats the last argument as type-generic, which
12039 means it does not do default promotion from float to double.
12040 @end deftypefn
12042 @deftypefn {Built-in Function} double __builtin_inf (void)
12043 Similar to @code{__builtin_huge_val}, except a warning is generated
12044 if the target floating-point format does not support infinities.
12045 @end deftypefn
12047 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12048 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12049 @end deftypefn
12051 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12052 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12053 @end deftypefn
12055 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12056 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12057 @end deftypefn
12059 @deftypefn {Built-in Function} float __builtin_inff (void)
12060 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12061 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12062 @end deftypefn
12064 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12065 Similar to @code{__builtin_inf}, except the return
12066 type is @code{long double}.
12067 @end deftypefn
12069 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12070 Similar to @code{__builtin_inf}, except the return
12071 type is @code{_Float@var{n}}.
12072 @end deftypefn
12074 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12075 Similar to @code{__builtin_inf}, except the return
12076 type is @code{_Float@var{n}x}.
12077 @end deftypefn
12079 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12080 Similar to @code{isinf}, except the return value is -1 for
12081 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12082 Note while the parameter list is an
12083 ellipsis, this function only accepts exactly one floating-point
12084 argument.  GCC treats this parameter as type-generic, which means it
12085 does not do default promotion from float to double.
12086 @end deftypefn
12088 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12089 This is an implementation of the ISO C99 function @code{nan}.
12091 Since ISO C99 defines this function in terms of @code{strtod}, which we
12092 do not implement, a description of the parsing is in order.  The string
12093 is parsed as by @code{strtol}; that is, the base is recognized by
12094 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12095 in the significand such that the least significant bit of the number
12096 is at the least significant bit of the significand.  The number is
12097 truncated to fit the significand field provided.  The significand is
12098 forced to be a quiet NaN@.
12100 This function, if given a string literal all of which would have been
12101 consumed by @code{strtol}, is evaluated early enough that it is considered a
12102 compile-time constant.
12103 @end deftypefn
12105 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12106 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12107 @end deftypefn
12109 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12110 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12111 @end deftypefn
12113 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12114 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12115 @end deftypefn
12117 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12118 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12119 @end deftypefn
12121 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12122 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12123 @end deftypefn
12125 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12126 Similar to @code{__builtin_nan}, except the return type is
12127 @code{_Float@var{n}}.
12128 @end deftypefn
12130 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12131 Similar to @code{__builtin_nan}, except the return type is
12132 @code{_Float@var{n}x}.
12133 @end deftypefn
12135 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12136 Similar to @code{__builtin_nan}, except the significand is forced
12137 to be a signaling NaN@.  The @code{nans} function is proposed by
12138 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12139 @end deftypefn
12141 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12142 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12143 @end deftypefn
12145 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12146 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12147 @end deftypefn
12149 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12150 Similar to @code{__builtin_nans}, except the return type is
12151 @code{_Float@var{n}}.
12152 @end deftypefn
12154 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12155 Similar to @code{__builtin_nans}, except the return type is
12156 @code{_Float@var{n}x}.
12157 @end deftypefn
12159 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12160 Returns one plus the index of the least significant 1-bit of @var{x}, or
12161 if @var{x} is zero, returns zero.
12162 @end deftypefn
12164 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12165 Returns the number of leading 0-bits in @var{x}, starting at the most
12166 significant bit position.  If @var{x} is 0, the result is undefined.
12167 @end deftypefn
12169 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12170 Returns the number of trailing 0-bits in @var{x}, starting at the least
12171 significant bit position.  If @var{x} is 0, the result is undefined.
12172 @end deftypefn
12174 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12175 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12176 number of bits following the most significant bit that are identical
12177 to it.  There are no special cases for 0 or other values. 
12178 @end deftypefn
12180 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12181 Returns the number of 1-bits in @var{x}.
12182 @end deftypefn
12184 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12185 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12186 modulo 2.
12187 @end deftypefn
12189 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12190 Similar to @code{__builtin_ffs}, except the argument type is
12191 @code{long}.
12192 @end deftypefn
12194 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12195 Similar to @code{__builtin_clz}, except the argument type is
12196 @code{unsigned long}.
12197 @end deftypefn
12199 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12200 Similar to @code{__builtin_ctz}, except the argument type is
12201 @code{unsigned long}.
12202 @end deftypefn
12204 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12205 Similar to @code{__builtin_clrsb}, except the argument type is
12206 @code{long}.
12207 @end deftypefn
12209 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12210 Similar to @code{__builtin_popcount}, except the argument type is
12211 @code{unsigned long}.
12212 @end deftypefn
12214 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12215 Similar to @code{__builtin_parity}, except the argument type is
12216 @code{unsigned long}.
12217 @end deftypefn
12219 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12220 Similar to @code{__builtin_ffs}, except the argument type is
12221 @code{long long}.
12222 @end deftypefn
12224 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12225 Similar to @code{__builtin_clz}, except the argument type is
12226 @code{unsigned long long}.
12227 @end deftypefn
12229 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12230 Similar to @code{__builtin_ctz}, except the argument type is
12231 @code{unsigned long long}.
12232 @end deftypefn
12234 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12235 Similar to @code{__builtin_clrsb}, except the argument type is
12236 @code{long long}.
12237 @end deftypefn
12239 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12240 Similar to @code{__builtin_popcount}, except the argument type is
12241 @code{unsigned long long}.
12242 @end deftypefn
12244 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12245 Similar to @code{__builtin_parity}, except the argument type is
12246 @code{unsigned long long}.
12247 @end deftypefn
12249 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12250 Returns the first argument raised to the power of the second.  Unlike the
12251 @code{pow} function no guarantees about precision and rounding are made.
12252 @end deftypefn
12254 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12255 Similar to @code{__builtin_powi}, except the argument and return types
12256 are @code{float}.
12257 @end deftypefn
12259 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12260 Similar to @code{__builtin_powi}, except the argument and return types
12261 are @code{long double}.
12262 @end deftypefn
12264 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12265 Returns @var{x} with the order of the bytes reversed; for example,
12266 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12267 exactly 8 bits.
12268 @end deftypefn
12270 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12271 Similar to @code{__builtin_bswap16}, except the argument and return types
12272 are 32 bit.
12273 @end deftypefn
12275 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12276 Similar to @code{__builtin_bswap32}, except the argument and return types
12277 are 64 bit.
12278 @end deftypefn
12280 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12281 On targets where the user visible pointer size is smaller than the size
12282 of an actual hardware address this function returns the extended user
12283 pointer.  Targets where this is true included ILP32 mode on x86_64 or
12284 Aarch64.  This function is mainly useful when writing inline assembly
12285 code.
12286 @end deftypefn
12288 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12289 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12290 0, 1 or 2.
12291 @end deftypefn
12293 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12294 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12295 0, 1 or 2.
12296 @end deftypefn
12298 @node Target Builtins
12299 @section Built-in Functions Specific to Particular Target Machines
12301 On some target machines, GCC supports many built-in functions specific
12302 to those machines.  Generally these generate calls to specific machine
12303 instructions, but allow the compiler to schedule those calls.
12305 @menu
12306 * AArch64 Built-in Functions::
12307 * Alpha Built-in Functions::
12308 * Altera Nios II Built-in Functions::
12309 * ARC Built-in Functions::
12310 * ARC SIMD Built-in Functions::
12311 * ARM iWMMXt Built-in Functions::
12312 * ARM C Language Extensions (ACLE)::
12313 * ARM Floating Point Status and Control Intrinsics::
12314 * ARM ARMv8-M Security Extensions::
12315 * AVR Built-in Functions::
12316 * Blackfin Built-in Functions::
12317 * FR-V Built-in Functions::
12318 * MIPS DSP Built-in Functions::
12319 * MIPS Paired-Single Support::
12320 * MIPS Loongson Built-in Functions::
12321 * MIPS SIMD Architecture (MSA) Support::
12322 * Other MIPS Built-in Functions::
12323 * MSP430 Built-in Functions::
12324 * NDS32 Built-in Functions::
12325 * picoChip Built-in Functions::
12326 * Basic PowerPC Built-in Functions::
12327 * PowerPC AltiVec/VSX Built-in Functions::
12328 * PowerPC Hardware Transactional Memory Built-in Functions::
12329 * PowerPC Atomic Memory Operation Functions::
12330 * RX Built-in Functions::
12331 * S/390 System z Built-in Functions::
12332 * SH Built-in Functions::
12333 * SPARC VIS Built-in Functions::
12334 * SPU Built-in Functions::
12335 * TI C6X Built-in Functions::
12336 * TILE-Gx Built-in Functions::
12337 * TILEPro Built-in Functions::
12338 * x86 Built-in Functions::
12339 * x86 transactional memory intrinsics::
12340 * x86 control-flow protection intrinsics::
12341 @end menu
12343 @node AArch64 Built-in Functions
12344 @subsection AArch64 Built-in Functions
12346 These built-in functions are available for the AArch64 family of
12347 processors.
12348 @smallexample
12349 unsigned int __builtin_aarch64_get_fpcr ()
12350 void __builtin_aarch64_set_fpcr (unsigned int)
12351 unsigned int __builtin_aarch64_get_fpsr ()
12352 void __builtin_aarch64_set_fpsr (unsigned int)
12353 @end smallexample
12355 @node Alpha Built-in Functions
12356 @subsection Alpha Built-in Functions
12358 These built-in functions are available for the Alpha family of
12359 processors, depending on the command-line switches used.
12361 The following built-in functions are always available.  They
12362 all generate the machine instruction that is part of the name.
12364 @smallexample
12365 long __builtin_alpha_implver (void)
12366 long __builtin_alpha_rpcc (void)
12367 long __builtin_alpha_amask (long)
12368 long __builtin_alpha_cmpbge (long, long)
12369 long __builtin_alpha_extbl (long, long)
12370 long __builtin_alpha_extwl (long, long)
12371 long __builtin_alpha_extll (long, long)
12372 long __builtin_alpha_extql (long, long)
12373 long __builtin_alpha_extwh (long, long)
12374 long __builtin_alpha_extlh (long, long)
12375 long __builtin_alpha_extqh (long, long)
12376 long __builtin_alpha_insbl (long, long)
12377 long __builtin_alpha_inswl (long, long)
12378 long __builtin_alpha_insll (long, long)
12379 long __builtin_alpha_insql (long, long)
12380 long __builtin_alpha_inswh (long, long)
12381 long __builtin_alpha_inslh (long, long)
12382 long __builtin_alpha_insqh (long, long)
12383 long __builtin_alpha_mskbl (long, long)
12384 long __builtin_alpha_mskwl (long, long)
12385 long __builtin_alpha_mskll (long, long)
12386 long __builtin_alpha_mskql (long, long)
12387 long __builtin_alpha_mskwh (long, long)
12388 long __builtin_alpha_msklh (long, long)
12389 long __builtin_alpha_mskqh (long, long)
12390 long __builtin_alpha_umulh (long, long)
12391 long __builtin_alpha_zap (long, long)
12392 long __builtin_alpha_zapnot (long, long)
12393 @end smallexample
12395 The following built-in functions are always with @option{-mmax}
12396 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12397 later.  They all generate the machine instruction that is part
12398 of the name.
12400 @smallexample
12401 long __builtin_alpha_pklb (long)
12402 long __builtin_alpha_pkwb (long)
12403 long __builtin_alpha_unpkbl (long)
12404 long __builtin_alpha_unpkbw (long)
12405 long __builtin_alpha_minub8 (long, long)
12406 long __builtin_alpha_minsb8 (long, long)
12407 long __builtin_alpha_minuw4 (long, long)
12408 long __builtin_alpha_minsw4 (long, long)
12409 long __builtin_alpha_maxub8 (long, long)
12410 long __builtin_alpha_maxsb8 (long, long)
12411 long __builtin_alpha_maxuw4 (long, long)
12412 long __builtin_alpha_maxsw4 (long, long)
12413 long __builtin_alpha_perr (long, long)
12414 @end smallexample
12416 The following built-in functions are always with @option{-mcix}
12417 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12418 later.  They all generate the machine instruction that is part
12419 of the name.
12421 @smallexample
12422 long __builtin_alpha_cttz (long)
12423 long __builtin_alpha_ctlz (long)
12424 long __builtin_alpha_ctpop (long)
12425 @end smallexample
12427 The following built-in functions are available on systems that use the OSF/1
12428 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12429 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12430 @code{rdval} and @code{wrval}.
12432 @smallexample
12433 void *__builtin_thread_pointer (void)
12434 void __builtin_set_thread_pointer (void *)
12435 @end smallexample
12437 @node Altera Nios II Built-in Functions
12438 @subsection Altera Nios II Built-in Functions
12440 These built-in functions are available for the Altera Nios II
12441 family of processors.
12443 The following built-in functions are always available.  They
12444 all generate the machine instruction that is part of the name.
12446 @example
12447 int __builtin_ldbio (volatile const void *)
12448 int __builtin_ldbuio (volatile const void *)
12449 int __builtin_ldhio (volatile const void *)
12450 int __builtin_ldhuio (volatile const void *)
12451 int __builtin_ldwio (volatile const void *)
12452 void __builtin_stbio (volatile void *, int)
12453 void __builtin_sthio (volatile void *, int)
12454 void __builtin_stwio (volatile void *, int)
12455 void __builtin_sync (void)
12456 int __builtin_rdctl (int) 
12457 int __builtin_rdprs (int, int)
12458 void __builtin_wrctl (int, int)
12459 void __builtin_flushd (volatile void *)
12460 void __builtin_flushda (volatile void *)
12461 int __builtin_wrpie (int);
12462 void __builtin_eni (int);
12463 int __builtin_ldex (volatile const void *)
12464 int __builtin_stex (volatile void *, int)
12465 int __builtin_ldsex (volatile const void *)
12466 int __builtin_stsex (volatile void *, int)
12467 @end example
12469 The following built-in functions are always available.  They
12470 all generate a Nios II Custom Instruction. The name of the
12471 function represents the types that the function takes and
12472 returns. The letter before the @code{n} is the return type
12473 or void if absent. The @code{n} represents the first parameter
12474 to all the custom instructions, the custom instruction number.
12475 The two letters after the @code{n} represent the up to two
12476 parameters to the function.
12478 The letters represent the following data types:
12479 @table @code
12480 @item <no letter>
12481 @code{void} for return type and no parameter for parameter types.
12483 @item i
12484 @code{int} for return type and parameter type
12486 @item f
12487 @code{float} for return type and parameter type
12489 @item p
12490 @code{void *} for return type and parameter type
12492 @end table
12494 And the function names are:
12495 @example
12496 void __builtin_custom_n (void)
12497 void __builtin_custom_ni (int)
12498 void __builtin_custom_nf (float)
12499 void __builtin_custom_np (void *)
12500 void __builtin_custom_nii (int, int)
12501 void __builtin_custom_nif (int, float)
12502 void __builtin_custom_nip (int, void *)
12503 void __builtin_custom_nfi (float, int)
12504 void __builtin_custom_nff (float, float)
12505 void __builtin_custom_nfp (float, void *)
12506 void __builtin_custom_npi (void *, int)
12507 void __builtin_custom_npf (void *, float)
12508 void __builtin_custom_npp (void *, void *)
12509 int __builtin_custom_in (void)
12510 int __builtin_custom_ini (int)
12511 int __builtin_custom_inf (float)
12512 int __builtin_custom_inp (void *)
12513 int __builtin_custom_inii (int, int)
12514 int __builtin_custom_inif (int, float)
12515 int __builtin_custom_inip (int, void *)
12516 int __builtin_custom_infi (float, int)
12517 int __builtin_custom_inff (float, float)
12518 int __builtin_custom_infp (float, void *)
12519 int __builtin_custom_inpi (void *, int)
12520 int __builtin_custom_inpf (void *, float)
12521 int __builtin_custom_inpp (void *, void *)
12522 float __builtin_custom_fn (void)
12523 float __builtin_custom_fni (int)
12524 float __builtin_custom_fnf (float)
12525 float __builtin_custom_fnp (void *)
12526 float __builtin_custom_fnii (int, int)
12527 float __builtin_custom_fnif (int, float)
12528 float __builtin_custom_fnip (int, void *)
12529 float __builtin_custom_fnfi (float, int)
12530 float __builtin_custom_fnff (float, float)
12531 float __builtin_custom_fnfp (float, void *)
12532 float __builtin_custom_fnpi (void *, int)
12533 float __builtin_custom_fnpf (void *, float)
12534 float __builtin_custom_fnpp (void *, void *)
12535 void * __builtin_custom_pn (void)
12536 void * __builtin_custom_pni (int)
12537 void * __builtin_custom_pnf (float)
12538 void * __builtin_custom_pnp (void *)
12539 void * __builtin_custom_pnii (int, int)
12540 void * __builtin_custom_pnif (int, float)
12541 void * __builtin_custom_pnip (int, void *)
12542 void * __builtin_custom_pnfi (float, int)
12543 void * __builtin_custom_pnff (float, float)
12544 void * __builtin_custom_pnfp (float, void *)
12545 void * __builtin_custom_pnpi (void *, int)
12546 void * __builtin_custom_pnpf (void *, float)
12547 void * __builtin_custom_pnpp (void *, void *)
12548 @end example
12550 @node ARC Built-in Functions
12551 @subsection ARC Built-in Functions
12553 The following built-in functions are provided for ARC targets.  The
12554 built-ins generate the corresponding assembly instructions.  In the
12555 examples given below, the generated code often requires an operand or
12556 result to be in a register.  Where necessary further code will be
12557 generated to ensure this is true, but for brevity this is not
12558 described in each case.
12560 @emph{Note:} Using a built-in to generate an instruction not supported
12561 by a target may cause problems. At present the compiler is not
12562 guaranteed to detect such misuse, and as a result an internal compiler
12563 error may be generated.
12565 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12566 Return 1 if @var{val} is known to have the byte alignment given
12567 by @var{alignval}, otherwise return 0.
12568 Note that this is different from
12569 @smallexample
12570 __alignof__(*(char *)@var{val}) >= alignval
12571 @end smallexample
12572 because __alignof__ sees only the type of the dereference, whereas
12573 __builtin_arc_align uses alignment information from the pointer
12574 as well as from the pointed-to type.
12575 The information available will depend on optimization level.
12576 @end deftypefn
12578 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12579 Generates
12580 @example
12582 @end example
12583 @end deftypefn
12585 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12586 The operand is the number of a register to be read.  Generates:
12587 @example
12588 mov  @var{dest}, r@var{regno}
12589 @end example
12590 where the value in @var{dest} will be the result returned from the
12591 built-in.
12592 @end deftypefn
12594 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12595 The first operand is the number of a register to be written, the
12596 second operand is a compile time constant to write into that
12597 register.  Generates:
12598 @example
12599 mov  r@var{regno}, @var{val}
12600 @end example
12601 @end deftypefn
12603 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12604 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12605 Generates:
12606 @example
12607 divaw  @var{dest}, @var{a}, @var{b}
12608 @end example
12609 where the value in @var{dest} will be the result returned from the
12610 built-in.
12611 @end deftypefn
12613 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12614 Generates
12615 @example
12616 flag  @var{a}
12617 @end example
12618 @end deftypefn
12620 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12621 The operand, @var{auxv}, is the address of an auxiliary register and
12622 must be a compile time constant.  Generates:
12623 @example
12624 lr  @var{dest}, [@var{auxr}]
12625 @end example
12626 Where the value in @var{dest} will be the result returned from the
12627 built-in.
12628 @end deftypefn
12630 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12631 Only available with @option{-mmul64}.  Generates:
12632 @example
12633 mul64  @var{a}, @var{b}
12634 @end example
12635 @end deftypefn
12637 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12638 Only available with @option{-mmul64}.  Generates:
12639 @example
12640 mulu64  @var{a}, @var{b}
12641 @end example
12642 @end deftypefn
12644 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12645 Generates:
12646 @example
12648 @end example
12649 @end deftypefn
12651 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12652 Only valid if the @samp{norm} instruction is available through the
12653 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12654 Generates:
12655 @example
12656 norm  @var{dest}, @var{src}
12657 @end example
12658 Where the value in @var{dest} will be the result returned from the
12659 built-in.
12660 @end deftypefn
12662 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12663 Only valid if the @samp{normw} instruction is available through the
12664 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12665 Generates:
12666 @example
12667 normw  @var{dest}, @var{src}
12668 @end example
12669 Where the value in @var{dest} will be the result returned from the
12670 built-in.
12671 @end deftypefn
12673 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12674 Generates:
12675 @example
12676 rtie
12677 @end example
12678 @end deftypefn
12680 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12681 Generates:
12682 @example
12683 sleep  @var{a}
12684 @end example
12685 @end deftypefn
12687 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12688 The first argument, @var{auxv}, is the address of an auxiliary
12689 register, the second argument, @var{val}, is a compile time constant
12690 to be written to the register.  Generates:
12691 @example
12692 sr  @var{auxr}, [@var{val}]
12693 @end example
12694 @end deftypefn
12696 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12697 Only valid with @option{-mswap}.  Generates:
12698 @example
12699 swap  @var{dest}, @var{src}
12700 @end example
12701 Where the value in @var{dest} will be the result returned from the
12702 built-in.
12703 @end deftypefn
12705 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12706 Generates:
12707 @example
12709 @end example
12710 @end deftypefn
12712 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12713 Only available with @option{-mcpu=ARC700}.  Generates:
12714 @example
12715 sync
12716 @end example
12717 @end deftypefn
12719 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12720 Only available with @option{-mcpu=ARC700}.  Generates:
12721 @example
12722 trap_s  @var{c}
12723 @end example
12724 @end deftypefn
12726 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12727 Only available with @option{-mcpu=ARC700}.  Generates:
12728 @example
12729 unimp_s
12730 @end example
12731 @end deftypefn
12733 The instructions generated by the following builtins are not
12734 considered as candidates for scheduling.  They are not moved around by
12735 the compiler during scheduling, and thus can be expected to appear
12736 where they are put in the C code:
12737 @example
12738 __builtin_arc_brk()
12739 __builtin_arc_core_read()
12740 __builtin_arc_core_write()
12741 __builtin_arc_flag()
12742 __builtin_arc_lr()
12743 __builtin_arc_sleep()
12744 __builtin_arc_sr()
12745 __builtin_arc_swi()
12746 @end example
12748 @node ARC SIMD Built-in Functions
12749 @subsection ARC SIMD Built-in Functions
12751 SIMD builtins provided by the compiler can be used to generate the
12752 vector instructions.  This section describes the available builtins
12753 and their usage in programs.  With the @option{-msimd} option, the
12754 compiler provides 128-bit vector types, which can be specified using
12755 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12756 can be included to use the following predefined types:
12757 @example
12758 typedef int __v4si   __attribute__((vector_size(16)));
12759 typedef short __v8hi __attribute__((vector_size(16)));
12760 @end example
12762 These types can be used to define 128-bit variables.  The built-in
12763 functions listed in the following section can be used on these
12764 variables to generate the vector operations.
12766 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12767 @file{arc-simd.h} also provides equivalent macros called
12768 @code{_@var{someinsn}} that can be used for programming ease and
12769 improved readability.  The following macros for DMA control are also
12770 provided:
12771 @example
12772 #define _setup_dma_in_channel_reg _vdiwr
12773 #define _setup_dma_out_channel_reg _vdowr
12774 @end example
12776 The following is a complete list of all the SIMD built-ins provided
12777 for ARC, grouped by calling signature.
12779 The following take two @code{__v8hi} arguments and return a
12780 @code{__v8hi} result:
12781 @example
12782 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12783 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12784 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12785 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12786 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12787 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12788 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12789 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12790 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12791 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12792 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12793 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12794 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12795 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12796 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12797 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12798 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12799 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12800 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12801 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12802 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12803 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12804 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12805 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12806 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12807 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12808 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12809 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12810 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12811 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12812 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12813 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12814 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12815 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12816 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12817 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12818 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12819 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12820 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12821 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12822 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12823 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12824 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12825 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12826 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12827 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12828 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12829 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12830 @end example
12832 The following take one @code{__v8hi} and one @code{int} argument and return a
12833 @code{__v8hi} result:
12835 @example
12836 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12837 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12838 __v8hi __builtin_arc_vbminw (__v8hi, int)
12839 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12840 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12841 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12842 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12843 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12844 @end example
12846 The following take one @code{__v8hi} argument and one @code{int} argument which
12847 must be a 3-bit compile time constant indicating a register number
12848 I0-I7.  They return a @code{__v8hi} result.
12849 @example
12850 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12851 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12852 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12853 @end example
12855 The following take one @code{__v8hi} argument and one @code{int}
12856 argument which must be a 6-bit compile time constant.  They return a
12857 @code{__v8hi} result.
12858 @example
12859 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12860 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12861 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12862 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12863 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12864 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12865 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12866 @end example
12868 The following take one @code{__v8hi} argument and one @code{int} argument which
12869 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12870 result.
12871 @example
12872 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12873 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12874 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12875 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12876 @end example
12878 The following take two @code{int} arguments, the second of which which
12879 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12880 result:
12881 @example
12882 __v8hi __builtin_arc_vmovaw (int, const int)
12883 __v8hi __builtin_arc_vmovw (int, const int)
12884 __v8hi __builtin_arc_vmovzw (int, const int)
12885 @end example
12887 The following take a single @code{__v8hi} argument and return a
12888 @code{__v8hi} result:
12889 @example
12890 __v8hi __builtin_arc_vabsaw (__v8hi)
12891 __v8hi __builtin_arc_vabsw (__v8hi)
12892 __v8hi __builtin_arc_vaddsuw (__v8hi)
12893 __v8hi __builtin_arc_vexch1 (__v8hi)
12894 __v8hi __builtin_arc_vexch2 (__v8hi)
12895 __v8hi __builtin_arc_vexch4 (__v8hi)
12896 __v8hi __builtin_arc_vsignw (__v8hi)
12897 __v8hi __builtin_arc_vupbaw (__v8hi)
12898 __v8hi __builtin_arc_vupbw (__v8hi)
12899 __v8hi __builtin_arc_vupsbaw (__v8hi)
12900 __v8hi __builtin_arc_vupsbw (__v8hi)
12901 @end example
12903 The following take two @code{int} arguments and return no result:
12904 @example
12905 void __builtin_arc_vdirun (int, int)
12906 void __builtin_arc_vdorun (int, int)
12907 @end example
12909 The following take two @code{int} arguments and return no result.  The
12910 first argument must a 3-bit compile time constant indicating one of
12911 the DR0-DR7 DMA setup channels:
12912 @example
12913 void __builtin_arc_vdiwr (const int, int)
12914 void __builtin_arc_vdowr (const int, int)
12915 @end example
12917 The following take an @code{int} argument and return no result:
12918 @example
12919 void __builtin_arc_vendrec (int)
12920 void __builtin_arc_vrec (int)
12921 void __builtin_arc_vrecrun (int)
12922 void __builtin_arc_vrun (int)
12923 @end example
12925 The following take a @code{__v8hi} argument and two @code{int}
12926 arguments and return a @code{__v8hi} result.  The second argument must
12927 be a 3-bit compile time constants, indicating one the registers I0-I7,
12928 and the third argument must be an 8-bit compile time constant.
12930 @emph{Note:} Although the equivalent hardware instructions do not take
12931 an SIMD register as an operand, these builtins overwrite the relevant
12932 bits of the @code{__v8hi} register provided as the first argument with
12933 the value loaded from the @code{[Ib, u8]} location in the SDM.
12935 @example
12936 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12937 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12938 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12939 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12940 @end example
12942 The following take two @code{int} arguments and return a @code{__v8hi}
12943 result.  The first argument must be a 3-bit compile time constants,
12944 indicating one the registers I0-I7, and the second argument must be an
12945 8-bit compile time constant.
12947 @example
12948 __v8hi __builtin_arc_vld128 (const int, const int)
12949 __v8hi __builtin_arc_vld64w (const int, const int)
12950 @end example
12952 The following take a @code{__v8hi} argument and two @code{int}
12953 arguments and return no result.  The second argument must be a 3-bit
12954 compile time constants, indicating one the registers I0-I7, and the
12955 third argument must be an 8-bit compile time constant.
12957 @example
12958 void __builtin_arc_vst128 (__v8hi, const int, const int)
12959 void __builtin_arc_vst64 (__v8hi, const int, const int)
12960 @end example
12962 The following take a @code{__v8hi} argument and three @code{int}
12963 arguments and return no result.  The second argument must be a 3-bit
12964 compile-time constant, identifying the 16-bit sub-register to be
12965 stored, the third argument must be a 3-bit compile time constants,
12966 indicating one the registers I0-I7, and the fourth argument must be an
12967 8-bit compile time constant.
12969 @example
12970 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12971 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12972 @end example
12974 @node ARM iWMMXt Built-in Functions
12975 @subsection ARM iWMMXt Built-in Functions
12977 These built-in functions are available for the ARM family of
12978 processors when the @option{-mcpu=iwmmxt} switch is used:
12980 @smallexample
12981 typedef int v2si __attribute__ ((vector_size (8)));
12982 typedef short v4hi __attribute__ ((vector_size (8)));
12983 typedef char v8qi __attribute__ ((vector_size (8)));
12985 int __builtin_arm_getwcgr0 (void)
12986 void __builtin_arm_setwcgr0 (int)
12987 int __builtin_arm_getwcgr1 (void)
12988 void __builtin_arm_setwcgr1 (int)
12989 int __builtin_arm_getwcgr2 (void)
12990 void __builtin_arm_setwcgr2 (int)
12991 int __builtin_arm_getwcgr3 (void)
12992 void __builtin_arm_setwcgr3 (int)
12993 int __builtin_arm_textrmsb (v8qi, int)
12994 int __builtin_arm_textrmsh (v4hi, int)
12995 int __builtin_arm_textrmsw (v2si, int)
12996 int __builtin_arm_textrmub (v8qi, int)
12997 int __builtin_arm_textrmuh (v4hi, int)
12998 int __builtin_arm_textrmuw (v2si, int)
12999 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13000 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13001 v2si __builtin_arm_tinsrw (v2si, int, int)
13002 long long __builtin_arm_tmia (long long, int, int)
13003 long long __builtin_arm_tmiabb (long long, int, int)
13004 long long __builtin_arm_tmiabt (long long, int, int)
13005 long long __builtin_arm_tmiaph (long long, int, int)
13006 long long __builtin_arm_tmiatb (long long, int, int)
13007 long long __builtin_arm_tmiatt (long long, int, int)
13008 int __builtin_arm_tmovmskb (v8qi)
13009 int __builtin_arm_tmovmskh (v4hi)
13010 int __builtin_arm_tmovmskw (v2si)
13011 long long __builtin_arm_waccb (v8qi)
13012 long long __builtin_arm_wacch (v4hi)
13013 long long __builtin_arm_waccw (v2si)
13014 v8qi __builtin_arm_waddb (v8qi, v8qi)
13015 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13016 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13017 v4hi __builtin_arm_waddh (v4hi, v4hi)
13018 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13019 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13020 v2si __builtin_arm_waddw (v2si, v2si)
13021 v2si __builtin_arm_waddwss (v2si, v2si)
13022 v2si __builtin_arm_waddwus (v2si, v2si)
13023 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13024 long long __builtin_arm_wand(long long, long long)
13025 long long __builtin_arm_wandn (long long, long long)
13026 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13027 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13028 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13029 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13030 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13031 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13032 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13033 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13034 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13035 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13036 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13037 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13038 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13039 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13040 long long __builtin_arm_wmacsz (v4hi, v4hi)
13041 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13042 long long __builtin_arm_wmacuz (v4hi, v4hi)
13043 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13044 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13045 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13046 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13047 v2si __builtin_arm_wmaxsw (v2si, v2si)
13048 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13049 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13050 v2si __builtin_arm_wmaxuw (v2si, v2si)
13051 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13052 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13053 v2si __builtin_arm_wminsw (v2si, v2si)
13054 v8qi __builtin_arm_wminub (v8qi, v8qi)
13055 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13056 v2si __builtin_arm_wminuw (v2si, v2si)
13057 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13058 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13059 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13060 long long __builtin_arm_wor (long long, long long)
13061 v2si __builtin_arm_wpackdss (long long, long long)
13062 v2si __builtin_arm_wpackdus (long long, long long)
13063 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13064 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13065 v4hi __builtin_arm_wpackwss (v2si, v2si)
13066 v4hi __builtin_arm_wpackwus (v2si, v2si)
13067 long long __builtin_arm_wrord (long long, long long)
13068 long long __builtin_arm_wrordi (long long, int)
13069 v4hi __builtin_arm_wrorh (v4hi, long long)
13070 v4hi __builtin_arm_wrorhi (v4hi, int)
13071 v2si __builtin_arm_wrorw (v2si, long long)
13072 v2si __builtin_arm_wrorwi (v2si, int)
13073 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13074 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13075 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13076 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13077 v4hi __builtin_arm_wshufh (v4hi, int)
13078 long long __builtin_arm_wslld (long long, long long)
13079 long long __builtin_arm_wslldi (long long, int)
13080 v4hi __builtin_arm_wsllh (v4hi, long long)
13081 v4hi __builtin_arm_wsllhi (v4hi, int)
13082 v2si __builtin_arm_wsllw (v2si, long long)
13083 v2si __builtin_arm_wsllwi (v2si, int)
13084 long long __builtin_arm_wsrad (long long, long long)
13085 long long __builtin_arm_wsradi (long long, int)
13086 v4hi __builtin_arm_wsrah (v4hi, long long)
13087 v4hi __builtin_arm_wsrahi (v4hi, int)
13088 v2si __builtin_arm_wsraw (v2si, long long)
13089 v2si __builtin_arm_wsrawi (v2si, int)
13090 long long __builtin_arm_wsrld (long long, long long)
13091 long long __builtin_arm_wsrldi (long long, int)
13092 v4hi __builtin_arm_wsrlh (v4hi, long long)
13093 v4hi __builtin_arm_wsrlhi (v4hi, int)
13094 v2si __builtin_arm_wsrlw (v2si, long long)
13095 v2si __builtin_arm_wsrlwi (v2si, int)
13096 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13097 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13098 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13099 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13100 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13101 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13102 v2si __builtin_arm_wsubw (v2si, v2si)
13103 v2si __builtin_arm_wsubwss (v2si, v2si)
13104 v2si __builtin_arm_wsubwus (v2si, v2si)
13105 v4hi __builtin_arm_wunpckehsb (v8qi)
13106 v2si __builtin_arm_wunpckehsh (v4hi)
13107 long long __builtin_arm_wunpckehsw (v2si)
13108 v4hi __builtin_arm_wunpckehub (v8qi)
13109 v2si __builtin_arm_wunpckehuh (v4hi)
13110 long long __builtin_arm_wunpckehuw (v2si)
13111 v4hi __builtin_arm_wunpckelsb (v8qi)
13112 v2si __builtin_arm_wunpckelsh (v4hi)
13113 long long __builtin_arm_wunpckelsw (v2si)
13114 v4hi __builtin_arm_wunpckelub (v8qi)
13115 v2si __builtin_arm_wunpckeluh (v4hi)
13116 long long __builtin_arm_wunpckeluw (v2si)
13117 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13118 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13119 v2si __builtin_arm_wunpckihw (v2si, v2si)
13120 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13121 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13122 v2si __builtin_arm_wunpckilw (v2si, v2si)
13123 long long __builtin_arm_wxor (long long, long long)
13124 long long __builtin_arm_wzero ()
13125 @end smallexample
13128 @node ARM C Language Extensions (ACLE)
13129 @subsection ARM C Language Extensions (ACLE)
13131 GCC implements extensions for C as described in the ARM C Language
13132 Extensions (ACLE) specification, which can be found at
13133 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13135 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13136 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13137 intrinsics can be found at
13138 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13139 The built-in intrinsics for the Advanced SIMD extension are available when
13140 NEON is enabled.
13142 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13143 back ends support CRC32 intrinsics and the ARM back end supports the
13144 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13145 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13146 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13147 intrinsics yet.
13149 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13150 availability of extensions.
13152 @node ARM Floating Point Status and Control Intrinsics
13153 @subsection ARM Floating Point Status and Control Intrinsics
13155 These built-in functions are available for the ARM family of
13156 processors with floating-point unit.
13158 @smallexample
13159 unsigned int __builtin_arm_get_fpscr ()
13160 void __builtin_arm_set_fpscr (unsigned int)
13161 @end smallexample
13163 @node ARM ARMv8-M Security Extensions
13164 @subsection ARM ARMv8-M Security Extensions
13166 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13167 Security Extensions: Requirements on Development Tools Engineering
13168 Specification, which can be found at
13169 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13171 As part of the Security Extensions GCC implements two new function attributes:
13172 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13174 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13175 is used here to mean any function pointer type.
13177 @smallexample
13178 cmse_address_info_t cmse_TT (void *)
13179 cmse_address_info_t cmse_TT_fptr (FPTR)
13180 cmse_address_info_t cmse_TTT (void *)
13181 cmse_address_info_t cmse_TTT_fptr (FPTR)
13182 cmse_address_info_t cmse_TTA (void *)
13183 cmse_address_info_t cmse_TTA_fptr (FPTR)
13184 cmse_address_info_t cmse_TTAT (void *)
13185 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13186 void * cmse_check_address_range (void *, size_t, int)
13187 typeof(p) cmse_nsfptr_create (FPTR p)
13188 intptr_t cmse_is_nsfptr (FPTR)
13189 int cmse_nonsecure_caller (void)
13190 @end smallexample
13192 @node AVR Built-in Functions
13193 @subsection AVR Built-in Functions
13195 For each built-in function for AVR, there is an equally named,
13196 uppercase built-in macro defined. That way users can easily query if
13197 or if not a specific built-in is implemented or not. For example, if
13198 @code{__builtin_avr_nop} is available the macro
13199 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13201 @table @code
13203 @item void __builtin_avr_nop (void)
13204 @itemx void __builtin_avr_sei (void)
13205 @itemx void __builtin_avr_cli (void)
13206 @itemx void __builtin_avr_sleep (void)
13207 @itemx void __builtin_avr_wdr (void)
13208 @itemx unsigned char __builtin_avr_swap (unsigned char)
13209 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13210 @itemx int __builtin_avr_fmuls (char, char)
13211 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13212 These built-in functions map to the respective machine
13213 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13214 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13215 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13216 as library call if no hardware multiplier is available.
13218 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13219 Delay execution for @var{ticks} cycles. Note that this
13220 built-in does not take into account the effect of interrupts that
13221 might increase delay time. @var{ticks} must be a compile-time
13222 integer constant; delays with a variable number of cycles are not supported.
13224 @item char __builtin_avr_flash_segment (const __memx void*)
13225 This built-in takes a byte address to the 24-bit
13226 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13227 the number of the flash segment (the 64 KiB chunk) where the address
13228 points to.  Counting starts at @code{0}.
13229 If the address does not point to flash memory, return @code{-1}.
13231 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13232 Insert bits from @var{bits} into @var{val} and return the resulting
13233 value. The nibbles of @var{map} determine how the insertion is
13234 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13235 @enumerate
13236 @item If @var{X} is @code{0xf},
13237 then the @var{n}-th bit of @var{val} is returned unaltered.
13239 @item If X is in the range 0@dots{}7,
13240 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13242 @item If X is in the range 8@dots{}@code{0xe},
13243 then the @var{n}-th result bit is undefined.
13244 @end enumerate
13246 @noindent
13247 One typical use case for this built-in is adjusting input and
13248 output values to non-contiguous port layouts. Some examples:
13250 @smallexample
13251 // same as val, bits is unused
13252 __builtin_avr_insert_bits (0xffffffff, bits, val)
13253 @end smallexample
13255 @smallexample
13256 // same as bits, val is unused
13257 __builtin_avr_insert_bits (0x76543210, bits, val)
13258 @end smallexample
13260 @smallexample
13261 // same as rotating bits by 4
13262 __builtin_avr_insert_bits (0x32107654, bits, 0)
13263 @end smallexample
13265 @smallexample
13266 // high nibble of result is the high nibble of val
13267 // low nibble of result is the low nibble of bits
13268 __builtin_avr_insert_bits (0xffff3210, bits, val)
13269 @end smallexample
13271 @smallexample
13272 // reverse the bit order of bits
13273 __builtin_avr_insert_bits (0x01234567, bits, 0)
13274 @end smallexample
13276 @item void __builtin_avr_nops (unsigned count)
13277 Insert @var{count} @code{NOP} instructions.
13278 The number of instructions must be a compile-time integer constant.
13280 @end table
13282 @noindent
13283 There are many more AVR-specific built-in functions that are used to
13284 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13285 section 7.18a.6.  You don't need to use these built-ins directly.
13286 Instead, use the declarations as supplied by the @code{stdfix.h} header
13287 with GNU-C99:
13289 @smallexample
13290 #include <stdfix.h>
13292 // Re-interpret the bit representation of unsigned 16-bit
13293 // integer @var{uval} as Q-format 0.16 value.
13294 unsigned fract get_bits (uint_ur_t uval)
13296     return urbits (uval);
13298 @end smallexample
13300 @node Blackfin Built-in Functions
13301 @subsection Blackfin Built-in Functions
13303 Currently, there are two Blackfin-specific built-in functions.  These are
13304 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13305 using inline assembly; by using these built-in functions the compiler can
13306 automatically add workarounds for hardware errata involving these
13307 instructions.  These functions are named as follows:
13309 @smallexample
13310 void __builtin_bfin_csync (void)
13311 void __builtin_bfin_ssync (void)
13312 @end smallexample
13314 @node FR-V Built-in Functions
13315 @subsection FR-V Built-in Functions
13317 GCC provides many FR-V-specific built-in functions.  In general,
13318 these functions are intended to be compatible with those described
13319 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13320 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13321 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13322 pointer rather than by value.
13324 Most of the functions are named after specific FR-V instructions.
13325 Such functions are said to be ``directly mapped'' and are summarized
13326 here in tabular form.
13328 @menu
13329 * Argument Types::
13330 * Directly-mapped Integer Functions::
13331 * Directly-mapped Media Functions::
13332 * Raw read/write Functions::
13333 * Other Built-in Functions::
13334 @end menu
13336 @node Argument Types
13337 @subsubsection Argument Types
13339 The arguments to the built-in functions can be divided into three groups:
13340 register numbers, compile-time constants and run-time values.  In order
13341 to make this classification clear at a glance, the arguments and return
13342 values are given the following pseudo types:
13344 @multitable @columnfractions .20 .30 .15 .35
13345 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13346 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13347 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13348 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13349 @item @code{uw2} @tab @code{unsigned long long} @tab No
13350 @tab an unsigned doubleword
13351 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13352 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13353 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13354 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13355 @end multitable
13357 These pseudo types are not defined by GCC, they are simply a notational
13358 convenience used in this manual.
13360 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13361 and @code{sw2} are evaluated at run time.  They correspond to
13362 register operands in the underlying FR-V instructions.
13364 @code{const} arguments represent immediate operands in the underlying
13365 FR-V instructions.  They must be compile-time constants.
13367 @code{acc} arguments are evaluated at compile time and specify the number
13368 of an accumulator register.  For example, an @code{acc} argument of 2
13369 selects the ACC2 register.
13371 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13372 number of an IACC register.  See @pxref{Other Built-in Functions}
13373 for more details.
13375 @node Directly-mapped Integer Functions
13376 @subsubsection Directly-Mapped Integer Functions
13378 The functions listed below map directly to FR-V I-type instructions.
13380 @multitable @columnfractions .45 .32 .23
13381 @item Function prototype @tab Example usage @tab Assembly output
13382 @item @code{sw1 __ADDSS (sw1, sw1)}
13383 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13384 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13385 @item @code{sw1 __SCAN (sw1, sw1)}
13386 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13387 @tab @code{SCAN @var{a},@var{b},@var{c}}
13388 @item @code{sw1 __SCUTSS (sw1)}
13389 @tab @code{@var{b} = __SCUTSS (@var{a})}
13390 @tab @code{SCUTSS @var{a},@var{b}}
13391 @item @code{sw1 __SLASS (sw1, sw1)}
13392 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13393 @tab @code{SLASS @var{a},@var{b},@var{c}}
13394 @item @code{void __SMASS (sw1, sw1)}
13395 @tab @code{__SMASS (@var{a}, @var{b})}
13396 @tab @code{SMASS @var{a},@var{b}}
13397 @item @code{void __SMSSS (sw1, sw1)}
13398 @tab @code{__SMSSS (@var{a}, @var{b})}
13399 @tab @code{SMSSS @var{a},@var{b}}
13400 @item @code{void __SMU (sw1, sw1)}
13401 @tab @code{__SMU (@var{a}, @var{b})}
13402 @tab @code{SMU @var{a},@var{b}}
13403 @item @code{sw2 __SMUL (sw1, sw1)}
13404 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13405 @tab @code{SMUL @var{a},@var{b},@var{c}}
13406 @item @code{sw1 __SUBSS (sw1, sw1)}
13407 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13408 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13409 @item @code{uw2 __UMUL (uw1, uw1)}
13410 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13411 @tab @code{UMUL @var{a},@var{b},@var{c}}
13412 @end multitable
13414 @node Directly-mapped Media Functions
13415 @subsubsection Directly-Mapped Media Functions
13417 The functions listed below map directly to FR-V M-type instructions.
13419 @multitable @columnfractions .45 .32 .23
13420 @item Function prototype @tab Example usage @tab Assembly output
13421 @item @code{uw1 __MABSHS (sw1)}
13422 @tab @code{@var{b} = __MABSHS (@var{a})}
13423 @tab @code{MABSHS @var{a},@var{b}}
13424 @item @code{void __MADDACCS (acc, acc)}
13425 @tab @code{__MADDACCS (@var{b}, @var{a})}
13426 @tab @code{MADDACCS @var{a},@var{b}}
13427 @item @code{sw1 __MADDHSS (sw1, sw1)}
13428 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13429 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13430 @item @code{uw1 __MADDHUS (uw1, uw1)}
13431 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13432 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13433 @item @code{uw1 __MAND (uw1, uw1)}
13434 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13435 @tab @code{MAND @var{a},@var{b},@var{c}}
13436 @item @code{void __MASACCS (acc, acc)}
13437 @tab @code{__MASACCS (@var{b}, @var{a})}
13438 @tab @code{MASACCS @var{a},@var{b}}
13439 @item @code{uw1 __MAVEH (uw1, uw1)}
13440 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13441 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13442 @item @code{uw2 __MBTOH (uw1)}
13443 @tab @code{@var{b} = __MBTOH (@var{a})}
13444 @tab @code{MBTOH @var{a},@var{b}}
13445 @item @code{void __MBTOHE (uw1 *, uw1)}
13446 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13447 @tab @code{MBTOHE @var{a},@var{b}}
13448 @item @code{void __MCLRACC (acc)}
13449 @tab @code{__MCLRACC (@var{a})}
13450 @tab @code{MCLRACC @var{a}}
13451 @item @code{void __MCLRACCA (void)}
13452 @tab @code{__MCLRACCA ()}
13453 @tab @code{MCLRACCA}
13454 @item @code{uw1 __Mcop1 (uw1, uw1)}
13455 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13456 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13457 @item @code{uw1 __Mcop2 (uw1, uw1)}
13458 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13459 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13460 @item @code{uw1 __MCPLHI (uw2, const)}
13461 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13462 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13463 @item @code{uw1 __MCPLI (uw2, const)}
13464 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13465 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13466 @item @code{void __MCPXIS (acc, sw1, sw1)}
13467 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13468 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13469 @item @code{void __MCPXIU (acc, uw1, uw1)}
13470 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13471 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13472 @item @code{void __MCPXRS (acc, sw1, sw1)}
13473 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13474 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13475 @item @code{void __MCPXRU (acc, uw1, uw1)}
13476 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13477 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13478 @item @code{uw1 __MCUT (acc, uw1)}
13479 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13480 @tab @code{MCUT @var{a},@var{b},@var{c}}
13481 @item @code{uw1 __MCUTSS (acc, sw1)}
13482 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13483 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13484 @item @code{void __MDADDACCS (acc, acc)}
13485 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13486 @tab @code{MDADDACCS @var{a},@var{b}}
13487 @item @code{void __MDASACCS (acc, acc)}
13488 @tab @code{__MDASACCS (@var{b}, @var{a})}
13489 @tab @code{MDASACCS @var{a},@var{b}}
13490 @item @code{uw2 __MDCUTSSI (acc, const)}
13491 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13492 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13493 @item @code{uw2 __MDPACKH (uw2, uw2)}
13494 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13495 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13496 @item @code{uw2 __MDROTLI (uw2, const)}
13497 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13498 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13499 @item @code{void __MDSUBACCS (acc, acc)}
13500 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13501 @tab @code{MDSUBACCS @var{a},@var{b}}
13502 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13503 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13504 @tab @code{MDUNPACKH @var{a},@var{b}}
13505 @item @code{uw2 __MEXPDHD (uw1, const)}
13506 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13507 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13508 @item @code{uw1 __MEXPDHW (uw1, const)}
13509 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13510 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13511 @item @code{uw1 __MHDSETH (uw1, const)}
13512 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13513 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13514 @item @code{sw1 __MHDSETS (const)}
13515 @tab @code{@var{b} = __MHDSETS (@var{a})}
13516 @tab @code{MHDSETS #@var{a},@var{b}}
13517 @item @code{uw1 __MHSETHIH (uw1, const)}
13518 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13519 @tab @code{MHSETHIH #@var{a},@var{b}}
13520 @item @code{sw1 __MHSETHIS (sw1, const)}
13521 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13522 @tab @code{MHSETHIS #@var{a},@var{b}}
13523 @item @code{uw1 __MHSETLOH (uw1, const)}
13524 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13525 @tab @code{MHSETLOH #@var{a},@var{b}}
13526 @item @code{sw1 __MHSETLOS (sw1, const)}
13527 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13528 @tab @code{MHSETLOS #@var{a},@var{b}}
13529 @item @code{uw1 __MHTOB (uw2)}
13530 @tab @code{@var{b} = __MHTOB (@var{a})}
13531 @tab @code{MHTOB @var{a},@var{b}}
13532 @item @code{void __MMACHS (acc, sw1, sw1)}
13533 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13534 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13535 @item @code{void __MMACHU (acc, uw1, uw1)}
13536 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13537 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13538 @item @code{void __MMRDHS (acc, sw1, sw1)}
13539 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13540 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13541 @item @code{void __MMRDHU (acc, uw1, uw1)}
13542 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13543 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13544 @item @code{void __MMULHS (acc, sw1, sw1)}
13545 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13546 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13547 @item @code{void __MMULHU (acc, uw1, uw1)}
13548 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13549 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13550 @item @code{void __MMULXHS (acc, sw1, sw1)}
13551 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13552 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13553 @item @code{void __MMULXHU (acc, uw1, uw1)}
13554 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13555 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13556 @item @code{uw1 __MNOT (uw1)}
13557 @tab @code{@var{b} = __MNOT (@var{a})}
13558 @tab @code{MNOT @var{a},@var{b}}
13559 @item @code{uw1 __MOR (uw1, uw1)}
13560 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13561 @tab @code{MOR @var{a},@var{b},@var{c}}
13562 @item @code{uw1 __MPACKH (uh, uh)}
13563 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13564 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13565 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13566 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13567 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13568 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13569 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13570 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13571 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13572 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13573 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13574 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13575 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13576 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13577 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13578 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13579 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13580 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13581 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13582 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13583 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13584 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13585 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13586 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13587 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13588 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13589 @item @code{void __MQMACHS (acc, sw2, sw2)}
13590 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13591 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13592 @item @code{void __MQMACHU (acc, uw2, uw2)}
13593 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13594 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13595 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13596 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13597 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13598 @item @code{void __MQMULHS (acc, sw2, sw2)}
13599 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13600 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13601 @item @code{void __MQMULHU (acc, uw2, uw2)}
13602 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13603 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13604 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13605 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13606 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13607 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13608 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13609 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13610 @item @code{sw2 __MQSATHS (sw2, sw2)}
13611 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13612 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13613 @item @code{uw2 __MQSLLHI (uw2, int)}
13614 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13615 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13616 @item @code{sw2 __MQSRAHI (sw2, int)}
13617 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13618 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13619 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13620 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13621 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13622 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13623 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13624 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13625 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13626 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13627 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13628 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13629 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13630 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13631 @item @code{uw1 __MRDACC (acc)}
13632 @tab @code{@var{b} = __MRDACC (@var{a})}
13633 @tab @code{MRDACC @var{a},@var{b}}
13634 @item @code{uw1 __MRDACCG (acc)}
13635 @tab @code{@var{b} = __MRDACCG (@var{a})}
13636 @tab @code{MRDACCG @var{a},@var{b}}
13637 @item @code{uw1 __MROTLI (uw1, const)}
13638 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13639 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13640 @item @code{uw1 __MROTRI (uw1, const)}
13641 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13642 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13643 @item @code{sw1 __MSATHS (sw1, sw1)}
13644 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13645 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13646 @item @code{uw1 __MSATHU (uw1, uw1)}
13647 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13648 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13649 @item @code{uw1 __MSLLHI (uw1, const)}
13650 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13651 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13652 @item @code{sw1 __MSRAHI (sw1, const)}
13653 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13654 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13655 @item @code{uw1 __MSRLHI (uw1, const)}
13656 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13657 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13658 @item @code{void __MSUBACCS (acc, acc)}
13659 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13660 @tab @code{MSUBACCS @var{a},@var{b}}
13661 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13662 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13663 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13664 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13665 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13666 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13667 @item @code{void __MTRAP (void)}
13668 @tab @code{__MTRAP ()}
13669 @tab @code{MTRAP}
13670 @item @code{uw2 __MUNPACKH (uw1)}
13671 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13672 @tab @code{MUNPACKH @var{a},@var{b}}
13673 @item @code{uw1 __MWCUT (uw2, uw1)}
13674 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13675 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13676 @item @code{void __MWTACC (acc, uw1)}
13677 @tab @code{__MWTACC (@var{b}, @var{a})}
13678 @tab @code{MWTACC @var{a},@var{b}}
13679 @item @code{void __MWTACCG (acc, uw1)}
13680 @tab @code{__MWTACCG (@var{b}, @var{a})}
13681 @tab @code{MWTACCG @var{a},@var{b}}
13682 @item @code{uw1 __MXOR (uw1, uw1)}
13683 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13684 @tab @code{MXOR @var{a},@var{b},@var{c}}
13685 @end multitable
13687 @node Raw read/write Functions
13688 @subsubsection Raw Read/Write Functions
13690 This sections describes built-in functions related to read and write
13691 instructions to access memory.  These functions generate
13692 @code{membar} instructions to flush the I/O load and stores where
13693 appropriate, as described in Fujitsu's manual described above.
13695 @table @code
13697 @item unsigned char __builtin_read8 (void *@var{data})
13698 @item unsigned short __builtin_read16 (void *@var{data})
13699 @item unsigned long __builtin_read32 (void *@var{data})
13700 @item unsigned long long __builtin_read64 (void *@var{data})
13702 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13703 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13704 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13705 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13706 @end table
13708 @node Other Built-in Functions
13709 @subsubsection Other Built-in Functions
13711 This section describes built-in functions that are not named after
13712 a specific FR-V instruction.
13714 @table @code
13715 @item sw2 __IACCreadll (iacc @var{reg})
13716 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13717 for future expansion and must be 0.
13719 @item sw1 __IACCreadl (iacc @var{reg})
13720 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13721 Other values of @var{reg} are rejected as invalid.
13723 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13724 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13725 is reserved for future expansion and must be 0.
13727 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13728 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13729 is 1.  Other values of @var{reg} are rejected as invalid.
13731 @item void __data_prefetch0 (const void *@var{x})
13732 Use the @code{dcpl} instruction to load the contents of address @var{x}
13733 into the data cache.
13735 @item void __data_prefetch (const void *@var{x})
13736 Use the @code{nldub} instruction to load the contents of address @var{x}
13737 into the data cache.  The instruction is issued in slot I1@.
13738 @end table
13740 @node MIPS DSP Built-in Functions
13741 @subsection MIPS DSP Built-in Functions
13743 The MIPS DSP Application-Specific Extension (ASE) includes new
13744 instructions that are designed to improve the performance of DSP and
13745 media applications.  It provides instructions that operate on packed
13746 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13748 GCC supports MIPS DSP operations using both the generic
13749 vector extensions (@pxref{Vector Extensions}) and a collection of
13750 MIPS-specific built-in functions.  Both kinds of support are
13751 enabled by the @option{-mdsp} command-line option.
13753 Revision 2 of the ASE was introduced in the second half of 2006.
13754 This revision adds extra instructions to the original ASE, but is
13755 otherwise backwards-compatible with it.  You can select revision 2
13756 using the command-line option @option{-mdspr2}; this option implies
13757 @option{-mdsp}.
13759 The SCOUNT and POS bits of the DSP control register are global.  The
13760 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13761 POS bits.  During optimization, the compiler does not delete these
13762 instructions and it does not delete calls to functions containing
13763 these instructions.
13765 At present, GCC only provides support for operations on 32-bit
13766 vectors.  The vector type associated with 8-bit integer data is
13767 usually called @code{v4i8}, the vector type associated with Q7
13768 is usually called @code{v4q7}, the vector type associated with 16-bit
13769 integer data is usually called @code{v2i16}, and the vector type
13770 associated with Q15 is usually called @code{v2q15}.  They can be
13771 defined in C as follows:
13773 @smallexample
13774 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13775 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13776 typedef short v2i16 __attribute__ ((vector_size(4)));
13777 typedef short v2q15 __attribute__ ((vector_size(4)));
13778 @end smallexample
13780 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13781 initialized in the same way as aggregates.  For example:
13783 @smallexample
13784 v4i8 a = @{1, 2, 3, 4@};
13785 v4i8 b;
13786 b = (v4i8) @{5, 6, 7, 8@};
13788 v2q15 c = @{0x0fcb, 0x3a75@};
13789 v2q15 d;
13790 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13791 @end smallexample
13793 @emph{Note:} The CPU's endianness determines the order in which values
13794 are packed.  On little-endian targets, the first value is the least
13795 significant and the last value is the most significant.  The opposite
13796 order applies to big-endian targets.  For example, the code above
13797 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13798 and @code{4} on big-endian targets.
13800 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13801 representation.  As shown in this example, the integer representation
13802 of a Q7 value can be obtained by multiplying the fractional value by
13803 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13804 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13805 @code{0x1.0p31}.
13807 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13808 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13809 and @code{c} and @code{d} are @code{v2q15} values.
13811 @multitable @columnfractions .50 .50
13812 @item C code @tab MIPS instruction
13813 @item @code{a + b} @tab @code{addu.qb}
13814 @item @code{c + d} @tab @code{addq.ph}
13815 @item @code{a - b} @tab @code{subu.qb}
13816 @item @code{c - d} @tab @code{subq.ph}
13817 @end multitable
13819 The table below lists the @code{v2i16} operation for which
13820 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13821 @code{v2i16} values.
13823 @multitable @columnfractions .50 .50
13824 @item C code @tab MIPS instruction
13825 @item @code{e * f} @tab @code{mul.ph}
13826 @end multitable
13828 It is easier to describe the DSP built-in functions if we first define
13829 the following types:
13831 @smallexample
13832 typedef int q31;
13833 typedef int i32;
13834 typedef unsigned int ui32;
13835 typedef long long a64;
13836 @end smallexample
13838 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13839 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13840 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13841 @code{long long}, but we use @code{a64} to indicate values that are
13842 placed in one of the four DSP accumulators (@code{$ac0},
13843 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13845 Also, some built-in functions prefer or require immediate numbers as
13846 parameters, because the corresponding DSP instructions accept both immediate
13847 numbers and register operands, or accept immediate numbers only.  The
13848 immediate parameters are listed as follows.
13850 @smallexample
13851 imm0_3: 0 to 3.
13852 imm0_7: 0 to 7.
13853 imm0_15: 0 to 15.
13854 imm0_31: 0 to 31.
13855 imm0_63: 0 to 63.
13856 imm0_255: 0 to 255.
13857 imm_n32_31: -32 to 31.
13858 imm_n512_511: -512 to 511.
13859 @end smallexample
13861 The following built-in functions map directly to a particular MIPS DSP
13862 instruction.  Please refer to the architecture specification
13863 for details on what each instruction does.
13865 @smallexample
13866 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13867 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13868 q31 __builtin_mips_addq_s_w (q31, q31)
13869 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13870 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13871 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13872 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13873 q31 __builtin_mips_subq_s_w (q31, q31)
13874 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13875 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13876 i32 __builtin_mips_addsc (i32, i32)
13877 i32 __builtin_mips_addwc (i32, i32)
13878 i32 __builtin_mips_modsub (i32, i32)
13879 i32 __builtin_mips_raddu_w_qb (v4i8)
13880 v2q15 __builtin_mips_absq_s_ph (v2q15)
13881 q31 __builtin_mips_absq_s_w (q31)
13882 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13883 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13884 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13885 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13886 q31 __builtin_mips_preceq_w_phl (v2q15)
13887 q31 __builtin_mips_preceq_w_phr (v2q15)
13888 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13889 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13890 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13891 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13892 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13893 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13894 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13895 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13896 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13897 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13898 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13899 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13900 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13901 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13902 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13903 q31 __builtin_mips_shll_s_w (q31, i32)
13904 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13905 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13906 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13907 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13908 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13909 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13910 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13911 q31 __builtin_mips_shra_r_w (q31, i32)
13912 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13913 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13914 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13915 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13916 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13917 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13918 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13919 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13920 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13921 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13922 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13923 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13924 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13925 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13926 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13927 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13928 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13929 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13930 i32 __builtin_mips_bitrev (i32)
13931 i32 __builtin_mips_insv (i32, i32)
13932 v4i8 __builtin_mips_repl_qb (imm0_255)
13933 v4i8 __builtin_mips_repl_qb (i32)
13934 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13935 v2q15 __builtin_mips_repl_ph (i32)
13936 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13937 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13938 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13939 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13940 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13941 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13942 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13943 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13944 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13945 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13946 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13947 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13948 i32 __builtin_mips_extr_w (a64, imm0_31)
13949 i32 __builtin_mips_extr_w (a64, i32)
13950 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13951 i32 __builtin_mips_extr_s_h (a64, i32)
13952 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13953 i32 __builtin_mips_extr_rs_w (a64, i32)
13954 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13955 i32 __builtin_mips_extr_r_w (a64, i32)
13956 i32 __builtin_mips_extp (a64, imm0_31)
13957 i32 __builtin_mips_extp (a64, i32)
13958 i32 __builtin_mips_extpdp (a64, imm0_31)
13959 i32 __builtin_mips_extpdp (a64, i32)
13960 a64 __builtin_mips_shilo (a64, imm_n32_31)
13961 a64 __builtin_mips_shilo (a64, i32)
13962 a64 __builtin_mips_mthlip (a64, i32)
13963 void __builtin_mips_wrdsp (i32, imm0_63)
13964 i32 __builtin_mips_rddsp (imm0_63)
13965 i32 __builtin_mips_lbux (void *, i32)
13966 i32 __builtin_mips_lhx (void *, i32)
13967 i32 __builtin_mips_lwx (void *, i32)
13968 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13969 i32 __builtin_mips_bposge32 (void)
13970 a64 __builtin_mips_madd (a64, i32, i32);
13971 a64 __builtin_mips_maddu (a64, ui32, ui32);
13972 a64 __builtin_mips_msub (a64, i32, i32);
13973 a64 __builtin_mips_msubu (a64, ui32, ui32);
13974 a64 __builtin_mips_mult (i32, i32);
13975 a64 __builtin_mips_multu (ui32, ui32);
13976 @end smallexample
13978 The following built-in functions map directly to a particular MIPS DSP REV 2
13979 instruction.  Please refer to the architecture specification
13980 for details on what each instruction does.
13982 @smallexample
13983 v4q7 __builtin_mips_absq_s_qb (v4q7);
13984 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13985 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13986 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13987 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13988 i32 __builtin_mips_append (i32, i32, imm0_31);
13989 i32 __builtin_mips_balign (i32, i32, imm0_3);
13990 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13991 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13992 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13993 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13994 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13995 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13996 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13997 q31 __builtin_mips_mulq_rs_w (q31, q31);
13998 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13999 q31 __builtin_mips_mulq_s_w (q31, q31);
14000 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14001 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14002 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14003 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14004 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14005 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14006 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14007 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14008 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14009 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14010 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14011 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14012 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14013 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14014 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14015 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14016 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14017 q31 __builtin_mips_addqh_w (q31, q31);
14018 q31 __builtin_mips_addqh_r_w (q31, q31);
14019 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14020 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14021 q31 __builtin_mips_subqh_w (q31, q31);
14022 q31 __builtin_mips_subqh_r_w (q31, q31);
14023 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14024 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14025 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14026 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14027 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14028 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14029 @end smallexample
14032 @node MIPS Paired-Single Support
14033 @subsection MIPS Paired-Single Support
14035 The MIPS64 architecture includes a number of instructions that
14036 operate on pairs of single-precision floating-point values.
14037 Each pair is packed into a 64-bit floating-point register,
14038 with one element being designated the ``upper half'' and
14039 the other being designated the ``lower half''.
14041 GCC supports paired-single operations using both the generic
14042 vector extensions (@pxref{Vector Extensions}) and a collection of
14043 MIPS-specific built-in functions.  Both kinds of support are
14044 enabled by the @option{-mpaired-single} command-line option.
14046 The vector type associated with paired-single values is usually
14047 called @code{v2sf}.  It can be defined in C as follows:
14049 @smallexample
14050 typedef float v2sf __attribute__ ((vector_size (8)));
14051 @end smallexample
14053 @code{v2sf} values are initialized in the same way as aggregates.
14054 For example:
14056 @smallexample
14057 v2sf a = @{1.5, 9.1@};
14058 v2sf b;
14059 float e, f;
14060 b = (v2sf) @{e, f@};
14061 @end smallexample
14063 @emph{Note:} The CPU's endianness determines which value is stored in
14064 the upper half of a register and which value is stored in the lower half.
14065 On little-endian targets, the first value is the lower one and the second
14066 value is the upper one.  The opposite order applies to big-endian targets.
14067 For example, the code above sets the lower half of @code{a} to
14068 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14070 @node MIPS Loongson Built-in Functions
14071 @subsection MIPS Loongson Built-in Functions
14073 GCC provides intrinsics to access the SIMD instructions provided by the
14074 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
14075 available after inclusion of the @code{loongson.h} header file,
14076 operate on the following 64-bit vector types:
14078 @itemize
14079 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14080 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14081 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14082 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14083 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14084 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14085 @end itemize
14087 The intrinsics provided are listed below; each is named after the
14088 machine instruction to which it corresponds, with suffixes added as
14089 appropriate to distinguish intrinsics that expand to the same machine
14090 instruction yet have different argument types.  Refer to the architecture
14091 documentation for a description of the functionality of each
14092 instruction.
14094 @smallexample
14095 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14096 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14097 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14098 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14099 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14100 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14101 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14102 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14103 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14104 uint64_t paddd_u (uint64_t s, uint64_t t);
14105 int64_t paddd_s (int64_t s, int64_t t);
14106 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14107 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14108 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14109 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14110 uint64_t pandn_ud (uint64_t s, uint64_t t);
14111 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14112 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14113 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14114 int64_t pandn_sd (int64_t s, int64_t t);
14115 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14116 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14117 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14118 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14119 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14120 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14121 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14122 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14123 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14124 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14125 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14126 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14127 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14128 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14129 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14130 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14131 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14132 uint16x4_t pextrh_u (uint16x4_t s, int field);
14133 int16x4_t pextrh_s (int16x4_t s, int field);
14134 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14135 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14136 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14137 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14138 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14139 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14140 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14141 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14142 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14143 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14144 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14145 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14146 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14147 uint8x8_t pmovmskb_u (uint8x8_t s);
14148 int8x8_t pmovmskb_s (int8x8_t s);
14149 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14150 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14151 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14152 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14153 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14154 uint16x4_t biadd (uint8x8_t s);
14155 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14156 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14157 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14158 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14159 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14160 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14161 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14162 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14163 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14164 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14165 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14166 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14167 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14168 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14169 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14170 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14171 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14172 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14173 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14174 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14175 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14176 uint64_t psubd_u (uint64_t s, uint64_t t);
14177 int64_t psubd_s (int64_t s, int64_t t);
14178 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14179 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14180 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14181 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14182 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14183 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14184 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14185 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14186 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14187 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14188 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14189 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14190 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14191 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14192 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14193 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14194 @end smallexample
14196 @menu
14197 * Paired-Single Arithmetic::
14198 * Paired-Single Built-in Functions::
14199 * MIPS-3D Built-in Functions::
14200 @end menu
14202 @node Paired-Single Arithmetic
14203 @subsubsection Paired-Single Arithmetic
14205 The table below lists the @code{v2sf} operations for which hardware
14206 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14207 values and @code{x} is an integral value.
14209 @multitable @columnfractions .50 .50
14210 @item C code @tab MIPS instruction
14211 @item @code{a + b} @tab @code{add.ps}
14212 @item @code{a - b} @tab @code{sub.ps}
14213 @item @code{-a} @tab @code{neg.ps}
14214 @item @code{a * b} @tab @code{mul.ps}
14215 @item @code{a * b + c} @tab @code{madd.ps}
14216 @item @code{a * b - c} @tab @code{msub.ps}
14217 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14218 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14219 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14220 @end multitable
14222 Note that the multiply-accumulate instructions can be disabled
14223 using the command-line option @code{-mno-fused-madd}.
14225 @node Paired-Single Built-in Functions
14226 @subsubsection Paired-Single Built-in Functions
14228 The following paired-single functions map directly to a particular
14229 MIPS instruction.  Please refer to the architecture specification
14230 for details on what each instruction does.
14232 @table @code
14233 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14234 Pair lower lower (@code{pll.ps}).
14236 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14237 Pair upper lower (@code{pul.ps}).
14239 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14240 Pair lower upper (@code{plu.ps}).
14242 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14243 Pair upper upper (@code{puu.ps}).
14245 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14246 Convert pair to paired single (@code{cvt.ps.s}).
14248 @item float __builtin_mips_cvt_s_pl (v2sf)
14249 Convert pair lower to single (@code{cvt.s.pl}).
14251 @item float __builtin_mips_cvt_s_pu (v2sf)
14252 Convert pair upper to single (@code{cvt.s.pu}).
14254 @item v2sf __builtin_mips_abs_ps (v2sf)
14255 Absolute value (@code{abs.ps}).
14257 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14258 Align variable (@code{alnv.ps}).
14260 @emph{Note:} The value of the third parameter must be 0 or 4
14261 modulo 8, otherwise the result is unpredictable.  Please read the
14262 instruction description for details.
14263 @end table
14265 The following multi-instruction functions are also available.
14266 In each case, @var{cond} can be any of the 16 floating-point conditions:
14267 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14268 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14269 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14271 @table @code
14272 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14273 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14274 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14275 @code{movt.ps}/@code{movf.ps}).
14277 The @code{movt} functions return the value @var{x} computed by:
14279 @smallexample
14280 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14281 mov.ps @var{x},@var{c}
14282 movt.ps @var{x},@var{d},@var{cc}
14283 @end smallexample
14285 The @code{movf} functions are similar but use @code{movf.ps} instead
14286 of @code{movt.ps}.
14288 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14289 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14290 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14291 @code{bc1t}/@code{bc1f}).
14293 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14294 and return either the upper or lower half of the result.  For example:
14296 @smallexample
14297 v2sf a, b;
14298 if (__builtin_mips_upper_c_eq_ps (a, b))
14299   upper_halves_are_equal ();
14300 else
14301   upper_halves_are_unequal ();
14303 if (__builtin_mips_lower_c_eq_ps (a, b))
14304   lower_halves_are_equal ();
14305 else
14306   lower_halves_are_unequal ();
14307 @end smallexample
14308 @end table
14310 @node MIPS-3D Built-in Functions
14311 @subsubsection MIPS-3D Built-in Functions
14313 The MIPS-3D Application-Specific Extension (ASE) includes additional
14314 paired-single instructions that are designed to improve the performance
14315 of 3D graphics operations.  Support for these instructions is controlled
14316 by the @option{-mips3d} command-line option.
14318 The functions listed below map directly to a particular MIPS-3D
14319 instruction.  Please refer to the architecture specification for
14320 more details on what each instruction does.
14322 @table @code
14323 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14324 Reduction add (@code{addr.ps}).
14326 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14327 Reduction multiply (@code{mulr.ps}).
14329 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14330 Convert paired single to paired word (@code{cvt.pw.ps}).
14332 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14333 Convert paired word to paired single (@code{cvt.ps.pw}).
14335 @item float __builtin_mips_recip1_s (float)
14336 @itemx double __builtin_mips_recip1_d (double)
14337 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14338 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14340 @item float __builtin_mips_recip2_s (float, float)
14341 @itemx double __builtin_mips_recip2_d (double, double)
14342 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14343 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14345 @item float __builtin_mips_rsqrt1_s (float)
14346 @itemx double __builtin_mips_rsqrt1_d (double)
14347 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14348 Reduced-precision reciprocal square root (sequence step 1)
14349 (@code{rsqrt1.@var{fmt}}).
14351 @item float __builtin_mips_rsqrt2_s (float, float)
14352 @itemx double __builtin_mips_rsqrt2_d (double, double)
14353 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14354 Reduced-precision reciprocal square root (sequence step 2)
14355 (@code{rsqrt2.@var{fmt}}).
14356 @end table
14358 The following multi-instruction functions are also available.
14359 In each case, @var{cond} can be any of the 16 floating-point conditions:
14360 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14361 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14362 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14364 @table @code
14365 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14366 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14367 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14368 @code{bc1t}/@code{bc1f}).
14370 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14371 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14372 For example:
14374 @smallexample
14375 float a, b;
14376 if (__builtin_mips_cabs_eq_s (a, b))
14377   true ();
14378 else
14379   false ();
14380 @end smallexample
14382 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14383 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14384 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14385 @code{bc1t}/@code{bc1f}).
14387 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14388 and return either the upper or lower half of the result.  For example:
14390 @smallexample
14391 v2sf a, b;
14392 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14393   upper_halves_are_equal ();
14394 else
14395   upper_halves_are_unequal ();
14397 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14398   lower_halves_are_equal ();
14399 else
14400   lower_halves_are_unequal ();
14401 @end smallexample
14403 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14404 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14405 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14406 @code{movt.ps}/@code{movf.ps}).
14408 The @code{movt} functions return the value @var{x} computed by:
14410 @smallexample
14411 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14412 mov.ps @var{x},@var{c}
14413 movt.ps @var{x},@var{d},@var{cc}
14414 @end smallexample
14416 The @code{movf} functions are similar but use @code{movf.ps} instead
14417 of @code{movt.ps}.
14419 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14420 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14421 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14422 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14423 Comparison of two paired-single values
14424 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14425 @code{bc1any2t}/@code{bc1any2f}).
14427 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14428 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
14429 result is true and the @code{all} forms return true if both results are true.
14430 For example:
14432 @smallexample
14433 v2sf a, b;
14434 if (__builtin_mips_any_c_eq_ps (a, b))
14435   one_is_true ();
14436 else
14437   both_are_false ();
14439 if (__builtin_mips_all_c_eq_ps (a, b))
14440   both_are_true ();
14441 else
14442   one_is_false ();
14443 @end smallexample
14445 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14446 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14447 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14448 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14449 Comparison of four paired-single values
14450 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14451 @code{bc1any4t}/@code{bc1any4f}).
14453 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14454 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14455 The @code{any} forms return true if any of the four results are true
14456 and the @code{all} forms return true if all four results are true.
14457 For example:
14459 @smallexample
14460 v2sf a, b, c, d;
14461 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14462   some_are_true ();
14463 else
14464   all_are_false ();
14466 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14467   all_are_true ();
14468 else
14469   some_are_false ();
14470 @end smallexample
14471 @end table
14473 @node MIPS SIMD Architecture (MSA) Support
14474 @subsection MIPS SIMD Architecture (MSA) Support
14476 @menu
14477 * MIPS SIMD Architecture Built-in Functions::
14478 @end menu
14480 GCC provides intrinsics to access the SIMD instructions provided by the
14481 MSA MIPS SIMD Architecture.  The interface is made available by including
14482 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14483 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14484 @code{__msa_*}.
14486 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14487 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14488 data elements.  The following vectors typedefs are included in @code{msa.h}:
14489 @itemize
14490 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14491 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14492 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14493 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14494 @item @code{v4i32}, a vector of four signed 32-bit integers;
14495 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14496 @item @code{v2i64}, a vector of two signed 64-bit integers;
14497 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14498 @item @code{v4f32}, a vector of four 32-bit floats;
14499 @item @code{v2f64}, a vector of two 64-bit doubles.
14500 @end itemize
14502 Instructions and corresponding built-ins may have additional restrictions and/or
14503 input/output values manipulated:
14504 @itemize
14505 @item @code{imm0_1}, an integer literal in range 0 to 1;
14506 @item @code{imm0_3}, an integer literal in range 0 to 3;
14507 @item @code{imm0_7}, an integer literal in range 0 to 7;
14508 @item @code{imm0_15}, an integer literal in range 0 to 15;
14509 @item @code{imm0_31}, an integer literal in range 0 to 31;
14510 @item @code{imm0_63}, an integer literal in range 0 to 63;
14511 @item @code{imm0_255}, an integer literal in range 0 to 255;
14512 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14513 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14514 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14515 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14516 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14517 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14518 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14519 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14520 @item @code{imm1_4}, an integer literal in range 1 to 4;
14521 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14522 @end itemize
14524 @smallexample
14526 typedef int i32;
14527 #if __LONG_MAX__ == __LONG_LONG_MAX__
14528 typedef long i64;
14529 #else
14530 typedef long long i64;
14531 #endif
14533 typedef unsigned int u32;
14534 #if __LONG_MAX__ == __LONG_LONG_MAX__
14535 typedef unsigned long u64;
14536 #else
14537 typedef unsigned long long u64;
14538 #endif
14540 typedef double f64;
14541 typedef float f32;
14543 @end smallexample
14545 @node MIPS SIMD Architecture Built-in Functions
14546 @subsubsection MIPS SIMD Architecture Built-in Functions
14548 The intrinsics provided are listed below; each is named after the
14549 machine instruction.
14551 @smallexample
14552 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14553 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14554 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14555 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14557 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14558 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14559 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14560 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14562 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14563 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14564 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14565 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14567 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14568 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14569 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14570 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14572 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14573 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14574 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14575 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14577 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14578 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14579 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14580 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14582 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14584 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14586 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14587 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14588 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14589 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14591 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14592 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14593 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14594 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14596 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14597 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14598 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14599 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14601 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14602 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14603 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14604 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14606 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14607 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14608 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14609 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14611 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14612 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14613 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14614 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14616 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14617 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14618 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14619 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14621 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14622 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14623 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14624 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14626 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14627 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14628 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14629 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14631 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14632 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14633 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14634 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14636 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14637 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14638 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14639 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14641 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14642 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14643 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14644 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14646 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14648 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14650 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14652 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14654 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14655 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14656 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14657 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14659 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14660 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14661 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14662 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14664 i32 __builtin_msa_bnz_b (v16u8);
14665 i32 __builtin_msa_bnz_h (v8u16);
14666 i32 __builtin_msa_bnz_w (v4u32);
14667 i32 __builtin_msa_bnz_d (v2u64);
14669 i32 __builtin_msa_bnz_v (v16u8);
14671 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14673 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14675 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14676 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14677 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14678 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14680 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14681 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14682 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14683 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14685 i32 __builtin_msa_bz_b (v16u8);
14686 i32 __builtin_msa_bz_h (v8u16);
14687 i32 __builtin_msa_bz_w (v4u32);
14688 i32 __builtin_msa_bz_d (v2u64);
14690 i32 __builtin_msa_bz_v (v16u8);
14692 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14693 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14694 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14695 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14697 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14698 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14699 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14700 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14702 i32 __builtin_msa_cfcmsa (imm0_31);
14704 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14705 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14706 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14707 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14709 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14710 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14711 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14712 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14714 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14715 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14716 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14717 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14719 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14720 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14721 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14722 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14724 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14725 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14726 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14727 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14729 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14730 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14731 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14732 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14734 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14735 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14736 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14737 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14739 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14740 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14741 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14742 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14744 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14745 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14746 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14747 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14749 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14750 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14751 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14752 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14754 void __builtin_msa_ctcmsa (imm0_31, i32);
14756 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14757 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14758 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14759 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14761 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14762 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14763 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14764 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14766 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14767 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14768 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14770 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14771 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14772 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14774 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14775 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14776 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14778 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14779 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14780 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14782 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14783 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14784 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14786 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14787 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14788 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14790 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14791 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14793 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14794 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14796 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14797 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14799 v4i32 __builtin_msa_fclass_w (v4f32);
14800 v2i64 __builtin_msa_fclass_d (v2f64);
14802 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14803 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14805 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14806 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14808 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14809 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14811 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14812 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14814 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14815 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14817 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14818 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14820 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14821 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14823 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14824 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14826 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14827 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14829 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14830 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14832 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14833 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14835 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14836 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14838 v4f32 __builtin_msa_fexupl_w (v8i16);
14839 v2f64 __builtin_msa_fexupl_d (v4f32);
14841 v4f32 __builtin_msa_fexupr_w (v8i16);
14842 v2f64 __builtin_msa_fexupr_d (v4f32);
14844 v4f32 __builtin_msa_ffint_s_w (v4i32);
14845 v2f64 __builtin_msa_ffint_s_d (v2i64);
14847 v4f32 __builtin_msa_ffint_u_w (v4u32);
14848 v2f64 __builtin_msa_ffint_u_d (v2u64);
14850 v4f32 __builtin_msa_ffql_w (v8i16);
14851 v2f64 __builtin_msa_ffql_d (v4i32);
14853 v4f32 __builtin_msa_ffqr_w (v8i16);
14854 v2f64 __builtin_msa_ffqr_d (v4i32);
14856 v16i8 __builtin_msa_fill_b (i32);
14857 v8i16 __builtin_msa_fill_h (i32);
14858 v4i32 __builtin_msa_fill_w (i32);
14859 v2i64 __builtin_msa_fill_d (i64);
14861 v4f32 __builtin_msa_flog2_w (v4f32);
14862 v2f64 __builtin_msa_flog2_d (v2f64);
14864 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14865 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14867 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14868 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14870 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14871 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14873 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14874 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14876 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14877 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14879 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14880 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14882 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14883 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14885 v4f32 __builtin_msa_frint_w (v4f32);
14886 v2f64 __builtin_msa_frint_d (v2f64);
14888 v4f32 __builtin_msa_frcp_w (v4f32);
14889 v2f64 __builtin_msa_frcp_d (v2f64);
14891 v4f32 __builtin_msa_frsqrt_w (v4f32);
14892 v2f64 __builtin_msa_frsqrt_d (v2f64);
14894 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14895 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14897 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14898 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14900 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14901 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14903 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14904 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14906 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14907 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14909 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14910 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14912 v4f32 __builtin_msa_fsqrt_w (v4f32);
14913 v2f64 __builtin_msa_fsqrt_d (v2f64);
14915 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14916 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14918 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14919 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14921 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14922 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14924 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14925 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14927 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14928 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14930 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14931 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14933 v4i32 __builtin_msa_ftint_s_w (v4f32);
14934 v2i64 __builtin_msa_ftint_s_d (v2f64);
14936 v4u32 __builtin_msa_ftint_u_w (v4f32);
14937 v2u64 __builtin_msa_ftint_u_d (v2f64);
14939 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14940 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14942 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14943 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14945 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14946 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14948 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14949 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14950 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14952 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14953 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14954 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14956 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14957 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14958 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14960 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14961 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14962 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14964 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14965 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14966 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14967 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14969 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14970 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14971 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14972 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14974 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14975 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14976 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14977 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14979 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14980 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14981 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14982 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14984 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14985 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14986 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14987 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14989 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14990 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14991 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14992 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14994 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14995 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14996 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14997 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14999 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15000 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15001 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15002 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15004 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15005 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15007 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15008 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15010 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15011 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15012 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15013 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15015 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15016 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15017 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15018 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15020 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15021 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15022 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15023 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15025 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15026 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15027 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15028 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15030 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15031 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15032 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15033 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15035 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15036 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15037 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15038 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15040 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15041 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15042 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15043 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15045 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15046 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15047 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15048 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15050 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15051 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15052 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15053 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15055 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15056 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15057 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15058 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15060 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15061 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15062 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15063 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15065 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15066 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15067 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15068 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15070 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15071 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15072 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15073 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15075 v16i8 __builtin_msa_move_v (v16i8);
15077 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15078 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15080 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15081 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15083 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15084 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15085 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15086 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15088 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15089 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15091 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15092 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15094 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15095 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15096 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15097 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15099 v16i8 __builtin_msa_nloc_b (v16i8);
15100 v8i16 __builtin_msa_nloc_h (v8i16);
15101 v4i32 __builtin_msa_nloc_w (v4i32);
15102 v2i64 __builtin_msa_nloc_d (v2i64);
15104 v16i8 __builtin_msa_nlzc_b (v16i8);
15105 v8i16 __builtin_msa_nlzc_h (v8i16);
15106 v4i32 __builtin_msa_nlzc_w (v4i32);
15107 v2i64 __builtin_msa_nlzc_d (v2i64);
15109 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15111 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15113 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15115 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15117 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15118 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15119 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15120 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15122 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15123 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15124 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15125 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15127 v16i8 __builtin_msa_pcnt_b (v16i8);
15128 v8i16 __builtin_msa_pcnt_h (v8i16);
15129 v4i32 __builtin_msa_pcnt_w (v4i32);
15130 v2i64 __builtin_msa_pcnt_d (v2i64);
15132 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15133 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15134 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15135 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15137 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15138 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15139 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15140 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15142 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15143 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15144 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15146 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15147 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15148 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15149 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15151 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15152 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15153 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15154 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15156 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15157 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15158 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15159 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15161 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15162 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15163 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15164 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15166 v16i8 __builtin_msa_splat_b (v16i8, i32);
15167 v8i16 __builtin_msa_splat_h (v8i16, i32);
15168 v4i32 __builtin_msa_splat_w (v4i32, i32);
15169 v2i64 __builtin_msa_splat_d (v2i64, i32);
15171 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15172 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15173 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15174 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15176 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15177 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15178 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15179 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15181 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15182 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15183 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15184 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15186 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15187 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15188 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15189 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15191 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15192 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15193 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15194 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15196 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15197 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15198 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15199 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15201 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15202 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15203 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15204 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15206 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15207 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15208 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15209 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15211 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15212 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15213 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15214 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15216 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15217 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15218 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15219 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15221 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15222 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15223 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15224 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15226 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15227 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15228 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15229 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15231 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15232 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15233 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15234 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15236 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15237 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15238 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15239 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15241 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15242 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15243 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15244 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15246 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15247 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15248 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15249 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15251 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15252 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15253 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15254 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15256 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15258 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15259 @end smallexample
15261 @node Other MIPS Built-in Functions
15262 @subsection Other MIPS Built-in Functions
15264 GCC provides other MIPS-specific built-in functions:
15266 @table @code
15267 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15268 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15269 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15270 when this function is available.
15272 @item unsigned int __builtin_mips_get_fcsr (void)
15273 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15274 Get and set the contents of the floating-point control and status register
15275 (FPU control register 31).  These functions are only available in hard-float
15276 code but can be called in both MIPS16 and non-MIPS16 contexts.
15278 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15279 register except the condition codes, which GCC assumes are preserved.
15280 @end table
15282 @node MSP430 Built-in Functions
15283 @subsection MSP430 Built-in Functions
15285 GCC provides a couple of special builtin functions to aid in the
15286 writing of interrupt handlers in C.
15288 @table @code
15289 @item __bic_SR_register_on_exit (int @var{mask})
15290 This clears the indicated bits in the saved copy of the status register
15291 currently residing on the stack.  This only works inside interrupt
15292 handlers and the changes to the status register will only take affect
15293 once the handler returns.
15295 @item __bis_SR_register_on_exit (int @var{mask})
15296 This sets the indicated bits in the saved copy of the status register
15297 currently residing on the stack.  This only works inside interrupt
15298 handlers and the changes to the status register will only take affect
15299 once the handler returns.
15301 @item __delay_cycles (long long @var{cycles})
15302 This inserts an instruction sequence that takes exactly @var{cycles}
15303 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15304 may use jumps, loops, or no-ops, and does not interfere with any other
15305 instructions.  Note that @var{cycles} must be a compile-time constant
15306 integer - that is, you must pass a number, not a variable that may be
15307 optimized to a constant later.  The number of cycles delayed by this
15308 builtin is exact.
15309 @end table
15311 @node NDS32 Built-in Functions
15312 @subsection NDS32 Built-in Functions
15314 These built-in functions are available for the NDS32 target:
15316 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15317 Insert an ISYNC instruction into the instruction stream where
15318 @var{addr} is an instruction address for serialization.
15319 @end deftypefn
15321 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15322 Insert an ISB instruction into the instruction stream.
15323 @end deftypefn
15325 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15326 Return the content of a system register which is mapped by @var{sr}.
15327 @end deftypefn
15329 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15330 Return the content of a user space register which is mapped by @var{usr}.
15331 @end deftypefn
15333 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15334 Move the @var{value} to a system register which is mapped by @var{sr}.
15335 @end deftypefn
15337 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15338 Move the @var{value} to a user space register which is mapped by @var{usr}.
15339 @end deftypefn
15341 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15342 Enable global interrupt.
15343 @end deftypefn
15345 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15346 Disable global interrupt.
15347 @end deftypefn
15349 @node picoChip Built-in Functions
15350 @subsection picoChip Built-in Functions
15352 GCC provides an interface to selected machine instructions from the
15353 picoChip instruction set.
15355 @table @code
15356 @item int __builtin_sbc (int @var{value})
15357 Sign bit count.  Return the number of consecutive bits in @var{value}
15358 that have the same value as the sign bit.  The result is the number of
15359 leading sign bits minus one, giving the number of redundant sign bits in
15360 @var{value}.
15362 @item int __builtin_byteswap (int @var{value})
15363 Byte swap.  Return the result of swapping the upper and lower bytes of
15364 @var{value}.
15366 @item int __builtin_brev (int @var{value})
15367 Bit reversal.  Return the result of reversing the bits in
15368 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15369 and so on.
15371 @item int __builtin_adds (int @var{x}, int @var{y})
15372 Saturating addition.  Return the result of adding @var{x} and @var{y},
15373 storing the value 32767 if the result overflows.
15375 @item int __builtin_subs (int @var{x}, int @var{y})
15376 Saturating subtraction.  Return the result of subtracting @var{y} from
15377 @var{x}, storing the value @minus{}32768 if the result overflows.
15379 @item void __builtin_halt (void)
15380 Halt.  The processor stops execution.  This built-in is useful for
15381 implementing assertions.
15383 @end table
15385 @node Basic PowerPC Built-in Functions
15386 @subsection Basic PowerPC Built-in Functions
15388 @menu
15389 * Basic PowerPC Built-in Functions Available on all Configurations::
15390 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15391 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15392 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15393 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15394 @end menu
15396 This section describes PowerPC built-in functions that do not require
15397 the inclusion of any special header files to declare prototypes or
15398 provide macro definitions.  The sections that follow describe
15399 additional PowerPC built-in functions.
15401 @node Basic PowerPC Built-in Functions Available on all Configurations
15402 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15404 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15405 This function is a @code{nop} on the PowerPC platform and is included solely
15406 to maintain API compatibility with the x86 builtins.
15407 @end deftypefn
15409 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15410 This function returns a value of @code{1} if the run-time CPU is of type
15411 @var{cpuname} and returns @code{0} otherwise
15413 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15414 which exports the hardware capability bits.  GCC defines the macro
15415 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15416 built-in function is fully supported.
15418 If GCC was configured to use a GLIBC before 2.23, the built-in
15419 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15420 issues a warning.
15422 The following CPU names can be detected:
15424 @table @samp
15425 @item power9
15426 IBM POWER9 Server CPU.
15427 @item power8
15428 IBM POWER8 Server CPU.
15429 @item power7
15430 IBM POWER7 Server CPU.
15431 @item power6x
15432 IBM POWER6 Server CPU (RAW mode).
15433 @item power6
15434 IBM POWER6 Server CPU (Architected mode).
15435 @item power5+
15436 IBM POWER5+ Server CPU.
15437 @item power5
15438 IBM POWER5 Server CPU.
15439 @item ppc970
15440 IBM 970 Server CPU (ie, Apple G5).
15441 @item power4
15442 IBM POWER4 Server CPU.
15443 @item ppca2
15444 IBM A2 64-bit Embedded CPU
15445 @item ppc476
15446 IBM PowerPC 476FP 32-bit Embedded CPU.
15447 @item ppc464
15448 IBM PowerPC 464 32-bit Embedded CPU.
15449 @item ppc440
15450 PowerPC 440 32-bit Embedded CPU.
15451 @item ppc405
15452 PowerPC 405 32-bit Embedded CPU.
15453 @item ppc-cell-be
15454 IBM PowerPC Cell Broadband Engine Architecture CPU.
15455 @end table
15457 Here is an example:
15458 @smallexample
15459 #ifdef __BUILTIN_CPU_SUPPORTS__
15460   if (__builtin_cpu_is ("power8"))
15461     @{
15462        do_power8 (); // POWER8 specific implementation.
15463     @}
15464   else
15465 #endif
15466     @{
15467        do_generic (); // Generic implementation.
15468     @}
15469 @end smallexample
15470 @end deftypefn
15472 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15473 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15474 feature @var{feature} and returns @code{0} otherwise.
15476 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15477 newer which exports the hardware capability bits.  GCC defines the
15478 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15479 @code{__builtin_cpu_supports} built-in function is fully supported.
15481 If GCC was configured to use a GLIBC before 2.23, the built-in
15482 function @code{__builtin_cpu_suports} always returns a 0 and the
15483 compiler issues a warning.
15485 The following features can be
15486 detected:
15488 @table @samp
15489 @item 4xxmac
15490 4xx CPU has a Multiply Accumulator.
15491 @item altivec
15492 CPU has a SIMD/Vector Unit.
15493 @item arch_2_05
15494 CPU supports ISA 2.05 (eg, POWER6)
15495 @item arch_2_06
15496 CPU supports ISA 2.06 (eg, POWER7)
15497 @item arch_2_07
15498 CPU supports ISA 2.07 (eg, POWER8)
15499 @item arch_3_00
15500 CPU supports ISA 3.0 (eg, POWER9)
15501 @item archpmu
15502 CPU supports the set of compatible performance monitoring events.
15503 @item booke
15504 CPU supports the Embedded ISA category.
15505 @item cellbe
15506 CPU has a CELL broadband engine.
15507 @item darn
15508 CPU supports the @code{darn} (deliver a random number) instruction.
15509 @item dfp
15510 CPU has a decimal floating point unit.
15511 @item dscr
15512 CPU supports the data stream control register.
15513 @item ebb
15514 CPU supports event base branching.
15515 @item efpdouble
15516 CPU has a SPE double precision floating point unit.
15517 @item efpsingle
15518 CPU has a SPE single precision floating point unit.
15519 @item fpu
15520 CPU has a floating point unit.
15521 @item htm
15522 CPU has hardware transaction memory instructions.
15523 @item htm-nosc
15524 Kernel aborts hardware transactions when a syscall is made.
15525 @item htm-no-suspend
15526 CPU supports hardware transaction memory but does not support the
15527 @code{tsuspend.} instruction.
15528 @item ic_snoop
15529 CPU supports icache snooping capabilities.
15530 @item ieee128
15531 CPU supports 128-bit IEEE binary floating point instructions.
15532 @item isel
15533 CPU supports the integer select instruction.
15534 @item mmu
15535 CPU has a memory management unit.
15536 @item notb
15537 CPU does not have a timebase (eg, 601 and 403gx).
15538 @item pa6t
15539 CPU supports the PA Semi 6T CORE ISA.
15540 @item power4
15541 CPU supports ISA 2.00 (eg, POWER4)
15542 @item power5
15543 CPU supports ISA 2.02 (eg, POWER5)
15544 @item power5+
15545 CPU supports ISA 2.03 (eg, POWER5+)
15546 @item power6x
15547 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15548 @item ppc32
15549 CPU supports 32-bit mode execution.
15550 @item ppc601
15551 CPU supports the old POWER ISA (eg, 601)
15552 @item ppc64
15553 CPU supports 64-bit mode execution.
15554 @item ppcle
15555 CPU supports a little-endian mode that uses address swizzling.
15556 @item scv
15557 Kernel supports system call vectored.
15558 @item smt
15559 CPU support simultaneous multi-threading.
15560 @item spe
15561 CPU has a signal processing extension unit.
15562 @item tar
15563 CPU supports the target address register.
15564 @item true_le
15565 CPU supports true little-endian mode.
15566 @item ucache
15567 CPU has unified I/D cache.
15568 @item vcrypto
15569 CPU supports the vector cryptography instructions.
15570 @item vsx
15571 CPU supports the vector-scalar extension.
15572 @end table
15574 Here is an example:
15575 @smallexample
15576 #ifdef __BUILTIN_CPU_SUPPORTS__
15577   if (__builtin_cpu_supports ("fpu"))
15578     @{
15579        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15580     @}
15581   else
15582 #endif
15583     @{
15584        dst = __fadd (src1, src2); // Software FP addition function.
15585     @}
15586 @end smallexample
15587 @end deftypefn
15589 The following built-in functions are also available on all PowerPC
15590 processors:
15591 @smallexample
15592 uint64_t __builtin_ppc_get_timebase ();
15593 unsigned long __builtin_ppc_mftb ();
15594 __ibm128 __builtin_unpack_ibm128 (__ibm128, int);
15595 __ibm128 __builtin_pack_ibm128 (double, double);
15596 @end smallexample
15598 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15599 functions generate instructions to read the Time Base Register.  The
15600 @code{__builtin_ppc_get_timebase} function may generate multiple
15601 instructions and always returns the 64 bits of the Time Base Register.
15602 The @code{__builtin_ppc_mftb} function always generates one instruction and
15603 returns the Time Base Register value as an unsigned long, throwing away
15604 the most significant word on 32-bit environments.
15606 @node Basic PowerPC Built-in Functions Available on ISA 2.05
15607 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
15609 The basic built-in functions described in this section are
15610 available on the PowerPC family of processors starting with ISA 2.05
15611 or later.  Unless specific options are explicitly disabled on the
15612 command line, specifying option @option{-mcpu=power6} has the effect of
15613 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
15614 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
15615 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
15616 @option{-mrecip-precision} options.  Specify the
15617 @option{-maltivec} and @option{-mfpgpr} options explicitly in
15618 combination with the above options if they are desired.
15620 The following functions require option @option{-mcmpb}.
15621 @smallexample
15622 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15623 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15624 @end smallexample
15626 The @code{__builtin_cmpb} function
15627 performs a byte-wise compare on the contents of its two arguments,
15628 returning the result of the byte-wise comparison as the returned
15629 value.  For each byte comparison, the corresponding byte of the return
15630 value holds 0xff if the input bytes are equal and 0 if the input bytes
15631 are not equal.  If either of the arguments to this built-in function
15632 is wider than 32 bits, the function call expands into the form that
15633 expects @code{unsigned long long int} arguments
15634 which is only available on 64-bit targets.
15636 The following built-in functions are available
15637 when hardware decimal floating point
15638 (@option{-mhard-dfp}) is available:
15639 @smallexample
15640 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15641 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15642 _Decimal64 __builtin_denbcd (int, _Decimal64);
15643 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15644 _Decimal64 __builtin_diex (long long, _Decimal64);
15645 _Decimal128 _builtin_diexq (long long, _Decimal128);
15646 _Decimal64 __builtin_dscli (_Decimal64, int);
15647 _Decimal128 __builtin_dscliq (_Decimal128, int);
15648 _Decimal64 __builtin_dscri (_Decimal64, int);
15649 _Decimal128 __builtin_dscriq (_Decimal128, int);
15650 long long __builtin_dxex (_Decimal64);
15651 long long __builtin_dxexq (_Decimal128);
15652 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15653 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15654 @end smallexample
15656 The following functions require @option{-mhard-float},
15657 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
15659 @smallexample
15660 double __builtin_recipdiv (double, double);
15661 float __builtin_recipdivf (float, float);
15662 double __builtin_rsqrt (double);
15663 float __builtin_rsqrtf (float);
15664 @end smallexample
15666 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15667 @code{__builtin_rsqrtf} functions generate multiple instructions to
15668 implement the reciprocal sqrt functionality using reciprocal sqrt
15669 estimate instructions.
15671 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15672 functions generate multiple instructions to implement division using
15673 the reciprocal estimate instructions.
15675 The following functions require @option{-mhard-float} and
15676 @option{-mmultiple} options.
15678 The @code{__builtin_unpack_longdouble} function takes a
15679 @code{long double} argument and a compile time constant of 0 or 1.  If
15680 the constant is 0, the first @code{double} within the
15681 @code{long double} is returned, otherwise the second @code{double}
15682 is returned.  The @code{__builtin_unpack_longdouble} function is only
15683 availble if @code{long double} uses the IBM extended double
15684 representation.
15686 The @code{__builtin_pack_longdouble} function takes two @code{double}
15687 arguments and returns a @code{long double} value that combines the two
15688 arguments.  The @code{__builtin_pack_longdouble} function is only
15689 availble if @code{long double} uses the IBM extended double
15690 representation.
15692 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
15693 argument and a compile time constant of 0 or 1.  If the constant is 0,
15694 the first @code{double} within the @code{__ibm128} is returned,
15695 otherwise the second @code{double} is returned.
15697 The @code{__builtin_pack_ibm128} function takes two @code{double}
15698 arguments and returns a @code{__ibm128} value that combines the two
15699 arguments.
15701 Additional built-in functions are available for the 64-bit PowerPC
15702 family of processors, for efficient use of 128-bit floating point
15703 (@code{__float128}) values.
15705 @node Basic PowerPC Built-in Functions Available on ISA 2.06
15706 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
15708 The basic built-in functions described in this section are
15709 available on the PowerPC family of processors starting with ISA 2.05
15710 or later.  Unless specific options are explicitly disabled on the
15711 command line, specifying option @option{-mcpu=power7} has the effect of
15712 enabling all the same options as for @option{-mcpu=power6} in
15713 addition to the @option{-maltivec}, @option{-mpopcntd}, and
15714 @option{-mvsx} options.
15716 The following basic built-in functions require @option{-mpopcntd}:
15717 @smallexample
15718 unsigned int __builtin_addg6s (unsigned int, unsigned int);
15719 long long __builtin_bpermd (long long, long long);
15720 unsigned int __builtin_cbcdtd (unsigned int);
15721 unsigned int __builtin_cdtbcd (unsigned int);
15722 long long __builtin_divde (long long, long long);
15723 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
15724 int __builtin_divwe (int, int);
15725 unsigned int __builtin_divweu (unsigned int, unsigned int);
15726 vector __int128_t __builtin_pack_vector_int128 (long long, long long);
15727 void __builtin_rs6000_speculation_barrier (void);
15728 long long __builtin_unpack_vector_int128 (vector __int128_t, signed char);
15729 @end smallexample
15731 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
15732 require a 64-bit environment.
15734 The following basic built-in functions, which are also supported on
15735 x86 targets, require @option{-mfloat128}.
15736 @smallexample
15737 __float128 __builtin_fabsq (__float128);
15738 __float128 __builtin_copysignq (__float128, __float128);
15739 __float128 __builtin_infq (void);
15740 __float128 __builtin_huge_valq (void);
15741 __float128 __builtin_nanq (void);
15742 __float128 __builtin_nansq (void);
15744 __float128 __builtin_sqrtf128 (__float128);
15745 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
15746 @end smallexample
15748 @node Basic PowerPC Built-in Functions Available on ISA 2.07
15749 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
15751 The basic built-in functions described in this section are
15752 available on the PowerPC family of processors starting with ISA 2.07
15753 or later.  Unless specific options are explicitly disabled on the
15754 command line, specifying option @option{-mcpu=power8} has the effect of
15755 enabling all the same options as for @option{-mcpu=power7} in
15756 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
15757 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
15758 @option{-mquad-memory-atomic} options.
15760 This section intentionally empty.
15762 @node Basic PowerPC Built-in Functions Available on ISA 3.0
15763 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
15765 The basic built-in functions described in this section are
15766 available on the PowerPC family of processors starting with ISA 3.0
15767 or later.  Unless specific options are explicitly disabled on the
15768 command line, specifying option @option{-mcpu=power9} has the effect of
15769 enabling all the same options as for @option{-mcpu=power8} in
15770 addition to the @option{-misel} option.
15772 The following built-in functions are available on Linux 64-bit systems
15773 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
15775 @table @code
15776 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
15777 Perform a 128-bit IEEE floating point add using round to odd as the
15778 rounding mode.
15779 @findex __builtin_addf128_round_to_odd
15781 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
15782 Perform a 128-bit IEEE floating point subtract using round to odd as
15783 the rounding mode.
15784 @findex __builtin_subf128_round_to_odd
15786 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
15787 Perform a 128-bit IEEE floating point multiply using round to odd as
15788 the rounding mode.
15789 @findex __builtin_mulf128_round_to_odd
15791 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
15792 Perform a 128-bit IEEE floating point divide using round to odd as
15793 the rounding mode.
15794 @findex __builtin_divf128_round_to_odd
15796 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
15797 Perform a 128-bit IEEE floating point square root using round to odd
15798 as the rounding mode.
15799 @findex __builtin_sqrtf128_round_to_odd
15801 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
15802 Perform a 128-bit IEEE floating point fused multiply and add operation
15803 using round to odd as the rounding mode.
15804 @findex __builtin_fmaf128_round_to_odd
15806 @item double __builtin_truncf128_round_to_odd (__float128)
15807 Convert a 128-bit IEEE floating point value to @code{double} using
15808 round to odd as the rounding mode.
15809 @findex __builtin_truncf128_round_to_odd
15810 @end table
15812 The following additional built-in functions are also available for the
15813 PowerPC family of processors, starting with ISA 3.0 or later:
15814 @smallexample
15815 long long __builtin_darn (void);
15816 long long __builtin_darn_raw (void);
15817 int __builtin_darn_32 (void);
15818 @end smallexample
15820 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15821 functions require a
15822 64-bit environment supporting ISA 3.0 or later.
15823 The @code{__builtin_darn} function provides a 64-bit conditioned
15824 random number.  The @code{__builtin_darn_raw} function provides a
15825 64-bit raw random number.  The @code{__builtin_darn_32} function
15826 provides a 32-bit conditioned random number.
15828 The following additional built-in functions are also available for the
15829 PowerPC family of processors, starting with ISA 3.0 or later:
15831 @smallexample
15832 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15833 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15834 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15836 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15837 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15838 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15839 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15841 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15842 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15843 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15844 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15846 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15847 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15848 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15849 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15851 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15852 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15853 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15854 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15855 @end smallexample
15856 The @code{__builtin_byte_in_set} function requires a
15857 64-bit environment supporting ISA 3.0 or later.  This function returns
15858 a non-zero value if and only if its @code{u} argument exactly equals one of
15859 the eight bytes contained within its 64-bit @code{set} argument.
15861 The @code{__builtin_byte_in_range} and
15862 @code{__builtin_byte_in_either_range} require an environment
15863 supporting ISA 3.0 or later.  For these two functions, the
15864 @code{range} argument is encoded as 4 bytes, organized as
15865 @code{hi_1:lo_1:hi_2:lo_2}.
15866 The @code{__builtin_byte_in_range} function returns a
15867 non-zero value if and only if its @code{u} argument is within the
15868 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15869 The @code{__builtin_byte_in_either_range} function returns non-zero if
15870 and only if its @code{u} argument is within either the range bounded
15871 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15872 between @code{lo_2} and @code{hi_2} inclusive.
15874 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15875 if and only if the number of signficant digits of its @code{value} argument
15876 is less than its @code{comparison} argument.  The
15877 @code{__builtin_dfp_dtstsfi_lt_dd} and
15878 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15879 require that the type of the @code{value} argument be
15880 @code{__Decimal64} and @code{__Decimal128} respectively.
15882 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15883 if and only if the number of signficant digits of its @code{value} argument
15884 is greater than its @code{comparison} argument.  The
15885 @code{__builtin_dfp_dtstsfi_gt_dd} and
15886 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15887 require that the type of the @code{value} argument be
15888 @code{__Decimal64} and @code{__Decimal128} respectively.
15890 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15891 if and only if the number of signficant digits of its @code{value} argument
15892 equals its @code{comparison} argument.  The
15893 @code{__builtin_dfp_dtstsfi_eq_dd} and
15894 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15895 require that the type of the @code{value} argument be
15896 @code{__Decimal64} and @code{__Decimal128} respectively.
15898 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15899 if and only if its @code{value} argument has an undefined number of
15900 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15901 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15902 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15903 require that the type of the @code{value} argument be
15904 @code{__Decimal64} and @code{__Decimal128} respectively.
15908 @node PowerPC AltiVec/VSX Built-in Functions
15909 @subsection PowerPC AltiVec Built-in Functions
15911 GCC provides an interface for the PowerPC family of processors to access
15912 the AltiVec operations described in Motorola's AltiVec Programming
15913 Interface Manual.  The interface is made available by including
15914 @code{<altivec.h>} and using @option{-maltivec} and
15915 @option{-mabi=altivec}.  The interface supports the following vector
15916 types.
15918 @smallexample
15919 vector unsigned char
15920 vector signed char
15921 vector bool char
15923 vector unsigned short
15924 vector signed short
15925 vector bool short
15926 vector pixel
15928 vector unsigned int
15929 vector signed int
15930 vector bool int
15931 vector float
15932 @end smallexample
15934 If @option{-mvsx} is used the following additional vector types are
15935 implemented.
15937 @smallexample
15938 vector unsigned long
15939 vector signed long
15940 vector double
15941 @end smallexample
15943 The long types are only implemented for 64-bit code generation, and
15944 the long type is only used in the floating point/integer conversion
15945 instructions.
15947 GCC's implementation of the high-level language interface available from
15948 C and C++ code differs from Motorola's documentation in several ways.
15950 @itemize @bullet
15952 @item
15953 A vector constant is a list of constant expressions within curly braces.
15955 @item
15956 A vector initializer requires no cast if the vector constant is of the
15957 same type as the variable it is initializing.
15959 @item
15960 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15961 vector type is the default signedness of the base type.  The default
15962 varies depending on the operating system, so a portable program should
15963 always specify the signedness.
15965 @item
15966 Compiling with @option{-maltivec} adds keywords @code{__vector},
15967 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15968 @code{bool}.  When compiling ISO C, the context-sensitive substitution
15969 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15970 disabled.  To use them, you must include @code{<altivec.h>} instead.
15972 @item
15973 GCC allows using a @code{typedef} name as the type specifier for a
15974 vector type.
15976 @item
15977 For C, overloaded functions are implemented with macros so the following
15978 does not work:
15980 @smallexample
15981   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15982 @end smallexample
15984 @noindent
15985 Since @code{vec_add} is a macro, the vector constant in the example
15986 is treated as four separate arguments.  Wrap the entire argument in
15987 parentheses for this to work.
15988 @end itemize
15990 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15991 Internally, GCC uses built-in functions to achieve the functionality in
15992 the aforementioned header file, but they are not supported and are
15993 subject to change without notice.
15995 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
15996 which may be found at
15997 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
15998 Appendix A of this document lists the vector API interfaces that must be
15999 provided by compliant compilers.  Programmers should preferentially use
16000 the interfaces described therein.  However, historically GCC has provided
16001 additional interfaces for access to vector instructions.  These are
16002 briefly described below.
16004 The following interfaces are supported for the generic and specific
16005 AltiVec operations and the AltiVec predicates.  In cases where there
16006 is a direct mapping between generic and specific operations, only the
16007 generic names are shown here, although the specific operations can also
16008 be used.
16010 Arguments that are documented as @code{const int} require literal
16011 integral values within the range required for that operation.
16013 @smallexample
16014 vector signed char vec_abs (vector signed char);
16015 vector signed short vec_abs (vector signed short);
16016 vector signed int vec_abs (vector signed int);
16017 vector float vec_abs (vector float);
16019 vector signed char vec_abss (vector signed char);
16020 vector signed short vec_abss (vector signed short);
16021 vector signed int vec_abss (vector signed int);
16023 vector signed char vec_add (vector bool char, vector signed char);
16024 vector signed char vec_add (vector signed char, vector bool char);
16025 vector signed char vec_add (vector signed char, vector signed char);
16026 vector unsigned char vec_add (vector bool char, vector unsigned char);
16027 vector unsigned char vec_add (vector unsigned char, vector bool char);
16028 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
16029 vector signed short vec_add (vector bool short, vector signed short);
16030 vector signed short vec_add (vector signed short, vector bool short);
16031 vector signed short vec_add (vector signed short, vector signed short);
16032 vector unsigned short vec_add (vector bool short, vector unsigned short);
16033 vector unsigned short vec_add (vector unsigned short, vector bool short);
16034 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
16035 vector signed int vec_add (vector bool int, vector signed int);
16036 vector signed int vec_add (vector signed int, vector bool int);
16037 vector signed int vec_add (vector signed int, vector signed int);
16038 vector unsigned int vec_add (vector bool int, vector unsigned int);
16039 vector unsigned int vec_add (vector unsigned int, vector bool int);
16040 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16041 vector float vec_add (vector float, vector float);
16043 vector float vec_vaddfp (vector float, vector float);
16045 vector signed int vec_vadduwm (vector bool int, vector signed int);
16046 vector signed int vec_vadduwm (vector signed int, vector bool int);
16047 vector signed int vec_vadduwm (vector signed int, vector signed int);
16048 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
16049 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
16050 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
16052 vector signed short vec_vadduhm (vector bool short, vector signed short);
16053 vector signed short vec_vadduhm (vector signed short, vector bool short);
16054 vector signed short vec_vadduhm (vector signed short, vector signed short);
16055 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
16056 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
16057 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
16059 vector signed char vec_vaddubm (vector bool char, vector signed char);
16060 vector signed char vec_vaddubm (vector signed char, vector bool char);
16061 vector signed char vec_vaddubm (vector signed char, vector signed char);
16062 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
16063 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
16064 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
16066 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16068 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16069 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16070 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
16071 vector signed char vec_adds (vector bool char, vector signed char);
16072 vector signed char vec_adds (vector signed char, vector bool char);
16073 vector signed char vec_adds (vector signed char, vector signed char);
16074 vector unsigned short vec_adds (vector bool short, vector unsigned short);
16075 vector unsigned short vec_adds (vector unsigned short, vector bool short);
16076 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
16077 vector signed short vec_adds (vector bool short, vector signed short);
16078 vector signed short vec_adds (vector signed short, vector bool short);
16079 vector signed short vec_adds (vector signed short, vector signed short);
16080 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16081 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16082 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16083 vector signed int vec_adds (vector bool int, vector signed int);
16084 vector signed int vec_adds (vector signed int, vector bool int);
16085 vector signed int vec_adds (vector signed int, vector signed int);
16087 vector signed int vec_vaddsws (vector bool int, vector signed int);
16088 vector signed int vec_vaddsws (vector signed int, vector bool int);
16089 vector signed int vec_vaddsws (vector signed int, vector signed int);
16091 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
16092 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
16093 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
16095 vector signed short vec_vaddshs (vector bool short, vector signed short);
16096 vector signed short vec_vaddshs (vector signed short, vector bool short);
16097 vector signed short vec_vaddshs (vector signed short, vector signed short);
16099 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
16100 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
16101 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
16103 vector signed char vec_vaddsbs (vector bool char, vector signed char);
16104 vector signed char vec_vaddsbs (vector signed char, vector bool char);
16105 vector signed char vec_vaddsbs (vector signed char, vector signed char);
16107 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
16108 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
16109 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
16111 vector float vec_and (vector float, vector float);
16112 vector float vec_and (vector float, vector bool int);
16113 vector float vec_and (vector bool int, vector float);
16114 vector bool long long vec_and (vector bool long long int, vector bool long long);
16115 vector bool int vec_and (vector bool int, vector bool int);
16116 vector signed int vec_and (vector bool int, vector signed int);
16117 vector signed int vec_and (vector signed int, vector bool int);
16118 vector signed int vec_and (vector signed int, vector signed int);
16119 vector unsigned int vec_and (vector bool int, vector unsigned int);
16120 vector unsigned int vec_and (vector unsigned int, vector bool int);
16121 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16122 vector bool short vec_and (vector bool short, vector bool short);
16123 vector signed short vec_and (vector bool short, vector signed short);
16124 vector signed short vec_and (vector signed short, vector bool short);
16125 vector signed short vec_and (vector signed short, vector signed short);
16126 vector unsigned short vec_and (vector bool short, vector unsigned short);
16127 vector unsigned short vec_and (vector unsigned short, vector bool short);
16128 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
16129 vector signed char vec_and (vector bool char, vector signed char);
16130 vector bool char vec_and (vector bool char, vector bool char);
16131 vector signed char vec_and (vector signed char, vector bool char);
16132 vector signed char vec_and (vector signed char, vector signed char);
16133 vector unsigned char vec_and (vector bool char, vector unsigned char);
16134 vector unsigned char vec_and (vector unsigned char, vector bool char);
16135 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
16137 vector float vec_andc (vector float, vector float);
16138 vector float vec_andc (vector float, vector bool int);
16139 vector float vec_andc (vector bool int, vector float);
16140 vector bool int vec_andc (vector bool int, vector bool int);
16141 vector signed int vec_andc (vector bool int, vector signed int);
16142 vector signed int vec_andc (vector signed int, vector bool int);
16143 vector signed int vec_andc (vector signed int, vector signed int);
16144 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16145 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16146 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16147 vector bool short vec_andc (vector bool short, vector bool short);
16148 vector signed short vec_andc (vector bool short, vector signed short);
16149 vector signed short vec_andc (vector signed short, vector bool short);
16150 vector signed short vec_andc (vector signed short, vector signed short);
16151 vector unsigned short vec_andc (vector bool short, vector unsigned short);
16152 vector unsigned short vec_andc (vector unsigned short, vector bool short);
16153 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
16154 vector signed char vec_andc (vector bool char, vector signed char);
16155 vector bool char vec_andc (vector bool char, vector bool char);
16156 vector signed char vec_andc (vector signed char, vector bool char);
16157 vector signed char vec_andc (vector signed char, vector signed char);
16158 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16159 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16160 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
16162 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
16163 vector signed char vec_avg (vector signed char, vector signed char);
16164 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
16165 vector signed short vec_avg (vector signed short, vector signed short);
16166 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16167 vector signed int vec_avg (vector signed int, vector signed int);
16169 vector signed int vec_vavgsw (vector signed int, vector signed int);
16171 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
16173 vector signed short vec_vavgsh (vector signed short, vector signed short);
16175 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
16177 vector signed char vec_vavgsb (vector signed char, vector signed char);
16179 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
16181 vector float vec_ceil (vector float);
16183 vector signed int vec_cmpb (vector float, vector float);
16185 vector bool char vec_cmpeq (vector bool char, vector bool char);
16186 vector bool short vec_cmpeq (vector bool short, vector bool short);
16187 vector bool int vec_cmpeq (vector bool int, vector bool int);
16188 vector bool char vec_cmpeq (vector signed char, vector signed char);
16189 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16190 vector bool short vec_cmpeq (vector signed short, vector signed short);
16191 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
16192 vector bool int vec_cmpeq (vector signed int, vector signed int);
16193 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16194 vector bool int vec_cmpeq (vector float, vector float);
16196 vector bool int vec_vcmpeqfp (vector float, vector float);
16198 vector bool int vec_vcmpequw (vector signed int, vector signed int);
16199 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
16201 vector bool short vec_vcmpequh (vector signed short, vector signed short);
16202 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
16204 vector bool char vec_vcmpequb (vector signed char, vector signed char);
16205 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
16207 vector bool int vec_cmpge (vector float, vector float);
16209 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16210 vector bool char vec_cmpgt (vector signed char, vector signed char);
16211 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
16212 vector bool short vec_cmpgt (vector signed short, vector signed short);
16213 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16214 vector bool int vec_cmpgt (vector signed int, vector signed int);
16215 vector bool int vec_cmpgt (vector float, vector float);
16217 vector bool int vec_vcmpgtfp (vector float, vector float);
16219 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
16221 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
16223 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
16225 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
16227 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
16229 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
16231 vector bool int vec_cmple (vector float, vector float);
16233 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16234 vector bool char vec_cmplt (vector signed char, vector signed char);
16235 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
16236 vector bool short vec_cmplt (vector signed short, vector signed short);
16237 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16238 vector bool int vec_cmplt (vector signed int, vector signed int);
16239 vector bool int vec_cmplt (vector float, vector float);
16241 vector float vec_cpsgn (vector float, vector float);
16243 vector float vec_ctf (vector unsigned int, const int);
16244 vector float vec_ctf (vector signed int, const int);
16245 vector double vec_ctf (vector unsigned long, const int);
16246 vector double vec_ctf (vector signed long, const int);
16248 vector float vec_vcfsx (vector signed int, const int);
16250 vector float vec_vcfux (vector unsigned int, const int);
16252 vector signed int vec_cts (vector float, const int);
16253 vector signed long vec_cts (vector double, const int);
16255 vector unsigned int vec_ctu (vector float, const int);
16256 vector unsigned long vec_ctu (vector double, const int);
16258 vector double vec_doublee (vector float);
16259 vector double vec_doublee (vector signed int);
16260 vector double vec_doublee (vector unsigned int);
16262 vector double vec_doubleo (vector float);
16263 vector double vec_doubleo (vector signed int);
16264 vector double vec_doubleo (vector unsigned int);
16266 vector double vec_doubleh (vector float);
16267 vector double vec_doubleh (vector signed int);
16268 vector double vec_doubleh (vector unsigned int);
16270 vector double vec_doublel (vector float);
16271 vector double vec_doublel (vector signed int);
16272 vector double vec_doublel (vector unsigned int);
16274 void vec_dss (const int);
16276 void vec_dssall (void);
16278 void vec_dst (const vector unsigned char *, int, const int);
16279 void vec_dst (const vector signed char *, int, const int);
16280 void vec_dst (const vector bool char *, int, const int);
16281 void vec_dst (const vector unsigned short *, int, const int);
16282 void vec_dst (const vector signed short *, int, const int);
16283 void vec_dst (const vector bool short *, int, const int);
16284 void vec_dst (const vector pixel *, int, const int);
16285 void vec_dst (const vector unsigned int *, int, const int);
16286 void vec_dst (const vector signed int *, int, const int);
16287 void vec_dst (const vector bool int *, int, const int);
16288 void vec_dst (const vector float *, int, const int);
16289 void vec_dst (const unsigned char *, int, const int);
16290 void vec_dst (const signed char *, int, const int);
16291 void vec_dst (const unsigned short *, int, const int);
16292 void vec_dst (const short *, int, const int);
16293 void vec_dst (const unsigned int *, int, const int);
16294 void vec_dst (const int *, int, const int);
16295 void vec_dst (const unsigned long *, int, const int);
16296 void vec_dst (const long *, int, const int);
16297 void vec_dst (const float *, int, const int);
16299 void vec_dstst (const vector unsigned char *, int, const int);
16300 void vec_dstst (const vector signed char *, int, const int);
16301 void vec_dstst (const vector bool char *, int, const int);
16302 void vec_dstst (const vector unsigned short *, int, const int);
16303 void vec_dstst (const vector signed short *, int, const int);
16304 void vec_dstst (const vector bool short *, int, const int);
16305 void vec_dstst (const vector pixel *, int, const int);
16306 void vec_dstst (const vector unsigned int *, int, const int);
16307 void vec_dstst (const vector signed int *, int, const int);
16308 void vec_dstst (const vector bool int *, int, const int);
16309 void vec_dstst (const vector float *, int, const int);
16310 void vec_dstst (const unsigned char *, int, const int);
16311 void vec_dstst (const signed char *, int, const int);
16312 void vec_dstst (const unsigned short *, int, const int);
16313 void vec_dstst (const short *, int, const int);
16314 void vec_dstst (const unsigned int *, int, const int);
16315 void vec_dstst (const int *, int, const int);
16316 void vec_dstst (const unsigned long *, int, const int);
16317 void vec_dstst (const long *, int, const int);
16318 void vec_dstst (const float *, int, const int);
16320 void vec_dststt (const vector unsigned char *, int, const int);
16321 void vec_dststt (const vector signed char *, int, const int);
16322 void vec_dststt (const vector bool char *, int, const int);
16323 void vec_dststt (const vector unsigned short *, int, const int);
16324 void vec_dststt (const vector signed short *, int, const int);
16325 void vec_dststt (const vector bool short *, int, const int);
16326 void vec_dststt (const vector pixel *, int, const int);
16327 void vec_dststt (const vector unsigned int *, int, const int);
16328 void vec_dststt (const vector signed int *, int, const int);
16329 void vec_dststt (const vector bool int *, int, const int);
16330 void vec_dststt (const vector float *, int, const int);
16331 void vec_dststt (const unsigned char *, int, const int);
16332 void vec_dststt (const signed char *, int, const int);
16333 void vec_dststt (const unsigned short *, int, const int);
16334 void vec_dststt (const short *, int, const int);
16335 void vec_dststt (const unsigned int *, int, const int);
16336 void vec_dststt (const int *, int, const int);
16337 void vec_dststt (const unsigned long *, int, const int);
16338 void vec_dststt (const long *, int, const int);
16339 void vec_dststt (const float *, int, const int);
16341 void vec_dstt (const vector unsigned char *, int, const int);
16342 void vec_dstt (const vector signed char *, int, const int);
16343 void vec_dstt (const vector bool char *, int, const int);
16344 void vec_dstt (const vector unsigned short *, int, const int);
16345 void vec_dstt (const vector signed short *, int, const int);
16346 void vec_dstt (const vector bool short *, int, const int);
16347 void vec_dstt (const vector pixel *, int, const int);
16348 void vec_dstt (const vector unsigned int *, int, const int);
16349 void vec_dstt (const vector signed int *, int, const int);
16350 void vec_dstt (const vector bool int *, int, const int);
16351 void vec_dstt (const vector float *, int, const int);
16352 void vec_dstt (const unsigned char *, int, const int);
16353 void vec_dstt (const signed char *, int, const int);
16354 void vec_dstt (const unsigned short *, int, const int);
16355 void vec_dstt (const short *, int, const int);
16356 void vec_dstt (const unsigned int *, int, const int);
16357 void vec_dstt (const int *, int, const int);
16358 void vec_dstt (const unsigned long *, int, const int);
16359 void vec_dstt (const long *, int, const int);
16360 void vec_dstt (const float *, int, const int);
16362 vector float vec_expte (vector float);
16364 vector float vec_floor (vector float);
16366 vector float vec_float (vector signed int);
16367 vector float vec_float (vector unsigned int);
16369 vector float vec_float2 (vector signed long long, vector signed long long);
16370 vector float vec_float2 (vector unsigned long long, vector signed long long);
16372 vector float vec_floate (vector double);
16373 vector float vec_floate (vector signed long long);
16374 vector float vec_floate (vector unsigned long long);
16376 vector float vec_floato (vector double);
16377 vector float vec_floato (vector signed long long);
16378 vector float vec_floato (vector unsigned long long);
16380 vector float vec_ld (int, const vector float *);
16381 vector float vec_ld (int, const float *);
16382 vector bool int vec_ld (int, const vector bool int *);
16383 vector signed int vec_ld (int, const vector signed int *);
16384 vector signed int vec_ld (int, const int *);
16385 vector unsigned int vec_ld (int, const vector unsigned int *);
16386 vector unsigned int vec_ld (int, const unsigned int *);
16387 vector bool short vec_ld (int, const vector bool short *);
16388 vector pixel vec_ld (int, const vector pixel *);
16389 vector signed short vec_ld (int, const vector signed short *);
16390 vector signed short vec_ld (int, const short *);
16391 vector unsigned short vec_ld (int, const vector unsigned short *);
16392 vector unsigned short vec_ld (int, const unsigned short *);
16393 vector bool char vec_ld (int, const vector bool char *);
16394 vector signed char vec_ld (int, const vector signed char *);
16395 vector signed char vec_ld (int, const signed char *);
16396 vector unsigned char vec_ld (int, const vector unsigned char *);
16397 vector unsigned char vec_ld (int, const unsigned char *);
16399 vector signed char vec_lde (int, const signed char *);
16400 vector unsigned char vec_lde (int, const unsigned char *);
16401 vector signed short vec_lde (int, const short *);
16402 vector unsigned short vec_lde (int, const unsigned short *);
16403 vector float vec_lde (int, const float *);
16404 vector signed int vec_lde (int, const int *);
16405 vector unsigned int vec_lde (int, const unsigned int *);
16407 vector float vec_lvewx (int, float *);
16408 vector signed int vec_lvewx (int, int *);
16409 vector unsigned int vec_lvewx (int, unsigned int *);
16411 vector signed short vec_lvehx (int, short *);
16412 vector unsigned short vec_lvehx (int, unsigned short *);
16414 vector signed char vec_lvebx (int, char *);
16415 vector unsigned char vec_lvebx (int, unsigned char *);
16417 vector float vec_ldl (int, const vector float *);
16418 vector float vec_ldl (int, const float *);
16419 vector bool int vec_ldl (int, const vector bool int *);
16420 vector signed int vec_ldl (int, const vector signed int *);
16421 vector signed int vec_ldl (int, const int *);
16422 vector unsigned int vec_ldl (int, const vector unsigned int *);
16423 vector unsigned int vec_ldl (int, const unsigned int *);
16424 vector bool short vec_ldl (int, const vector bool short *);
16425 vector pixel vec_ldl (int, const vector pixel *);
16426 vector signed short vec_ldl (int, const vector signed short *);
16427 vector signed short vec_ldl (int, const short *);
16428 vector unsigned short vec_ldl (int, const vector unsigned short *);
16429 vector unsigned short vec_ldl (int, const unsigned short *);
16430 vector bool char vec_ldl (int, const vector bool char *);
16431 vector signed char vec_ldl (int, const vector signed char *);
16432 vector signed char vec_ldl (int, const signed char *);
16433 vector unsigned char vec_ldl (int, const vector unsigned char *);
16434 vector unsigned char vec_ldl (int, const unsigned char *);
16436 vector float vec_loge (vector float);
16438 vector unsigned char vec_lvsl (int, const unsigned char *);
16439 vector unsigned char vec_lvsl (int, const signed char *);
16440 vector unsigned char vec_lvsl (int, const unsigned short *);
16441 vector unsigned char vec_lvsl (int, const short *);
16442 vector unsigned char vec_lvsl (int, const unsigned int *);
16443 vector unsigned char vec_lvsl (int, const int *);
16444 vector unsigned char vec_lvsl (int, const unsigned long *);
16445 vector unsigned char vec_lvsl (int, const long *);
16446 vector unsigned char vec_lvsl (int, const float *);
16448 vector unsigned char vec_lvsr (int, const unsigned char *);
16449 vector unsigned char vec_lvsr (int, const signed char *);
16450 vector unsigned char vec_lvsr (int, const unsigned short *);
16451 vector unsigned char vec_lvsr (int, const short *);
16452 vector unsigned char vec_lvsr (int, const unsigned int *);
16453 vector unsigned char vec_lvsr (int, const int *);
16454 vector unsigned char vec_lvsr (int, const unsigned long *);
16455 vector unsigned char vec_lvsr (int, const long *);
16456 vector unsigned char vec_lvsr (int, const float *);
16458 vector float vec_madd (vector float, vector float, vector float);
16460 vector signed short vec_madds (vector signed short, vector signed short,
16461                                vector signed short);
16463 vector unsigned char vec_max (vector bool char, vector unsigned char);
16464 vector unsigned char vec_max (vector unsigned char, vector bool char);
16465 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
16466 vector signed char vec_max (vector bool char, vector signed char);
16467 vector signed char vec_max (vector signed char, vector bool char);
16468 vector signed char vec_max (vector signed char, vector signed char);
16469 vector unsigned short vec_max (vector bool short, vector unsigned short);
16470 vector unsigned short vec_max (vector unsigned short, vector bool short);
16471 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
16472 vector signed short vec_max (vector bool short, vector signed short);
16473 vector signed short vec_max (vector signed short, vector bool short);
16474 vector signed short vec_max (vector signed short, vector signed short);
16475 vector unsigned int vec_max (vector bool int, vector unsigned int);
16476 vector unsigned int vec_max (vector unsigned int, vector bool int);
16477 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16478 vector signed int vec_max (vector bool int, vector signed int);
16479 vector signed int vec_max (vector signed int, vector bool int);
16480 vector signed int vec_max (vector signed int, vector signed int);
16481 vector float vec_max (vector float, vector float);
16483 vector float vec_vmaxfp (vector float, vector float);
16485 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16486 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16487 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16489 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16490 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16491 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
16493 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16494 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16495 vector signed short vec_vmaxsh (vector signed short, vector signed short);
16497 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
16498 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
16499 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
16501 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16502 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16503 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16505 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
16506 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
16507 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
16509 vector bool char vec_mergeh (vector bool char, vector bool char);
16510 vector signed char vec_mergeh (vector signed char, vector signed char);
16511 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
16512 vector bool short vec_mergeh (vector bool short, vector bool short);
16513 vector pixel vec_mergeh (vector pixel, vector pixel);
16514 vector signed short vec_mergeh (vector signed short, vector signed short);
16515 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
16516 vector float vec_mergeh (vector float, vector float);
16517 vector bool int vec_mergeh (vector bool int, vector bool int);
16518 vector signed int vec_mergeh (vector signed int, vector signed int);
16519 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
16521 vector float vec_vmrghw (vector float, vector float);
16522 vector bool int vec_vmrghw (vector bool int, vector bool int);
16523 vector signed int vec_vmrghw (vector signed int, vector signed int);
16524 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
16526 vector bool short vec_vmrghh (vector bool short, vector bool short);
16527 vector signed short vec_vmrghh (vector signed short, vector signed short);
16528 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
16529 vector pixel vec_vmrghh (vector pixel, vector pixel);
16531 vector bool char vec_vmrghb (vector bool char, vector bool char);
16532 vector signed char vec_vmrghb (vector signed char, vector signed char);
16533 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
16535 vector bool char vec_mergel (vector bool char, vector bool char);
16536 vector signed char vec_mergel (vector signed char, vector signed char);
16537 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
16538 vector bool short vec_mergel (vector bool short, vector bool short);
16539 vector pixel vec_mergel (vector pixel, vector pixel);
16540 vector signed short vec_mergel (vector signed short, vector signed short);
16541 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
16542 vector float vec_mergel (vector float, vector float);
16543 vector bool int vec_mergel (vector bool int, vector bool int);
16544 vector signed int vec_mergel (vector signed int, vector signed int);
16545 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
16547 vector float vec_vmrglw (vector float, vector float);
16548 vector signed int vec_vmrglw (vector signed int, vector signed int);
16549 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
16550 vector bool int vec_vmrglw (vector bool int, vector bool int);
16552 vector bool short vec_vmrglh (vector bool short, vector bool short);
16553 vector signed short vec_vmrglh (vector signed short, vector signed short);
16554 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
16555 vector pixel vec_vmrglh (vector pixel, vector pixel);
16557 vector bool char vec_vmrglb (vector bool char, vector bool char);
16558 vector signed char vec_vmrglb (vector signed char, vector signed char);
16559 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
16561 vector unsigned short vec_mfvscr (void);
16563 vector unsigned char vec_min (vector bool char, vector unsigned char);
16564 vector unsigned char vec_min (vector unsigned char, vector bool char);
16565 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
16566 vector signed char vec_min (vector bool char, vector signed char);
16567 vector signed char vec_min (vector signed char, vector bool char);
16568 vector signed char vec_min (vector signed char, vector signed char);
16569 vector unsigned short vec_min (vector bool short, vector unsigned short);
16570 vector unsigned short vec_min (vector unsigned short, vector bool short);
16571 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
16572 vector signed short vec_min (vector bool short, vector signed short);
16573 vector signed short vec_min (vector signed short, vector bool short);
16574 vector signed short vec_min (vector signed short, vector signed short);
16575 vector unsigned int vec_min (vector bool int, vector unsigned int);
16576 vector unsigned int vec_min (vector unsigned int, vector bool int);
16577 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16578 vector signed int vec_min (vector bool int, vector signed int);
16579 vector signed int vec_min (vector signed int, vector bool int);
16580 vector signed int vec_min (vector signed int, vector signed int);
16581 vector float vec_min (vector float, vector float);
16583 vector float vec_vminfp (vector float, vector float);
16585 vector signed int vec_vminsw (vector bool int, vector signed int);
16586 vector signed int vec_vminsw (vector signed int, vector bool int);
16587 vector signed int vec_vminsw (vector signed int, vector signed int);
16589 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16590 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16591 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
16593 vector signed short vec_vminsh (vector bool short, vector signed short);
16594 vector signed short vec_vminsh (vector signed short, vector bool short);
16595 vector signed short vec_vminsh (vector signed short, vector signed short);
16597 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
16598 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
16599 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
16601 vector signed char vec_vminsb (vector bool char, vector signed char);
16602 vector signed char vec_vminsb (vector signed char, vector bool char);
16603 vector signed char vec_vminsb (vector signed char, vector signed char);
16605 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
16606 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
16607 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
16609 vector signed short vec_mladd (vector signed short, vector signed short,
16610                                vector signed short);
16611 vector signed short vec_mladd (vector signed short, vector unsigned short,
16612                                vector unsigned short);
16613 vector signed short vec_mladd (vector unsigned short, vector signed short,
16614                                vector signed short);
16615 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
16616                                  vector unsigned short);
16618 vector signed short vec_mradds (vector signed short, vector signed short,
16619                                 vector signed short);
16621 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
16622                               vector unsigned int);
16623 vector signed int vec_msum (vector signed char, vector unsigned char,
16624                             vector signed int);
16625 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
16626                               vector unsigned int);
16627 vector signed int vec_msum (vector signed short, vector signed short,
16628                             vector signed int);
16630 vector signed int vec_vmsumshm (vector signed short, vector signed short,
16631                                 vector signed int);
16633 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
16634                                   vector unsigned int);
16636 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
16637                                 vector signed int);
16639 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
16640                                   vector unsigned int);
16642 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
16643                                vector unsigned int);
16644 vector signed int vec_msums (vector signed short, vector signed short,
16645                              vector signed int);
16647 vector signed int vec_vmsumshs (vector signed short, vector signed short,
16648                                 vector signed int);
16650 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
16651                                   vector unsigned int);
16653 void vec_mtvscr (vector signed int);
16654 void vec_mtvscr (vector unsigned int);
16655 void vec_mtvscr (vector bool int);
16656 void vec_mtvscr (vector signed short);
16657 void vec_mtvscr (vector unsigned short);
16658 void vec_mtvscr (vector bool short);
16659 void vec_mtvscr (vector pixel);
16660 void vec_mtvscr (vector signed char);
16661 void vec_mtvscr (vector unsigned char);
16662 void vec_mtvscr (vector bool char);
16664 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
16665 vector signed short vec_mule (vector signed char, vector signed char);
16666 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
16667 vector signed int vec_mule (vector signed short, vector signed short);
16668 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
16669 vector signed long long vec_mule (vector signed int, vector signed int);
16671 vector signed int vec_vmulesh (vector signed short, vector signed short);
16673 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
16675 vector signed short vec_vmulesb (vector signed char, vector signed char);
16677 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
16679 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
16680 vector signed short vec_mulo (vector signed char, vector signed char);
16681 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
16682 vector signed int vec_mulo (vector signed short, vector signed short);
16683 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
16684 vector signed long long vec_mulo (vector signed int, vector signed int);
16686 vector signed int vec_vmulosh (vector signed short, vector signed short);
16688 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
16690 vector signed short vec_vmulosb (vector signed char, vector signed char);
16692 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
16694 vector float vec_nmsub (vector float, vector float, vector float);
16696 vector signed char vec_nabs (vector signed char);
16697 vector signed short vec_nabs (vector signed short);
16698 vector signed int vec_nabs (vector signed int);
16699 vector float vec_nabs (vector float);
16700 vector double vec_nabs (vector double);
16702 vector signed char vec_neg (vector signed char);
16703 vector signed short vec_neg (vector signed short);
16704 vector signed int vec_neg (vector signed int);
16705 vector signed long long vec_neg (vector signed long long);
16706 vector float  char vec_neg (vector float);
16707 vector double vec_neg (vector double);
16709 vector float vec_nor (vector float, vector float);
16710 vector signed int vec_nor (vector signed int, vector signed int);
16711 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16712 vector bool int vec_nor (vector bool int, vector bool int);
16713 vector signed short vec_nor (vector signed short, vector signed short);
16714 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
16715 vector bool short vec_nor (vector bool short, vector bool short);
16716 vector signed char vec_nor (vector signed char, vector signed char);
16717 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
16718 vector bool char vec_nor (vector bool char, vector bool char);
16720 vector float vec_or (vector float, vector float);
16721 vector float vec_or (vector float, vector bool int);
16722 vector float vec_or (vector bool int, vector float);
16723 vector bool int vec_or (vector bool int, vector bool int);
16724 vector signed int vec_or (vector bool int, vector signed int);
16725 vector signed int vec_or (vector signed int, vector bool int);
16726 vector signed int vec_or (vector signed int, vector signed int);
16727 vector unsigned int vec_or (vector bool int, vector unsigned int);
16728 vector unsigned int vec_or (vector unsigned int, vector bool int);
16729 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16730 vector bool short vec_or (vector bool short, vector bool short);
16731 vector signed short vec_or (vector bool short, vector signed short);
16732 vector signed short vec_or (vector signed short, vector bool short);
16733 vector signed short vec_or (vector signed short, vector signed short);
16734 vector unsigned short vec_or (vector bool short, vector unsigned short);
16735 vector unsigned short vec_or (vector unsigned short, vector bool short);
16736 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
16737 vector signed char vec_or (vector bool char, vector signed char);
16738 vector bool char vec_or (vector bool char, vector bool char);
16739 vector signed char vec_or (vector signed char, vector bool char);
16740 vector signed char vec_or (vector signed char, vector signed char);
16741 vector unsigned char vec_or (vector bool char, vector unsigned char);
16742 vector unsigned char vec_or (vector unsigned char, vector bool char);
16743 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
16745 vector signed char vec_pack (vector signed short, vector signed short);
16746 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
16747 vector bool char vec_pack (vector bool short, vector bool short);
16748 vector signed short vec_pack (vector signed int, vector signed int);
16749 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
16750 vector bool short vec_pack (vector bool int, vector bool int);
16752 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16753 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16754 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
16756 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16757 vector signed char vec_vpkuhum (vector signed short, vector signed short);
16758 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
16760 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16762 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
16763 vector signed char vec_packs (vector signed short, vector signed short);
16764 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
16765 vector signed short vec_packs (vector signed int, vector signed int);
16767 vector signed short vec_vpkswss (vector signed int, vector signed int);
16769 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
16771 vector signed char vec_vpkshss (vector signed short, vector signed short);
16773 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
16775 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
16776 vector unsigned char vec_packsu (vector signed short, vector signed short);
16777 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
16778 vector unsigned short vec_packsu (vector signed int, vector signed int);
16780 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
16782 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
16784 vector float vec_perm (vector float, vector float, vector unsigned char);
16785 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
16786 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
16787                               vector unsigned char);
16788 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
16789 vector signed short vec_perm (vector signed short, vector signed short,
16790                               vector unsigned char);
16791 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
16792                                 vector unsigned char);
16793 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
16794 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
16795 vector signed char vec_perm (vector signed char, vector signed char,
16796                              vector unsigned char);
16797 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
16798                                vector unsigned char);
16799 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
16801 vector float vec_re (vector float);
16803 vector bool char vec_reve (vector bool char);
16804 vector signed char vec_reve (vector signed char);
16805 vector unsigned char vec_reve (vector unsigned char);
16806 vector bool int vec_reve (vector bool int);
16807 vector signed int vec_reve (vector signed int);
16808 vector unsigned int vec_reve (vector unsigned int);
16809 vector bool long long vec_reve (vector bool long long);
16810 vector signed long long vec_reve (vector signed long long);
16811 vector unsigned long long vec_reve (vector unsigned long long);
16812 vector bool short vec_reve (vector bool short);
16813 vector signed short vec_reve (vector signed short);
16814 vector unsigned short vec_reve (vector unsigned short);
16816 vector signed char vec_rl (vector signed char, vector unsigned char);
16817 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
16818 vector signed short vec_rl (vector signed short, vector unsigned short);
16819 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
16820 vector signed int vec_rl (vector signed int, vector unsigned int);
16821 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16823 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16824 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16826 vector signed short vec_vrlh (vector signed short, vector unsigned short);
16827 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
16829 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16830 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
16832 vector float vec_round (vector float);
16834 vector float vec_rsqrt (vector float);
16836 vector float vec_rsqrte (vector float);
16838 vector float vec_sel (vector float, vector float, vector bool int);
16839 vector float vec_sel (vector float, vector float, vector unsigned int);
16840 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
16841 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
16842 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
16843 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
16844                              vector unsigned int);
16845 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
16846 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
16847 vector signed short vec_sel (vector signed short, vector signed short,
16848                              vector bool short);
16849 vector signed short vec_sel (vector signed short, vector signed short,
16850                              vector unsigned short);
16851 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
16852                                vector bool short);
16853 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
16854                                vector unsigned short);
16855 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
16856 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
16857 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
16858 vector signed char vec_sel (vector signed char, vector signed char,
16859                             vector unsigned char);
16860 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
16861                               vector bool char);
16862 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
16863                               vector unsigned char);
16864 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
16865 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
16867 vector signed long long vec_signed (vector double);
16868 vector signed int vec_signed (vector float);
16870 vector signed int vec_signede (vector double);
16871 vector signed int vec_signedo (vector double);
16872 vector signed int vec_signed2 (vector double, vector double);
16874 vector signed char vec_sl (vector signed char, vector unsigned char);
16875 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
16876 vector signed short vec_sl (vector signed short, vector unsigned short);
16877 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
16878 vector signed int vec_sl (vector signed int, vector unsigned int);
16879 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16881 vector signed int vec_vslw (vector signed int, vector unsigned int);
16882 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16884 vector signed short vec_vslh (vector signed short, vector unsigned short);
16885 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
16887 vector signed char vec_vslb (vector signed char, vector unsigned char);
16888 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
16890 vector float vec_sld (vector float, vector float, const int);
16891 vector double vec_sld (vector double, vector double, const int);
16893 vector signed int vec_sld (vector signed int, vector signed int, const int);
16894 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
16895 vector bool int vec_sld (vector bool int, vector bool int, const int);
16896 vector signed short vec_sld (vector signed short, vector signed short, const int);
16897 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
16898 vector bool short vec_sld (vector bool short, vector bool short, const int);
16899 vector pixel vec_sld (vector pixel, vector pixel, const int);
16900 vector signed char vec_sld (vector signed char, vector signed char, const int);
16901 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
16902 vector bool char vec_sld (vector bool char, vector bool char, const int);
16903 vector bool long long int vec_sld (vector bool long long int,
16904                                    vector bool long long int, const int);
16905 vector long long int vec_sld (vector long long int, vector  long long int, const int);
16906 vector unsigned long long int vec_sld (vector unsigned long long int,
16907                                        vector unsigned long long int, const int);
16909 vector signed char vec_sldw (vector signed char, vector signed char, const int);
16910 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
16911 vector signed short vec_sldw (vector signed short, vector signed short, const int);
16912 vector unsigned short vec_sldw (vector unsigned short,
16913                                 vector unsigned short, const int);
16914 vector signed int vec_sldw (vector signed int, vector signed int, const int);
16915 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
16916 vector signed long long vec_sldw (vector signed long long,
16917                                   vector signed long long, const int);
16918 vector unsigned long long vec_sldw (vector unsigned long long,
16919                                     vector unsigned long long, const int);
16921 vector signed int vec_sll (vector signed int, vector unsigned int);
16922 vector signed int vec_sll (vector signed int, vector unsigned short);
16923 vector signed int vec_sll (vector signed int, vector unsigned char);
16924 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
16925 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
16926 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
16927 vector bool int vec_sll (vector bool int, vector unsigned int);
16928 vector bool int vec_sll (vector bool int, vector unsigned short);
16929 vector bool int vec_sll (vector bool int, vector unsigned char);
16930 vector signed short vec_sll (vector signed short, vector unsigned int);
16931 vector signed short vec_sll (vector signed short, vector unsigned short);
16932 vector signed short vec_sll (vector signed short, vector unsigned char);
16933 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
16934 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
16935 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
16936 vector long long int vec_sll (vector long long int, vector unsigned char);
16937 vector unsigned long long int vec_sll (vector unsigned long long int,
16938                                        vector unsigned char);
16939 vector bool short vec_sll (vector bool short, vector unsigned int);
16940 vector bool short vec_sll (vector bool short, vector unsigned short);
16941 vector bool short vec_sll (vector bool short, vector unsigned char);
16942 vector pixel vec_sll (vector pixel, vector unsigned int);
16943 vector pixel vec_sll (vector pixel, vector unsigned short);
16944 vector pixel vec_sll (vector pixel, vector unsigned char);
16945 vector signed char vec_sll (vector signed char, vector unsigned int);
16946 vector signed char vec_sll (vector signed char, vector unsigned short);
16947 vector signed char vec_sll (vector signed char, vector unsigned char);
16948 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
16949 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
16950 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
16951 vector bool char vec_sll (vector bool char, vector unsigned int);
16952 vector bool char vec_sll (vector bool char, vector unsigned short);
16953 vector bool char vec_sll (vector bool char, vector unsigned char);
16955 vector float vec_slo (vector float, vector signed char);
16956 vector float vec_slo (vector float, vector unsigned char);
16957 vector signed int vec_slo (vector signed int, vector signed char);
16958 vector signed int vec_slo (vector signed int, vector unsigned char);
16959 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16960 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16961 vector signed short vec_slo (vector signed short, vector signed char);
16962 vector signed short vec_slo (vector signed short, vector unsigned char);
16963 vector unsigned short vec_slo (vector unsigned short, vector signed char);
16964 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
16965 vector pixel vec_slo (vector pixel, vector signed char);
16966 vector pixel vec_slo (vector pixel, vector unsigned char);
16967 vector signed char vec_slo (vector signed char, vector signed char);
16968 vector signed char vec_slo (vector signed char, vector unsigned char);
16969 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16970 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
16971 vector signed long long vec_slo (vector signed long long, vector signed char);
16972 vector signed long long vec_slo (vector signed long long, vector unsigned char);
16973 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
16974 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
16976 vector signed char vec_splat (vector signed char, const int);
16977 vector unsigned char vec_splat (vector unsigned char, const int);
16978 vector bool char vec_splat (vector bool char, const int);
16979 vector signed short vec_splat (vector signed short, const int);
16980 vector unsigned short vec_splat (vector unsigned short, const int);
16981 vector bool short vec_splat (vector bool short, const int);
16982 vector pixel vec_splat (vector pixel, const int);
16983 vector float vec_splat (vector float, const int);
16984 vector signed int vec_splat (vector signed int, const int);
16985 vector unsigned int vec_splat (vector unsigned int, const int);
16986 vector bool int vec_splat (vector bool int, const int);
16987 vector signed long vec_splat (vector signed long, const int);
16988 vector unsigned long vec_splat (vector unsigned long, const int);
16990 vector signed char vec_splats (signed char);
16991 vector unsigned char vec_splats (unsigned char);
16992 vector signed short vec_splats (signed short);
16993 vector unsigned short vec_splats (unsigned short);
16994 vector signed int vec_splats (signed int);
16995 vector unsigned int vec_splats (unsigned int);
16996 vector float vec_splats (float);
16998 vector float vec_vspltw (vector float, const int);
16999 vector signed int vec_vspltw (vector signed int, const int);
17000 vector unsigned int vec_vspltw (vector unsigned int, const int);
17001 vector bool int vec_vspltw (vector bool int, const int);
17003 vector bool short vec_vsplth (vector bool short, const int);
17004 vector signed short vec_vsplth (vector signed short, const int);
17005 vector unsigned short vec_vsplth (vector unsigned short, const int);
17006 vector pixel vec_vsplth (vector pixel, const int);
17008 vector signed char vec_vspltb (vector signed char, const int);
17009 vector unsigned char vec_vspltb (vector unsigned char, const int);
17010 vector bool char vec_vspltb (vector bool char, const int);
17012 vector signed char vec_splat_s8 (const int);
17014 vector signed short vec_splat_s16 (const int);
17016 vector signed int vec_splat_s32 (const int);
17018 vector unsigned char vec_splat_u8 (const int);
17020 vector unsigned short vec_splat_u16 (const int);
17022 vector unsigned int vec_splat_u32 (const int);
17024 vector signed char vec_sr (vector signed char, vector unsigned char);
17025 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
17026 vector signed short vec_sr (vector signed short, vector unsigned short);
17027 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
17028 vector signed int vec_sr (vector signed int, vector unsigned int);
17029 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17031 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17032 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17034 vector signed short vec_vsrh (vector signed short, vector unsigned short);
17035 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
17037 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17038 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
17040 vector signed char vec_sra (vector signed char, vector unsigned char);
17041 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
17042 vector signed short vec_sra (vector signed short, vector unsigned short);
17043 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
17044 vector signed int vec_sra (vector signed int, vector unsigned int);
17045 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17047 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17048 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
17050 vector signed short vec_vsrah (vector signed short, vector unsigned short);
17051 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
17053 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17054 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
17056 vector signed int vec_srl (vector signed int, vector unsigned int);
17057 vector signed int vec_srl (vector signed int, vector unsigned short);
17058 vector signed int vec_srl (vector signed int, vector unsigned char);
17059 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17060 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
17061 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17062 vector bool int vec_srl (vector bool int, vector unsigned int);
17063 vector bool int vec_srl (vector bool int, vector unsigned short);
17064 vector bool int vec_srl (vector bool int, vector unsigned char);
17065 vector signed short vec_srl (vector signed short, vector unsigned int);
17066 vector signed short vec_srl (vector signed short, vector unsigned short);
17067 vector signed short vec_srl (vector signed short, vector unsigned char);
17068 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
17069 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
17070 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
17071 vector long long int vec_srl (vector long long int, vector unsigned char);
17072 vector unsigned long long int vec_srl (vector unsigned long long int,
17073                                        vector unsigned char);
17074 vector bool short vec_srl (vector bool short, vector unsigned int);
17075 vector bool short vec_srl (vector bool short, vector unsigned short);
17076 vector bool short vec_srl (vector bool short, vector unsigned char);
17077 vector pixel vec_srl (vector pixel, vector unsigned int);
17078 vector pixel vec_srl (vector pixel, vector unsigned short);
17079 vector pixel vec_srl (vector pixel, vector unsigned char);
17080 vector signed char vec_srl (vector signed char, vector unsigned int);
17081 vector signed char vec_srl (vector signed char, vector unsigned short);
17082 vector signed char vec_srl (vector signed char, vector unsigned char);
17083 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
17084 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
17085 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
17086 vector bool char vec_srl (vector bool char, vector unsigned int);
17087 vector bool char vec_srl (vector bool char, vector unsigned short);
17088 vector bool char vec_srl (vector bool char, vector unsigned char);
17090 vector float vec_sro (vector float, vector signed char);
17091 vector float vec_sro (vector float, vector unsigned char);
17092 vector signed int vec_sro (vector signed int, vector signed char);
17093 vector signed int vec_sro (vector signed int, vector unsigned char);
17094 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17095 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17096 vector signed short vec_sro (vector signed short, vector signed char);
17097 vector signed short vec_sro (vector signed short, vector unsigned char);
17098 vector unsigned short vec_sro (vector unsigned short, vector signed char);
17099 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
17100 vector long long int vec_sro (vector long long int, vector char);
17101 vector long long int vec_sro (vector long long int, vector unsigned char);
17102 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
17103 vector unsigned long long int vec_sro (vector unsigned long long int,
17104                                        vector unsigned char);
17105 vector pixel vec_sro (vector pixel, vector signed char);
17106 vector pixel vec_sro (vector pixel, vector unsigned char);
17107 vector signed char vec_sro (vector signed char, vector signed char);
17108 vector signed char vec_sro (vector signed char, vector unsigned char);
17109 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17110 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
17112 void vec_st (vector float, int, vector float *);
17113 void vec_st (vector float, int, float *);
17114 void vec_st (vector signed int, int, vector signed int *);
17115 void vec_st (vector signed int, int, int *);
17116 void vec_st (vector unsigned int, int, vector unsigned int *);
17117 void vec_st (vector unsigned int, int, unsigned int *);
17118 void vec_st (vector bool int, int, vector bool int *);
17119 void vec_st (vector bool int, int, unsigned int *);
17120 void vec_st (vector bool int, int, int *);
17121 void vec_st (vector signed short, int, vector signed short *);
17122 void vec_st (vector signed short, int, short *);
17123 void vec_st (vector unsigned short, int, vector unsigned short *);
17124 void vec_st (vector unsigned short, int, unsigned short *);
17125 void vec_st (vector bool short, int, vector bool short *);
17126 void vec_st (vector bool short, int, unsigned short *);
17127 void vec_st (vector pixel, int, vector pixel *);
17128 void vec_st (vector bool short, int, short *);
17129 void vec_st (vector signed char, int, vector signed char *);
17130 void vec_st (vector signed char, int, signed char *);
17131 void vec_st (vector unsigned char, int, vector unsigned char *);
17132 void vec_st (vector unsigned char, int, unsigned char *);
17133 void vec_st (vector bool char, int, vector bool char *);
17134 void vec_st (vector bool char, int, unsigned char *);
17135 void vec_st (vector bool char, int, signed char *);
17137 void vec_ste (vector signed char, int, signed char *);
17138 void vec_ste (vector unsigned char, int, unsigned char *);
17139 void vec_ste (vector bool char, int, signed char *);
17140 void vec_ste (vector bool char, int, unsigned char *);
17141 void vec_ste (vector signed short, int, short *);
17142 void vec_ste (vector unsigned short, int, unsigned short *);
17143 void vec_ste (vector bool short, int, short *);
17144 void vec_ste (vector bool short, int, unsigned short *);
17145 void vec_ste (vector pixel, int, short *);
17146 void vec_ste (vector pixel, int, unsigned short *);
17147 void vec_ste (vector float, int, float *);
17148 void vec_ste (vector signed int, int, int *);
17149 void vec_ste (vector unsigned int, int, unsigned int *);
17150 void vec_ste (vector bool int, int, int *);
17151 void vec_ste (vector bool int, int, unsigned int *);
17153 void vec_stvewx (vector float, int, float *);
17154 void vec_stvewx (vector signed int, int, int *);
17155 void vec_stvewx (vector unsigned int, int, unsigned int *);
17156 void vec_stvewx (vector bool int, int, int *);
17157 void vec_stvewx (vector bool int, int, unsigned int *);
17159 void vec_stvehx (vector signed short, int, short *);
17160 void vec_stvehx (vector unsigned short, int, unsigned short *);
17161 void vec_stvehx (vector bool short, int, short *);
17162 void vec_stvehx (vector bool short, int, unsigned short *);
17164 void vec_stvebx (vector signed char, int, signed char *);
17165 void vec_stvebx (vector unsigned char, int, unsigned char *);
17166 void vec_stvebx (vector bool char, int, signed char *);
17167 void vec_stvebx (vector bool char, int, unsigned char *);
17169 void vec_stl (vector float, int, vector float *);
17170 void vec_stl (vector float, int, float *);
17171 void vec_stl (vector signed int, int, vector signed int *);
17172 void vec_stl (vector signed int, int, int *);
17173 void vec_stl (vector unsigned int, int, vector unsigned int *);
17174 void vec_stl (vector unsigned int, int, unsigned int *);
17175 void vec_stl (vector bool int, int, vector bool int *);
17176 void vec_stl (vector bool int, int, unsigned int *);
17177 void vec_stl (vector bool int, int, int *);
17178 void vec_stl (vector signed short, int, vector signed short *);
17179 void vec_stl (vector signed short, int, short *);
17180 void vec_stl (vector unsigned short, int, vector unsigned short *);
17181 void vec_stl (vector unsigned short, int, unsigned short *);
17182 void vec_stl (vector bool short, int, vector bool short *);
17183 void vec_stl (vector bool short, int, unsigned short *);
17184 void vec_stl (vector bool short, int, short *);
17185 void vec_stl (vector pixel, int, vector pixel *);
17186 void vec_stl (vector signed char, int, vector signed char *);
17187 void vec_stl (vector signed char, int, signed char *);
17188 void vec_stl (vector unsigned char, int, vector unsigned char *);
17189 void vec_stl (vector unsigned char, int, unsigned char *);
17190 void vec_stl (vector bool char, int, vector bool char *);
17191 void vec_stl (vector bool char, int, unsigned char *);
17192 void vec_stl (vector bool char, int, signed char *);
17194 vector signed char vec_sub (vector bool char, vector signed char);
17195 vector signed char vec_sub (vector signed char, vector bool char);
17196 vector signed char vec_sub (vector signed char, vector signed char);
17197 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17198 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17199 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
17200 vector signed short vec_sub (vector bool short, vector signed short);
17201 vector signed short vec_sub (vector signed short, vector bool short);
17202 vector signed short vec_sub (vector signed short, vector signed short);
17203 vector unsigned short vec_sub (vector bool short, vector unsigned short);
17204 vector unsigned short vec_sub (vector unsigned short, vector bool short);
17205 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
17206 vector signed int vec_sub (vector bool int, vector signed int);
17207 vector signed int vec_sub (vector signed int, vector bool int);
17208 vector signed int vec_sub (vector signed int, vector signed int);
17209 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17210 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17211 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17212 vector float vec_sub (vector float, vector float);
17214 vector float vec_vsubfp (vector float, vector float);
17216 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17217 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17218 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17219 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17220 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17221 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
17223 vector signed short vec_vsubuhm (vector bool short, vector signed short);
17224 vector signed short vec_vsubuhm (vector signed short, vector bool short);
17225 vector signed short vec_vsubuhm (vector signed short, vector signed short);
17226 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
17227 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
17228 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
17230 vector signed char vec_vsububm (vector bool char, vector signed char);
17231 vector signed char vec_vsububm (vector signed char, vector bool char);
17232 vector signed char vec_vsububm (vector signed char, vector signed char);
17233 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
17234 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
17235 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
17237 vector signed int vec_subc (vector signed int, vector signed int);
17238 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17239 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
17240 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
17242 vector signed int vec_sube (vector signed int, vector signed int,
17243                             vector signed int);
17244 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17245                               vector unsigned int);
17246 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
17247                                  vector signed __int128);
17248 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
17249                                    vector unsigned __int128);
17251 vector signed int vec_subec (vector signed int, vector signed int,
17252                              vector signed int);
17253 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17254                                vector unsigned int);
17255 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
17256                                   vector signed __int128);
17257 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
17258                                     vector unsigned __int128);
17260 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17261 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17262 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
17263 vector signed char vec_subs (vector bool char, vector signed char);
17264 vector signed char vec_subs (vector signed char, vector bool char);
17265 vector signed char vec_subs (vector signed char, vector signed char);
17266 vector unsigned short vec_subs (vector bool short, vector unsigned short);
17267 vector unsigned short vec_subs (vector unsigned short, vector bool short);
17268 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
17269 vector signed short vec_subs (vector bool short, vector signed short);
17270 vector signed short vec_subs (vector signed short, vector bool short);
17271 vector signed short vec_subs (vector signed short, vector signed short);
17272 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17273 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17274 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17275 vector signed int vec_subs (vector bool int, vector signed int);
17276 vector signed int vec_subs (vector signed int, vector bool int);
17277 vector signed int vec_subs (vector signed int, vector signed int);
17279 vector signed int vec_vsubsws (vector bool int, vector signed int);
17280 vector signed int vec_vsubsws (vector signed int, vector bool int);
17281 vector signed int vec_vsubsws (vector signed int, vector signed int);
17283 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17284 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17285 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
17287 vector signed short vec_vsubshs (vector bool short, vector signed short);
17288 vector signed short vec_vsubshs (vector signed short, vector bool short);
17289 vector signed short vec_vsubshs (vector signed short, vector signed short);
17291 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
17292 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
17293 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
17295 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17296 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17297 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17299 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
17300 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
17301 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
17303 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
17304 vector signed int vec_sum4s (vector signed char, vector signed int);
17305 vector signed int vec_sum4s (vector signed short, vector signed int);
17307 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17309 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17311 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
17313 vector signed int vec_sum2s (vector signed int, vector signed int);
17315 vector signed int vec_sums (vector signed int, vector signed int);
17317 vector float vec_trunc (vector float);
17319 vector signed long long vec_unsigned (vector double);
17320 vector signed int vec_unsigned (vector float);
17322 vector signed int vec_unsignede (vector double);
17323 vector signed int vec_unsignedo (vector double);
17324 vector signed int vec_unsigned2 (vector double, vector double);
17326 vector signed short vec_unpackh (vector signed char);
17327 vector bool short vec_unpackh (vector bool char);
17328 vector signed int vec_unpackh (vector signed short);
17329 vector bool int vec_unpackh (vector bool short);
17330 vector unsigned int vec_unpackh (vector pixel);
17331 vector double vec_unpackh (vector float);
17333 vector bool int vec_vupkhsh (vector bool short);
17334 vector signed int vec_vupkhsh (vector signed short);
17336 vector unsigned int vec_vupkhpx (vector pixel);
17338 vector bool short vec_vupkhsb (vector bool char);
17339 vector signed short vec_vupkhsb (vector signed char);
17341 vector signed short vec_unpackl (vector signed char);
17342 vector bool short vec_unpackl (vector bool char);
17343 vector unsigned int vec_unpackl (vector pixel);
17344 vector signed int vec_unpackl (vector signed short);
17345 vector bool int vec_unpackl (vector bool short);
17346 vector double vec_unpackl (vector float);
17348 vector unsigned int vec_vupklpx (vector pixel);
17350 vector bool int vec_vupklsh (vector bool short);
17351 vector signed int vec_vupklsh (vector signed short);
17353 vector bool short vec_vupklsb (vector bool char);
17354 vector signed short vec_vupklsb (vector signed char);
17356 vector float vec_xor (vector float, vector float);
17357 vector float vec_xor (vector float, vector bool int);
17358 vector float vec_xor (vector bool int, vector float);
17359 vector bool int vec_xor (vector bool int, vector bool int);
17360 vector signed int vec_xor (vector bool int, vector signed int);
17361 vector signed int vec_xor (vector signed int, vector bool int);
17362 vector signed int vec_xor (vector signed int, vector signed int);
17363 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17364 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17365 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17366 vector bool short vec_xor (vector bool short, vector bool short);
17367 vector signed short vec_xor (vector bool short, vector signed short);
17368 vector signed short vec_xor (vector signed short, vector bool short);
17369 vector signed short vec_xor (vector signed short, vector signed short);
17370 vector unsigned short vec_xor (vector bool short, vector unsigned short);
17371 vector unsigned short vec_xor (vector unsigned short, vector bool short);
17372 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
17373 vector signed char vec_xor (vector bool char, vector signed char);
17374 vector bool char vec_xor (vector bool char, vector bool char);
17375 vector signed char vec_xor (vector signed char, vector bool char);
17376 vector signed char vec_xor (vector signed char, vector signed char);
17377 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17378 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17379 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
17381 int vec_all_eq (vector signed char, vector bool char);
17382 int vec_all_eq (vector signed char, vector signed char);
17383 int vec_all_eq (vector unsigned char, vector bool char);
17384 int vec_all_eq (vector unsigned char, vector unsigned char);
17385 int vec_all_eq (vector bool char, vector bool char);
17386 int vec_all_eq (vector bool char, vector unsigned char);
17387 int vec_all_eq (vector bool char, vector signed char);
17388 int vec_all_eq (vector signed short, vector bool short);
17389 int vec_all_eq (vector signed short, vector signed short);
17390 int vec_all_eq (vector unsigned short, vector bool short);
17391 int vec_all_eq (vector unsigned short, vector unsigned short);
17392 int vec_all_eq (vector bool short, vector bool short);
17393 int vec_all_eq (vector bool short, vector unsigned short);
17394 int vec_all_eq (vector bool short, vector signed short);
17395 int vec_all_eq (vector pixel, vector pixel);
17396 int vec_all_eq (vector signed int, vector bool int);
17397 int vec_all_eq (vector signed int, vector signed int);
17398 int vec_all_eq (vector unsigned int, vector bool int);
17399 int vec_all_eq (vector unsigned int, vector unsigned int);
17400 int vec_all_eq (vector bool int, vector bool int);
17401 int vec_all_eq (vector bool int, vector unsigned int);
17402 int vec_all_eq (vector bool int, vector signed int);
17403 int vec_all_eq (vector float, vector float);
17405 int vec_all_ge (vector bool char, vector unsigned char);
17406 int vec_all_ge (vector unsigned char, vector bool char);
17407 int vec_all_ge (vector unsigned char, vector unsigned char);
17408 int vec_all_ge (vector bool char, vector signed char);
17409 int vec_all_ge (vector signed char, vector bool char);
17410 int vec_all_ge (vector signed char, vector signed char);
17411 int vec_all_ge (vector bool short, vector unsigned short);
17412 int vec_all_ge (vector unsigned short, vector bool short);
17413 int vec_all_ge (vector unsigned short, vector unsigned short);
17414 int vec_all_ge (vector signed short, vector signed short);
17415 int vec_all_ge (vector bool short, vector signed short);
17416 int vec_all_ge (vector signed short, vector bool short);
17417 int vec_all_ge (vector bool int, vector unsigned int);
17418 int vec_all_ge (vector unsigned int, vector bool int);
17419 int vec_all_ge (vector unsigned int, vector unsigned int);
17420 int vec_all_ge (vector bool int, vector signed int);
17421 int vec_all_ge (vector signed int, vector bool int);
17422 int vec_all_ge (vector signed int, vector signed int);
17423 int vec_all_ge (vector float, vector float);
17425 int vec_all_gt (vector bool char, vector unsigned char);
17426 int vec_all_gt (vector unsigned char, vector bool char);
17427 int vec_all_gt (vector unsigned char, vector unsigned char);
17428 int vec_all_gt (vector bool char, vector signed char);
17429 int vec_all_gt (vector signed char, vector bool char);
17430 int vec_all_gt (vector signed char, vector signed char);
17431 int vec_all_gt (vector bool short, vector unsigned short);
17432 int vec_all_gt (vector unsigned short, vector bool short);
17433 int vec_all_gt (vector unsigned short, vector unsigned short);
17434 int vec_all_gt (vector bool short, vector signed short);
17435 int vec_all_gt (vector signed short, vector bool short);
17436 int vec_all_gt (vector signed short, vector signed short);
17437 int vec_all_gt (vector bool int, vector unsigned int);
17438 int vec_all_gt (vector unsigned int, vector bool int);
17439 int vec_all_gt (vector unsigned int, vector unsigned int);
17440 int vec_all_gt (vector bool int, vector signed int);
17441 int vec_all_gt (vector signed int, vector bool int);
17442 int vec_all_gt (vector signed int, vector signed int);
17443 int vec_all_gt (vector float, vector float);
17445 int vec_all_in (vector float, vector float);
17447 int vec_all_le (vector bool char, vector unsigned char);
17448 int vec_all_le (vector unsigned char, vector bool char);
17449 int vec_all_le (vector unsigned char, vector unsigned char);
17450 int vec_all_le (vector bool char, vector signed char);
17451 int vec_all_le (vector signed char, vector bool char);
17452 int vec_all_le (vector signed char, vector signed char);
17453 int vec_all_le (vector bool short, vector unsigned short);
17454 int vec_all_le (vector unsigned short, vector bool short);
17455 int vec_all_le (vector unsigned short, vector unsigned short);
17456 int vec_all_le (vector bool short, vector signed short);
17457 int vec_all_le (vector signed short, vector bool short);
17458 int vec_all_le (vector signed short, vector signed short);
17459 int vec_all_le (vector bool int, vector unsigned int);
17460 int vec_all_le (vector unsigned int, vector bool int);
17461 int vec_all_le (vector unsigned int, vector unsigned int);
17462 int vec_all_le (vector bool int, vector signed int);
17463 int vec_all_le (vector signed int, vector bool int);
17464 int vec_all_le (vector signed int, vector signed int);
17465 int vec_all_le (vector float, vector float);
17467 int vec_all_lt (vector bool char, vector unsigned char);
17468 int vec_all_lt (vector unsigned char, vector bool char);
17469 int vec_all_lt (vector unsigned char, vector unsigned char);
17470 int vec_all_lt (vector bool char, vector signed char);
17471 int vec_all_lt (vector signed char, vector bool char);
17472 int vec_all_lt (vector signed char, vector signed char);
17473 int vec_all_lt (vector bool short, vector unsigned short);
17474 int vec_all_lt (vector unsigned short, vector bool short);
17475 int vec_all_lt (vector unsigned short, vector unsigned short);
17476 int vec_all_lt (vector bool short, vector signed short);
17477 int vec_all_lt (vector signed short, vector bool short);
17478 int vec_all_lt (vector signed short, vector signed short);
17479 int vec_all_lt (vector bool int, vector unsigned int);
17480 int vec_all_lt (vector unsigned int, vector bool int);
17481 int vec_all_lt (vector unsigned int, vector unsigned int);
17482 int vec_all_lt (vector bool int, vector signed int);
17483 int vec_all_lt (vector signed int, vector bool int);
17484 int vec_all_lt (vector signed int, vector signed int);
17485 int vec_all_lt (vector float, vector float);
17487 int vec_all_nan (vector float);
17489 int vec_all_ne (vector signed char, vector bool char);
17490 int vec_all_ne (vector signed char, vector signed char);
17491 int vec_all_ne (vector unsigned char, vector bool char);
17492 int vec_all_ne (vector unsigned char, vector unsigned char);
17493 int vec_all_ne (vector bool char, vector bool char);
17494 int vec_all_ne (vector bool char, vector unsigned char);
17495 int vec_all_ne (vector bool char, vector signed char);
17496 int vec_all_ne (vector signed short, vector bool short);
17497 int vec_all_ne (vector signed short, vector signed short);
17498 int vec_all_ne (vector unsigned short, vector bool short);
17499 int vec_all_ne (vector unsigned short, vector unsigned short);
17500 int vec_all_ne (vector bool short, vector bool short);
17501 int vec_all_ne (vector bool short, vector unsigned short);
17502 int vec_all_ne (vector bool short, vector signed short);
17503 int vec_all_ne (vector pixel, vector pixel);
17504 int vec_all_ne (vector signed int, vector bool int);
17505 int vec_all_ne (vector signed int, vector signed int);
17506 int vec_all_ne (vector unsigned int, vector bool int);
17507 int vec_all_ne (vector unsigned int, vector unsigned int);
17508 int vec_all_ne (vector bool int, vector bool int);
17509 int vec_all_ne (vector bool int, vector unsigned int);
17510 int vec_all_ne (vector bool int, vector signed int);
17511 int vec_all_ne (vector float, vector float);
17513 int vec_all_nge (vector float, vector float);
17515 int vec_all_ngt (vector float, vector float);
17517 int vec_all_nle (vector float, vector float);
17519 int vec_all_nlt (vector float, vector float);
17521 int vec_all_numeric (vector float);
17523 int vec_any_eq (vector signed char, vector bool char);
17524 int vec_any_eq (vector signed char, vector signed char);
17525 int vec_any_eq (vector unsigned char, vector bool char);
17526 int vec_any_eq (vector unsigned char, vector unsigned char);
17527 int vec_any_eq (vector bool char, vector bool char);
17528 int vec_any_eq (vector bool char, vector unsigned char);
17529 int vec_any_eq (vector bool char, vector signed char);
17530 int vec_any_eq (vector signed short, vector bool short);
17531 int vec_any_eq (vector signed short, vector signed short);
17532 int vec_any_eq (vector unsigned short, vector bool short);
17533 int vec_any_eq (vector unsigned short, vector unsigned short);
17534 int vec_any_eq (vector bool short, vector bool short);
17535 int vec_any_eq (vector bool short, vector unsigned short);
17536 int vec_any_eq (vector bool short, vector signed short);
17537 int vec_any_eq (vector pixel, vector pixel);
17538 int vec_any_eq (vector signed int, vector bool int);
17539 int vec_any_eq (vector signed int, vector signed int);
17540 int vec_any_eq (vector unsigned int, vector bool int);
17541 int vec_any_eq (vector unsigned int, vector unsigned int);
17542 int vec_any_eq (vector bool int, vector bool int);
17543 int vec_any_eq (vector bool int, vector unsigned int);
17544 int vec_any_eq (vector bool int, vector signed int);
17545 int vec_any_eq (vector float, vector float);
17547 int vec_any_ge (vector signed char, vector bool char);
17548 int vec_any_ge (vector unsigned char, vector bool char);
17549 int vec_any_ge (vector unsigned char, vector unsigned char);
17550 int vec_any_ge (vector signed char, vector signed char);
17551 int vec_any_ge (vector bool char, vector unsigned char);
17552 int vec_any_ge (vector bool char, vector signed char);
17553 int vec_any_ge (vector unsigned short, vector bool short);
17554 int vec_any_ge (vector unsigned short, vector unsigned short);
17555 int vec_any_ge (vector signed short, vector signed short);
17556 int vec_any_ge (vector signed short, vector bool short);
17557 int vec_any_ge (vector bool short, vector unsigned short);
17558 int vec_any_ge (vector bool short, vector signed short);
17559 int vec_any_ge (vector signed int, vector bool int);
17560 int vec_any_ge (vector unsigned int, vector bool int);
17561 int vec_any_ge (vector unsigned int, vector unsigned int);
17562 int vec_any_ge (vector signed int, vector signed int);
17563 int vec_any_ge (vector bool int, vector unsigned int);
17564 int vec_any_ge (vector bool int, vector signed int);
17565 int vec_any_ge (vector float, vector float);
17567 int vec_any_gt (vector bool char, vector unsigned char);
17568 int vec_any_gt (vector unsigned char, vector bool char);
17569 int vec_any_gt (vector unsigned char, vector unsigned char);
17570 int vec_any_gt (vector bool char, vector signed char);
17571 int vec_any_gt (vector signed char, vector bool char);
17572 int vec_any_gt (vector signed char, vector signed char);
17573 int vec_any_gt (vector bool short, vector unsigned short);
17574 int vec_any_gt (vector unsigned short, vector bool short);
17575 int vec_any_gt (vector unsigned short, vector unsigned short);
17576 int vec_any_gt (vector bool short, vector signed short);
17577 int vec_any_gt (vector signed short, vector bool short);
17578 int vec_any_gt (vector signed short, vector signed short);
17579 int vec_any_gt (vector bool int, vector unsigned int);
17580 int vec_any_gt (vector unsigned int, vector bool int);
17581 int vec_any_gt (vector unsigned int, vector unsigned int);
17582 int vec_any_gt (vector bool int, vector signed int);
17583 int vec_any_gt (vector signed int, vector bool int);
17584 int vec_any_gt (vector signed int, vector signed int);
17585 int vec_any_gt (vector float, vector float);
17587 int vec_any_le (vector bool char, vector unsigned char);
17588 int vec_any_le (vector unsigned char, vector bool char);
17589 int vec_any_le (vector unsigned char, vector unsigned char);
17590 int vec_any_le (vector bool char, vector signed char);
17591 int vec_any_le (vector signed char, vector bool char);
17592 int vec_any_le (vector signed char, vector signed char);
17593 int vec_any_le (vector bool short, vector unsigned short);
17594 int vec_any_le (vector unsigned short, vector bool short);
17595 int vec_any_le (vector unsigned short, vector unsigned short);
17596 int vec_any_le (vector bool short, vector signed short);
17597 int vec_any_le (vector signed short, vector bool short);
17598 int vec_any_le (vector signed short, vector signed short);
17599 int vec_any_le (vector bool int, vector unsigned int);
17600 int vec_any_le (vector unsigned int, vector bool int);
17601 int vec_any_le (vector unsigned int, vector unsigned int);
17602 int vec_any_le (vector bool int, vector signed int);
17603 int vec_any_le (vector signed int, vector bool int);
17604 int vec_any_le (vector signed int, vector signed int);
17605 int vec_any_le (vector float, vector float);
17607 int vec_any_lt (vector bool char, vector unsigned char);
17608 int vec_any_lt (vector unsigned char, vector bool char);
17609 int vec_any_lt (vector unsigned char, vector unsigned char);
17610 int vec_any_lt (vector bool char, vector signed char);
17611 int vec_any_lt (vector signed char, vector bool char);
17612 int vec_any_lt (vector signed char, vector signed char);
17613 int vec_any_lt (vector bool short, vector unsigned short);
17614 int vec_any_lt (vector unsigned short, vector bool short);
17615 int vec_any_lt (vector unsigned short, vector unsigned short);
17616 int vec_any_lt (vector bool short, vector signed short);
17617 int vec_any_lt (vector signed short, vector bool short);
17618 int vec_any_lt (vector signed short, vector signed short);
17619 int vec_any_lt (vector bool int, vector unsigned int);
17620 int vec_any_lt (vector unsigned int, vector bool int);
17621 int vec_any_lt (vector unsigned int, vector unsigned int);
17622 int vec_any_lt (vector bool int, vector signed int);
17623 int vec_any_lt (vector signed int, vector bool int);
17624 int vec_any_lt (vector signed int, vector signed int);
17625 int vec_any_lt (vector float, vector float);
17627 int vec_any_nan (vector float);
17629 int vec_any_ne (vector signed char, vector bool char);
17630 int vec_any_ne (vector signed char, vector signed char);
17631 int vec_any_ne (vector unsigned char, vector bool char);
17632 int vec_any_ne (vector unsigned char, vector unsigned char);
17633 int vec_any_ne (vector bool char, vector bool char);
17634 int vec_any_ne (vector bool char, vector unsigned char);
17635 int vec_any_ne (vector bool char, vector signed char);
17636 int vec_any_ne (vector signed short, vector bool short);
17637 int vec_any_ne (vector signed short, vector signed short);
17638 int vec_any_ne (vector unsigned short, vector bool short);
17639 int vec_any_ne (vector unsigned short, vector unsigned short);
17640 int vec_any_ne (vector bool short, vector bool short);
17641 int vec_any_ne (vector bool short, vector unsigned short);
17642 int vec_any_ne (vector bool short, vector signed short);
17643 int vec_any_ne (vector pixel, vector pixel);
17644 int vec_any_ne (vector signed int, vector bool int);
17645 int vec_any_ne (vector signed int, vector signed int);
17646 int vec_any_ne (vector unsigned int, vector bool int);
17647 int vec_any_ne (vector unsigned int, vector unsigned int);
17648 int vec_any_ne (vector bool int, vector bool int);
17649 int vec_any_ne (vector bool int, vector unsigned int);
17650 int vec_any_ne (vector bool int, vector signed int);
17651 int vec_any_ne (vector float, vector float);
17653 int vec_any_nge (vector float, vector float);
17655 int vec_any_ngt (vector float, vector float);
17657 int vec_any_nle (vector float, vector float);
17659 int vec_any_nlt (vector float, vector float);
17661 int vec_any_numeric (vector float);
17663 int vec_any_out (vector float, vector float);
17664 @end smallexample
17666 If the vector/scalar (VSX) instruction set is available, the following
17667 additional functions are available:
17669 @smallexample
17670 vector double vec_abs (vector double);
17671 vector double vec_add (vector double, vector double);
17672 vector double vec_and (vector double, vector double);
17673 vector double vec_and (vector double, vector bool long);
17674 vector double vec_and (vector bool long, vector double);
17675 vector long vec_and (vector long, vector long);
17676 vector long vec_and (vector long, vector bool long);
17677 vector long vec_and (vector bool long, vector long);
17678 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17679 vector unsigned long vec_and (vector unsigned long, vector bool long);
17680 vector unsigned long vec_and (vector bool long, vector unsigned long);
17681 vector double vec_andc (vector double, vector double);
17682 vector double vec_andc (vector double, vector bool long);
17683 vector double vec_andc (vector bool long, vector double);
17684 vector long vec_andc (vector long, vector long);
17685 vector long vec_andc (vector long, vector bool long);
17686 vector long vec_andc (vector bool long, vector long);
17687 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17688 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17689 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17690 vector double vec_ceil (vector double);
17691 vector bool long vec_cmpeq (vector double, vector double);
17692 vector bool long vec_cmpge (vector double, vector double);
17693 vector bool long vec_cmpgt (vector double, vector double);
17694 vector bool long vec_cmple (vector double, vector double);
17695 vector bool long vec_cmplt (vector double, vector double);
17696 vector double vec_cpsgn (vector double, vector double);
17697 vector float vec_div (vector float, vector float);
17698 vector double vec_div (vector double, vector double);
17699 vector long vec_div (vector long, vector long);
17700 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17701 vector double vec_floor (vector double);
17702 vector __int128 vec_ld (int, const vector __int128 *);
17703 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
17704 vector __int128 vec_ld (int, const __int128 *);
17705 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
17706 vector double vec_ld (int, const vector double *);
17707 vector double vec_ld (int, const double *);
17708 vector double vec_ldl (int, const vector double *);
17709 vector double vec_ldl (int, const double *);
17710 vector unsigned char vec_lvsl (int, const double *);
17711 vector unsigned char vec_lvsr (int, const double *);
17712 vector double vec_madd (vector double, vector double, vector double);
17713 vector double vec_max (vector double, vector double);
17714 vector signed long vec_mergeh (vector signed long, vector signed long);
17715 vector signed long vec_mergeh (vector signed long, vector bool long);
17716 vector signed long vec_mergeh (vector bool long, vector signed long);
17717 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17718 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17719 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17720 vector signed long vec_mergel (vector signed long, vector signed long);
17721 vector signed long vec_mergel (vector signed long, vector bool long);
17722 vector signed long vec_mergel (vector bool long, vector signed long);
17723 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17724 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17725 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17726 vector double vec_min (vector double, vector double);
17727 vector float vec_msub (vector float, vector float, vector float);
17728 vector double vec_msub (vector double, vector double, vector double);
17729 vector float vec_mul (vector float, vector float);
17730 vector double vec_mul (vector double, vector double);
17731 vector long vec_mul (vector long, vector long);
17732 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17733 vector float vec_nearbyint (vector float);
17734 vector double vec_nearbyint (vector double);
17735 vector float vec_nmadd (vector float, vector float, vector float);
17736 vector double vec_nmadd (vector double, vector double, vector double);
17737 vector double vec_nmsub (vector double, vector double, vector double);
17738 vector double vec_nor (vector double, vector double);
17739 vector long vec_nor (vector long, vector long);
17740 vector long vec_nor (vector long, vector bool long);
17741 vector long vec_nor (vector bool long, vector long);
17742 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17743 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17744 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17745 vector double vec_or (vector double, vector double);
17746 vector double vec_or (vector double, vector bool long);
17747 vector double vec_or (vector bool long, vector double);
17748 vector long vec_or (vector long, vector long);
17749 vector long vec_or (vector long, vector bool long);
17750 vector long vec_or (vector bool long, vector long);
17751 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17752 vector unsigned long vec_or (vector unsigned long, vector bool long);
17753 vector unsigned long vec_or (vector bool long, vector unsigned long);
17754 vector double vec_perm (vector double, vector double, vector unsigned char);
17755 vector long vec_perm (vector long, vector long, vector unsigned char);
17756 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17757                                vector unsigned char);
17758 vector bool char vec_permxor (vector bool char, vector bool char,
17759                               vector bool char);
17760 vector unsigned char vec_permxor (vector signed char, vector signed char,
17761                                   vector signed char);
17762 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
17763                                   vector unsigned char);
17764 vector double vec_rint (vector double);
17765 vector double vec_recip (vector double, vector double);
17766 vector double vec_rsqrt (vector double);
17767 vector double vec_rsqrte (vector double);
17768 vector double vec_sel (vector double, vector double, vector bool long);
17769 vector double vec_sel (vector double, vector double, vector unsigned long);
17770 vector long vec_sel (vector long, vector long, vector long);
17771 vector long vec_sel (vector long, vector long, vector unsigned long);
17772 vector long vec_sel (vector long, vector long, vector bool long);
17773 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17774                               vector long);
17775 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17776                               vector unsigned long);
17777 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17778                               vector bool long);
17779 vector double vec_splats (double);
17780 vector signed long vec_splats (signed long);
17781 vector unsigned long vec_splats (unsigned long);
17782 vector float vec_sqrt (vector float);
17783 vector double vec_sqrt (vector double);
17784 void vec_st (vector double, int, vector double *);
17785 void vec_st (vector double, int, double *);
17786 vector double vec_sub (vector double, vector double);
17787 vector double vec_trunc (vector double);
17788 vector double vec_xl (int, vector double *);
17789 vector double vec_xl (int, double *);
17790 vector long long vec_xl (int, vector long long *);
17791 vector long long vec_xl (int, long long *);
17792 vector unsigned long long vec_xl (int, vector unsigned long long *);
17793 vector unsigned long long vec_xl (int, unsigned long long *);
17794 vector float vec_xl (int, vector float *);
17795 vector float vec_xl (int, float *);
17796 vector int vec_xl (int, vector int *);
17797 vector int vec_xl (int, int *);
17798 vector unsigned int vec_xl (int, vector unsigned int *);
17799 vector unsigned int vec_xl (int, unsigned int *);
17800 vector double vec_xor (vector double, vector double);
17801 vector double vec_xor (vector double, vector bool long);
17802 vector double vec_xor (vector bool long, vector double);
17803 vector long vec_xor (vector long, vector long);
17804 vector long vec_xor (vector long, vector bool long);
17805 vector long vec_xor (vector bool long, vector long);
17806 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17807 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17808 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17809 void vec_xst (vector double, int, vector double *);
17810 void vec_xst (vector double, int, double *);
17811 void vec_xst (vector long long, int, vector long long *);
17812 void vec_xst (vector long long, int, long long *);
17813 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17814 void vec_xst (vector unsigned long long, int, unsigned long long *);
17815 void vec_xst (vector float, int, vector float *);
17816 void vec_xst (vector float, int, float *);
17817 void vec_xst (vector int, int, vector int *);
17818 void vec_xst (vector int, int, int *);
17819 void vec_xst (vector unsigned int, int, vector unsigned int *);
17820 void vec_xst (vector unsigned int, int, unsigned int *);
17821 int vec_all_eq (vector double, vector double);
17822 int vec_all_ge (vector double, vector double);
17823 int vec_all_gt (vector double, vector double);
17824 int vec_all_le (vector double, vector double);
17825 int vec_all_lt (vector double, vector double);
17826 int vec_all_nan (vector double);
17827 int vec_all_ne (vector double, vector double);
17828 int vec_all_nge (vector double, vector double);
17829 int vec_all_ngt (vector double, vector double);
17830 int vec_all_nle (vector double, vector double);
17831 int vec_all_nlt (vector double, vector double);
17832 int vec_all_numeric (vector double);
17833 int vec_any_eq (vector double, vector double);
17834 int vec_any_ge (vector double, vector double);
17835 int vec_any_gt (vector double, vector double);
17836 int vec_any_le (vector double, vector double);
17837 int vec_any_lt (vector double, vector double);
17838 int vec_any_nan (vector double);
17839 int vec_any_ne (vector double, vector double);
17840 int vec_any_nge (vector double, vector double);
17841 int vec_any_ngt (vector double, vector double);
17842 int vec_any_nle (vector double, vector double);
17843 int vec_any_nlt (vector double, vector double);
17844 int vec_any_numeric (vector double);
17846 vector double vec_vsx_ld (int, const vector double *);
17847 vector double vec_vsx_ld (int, const double *);
17848 vector float vec_vsx_ld (int, const vector float *);
17849 vector float vec_vsx_ld (int, const float *);
17850 vector bool int vec_vsx_ld (int, const vector bool int *);
17851 vector signed int vec_vsx_ld (int, const vector signed int *);
17852 vector signed int vec_vsx_ld (int, const int *);
17853 vector signed int vec_vsx_ld (int, const long *);
17854 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17855 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17856 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17857 vector bool short vec_vsx_ld (int, const vector bool short *);
17858 vector pixel vec_vsx_ld (int, const vector pixel *);
17859 vector signed short vec_vsx_ld (int, const vector signed short *);
17860 vector signed short vec_vsx_ld (int, const short *);
17861 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17862 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17863 vector bool char vec_vsx_ld (int, const vector bool char *);
17864 vector signed char vec_vsx_ld (int, const vector signed char *);
17865 vector signed char vec_vsx_ld (int, const signed char *);
17866 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17867 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17869 void vec_vsx_st (vector double, int, vector double *);
17870 void vec_vsx_st (vector double, int, double *);
17871 void vec_vsx_st (vector float, int, vector float *);
17872 void vec_vsx_st (vector float, int, float *);
17873 void vec_vsx_st (vector signed int, int, vector signed int *);
17874 void vec_vsx_st (vector signed int, int, int *);
17875 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17876 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17877 void vec_vsx_st (vector bool int, int, vector bool int *);
17878 void vec_vsx_st (vector bool int, int, unsigned int *);
17879 void vec_vsx_st (vector bool int, int, int *);
17880 void vec_vsx_st (vector signed short, int, vector signed short *);
17881 void vec_vsx_st (vector signed short, int, short *);
17882 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17883 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17884 void vec_vsx_st (vector bool short, int, vector bool short *);
17885 void vec_vsx_st (vector bool short, int, unsigned short *);
17886 void vec_vsx_st (vector pixel, int, vector pixel *);
17887 void vec_vsx_st (vector pixel, int, unsigned short *);
17888 void vec_vsx_st (vector pixel, int, short *);
17889 void vec_vsx_st (vector bool short, int, short *);
17890 void vec_vsx_st (vector signed char, int, vector signed char *);
17891 void vec_vsx_st (vector signed char, int, signed char *);
17892 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17893 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17894 void vec_vsx_st (vector bool char, int, vector bool char *);
17895 void vec_vsx_st (vector bool char, int, unsigned char *);
17896 void vec_vsx_st (vector bool char, int, signed char *);
17898 vector double vec_xxpermdi (vector double, vector double, const int);
17899 vector float vec_xxpermdi (vector float, vector float, const int);
17900 vector long long vec_xxpermdi (vector long long, vector long long, const int);
17901 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17902                                         vector unsigned long long, const int);
17903 vector int vec_xxpermdi (vector int, vector int, const int);
17904 vector unsigned int vec_xxpermdi (vector unsigned int,
17905                                   vector unsigned int, const int);
17906 vector short vec_xxpermdi (vector short, vector short, const int);
17907 vector unsigned short vec_xxpermdi (vector unsigned short,
17908                                     vector unsigned short, const int);
17909 vector signed char vec_xxpermdi (vector signed char, vector signed char,
17910                                  const int);
17911 vector unsigned char vec_xxpermdi (vector unsigned char,
17912                                    vector unsigned char, const int);
17914 vector double vec_xxsldi (vector double, vector double, int);
17915 vector float vec_xxsldi (vector float, vector float, int);
17916 vector long long vec_xxsldi (vector long long, vector long long, int);
17917 vector unsigned long long vec_xxsldi (vector unsigned long long,
17918                                       vector unsigned long long, int);
17919 vector int vec_xxsldi (vector int, vector int, int);
17920 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17921 vector short vec_xxsldi (vector short, vector short, int);
17922 vector unsigned short vec_xxsldi (vector unsigned short,
17923                                   vector unsigned short, int);
17924 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17925 vector unsigned char vec_xxsldi (vector unsigned char,
17926                                  vector unsigned char, int);
17927 @end smallexample
17929 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17930 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17931 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
17932 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17933 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17935 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17936 instruction set are available, the following additional functions are
17937 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
17938 can use @var{vector long} instead of @var{vector long long},
17939 @var{vector bool long} instead of @var{vector bool long long}, and
17940 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17942 @smallexample
17943 vector long long vec_abs (vector long long);
17945 vector long long vec_add (vector long long, vector long long);
17946 vector unsigned long long vec_add (vector unsigned long long,
17947                                    vector unsigned long long);
17949 int vec_all_eq (vector long long, vector long long);
17950 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17951 int vec_all_ge (vector long long, vector long long);
17952 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17953 int vec_all_gt (vector long long, vector long long);
17954 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17955 int vec_all_le (vector long long, vector long long);
17956 int vec_all_le (vector unsigned long long, vector unsigned long long);
17957 int vec_all_lt (vector long long, vector long long);
17958 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17959 int vec_all_ne (vector long long, vector long long);
17960 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17962 int vec_any_eq (vector long long, vector long long);
17963 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17964 int vec_any_ge (vector long long, vector long long);
17965 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17966 int vec_any_gt (vector long long, vector long long);
17967 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17968 int vec_any_le (vector long long, vector long long);
17969 int vec_any_le (vector unsigned long long, vector unsigned long long);
17970 int vec_any_lt (vector long long, vector long long);
17971 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17972 int vec_any_ne (vector long long, vector long long);
17973 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17975 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
17977 vector long long vec_eqv (vector long long, vector long long);
17978 vector long long vec_eqv (vector bool long long, vector long long);
17979 vector long long vec_eqv (vector long long, vector bool long long);
17980 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
17981 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
17982 vector unsigned long long vec_eqv (vector unsigned long long,
17983                                    vector bool long long);
17984 vector int vec_eqv (vector int, vector int);
17985 vector int vec_eqv (vector bool int, vector int);
17986 vector int vec_eqv (vector int, vector bool int);
17987 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17988 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
17989 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
17990 vector short vec_eqv (vector short, vector short);
17991 vector short vec_eqv (vector bool short, vector short);
17992 vector short vec_eqv (vector short, vector bool short);
17993 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17994 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
17995 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
17996 vector signed char vec_eqv (vector signed char, vector signed char);
17997 vector signed char vec_eqv (vector bool signed char, vector signed char);
17998 vector signed char vec_eqv (vector signed char, vector bool signed char);
17999 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18000 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18001 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18003 vector long long vec_max (vector long long, vector long long);
18004 vector unsigned long long vec_max (vector unsigned long long,
18005                                    vector unsigned long long);
18007 vector signed int vec_mergee (vector signed int, vector signed int);
18008 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18009 vector bool int vec_mergee (vector bool int, vector bool int);
18011 vector signed int vec_mergeo (vector signed int, vector signed int);
18012 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18013 vector bool int vec_mergeo (vector bool int, vector bool int);
18015 vector long long vec_min (vector long long, vector long long);
18016 vector unsigned long long vec_min (vector unsigned long long,
18017                                    vector unsigned long long);
18019 vector signed long long vec_nabs (vector signed long long);
18021 vector long long vec_nand (vector long long, vector long long);
18022 vector long long vec_nand (vector bool long long, vector long long);
18023 vector long long vec_nand (vector long long, vector bool long long);
18024 vector unsigned long long vec_nand (vector unsigned long long,
18025                                     vector unsigned long long);
18026 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
18027 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
18028 vector int vec_nand (vector int, vector int);
18029 vector int vec_nand (vector bool int, vector int);
18030 vector int vec_nand (vector int, vector bool int);
18031 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18032 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
18033 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
18034 vector short vec_nand (vector short, vector short);
18035 vector short vec_nand (vector bool short, vector short);
18036 vector short vec_nand (vector short, vector bool short);
18037 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18038 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
18039 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
18040 vector signed char vec_nand (vector signed char, vector signed char);
18041 vector signed char vec_nand (vector bool signed char, vector signed char);
18042 vector signed char vec_nand (vector signed char, vector bool signed char);
18043 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18044 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18045 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18047 vector long long vec_orc (vector long long, vector long long);
18048 vector long long vec_orc (vector bool long long, vector long long);
18049 vector long long vec_orc (vector long long, vector bool long long);
18050 vector unsigned long long vec_orc (vector unsigned long long,
18051                                    vector unsigned long long);
18052 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
18053 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
18054 vector int vec_orc (vector int, vector int);
18055 vector int vec_orc (vector bool int, vector int);
18056 vector int vec_orc (vector int, vector bool int);
18057 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18058 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
18059 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
18060 vector short vec_orc (vector short, vector short);
18061 vector short vec_orc (vector bool short, vector short);
18062 vector short vec_orc (vector short, vector bool short);
18063 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18064 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
18065 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
18066 vector signed char vec_orc (vector signed char, vector signed char);
18067 vector signed char vec_orc (vector bool signed char, vector signed char);
18068 vector signed char vec_orc (vector signed char, vector bool signed char);
18069 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18070 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18071 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18073 vector int vec_pack (vector long long, vector long long);
18074 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
18075 vector bool int vec_pack (vector bool long long, vector bool long long);
18076 vector float vec_pack (vector double, vector double);
18078 vector int vec_packs (vector long long, vector long long);
18079 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
18081 vector unsigned char vec_packsu (vector signed short, vector signed short)
18082 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
18083 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18084 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
18085 vector unsigned int vec_packsu (vector long long, vector long long);
18086 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
18087 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
18089 vector unsigned char vec_popcnt (vector signed char);
18090 vector unsigned char vec_popcnt (vector unsigned char);
18091 vector unsigned short vec_popcnt (vector signed short);
18092 vector unsigned short vec_popcnt (vector unsigned short);
18093 vector unsigned int vec_popcnt (vector signed int);
18094 vector unsigned int vec_popcnt (vector unsigned int);
18095 vector unsigned long long vec_popcnt (vector signed long long);
18096 vector unsigned long long vec_popcnt (vector unsigned long long);
18098 vector long long vec_rl (vector long long, vector unsigned long long);
18099 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
18101 vector long long vec_sl (vector long long, vector unsigned long long);
18102 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
18104 vector long long vec_sr (vector long long, vector unsigned long long);
18105 vector unsigned long long char vec_sr (vector unsigned long long,
18106                                        vector unsigned long long);
18108 vector long long vec_sra (vector long long, vector unsigned long long);
18109 vector unsigned long long vec_sra (vector unsigned long long,
18110                                    vector unsigned long long);
18112 vector long long vec_sub (vector long long, vector long long);
18113 vector unsigned long long vec_sub (vector unsigned long long,
18114                                    vector unsigned long long);
18116 vector long long vec_unpackh (vector int);
18117 vector unsigned long long vec_unpackh (vector unsigned int);
18119 vector long long vec_unpackl (vector int);
18120 vector unsigned long long vec_unpackl (vector unsigned int);
18122 vector long long vec_vaddudm (vector long long, vector long long);
18123 vector long long vec_vaddudm (vector bool long long, vector long long);
18124 vector long long vec_vaddudm (vector long long, vector bool long long);
18125 vector unsigned long long vec_vaddudm (vector unsigned long long,
18126                                        vector unsigned long long);
18127 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18128                                        vector unsigned long long);
18129 vector unsigned long long vec_vaddudm (vector unsigned long long,
18130                                        vector bool unsigned long long);
18132 vector long long vec_vbpermq (vector signed char, vector signed char);
18133 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18135 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18136 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
18137 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
18139 vector long long vec_cntlz (vector long long);
18140 vector unsigned long long vec_cntlz (vector unsigned long long);
18141 vector int vec_cntlz (vector int);
18142 vector unsigned int vec_cntlz (vector int);
18143 vector short vec_cntlz (vector short);
18144 vector unsigned short vec_cntlz (vector unsigned short);
18145 vector signed char vec_cntlz (vector signed char);
18146 vector unsigned char vec_cntlz (vector unsigned char);
18148 vector long long vec_vclz (vector long long);
18149 vector unsigned long long vec_vclz (vector unsigned long long);
18150 vector int vec_vclz (vector int);
18151 vector unsigned int vec_vclz (vector int);
18152 vector short vec_vclz (vector short);
18153 vector unsigned short vec_vclz (vector unsigned short);
18154 vector signed char vec_vclz (vector signed char);
18155 vector unsigned char vec_vclz (vector unsigned char);
18157 vector signed char vec_vclzb (vector signed char);
18158 vector unsigned char vec_vclzb (vector unsigned char);
18160 vector long long vec_vclzd (vector long long);
18161 vector unsigned long long vec_vclzd (vector unsigned long long);
18163 vector short vec_vclzh (vector short);
18164 vector unsigned short vec_vclzh (vector unsigned short);
18166 vector int vec_vclzw (vector int);
18167 vector unsigned int vec_vclzw (vector int);
18169 vector signed char vec_vgbbd (vector signed char);
18170 vector unsigned char vec_vgbbd (vector unsigned char);
18172 vector long long vec_vmaxsd (vector long long, vector long long);
18174 vector unsigned long long vec_vmaxud (vector unsigned long long,
18175                                       unsigned vector long long);
18177 vector long long vec_vminsd (vector long long, vector long long);
18179 vector unsigned long long vec_vminud (vector long long, vector long long);
18181 vector int vec_vpksdss (vector long long, vector long long);
18182 vector unsigned int vec_vpksdss (vector long long, vector long long);
18184 vector unsigned int vec_vpkudus (vector unsigned long long,
18185                                  vector unsigned long long);
18187 vector int vec_vpkudum (vector long long, vector long long);
18188 vector unsigned int vec_vpkudum (vector unsigned long long,
18189                                  vector unsigned long long);
18190 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18192 vector long long vec_vpopcnt (vector long long);
18193 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18194 vector int vec_vpopcnt (vector int);
18195 vector unsigned int vec_vpopcnt (vector int);
18196 vector short vec_vpopcnt (vector short);
18197 vector unsigned short vec_vpopcnt (vector unsigned short);
18198 vector signed char vec_vpopcnt (vector signed char);
18199 vector unsigned char vec_vpopcnt (vector unsigned char);
18201 vector signed char vec_vpopcntb (vector signed char);
18202 vector unsigned char vec_vpopcntb (vector unsigned char);
18204 vector long long vec_vpopcntd (vector long long);
18205 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18207 vector short vec_vpopcnth (vector short);
18208 vector unsigned short vec_vpopcnth (vector unsigned short);
18210 vector int vec_vpopcntw (vector int);
18211 vector unsigned int vec_vpopcntw (vector int);
18213 vector long long vec_vrld (vector long long, vector unsigned long long);
18214 vector unsigned long long vec_vrld (vector unsigned long long,
18215                                     vector unsigned long long);
18217 vector long long vec_vsld (vector long long, vector unsigned long long);
18218 vector long long vec_vsld (vector unsigned long long,
18219                            vector unsigned long long);
18221 vector long long vec_vsrad (vector long long, vector unsigned long long);
18222 vector unsigned long long vec_vsrad (vector unsigned long long,
18223                                      vector unsigned long long);
18225 vector long long vec_vsrd (vector long long, vector unsigned long long);
18226 vector unsigned long long char vec_vsrd (vector unsigned long long,
18227                                          vector unsigned long long);
18229 vector long long vec_vsubudm (vector long long, vector long long);
18230 vector long long vec_vsubudm (vector bool long long, vector long long);
18231 vector long long vec_vsubudm (vector long long, vector bool long long);
18232 vector unsigned long long vec_vsubudm (vector unsigned long long,
18233                                        vector unsigned long long);
18234 vector unsigned long long vec_vsubudm (vector bool long long,
18235                                        vector unsigned long long);
18236 vector unsigned long long vec_vsubudm (vector unsigned long long,
18237                                        vector bool long long);
18239 vector long long vec_vupkhsw (vector int);
18240 vector unsigned long long vec_vupkhsw (vector unsigned int);
18242 vector long long vec_vupklsw (vector int);
18243 vector unsigned long long vec_vupklsw (vector int);
18244 @end smallexample
18246 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18247 instruction set are available, the following additional functions are
18248 available for 64-bit targets.  New vector types
18249 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18250 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18251 builtins.
18253 The normal vector extract, and set operations work on
18254 @var{vector __int128_t} and @var{vector __uint128_t} types,
18255 but the index value must be 0.
18257 @smallexample
18258 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18259 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18261 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18262 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18264 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18265                                 vector __int128_t);
18266 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18267                                  vector __uint128_t);
18269 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18270                                 vector __int128_t);
18271 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18272                                  vector __uint128_t);
18274 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18275                                 vector __int128_t);
18276 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18277                                  vector __uint128_t);
18279 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18280                                 vector __int128_t);
18281 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18282                                  vector __uint128_t);
18284 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18285 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18287 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18288 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18290 vector __int128_t __builtin_bcdadd (vector __int128_t, vector __int128_t);
18291 int __builtin_bcdadd_lt (vector __int128_t, vector __int128_t);
18292 int __builtin_bcdadd_eq (vector __int128_t, vector __int128_t);
18293 int __builtin_bcdadd_gt (vector __int128_t, vector __int128_t);
18294 int __builtin_bcdadd_ov (vector __int128_t, vector __int128_t);
18295 vector __int128_t bcdsub (vector __int128_t, vector __int128_t);
18296 int __builtin_bcdsub_lt (vector __int128_t, vector __int128_t);
18297 int __builtin_bcdsub_eq (vector __int128_t, vector __int128_t);
18298 int __builtin_bcdsub_gt (vector __int128_t, vector __int128_t);
18299 int __builtin_bcdsub_ov (vector __int128_t, vector __int128_t);
18300 @end smallexample
18302 The following additional built-in functions are also available for the
18303 PowerPC family of processors, starting with ISA 3.0
18304 (@option{-mcpu=power9}) or later:
18305 @smallexample
18306 unsigned int scalar_extract_exp (double source);
18307 unsigned long long int scalar_extract_exp (__ieee128 source);
18309 unsigned long long int scalar_extract_sig (double source);
18310 unsigned __int128 scalar_extract_sig (__ieee128 source);
18312 double scalar_insert_exp (unsigned long long int significand,
18313                           unsigned long long int exponent);
18314 double scalar_insert_exp (double significand, unsigned long long int exponent);
18316 ieee_128 scalar_insert_exp (unsigned __int128 significand,
18317                             unsigned long long int exponent);
18318 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18320 int scalar_cmp_exp_gt (double arg1, double arg2);
18321 int scalar_cmp_exp_lt (double arg1, double arg2);
18322 int scalar_cmp_exp_eq (double arg1, double arg2);
18323 int scalar_cmp_exp_unordered (double arg1, double arg2);
18325 bool scalar_test_data_class (float source, const int condition);
18326 bool scalar_test_data_class (double source, const int condition);
18327 bool scalar_test_data_class (__ieee128 source, const int condition);
18329 bool scalar_test_neg (float source);
18330 bool scalar_test_neg (double source);
18331 bool scalar_test_neg (__ieee128 source);
18332 @end smallexample
18334 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18335 functions require a 64-bit environment supporting ISA 3.0 or later.
18336 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18337 functions return the significand and the biased exponent value
18338 respectively of their @code{source} arguments.
18339 When supplied with a 64-bit @code{source} argument, the
18340 result returned by @code{scalar_extract_sig} has
18341 the @code{0x0010000000000000} bit set if the
18342 function's @code{source} argument is in normalized form.
18343 Otherwise, this bit is set to 0.
18344 When supplied with a 128-bit @code{source} argument, the
18345 @code{0x00010000000000000000000000000000} bit of the result is
18346 treated similarly.
18347 Note that the sign of the significand is not represented in the result
18348 returned from the @code{scalar_extract_sig} function.  Use the
18349 @code{scalar_test_neg} function to test the sign of its @code{double}
18350 argument.
18352 The @code{scalar_insert_exp}
18353 functions require a 64-bit environment supporting ISA 3.0 or later.
18354 When supplied with a 64-bit first argument, the
18355 @code{scalar_insert_exp} built-in function returns a double-precision
18356 floating point value that is constructed by assembling the values of its
18357 @code{significand} and @code{exponent} arguments.  The sign of the
18358 result is copied from the most significant bit of the
18359 @code{significand} argument.  The significand and exponent components
18360 of the result are composed of the least significant 11 bits of the
18361 @code{exponent} argument and the least significant 52 bits of the
18362 @code{significand} argument respectively.
18364 When supplied with a 128-bit first argument, the
18365 @code{scalar_insert_exp} built-in function returns a quad-precision
18366 ieee floating point value.  The sign bit of the result is copied from
18367 the most significant bit of the @code{significand} argument.
18368 The significand and exponent components of the result are composed of
18369 the least significant 15 bits of the @code{exponent} argument and the
18370 least significant 112 bits of the @code{significand} argument respectively.
18372 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18373 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18374 functions return a non-zero value if @code{arg1} is greater than, less
18375 than, equal to, or not comparable to @code{arg2} respectively.  The
18376 arguments are not comparable if one or the other equals NaN (not a
18377 number). 
18379 The @code{scalar_test_data_class} built-in function returns 1
18380 if any of the condition tests enabled by the value of the
18381 @code{condition} variable are true, and 0 otherwise.  The
18382 @code{condition} argument must be a compile-time constant integer with
18383 value not exceeding 127.  The
18384 @code{condition} argument is encoded as a bitmask with each bit
18385 enabling the testing of a different condition, as characterized by the
18386 following:
18387 @smallexample
18388 0x40    Test for NaN
18389 0x20    Test for +Infinity
18390 0x10    Test for -Infinity
18391 0x08    Test for +Zero
18392 0x04    Test for -Zero
18393 0x02    Test for +Denormal
18394 0x01    Test for -Denormal
18395 @end smallexample
18397 The @code{scalar_test_neg} built-in function returns 1 if its
18398 @code{source} argument holds a negative value, 0 otherwise.
18400 The following built-in functions are also available for the PowerPC family
18401 of processors, starting with ISA 3.0 or later
18402 (@option{-mcpu=power9}).  These string functions are described
18403 separately in order to group the descriptions closer to the function
18404 prototypes:
18405 @smallexample
18406 int vec_all_nez (vector signed char, vector signed char);
18407 int vec_all_nez (vector unsigned char, vector unsigned char);
18408 int vec_all_nez (vector signed short, vector signed short);
18409 int vec_all_nez (vector unsigned short, vector unsigned short);
18410 int vec_all_nez (vector signed int, vector signed int);
18411 int vec_all_nez (vector unsigned int, vector unsigned int);
18413 int vec_any_eqz (vector signed char, vector signed char);
18414 int vec_any_eqz (vector unsigned char, vector unsigned char);
18415 int vec_any_eqz (vector signed short, vector signed short);
18416 int vec_any_eqz (vector unsigned short, vector unsigned short);
18417 int vec_any_eqz (vector signed int, vector signed int);
18418 int vec_any_eqz (vector unsigned int, vector unsigned int);
18420 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
18421 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
18422 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
18423 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
18424 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
18425 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
18427 vector signed char vec_cnttz (vector signed char);
18428 vector unsigned char vec_cnttz (vector unsigned char);
18429 vector signed short vec_cnttz (vector signed short);
18430 vector unsigned short vec_cnttz (vector unsigned short);
18431 vector signed int vec_cnttz (vector signed int);
18432 vector unsigned int vec_cnttz (vector unsigned int);
18433 vector signed long long vec_cnttz (vector signed long long);
18434 vector unsigned long long vec_cnttz (vector unsigned long long);
18436 signed int vec_cntlz_lsbb (vector signed char);
18437 signed int vec_cntlz_lsbb (vector unsigned char);
18439 signed int vec_cnttz_lsbb (vector signed char);
18440 signed int vec_cnttz_lsbb (vector unsigned char);
18442 unsigned int vec_first_match_index (vector signed char, vector signed char);
18443 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
18444 unsigned int vec_first_match_index (vector signed int, vector signed int);
18445 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
18446 unsigned int vec_first_match_index (vector signed short, vector signed short);
18447 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
18448 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
18449 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
18450 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
18451 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
18452 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
18453 unsigned int vec_first_match_or_eos_index (vector unsigned short,
18454                                            vector unsigned short);
18455 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
18456 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
18457 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
18458 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
18459 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
18460 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
18461 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
18462 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
18463                                               vector unsigned char);
18464 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
18465 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
18466 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
18467 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
18468                                               vector unsigned short);
18470 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
18472 vector signed char vec_xl_be (signed long long, signed char *);
18473 vector unsigned char vec_xl_be (signed long long, unsigned char *);
18474 vector signed int vec_xl_be (signed long long, signed int *);
18475 vector unsigned int vec_xl_be (signed long long, unsigned int *);
18476 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
18477 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
18478 vector signed long long vec_xl_be (signed long long, signed long long *);
18479 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
18480 vector signed short vec_xl_be (signed long long, signed short *);
18481 vector unsigned short vec_xl_be (signed long long, unsigned short *);
18482 vector double vec_xl_be (signed long long, double *);
18483 vector float vec_xl_be (signed long long, float *);
18485 vector signed char vec_xl_len (signed char *addr, size_t len);
18486 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
18487 vector signed int vec_xl_len (signed int *addr, size_t len);
18488 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
18489 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
18490 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
18491 vector signed long long vec_xl_len (signed long long *addr, size_t len);
18492 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
18493 vector signed short vec_xl_len (signed short *addr, size_t len);
18494 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
18495 vector double vec_xl_len (double *addr, size_t len);
18496 vector float vec_xl_len (float *addr, size_t len);
18498 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
18500 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
18501 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
18502 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
18503 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
18504 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
18505 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
18506 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
18507 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
18508 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
18509 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
18510 void vec_xst_len (vector double data, double *addr, size_t len);
18511 void vec_xst_len (vector float data, float *addr, size_t len);
18513 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
18515 signed char vec_xlx (unsigned int index, vector signed char data);
18516 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
18517 signed short vec_xlx (unsigned int index, vector signed short data);
18518 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
18519 signed int vec_xlx (unsigned int index, vector signed int data);
18520 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
18521 float vec_xlx (unsigned int index, vector float data);
18523 signed char vec_xrx (unsigned int index, vector signed char data);
18524 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
18525 signed short vec_xrx (unsigned int index, vector signed short data);
18526 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
18527 signed int vec_xrx (unsigned int index, vector signed int data);
18528 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
18529 float vec_xrx (unsigned int index, vector float data);
18530 @end smallexample
18532 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
18533 perform pairwise comparisons between the elements at the same
18534 positions within their two vector arguments.
18535 The @code{vec_all_nez} function returns a
18536 non-zero value if and only if all pairwise comparisons are not
18537 equal and no element of either vector argument contains a zero.
18538 The @code{vec_any_eqz} function returns a
18539 non-zero value if and only if at least one pairwise comparison is equal
18540 or if at least one element of either vector argument contains a zero.
18541 The @code{vec_cmpnez} function returns a vector of the same type as
18542 its two arguments, within which each element consists of all ones to
18543 denote that either the corresponding elements of the incoming arguments are
18544 not equal or that at least one of the corresponding elements contains
18545 zero.  Otherwise, the element of the returned vector contains all zeros.
18547 The @code{vec_cntlz_lsbb} function returns the count of the number of
18548 consecutive leading byte elements (starting from position 0 within the
18549 supplied vector argument) for which the least-significant bit
18550 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
18551 the number of consecutive trailing byte elements (starting from
18552 position 15 and counting backwards within the supplied vector
18553 argument) for which the least-significant bit equals zero.
18555 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
18556 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
18557 function loads a variable length vector from memory.  The
18558 @code{vec_xst_len} function stores a variable length vector to memory.
18559 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
18560 @code{addr} argument represents the memory address to or from which
18561 data will be transferred, and the
18562 @code{len} argument represents the number of bytes to be
18563 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
18564 If this expression's value is not a multiple of the vector element's
18565 size, the behavior of this function is undefined.
18566 In the case that the underlying computer is configured to run in
18567 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
18568 the corresponding vector.  In little-endian mode, the data transfer
18569 moves bytes @code{(16 - len)} to @code{15} of the corresponding
18570 vector.  For the load function, any bytes of the result vector that
18571 are not loaded from memory are set to zero.
18572 The value of the @code{addr} argument need not be aligned on a
18573 multiple of the vector's element size.
18575 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
18576 element selected by the @code{index} argument from the vector
18577 represented by the @code{data} argument.  The @code{index} argument
18578 always specifies a byte offset, regardless of the size of the vector
18579 element.  With @code{vec_xlx}, @code{index} is the offset of the first
18580 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
18581 represents the last byte of the element to be extracted, measured
18582 from the right end of the vector.  In other words, the last byte of
18583 the element to be extracted is found at position @code{(15 - index)}.
18584 There is no requirement that @code{index} be a multiple of the vector
18585 element size.  However, if the size of the vector element added to
18586 @code{index} is greater than 15, the content of the returned value is
18587 undefined.
18589 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18590 are available:
18592 @smallexample
18593 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
18595 vector bool char vec_cmpne (vector bool char, vector bool char);
18596 vector bool char vec_cmpne (vector signed char, vector signed char);
18597 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
18598 vector bool int vec_cmpne (vector bool int, vector bool int);
18599 vector bool int vec_cmpne (vector signed int, vector signed int);
18600 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
18601 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18602 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
18603 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
18604 vector bool short vec_cmpne (vector bool short, vector bool short);
18605 vector bool short vec_cmpne (vector signed short, vector signed short);
18606 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
18607 vector bool long long vec_cmpne (vector double, vector double);
18608 vector bool int vec_cmpne (vector float, vector float);
18610 vector float vec_extract_fp32_from_shorth (vector unsigned short);
18611 vector float vec_extract_fp32_from_shortl (vector unsigned short);
18613 vector long long vec_vctz (vector long long);
18614 vector unsigned long long vec_vctz (vector unsigned long long);
18615 vector int vec_vctz (vector int);
18616 vector unsigned int vec_vctz (vector int);
18617 vector short vec_vctz (vector short);
18618 vector unsigned short vec_vctz (vector unsigned short);
18619 vector signed char vec_vctz (vector signed char);
18620 vector unsigned char vec_vctz (vector unsigned char);
18622 vector signed char vec_vctzb (vector signed char);
18623 vector unsigned char vec_vctzb (vector unsigned char);
18625 vector long long vec_vctzd (vector long long);
18626 vector unsigned long long vec_vctzd (vector unsigned long long);
18628 vector short vec_vctzh (vector short);
18629 vector unsigned short vec_vctzh (vector unsigned short);
18631 vector int vec_vctzw (vector int);
18632 vector unsigned int vec_vctzw (vector int);
18634 vector unsigned long long vec_extract4b (vector unsigned char, const int);
18636 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
18637                                    const int);
18638 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18639                                    const int);
18641 vector unsigned int vec_parity_lsbb (vector signed int);
18642 vector unsigned int vec_parity_lsbb (vector unsigned int);
18643 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
18644 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
18645 vector unsigned long long vec_parity_lsbb (vector signed long long);
18646 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
18648 vector int vec_vprtyb (vector int);
18649 vector unsigned int vec_vprtyb (vector unsigned int);
18650 vector long long vec_vprtyb (vector long long);
18651 vector unsigned long long vec_vprtyb (vector unsigned long long);
18653 vector int vec_vprtybw (vector int);
18654 vector unsigned int vec_vprtybw (vector unsigned int);
18656 vector long long vec_vprtybd (vector long long);
18657 vector unsigned long long vec_vprtybd (vector unsigned long long);
18658 @end smallexample
18660 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18661 are available:
18663 @smallexample
18664 vector long vec_vprtyb (vector long);
18665 vector unsigned long vec_vprtyb (vector unsigned long);
18666 vector __int128_t vec_vprtyb (vector __int128_t);
18667 vector __uint128_t vec_vprtyb (vector __uint128_t);
18669 vector long vec_vprtybd (vector long);
18670 vector unsigned long vec_vprtybd (vector unsigned long);
18672 vector __int128_t vec_vprtybq (vector __int128_t);
18673 vector __uint128_t vec_vprtybd (vector __uint128_t);
18674 @end smallexample
18676 The following built-in vector functions are available for the PowerPC family
18677 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18678 @smallexample
18679 __vector unsigned char
18680 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18681 __vector unsigned char
18682 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18683 @end smallexample
18685 The @code{vec_slv} and @code{vec_srv} functions operate on
18686 all of the bytes of their @code{src} and @code{shift_distance}
18687 arguments in parallel.  The behavior of the @code{vec_slv} is as if
18688 there existed a temporary array of 17 unsigned characters
18689 @code{slv_array} within which elements 0 through 15 are the same as
18690 the entries in the @code{src} array and element 16 equals 0.  The
18691 result returned from the @code{vec_slv} function is a
18692 @code{__vector} of 16 unsigned characters within which element
18693 @code{i} is computed using the C expression
18694 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18695 shift_distance[i]))},
18696 with this resulting value coerced to the @code{unsigned char} type.
18697 The behavior of the @code{vec_srv} is as if
18698 there existed a temporary array of 17 unsigned characters
18699 @code{srv_array} within which element 0 equals zero and
18700 elements 1 through 16 equal the elements 0 through 15 of
18701 the @code{src} array.  The
18702 result returned from the @code{vec_srv} function is a
18703 @code{__vector} of 16 unsigned characters within which element
18704 @code{i} is computed using the C expression
18705 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18706 (0x07 & shift_distance[i]))},
18707 with this resulting value coerced to the @code{unsigned char} type.
18709 The following built-in functions are available for the PowerPC family
18710 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18711 @smallexample
18712 __vector unsigned char
18713 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18714 __vector unsigned short
18715 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18716 __vector unsigned int
18717 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18719 __vector unsigned char
18720 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18721 __vector unsigned short
18722 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18723 __vector unsigned int
18724 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18725 @end smallexample
18727 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18728 @code{vec_absdw} built-in functions each computes the absolute
18729 differences of the pairs of vector elements supplied in its two vector
18730 arguments, placing the absolute differences into the corresponding
18731 elements of the vector result.
18733 The following built-in functions are available for the PowerPC family
18734 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18735 @smallexample
18736 __vector unsigned int vec_extract_exp (__vector float source);
18737 __vector unsigned long long int vec_extract_exp (__vector double source);
18739 __vector unsigned int vec_extract_sig (__vector float source);
18740 __vector unsigned long long int vec_extract_sig (__vector double source);
18742 __vector float vec_insert_exp (__vector unsigned int significands,
18743                                __vector unsigned int exponents);
18744 __vector float vec_insert_exp (__vector unsigned float significands,
18745                                __vector unsigned int exponents);
18746 __vector double vec_insert_exp (__vector unsigned long long int significands,
18747                                 __vector unsigned long long int exponents);
18748 __vector double vec_insert_exp (__vector unsigned double significands,
18749                                 __vector unsigned long long int exponents);
18751 __vector bool int vec_test_data_class (__vector float source, const int condition);
18752 __vector bool long long int vec_test_data_class (__vector double source,
18753                                                  const int condition);
18754 @end smallexample
18756 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18757 functions return vectors representing the significands and biased
18758 exponent values of their @code{source} arguments respectively.
18759 Within the result vector returned by @code{vec_extract_sig}, the
18760 @code{0x800000} bit of each vector element returned when the
18761 function's @code{source} argument is of type @code{float} is set to 1
18762 if the corresponding floating point value is in normalized form.
18763 Otherwise, this bit is set to 0.  When the @code{source} argument is
18764 of type @code{double}, the @code{0x10000000000000} bit within each of
18765 the result vector's elements is set according to the same rules.
18766 Note that the sign of the significand is not represented in the result
18767 returned from the @code{vec_extract_sig} function.  To extract the
18768 sign bits, use the
18769 @code{vec_cpsgn} function, which returns a new vector within which all
18770 of the sign bits of its second argument vector are overwritten with the
18771 sign bits copied from the coresponding elements of its first argument
18772 vector, and all other (non-sign) bits of the second argument vector
18773 are copied unchanged into the result vector.
18775 The @code{vec_insert_exp} built-in functions return a vector of
18776 single- or double-precision floating
18777 point values constructed by assembling the values of their
18778 @code{significands} and @code{exponents} arguments into the
18779 corresponding elements of the returned vector.
18780 The sign of each
18781 element of the result is copied from the most significant bit of the
18782 corresponding entry within the @code{significands} argument.
18783 Note that the relevant
18784 bits of the @code{significands} argument are the same, for both integer
18785 and floating point types.
18787 significand and exponent components of each element of the result are
18788 composed of the least significant bits of the corresponding
18789 @code{significands} element and the least significant bits of the
18790 corresponding @code{exponents} element.
18792 The @code{vec_test_data_class} built-in function returns a vector
18793 representing the results of testing the @code{source} vector for the
18794 condition selected by the @code{condition} argument.  The
18795 @code{condition} argument must be a compile-time constant integer with
18796 value not exceeding 127.  The
18797 @code{condition} argument is encoded as a bitmask with each bit
18798 enabling the testing of a different condition, as characterized by the
18799 following:
18800 @smallexample
18801 0x40    Test for NaN
18802 0x20    Test for +Infinity
18803 0x10    Test for -Infinity
18804 0x08    Test for +Zero
18805 0x04    Test for -Zero
18806 0x02    Test for +Denormal
18807 0x01    Test for -Denormal
18808 @end smallexample
18810 If any of the enabled test conditions is true, the corresponding entry
18811 in the result vector is -1.  Otherwise (all of the enabled test
18812 conditions are false), the corresponding entry of the result vector is 0.
18814 The following built-in functions are available for the PowerPC family
18815 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18816 @smallexample
18817 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
18818                               vector unsigned int);
18819 vector unsigned long long vec_rlmi (vector unsigned long long,
18820                                     vector unsigned long long,
18821                                     vector unsigned long long);
18822 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
18823                               vector unsigned int);
18824 vector unsigned long long vec_rlnm (vector unsigned long long,
18825                                     vector unsigned long long,
18826                                     vector unsigned long long);
18827 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
18828 vector unsigned long long vec_vrlnm (vector unsigned long long,
18829                                      vector unsigned long long);
18830 @end smallexample
18832 The result of @code{vec_rlmi} is obtained by rotating each element of
18833 the first argument vector left and inserting it under mask into the
18834 second argument vector.  The third argument vector contains the mask
18835 beginning in bits 11:15, the mask end in bits 19:23, and the shift
18836 count in bits 27:31, of each element.
18838 The result of @code{vec_rlnm} is obtained by rotating each element of
18839 the first argument vector left and ANDing it with a mask specified by
18840 the second and third argument vectors.  The second argument vector
18841 contains the shift count for each element in the low-order byte.  The
18842 third argument vector contains the mask end for each element in the
18843 low-order byte, with the mask begin in the next higher byte.
18845 The result of @code{vec_vrlnm} is obtained by rotating each element
18846 of the first argument vector left and ANDing it with a mask.  The
18847 second argument vector contains the mask  beginning in bits 11:15,
18848 the mask end in bits 19:23, and the shift count in bits 27:31,
18849 of each element.
18851 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18852 are available:
18853 @smallexample
18854 vector signed bool char vec_revb (vector signed char);
18855 vector signed char vec_revb (vector signed char);
18856 vector unsigned char vec_revb (vector unsigned char);
18857 vector bool short vec_revb (vector bool short);
18858 vector short vec_revb (vector short);
18859 vector unsigned short vec_revb (vector unsigned short);
18860 vector bool int vec_revb (vector bool int);
18861 vector int vec_revb (vector int);
18862 vector unsigned int vec_revb (vector unsigned int);
18863 vector float vec_revb (vector float);
18864 vector bool long long vec_revb (vector bool long long);
18865 vector long long vec_revb (vector long long);
18866 vector unsigned long long vec_revb (vector unsigned long long);
18867 vector double vec_revb (vector double);
18868 @end smallexample
18870 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18871 are available:
18872 @smallexample
18873 vector long vec_revb (vector long);
18874 vector unsigned long vec_revb (vector unsigned long);
18875 vector __int128_t vec_revb (vector __int128_t);
18876 vector __uint128_t vec_revb (vector __uint128_t);
18877 @end smallexample
18879 The @code{vec_revb} built-in function reverses the bytes on an element
18880 by element basis.  A vector of @code{vector unsigned char} or
18881 @code{vector signed char} reverses the bytes in the whole word.
18883 If the cryptographic instructions are enabled (@option{-mcrypto} or
18884 @option{-mcpu=power8}), the following builtins are enabled.
18886 @smallexample
18887 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
18889 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
18890                                                     vector unsigned long long);
18892 vector unsigned long long __builtin_crypto_vcipherlast
18893                                      (vector unsigned long long,
18894                                       vector unsigned long long);
18896 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
18897                                                      vector unsigned long long);
18899 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
18900                                                          vector unsigned long long);
18902 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
18903                                                 vector unsigned char,
18904                                                 vector unsigned char);
18906 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
18907                                                  vector unsigned short,
18908                                                  vector unsigned short);
18910 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
18911                                                vector unsigned int,
18912                                                vector unsigned int);
18914 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
18915                                                      vector unsigned long long,
18916                                                      vector unsigned long long);
18918 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
18919                                                vector unsigned char);
18921 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
18922                                                 vector unsigned short);
18924 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
18925                                               vector unsigned int);
18927 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
18928                                                     vector unsigned long long);
18930 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
18931                                                        int, int);
18933 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
18934 @end smallexample
18936 The second argument to @var{__builtin_crypto_vshasigmad} and
18937 @var{__builtin_crypto_vshasigmaw} must be a constant
18938 integer that is 0 or 1.  The third argument to these built-in functions
18939 must be a constant integer in the range of 0 to 15.
18941 If the ISA 3.0 instruction set additions 
18942 are enabled (@option{-mcpu=power9}), the following additional
18943 functions are available for both 32-bit and 64-bit targets.
18944 @smallexample
18945 vector short vec_xl (int, vector short *);
18946 vector short vec_xl (int, short *);
18947 vector unsigned short vec_xl (int, vector unsigned short *);
18948 vector unsigned short vec_xl (int, unsigned short *);
18949 vector char vec_xl (int, vector char *);
18950 vector char vec_xl (int, char *);
18951 vector unsigned char vec_xl (int, vector unsigned char *);
18952 vector unsigned char vec_xl (int, unsigned char *);
18954 void vec_xst (vector short, int, vector short *);
18955 void vec_xst (vector short, int, short *);
18956 void vec_xst (vector unsigned short, int, vector unsigned short *);
18957 void vec_xst (vector unsigned short, int, unsigned short *);
18958 void vec_xst (vector char, int, vector char *);
18959 void vec_xst (vector char, int, char *);
18960 void vec_xst (vector unsigned char, int, vector unsigned char *);
18961 void vec_xst (vector unsigned char, int, unsigned char *);
18962 @end smallexample
18963 @node PowerPC Hardware Transactional Memory Built-in Functions
18964 @subsection PowerPC Hardware Transactional Memory Built-in Functions
18965 GCC provides two interfaces for accessing the Hardware Transactional
18966 Memory (HTM) instructions available on some of the PowerPC family
18967 of processors (eg, POWER8).  The two interfaces come in a low level
18968 interface, consisting of built-in functions specific to PowerPC and a
18969 higher level interface consisting of inline functions that are common
18970 between PowerPC and S/390.
18972 @subsubsection PowerPC HTM Low Level Built-in Functions
18974 The following low level built-in functions are available with
18975 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
18976 They all generate the machine instruction that is part of the name.
18978 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
18979 the full 4-bit condition register value set by their associated hardware
18980 instruction.  The header file @code{htmintrin.h} defines some macros that can
18981 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
18982 returns a simple true or false value depending on whether a transaction was
18983 successfully started or not.  The arguments of the builtins match exactly the
18984 type and order of the associated hardware instruction's operands, except for
18985 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18986 Refer to the ISA manual for a description of each instruction's operands.
18988 @smallexample
18989 unsigned int __builtin_tbegin (unsigned int)
18990 unsigned int __builtin_tend (unsigned int)
18992 unsigned int __builtin_tabort (unsigned int)
18993 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18994 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18995 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18996 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18998 unsigned int __builtin_tcheck (void)
18999 unsigned int __builtin_treclaim (unsigned int)
19000 unsigned int __builtin_trechkpt (void)
19001 unsigned int __builtin_tsr (unsigned int)
19002 @end smallexample
19004 In addition to the above HTM built-ins, we have added built-ins for
19005 some common extended mnemonics of the HTM instructions:
19007 @smallexample
19008 unsigned int __builtin_tendall (void)
19009 unsigned int __builtin_tresume (void)
19010 unsigned int __builtin_tsuspend (void)
19011 @end smallexample
19013 Note that the semantics of the above HTM builtins are required to mimic
19014 the locking semantics used for critical sections.  Builtins that are used
19015 to create a new transaction or restart a suspended transaction must have
19016 lock acquisition like semantics while those builtins that end or suspend a
19017 transaction must have lock release like semantics.  Specifically, this must
19018 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19019 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19020 that returns 0, and lock release is as-if an execution of
19021 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19022 implicit implementation-defined lock used for all transactions.  The HTM
19023 instructions associated with with the builtins inherently provide the
19024 correct acquisition and release hardware barriers required.  However,
19025 the compiler must also be prohibited from moving loads and stores across
19026 the builtins in a way that would violate their semantics.  This has been
19027 accomplished by adding memory barriers to the associated HTM instructions
19028 (which is a conservative approach to provide acquire and release semantics).
19029 Earlier versions of the compiler did not treat the HTM instructions as
19030 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19031 be used to determine whether the current compiler treats HTM instructions
19032 as memory barriers or not.  This allows the user to explicitly add memory
19033 barriers to their code when using an older version of the compiler.
19035 The following set of built-in functions are available to gain access
19036 to the HTM specific special purpose registers.
19038 @smallexample
19039 unsigned long __builtin_get_texasr (void)
19040 unsigned long __builtin_get_texasru (void)
19041 unsigned long __builtin_get_tfhar (void)
19042 unsigned long __builtin_get_tfiar (void)
19044 void __builtin_set_texasr (unsigned long);
19045 void __builtin_set_texasru (unsigned long);
19046 void __builtin_set_tfhar (unsigned long);
19047 void __builtin_set_tfiar (unsigned long);
19048 @end smallexample
19050 Example usage of these low level built-in functions may look like:
19052 @smallexample
19053 #include <htmintrin.h>
19055 int num_retries = 10;
19057 while (1)
19058   @{
19059     if (__builtin_tbegin (0))
19060       @{
19061         /* Transaction State Initiated.  */
19062         if (is_locked (lock))
19063           __builtin_tabort (0);
19064         ... transaction code...
19065         __builtin_tend (0);
19066         break;
19067       @}
19068     else
19069       @{
19070         /* Transaction State Failed.  Use locks if the transaction
19071            failure is "persistent" or we've tried too many times.  */
19072         if (num_retries-- <= 0
19073             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19074           @{
19075             acquire_lock (lock);
19076             ... non transactional fallback path...
19077             release_lock (lock);
19078             break;
19079           @}
19080       @}
19081   @}
19082 @end smallexample
19084 One final built-in function has been added that returns the value of
19085 the 2-bit Transaction State field of the Machine Status Register (MSR)
19086 as stored in @code{CR0}.
19088 @smallexample
19089 unsigned long __builtin_ttest (void)
19090 @end smallexample
19092 This built-in can be used to determine the current transaction state
19093 using the following code example:
19095 @smallexample
19096 #include <htmintrin.h>
19098 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19100 if (tx_state == _HTM_TRANSACTIONAL)
19101   @{
19102     /* Code to use in transactional state.  */
19103   @}
19104 else if (tx_state == _HTM_NONTRANSACTIONAL)
19105   @{
19106     /* Code to use in non-transactional state.  */
19107   @}
19108 else if (tx_state == _HTM_SUSPENDED)
19109   @{
19110     /* Code to use in transaction suspended state.  */
19111   @}
19112 @end smallexample
19114 @subsubsection PowerPC HTM High Level Inline Functions
19116 The following high level HTM interface is made available by including
19117 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19118 where CPU is `power8' or later.  This interface is common between PowerPC
19119 and S/390, allowing users to write one HTM source implementation that
19120 can be compiled and executed on either system.
19122 @smallexample
19123 long __TM_simple_begin (void)
19124 long __TM_begin (void* const TM_buff)
19125 long __TM_end (void)
19126 void __TM_abort (void)
19127 void __TM_named_abort (unsigned char const code)
19128 void __TM_resume (void)
19129 void __TM_suspend (void)
19131 long __TM_is_user_abort (void* const TM_buff)
19132 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19133 long __TM_is_illegal (void* const TM_buff)
19134 long __TM_is_footprint_exceeded (void* const TM_buff)
19135 long __TM_nesting_depth (void* const TM_buff)
19136 long __TM_is_nested_too_deep(void* const TM_buff)
19137 long __TM_is_conflict(void* const TM_buff)
19138 long __TM_is_failure_persistent(void* const TM_buff)
19139 long __TM_failure_address(void* const TM_buff)
19140 long long __TM_failure_code(void* const TM_buff)
19141 @end smallexample
19143 Using these common set of HTM inline functions, we can create
19144 a more portable version of the HTM example in the previous
19145 section that will work on either PowerPC or S/390:
19147 @smallexample
19148 #include <htmxlintrin.h>
19150 int num_retries = 10;
19151 TM_buff_type TM_buff;
19153 while (1)
19154   @{
19155     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19156       @{
19157         /* Transaction State Initiated.  */
19158         if (is_locked (lock))
19159           __TM_abort ();
19160         ... transaction code...
19161         __TM_end ();
19162         break;
19163       @}
19164     else
19165       @{
19166         /* Transaction State Failed.  Use locks if the transaction
19167            failure is "persistent" or we've tried too many times.  */
19168         if (num_retries-- <= 0
19169             || __TM_is_failure_persistent (TM_buff))
19170           @{
19171             acquire_lock (lock);
19172             ... non transactional fallback path...
19173             release_lock (lock);
19174             break;
19175           @}
19176       @}
19177   @}
19178 @end smallexample
19180 @node PowerPC Atomic Memory Operation Functions
19181 @subsection PowerPC Atomic Memory Operation Functions
19182 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19183 instructions.  GCC provides support for these instructions in 64-bit
19184 environments.  All of the functions are declared in the include file
19185 @code{amo.h}.
19187 The functions supported are:
19189 @smallexample
19190 #include <amo.h>
19192 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19193 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19194 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19195 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19196 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19197 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19198 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19200 int32_t amo_lwat_sadd (int32_t *, int32_t);
19201 int32_t amo_lwat_smax (int32_t *, int32_t);
19202 int32_t amo_lwat_smin (int32_t *, int32_t);
19203 int32_t amo_lwat_sswap (int32_t *, int32_t);
19205 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19206 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19207 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19208 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19209 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19210 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19211 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19213 int64_t amo_ldat_sadd (int64_t *, int64_t);
19214 int64_t amo_ldat_smax (int64_t *, int64_t);
19215 int64_t amo_ldat_smin (int64_t *, int64_t);
19216 int64_t amo_ldat_sswap (int64_t *, int64_t);
19218 void amo_stwat_add (uint32_t *, uint32_t);
19219 void amo_stwat_xor (uint32_t *, uint32_t);
19220 void amo_stwat_ior (uint32_t *, uint32_t);
19221 void amo_stwat_and (uint32_t *, uint32_t);
19222 void amo_stwat_umax (uint32_t *, uint32_t);
19223 void amo_stwat_umin (uint32_t *, uint32_t);
19225 void amo_stwat_sadd (int32_t *, int32_t);
19226 void amo_stwat_smax (int32_t *, int32_t);
19227 void amo_stwat_smin (int32_t *, int32_t);
19229 void amo_stdat_add (uint64_t *, uint64_t);
19230 void amo_stdat_xor (uint64_t *, uint64_t);
19231 void amo_stdat_ior (uint64_t *, uint64_t);
19232 void amo_stdat_and (uint64_t *, uint64_t);
19233 void amo_stdat_umax (uint64_t *, uint64_t);
19234 void amo_stdat_umin (uint64_t *, uint64_t);
19236 void amo_stdat_sadd (int64_t *, int64_t);
19237 void amo_stdat_smax (int64_t *, int64_t);
19238 void amo_stdat_smin (int64_t *, int64_t);
19239 @end smallexample
19241 @node RX Built-in Functions
19242 @subsection RX Built-in Functions
19243 GCC supports some of the RX instructions which cannot be expressed in
19244 the C programming language via the use of built-in functions.  The
19245 following functions are supported:
19247 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19248 Generates the @code{brk} machine instruction.
19249 @end deftypefn
19251 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19252 Generates the @code{clrpsw} machine instruction to clear the specified
19253 bit in the processor status word.
19254 @end deftypefn
19256 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19257 Generates the @code{int} machine instruction to generate an interrupt
19258 with the specified value.
19259 @end deftypefn
19261 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19262 Generates the @code{machi} machine instruction to add the result of
19263 multiplying the top 16 bits of the two arguments into the
19264 accumulator.
19265 @end deftypefn
19267 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19268 Generates the @code{maclo} machine instruction to add the result of
19269 multiplying the bottom 16 bits of the two arguments into the
19270 accumulator.
19271 @end deftypefn
19273 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19274 Generates the @code{mulhi} machine instruction to place the result of
19275 multiplying the top 16 bits of the two arguments into the
19276 accumulator.
19277 @end deftypefn
19279 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19280 Generates the @code{mullo} machine instruction to place the result of
19281 multiplying the bottom 16 bits of the two arguments into the
19282 accumulator.
19283 @end deftypefn
19285 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19286 Generates the @code{mvfachi} machine instruction to read the top
19287 32 bits of the accumulator.
19288 @end deftypefn
19290 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19291 Generates the @code{mvfacmi} machine instruction to read the middle
19292 32 bits of the accumulator.
19293 @end deftypefn
19295 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19296 Generates the @code{mvfc} machine instruction which reads the control
19297 register specified in its argument and returns its value.
19298 @end deftypefn
19300 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19301 Generates the @code{mvtachi} machine instruction to set the top
19302 32 bits of the accumulator.
19303 @end deftypefn
19305 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19306 Generates the @code{mvtaclo} machine instruction to set the bottom
19307 32 bits of the accumulator.
19308 @end deftypefn
19310 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19311 Generates the @code{mvtc} machine instruction which sets control
19312 register number @code{reg} to @code{val}.
19313 @end deftypefn
19315 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19316 Generates the @code{mvtipl} machine instruction set the interrupt
19317 priority level.
19318 @end deftypefn
19320 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19321 Generates the @code{racw} machine instruction to round the accumulator
19322 according to the specified mode.
19323 @end deftypefn
19325 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19326 Generates the @code{revw} machine instruction which swaps the bytes in
19327 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19328 and also bits 16--23 occupy bits 24--31 and vice versa.
19329 @end deftypefn
19331 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19332 Generates the @code{rmpa} machine instruction which initiates a
19333 repeated multiply and accumulate sequence.
19334 @end deftypefn
19336 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19337 Generates the @code{round} machine instruction which returns the
19338 floating-point argument rounded according to the current rounding mode
19339 set in the floating-point status word register.
19340 @end deftypefn
19342 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19343 Generates the @code{sat} machine instruction which returns the
19344 saturated value of the argument.
19345 @end deftypefn
19347 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19348 Generates the @code{setpsw} machine instruction to set the specified
19349 bit in the processor status word.
19350 @end deftypefn
19352 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19353 Generates the @code{wait} machine instruction.
19354 @end deftypefn
19356 @node S/390 System z Built-in Functions
19357 @subsection S/390 System z Built-in Functions
19358 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19359 Generates the @code{tbegin} machine instruction starting a
19360 non-constrained hardware transaction.  If the parameter is non-NULL the
19361 memory area is used to store the transaction diagnostic buffer and
19362 will be passed as first operand to @code{tbegin}.  This buffer can be
19363 defined using the @code{struct __htm_tdb} C struct defined in
19364 @code{htmintrin.h} and must reside on a double-word boundary.  The
19365 second tbegin operand is set to @code{0xff0c}. This enables
19366 save/restore of all GPRs and disables aborts for FPR and AR
19367 manipulations inside the transaction body.  The condition code set by
19368 the tbegin instruction is returned as integer value.  The tbegin
19369 instruction by definition overwrites the content of all FPRs.  The
19370 compiler will generate code which saves and restores the FPRs.  For
19371 soft-float code it is recommended to used the @code{*_nofloat}
19372 variant.  In order to prevent a TDB from being written it is required
19373 to pass a constant zero value as parameter.  Passing a zero value
19374 through a variable is not sufficient.  Although modifications of
19375 access registers inside the transaction will not trigger an
19376 transaction abort it is not supported to actually modify them.  Access
19377 registers do not get saved when entering a transaction. They will have
19378 undefined state when reaching the abort code.
19379 @end deftypefn
19381 Macros for the possible return codes of tbegin are defined in the
19382 @code{htmintrin.h} header file:
19384 @table @code
19385 @item _HTM_TBEGIN_STARTED
19386 @code{tbegin} has been executed as part of normal processing.  The
19387 transaction body is supposed to be executed.
19388 @item _HTM_TBEGIN_INDETERMINATE
19389 The transaction was aborted due to an indeterminate condition which
19390 might be persistent.
19391 @item _HTM_TBEGIN_TRANSIENT
19392 The transaction aborted due to a transient failure.  The transaction
19393 should be re-executed in that case.
19394 @item _HTM_TBEGIN_PERSISTENT
19395 The transaction aborted due to a persistent failure.  Re-execution
19396 under same circumstances will not be productive.
19397 @end table
19399 @defmac _HTM_FIRST_USER_ABORT_CODE
19400 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19401 specifies the first abort code which can be used for
19402 @code{__builtin_tabort}.  Values below this threshold are reserved for
19403 machine use.
19404 @end defmac
19406 @deftp {Data type} {struct __htm_tdb}
19407 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19408 the structure of the transaction diagnostic block as specified in the
19409 Principles of Operation manual chapter 5-91.
19410 @end deftp
19412 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19413 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19414 Using this variant in code making use of FPRs will leave the FPRs in
19415 undefined state when entering the transaction abort handler code.
19416 @end deftypefn
19418 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19419 In addition to @code{__builtin_tbegin} a loop for transient failures
19420 is generated.  If tbegin returns a condition code of 2 the transaction
19421 will be retried as often as specified in the second argument.  The
19422 perform processor assist instruction is used to tell the CPU about the
19423 number of fails so far.
19424 @end deftypefn
19426 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19427 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19428 restores.  Using this variant in code making use of FPRs will leave
19429 the FPRs in undefined state when entering the transaction abort
19430 handler code.
19431 @end deftypefn
19433 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19434 Generates the @code{tbeginc} machine instruction starting a constrained
19435 hardware transaction.  The second operand is set to @code{0xff08}.
19436 @end deftypefn
19438 @deftypefn {Built-in Function} int __builtin_tend (void)
19439 Generates the @code{tend} machine instruction finishing a transaction
19440 and making the changes visible to other threads.  The condition code
19441 generated by tend is returned as integer value.
19442 @end deftypefn
19444 @deftypefn {Built-in Function} void __builtin_tabort (int)
19445 Generates the @code{tabort} machine instruction with the specified
19446 abort code.  Abort codes from 0 through 255 are reserved and will
19447 result in an error message.
19448 @end deftypefn
19450 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19451 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19452 integer parameter is loaded into rX and a value of zero is loaded into
19453 rY.  The integer parameter specifies the number of times the
19454 transaction repeatedly aborted.
19455 @end deftypefn
19457 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19458 Generates the @code{etnd} machine instruction.  The current nesting
19459 depth is returned as integer value.  For a nesting depth of 0 the code
19460 is not executed as part of an transaction.
19461 @end deftypefn
19463 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19465 Generates the @code{ntstg} machine instruction.  The second argument
19466 is written to the first arguments location.  The store operation will
19467 not be rolled-back in case of an transaction abort.
19468 @end deftypefn
19470 @node SH Built-in Functions
19471 @subsection SH Built-in Functions
19472 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19473 families of processors:
19475 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19476 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
19477 used by system code that manages threads and execution contexts.  The compiler
19478 normally does not generate code that modifies the contents of @samp{GBR} and
19479 thus the value is preserved across function calls.  Changing the @samp{GBR}
19480 value in user code must be done with caution, since the compiler might use
19481 @samp{GBR} in order to access thread local variables.
19483 @end deftypefn
19485 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19486 Returns the value that is currently set in the @samp{GBR} register.
19487 Memory loads and stores that use the thread pointer as a base address are
19488 turned into @samp{GBR} based displacement loads and stores, if possible.
19489 For example:
19490 @smallexample
19491 struct my_tcb
19493    int a, b, c, d, e;
19496 int get_tcb_value (void)
19498   // Generate @samp{mov.l @@(8,gbr),r0} instruction
19499   return ((my_tcb*)__builtin_thread_pointer ())->c;
19502 @end smallexample
19503 @end deftypefn
19505 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19506 Returns the value that is currently set in the @samp{FPSCR} register.
19507 @end deftypefn
19509 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19510 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19511 preserving the current values of the FR, SZ and PR bits.
19512 @end deftypefn
19514 @node SPARC VIS Built-in Functions
19515 @subsection SPARC VIS Built-in Functions
19517 GCC supports SIMD operations on the SPARC using both the generic vector
19518 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19519 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
19520 switch, the VIS extension is exposed as the following built-in functions:
19522 @smallexample
19523 typedef int v1si __attribute__ ((vector_size (4)));
19524 typedef int v2si __attribute__ ((vector_size (8)));
19525 typedef short v4hi __attribute__ ((vector_size (8)));
19526 typedef short v2hi __attribute__ ((vector_size (4)));
19527 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19528 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19530 void __builtin_vis_write_gsr (int64_t);
19531 int64_t __builtin_vis_read_gsr (void);
19533 void * __builtin_vis_alignaddr (void *, long);
19534 void * __builtin_vis_alignaddrl (void *, long);
19535 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19536 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19537 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19538 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19540 v4hi __builtin_vis_fexpand (v4qi);
19542 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19543 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19544 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19545 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19546 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19547 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19548 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19550 v4qi __builtin_vis_fpack16 (v4hi);
19551 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19552 v2hi __builtin_vis_fpackfix (v2si);
19553 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19555 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19557 long __builtin_vis_edge8 (void *, void *);
19558 long __builtin_vis_edge8l (void *, void *);
19559 long __builtin_vis_edge16 (void *, void *);
19560 long __builtin_vis_edge16l (void *, void *);
19561 long __builtin_vis_edge32 (void *, void *);
19562 long __builtin_vis_edge32l (void *, void *);
19564 long __builtin_vis_fcmple16 (v4hi, v4hi);
19565 long __builtin_vis_fcmple32 (v2si, v2si);
19566 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19567 long __builtin_vis_fcmpne32 (v2si, v2si);
19568 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19569 long __builtin_vis_fcmpgt32 (v2si, v2si);
19570 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19571 long __builtin_vis_fcmpeq32 (v2si, v2si);
19573 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19574 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19575 v2si __builtin_vis_fpadd32 (v2si, v2si);
19576 v1si __builtin_vis_fpadd32s (v1si, v1si);
19577 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19578 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19579 v2si __builtin_vis_fpsub32 (v2si, v2si);
19580 v1si __builtin_vis_fpsub32s (v1si, v1si);
19582 long __builtin_vis_array8 (long, long);
19583 long __builtin_vis_array16 (long, long);
19584 long __builtin_vis_array32 (long, long);
19585 @end smallexample
19587 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19588 functions also become available:
19590 @smallexample
19591 long __builtin_vis_bmask (long, long);
19592 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19593 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19594 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19595 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19597 long __builtin_vis_edge8n (void *, void *);
19598 long __builtin_vis_edge8ln (void *, void *);
19599 long __builtin_vis_edge16n (void *, void *);
19600 long __builtin_vis_edge16ln (void *, void *);
19601 long __builtin_vis_edge32n (void *, void *);
19602 long __builtin_vis_edge32ln (void *, void *);
19603 @end smallexample
19605 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19606 functions also become available:
19608 @smallexample
19609 void __builtin_vis_cmask8 (long);
19610 void __builtin_vis_cmask16 (long);
19611 void __builtin_vis_cmask32 (long);
19613 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19615 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19616 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19617 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19618 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19619 v2si __builtin_vis_fsll16 (v2si, v2si);
19620 v2si __builtin_vis_fslas16 (v2si, v2si);
19621 v2si __builtin_vis_fsrl16 (v2si, v2si);
19622 v2si __builtin_vis_fsra16 (v2si, v2si);
19624 long __builtin_vis_pdistn (v8qi, v8qi);
19626 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19628 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19629 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19631 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19632 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19633 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19634 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19635 v2si __builtin_vis_fpadds32 (v2si, v2si);
19636 v1si __builtin_vis_fpadds32s (v1si, v1si);
19637 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19638 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19640 long __builtin_vis_fucmple8 (v8qi, v8qi);
19641 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19642 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19643 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19645 float __builtin_vis_fhadds (float, float);
19646 double __builtin_vis_fhaddd (double, double);
19647 float __builtin_vis_fhsubs (float, float);
19648 double __builtin_vis_fhsubd (double, double);
19649 float __builtin_vis_fnhadds (float, float);
19650 double __builtin_vis_fnhaddd (double, double);
19652 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19653 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19654 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19655 @end smallexample
19657 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19658 functions also become available:
19660 @smallexample
19661 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19662 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19663 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19664 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19666 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19667 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19668 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19669 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19671 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19672 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19673 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19674 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19675 long __builtin_vis_fpcmpule32 (v2si, v2si);
19676 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19678 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19679 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19680 v2si __builtin_vis_fpmax32 (v2si, v2si);
19682 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19683 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19684 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19687 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19688 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19689 v2si __builtin_vis_fpmin32 (v2si, v2si);
19691 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19692 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19693 v2si __builtin_vis_fpminu32 (v2si, v2si);
19694 @end smallexample
19696 When you use the @option{-mvis4b} switch, the VIS version 4.0B
19697 built-in functions also become available:
19699 @smallexample
19700 v8qi __builtin_vis_dictunpack8 (double, int);
19701 v4hi __builtin_vis_dictunpack16 (double, int);
19702 v2si __builtin_vis_dictunpack32 (double, int);
19704 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
19705 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
19706 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
19707 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
19709 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
19710 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
19711 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
19712 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
19714 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
19715 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
19716 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
19717 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
19719 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
19720 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
19721 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
19722 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
19723 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
19724 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
19726 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
19727 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
19728 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
19730 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
19731 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
19732 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
19733 @end smallexample
19735 @node SPU Built-in Functions
19736 @subsection SPU Built-in Functions
19738 GCC provides extensions for the SPU processor as described in the
19739 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
19740 implementation differs in several ways.
19742 @itemize @bullet
19744 @item
19745 The optional extension of specifying vector constants in parentheses is
19746 not supported.
19748 @item
19749 A vector initializer requires no cast if the vector constant is of the
19750 same type as the variable it is initializing.
19752 @item
19753 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19754 vector type is the default signedness of the base type.  The default
19755 varies depending on the operating system, so a portable program should
19756 always specify the signedness.
19758 @item
19759 By default, the keyword @code{__vector} is added. The macro
19760 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19761 undefined.
19763 @item
19764 GCC allows using a @code{typedef} name as the type specifier for a
19765 vector type.
19767 @item
19768 For C, overloaded functions are implemented with macros so the following
19769 does not work:
19771 @smallexample
19772   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
19773 @end smallexample
19775 @noindent
19776 Since @code{spu_add} is a macro, the vector constant in the example
19777 is treated as four separate arguments.  Wrap the entire argument in
19778 parentheses for this to work.
19780 @item
19781 The extended version of @code{__builtin_expect} is not supported.
19783 @end itemize
19785 @emph{Note:} Only the interface described in the aforementioned
19786 specification is supported. Internally, GCC uses built-in functions to
19787 implement the required functionality, but these are not supported and
19788 are subject to change without notice.
19790 @node TI C6X Built-in Functions
19791 @subsection TI C6X Built-in Functions
19793 GCC provides intrinsics to access certain instructions of the TI C6X
19794 processors.  These intrinsics, listed below, are available after
19795 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
19796 to C6X instructions.
19798 @smallexample
19800 int _sadd (int, int)
19801 int _ssub (int, int)
19802 int _sadd2 (int, int)
19803 int _ssub2 (int, int)
19804 long long _mpy2 (int, int)
19805 long long _smpy2 (int, int)
19806 int _add4 (int, int)
19807 int _sub4 (int, int)
19808 int _saddu4 (int, int)
19810 int _smpy (int, int)
19811 int _smpyh (int, int)
19812 int _smpyhl (int, int)
19813 int _smpylh (int, int)
19815 int _sshl (int, int)
19816 int _subc (int, int)
19818 int _avg2 (int, int)
19819 int _avgu4 (int, int)
19821 int _clrr (int, int)
19822 int _extr (int, int)
19823 int _extru (int, int)
19824 int _abs (int)
19825 int _abs2 (int)
19827 @end smallexample
19829 @node TILE-Gx Built-in Functions
19830 @subsection TILE-Gx Built-in Functions
19832 GCC provides intrinsics to access every instruction of the TILE-Gx
19833 processor.  The intrinsics are of the form:
19835 @smallexample
19837 unsigned long long __insn_@var{op} (...)
19839 @end smallexample
19841 Where @var{op} is the name of the instruction.  Refer to the ISA manual
19842 for the complete list of instructions.
19844 GCC also provides intrinsics to directly access the network registers.
19845 The intrinsics are:
19847 @smallexample
19849 unsigned long long __tile_idn0_receive (void)
19850 unsigned long long __tile_idn1_receive (void)
19851 unsigned long long __tile_udn0_receive (void)
19852 unsigned long long __tile_udn1_receive (void)
19853 unsigned long long __tile_udn2_receive (void)
19854 unsigned long long __tile_udn3_receive (void)
19855 void __tile_idn_send (unsigned long long)
19856 void __tile_udn_send (unsigned long long)
19858 @end smallexample
19860 The intrinsic @code{void __tile_network_barrier (void)} is used to
19861 guarantee that no network operations before it are reordered with
19862 those after it.
19864 @node TILEPro Built-in Functions
19865 @subsection TILEPro Built-in Functions
19867 GCC provides intrinsics to access every instruction of the TILEPro
19868 processor.  The intrinsics are of the form:
19870 @smallexample
19872 unsigned __insn_@var{op} (...)
19874 @end smallexample
19876 @noindent
19877 where @var{op} is the name of the instruction.  Refer to the ISA manual
19878 for the complete list of instructions.
19880 GCC also provides intrinsics to directly access the network registers.
19881 The intrinsics are:
19883 @smallexample
19885 unsigned __tile_idn0_receive (void)
19886 unsigned __tile_idn1_receive (void)
19887 unsigned __tile_sn_receive (void)
19888 unsigned __tile_udn0_receive (void)
19889 unsigned __tile_udn1_receive (void)
19890 unsigned __tile_udn2_receive (void)
19891 unsigned __tile_udn3_receive (void)
19892 void __tile_idn_send (unsigned)
19893 void __tile_sn_send (unsigned)
19894 void __tile_udn_send (unsigned)
19896 @end smallexample
19898 The intrinsic @code{void __tile_network_barrier (void)} is used to
19899 guarantee that no network operations before it are reordered with
19900 those after it.
19902 @node x86 Built-in Functions
19903 @subsection x86 Built-in Functions
19905 These built-in functions are available for the x86-32 and x86-64 family
19906 of computers, depending on the command-line switches used.
19908 If you specify command-line switches such as @option{-msse},
19909 the compiler could use the extended instruction sets even if the built-ins
19910 are not used explicitly in the program.  For this reason, applications
19911 that perform run-time CPU detection must compile separate files for each
19912 supported architecture, using the appropriate flags.  In particular,
19913 the file containing the CPU detection code should be compiled without
19914 these options.
19916 The following machine modes are available for use with MMX built-in functions
19917 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
19918 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
19919 vector of eight 8-bit integers.  Some of the built-in functions operate on
19920 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
19922 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
19923 of two 32-bit floating-point values.
19925 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
19926 floating-point values.  Some instructions use a vector of four 32-bit
19927 integers, these use @code{V4SI}.  Finally, some instructions operate on an
19928 entire vector register, interpreting it as a 128-bit integer, these use mode
19929 @code{TI}.
19931 The x86-32 and x86-64 family of processors use additional built-in
19932 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
19933 floating point and @code{TC} 128-bit complex floating-point values.
19935 The following floating-point built-in functions are always available.  All
19936 of them implement the function that is part of the name.
19938 @smallexample
19939 __float128 __builtin_fabsq (__float128)
19940 __float128 __builtin_copysignq (__float128, __float128)
19941 @end smallexample
19943 The following built-in functions are always available.
19945 @table @code
19946 @item __float128 __builtin_infq (void)
19947 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
19948 @findex __builtin_infq
19950 @item __float128 __builtin_huge_valq (void)
19951 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
19952 @findex __builtin_huge_valq
19954 @item __float128 __builtin_nanq (void)
19955 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
19956 @findex __builtin_nanq
19958 @item __float128 __builtin_nansq (void)
19959 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
19960 @findex __builtin_nansq
19961 @end table
19963 The following built-in function is always available.
19965 @table @code
19966 @item void __builtin_ia32_pause (void)
19967 Generates the @code{pause} machine instruction with a compiler memory
19968 barrier.
19969 @end table
19971 The following built-in functions are always available and can be used to
19972 check the target platform type.
19974 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
19975 This function runs the CPU detection code to check the type of CPU and the
19976 features supported.  This built-in function needs to be invoked along with the built-in functions
19977 to check CPU type and features, @code{__builtin_cpu_is} and
19978 @code{__builtin_cpu_supports}, only when used in a function that is
19979 executed before any constructors are called.  The CPU detection code is
19980 automatically executed in a very high priority constructor.
19982 For example, this function has to be used in @code{ifunc} resolvers that
19983 check for CPU type using the built-in functions @code{__builtin_cpu_is}
19984 and @code{__builtin_cpu_supports}, or in constructors on targets that
19985 don't support constructor priority.
19986 @smallexample
19988 static void (*resolve_memcpy (void)) (void)
19990   // ifunc resolvers fire before constructors, explicitly call the init
19991   // function.
19992   __builtin_cpu_init ();
19993   if (__builtin_cpu_supports ("ssse3"))
19994     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
19995   else
19996     return default_memcpy;
19999 void *memcpy (void *, const void *, size_t)
20000      __attribute__ ((ifunc ("resolve_memcpy")));
20001 @end smallexample
20003 @end deftypefn
20005 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20006 This function returns a positive integer if the run-time CPU
20007 is of type @var{cpuname}
20008 and returns @code{0} otherwise. The following CPU names can be detected:
20010 @table @samp
20011 @item intel
20012 Intel CPU.
20014 @item atom
20015 Intel Atom CPU.
20017 @item core2
20018 Intel Core 2 CPU.
20020 @item corei7
20021 Intel Core i7 CPU.
20023 @item nehalem
20024 Intel Core i7 Nehalem CPU.
20026 @item westmere
20027 Intel Core i7 Westmere CPU.
20029 @item sandybridge
20030 Intel Core i7 Sandy Bridge CPU.
20032 @item amd
20033 AMD CPU.
20035 @item amdfam10h
20036 AMD Family 10h CPU.
20038 @item barcelona
20039 AMD Family 10h Barcelona CPU.
20041 @item shanghai
20042 AMD Family 10h Shanghai CPU.
20044 @item istanbul
20045 AMD Family 10h Istanbul CPU.
20047 @item btver1
20048 AMD Family 14h CPU.
20050 @item amdfam15h
20051 AMD Family 15h CPU.
20053 @item bdver1
20054 AMD Family 15h Bulldozer version 1.
20056 @item bdver2
20057 AMD Family 15h Bulldozer version 2.
20059 @item bdver3
20060 AMD Family 15h Bulldozer version 3.
20062 @item bdver4
20063 AMD Family 15h Bulldozer version 4.
20065 @item btver2
20066 AMD Family 16h CPU.
20068 @item amdfam17h
20069 AMD Family 17h CPU.
20071 @item znver1
20072 AMD Family 17h Zen version 1.
20073 @end table
20075 Here is an example:
20076 @smallexample
20077 if (__builtin_cpu_is ("corei7"))
20078   @{
20079      do_corei7 (); // Core i7 specific implementation.
20080   @}
20081 else
20082   @{
20083      do_generic (); // Generic implementation.
20084   @}
20085 @end smallexample
20086 @end deftypefn
20088 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20089 This function returns a positive integer if the run-time CPU
20090 supports @var{feature}
20091 and returns @code{0} otherwise. The following features can be detected:
20093 @table @samp
20094 @item cmov
20095 CMOV instruction.
20096 @item mmx
20097 MMX instructions.
20098 @item popcnt
20099 POPCNT instruction.
20100 @item sse
20101 SSE instructions.
20102 @item sse2
20103 SSE2 instructions.
20104 @item sse3
20105 SSE3 instructions.
20106 @item ssse3
20107 SSSE3 instructions.
20108 @item sse4.1
20109 SSE4.1 instructions.
20110 @item sse4.2
20111 SSE4.2 instructions.
20112 @item avx
20113 AVX instructions.
20114 @item avx2
20115 AVX2 instructions.
20116 @item avx512f
20117 AVX512F instructions.
20118 @end table
20120 Here is an example:
20121 @smallexample
20122 if (__builtin_cpu_supports ("popcnt"))
20123   @{
20124      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20125   @}
20126 else
20127   @{
20128      count = generic_countbits (n); //generic implementation.
20129   @}
20130 @end smallexample
20131 @end deftypefn
20134 The following built-in functions are made available by @option{-mmmx}.
20135 All of them generate the machine instruction that is part of the name.
20137 @smallexample
20138 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20139 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20140 v2si __builtin_ia32_paddd (v2si, v2si)
20141 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20142 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20143 v2si __builtin_ia32_psubd (v2si, v2si)
20144 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20145 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20146 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20147 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20148 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20149 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20150 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20151 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20152 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20153 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20154 di __builtin_ia32_pand (di, di)
20155 di __builtin_ia32_pandn (di,di)
20156 di __builtin_ia32_por (di, di)
20157 di __builtin_ia32_pxor (di, di)
20158 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20159 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20160 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20161 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20162 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20163 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20164 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20165 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20166 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20167 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20168 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20169 v2si __builtin_ia32_punpckldq (v2si, v2si)
20170 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20171 v4hi __builtin_ia32_packssdw (v2si, v2si)
20172 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20174 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20175 v2si __builtin_ia32_pslld (v2si, v2si)
20176 v1di __builtin_ia32_psllq (v1di, v1di)
20177 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20178 v2si __builtin_ia32_psrld (v2si, v2si)
20179 v1di __builtin_ia32_psrlq (v1di, v1di)
20180 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20181 v2si __builtin_ia32_psrad (v2si, v2si)
20182 v4hi __builtin_ia32_psllwi (v4hi, int)
20183 v2si __builtin_ia32_pslldi (v2si, int)
20184 v1di __builtin_ia32_psllqi (v1di, int)
20185 v4hi __builtin_ia32_psrlwi (v4hi, int)
20186 v2si __builtin_ia32_psrldi (v2si, int)
20187 v1di __builtin_ia32_psrlqi (v1di, int)
20188 v4hi __builtin_ia32_psrawi (v4hi, int)
20189 v2si __builtin_ia32_psradi (v2si, int)
20191 @end smallexample
20193 The following built-in functions are made available either with
20194 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20195 the machine instruction that is part of the name.
20197 @smallexample
20198 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20199 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20200 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20201 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20202 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20203 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20204 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20205 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20206 int __builtin_ia32_pmovmskb (v8qi)
20207 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20208 void __builtin_ia32_movntq (di *, di)
20209 void __builtin_ia32_sfence (void)
20210 @end smallexample
20212 The following built-in functions are available when @option{-msse} is used.
20213 All of them generate the machine instruction that is part of the name.
20215 @smallexample
20216 int __builtin_ia32_comieq (v4sf, v4sf)
20217 int __builtin_ia32_comineq (v4sf, v4sf)
20218 int __builtin_ia32_comilt (v4sf, v4sf)
20219 int __builtin_ia32_comile (v4sf, v4sf)
20220 int __builtin_ia32_comigt (v4sf, v4sf)
20221 int __builtin_ia32_comige (v4sf, v4sf)
20222 int __builtin_ia32_ucomieq (v4sf, v4sf)
20223 int __builtin_ia32_ucomineq (v4sf, v4sf)
20224 int __builtin_ia32_ucomilt (v4sf, v4sf)
20225 int __builtin_ia32_ucomile (v4sf, v4sf)
20226 int __builtin_ia32_ucomigt (v4sf, v4sf)
20227 int __builtin_ia32_ucomige (v4sf, v4sf)
20228 v4sf __builtin_ia32_addps (v4sf, v4sf)
20229 v4sf __builtin_ia32_subps (v4sf, v4sf)
20230 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20231 v4sf __builtin_ia32_divps (v4sf, v4sf)
20232 v4sf __builtin_ia32_addss (v4sf, v4sf)
20233 v4sf __builtin_ia32_subss (v4sf, v4sf)
20234 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20235 v4sf __builtin_ia32_divss (v4sf, v4sf)
20236 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20237 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20238 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20239 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20240 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20241 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20242 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20243 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20244 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20245 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20246 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20247 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20248 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20249 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20250 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20251 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20252 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20253 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20254 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20255 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20256 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20257 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20258 v4sf __builtin_ia32_minps (v4sf, v4sf)
20259 v4sf __builtin_ia32_minss (v4sf, v4sf)
20260 v4sf __builtin_ia32_andps (v4sf, v4sf)
20261 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20262 v4sf __builtin_ia32_orps (v4sf, v4sf)
20263 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20264 v4sf __builtin_ia32_movss (v4sf, v4sf)
20265 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20266 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20267 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20268 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20269 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20270 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20271 v2si __builtin_ia32_cvtps2pi (v4sf)
20272 int __builtin_ia32_cvtss2si (v4sf)
20273 v2si __builtin_ia32_cvttps2pi (v4sf)
20274 int __builtin_ia32_cvttss2si (v4sf)
20275 v4sf __builtin_ia32_rcpps (v4sf)
20276 v4sf __builtin_ia32_rsqrtps (v4sf)
20277 v4sf __builtin_ia32_sqrtps (v4sf)
20278 v4sf __builtin_ia32_rcpss (v4sf)
20279 v4sf __builtin_ia32_rsqrtss (v4sf)
20280 v4sf __builtin_ia32_sqrtss (v4sf)
20281 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20282 void __builtin_ia32_movntps (float *, v4sf)
20283 int __builtin_ia32_movmskps (v4sf)
20284 @end smallexample
20286 The following built-in functions are available when @option{-msse} is used.
20288 @table @code
20289 @item v4sf __builtin_ia32_loadups (float *)
20290 Generates the @code{movups} machine instruction as a load from memory.
20291 @item void __builtin_ia32_storeups (float *, v4sf)
20292 Generates the @code{movups} machine instruction as a store to memory.
20293 @item v4sf __builtin_ia32_loadss (float *)
20294 Generates the @code{movss} machine instruction as a load from memory.
20295 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20296 Generates the @code{movhps} machine instruction as a load from memory.
20297 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20298 Generates the @code{movlps} machine instruction as a load from memory
20299 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20300 Generates the @code{movhps} machine instruction as a store to memory.
20301 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20302 Generates the @code{movlps} machine instruction as a store to memory.
20303 @end table
20305 The following built-in functions are available when @option{-msse2} is used.
20306 All of them generate the machine instruction that is part of the name.
20308 @smallexample
20309 int __builtin_ia32_comisdeq (v2df, v2df)
20310 int __builtin_ia32_comisdlt (v2df, v2df)
20311 int __builtin_ia32_comisdle (v2df, v2df)
20312 int __builtin_ia32_comisdgt (v2df, v2df)
20313 int __builtin_ia32_comisdge (v2df, v2df)
20314 int __builtin_ia32_comisdneq (v2df, v2df)
20315 int __builtin_ia32_ucomisdeq (v2df, v2df)
20316 int __builtin_ia32_ucomisdlt (v2df, v2df)
20317 int __builtin_ia32_ucomisdle (v2df, v2df)
20318 int __builtin_ia32_ucomisdgt (v2df, v2df)
20319 int __builtin_ia32_ucomisdge (v2df, v2df)
20320 int __builtin_ia32_ucomisdneq (v2df, v2df)
20321 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20322 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20323 v2df __builtin_ia32_cmplepd (v2df, v2df)
20324 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20325 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20326 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20327 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20328 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20329 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20330 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20331 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20332 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20333 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20334 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20335 v2df __builtin_ia32_cmplesd (v2df, v2df)
20336 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20337 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20338 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20339 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20340 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20341 v2di __builtin_ia32_paddq (v2di, v2di)
20342 v2di __builtin_ia32_psubq (v2di, v2di)
20343 v2df __builtin_ia32_addpd (v2df, v2df)
20344 v2df __builtin_ia32_subpd (v2df, v2df)
20345 v2df __builtin_ia32_mulpd (v2df, v2df)
20346 v2df __builtin_ia32_divpd (v2df, v2df)
20347 v2df __builtin_ia32_addsd (v2df, v2df)
20348 v2df __builtin_ia32_subsd (v2df, v2df)
20349 v2df __builtin_ia32_mulsd (v2df, v2df)
20350 v2df __builtin_ia32_divsd (v2df, v2df)
20351 v2df __builtin_ia32_minpd (v2df, v2df)
20352 v2df __builtin_ia32_maxpd (v2df, v2df)
20353 v2df __builtin_ia32_minsd (v2df, v2df)
20354 v2df __builtin_ia32_maxsd (v2df, v2df)
20355 v2df __builtin_ia32_andpd (v2df, v2df)
20356 v2df __builtin_ia32_andnpd (v2df, v2df)
20357 v2df __builtin_ia32_orpd (v2df, v2df)
20358 v2df __builtin_ia32_xorpd (v2df, v2df)
20359 v2df __builtin_ia32_movsd (v2df, v2df)
20360 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20361 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20362 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20363 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20364 v4si __builtin_ia32_paddd128 (v4si, v4si)
20365 v2di __builtin_ia32_paddq128 (v2di, v2di)
20366 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20367 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20368 v4si __builtin_ia32_psubd128 (v4si, v4si)
20369 v2di __builtin_ia32_psubq128 (v2di, v2di)
20370 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20371 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20372 v2di __builtin_ia32_pand128 (v2di, v2di)
20373 v2di __builtin_ia32_pandn128 (v2di, v2di)
20374 v2di __builtin_ia32_por128 (v2di, v2di)
20375 v2di __builtin_ia32_pxor128 (v2di, v2di)
20376 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20377 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20378 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20379 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20380 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20381 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20382 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20383 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20384 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20385 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20386 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20387 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20388 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20389 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20390 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20391 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20392 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20393 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20394 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20395 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20396 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20397 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20398 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20399 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20400 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20401 v2df __builtin_ia32_loadupd (double *)
20402 void __builtin_ia32_storeupd (double *, v2df)
20403 v2df __builtin_ia32_loadhpd (v2df, double const *)
20404 v2df __builtin_ia32_loadlpd (v2df, double const *)
20405 int __builtin_ia32_movmskpd (v2df)
20406 int __builtin_ia32_pmovmskb128 (v16qi)
20407 void __builtin_ia32_movnti (int *, int)
20408 void __builtin_ia32_movnti64 (long long int *, long long int)
20409 void __builtin_ia32_movntpd (double *, v2df)
20410 void __builtin_ia32_movntdq (v2df *, v2df)
20411 v4si __builtin_ia32_pshufd (v4si, int)
20412 v8hi __builtin_ia32_pshuflw (v8hi, int)
20413 v8hi __builtin_ia32_pshufhw (v8hi, int)
20414 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20415 v2df __builtin_ia32_sqrtpd (v2df)
20416 v2df __builtin_ia32_sqrtsd (v2df)
20417 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20418 v2df __builtin_ia32_cvtdq2pd (v4si)
20419 v4sf __builtin_ia32_cvtdq2ps (v4si)
20420 v4si __builtin_ia32_cvtpd2dq (v2df)
20421 v2si __builtin_ia32_cvtpd2pi (v2df)
20422 v4sf __builtin_ia32_cvtpd2ps (v2df)
20423 v4si __builtin_ia32_cvttpd2dq (v2df)
20424 v2si __builtin_ia32_cvttpd2pi (v2df)
20425 v2df __builtin_ia32_cvtpi2pd (v2si)
20426 int __builtin_ia32_cvtsd2si (v2df)
20427 int __builtin_ia32_cvttsd2si (v2df)
20428 long long __builtin_ia32_cvtsd2si64 (v2df)
20429 long long __builtin_ia32_cvttsd2si64 (v2df)
20430 v4si __builtin_ia32_cvtps2dq (v4sf)
20431 v2df __builtin_ia32_cvtps2pd (v4sf)
20432 v4si __builtin_ia32_cvttps2dq (v4sf)
20433 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20434 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20435 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20436 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20437 void __builtin_ia32_clflush (const void *)
20438 void __builtin_ia32_lfence (void)
20439 void __builtin_ia32_mfence (void)
20440 v16qi __builtin_ia32_loaddqu (const char *)
20441 void __builtin_ia32_storedqu (char *, v16qi)
20442 v1di __builtin_ia32_pmuludq (v2si, v2si)
20443 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20444 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20445 v4si __builtin_ia32_pslld128 (v4si, v4si)
20446 v2di __builtin_ia32_psllq128 (v2di, v2di)
20447 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20448 v4si __builtin_ia32_psrld128 (v4si, v4si)
20449 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20450 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20451 v4si __builtin_ia32_psrad128 (v4si, v4si)
20452 v2di __builtin_ia32_pslldqi128 (v2di, int)
20453 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20454 v4si __builtin_ia32_pslldi128 (v4si, int)
20455 v2di __builtin_ia32_psllqi128 (v2di, int)
20456 v2di __builtin_ia32_psrldqi128 (v2di, int)
20457 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20458 v4si __builtin_ia32_psrldi128 (v4si, int)
20459 v2di __builtin_ia32_psrlqi128 (v2di, int)
20460 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20461 v4si __builtin_ia32_psradi128 (v4si, int)
20462 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20463 v2di __builtin_ia32_movq128 (v2di)
20464 @end smallexample
20466 The following built-in functions are available when @option{-msse3} is used.
20467 All of them generate the machine instruction that is part of the name.
20469 @smallexample
20470 v2df __builtin_ia32_addsubpd (v2df, v2df)
20471 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20472 v2df __builtin_ia32_haddpd (v2df, v2df)
20473 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20474 v2df __builtin_ia32_hsubpd (v2df, v2df)
20475 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20476 v16qi __builtin_ia32_lddqu (char const *)
20477 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20478 v4sf __builtin_ia32_movshdup (v4sf)
20479 v4sf __builtin_ia32_movsldup (v4sf)
20480 void __builtin_ia32_mwait (unsigned int, unsigned int)
20481 @end smallexample
20483 The following built-in functions are available when @option{-mssse3} is used.
20484 All of them generate the machine instruction that is part of the name.
20486 @smallexample
20487 v2si __builtin_ia32_phaddd (v2si, v2si)
20488 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20489 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20490 v2si __builtin_ia32_phsubd (v2si, v2si)
20491 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20492 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20493 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20494 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20495 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20496 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20497 v2si __builtin_ia32_psignd (v2si, v2si)
20498 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20499 v1di __builtin_ia32_palignr (v1di, v1di, int)
20500 v8qi __builtin_ia32_pabsb (v8qi)
20501 v2si __builtin_ia32_pabsd (v2si)
20502 v4hi __builtin_ia32_pabsw (v4hi)
20503 @end smallexample
20505 The following built-in functions are available when @option{-mssse3} is used.
20506 All of them generate the machine instruction that is part of the name.
20508 @smallexample
20509 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20510 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20511 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20512 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20513 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20514 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20515 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20516 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20517 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20518 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20519 v4si __builtin_ia32_psignd128 (v4si, v4si)
20520 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20521 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20522 v16qi __builtin_ia32_pabsb128 (v16qi)
20523 v4si __builtin_ia32_pabsd128 (v4si)
20524 v8hi __builtin_ia32_pabsw128 (v8hi)
20525 @end smallexample
20527 The following built-in functions are available when @option{-msse4.1} is
20528 used.  All of them generate the machine instruction that is part of the
20529 name.
20531 @smallexample
20532 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20533 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20534 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20535 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20536 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20537 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20538 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20539 v2di __builtin_ia32_movntdqa (v2di *);
20540 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20541 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20542 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20543 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20544 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20545 v8hi __builtin_ia32_phminposuw128 (v8hi)
20546 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20547 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20548 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20549 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20550 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20551 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20552 v4si __builtin_ia32_pminud128 (v4si, v4si)
20553 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20554 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20555 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20556 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20557 v2di __builtin_ia32_pmovsxdq128 (v4si)
20558 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20559 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20560 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20561 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20562 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20563 v2di __builtin_ia32_pmovzxdq128 (v4si)
20564 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20565 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20566 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20567 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20568 int __builtin_ia32_ptestc128 (v2di, v2di)
20569 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20570 int __builtin_ia32_ptestz128 (v2di, v2di)
20571 v2df __builtin_ia32_roundpd (v2df, const int)
20572 v4sf __builtin_ia32_roundps (v4sf, const int)
20573 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20574 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20575 @end smallexample
20577 The following built-in functions are available when @option{-msse4.1} is
20578 used.
20580 @table @code
20581 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20582 Generates the @code{insertps} machine instruction.
20583 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20584 Generates the @code{pextrb} machine instruction.
20585 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20586 Generates the @code{pinsrb} machine instruction.
20587 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20588 Generates the @code{pinsrd} machine instruction.
20589 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20590 Generates the @code{pinsrq} machine instruction in 64bit mode.
20591 @end table
20593 The following built-in functions are changed to generate new SSE4.1
20594 instructions when @option{-msse4.1} is used.
20596 @table @code
20597 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20598 Generates the @code{extractps} machine instruction.
20599 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20600 Generates the @code{pextrd} machine instruction.
20601 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20602 Generates the @code{pextrq} machine instruction in 64bit mode.
20603 @end table
20605 The following built-in functions are available when @option{-msse4.2} is
20606 used.  All of them generate the machine instruction that is part of the
20607 name.
20609 @smallexample
20610 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20611 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20612 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20613 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20614 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20615 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20616 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20617 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20618 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20619 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20620 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20621 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20622 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20623 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20624 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20625 @end smallexample
20627 The following built-in functions are available when @option{-msse4.2} is
20628 used.
20630 @table @code
20631 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20632 Generates the @code{crc32b} machine instruction.
20633 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20634 Generates the @code{crc32w} machine instruction.
20635 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20636 Generates the @code{crc32l} machine instruction.
20637 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20638 Generates the @code{crc32q} machine instruction.
20639 @end table
20641 The following built-in functions are changed to generate new SSE4.2
20642 instructions when @option{-msse4.2} is used.
20644 @table @code
20645 @item int __builtin_popcount (unsigned int)
20646 Generates the @code{popcntl} machine instruction.
20647 @item int __builtin_popcountl (unsigned long)
20648 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20649 depending on the size of @code{unsigned long}.
20650 @item int __builtin_popcountll (unsigned long long)
20651 Generates the @code{popcntq} machine instruction.
20652 @end table
20654 The following built-in functions are available when @option{-mavx} is
20655 used. All of them generate the machine instruction that is part of the
20656 name.
20658 @smallexample
20659 v4df __builtin_ia32_addpd256 (v4df,v4df)
20660 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20661 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20662 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20663 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20664 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20665 v4df __builtin_ia32_andpd256 (v4df,v4df)
20666 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20667 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20668 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20669 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20670 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20671 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20672 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20673 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20674 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20675 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20676 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20677 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20678 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20679 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20680 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20681 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20682 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20683 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20684 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20685 v4df __builtin_ia32_divpd256 (v4df,v4df)
20686 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20687 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20688 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20689 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20690 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20691 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20692 v32qi __builtin_ia32_lddqu256 (pcchar)
20693 v32qi __builtin_ia32_loaddqu256 (pcchar)
20694 v4df __builtin_ia32_loadupd256 (pcdouble)
20695 v8sf __builtin_ia32_loadups256 (pcfloat)
20696 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20697 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20698 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20699 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20700 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20701 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20702 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20703 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20704 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20705 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20706 v4df __builtin_ia32_minpd256 (v4df,v4df)
20707 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20708 v4df __builtin_ia32_movddup256 (v4df)
20709 int __builtin_ia32_movmskpd256 (v4df)
20710 int __builtin_ia32_movmskps256 (v8sf)
20711 v8sf __builtin_ia32_movshdup256 (v8sf)
20712 v8sf __builtin_ia32_movsldup256 (v8sf)
20713 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20714 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20715 v4df __builtin_ia32_orpd256 (v4df,v4df)
20716 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20717 v2df __builtin_ia32_pd_pd256 (v4df)
20718 v4df __builtin_ia32_pd256_pd (v2df)
20719 v4sf __builtin_ia32_ps_ps256 (v8sf)
20720 v8sf __builtin_ia32_ps256_ps (v4sf)
20721 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20722 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20723 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20724 v8sf __builtin_ia32_rcpps256 (v8sf)
20725 v4df __builtin_ia32_roundpd256 (v4df,int)
20726 v8sf __builtin_ia32_roundps256 (v8sf,int)
20727 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20728 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20729 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20730 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20731 v4si __builtin_ia32_si_si256 (v8si)
20732 v8si __builtin_ia32_si256_si (v4si)
20733 v4df __builtin_ia32_sqrtpd256 (v4df)
20734 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20735 v8sf __builtin_ia32_sqrtps256 (v8sf)
20736 void __builtin_ia32_storedqu256 (pchar,v32qi)
20737 void __builtin_ia32_storeupd256 (pdouble,v4df)
20738 void __builtin_ia32_storeups256 (pfloat,v8sf)
20739 v4df __builtin_ia32_subpd256 (v4df,v4df)
20740 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20741 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20742 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20743 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20744 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20745 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20746 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20747 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20748 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20749 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20750 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20751 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20752 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20753 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20754 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20755 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20756 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20757 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20758 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20759 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20760 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20761 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20762 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20763 v2df __builtin_ia32_vpermilpd (v2df,int)
20764 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20765 v4sf __builtin_ia32_vpermilps (v4sf,int)
20766 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
20767 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
20768 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
20769 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
20770 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
20771 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
20772 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
20773 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
20774 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
20775 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
20776 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
20777 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
20778 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
20779 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
20780 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
20781 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
20782 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
20783 void __builtin_ia32_vzeroall (void)
20784 void __builtin_ia32_vzeroupper (void)
20785 v4df __builtin_ia32_xorpd256 (v4df,v4df)
20786 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
20787 @end smallexample
20789 The following built-in functions are available when @option{-mavx2} is
20790 used. All of them generate the machine instruction that is part of the
20791 name.
20793 @smallexample
20794 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
20795 v32qi __builtin_ia32_pabsb256 (v32qi)
20796 v16hi __builtin_ia32_pabsw256 (v16hi)
20797 v8si __builtin_ia32_pabsd256 (v8si)
20798 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
20799 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
20800 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
20801 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
20802 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
20803 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
20804 v8si __builtin_ia32_paddd256 (v8si,v8si)
20805 v4di __builtin_ia32_paddq256 (v4di,v4di)
20806 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
20807 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
20808 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20809 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20810 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20811 v4di __builtin_ia32_andsi256 (v4di,v4di)
20812 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20813 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20814 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20815 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20816 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20817 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20818 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20819 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20820 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20821 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20822 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20823 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20824 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20825 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20826 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20827 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20828 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20829 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20830 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20831 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20832 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20833 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20834 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20835 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20836 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20837 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20838 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20839 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20840 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20841 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20842 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20843 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20844 v8si __builtin_ia32_pminud256 (v8si,v8si)
20845 int __builtin_ia32_pmovmskb256 (v32qi)
20846 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20847 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20848 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20849 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20850 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20851 v4di __builtin_ia32_pmovsxdq256 (v4si)
20852 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20853 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20854 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20855 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20856 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20857 v4di __builtin_ia32_pmovzxdq256 (v4si)
20858 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20859 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20860 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20861 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20862 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20863 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20864 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20865 v4di __builtin_ia32_por256 (v4di,v4di)
20866 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20867 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20868 v8si __builtin_ia32_pshufd256 (v8si,int)
20869 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
20870 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
20871 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
20872 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
20873 v8si __builtin_ia32_psignd256 (v8si,v8si)
20874 v4di __builtin_ia32_pslldqi256 (v4di,int)
20875 v16hi __builtin_ia32_psllwi256 (16hi,int)
20876 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
20877 v8si __builtin_ia32_pslldi256 (v8si,int)
20878 v8si __builtin_ia32_pslld256(v8si,v4si)
20879 v4di __builtin_ia32_psllqi256 (v4di,int)
20880 v4di __builtin_ia32_psllq256(v4di,v2di)
20881 v16hi __builtin_ia32_psrawi256 (v16hi,int)
20882 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
20883 v8si __builtin_ia32_psradi256 (v8si,int)
20884 v8si __builtin_ia32_psrad256 (v8si,v4si)
20885 v4di __builtin_ia32_psrldqi256 (v4di, int)
20886 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
20887 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
20888 v8si __builtin_ia32_psrldi256 (v8si,int)
20889 v8si __builtin_ia32_psrld256 (v8si,v4si)
20890 v4di __builtin_ia32_psrlqi256 (v4di,int)
20891 v4di __builtin_ia32_psrlq256(v4di,v2di)
20892 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
20893 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
20894 v8si __builtin_ia32_psubd256 (v8si,v8si)
20895 v4di __builtin_ia32_psubq256 (v4di,v4di)
20896 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
20897 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
20898 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
20899 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
20900 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
20901 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
20902 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
20903 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
20904 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
20905 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
20906 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
20907 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
20908 v4di __builtin_ia32_pxor256 (v4di,v4di)
20909 v4di __builtin_ia32_movntdqa256 (pv4di)
20910 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
20911 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
20912 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
20913 v4di __builtin_ia32_vbroadcastsi256 (v2di)
20914 v4si __builtin_ia32_pblendd128 (v4si,v4si)
20915 v8si __builtin_ia32_pblendd256 (v8si,v8si)
20916 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
20917 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
20918 v8si __builtin_ia32_pbroadcastd256 (v4si)
20919 v4di __builtin_ia32_pbroadcastq256 (v2di)
20920 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
20921 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
20922 v4si __builtin_ia32_pbroadcastd128 (v4si)
20923 v2di __builtin_ia32_pbroadcastq128 (v2di)
20924 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
20925 v4df __builtin_ia32_permdf256 (v4df,int)
20926 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
20927 v4di __builtin_ia32_permdi256 (v4di,int)
20928 v4di __builtin_ia32_permti256 (v4di,v4di,int)
20929 v4di __builtin_ia32_extract128i256 (v4di,int)
20930 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
20931 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
20932 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
20933 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
20934 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
20935 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
20936 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
20937 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
20938 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
20939 v8si __builtin_ia32_psllv8si (v8si,v8si)
20940 v4si __builtin_ia32_psllv4si (v4si,v4si)
20941 v4di __builtin_ia32_psllv4di (v4di,v4di)
20942 v2di __builtin_ia32_psllv2di (v2di,v2di)
20943 v8si __builtin_ia32_psrav8si (v8si,v8si)
20944 v4si __builtin_ia32_psrav4si (v4si,v4si)
20945 v8si __builtin_ia32_psrlv8si (v8si,v8si)
20946 v4si __builtin_ia32_psrlv4si (v4si,v4si)
20947 v4di __builtin_ia32_psrlv4di (v4di,v4di)
20948 v2di __builtin_ia32_psrlv2di (v2di,v2di)
20949 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
20950 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
20951 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
20952 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
20953 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
20954 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
20955 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
20956 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
20957 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
20958 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
20959 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
20960 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
20961 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
20962 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
20963 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
20964 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
20965 @end smallexample
20967 The following built-in functions are available when @option{-maes} is
20968 used.  All of them generate the machine instruction that is part of the
20969 name.
20971 @smallexample
20972 v2di __builtin_ia32_aesenc128 (v2di, v2di)
20973 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
20974 v2di __builtin_ia32_aesdec128 (v2di, v2di)
20975 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
20976 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
20977 v2di __builtin_ia32_aesimc128 (v2di)
20978 @end smallexample
20980 The following built-in function is available when @option{-mpclmul} is
20981 used.
20983 @table @code
20984 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
20985 Generates the @code{pclmulqdq} machine instruction.
20986 @end table
20988 The following built-in function is available when @option{-mfsgsbase} is
20989 used.  All of them generate the machine instruction that is part of the
20990 name.
20992 @smallexample
20993 unsigned int __builtin_ia32_rdfsbase32 (void)
20994 unsigned long long __builtin_ia32_rdfsbase64 (void)
20995 unsigned int __builtin_ia32_rdgsbase32 (void)
20996 unsigned long long __builtin_ia32_rdgsbase64 (void)
20997 void _writefsbase_u32 (unsigned int)
20998 void _writefsbase_u64 (unsigned long long)
20999 void _writegsbase_u32 (unsigned int)
21000 void _writegsbase_u64 (unsigned long long)
21001 @end smallexample
21003 The following built-in function is available when @option{-mrdrnd} is
21004 used.  All of them generate the machine instruction that is part of the
21005 name.
21007 @smallexample
21008 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21009 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21010 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21011 @end smallexample
21013 The following built-in functions are available when @option{-msse4a} is used.
21014 All of them generate the machine instruction that is part of the name.
21016 @smallexample
21017 void __builtin_ia32_movntsd (double *, v2df)
21018 void __builtin_ia32_movntss (float *, v4sf)
21019 v2di __builtin_ia32_extrq  (v2di, v16qi)
21020 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21021 v2di __builtin_ia32_insertq (v2di, v2di)
21022 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21023 @end smallexample
21025 The following built-in functions are available when @option{-mxop} is used.
21026 @smallexample
21027 v2df __builtin_ia32_vfrczpd (v2df)
21028 v4sf __builtin_ia32_vfrczps (v4sf)
21029 v2df __builtin_ia32_vfrczsd (v2df)
21030 v4sf __builtin_ia32_vfrczss (v4sf)
21031 v4df __builtin_ia32_vfrczpd256 (v4df)
21032 v8sf __builtin_ia32_vfrczps256 (v8sf)
21033 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21034 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21035 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21036 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21037 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21038 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21039 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21040 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21041 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21042 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21043 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21044 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21045 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21046 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21047 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21048 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21049 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21050 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21051 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21052 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21053 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21054 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21055 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21056 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21057 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21058 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21059 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21060 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21061 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21062 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21063 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21064 v4si __builtin_ia32_vpcomged (v4si, v4si)
21065 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21066 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21067 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21068 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21069 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21070 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21071 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21072 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21073 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21074 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21075 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21076 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21077 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21078 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21079 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21080 v4si __builtin_ia32_vpcomled (v4si, v4si)
21081 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21082 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21083 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21084 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21085 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21086 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21087 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21088 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21089 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21090 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21091 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21092 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21093 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21094 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21095 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21096 v4si __builtin_ia32_vpcomned (v4si, v4si)
21097 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21098 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21099 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21100 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21101 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21102 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21103 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21104 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21105 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21106 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21107 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21108 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21109 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21110 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21111 v4si __builtin_ia32_vphaddbd (v16qi)
21112 v2di __builtin_ia32_vphaddbq (v16qi)
21113 v8hi __builtin_ia32_vphaddbw (v16qi)
21114 v2di __builtin_ia32_vphadddq (v4si)
21115 v4si __builtin_ia32_vphaddubd (v16qi)
21116 v2di __builtin_ia32_vphaddubq (v16qi)
21117 v8hi __builtin_ia32_vphaddubw (v16qi)
21118 v2di __builtin_ia32_vphaddudq (v4si)
21119 v4si __builtin_ia32_vphadduwd (v8hi)
21120 v2di __builtin_ia32_vphadduwq (v8hi)
21121 v4si __builtin_ia32_vphaddwd (v8hi)
21122 v2di __builtin_ia32_vphaddwq (v8hi)
21123 v8hi __builtin_ia32_vphsubbw (v16qi)
21124 v2di __builtin_ia32_vphsubdq (v4si)
21125 v4si __builtin_ia32_vphsubwd (v8hi)
21126 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21127 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21128 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21129 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21130 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21131 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21132 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21133 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21134 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21135 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21136 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21137 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21138 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21139 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21140 v4si __builtin_ia32_vprotd (v4si, v4si)
21141 v2di __builtin_ia32_vprotq (v2di, v2di)
21142 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21143 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21144 v4si __builtin_ia32_vpshad (v4si, v4si)
21145 v2di __builtin_ia32_vpshaq (v2di, v2di)
21146 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21147 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21148 v4si __builtin_ia32_vpshld (v4si, v4si)
21149 v2di __builtin_ia32_vpshlq (v2di, v2di)
21150 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21151 @end smallexample
21153 The following built-in functions are available when @option{-mfma4} is used.
21154 All of them generate the machine instruction that is part of the name.
21156 @smallexample
21157 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21158 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21159 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21160 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21161 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21162 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21163 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21164 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21165 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21166 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21167 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21168 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21169 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21170 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21171 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21172 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21173 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21174 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21175 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21176 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21177 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21178 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21179 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21180 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21181 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21182 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21183 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21184 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21185 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21186 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21187 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21188 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21190 @end smallexample
21192 The following built-in functions are available when @option{-mlwp} is used.
21194 @smallexample
21195 void __builtin_ia32_llwpcb16 (void *);
21196 void __builtin_ia32_llwpcb32 (void *);
21197 void __builtin_ia32_llwpcb64 (void *);
21198 void * __builtin_ia32_llwpcb16 (void);
21199 void * __builtin_ia32_llwpcb32 (void);
21200 void * __builtin_ia32_llwpcb64 (void);
21201 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21202 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21203 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21204 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21205 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21206 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21207 @end smallexample
21209 The following built-in functions are available when @option{-mbmi} is used.
21210 All of them generate the machine instruction that is part of the name.
21211 @smallexample
21212 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21213 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21214 @end smallexample
21216 The following built-in functions are available when @option{-mbmi2} is used.
21217 All of them generate the machine instruction that is part of the name.
21218 @smallexample
21219 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21220 unsigned int _pdep_u32 (unsigned int, unsigned int)
21221 unsigned int _pext_u32 (unsigned int, unsigned int)
21222 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21223 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21224 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21225 @end smallexample
21227 The following built-in functions are available when @option{-mlzcnt} is used.
21228 All of them generate the machine instruction that is part of the name.
21229 @smallexample
21230 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21231 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21232 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21233 @end smallexample
21235 The following built-in functions are available when @option{-mfxsr} is used.
21236 All of them generate the machine instruction that is part of the name.
21237 @smallexample
21238 void __builtin_ia32_fxsave (void *)
21239 void __builtin_ia32_fxrstor (void *)
21240 void __builtin_ia32_fxsave64 (void *)
21241 void __builtin_ia32_fxrstor64 (void *)
21242 @end smallexample
21244 The following built-in functions are available when @option{-mxsave} is used.
21245 All of them generate the machine instruction that is part of the name.
21246 @smallexample
21247 void __builtin_ia32_xsave (void *, long long)
21248 void __builtin_ia32_xrstor (void *, long long)
21249 void __builtin_ia32_xsave64 (void *, long long)
21250 void __builtin_ia32_xrstor64 (void *, long long)
21251 @end smallexample
21253 The following built-in functions are available when @option{-mxsaveopt} is used.
21254 All of them generate the machine instruction that is part of the name.
21255 @smallexample
21256 void __builtin_ia32_xsaveopt (void *, long long)
21257 void __builtin_ia32_xsaveopt64 (void *, long long)
21258 @end smallexample
21260 The following built-in functions are available when @option{-mtbm} is used.
21261 Both of them generate the immediate form of the bextr machine instruction.
21262 @smallexample
21263 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21264                                         const unsigned int);
21265 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21266                                               const unsigned long long);
21267 @end smallexample
21270 The following built-in functions are available when @option{-m3dnow} is used.
21271 All of them generate the machine instruction that is part of the name.
21273 @smallexample
21274 void __builtin_ia32_femms (void)
21275 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21276 v2si __builtin_ia32_pf2id (v2sf)
21277 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21278 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21279 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21280 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21281 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21282 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21283 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21284 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21285 v2sf __builtin_ia32_pfrcp (v2sf)
21286 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21287 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21288 v2sf __builtin_ia32_pfrsqrt (v2sf)
21289 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21290 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21291 v2sf __builtin_ia32_pi2fd (v2si)
21292 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21293 @end smallexample
21295 The following built-in functions are available when @option{-m3dnowa} is used.
21296 All of them generate the machine instruction that is part of the name.
21298 @smallexample
21299 v2si __builtin_ia32_pf2iw (v2sf)
21300 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21301 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21302 v2sf __builtin_ia32_pi2fw (v2si)
21303 v2sf __builtin_ia32_pswapdsf (v2sf)
21304 v2si __builtin_ia32_pswapdsi (v2si)
21305 @end smallexample
21307 The following built-in functions are available when @option{-mrtm} is used
21308 They are used for restricted transactional memory. These are the internal
21309 low level functions. Normally the functions in 
21310 @ref{x86 transactional memory intrinsics} should be used instead.
21312 @smallexample
21313 int __builtin_ia32_xbegin ()
21314 void __builtin_ia32_xend ()
21315 void __builtin_ia32_xabort (status)
21316 int __builtin_ia32_xtest ()
21317 @end smallexample
21319 The following built-in functions are available when @option{-mmwaitx} is used.
21320 All of them generate the machine instruction that is part of the name.
21321 @smallexample
21322 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21323 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21324 @end smallexample
21326 The following built-in functions are available when @option{-mclzero} is used.
21327 All of them generate the machine instruction that is part of the name.
21328 @smallexample
21329 void __builtin_i32_clzero (void *)
21330 @end smallexample
21332 The following built-in functions are available when @option{-mpku} is used.
21333 They generate reads and writes to PKRU.
21334 @smallexample
21335 void __builtin_ia32_wrpkru (unsigned int)
21336 unsigned int __builtin_ia32_rdpkru ()
21337 @end smallexample
21339 The following built-in functions are available when @option{-mcet} or
21340 @option{-mshstk} option is used.  They support shadow stack
21341 machine instructions from Intel Control-flow Enforcement Technology (CET).
21342 Each built-in function generates the  machine instruction that is part
21343 of the function's name.  These are the internal low-level functions.
21344 Normally the functions in @ref{x86 control-flow protection intrinsics}
21345 should be used instead.
21347 @smallexample
21348 unsigned int __builtin_ia32_rdsspd (void)
21349 unsigned long long __builtin_ia32_rdsspq (void)
21350 void __builtin_ia32_incsspd (unsigned int)
21351 void __builtin_ia32_incsspq (unsigned long long)
21352 void __builtin_ia32_saveprevssp(void);
21353 void __builtin_ia32_rstorssp(void *);
21354 void __builtin_ia32_wrssd(unsigned int, void *);
21355 void __builtin_ia32_wrssq(unsigned long long, void *);
21356 void __builtin_ia32_wrussd(unsigned int, void *);
21357 void __builtin_ia32_wrussq(unsigned long long, void *);
21358 void __builtin_ia32_setssbsy(void);
21359 void __builtin_ia32_clrssbsy(void *);
21360 @end smallexample
21362 @node x86 transactional memory intrinsics
21363 @subsection x86 Transactional Memory Intrinsics
21365 These hardware transactional memory intrinsics for x86 allow you to use
21366 memory transactions with RTM (Restricted Transactional Memory).
21367 This support is enabled with the @option{-mrtm} option.
21368 For using HLE (Hardware Lock Elision) see 
21369 @ref{x86 specific memory model extensions for transactional memory} instead.
21371 A memory transaction commits all changes to memory in an atomic way,
21372 as visible to other threads. If the transaction fails it is rolled back
21373 and all side effects discarded.
21375 Generally there is no guarantee that a memory transaction ever succeeds
21376 and suitable fallback code always needs to be supplied.
21378 @deftypefn {RTM Function} {unsigned} _xbegin ()
21379 Start a RTM (Restricted Transactional Memory) transaction. 
21380 Returns @code{_XBEGIN_STARTED} when the transaction
21381 started successfully (note this is not 0, so the constant has to be 
21382 explicitly tested).  
21384 If the transaction aborts, all side effects
21385 are undone and an abort code encoded as a bit mask is returned.
21386 The following macros are defined:
21388 @table @code
21389 @item _XABORT_EXPLICIT
21390 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
21391 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21392 @item _XABORT_RETRY
21393 Transaction retry is possible.
21394 @item _XABORT_CONFLICT
21395 Transaction abort due to a memory conflict with another thread.
21396 @item _XABORT_CAPACITY
21397 Transaction abort due to the transaction using too much memory.
21398 @item _XABORT_DEBUG
21399 Transaction abort due to a debug trap.
21400 @item _XABORT_NESTED
21401 Transaction abort in an inner nested transaction.
21402 @end table
21404 There is no guarantee
21405 any transaction ever succeeds, so there always needs to be a valid
21406 fallback path.
21407 @end deftypefn
21409 @deftypefn {RTM Function} {void} _xend ()
21410 Commit the current transaction. When no transaction is active this faults.
21411 All memory side effects of the transaction become visible
21412 to other threads in an atomic manner.
21413 @end deftypefn
21415 @deftypefn {RTM Function} {int} _xtest ()
21416 Return a nonzero value if a transaction is currently active, otherwise 0.
21417 @end deftypefn
21419 @deftypefn {RTM Function} {void} _xabort (status)
21420 Abort the current transaction. When no transaction is active this is a no-op.
21421 The @var{status} is an 8-bit constant; its value is encoded in the return 
21422 value from @code{_xbegin}.
21423 @end deftypefn
21425 Here is an example showing handling for @code{_XABORT_RETRY}
21426 and a fallback path for other failures:
21428 @smallexample
21429 #include <immintrin.h>
21431 int n_tries, max_tries;
21432 unsigned status = _XABORT_EXPLICIT;
21435 for (n_tries = 0; n_tries < max_tries; n_tries++) 
21436   @{
21437     status = _xbegin ();
21438     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21439       break;
21440   @}
21441 if (status == _XBEGIN_STARTED) 
21442   @{
21443     ... transaction code...
21444     _xend ();
21445   @} 
21446 else 
21447   @{
21448     ... non-transactional fallback path...
21449   @}
21450 @end smallexample
21452 @noindent
21453 Note that, in most cases, the transactional and non-transactional code
21454 must synchronize together to ensure consistency.
21456 @node x86 control-flow protection intrinsics
21457 @subsection x86 Control-Flow Protection Intrinsics
21459 @deftypefn {CET Function} {ret_type} _get_ssp (void)
21460 Get the current value of shadow stack pointer if shadow stack support
21461 from Intel CET is enabled in the hardware or @code{0} otherwise.
21462 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
21463 and @code{unsigned int} for 32-bit targets.
21464 @end deftypefn
21466 @deftypefn {CET Function} void _inc_ssp (unsigned int)
21467 Increment the current shadow stack pointer by the size specified by the
21468 function argument.  The argument is masked to a byte value for security
21469 reasons, so to increment by more than 255 bytes you must call the function
21470 multiple times.
21471 @end deftypefn
21473 The shadow stack unwind code looks like:
21475 @smallexample
21476 #include <immintrin.h>
21478 /* Unwind the shadow stack for EH.  */
21479 #define _Unwind_Frames_Extra(x)       \
21480   do                                  \
21481     @{                                \
21482       _Unwind_Word ssp = _get_ssp (); \
21483       if (ssp != 0)                   \
21484         @{                            \
21485           _Unwind_Word tmp = (x);     \
21486           while (tmp > 255)           \
21487             @{                        \
21488               _inc_ssp (tmp);         \
21489               tmp -= 255;             \
21490             @}                        \
21491           _inc_ssp (tmp);             \
21492         @}                            \
21493     @}                                \
21494     while (0)
21495 @end smallexample
21497 @noindent
21498 This code runs unconditionally on all 64-bit processors.  For 32-bit
21499 processors the code runs on those that support multi-byte NOP instructions.
21501 @node Target Format Checks
21502 @section Format Checks Specific to Particular Target Machines
21504 For some target machines, GCC supports additional options to the
21505 format attribute
21506 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
21508 @menu
21509 * Solaris Format Checks::
21510 * Darwin Format Checks::
21511 @end menu
21513 @node Solaris Format Checks
21514 @subsection Solaris Format Checks
21516 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
21517 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
21518 conversions, and the two-argument @code{%b} conversion for displaying
21519 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
21521 @node Darwin Format Checks
21522 @subsection Darwin Format Checks
21524 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
21525 attribute context.  Declarations made with such attribution are parsed for correct syntax
21526 and format argument types.  However, parsing of the format string itself is currently undefined
21527 and is not carried out by this version of the compiler.
21529 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
21530 also be used as format arguments.  Note that the relevant headers are only likely to be
21531 available on Darwin (OSX) installations.  On such installations, the XCode and system
21532 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
21533 associated functions.
21535 @node Pragmas
21536 @section Pragmas Accepted by GCC
21537 @cindex pragmas
21538 @cindex @code{#pragma}
21540 GCC supports several types of pragmas, primarily in order to compile
21541 code originally written for other compilers.  Note that in general
21542 we do not recommend the use of pragmas; @xref{Function Attributes},
21543 for further explanation.
21545 @menu
21546 * AArch64 Pragmas::
21547 * ARM Pragmas::
21548 * M32C Pragmas::
21549 * MeP Pragmas::
21550 * RS/6000 and PowerPC Pragmas::
21551 * S/390 Pragmas::
21552 * Darwin Pragmas::
21553 * Solaris Pragmas::
21554 * Symbol-Renaming Pragmas::
21555 * Structure-Layout Pragmas::
21556 * Weak Pragmas::
21557 * Diagnostic Pragmas::
21558 * Visibility Pragmas::
21559 * Push/Pop Macro Pragmas::
21560 * Function Specific Option Pragmas::
21561 * Loop-Specific Pragmas::
21562 @end menu
21564 @node AArch64 Pragmas
21565 @subsection AArch64 Pragmas
21567 The pragmas defined by the AArch64 target correspond to the AArch64
21568 target function attributes.  They can be specified as below:
21569 @smallexample
21570 #pragma GCC target("string")
21571 @end smallexample
21573 where @code{@var{string}} can be any string accepted as an AArch64 target
21574 attribute.  @xref{AArch64 Function Attributes}, for more details
21575 on the permissible values of @code{string}.
21577 @node ARM Pragmas
21578 @subsection ARM Pragmas
21580 The ARM target defines pragmas for controlling the default addition of
21581 @code{long_call} and @code{short_call} attributes to functions.
21582 @xref{Function Attributes}, for information about the effects of these
21583 attributes.
21585 @table @code
21586 @item long_calls
21587 @cindex pragma, long_calls
21588 Set all subsequent functions to have the @code{long_call} attribute.
21590 @item no_long_calls
21591 @cindex pragma, no_long_calls
21592 Set all subsequent functions to have the @code{short_call} attribute.
21594 @item long_calls_off
21595 @cindex pragma, long_calls_off
21596 Do not affect the @code{long_call} or @code{short_call} attributes of
21597 subsequent functions.
21598 @end table
21600 @node M32C Pragmas
21601 @subsection M32C Pragmas
21603 @table @code
21604 @item GCC memregs @var{number}
21605 @cindex pragma, memregs
21606 Overrides the command-line option @code{-memregs=} for the current
21607 file.  Use with care!  This pragma must be before any function in the
21608 file, and mixing different memregs values in different objects may
21609 make them incompatible.  This pragma is useful when a
21610 performance-critical function uses a memreg for temporary values,
21611 as it may allow you to reduce the number of memregs used.
21613 @item ADDRESS @var{name} @var{address}
21614 @cindex pragma, address
21615 For any declared symbols matching @var{name}, this does three things
21616 to that symbol: it forces the symbol to be located at the given
21617 address (a number), it forces the symbol to be volatile, and it
21618 changes the symbol's scope to be static.  This pragma exists for
21619 compatibility with other compilers, but note that the common
21620 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21621 instead).  Example:
21623 @smallexample
21624 #pragma ADDRESS port3 0x103
21625 char port3;
21626 @end smallexample
21628 @end table
21630 @node MeP Pragmas
21631 @subsection MeP Pragmas
21633 @table @code
21635 @item custom io_volatile (on|off)
21636 @cindex pragma, custom io_volatile
21637 Overrides the command-line option @code{-mio-volatile} for the current
21638 file.  Note that for compatibility with future GCC releases, this
21639 option should only be used once before any @code{io} variables in each
21640 file.
21642 @item GCC coprocessor available @var{registers}
21643 @cindex pragma, coprocessor available
21644 Specifies which coprocessor registers are available to the register
21645 allocator.  @var{registers} may be a single register, register range
21646 separated by ellipses, or comma-separated list of those.  Example:
21648 @smallexample
21649 #pragma GCC coprocessor available $c0...$c10, $c28
21650 @end smallexample
21652 @item GCC coprocessor call_saved @var{registers}
21653 @cindex pragma, coprocessor call_saved
21654 Specifies which coprocessor registers are to be saved and restored by
21655 any function using them.  @var{registers} may be a single register,
21656 register range separated by ellipses, or comma-separated list of
21657 those.  Example:
21659 @smallexample
21660 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21661 @end smallexample
21663 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21664 @cindex pragma, coprocessor subclass
21665 Creates and defines a register class.  These register classes can be
21666 used by inline @code{asm} constructs.  @var{registers} may be a single
21667 register, register range separated by ellipses, or comma-separated
21668 list of those.  Example:
21670 @smallexample
21671 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21673 asm ("cpfoo %0" : "=B" (x));
21674 @end smallexample
21676 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21677 @cindex pragma, disinterrupt
21678 For the named functions, the compiler adds code to disable interrupts
21679 for the duration of those functions.  If any functions so named 
21680 are not encountered in the source, a warning is emitted that the pragma is
21681 not used.  Examples:
21683 @smallexample
21684 #pragma disinterrupt foo
21685 #pragma disinterrupt bar, grill
21686 int foo () @{ @dots{} @}
21687 @end smallexample
21689 @item GCC call @var{name} , @var{name} @dots{}
21690 @cindex pragma, call
21691 For the named functions, the compiler always uses a register-indirect
21692 call model when calling the named functions.  Examples:
21694 @smallexample
21695 extern int foo ();
21696 #pragma call foo
21697 @end smallexample
21699 @end table
21701 @node RS/6000 and PowerPC Pragmas
21702 @subsection RS/6000 and PowerPC Pragmas
21704 The RS/6000 and PowerPC targets define one pragma for controlling
21705 whether or not the @code{longcall} attribute is added to function
21706 declarations by default.  This pragma overrides the @option{-mlongcall}
21707 option, but not the @code{longcall} and @code{shortcall} attributes.
21708 @xref{RS/6000 and PowerPC Options}, for more information about when long
21709 calls are and are not necessary.
21711 @table @code
21712 @item longcall (1)
21713 @cindex pragma, longcall
21714 Apply the @code{longcall} attribute to all subsequent function
21715 declarations.
21717 @item longcall (0)
21718 Do not apply the @code{longcall} attribute to subsequent function
21719 declarations.
21720 @end table
21722 @c Describe h8300 pragmas here.
21723 @c Describe sh pragmas here.
21724 @c Describe v850 pragmas here.
21726 @node S/390 Pragmas
21727 @subsection S/390 Pragmas
21729 The pragmas defined by the S/390 target correspond to the S/390
21730 target function attributes and some the additional options:
21732 @table @samp
21733 @item zvector
21734 @itemx no-zvector
21735 @end table
21737 Note that options of the pragma, unlike options of the target
21738 attribute, do change the value of preprocessor macros like
21739 @code{__VEC__}.  They can be specified as below:
21741 @smallexample
21742 #pragma GCC target("string[,string]...")
21743 #pragma GCC target("string"[,"string"]...)
21744 @end smallexample
21746 @node Darwin Pragmas
21747 @subsection Darwin Pragmas
21749 The following pragmas are available for all architectures running the
21750 Darwin operating system.  These are useful for compatibility with other
21751 Mac OS compilers.
21753 @table @code
21754 @item mark @var{tokens}@dots{}
21755 @cindex pragma, mark
21756 This pragma is accepted, but has no effect.
21758 @item options align=@var{alignment}
21759 @cindex pragma, options align
21760 This pragma sets the alignment of fields in structures.  The values of
21761 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21762 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
21763 properly; to restore the previous setting, use @code{reset} for the
21764 @var{alignment}.
21766 @item segment @var{tokens}@dots{}
21767 @cindex pragma, segment
21768 This pragma is accepted, but has no effect.
21770 @item unused (@var{var} [, @var{var}]@dots{})
21771 @cindex pragma, unused
21772 This pragma declares variables to be possibly unused.  GCC does not
21773 produce warnings for the listed variables.  The effect is similar to
21774 that of the @code{unused} attribute, except that this pragma may appear
21775 anywhere within the variables' scopes.
21776 @end table
21778 @node Solaris Pragmas
21779 @subsection Solaris Pragmas
21781 The Solaris target supports @code{#pragma redefine_extname}
21782 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
21783 @code{#pragma} directives for compatibility with the system compiler.
21785 @table @code
21786 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
21787 @cindex pragma, align
21789 Increase the minimum alignment of each @var{variable} to @var{alignment}.
21790 This is the same as GCC's @code{aligned} attribute @pxref{Variable
21791 Attributes}).  Macro expansion occurs on the arguments to this pragma
21792 when compiling C and Objective-C@.  It does not currently occur when
21793 compiling C++, but this is a bug which may be fixed in a future
21794 release.
21796 @item fini (@var{function} [, @var{function}]...)
21797 @cindex pragma, fini
21799 This pragma causes each listed @var{function} to be called after
21800 main, or during shared module unloading, by adding a call to the
21801 @code{.fini} section.
21803 @item init (@var{function} [, @var{function}]...)
21804 @cindex pragma, init
21806 This pragma causes each listed @var{function} to be called during
21807 initialization (before @code{main}) or during shared module loading, by
21808 adding a call to the @code{.init} section.
21810 @end table
21812 @node Symbol-Renaming Pragmas
21813 @subsection Symbol-Renaming Pragmas
21815 GCC supports a @code{#pragma} directive that changes the name used in
21816 assembly for a given declaration. While this pragma is supported on all
21817 platforms, it is intended primarily to provide compatibility with the
21818 Solaris system headers. This effect can also be achieved using the asm
21819 labels extension (@pxref{Asm Labels}).
21821 @table @code
21822 @item redefine_extname @var{oldname} @var{newname}
21823 @cindex pragma, redefine_extname
21825 This pragma gives the C function @var{oldname} the assembly symbol
21826 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
21827 is defined if this pragma is available (currently on all platforms).
21828 @end table
21830 This pragma and the asm labels extension interact in a complicated
21831 manner.  Here are some corner cases you may want to be aware of:
21833 @enumerate
21834 @item This pragma silently applies only to declarations with external
21835 linkage.  Asm labels do not have this restriction.
21837 @item In C++, this pragma silently applies only to declarations with
21838 ``C'' linkage.  Again, asm labels do not have this restriction.
21840 @item If either of the ways of changing the assembly name of a
21841 declaration are applied to a declaration whose assembly name has
21842 already been determined (either by a previous use of one of these
21843 features, or because the compiler needed the assembly name in order to
21844 generate code), and the new name is different, a warning issues and
21845 the name does not change.
21847 @item The @var{oldname} used by @code{#pragma redefine_extname} is
21848 always the C-language name.
21849 @end enumerate
21851 @node Structure-Layout Pragmas
21852 @subsection Structure-Layout Pragmas
21854 For compatibility with Microsoft Windows compilers, GCC supports a
21855 set of @code{#pragma} directives that change the maximum alignment of
21856 members of structures (other than zero-width bit-fields), unions, and
21857 classes subsequently defined. The @var{n} value below always is required
21858 to be a small power of two and specifies the new alignment in bytes.
21860 @enumerate
21861 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
21862 @item @code{#pragma pack()} sets the alignment to the one that was in
21863 effect when compilation started (see also command-line option
21864 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
21865 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
21866 setting on an internal stack and then optionally sets the new alignment.
21867 @item @code{#pragma pack(pop)} restores the alignment setting to the one
21868 saved at the top of the internal stack (and removes that stack entry).
21869 Note that @code{#pragma pack([@var{n}])} does not influence this internal
21870 stack; thus it is possible to have @code{#pragma pack(push)} followed by
21871 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
21872 @code{#pragma pack(pop)}.
21873 @end enumerate
21875 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
21876 directive which lays out structures and unions subsequently defined as the
21877 documented @code{__attribute__ ((ms_struct))}.
21879 @enumerate
21880 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21881 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21882 @item @code{#pragma ms_struct reset} goes back to the default layout.
21883 @end enumerate
21885 Most targets also support the @code{#pragma scalar_storage_order} directive
21886 which lays out structures and unions subsequently defined as the documented
21887 @code{__attribute__ ((scalar_storage_order))}.
21889 @enumerate
21890 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21891 of the scalar fields to big-endian.
21892 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21893 of the scalar fields to little-endian.
21894 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21895 that was in effect when compilation started (see also command-line option
21896 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21897 @end enumerate
21899 @node Weak Pragmas
21900 @subsection Weak Pragmas
21902 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21903 directives for declaring symbols to be weak, and defining weak
21904 aliases.
21906 @table @code
21907 @item #pragma weak @var{symbol}
21908 @cindex pragma, weak
21909 This pragma declares @var{symbol} to be weak, as if the declaration
21910 had the attribute of the same name.  The pragma may appear before
21911 or after the declaration of @var{symbol}.  It is not an error for
21912 @var{symbol} to never be defined at all.
21914 @item #pragma weak @var{symbol1} = @var{symbol2}
21915 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21916 It is an error if @var{symbol2} is not defined in the current
21917 translation unit.
21918 @end table
21920 @node Diagnostic Pragmas
21921 @subsection Diagnostic Pragmas
21923 GCC allows the user to selectively enable or disable certain types of
21924 diagnostics, and change the kind of the diagnostic.  For example, a
21925 project's policy might require that all sources compile with
21926 @option{-Werror} but certain files might have exceptions allowing
21927 specific types of warnings.  Or, a project might selectively enable
21928 diagnostics and treat them as errors depending on which preprocessor
21929 macros are defined.
21931 @table @code
21932 @item #pragma GCC diagnostic @var{kind} @var{option}
21933 @cindex pragma, diagnostic
21935 Modifies the disposition of a diagnostic.  Note that not all
21936 diagnostics are modifiable; at the moment only warnings (normally
21937 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
21938 Use @option{-fdiagnostics-show-option} to determine which diagnostics
21939 are controllable and which option controls them.
21941 @var{kind} is @samp{error} to treat this diagnostic as an error,
21942 @samp{warning} to treat it like a warning (even if @option{-Werror} is
21943 in effect), or @samp{ignored} if the diagnostic is to be ignored.
21944 @var{option} is a double quoted string that matches the command-line
21945 option.
21947 @smallexample
21948 #pragma GCC diagnostic warning "-Wformat"
21949 #pragma GCC diagnostic error "-Wformat"
21950 #pragma GCC diagnostic ignored "-Wformat"
21951 @end smallexample
21953 Note that these pragmas override any command-line options.  GCC keeps
21954 track of the location of each pragma, and issues diagnostics according
21955 to the state as of that point in the source file.  Thus, pragmas occurring
21956 after a line do not affect diagnostics caused by that line.
21958 @item #pragma GCC diagnostic push
21959 @itemx #pragma GCC diagnostic pop
21961 Causes GCC to remember the state of the diagnostics as of each
21962 @code{push}, and restore to that point at each @code{pop}.  If a
21963 @code{pop} has no matching @code{push}, the command-line options are
21964 restored.
21966 @smallexample
21967 #pragma GCC diagnostic error "-Wuninitialized"
21968   foo(a);                       /* error is given for this one */
21969 #pragma GCC diagnostic push
21970 #pragma GCC diagnostic ignored "-Wuninitialized"
21971   foo(b);                       /* no diagnostic for this one */
21972 #pragma GCC diagnostic pop
21973   foo(c);                       /* error is given for this one */
21974 #pragma GCC diagnostic pop
21975   foo(d);                       /* depends on command-line options */
21976 @end smallexample
21978 @end table
21980 GCC also offers a simple mechanism for printing messages during
21981 compilation.
21983 @table @code
21984 @item #pragma message @var{string}
21985 @cindex pragma, diagnostic
21987 Prints @var{string} as a compiler message on compilation.  The message
21988 is informational only, and is neither a compilation warning nor an
21989 error.  Newlines can be included in the string by using the @samp{\n}
21990 escape sequence.
21992 @smallexample
21993 #pragma message "Compiling " __FILE__ "..."
21994 @end smallexample
21996 @var{string} may be parenthesized, and is printed with location
21997 information.  For example,
21999 @smallexample
22000 #define DO_PRAGMA(x) _Pragma (#x)
22001 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22003 TODO(Remember to fix this)
22004 @end smallexample
22006 @noindent
22007 prints @samp{/tmp/file.c:4: note: #pragma message:
22008 TODO - Remember to fix this}.
22010 @item #pragma GCC error @var{message}
22011 @cindex pragma, diagnostic
22012 Generates an error message.  This pragma @emph{is} considered to
22013 indicate an error in the compilation, and it will be treated as such.
22015 Newlines can be included in the string by using the @samp{\n}
22016 escape sequence.  They will be displayed as newlines even if the
22017 @option{-fmessage-length} option is set to zero.
22019 The error is only generated if the pragma is present in the code after
22020 pre-processing has been completed.  It does not matter however if the
22021 code containing the pragma is unreachable:
22023 @smallexample
22024 #if 0
22025 #pragma GCC error "this error is not seen"
22026 #endif
22027 void foo (void)
22029   return;
22030 #pragma GCC error "this error is seen"
22032 @end smallexample
22034 @item #pragma GCC warning @var{message}
22035 @cindex pragma, diagnostic
22036 This is just like @samp{pragma GCC error} except that a warning
22037 message is issued instead of an error message.  Unless
22038 @option{-Werror} is in effect, in which case this pragma will generate
22039 an error as well.
22041 @end table
22043 @node Visibility Pragmas
22044 @subsection Visibility Pragmas
22046 @table @code
22047 @item #pragma GCC visibility push(@var{visibility})
22048 @itemx #pragma GCC visibility pop
22049 @cindex pragma, visibility
22051 This pragma allows the user to set the visibility for multiple
22052 declarations without having to give each a visibility attribute
22053 (@pxref{Function Attributes}).
22055 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22056 declarations.  Class members and template specializations are not
22057 affected; if you want to override the visibility for a particular
22058 member or instantiation, you must use an attribute.
22060 @end table
22063 @node Push/Pop Macro Pragmas
22064 @subsection Push/Pop Macro Pragmas
22066 For compatibility with Microsoft Windows compilers, GCC supports
22067 @samp{#pragma push_macro(@var{"macro_name"})}
22068 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22070 @table @code
22071 @item #pragma push_macro(@var{"macro_name"})
22072 @cindex pragma, push_macro
22073 This pragma saves the value of the macro named as @var{macro_name} to
22074 the top of the stack for this macro.
22076 @item #pragma pop_macro(@var{"macro_name"})
22077 @cindex pragma, pop_macro
22078 This pragma sets the value of the macro named as @var{macro_name} to
22079 the value on top of the stack for this macro. If the stack for
22080 @var{macro_name} is empty, the value of the macro remains unchanged.
22081 @end table
22083 For example:
22085 @smallexample
22086 #define X  1
22087 #pragma push_macro("X")
22088 #undef X
22089 #define X -1
22090 #pragma pop_macro("X")
22091 int x [X];
22092 @end smallexample
22094 @noindent
22095 In this example, the definition of X as 1 is saved by @code{#pragma
22096 push_macro} and restored by @code{#pragma pop_macro}.
22098 @node Function Specific Option Pragmas
22099 @subsection Function Specific Option Pragmas
22101 @table @code
22102 @item #pragma GCC target (@var{"string"}...)
22103 @cindex pragma GCC target
22105 This pragma allows you to set target specific options for functions
22106 defined later in the source file.  One or more strings can be
22107 specified.  Each function that is defined after this point is as
22108 if @code{attribute((target("STRING")))} was specified for that
22109 function.  The parenthesis around the options is optional.
22110 @xref{Function Attributes}, for more information about the
22111 @code{target} attribute and the attribute syntax.
22113 The @code{#pragma GCC target} pragma is presently implemented for
22114 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22116 @item #pragma GCC optimize (@var{"string"}...)
22117 @cindex pragma GCC optimize
22119 This pragma allows you to set global optimization options for functions
22120 defined later in the source file.  One or more strings can be
22121 specified.  Each function that is defined after this point is as
22122 if @code{attribute((optimize("STRING")))} was specified for that
22123 function.  The parenthesis around the options is optional.
22124 @xref{Function Attributes}, for more information about the
22125 @code{optimize} attribute and the attribute syntax.
22127 @item #pragma GCC push_options
22128 @itemx #pragma GCC pop_options
22129 @cindex pragma GCC push_options
22130 @cindex pragma GCC pop_options
22132 These pragmas maintain a stack of the current target and optimization
22133 options.  It is intended for include files where you temporarily want
22134 to switch to using a different @samp{#pragma GCC target} or
22135 @samp{#pragma GCC optimize} and then to pop back to the previous
22136 options.
22138 @item #pragma GCC reset_options
22139 @cindex pragma GCC reset_options
22141 This pragma clears the current @code{#pragma GCC target} and
22142 @code{#pragma GCC optimize} to use the default switches as specified
22143 on the command line.
22145 @end table
22147 @node Loop-Specific Pragmas
22148 @subsection Loop-Specific Pragmas
22150 @table @code
22151 @item #pragma GCC ivdep
22152 @cindex pragma GCC ivdep
22154 With this pragma, the programmer asserts that there are no loop-carried
22155 dependencies which would prevent consecutive iterations of
22156 the following loop from executing concurrently with SIMD
22157 (single instruction multiple data) instructions.
22159 For example, the compiler can only unconditionally vectorize the following
22160 loop with the pragma:
22162 @smallexample
22163 void foo (int n, int *a, int *b, int *c)
22165   int i, j;
22166 #pragma GCC ivdep
22167   for (i = 0; i < n; ++i)
22168     a[i] = b[i] + c[i];
22170 @end smallexample
22172 @noindent
22173 In this example, using the @code{restrict} qualifier had the same
22174 effect. In the following example, that would not be possible. Assume
22175 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22176 that it can unconditionally vectorize the following loop:
22178 @smallexample
22179 void ignore_vec_dep (int *a, int k, int c, int m)
22181 #pragma GCC ivdep
22182   for (int i = 0; i < m; i++)
22183     a[i] = a[i + k] * c;
22185 @end smallexample
22187 @item #pragma GCC unroll @var{n}
22188 @cindex pragma GCC unroll @var{n}
22190 You can use this pragma to control how many times a loop should be unrolled.
22191 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22192 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22193 @var{n} is an integer constant expression specifying the unrolling factor.
22194 The values of @math{0} and @math{1} block any unrolling of the loop.
22196 @end table
22198 @node Unnamed Fields
22199 @section Unnamed Structure and Union Fields
22200 @cindex @code{struct}
22201 @cindex @code{union}
22203 As permitted by ISO C11 and for compatibility with other compilers,
22204 GCC allows you to define
22205 a structure or union that contains, as fields, structures and unions
22206 without names.  For example:
22208 @smallexample
22209 struct @{
22210   int a;
22211   union @{
22212     int b;
22213     float c;
22214   @};
22215   int d;
22216 @} foo;
22217 @end smallexample
22219 @noindent
22220 In this example, you are able to access members of the unnamed
22221 union with code like @samp{foo.b}.  Note that only unnamed structs and
22222 unions are allowed, you may not have, for example, an unnamed
22223 @code{int}.
22225 You must never create such structures that cause ambiguous field definitions.
22226 For example, in this structure:
22228 @smallexample
22229 struct @{
22230   int a;
22231   struct @{
22232     int a;
22233   @};
22234 @} foo;
22235 @end smallexample
22237 @noindent
22238 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22239 The compiler gives errors for such constructs.
22241 @opindex fms-extensions
22242 Unless @option{-fms-extensions} is used, the unnamed field must be a
22243 structure or union definition without a tag (for example, @samp{struct
22244 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22245 also be a definition with a tag such as @samp{struct foo @{ int a;
22246 @};}, a reference to a previously defined structure or union such as
22247 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22248 previously defined structure or union type.
22250 @opindex fplan9-extensions
22251 The option @option{-fplan9-extensions} enables
22252 @option{-fms-extensions} as well as two other extensions.  First, a
22253 pointer to a structure is automatically converted to a pointer to an
22254 anonymous field for assignments and function calls.  For example:
22256 @smallexample
22257 struct s1 @{ int a; @};
22258 struct s2 @{ struct s1; @};
22259 extern void f1 (struct s1 *);
22260 void f2 (struct s2 *p) @{ f1 (p); @}
22261 @end smallexample
22263 @noindent
22264 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22265 converted into a pointer to the anonymous field.
22267 Second, when the type of an anonymous field is a @code{typedef} for a
22268 @code{struct} or @code{union}, code may refer to the field using the
22269 name of the @code{typedef}.
22271 @smallexample
22272 typedef struct @{ int a; @} s1;
22273 struct s2 @{ s1; @};
22274 s1 f1 (struct s2 *p) @{ return p->s1; @}
22275 @end smallexample
22277 These usages are only permitted when they are not ambiguous.
22279 @node Thread-Local
22280 @section Thread-Local Storage
22281 @cindex Thread-Local Storage
22282 @cindex @acronym{TLS}
22283 @cindex @code{__thread}
22285 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22286 are allocated such that there is one instance of the variable per extant
22287 thread.  The runtime model GCC uses to implement this originates
22288 in the IA-64 processor-specific ABI, but has since been migrated
22289 to other processors as well.  It requires significant support from
22290 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22291 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22292 is not available everywhere.
22294 At the user level, the extension is visible with a new storage
22295 class keyword: @code{__thread}.  For example:
22297 @smallexample
22298 __thread int i;
22299 extern __thread struct state s;
22300 static __thread char *p;
22301 @end smallexample
22303 The @code{__thread} specifier may be used alone, with the @code{extern}
22304 or @code{static} specifiers, but with no other storage class specifier.
22305 When used with @code{extern} or @code{static}, @code{__thread} must appear
22306 immediately after the other storage class specifier.
22308 The @code{__thread} specifier may be applied to any global, file-scoped
22309 static, function-scoped static, or static data member of a class.  It may
22310 not be applied to block-scoped automatic or non-static data member.
22312 When the address-of operator is applied to a thread-local variable, it is
22313 evaluated at run time and returns the address of the current thread's
22314 instance of that variable.  An address so obtained may be used by any
22315 thread.  When a thread terminates, any pointers to thread-local variables
22316 in that thread become invalid.
22318 No static initialization may refer to the address of a thread-local variable.
22320 In C++, if an initializer is present for a thread-local variable, it must
22321 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22322 standard.
22324 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22325 ELF Handling For Thread-Local Storage} for a detailed explanation of
22326 the four thread-local storage addressing models, and how the runtime
22327 is expected to function.
22329 @menu
22330 * C99 Thread-Local Edits::
22331 * C++98 Thread-Local Edits::
22332 @end menu
22334 @node C99 Thread-Local Edits
22335 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22337 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22338 that document the exact semantics of the language extension.
22340 @itemize @bullet
22341 @item
22342 @cite{5.1.2  Execution environments}
22344 Add new text after paragraph 1
22346 @quotation
22347 Within either execution environment, a @dfn{thread} is a flow of
22348 control within a program.  It is implementation defined whether
22349 or not there may be more than one thread associated with a program.
22350 It is implementation defined how threads beyond the first are
22351 created, the name and type of the function called at thread
22352 startup, and how threads may be terminated.  However, objects
22353 with thread storage duration shall be initialized before thread
22354 startup.
22355 @end quotation
22357 @item
22358 @cite{6.2.4  Storage durations of objects}
22360 Add new text before paragraph 3
22362 @quotation
22363 An object whose identifier is declared with the storage-class
22364 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22365 Its lifetime is the entire execution of the thread, and its
22366 stored value is initialized only once, prior to thread startup.
22367 @end quotation
22369 @item
22370 @cite{6.4.1  Keywords}
22372 Add @code{__thread}.
22374 @item
22375 @cite{6.7.1  Storage-class specifiers}
22377 Add @code{__thread} to the list of storage class specifiers in
22378 paragraph 1.
22380 Change paragraph 2 to
22382 @quotation
22383 With the exception of @code{__thread}, at most one storage-class
22384 specifier may be given [@dots{}].  The @code{__thread} specifier may
22385 be used alone, or immediately following @code{extern} or
22386 @code{static}.
22387 @end quotation
22389 Add new text after paragraph 6
22391 @quotation
22392 The declaration of an identifier for a variable that has
22393 block scope that specifies @code{__thread} shall also
22394 specify either @code{extern} or @code{static}.
22396 The @code{__thread} specifier shall be used only with
22397 variables.
22398 @end quotation
22399 @end itemize
22401 @node C++98 Thread-Local Edits
22402 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22404 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22405 that document the exact semantics of the language extension.
22407 @itemize @bullet
22408 @item
22409 @b{[intro.execution]}
22411 New text after paragraph 4
22413 @quotation
22414 A @dfn{thread} is a flow of control within the abstract machine.
22415 It is implementation defined whether or not there may be more than
22416 one thread.
22417 @end quotation
22419 New text after paragraph 7
22421 @quotation
22422 It is unspecified whether additional action must be taken to
22423 ensure when and whether side effects are visible to other threads.
22424 @end quotation
22426 @item
22427 @b{[lex.key]}
22429 Add @code{__thread}.
22431 @item
22432 @b{[basic.start.main]}
22434 Add after paragraph 5
22436 @quotation
22437 The thread that begins execution at the @code{main} function is called
22438 the @dfn{main thread}.  It is implementation defined how functions
22439 beginning threads other than the main thread are designated or typed.
22440 A function so designated, as well as the @code{main} function, is called
22441 a @dfn{thread startup function}.  It is implementation defined what
22442 happens if a thread startup function returns.  It is implementation
22443 defined what happens to other threads when any thread calls @code{exit}.
22444 @end quotation
22446 @item
22447 @b{[basic.start.init]}
22449 Add after paragraph 4
22451 @quotation
22452 The storage for an object of thread storage duration shall be
22453 statically initialized before the first statement of the thread startup
22454 function.  An object of thread storage duration shall not require
22455 dynamic initialization.
22456 @end quotation
22458 @item
22459 @b{[basic.start.term]}
22461 Add after paragraph 3
22463 @quotation
22464 The type of an object with thread storage duration shall not have a
22465 non-trivial destructor, nor shall it be an array type whose elements
22466 (directly or indirectly) have non-trivial destructors.
22467 @end quotation
22469 @item
22470 @b{[basic.stc]}
22472 Add ``thread storage duration'' to the list in paragraph 1.
22474 Change paragraph 2
22476 @quotation
22477 Thread, static, and automatic storage durations are associated with
22478 objects introduced by declarations [@dots{}].
22479 @end quotation
22481 Add @code{__thread} to the list of specifiers in paragraph 3.
22483 @item
22484 @b{[basic.stc.thread]}
22486 New section before @b{[basic.stc.static]}
22488 @quotation
22489 The keyword @code{__thread} applied to a non-local object gives the
22490 object thread storage duration.
22492 A local variable or class data member declared both @code{static}
22493 and @code{__thread} gives the variable or member thread storage
22494 duration.
22495 @end quotation
22497 @item
22498 @b{[basic.stc.static]}
22500 Change paragraph 1
22502 @quotation
22503 All objects that have neither thread storage duration, dynamic
22504 storage duration nor are local [@dots{}].
22505 @end quotation
22507 @item
22508 @b{[dcl.stc]}
22510 Add @code{__thread} to the list in paragraph 1.
22512 Change paragraph 1
22514 @quotation
22515 With the exception of @code{__thread}, at most one
22516 @var{storage-class-specifier} shall appear in a given
22517 @var{decl-specifier-seq}.  The @code{__thread} specifier may
22518 be used alone, or immediately following the @code{extern} or
22519 @code{static} specifiers.  [@dots{}]
22520 @end quotation
22522 Add after paragraph 5
22524 @quotation
22525 The @code{__thread} specifier can be applied only to the names of objects
22526 and to anonymous unions.
22527 @end quotation
22529 @item
22530 @b{[class.mem]}
22532 Add after paragraph 6
22534 @quotation
22535 Non-@code{static} members shall not be @code{__thread}.
22536 @end quotation
22537 @end itemize
22539 @node Binary constants
22540 @section Binary Constants using the @samp{0b} Prefix
22541 @cindex Binary constants using the @samp{0b} prefix
22543 Integer constants can be written as binary constants, consisting of a
22544 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
22545 @samp{0B}.  This is particularly useful in environments that operate a
22546 lot on the bit level (like microcontrollers).
22548 The following statements are identical:
22550 @smallexample
22551 i =       42;
22552 i =     0x2a;
22553 i =      052;
22554 i = 0b101010;
22555 @end smallexample
22557 The type of these constants follows the same rules as for octal or
22558 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
22559 can be applied.
22561 @node C++ Extensions
22562 @chapter Extensions to the C++ Language
22563 @cindex extensions, C++ language
22564 @cindex C++ language extensions
22566 The GNU compiler provides these extensions to the C++ language (and you
22567 can also use most of the C language extensions in your C++ programs).  If you
22568 want to write code that checks whether these features are available, you can
22569 test for the GNU compiler the same way as for C programs: check for a
22570 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
22571 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
22572 Predefined Macros,cpp,The GNU C Preprocessor}).
22574 @menu
22575 * C++ Volatiles::       What constitutes an access to a volatile object.
22576 * Restricted Pointers:: C99 restricted pointers and references.
22577 * Vague Linkage::       Where G++ puts inlines, vtables and such.
22578 * C++ Interface::       You can use a single C++ header file for both
22579                         declarations and definitions.
22580 * Template Instantiation:: Methods for ensuring that exactly one copy of
22581                         each needed template instantiation is emitted.
22582 * Bound member functions:: You can extract a function pointer to the
22583                         method denoted by a @samp{->*} or @samp{.*} expression.
22584 * C++ Attributes::      Variable, function, and type attributes for C++ only.
22585 * Function Multiversioning::   Declaring multiple function versions.
22586 * Type Traits::         Compiler support for type traits.
22587 * C++ Concepts::        Improved support for generic programming.
22588 * Deprecated Features:: Things will disappear from G++.
22589 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22590 @end menu
22592 @node C++ Volatiles
22593 @section When is a Volatile C++ Object Accessed?
22594 @cindex accessing volatiles
22595 @cindex volatile read
22596 @cindex volatile write
22597 @cindex volatile access
22599 The C++ standard differs from the C standard in its treatment of
22600 volatile objects.  It fails to specify what constitutes a volatile
22601 access, except to say that C++ should behave in a similar manner to C
22602 with respect to volatiles, where possible.  However, the different
22603 lvalueness of expressions between C and C++ complicate the behavior.
22604 G++ behaves the same as GCC for volatile access, @xref{C
22605 Extensions,,Volatiles}, for a description of GCC's behavior.
22607 The C and C++ language specifications differ when an object is
22608 accessed in a void context:
22610 @smallexample
22611 volatile int *src = @var{somevalue};
22612 *src;
22613 @end smallexample
22615 The C++ standard specifies that such expressions do not undergo lvalue
22616 to rvalue conversion, and that the type of the dereferenced object may
22617 be incomplete.  The C++ standard does not specify explicitly that it
22618 is lvalue to rvalue conversion that is responsible for causing an
22619 access.  There is reason to believe that it is, because otherwise
22620 certain simple expressions become undefined.  However, because it
22621 would surprise most programmers, G++ treats dereferencing a pointer to
22622 volatile object of complete type as GCC would do for an equivalent
22623 type in C@.  When the object has incomplete type, G++ issues a
22624 warning; if you wish to force an error, you must force a conversion to
22625 rvalue with, for instance, a static cast.
22627 When using a reference to volatile, G++ does not treat equivalent
22628 expressions as accesses to volatiles, but instead issues a warning that
22629 no volatile is accessed.  The rationale for this is that otherwise it
22630 becomes difficult to determine where volatile access occur, and not
22631 possible to ignore the return value from functions returning volatile
22632 references.  Again, if you wish to force a read, cast the reference to
22633 an rvalue.
22635 G++ implements the same behavior as GCC does when assigning to a
22636 volatile object---there is no reread of the assigned-to object, the
22637 assigned rvalue is reused.  Note that in C++ assignment expressions
22638 are lvalues, and if used as an lvalue, the volatile object is
22639 referred to.  For instance, @var{vref} refers to @var{vobj}, as
22640 expected, in the following example:
22642 @smallexample
22643 volatile int vobj;
22644 volatile int &vref = vobj = @var{something};
22645 @end smallexample
22647 @node Restricted Pointers
22648 @section Restricting Pointer Aliasing
22649 @cindex restricted pointers
22650 @cindex restricted references
22651 @cindex restricted this pointer
22653 As with the C front end, G++ understands the C99 feature of restricted pointers,
22654 specified with the @code{__restrict__}, or @code{__restrict} type
22655 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
22656 language flag, @code{restrict} is not a keyword in C++.
22658 In addition to allowing restricted pointers, you can specify restricted
22659 references, which indicate that the reference is not aliased in the local
22660 context.
22662 @smallexample
22663 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22665   /* @r{@dots{}} */
22667 @end smallexample
22669 @noindent
22670 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22671 @var{rref} refers to a (different) unaliased integer.
22673 You may also specify whether a member function's @var{this} pointer is
22674 unaliased by using @code{__restrict__} as a member function qualifier.
22676 @smallexample
22677 void T::fn () __restrict__
22679   /* @r{@dots{}} */
22681 @end smallexample
22683 @noindent
22684 Within the body of @code{T::fn}, @var{this} has the effective
22685 definition @code{T *__restrict__ const this}.  Notice that the
22686 interpretation of a @code{__restrict__} member function qualifier is
22687 different to that of @code{const} or @code{volatile} qualifier, in that it
22688 is applied to the pointer rather than the object.  This is consistent with
22689 other compilers that implement restricted pointers.
22691 As with all outermost parameter qualifiers, @code{__restrict__} is
22692 ignored in function definition matching.  This means you only need to
22693 specify @code{__restrict__} in a function definition, rather than
22694 in a function prototype as well.
22696 @node Vague Linkage
22697 @section Vague Linkage
22698 @cindex vague linkage
22700 There are several constructs in C++ that require space in the object
22701 file but are not clearly tied to a single translation unit.  We say that
22702 these constructs have ``vague linkage''.  Typically such constructs are
22703 emitted wherever they are needed, though sometimes we can be more
22704 clever.
22706 @table @asis
22707 @item Inline Functions
22708 Inline functions are typically defined in a header file which can be
22709 included in many different compilations.  Hopefully they can usually be
22710 inlined, but sometimes an out-of-line copy is necessary, if the address
22711 of the function is taken or if inlining fails.  In general, we emit an
22712 out-of-line copy in all translation units where one is needed.  As an
22713 exception, we only emit inline virtual functions with the vtable, since
22714 it always requires a copy.
22716 Local static variables and string constants used in an inline function
22717 are also considered to have vague linkage, since they must be shared
22718 between all inlined and out-of-line instances of the function.
22720 @item VTables
22721 @cindex vtable
22722 C++ virtual functions are implemented in most compilers using a lookup
22723 table, known as a vtable.  The vtable contains pointers to the virtual
22724 functions provided by a class, and each object of the class contains a
22725 pointer to its vtable (or vtables, in some multiple-inheritance
22726 situations).  If the class declares any non-inline, non-pure virtual
22727 functions, the first one is chosen as the ``key method'' for the class,
22728 and the vtable is only emitted in the translation unit where the key
22729 method is defined.
22731 @emph{Note:} If the chosen key method is later defined as inline, the
22732 vtable is still emitted in every translation unit that defines it.
22733 Make sure that any inline virtuals are declared inline in the class
22734 body, even if they are not defined there.
22736 @item @code{type_info} objects
22737 @cindex @code{type_info}
22738 @cindex RTTI
22739 C++ requires information about types to be written out in order to
22740 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
22741 For polymorphic classes (classes with virtual functions), the @samp{type_info}
22742 object is written out along with the vtable so that @samp{dynamic_cast}
22743 can determine the dynamic type of a class object at run time.  For all
22744 other types, we write out the @samp{type_info} object when it is used: when
22745 applying @samp{typeid} to an expression, throwing an object, or
22746 referring to a type in a catch clause or exception specification.
22748 @item Template Instantiations
22749 Most everything in this section also applies to template instantiations,
22750 but there are other options as well.
22751 @xref{Template Instantiation,,Where's the Template?}.
22753 @end table
22755 When used with GNU ld version 2.8 or later on an ELF system such as
22756 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
22757 these constructs will be discarded at link time.  This is known as
22758 COMDAT support.
22760 On targets that don't support COMDAT, but do support weak symbols, GCC
22761 uses them.  This way one copy overrides all the others, but
22762 the unused copies still take up space in the executable.
22764 For targets that do not support either COMDAT or weak symbols,
22765 most entities with vague linkage are emitted as local symbols to
22766 avoid duplicate definition errors from the linker.  This does not happen
22767 for local statics in inlines, however, as having multiple copies
22768 almost certainly breaks things.
22770 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
22771 another way to control placement of these constructs.
22773 @node C++ Interface
22774 @section C++ Interface and Implementation Pragmas
22776 @cindex interface and implementation headers, C++
22777 @cindex C++ interface and implementation headers
22778 @cindex pragmas, interface and implementation
22780 @code{#pragma interface} and @code{#pragma implementation} provide the
22781 user with a way of explicitly directing the compiler to emit entities
22782 with vague linkage (and debugging information) in a particular
22783 translation unit.
22785 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
22786 by COMDAT support and the ``key method'' heuristic
22787 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
22788 program to grow due to unnecessary out-of-line copies of inline
22789 functions.
22791 @table @code
22792 @item #pragma interface
22793 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
22794 @kindex #pragma interface
22795 Use this directive in @emph{header files} that define object classes, to save
22796 space in most of the object files that use those classes.  Normally,
22797 local copies of certain information (backup copies of inline member
22798 functions, debugging information, and the internal tables that implement
22799 virtual functions) must be kept in each object file that includes class
22800 definitions.  You can use this pragma to avoid such duplication.  When a
22801 header file containing @samp{#pragma interface} is included in a
22802 compilation, this auxiliary information is not generated (unless
22803 the main input source file itself uses @samp{#pragma implementation}).
22804 Instead, the object files contain references to be resolved at link
22805 time.
22807 The second form of this directive is useful for the case where you have
22808 multiple headers with the same name in different directories.  If you
22809 use this form, you must specify the same string to @samp{#pragma
22810 implementation}.
22812 @item #pragma implementation
22813 @itemx #pragma implementation "@var{objects}.h"
22814 @kindex #pragma implementation
22815 Use this pragma in a @emph{main input file}, when you want full output from
22816 included header files to be generated (and made globally visible).  The
22817 included header file, in turn, should use @samp{#pragma interface}.
22818 Backup copies of inline member functions, debugging information, and the
22819 internal tables used to implement virtual functions are all generated in
22820 implementation files.
22822 @cindex implied @code{#pragma implementation}
22823 @cindex @code{#pragma implementation}, implied
22824 @cindex naming convention, implementation headers
22825 If you use @samp{#pragma implementation} with no argument, it applies to
22826 an include file with the same basename@footnote{A file's @dfn{basename}
22827 is the name stripped of all leading path information and of trailing
22828 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
22829 file.  For example, in @file{allclass.cc}, giving just
22830 @samp{#pragma implementation}
22831 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
22833 Use the string argument if you want a single implementation file to
22834 include code from multiple header files.  (You must also use
22835 @samp{#include} to include the header file; @samp{#pragma
22836 implementation} only specifies how to use the file---it doesn't actually
22837 include it.)
22839 There is no way to split up the contents of a single header file into
22840 multiple implementation files.
22841 @end table
22843 @cindex inlining and C++ pragmas
22844 @cindex C++ pragmas, effect on inlining
22845 @cindex pragmas in C++, effect on inlining
22846 @samp{#pragma implementation} and @samp{#pragma interface} also have an
22847 effect on function inlining.
22849 If you define a class in a header file marked with @samp{#pragma
22850 interface}, the effect on an inline function defined in that class is
22851 similar to an explicit @code{extern} declaration---the compiler emits
22852 no code at all to define an independent version of the function.  Its
22853 definition is used only for inlining with its callers.
22855 @opindex fno-implement-inlines
22856 Conversely, when you include the same header file in a main source file
22857 that declares it as @samp{#pragma implementation}, the compiler emits
22858 code for the function itself; this defines a version of the function
22859 that can be found via pointers (or by callers compiled without
22860 inlining).  If all calls to the function can be inlined, you can avoid
22861 emitting the function by compiling with @option{-fno-implement-inlines}.
22862 If any calls are not inlined, you will get linker errors.
22864 @node Template Instantiation
22865 @section Where's the Template?
22866 @cindex template instantiation
22868 C++ templates were the first language feature to require more
22869 intelligence from the environment than was traditionally found on a UNIX
22870 system.  Somehow the compiler and linker have to make sure that each
22871 template instance occurs exactly once in the executable if it is needed,
22872 and not at all otherwise.  There are two basic approaches to this
22873 problem, which are referred to as the Borland model and the Cfront model.
22875 @table @asis
22876 @item Borland model
22877 Borland C++ solved the template instantiation problem by adding the code
22878 equivalent of common blocks to their linker; the compiler emits template
22879 instances in each translation unit that uses them, and the linker
22880 collapses them together.  The advantage of this model is that the linker
22881 only has to consider the object files themselves; there is no external
22882 complexity to worry about.  The disadvantage is that compilation time
22883 is increased because the template code is being compiled repeatedly.
22884 Code written for this model tends to include definitions of all
22885 templates in the header file, since they must be seen to be
22886 instantiated.
22888 @item Cfront model
22889 The AT&T C++ translator, Cfront, solved the template instantiation
22890 problem by creating the notion of a template repository, an
22891 automatically maintained place where template instances are stored.  A
22892 more modern version of the repository works as follows: As individual
22893 object files are built, the compiler places any template definitions and
22894 instantiations encountered in the repository.  At link time, the link
22895 wrapper adds in the objects in the repository and compiles any needed
22896 instances that were not previously emitted.  The advantages of this
22897 model are more optimal compilation speed and the ability to use the
22898 system linker; to implement the Borland model a compiler vendor also
22899 needs to replace the linker.  The disadvantages are vastly increased
22900 complexity, and thus potential for error; for some code this can be
22901 just as transparent, but in practice it can been very difficult to build
22902 multiple programs in one directory and one program in multiple
22903 directories.  Code written for this model tends to separate definitions
22904 of non-inline member templates into a separate file, which should be
22905 compiled separately.
22906 @end table
22908 G++ implements the Borland model on targets where the linker supports it,
22909 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
22910 Otherwise G++ implements neither automatic model.
22912 You have the following options for dealing with template instantiations:
22914 @enumerate
22915 @item
22916 Do nothing.  Code written for the Borland model works fine, but
22917 each translation unit contains instances of each of the templates it
22918 uses.  The duplicate instances will be discarded by the linker, but in
22919 a large program, this can lead to an unacceptable amount of code
22920 duplication in object files or shared libraries.
22922 Duplicate instances of a template can be avoided by defining an explicit
22923 instantiation in one object file, and preventing the compiler from doing
22924 implicit instantiations in any other object files by using an explicit
22925 instantiation declaration, using the @code{extern template} syntax:
22927 @smallexample
22928 extern template int max (int, int);
22929 @end smallexample
22931 This syntax is defined in the C++ 2011 standard, but has been supported by
22932 G++ and other compilers since well before 2011.
22934 Explicit instantiations can be used for the largest or most frequently
22935 duplicated instances, without having to know exactly which other instances
22936 are used in the rest of the program.  You can scatter the explicit
22937 instantiations throughout your program, perhaps putting them in the
22938 translation units where the instances are used or the translation units
22939 that define the templates themselves; you can put all of the explicit
22940 instantiations you need into one big file; or you can create small files
22941 like
22943 @smallexample
22944 #include "Foo.h"
22945 #include "Foo.cc"
22947 template class Foo<int>;
22948 template ostream& operator <<
22949                 (ostream&, const Foo<int>&);
22950 @end smallexample
22952 @noindent
22953 for each of the instances you need, and create a template instantiation
22954 library from those.
22956 This is the simplest option, but also offers flexibility and
22957 fine-grained control when necessary. It is also the most portable
22958 alternative and programs using this approach will work with most modern
22959 compilers.
22961 @item
22962 @opindex frepo
22963 Compile your template-using code with @option{-frepo}.  The compiler
22964 generates files with the extension @samp{.rpo} listing all of the
22965 template instantiations used in the corresponding object files that
22966 could be instantiated there; the link wrapper, @samp{collect2},
22967 then updates the @samp{.rpo} files to tell the compiler where to place
22968 those instantiations and rebuild any affected object files.  The
22969 link-time overhead is negligible after the first pass, as the compiler
22970 continues to place the instantiations in the same files.
22972 This can be a suitable option for application code written for the Borland
22973 model, as it usually just works.  Code written for the Cfront model 
22974 needs to be modified so that the template definitions are available at
22975 one or more points of instantiation; usually this is as simple as adding
22976 @code{#include <tmethods.cc>} to the end of each template header.
22978 For library code, if you want the library to provide all of the template
22979 instantiations it needs, just try to link all of its object files
22980 together; the link will fail, but cause the instantiations to be
22981 generated as a side effect.  Be warned, however, that this may cause
22982 conflicts if multiple libraries try to provide the same instantiations.
22983 For greater control, use explicit instantiation as described in the next
22984 option.
22986 @item
22987 @opindex fno-implicit-templates
22988 Compile your code with @option{-fno-implicit-templates} to disable the
22989 implicit generation of template instances, and explicitly instantiate
22990 all the ones you use.  This approach requires more knowledge of exactly
22991 which instances you need than do the others, but it's less
22992 mysterious and allows greater control if you want to ensure that only
22993 the intended instances are used.
22995 If you are using Cfront-model code, you can probably get away with not
22996 using @option{-fno-implicit-templates} when compiling files that don't
22997 @samp{#include} the member template definitions.
22999 If you use one big file to do the instantiations, you may want to
23000 compile it without @option{-fno-implicit-templates} so you get all of the
23001 instances required by your explicit instantiations (but not by any
23002 other files) without having to specify them as well.
23004 In addition to forward declaration of explicit instantiations
23005 (with @code{extern}), G++ has extended the template instantiation
23006 syntax to support instantiation of the compiler support data for a
23007 template class (i.e.@: the vtable) without instantiating any of its
23008 members (with @code{inline}), and instantiation of only the static data
23009 members of a template class, without the support data or member
23010 functions (with @code{static}):
23012 @smallexample
23013 inline template class Foo<int>;
23014 static template class Foo<int>;
23015 @end smallexample
23016 @end enumerate
23018 @node Bound member functions
23019 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23020 @cindex pmf
23021 @cindex pointer to member function
23022 @cindex bound pointer to member function
23024 In C++, pointer to member functions (PMFs) are implemented using a wide
23025 pointer of sorts to handle all the possible call mechanisms; the PMF
23026 needs to store information about how to adjust the @samp{this} pointer,
23027 and if the function pointed to is virtual, where to find the vtable, and
23028 where in the vtable to look for the member function.  If you are using
23029 PMFs in an inner loop, you should really reconsider that decision.  If
23030 that is not an option, you can extract the pointer to the function that
23031 would be called for a given object/PMF pair and call it directly inside
23032 the inner loop, to save a bit of time.
23034 Note that you still pay the penalty for the call through a
23035 function pointer; on most modern architectures, such a call defeats the
23036 branch prediction features of the CPU@.  This is also true of normal
23037 virtual function calls.
23039 The syntax for this extension is
23041 @smallexample
23042 extern A a;
23043 extern int (A::*fp)();
23044 typedef int (*fptr)(A *);
23046 fptr p = (fptr)(a.*fp);
23047 @end smallexample
23049 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23050 no object is needed to obtain the address of the function.  They can be
23051 converted to function pointers directly:
23053 @smallexample
23054 fptr p1 = (fptr)(&A::foo);
23055 @end smallexample
23057 @opindex Wno-pmf-conversions
23058 You must specify @option{-Wno-pmf-conversions} to use this extension.
23060 @node C++ Attributes
23061 @section C++-Specific Variable, Function, and Type Attributes
23063 Some attributes only make sense for C++ programs.
23065 @table @code
23066 @item abi_tag ("@var{tag}", ...)
23067 @cindex @code{abi_tag} function attribute
23068 @cindex @code{abi_tag} variable attribute
23069 @cindex @code{abi_tag} type attribute
23070 The @code{abi_tag} attribute can be applied to a function, variable, or class
23071 declaration.  It modifies the mangled name of the entity to
23072 incorporate the tag name, in order to distinguish the function or
23073 class from an earlier version with a different ABI; perhaps the class
23074 has changed size, or the function has a different return type that is
23075 not encoded in the mangled name.
23077 The attribute can also be applied to an inline namespace, but does not
23078 affect the mangled name of the namespace; in this case it is only used
23079 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23080 variables.  Tagging inline namespaces is generally preferable to
23081 tagging individual declarations, but the latter is sometimes
23082 necessary, such as when only certain members of a class need to be
23083 tagged.
23085 The argument can be a list of strings of arbitrary length.  The
23086 strings are sorted on output, so the order of the list is
23087 unimportant.
23089 A redeclaration of an entity must not add new ABI tags,
23090 since doing so would change the mangled name.
23092 The ABI tags apply to a name, so all instantiations and
23093 specializations of a template have the same tags.  The attribute will
23094 be ignored if applied to an explicit specialization or instantiation.
23096 The @option{-Wabi-tag} flag enables a warning about a class which does
23097 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23098 that needs to coexist with an earlier ABI, using this option can help
23099 to find all affected types that need to be tagged.
23101 When a type involving an ABI tag is used as the type of a variable or
23102 return type of a function where that tag is not already present in the
23103 signature of the function, the tag is automatically applied to the
23104 variable or function.  @option{-Wabi-tag} also warns about this
23105 situation; this warning can be avoided by explicitly tagging the
23106 variable or function or moving it into a tagged inline namespace.
23108 @item init_priority (@var{priority})
23109 @cindex @code{init_priority} variable attribute
23111 In Standard C++, objects defined at namespace scope are guaranteed to be
23112 initialized in an order in strict accordance with that of their definitions
23113 @emph{in a given translation unit}.  No guarantee is made for initializations
23114 across translation units.  However, GNU C++ allows users to control the
23115 order of initialization of objects defined at namespace scope with the
23116 @code{init_priority} attribute by specifying a relative @var{priority},
23117 a constant integral expression currently bounded between 101 and 65535
23118 inclusive.  Lower numbers indicate a higher priority.
23120 In the following example, @code{A} would normally be created before
23121 @code{B}, but the @code{init_priority} attribute reverses that order:
23123 @smallexample
23124 Some_Class  A  __attribute__ ((init_priority (2000)));
23125 Some_Class  B  __attribute__ ((init_priority (543)));
23126 @end smallexample
23128 @noindent
23129 Note that the particular values of @var{priority} do not matter; only their
23130 relative ordering.
23132 @item warn_unused
23133 @cindex @code{warn_unused} type attribute
23135 For C++ types with non-trivial constructors and/or destructors it is
23136 impossible for the compiler to determine whether a variable of this
23137 type is truly unused if it is not referenced. This type attribute
23138 informs the compiler that variables of this type should be warned
23139 about if they appear to be unused, just like variables of fundamental
23140 types.
23142 This attribute is appropriate for types which just represent a value,
23143 such as @code{std::string}; it is not appropriate for types which
23144 control a resource, such as @code{std::lock_guard}.
23146 This attribute is also accepted in C, but it is unnecessary because C
23147 does not have constructors or destructors.
23149 @end table
23151 @node Function Multiversioning
23152 @section Function Multiversioning
23153 @cindex function versions
23155 With the GNU C++ front end, for x86 targets, you may specify multiple
23156 versions of a function, where each function is specialized for a
23157 specific target feature.  At runtime, the appropriate version of the
23158 function is automatically executed depending on the characteristics of
23159 the execution platform.  Here is an example.
23161 @smallexample
23162 __attribute__ ((target ("default")))
23163 int foo ()
23165   // The default version of foo.
23166   return 0;
23169 __attribute__ ((target ("sse4.2")))
23170 int foo ()
23172   // foo version for SSE4.2
23173   return 1;
23176 __attribute__ ((target ("arch=atom")))
23177 int foo ()
23179   // foo version for the Intel ATOM processor
23180   return 2;
23183 __attribute__ ((target ("arch=amdfam10")))
23184 int foo ()
23186   // foo version for the AMD Family 0x10 processors.
23187   return 3;
23190 int main ()
23192   int (*p)() = &foo;
23193   assert ((*p) () == foo ());
23194   return 0;
23196 @end smallexample
23198 In the above example, four versions of function foo are created. The
23199 first version of foo with the target attribute "default" is the default
23200 version.  This version gets executed when no other target specific
23201 version qualifies for execution on a particular platform. A new version
23202 of foo is created by using the same function signature but with a
23203 different target string.  Function foo is called or a pointer to it is
23204 taken just like a regular function.  GCC takes care of doing the
23205 dispatching to call the right version at runtime.  Refer to the
23206 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23207 Function Multiversioning} for more details.
23209 @node Type Traits
23210 @section Type Traits
23212 The C++ front end implements syntactic extensions that allow
23213 compile-time determination of 
23214 various characteristics of a type (or of a
23215 pair of types).
23217 @table @code
23218 @item __has_nothrow_assign (type)
23219 If @code{type} is const qualified or is a reference type then the trait is
23220 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23221 is true, else if @code{type} is a cv class or union type with copy assignment
23222 operators that are known not to throw an exception then the trait is true,
23223 else it is false.  Requires: @code{type} shall be a complete type,
23224 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23226 @item __has_nothrow_copy (type)
23227 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23228 @code{type} is a cv class or union type with copy constructors that
23229 are known not to throw an exception then the trait is true, else it is false.
23230 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23231 @code{void}, or an array of unknown bound.
23233 @item __has_nothrow_constructor (type)
23234 If @code{__has_trivial_constructor (type)} is true then the trait is
23235 true, else if @code{type} is a cv class or union type (or array
23236 thereof) with a default constructor that is known not to throw an
23237 exception then the trait is true, else it is false.  Requires:
23238 @code{type} shall be a complete type, (possibly cv-qualified)
23239 @code{void}, or an array of unknown bound.
23241 @item __has_trivial_assign (type)
23242 If @code{type} is const qualified or is a reference type then the trait is
23243 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
23244 true, else if @code{type} is a cv class or union type with a trivial
23245 copy assignment ([class.copy]) then the trait is true, else it is
23246 false.  Requires: @code{type} shall be a complete type, (possibly
23247 cv-qualified) @code{void}, or an array of unknown bound.
23249 @item __has_trivial_copy (type)
23250 If @code{__is_pod (type)} is true or @code{type} is a reference type
23251 then the trait is true, else if @code{type} is a cv class or union type
23252 with a trivial copy constructor ([class.copy]) then the trait
23253 is true, else it is false.  Requires: @code{type} shall be a complete
23254 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23256 @item __has_trivial_constructor (type)
23257 If @code{__is_pod (type)} is true then the trait is true, else if
23258 @code{type} is a cv class or union type (or array thereof) with a
23259 trivial default constructor ([class.ctor]) then the trait is true,
23260 else it is false.  Requires: @code{type} shall be a complete
23261 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23263 @item __has_trivial_destructor (type)
23264 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23265 the trait is true, else if @code{type} is a cv class or union type (or
23266 array thereof) with a trivial destructor ([class.dtor]) then the trait
23267 is true, else it is false.  Requires: @code{type} shall be a complete
23268 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23270 @item __has_virtual_destructor (type)
23271 If @code{type} is a class type with a virtual destructor
23272 ([class.dtor]) then the trait is true, else it is false.  Requires:
23273 @code{type} shall be a complete type, (possibly cv-qualified)
23274 @code{void}, or an array of unknown bound.
23276 @item __is_abstract (type)
23277 If @code{type} is an abstract class ([class.abstract]) then the trait
23278 is true, else it is false.  Requires: @code{type} shall be a complete
23279 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23281 @item __is_base_of (base_type, derived_type)
23282 If @code{base_type} is a base class of @code{derived_type}
23283 ([class.derived]) then the trait is true, otherwise it is false.
23284 Top-level cv qualifications of @code{base_type} and
23285 @code{derived_type} are ignored.  For the purposes of this trait, a
23286 class type is considered is own base.  Requires: if @code{__is_class
23287 (base_type)} and @code{__is_class (derived_type)} are true and
23288 @code{base_type} and @code{derived_type} are not the same type
23289 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23290 type.  A diagnostic is produced if this requirement is not met.
23292 @item __is_class (type)
23293 If @code{type} is a cv class type, and not a union type
23294 ([basic.compound]) the trait is true, else it is false.
23296 @item __is_empty (type)
23297 If @code{__is_class (type)} is false then the trait is false.
23298 Otherwise @code{type} is considered empty if and only if: @code{type}
23299 has no non-static data members, or all non-static data members, if
23300 any, are bit-fields of length 0, and @code{type} has no virtual
23301 members, and @code{type} has no virtual base classes, and @code{type}
23302 has no base classes @code{base_type} for which
23303 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
23304 be a complete type, (possibly cv-qualified) @code{void}, or an array
23305 of unknown bound.
23307 @item __is_enum (type)
23308 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23309 true, else it is false.
23311 @item __is_literal_type (type)
23312 If @code{type} is a literal type ([basic.types]) the trait is
23313 true, else it is false.  Requires: @code{type} shall be a complete type,
23314 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23316 @item __is_pod (type)
23317 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23318 else it is false.  Requires: @code{type} shall be a complete type,
23319 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23321 @item __is_polymorphic (type)
23322 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23323 is true, else it is false.  Requires: @code{type} shall be a complete
23324 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23326 @item __is_standard_layout (type)
23327 If @code{type} is a standard-layout type ([basic.types]) the trait is
23328 true, else it is false.  Requires: @code{type} shall be a complete
23329 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23331 @item __is_trivial (type)
23332 If @code{type} is a trivial type ([basic.types]) the trait is
23333 true, else it is false.  Requires: @code{type} shall be a complete
23334 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23336 @item __is_union (type)
23337 If @code{type} is a cv union type ([basic.compound]) the trait is
23338 true, else it is false.
23340 @item __underlying_type (type)
23341 The underlying type of @code{type}.  Requires: @code{type} shall be
23342 an enumeration type ([dcl.enum]).
23344 @item __integer_pack (length)
23345 When used as the pattern of a pack expansion within a template
23346 definition, expands to a template argument pack containing integers
23347 from @code{0} to @code{length-1}.  This is provided for efficient
23348 implementation of @code{std::make_integer_sequence}.
23350 @end table
23353 @node C++ Concepts
23354 @section C++ Concepts
23356 C++ concepts provide much-improved support for generic programming. In
23357 particular, they allow the specification of constraints on template arguments.
23358 The constraints are used to extend the usual overloading and partial
23359 specialization capabilities of the language, allowing generic data structures
23360 and algorithms to be ``refined'' based on their properties rather than their
23361 type names.
23363 The following keywords are reserved for concepts.
23365 @table @code
23366 @item assumes
23367 States an expression as an assumption, and if possible, verifies that the
23368 assumption is valid. For example, @code{assume(n > 0)}.
23370 @item axiom
23371 Introduces an axiom definition. Axioms introduce requirements on values.
23373 @item forall
23374 Introduces a universally quantified object in an axiom. For example,
23375 @code{forall (int n) n + 0 == n}).
23377 @item concept
23378 Introduces a concept definition. Concepts are sets of syntactic and semantic
23379 requirements on types and their values.
23381 @item requires
23382 Introduces constraints on template arguments or requirements for a member
23383 function of a class template.
23385 @end table
23387 The front end also exposes a number of internal mechanism that can be used
23388 to simplify the writing of type traits. Note that some of these traits are
23389 likely to be removed in the future.
23391 @table @code
23392 @item __is_same (type1, type2)
23393 A binary type trait: true whenever the type arguments are the same.
23395 @end table
23398 @node Deprecated Features
23399 @section Deprecated Features
23401 In the past, the GNU C++ compiler was extended to experiment with new
23402 features, at a time when the C++ language was still evolving.  Now that
23403 the C++ standard is complete, some of those features are superseded by
23404 superior alternatives.  Using the old features might cause a warning in
23405 some cases that the feature will be dropped in the future.  In other
23406 cases, the feature might be gone already.
23408 G++ allows a virtual function returning @samp{void *} to be overridden
23409 by one returning a different pointer type.  This extension to the
23410 covariant return type rules is now deprecated and will be removed from a
23411 future version.
23413 The use of default arguments in function pointers, function typedefs
23414 and other places where they are not permitted by the standard is
23415 deprecated and will be removed from a future version of G++.
23417 G++ allows floating-point literals to appear in integral constant expressions,
23418 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23419 This extension is deprecated and will be removed from a future version.
23421 G++ allows static data members of const floating-point type to be declared
23422 with an initializer in a class definition. The standard only allows
23423 initializers for static members of const integral types and const
23424 enumeration types so this extension has been deprecated and will be removed
23425 from a future version.
23427 G++ allows attributes to follow a parenthesized direct initializer,
23428 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
23429 has been ignored since G++ 3.3 and is deprecated.
23431 G++ allows anonymous structs and unions to have members that are not
23432 public non-static data members (i.e.@: fields).  These extensions are
23433 deprecated.
23435 @node Backwards Compatibility
23436 @section Backwards Compatibility
23437 @cindex Backwards Compatibility
23438 @cindex ARM [Annotated C++ Reference Manual]
23440 Now that there is a definitive ISO standard C++, G++ has a specification
23441 to adhere to.  The C++ language evolved over time, and features that
23442 used to be acceptable in previous drafts of the standard, such as the ARM
23443 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
23444 compilation of C++ written to such drafts, G++ contains some backwards
23445 compatibilities.  @emph{All such backwards compatibility features are
23446 liable to disappear in future versions of G++.} They should be considered
23447 deprecated.   @xref{Deprecated Features}.
23449 @table @code
23451 @item Implicit C language
23452 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23453 scope to set the language.  On such systems, all header files are
23454 implicitly scoped inside a C language scope.  Also, an empty prototype
23455 @code{()} is treated as an unspecified number of arguments, rather
23456 than no arguments, as C++ demands.
23458 @end table
23460 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
23461 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr