* asan.c (handle_builtin_alloca): Deal with all alloca variants.
[official-gcc.git] / gcc / doc / extend.texi
blob768751f58a1ec7a98ec2af86fdc1f3e00b67ea2f
1 c Copyright (C) 1988-2017 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax::    Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments::        C++ comments are recognized.
67 * Dollar Signs::        Dollar sign is allowed in identifiers.
68 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
69 * Alignment::           Inquiring about the alignment of a type or variable.
70 * Inline::              Defining inline functions (as fast as macros).
71 * Volatiles::           What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83                         arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86                         checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
89 * Other Builtins::      Other built-in functions.
90 * Target Builtins::     Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas::             Pragmas accepted by GCC.
93 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
94 * Thread-Local::        Per-thread variables.
95 * Binary constants::    Binary constants using the @samp{0b} prefix.
96 @end menu
98 @node Statement Exprs
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@.  This allows you to use loops, switches, and local variables
109 within an expression.
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces.  For
113 example:
115 @smallexample
116 (@{ int y = foo (); int z;
117    if (y > 0) z = y;
118    else z = - y;
119    z; @})
120 @end smallexample
122 @noindent
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct.  (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once).  For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
135 follows:
137 @smallexample
138 #define max(a,b) ((a) > (b) ? (a) : (b))
139 @end smallexample
141 @noindent
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects.  In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
148 @smallexample
149 #define maxint(a,b) \
150   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 @end smallexample
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression.  For instance, if @code{A} is a class, then
164 @smallexample
165         A a;
167         (@{a;@}).Foo ()
168 @end smallexample
170 @noindent
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 address of @code{a}.
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end.  This makes statement
178 expressions inside macros slightly different from function calls.  In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call.  In the statement expression case they are destroyed during
182 the statement expression.  For instance,
184 @smallexample
185 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
188 void foo ()
190   macro (X ());
191   function (X ());
193 @end smallexample
195 @noindent
196 has different places where temporaries are destroyed.  For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}.  In the @code{function} case that
199 temporary is destroyed when the function returns.
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++.  (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
205 bug.)
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted.  Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression.  In any case, as with a function call, the evaluation of a
218 statement expression is not interleaved with the evaluation of other
219 parts of the containing expression.  For example,
221 @smallexample
222   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
223 @end smallexample
225 @noindent
226 calls @code{foo} and @code{bar1} and does not call @code{baz} but
227 may or may not call @code{bar2}.  If @code{bar2} is called, it is
228 called after @code{foo} and before @code{bar1}.
230 @node Local Labels
231 @section Locally Declared Labels
232 @cindex local labels
233 @cindex macros, local labels
235 GCC allows you to declare @dfn{local labels} in any nested block
236 scope.  A local label is just like an ordinary label, but you can
237 only reference it (with a @code{goto} statement, or by taking its
238 address) within the block in which it is declared.
240 A local label declaration looks like this:
242 @smallexample
243 __label__ @var{label};
244 @end smallexample
246 @noindent
249 @smallexample
250 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 @end smallexample
253 Local label declarations must come at the beginning of the block,
254 before any ordinary declarations or statements.
256 The label declaration defines the label @emph{name}, but does not define
257 the label itself.  You must do this in the usual way, with
258 @code{@var{label}:}, within the statements of the statement expression.
260 The local label feature is useful for complex macros.  If a macro
261 contains nested loops, a @code{goto} can be useful for breaking out of
262 them.  However, an ordinary label whose scope is the whole function
263 cannot be used: if the macro can be expanded several times in one
264 function, the label is multiply defined in that function.  A
265 local label avoids this problem.  For example:
267 @smallexample
268 #define SEARCH(value, array, target)              \
269 do @{                                              \
270   __label__ found;                                \
271   typeof (target) _SEARCH_target = (target);      \
272   typeof (*(array)) *_SEARCH_array = (array);     \
273   int i, j;                                       \
274   int value;                                      \
275   for (i = 0; i < max; i++)                       \
276     for (j = 0; j < max; j++)                     \
277       if (_SEARCH_array[i][j] == _SEARCH_target)  \
278         @{ (value) = i; goto found; @}              \
279   (value) = -1;                                   \
280  found:;                                          \
281 @} while (0)
282 @end smallexample
284 This could also be written using a statement expression:
286 @smallexample
287 #define SEARCH(array, target)                     \
288 (@{                                                \
289   __label__ found;                                \
290   typeof (target) _SEARCH_target = (target);      \
291   typeof (*(array)) *_SEARCH_array = (array);     \
292   int i, j;                                       \
293   int value;                                      \
294   for (i = 0; i < max; i++)                       \
295     for (j = 0; j < max; j++)                     \
296       if (_SEARCH_array[i][j] == _SEARCH_target)  \
297         @{ value = i; goto found; @}                \
298   value = -1;                                     \
299  found:                                           \
300   value;                                          \
302 @end smallexample
304 Local label declarations also make the labels they declare visible to
305 nested functions, if there are any.  @xref{Nested Functions}, for details.
307 @node Labels as Values
308 @section Labels as Values
309 @cindex labels as values
310 @cindex computed gotos
311 @cindex goto with computed label
312 @cindex address of a label
314 You can get the address of a label defined in the current function
315 (or a containing function) with the unary operator @samp{&&}.  The
316 value has type @code{void *}.  This value is a constant and can be used
317 wherever a constant of that type is valid.  For example:
319 @smallexample
320 void *ptr;
321 /* @r{@dots{}} */
322 ptr = &&foo;
323 @end smallexample
325 To use these values, you need to be able to jump to one.  This is done
326 with the computed goto statement@footnote{The analogous feature in
327 Fortran is called an assigned goto, but that name seems inappropriate in
328 C, where one can do more than simply store label addresses in label
329 variables.}, @code{goto *@var{exp};}.  For example,
331 @smallexample
332 goto *ptr;
333 @end smallexample
335 @noindent
336 Any expression of type @code{void *} is allowed.
338 One way of using these constants is in initializing a static array that
339 serves as a jump table:
341 @smallexample
342 static void *array[] = @{ &&foo, &&bar, &&hack @};
343 @end smallexample
345 @noindent
346 Then you can select a label with indexing, like this:
348 @smallexample
349 goto *array[i];
350 @end smallexample
352 @noindent
353 Note that this does not check whether the subscript is in bounds---array
354 indexing in C never does that.
356 Such an array of label values serves a purpose much like that of the
357 @code{switch} statement.  The @code{switch} statement is cleaner, so
358 use that rather than an array unless the problem does not fit a
359 @code{switch} statement very well.
361 Another use of label values is in an interpreter for threaded code.
362 The labels within the interpreter function can be stored in the
363 threaded code for super-fast dispatching.
365 You may not use this mechanism to jump to code in a different function.
366 If you do that, totally unpredictable things happen.  The best way to
367 avoid this is to store the label address only in automatic variables and
368 never pass it as an argument.
370 An alternate way to write the above example is
372 @smallexample
373 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374                              &&hack - &&foo @};
375 goto *(&&foo + array[i]);
376 @end smallexample
378 @noindent
379 This is more friendly to code living in shared libraries, as it reduces
380 the number of dynamic relocations that are needed, and by consequence,
381 allows the data to be read-only.
382 This alternative with label differences is not supported for the AVR target,
383 please use the first approach for AVR programs.
385 The @code{&&foo} expressions for the same label might have different
386 values if the containing function is inlined or cloned.  If a program
387 relies on them being always the same,
388 @code{__attribute__((__noinline__,__noclone__))} should be used to
389 prevent inlining and cloning.  If @code{&&foo} is used in a static
390 variable initializer, inlining and cloning is forbidden.
392 @node Nested Functions
393 @section Nested Functions
394 @cindex nested functions
395 @cindex downward funargs
396 @cindex thunks
398 A @dfn{nested function} is a function defined inside another function.
399 Nested functions are supported as an extension in GNU C, but are not
400 supported by GNU C++.
402 The nested function's name is local to the block where it is defined.
403 For example, here we define a nested function named @code{square}, and
404 call it twice:
406 @smallexample
407 @group
408 foo (double a, double b)
410   double square (double z) @{ return z * z; @}
412   return square (a) + square (b);
414 @end group
415 @end smallexample
417 The nested function can access all the variables of the containing
418 function that are visible at the point of its definition.  This is
419 called @dfn{lexical scoping}.  For example, here we show a nested
420 function which uses an inherited variable named @code{offset}:
422 @smallexample
423 @group
424 bar (int *array, int offset, int size)
426   int access (int *array, int index)
427     @{ return array[index + offset]; @}
428   int i;
429   /* @r{@dots{}} */
430   for (i = 0; i < size; i++)
431     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
433 @end group
434 @end smallexample
436 Nested function definitions are permitted within functions in the places
437 where variable definitions are allowed; that is, in any block, mixed
438 with the other declarations and statements in the block.
440 It is possible to call the nested function from outside the scope of its
441 name by storing its address or passing the address to another function:
443 @smallexample
444 hack (int *array, int size)
446   void store (int index, int value)
447     @{ array[index] = value; @}
449   intermediate (store, size);
451 @end smallexample
453 Here, the function @code{intermediate} receives the address of
454 @code{store} as an argument.  If @code{intermediate} calls @code{store},
455 the arguments given to @code{store} are used to store into @code{array}.
456 But this technique works only so long as the containing function
457 (@code{hack}, in this example) does not exit.
459 If you try to call the nested function through its address after the
460 containing function exits, all hell breaks loose.  If you try
461 to call it after a containing scope level exits, and if it refers
462 to some of the variables that are no longer in scope, you may be lucky,
463 but it's not wise to take the risk.  If, however, the nested function
464 does not refer to anything that has gone out of scope, you should be
465 safe.
467 GCC implements taking the address of a nested function using a technique
468 called @dfn{trampolines}.  This technique was described in
469 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
470 C++ Conference Proceedings, October 17-21, 1988).
472 A nested function can jump to a label inherited from a containing
473 function, provided the label is explicitly declared in the containing
474 function (@pxref{Local Labels}).  Such a jump returns instantly to the
475 containing function, exiting the nested function that did the
476 @code{goto} and any intermediate functions as well.  Here is an example:
478 @smallexample
479 @group
480 bar (int *array, int offset, int size)
482   __label__ failure;
483   int access (int *array, int index)
484     @{
485       if (index > size)
486         goto failure;
487       return array[index + offset];
488     @}
489   int i;
490   /* @r{@dots{}} */
491   for (i = 0; i < size; i++)
492     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
493   /* @r{@dots{}} */
494   return 0;
496  /* @r{Control comes here from @code{access}
497     if it detects an error.}  */
498  failure:
499   return -1;
501 @end group
502 @end smallexample
504 A nested function always has no linkage.  Declaring one with
505 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
506 before its definition, use @code{auto} (which is otherwise meaningless
507 for function declarations).
509 @smallexample
510 bar (int *array, int offset, int size)
512   __label__ failure;
513   auto int access (int *, int);
514   /* @r{@dots{}} */
515   int access (int *array, int index)
516     @{
517       if (index > size)
518         goto failure;
519       return array[index + offset];
520     @}
521   /* @r{@dots{}} */
523 @end smallexample
525 @node Constructing Calls
526 @section Constructing Function Calls
527 @cindex constructing calls
528 @cindex forwarding calls
530 Using the built-in functions described below, you can record
531 the arguments a function received, and call another function
532 with the same arguments, without knowing the number or types
533 of the arguments.
535 You can also record the return value of that function call,
536 and later return that value, without knowing what data type
537 the function tried to return (as long as your caller expects
538 that data type).
540 However, these built-in functions may interact badly with some
541 sophisticated features or other extensions of the language.  It
542 is, therefore, not recommended to use them outside very simple
543 functions acting as mere forwarders for their arguments.
545 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
546 This built-in function returns a pointer to data
547 describing how to perform a call with the same arguments as are passed
548 to the current function.
550 The function saves the arg pointer register, structure value address,
551 and all registers that might be used to pass arguments to a function
552 into a block of memory allocated on the stack.  Then it returns the
553 address of that block.
554 @end deftypefn
556 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
557 This built-in function invokes @var{function}
558 with a copy of the parameters described by @var{arguments}
559 and @var{size}.
561 The value of @var{arguments} should be the value returned by
562 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
563 of the stack argument data, in bytes.
565 This function returns a pointer to data describing
566 how to return whatever value is returned by @var{function}.  The data
567 is saved in a block of memory allocated on the stack.
569 It is not always simple to compute the proper value for @var{size}.  The
570 value is used by @code{__builtin_apply} to compute the amount of data
571 that should be pushed on the stack and copied from the incoming argument
572 area.
573 @end deftypefn
575 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
576 This built-in function returns the value described by @var{result} from
577 the containing function.  You should specify, for @var{result}, a value
578 returned by @code{__builtin_apply}.
579 @end deftypefn
581 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
582 This built-in function represents all anonymous arguments of an inline
583 function.  It can be used only in inline functions that are always
584 inlined, never compiled as a separate function, such as those using
585 @code{__attribute__ ((__always_inline__))} or
586 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
587 It must be only passed as last argument to some other function
588 with variable arguments.  This is useful for writing small wrapper
589 inlines for variable argument functions, when using preprocessor
590 macros is undesirable.  For example:
591 @smallexample
592 extern int myprintf (FILE *f, const char *format, ...);
593 extern inline __attribute__ ((__gnu_inline__)) int
594 myprintf (FILE *f, const char *format, ...)
596   int r = fprintf (f, "myprintf: ");
597   if (r < 0)
598     return r;
599   int s = fprintf (f, format, __builtin_va_arg_pack ());
600   if (s < 0)
601     return s;
602   return r + s;
604 @end smallexample
605 @end deftypefn
607 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
608 This built-in function returns the number of anonymous arguments of
609 an inline function.  It can be used only in inline functions that
610 are always inlined, never compiled as a separate function, such
611 as those using @code{__attribute__ ((__always_inline__))} or
612 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
613 For example following does link- or run-time checking of open
614 arguments for optimized code:
615 @smallexample
616 #ifdef __OPTIMIZE__
617 extern inline __attribute__((__gnu_inline__)) int
618 myopen (const char *path, int oflag, ...)
620   if (__builtin_va_arg_pack_len () > 1)
621     warn_open_too_many_arguments ();
623   if (__builtin_constant_p (oflag))
624     @{
625       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
626         @{
627           warn_open_missing_mode ();
628           return __open_2 (path, oflag);
629         @}
630       return open (path, oflag, __builtin_va_arg_pack ());
631     @}
633   if (__builtin_va_arg_pack_len () < 1)
634     return __open_2 (path, oflag);
636   return open (path, oflag, __builtin_va_arg_pack ());
638 #endif
639 @end smallexample
640 @end deftypefn
642 @node Typeof
643 @section Referring to a Type with @code{typeof}
644 @findex typeof
645 @findex sizeof
646 @cindex macros, types of arguments
648 Another way to refer to the type of an expression is with @code{typeof}.
649 The syntax of using of this keyword looks like @code{sizeof}, but the
650 construct acts semantically like a type name defined with @code{typedef}.
652 There are two ways of writing the argument to @code{typeof}: with an
653 expression or with a type.  Here is an example with an expression:
655 @smallexample
656 typeof (x[0](1))
657 @end smallexample
659 @noindent
660 This assumes that @code{x} is an array of pointers to functions;
661 the type described is that of the values of the functions.
663 Here is an example with a typename as the argument:
665 @smallexample
666 typeof (int *)
667 @end smallexample
669 @noindent
670 Here the type described is that of pointers to @code{int}.
672 If you are writing a header file that must work when included in ISO C
673 programs, write @code{__typeof__} instead of @code{typeof}.
674 @xref{Alternate Keywords}.
676 A @code{typeof} construct can be used anywhere a typedef name can be
677 used.  For example, you can use it in a declaration, in a cast, or inside
678 of @code{sizeof} or @code{typeof}.
680 The operand of @code{typeof} is evaluated for its side effects if and
681 only if it is an expression of variably modified type or the name of
682 such a type.
684 @code{typeof} is often useful in conjunction with
685 statement expressions (@pxref{Statement Exprs}).
686 Here is how the two together can
687 be used to define a safe ``maximum'' macro which operates on any
688 arithmetic type and evaluates each of its arguments exactly once:
690 @smallexample
691 #define max(a,b) \
692   (@{ typeof (a) _a = (a); \
693       typeof (b) _b = (b); \
694     _a > _b ? _a : _b; @})
695 @end smallexample
697 @cindex underscores in variables in macros
698 @cindex @samp{_} in variables in macros
699 @cindex local variables in macros
700 @cindex variables, local, in macros
701 @cindex macros, local variables in
703 The reason for using names that start with underscores for the local
704 variables is to avoid conflicts with variable names that occur within the
705 expressions that are substituted for @code{a} and @code{b}.  Eventually we
706 hope to design a new form of declaration syntax that allows you to declare
707 variables whose scopes start only after their initializers; this will be a
708 more reliable way to prevent such conflicts.
710 @noindent
711 Some more examples of the use of @code{typeof}:
713 @itemize @bullet
714 @item
715 This declares @code{y} with the type of what @code{x} points to.
717 @smallexample
718 typeof (*x) y;
719 @end smallexample
721 @item
722 This declares @code{y} as an array of such values.
724 @smallexample
725 typeof (*x) y[4];
726 @end smallexample
728 @item
729 This declares @code{y} as an array of pointers to characters:
731 @smallexample
732 typeof (typeof (char *)[4]) y;
733 @end smallexample
735 @noindent
736 It is equivalent to the following traditional C declaration:
738 @smallexample
739 char *y[4];
740 @end smallexample
742 To see the meaning of the declaration using @code{typeof}, and why it
743 might be a useful way to write, rewrite it with these macros:
745 @smallexample
746 #define pointer(T)  typeof(T *)
747 #define array(T, N) typeof(T [N])
748 @end smallexample
750 @noindent
751 Now the declaration can be rewritten this way:
753 @smallexample
754 array (pointer (char), 4) y;
755 @end smallexample
757 @noindent
758 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
759 pointers to @code{char}.
760 @end itemize
762 In GNU C, but not GNU C++, you may also declare the type of a variable
763 as @code{__auto_type}.  In that case, the declaration must declare
764 only one variable, whose declarator must just be an identifier, the
765 declaration must be initialized, and the type of the variable is
766 determined by the initializer; the name of the variable is not in
767 scope until after the initializer.  (In C++, you should use C++11
768 @code{auto} for this purpose.)  Using @code{__auto_type}, the
769 ``maximum'' macro above could be written as:
771 @smallexample
772 #define max(a,b) \
773   (@{ __auto_type _a = (a); \
774       __auto_type _b = (b); \
775     _a > _b ? _a : _b; @})
776 @end smallexample
778 Using @code{__auto_type} instead of @code{typeof} has two advantages:
780 @itemize @bullet
781 @item Each argument to the macro appears only once in the expansion of
782 the macro.  This prevents the size of the macro expansion growing
783 exponentially when calls to such macros are nested inside arguments of
784 such macros.
786 @item If the argument to the macro has variably modified type, it is
787 evaluated only once when using @code{__auto_type}, but twice if
788 @code{typeof} is used.
789 @end itemize
791 @node Conditionals
792 @section Conditionals with Omitted Operands
793 @cindex conditional expressions, extensions
794 @cindex omitted middle-operands
795 @cindex middle-operands, omitted
796 @cindex extensions, @code{?:}
797 @cindex @code{?:} extensions
799 The middle operand in a conditional expression may be omitted.  Then
800 if the first operand is nonzero, its value is the value of the conditional
801 expression.
803 Therefore, the expression
805 @smallexample
806 x ? : y
807 @end smallexample
809 @noindent
810 has the value of @code{x} if that is nonzero; otherwise, the value of
811 @code{y}.
813 This example is perfectly equivalent to
815 @smallexample
816 x ? x : y
817 @end smallexample
819 @cindex side effect in @code{?:}
820 @cindex @code{?:} side effect
821 @noindent
822 In this simple case, the ability to omit the middle operand is not
823 especially useful.  When it becomes useful is when the first operand does,
824 or may (if it is a macro argument), contain a side effect.  Then repeating
825 the operand in the middle would perform the side effect twice.  Omitting
826 the middle operand uses the value already computed without the undesirable
827 effects of recomputing it.
829 @node __int128
830 @section 128-bit Integers
831 @cindex @code{__int128} data types
833 As an extension the integer scalar type @code{__int128} is supported for
834 targets which have an integer mode wide enough to hold 128 bits.
835 Simply write @code{__int128} for a signed 128-bit integer, or
836 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
837 support in GCC for expressing an integer constant of type @code{__int128}
838 for targets with @code{long long} integer less than 128 bits wide.
840 @node Long Long
841 @section Double-Word Integers
842 @cindex @code{long long} data types
843 @cindex double-word arithmetic
844 @cindex multiprecision arithmetic
845 @cindex @code{LL} integer suffix
846 @cindex @code{ULL} integer suffix
848 ISO C99 supports data types for integers that are at least 64 bits wide,
849 and as an extension GCC supports them in C90 mode and in C++.
850 Simply write @code{long long int} for a signed integer, or
851 @code{unsigned long long int} for an unsigned integer.  To make an
852 integer constant of type @code{long long int}, add the suffix @samp{LL}
853 to the integer.  To make an integer constant of type @code{unsigned long
854 long int}, add the suffix @samp{ULL} to the integer.
856 You can use these types in arithmetic like any other integer types.
857 Addition, subtraction, and bitwise boolean operations on these types
858 are open-coded on all types of machines.  Multiplication is open-coded
859 if the machine supports a fullword-to-doubleword widening multiply
860 instruction.  Division and shifts are open-coded only on machines that
861 provide special support.  The operations that are not open-coded use
862 special library routines that come with GCC@.
864 There may be pitfalls when you use @code{long long} types for function
865 arguments without function prototypes.  If a function
866 expects type @code{int} for its argument, and you pass a value of type
867 @code{long long int}, confusion results because the caller and the
868 subroutine disagree about the number of bytes for the argument.
869 Likewise, if the function expects @code{long long int} and you pass
870 @code{int}.  The best way to avoid such problems is to use prototypes.
872 @node Complex
873 @section Complex Numbers
874 @cindex complex numbers
875 @cindex @code{_Complex} keyword
876 @cindex @code{__complex__} keyword
878 ISO C99 supports complex floating data types, and as an extension GCC
879 supports them in C90 mode and in C++.  GCC also supports complex integer data
880 types which are not part of ISO C99.  You can declare complex types
881 using the keyword @code{_Complex}.  As an extension, the older GNU
882 keyword @code{__complex__} is also supported.
884 For example, @samp{_Complex double x;} declares @code{x} as a
885 variable whose real part and imaginary part are both of type
886 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
887 have real and imaginary parts of type @code{short int}; this is not
888 likely to be useful, but it shows that the set of complex types is
889 complete.
891 To write a constant with a complex data type, use the suffix @samp{i} or
892 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
893 has type @code{_Complex float} and @code{3i} has type
894 @code{_Complex int}.  Such a constant always has a pure imaginary
895 value, but you can form any complex value you like by adding one to a
896 real constant.  This is a GNU extension; if you have an ISO C99
897 conforming C library (such as the GNU C Library), and want to construct complex
898 constants of floating type, you should include @code{<complex.h>} and
899 use the macros @code{I} or @code{_Complex_I} instead.
901 @cindex @code{__real__} keyword
902 @cindex @code{__imag__} keyword
903 To extract the real part of a complex-valued expression @var{exp}, write
904 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
905 extract the imaginary part.  This is a GNU extension; for values of
906 floating type, you should use the ISO C99 functions @code{crealf},
907 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
908 @code{cimagl}, declared in @code{<complex.h>} and also provided as
909 built-in functions by GCC@.
911 @cindex complex conjugation
912 The operator @samp{~} performs complex conjugation when used on a value
913 with a complex type.  This is a GNU extension; for values of
914 floating type, you should use the ISO C99 functions @code{conjf},
915 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
916 provided as built-in functions by GCC@.
918 GCC can allocate complex automatic variables in a noncontiguous
919 fashion; it's even possible for the real part to be in a register while
920 the imaginary part is on the stack (or vice versa).  Only the DWARF
921 debug info format can represent this, so use of DWARF is recommended.
922 If you are using the stabs debug info format, GCC describes a noncontiguous
923 complex variable as if it were two separate variables of noncomplex type.
924 If the variable's actual name is @code{foo}, the two fictitious
925 variables are named @code{foo$real} and @code{foo$imag}.  You can
926 examine and set these two fictitious variables with your debugger.
928 @node Floating Types
929 @section Additional Floating Types
930 @cindex additional floating types
931 @cindex @code{_Float@var{n}} data types
932 @cindex @code{_Float@var{n}x} data types
933 @cindex @code{__float80} data type
934 @cindex @code{__float128} data type
935 @cindex @code{__ibm128} data type
936 @cindex @code{w} floating point suffix
937 @cindex @code{q} floating point suffix
938 @cindex @code{W} floating point suffix
939 @cindex @code{Q} floating point suffix
941 ISO/IEC TS 18661-3:2015 defines C support for additional floating
942 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
943 these type names; the set of types supported depends on the target
944 architecture.  These types are not supported when compiling C++.
945 Constants with these types use suffixes @code{f@var{n}} or
946 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
947 names can be used together with @code{_Complex} to declare complex
948 types.
950 As an extension, GNU C and GNU C++ support additional floating
951 types, which are not supported by all targets.
952 @itemize @bullet
953 @item @code{__float128} is available on i386, x86_64, IA-64, and
954 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
955 the vector scalar (VSX) instruction set.  @code{__float128} supports
956 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
957 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
958 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
959 double}.
961 @item @code{__float80} is available on the i386, x86_64, and IA-64
962 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
963 an alias for the type name @code{_Float64x} on these targets.
965 @item @code{__ibm128} is available on PowerPC targets, and provides
966 access to the IBM extended double format which is the current format
967 used for @code{long double}.  When @code{long double} transitions to
968 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
969 for use in conversions between the two types.
970 @end itemize
972 Support for these additional types includes the arithmetic operators:
973 add, subtract, multiply, divide; unary arithmetic operators;
974 relational operators; equality operators; and conversions to and from
975 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
976 in a literal constant of type @code{__float80} or type
977 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
979 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
980 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
981 expected in future versions of GCC that @code{_Float128} and @code{__float128}
982 will be enabled automatically.
984 The @code{_Float128} type is supported on all systems where
985 @code{__float128} is supported or where @code{long double} has the
986 IEEE binary128 format.  The @code{_Float64x} type is supported on all
987 systems where @code{__float128} is supported.  The @code{_Float32}
988 type is supported on all systems supporting IEEE binary32; the
989 @code{_Float64} and @code{_Float32x} types are supported on all systems
990 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
991 systems by default, and on ARM systems when the IEEE format for 16-bit
992 floating-point types is selected with @option{-mfp16-format=ieee}.
993 GCC does not currently support @code{_Float128x} on any systems.
995 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
996 types using the corresponding internal complex type, @code{XCmode} for
997 @code{__float80} type and @code{TCmode} for @code{__float128} type:
999 @smallexample
1000 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1001 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1002 @end smallexample
1004 On the PowerPC Linux VSX targets, you can declare complex types using
1005 the corresponding internal complex type, @code{KCmode} for
1006 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1008 @smallexample
1009 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1010 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1011 @end smallexample
1013 @node Half-Precision
1014 @section Half-Precision Floating Point
1015 @cindex half-precision floating point
1016 @cindex @code{__fp16} data type
1018 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1019 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1020 On ARM systems, you must enable this type explicitly with the
1021 @option{-mfp16-format} command-line option in order to use it.
1023 ARM targets support two incompatible representations for half-precision
1024 floating-point values.  You must choose one of the representations and
1025 use it consistently in your program.
1027 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1028 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1029 There are 11 bits of significand precision, approximately 3
1030 decimal digits.
1032 Specifying @option{-mfp16-format=alternative} selects the ARM
1033 alternative format.  This representation is similar to the IEEE
1034 format, but does not support infinities or NaNs.  Instead, the range
1035 of exponents is extended, so that this format can represent normalized
1036 values in the range of @math{2^{-14}} to 131008.
1038 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1039 not require use of the @option{-mfp16-format} command-line option.
1041 The @code{__fp16} type may only be used as an argument to intrinsics defined
1042 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1043 arithmetic and other operations, @code{__fp16} values in C or C++
1044 expressions are automatically promoted to @code{float}.
1046 The ARM target provides hardware support for conversions between
1047 @code{__fp16} and @code{float} values
1048 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8 provides
1049 hardware support for conversions between @code{__fp16} and @code{double}
1050 values.  GCC generates code using these hardware instructions if you
1051 compile with options to select an FPU that provides them;
1052 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1053 in addition to the @option{-mfp16-format} option to select
1054 a half-precision format.
1056 Language-level support for the @code{__fp16} data type is
1057 independent of whether GCC generates code using hardware floating-point
1058 instructions.  In cases where hardware support is not specified, GCC
1059 implements conversions between @code{__fp16} and other types as library
1060 calls.
1062 It is recommended that portable code use the @code{_Float16} type defined
1063 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1065 @node Decimal Float
1066 @section Decimal Floating Types
1067 @cindex decimal floating types
1068 @cindex @code{_Decimal32} data type
1069 @cindex @code{_Decimal64} data type
1070 @cindex @code{_Decimal128} data type
1071 @cindex @code{df} integer suffix
1072 @cindex @code{dd} integer suffix
1073 @cindex @code{dl} integer suffix
1074 @cindex @code{DF} integer suffix
1075 @cindex @code{DD} integer suffix
1076 @cindex @code{DL} integer suffix
1078 As an extension, GNU C supports decimal floating types as
1079 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1080 floating types in GCC will evolve as the draft technical report changes.
1081 Calling conventions for any target might also change.  Not all targets
1082 support decimal floating types.
1084 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1085 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1086 @code{float}, @code{double}, and @code{long double} whose radix is not
1087 specified by the C standard but is usually two.
1089 Support for decimal floating types includes the arithmetic operators
1090 add, subtract, multiply, divide; unary arithmetic operators;
1091 relational operators; equality operators; and conversions to and from
1092 integer and other floating types.  Use a suffix @samp{df} or
1093 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1094 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1095 @code{_Decimal128}.
1097 GCC support of decimal float as specified by the draft technical report
1098 is incomplete:
1100 @itemize @bullet
1101 @item
1102 When the value of a decimal floating type cannot be represented in the
1103 integer type to which it is being converted, the result is undefined
1104 rather than the result value specified by the draft technical report.
1106 @item
1107 GCC does not provide the C library functionality associated with
1108 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1109 @file{wchar.h}, which must come from a separate C library implementation.
1110 Because of this the GNU C compiler does not define macro
1111 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1112 the technical report.
1113 @end itemize
1115 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1116 are supported by the DWARF debug information format.
1118 @node Hex Floats
1119 @section Hex Floats
1120 @cindex hex floats
1122 ISO C99 supports floating-point numbers written not only in the usual
1123 decimal notation, such as @code{1.55e1}, but also numbers such as
1124 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1125 supports this in C90 mode (except in some cases when strictly
1126 conforming) and in C++.  In that format the
1127 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1128 mandatory.  The exponent is a decimal number that indicates the power of
1129 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1130 @tex
1131 $1 {15\over16}$,
1132 @end tex
1133 @ifnottex
1134 1 15/16,
1135 @end ifnottex
1136 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1137 is the same as @code{1.55e1}.
1139 Unlike for floating-point numbers in the decimal notation the exponent
1140 is always required in the hexadecimal notation.  Otherwise the compiler
1141 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1142 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1143 extension for floating-point constants of type @code{float}.
1145 @node Fixed-Point
1146 @section Fixed-Point Types
1147 @cindex fixed-point types
1148 @cindex @code{_Fract} data type
1149 @cindex @code{_Accum} data type
1150 @cindex @code{_Sat} data type
1151 @cindex @code{hr} fixed-suffix
1152 @cindex @code{r} fixed-suffix
1153 @cindex @code{lr} fixed-suffix
1154 @cindex @code{llr} fixed-suffix
1155 @cindex @code{uhr} fixed-suffix
1156 @cindex @code{ur} fixed-suffix
1157 @cindex @code{ulr} fixed-suffix
1158 @cindex @code{ullr} fixed-suffix
1159 @cindex @code{hk} fixed-suffix
1160 @cindex @code{k} fixed-suffix
1161 @cindex @code{lk} fixed-suffix
1162 @cindex @code{llk} fixed-suffix
1163 @cindex @code{uhk} fixed-suffix
1164 @cindex @code{uk} fixed-suffix
1165 @cindex @code{ulk} fixed-suffix
1166 @cindex @code{ullk} fixed-suffix
1167 @cindex @code{HR} fixed-suffix
1168 @cindex @code{R} fixed-suffix
1169 @cindex @code{LR} fixed-suffix
1170 @cindex @code{LLR} fixed-suffix
1171 @cindex @code{UHR} fixed-suffix
1172 @cindex @code{UR} fixed-suffix
1173 @cindex @code{ULR} fixed-suffix
1174 @cindex @code{ULLR} fixed-suffix
1175 @cindex @code{HK} fixed-suffix
1176 @cindex @code{K} fixed-suffix
1177 @cindex @code{LK} fixed-suffix
1178 @cindex @code{LLK} fixed-suffix
1179 @cindex @code{UHK} fixed-suffix
1180 @cindex @code{UK} fixed-suffix
1181 @cindex @code{ULK} fixed-suffix
1182 @cindex @code{ULLK} fixed-suffix
1184 As an extension, GNU C supports fixed-point types as
1185 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1186 types in GCC will evolve as the draft technical report changes.
1187 Calling conventions for any target might also change.  Not all targets
1188 support fixed-point types.
1190 The fixed-point types are
1191 @code{short _Fract},
1192 @code{_Fract},
1193 @code{long _Fract},
1194 @code{long long _Fract},
1195 @code{unsigned short _Fract},
1196 @code{unsigned _Fract},
1197 @code{unsigned long _Fract},
1198 @code{unsigned long long _Fract},
1199 @code{_Sat short _Fract},
1200 @code{_Sat _Fract},
1201 @code{_Sat long _Fract},
1202 @code{_Sat long long _Fract},
1203 @code{_Sat unsigned short _Fract},
1204 @code{_Sat unsigned _Fract},
1205 @code{_Sat unsigned long _Fract},
1206 @code{_Sat unsigned long long _Fract},
1207 @code{short _Accum},
1208 @code{_Accum},
1209 @code{long _Accum},
1210 @code{long long _Accum},
1211 @code{unsigned short _Accum},
1212 @code{unsigned _Accum},
1213 @code{unsigned long _Accum},
1214 @code{unsigned long long _Accum},
1215 @code{_Sat short _Accum},
1216 @code{_Sat _Accum},
1217 @code{_Sat long _Accum},
1218 @code{_Sat long long _Accum},
1219 @code{_Sat unsigned short _Accum},
1220 @code{_Sat unsigned _Accum},
1221 @code{_Sat unsigned long _Accum},
1222 @code{_Sat unsigned long long _Accum}.
1224 Fixed-point data values contain fractional and optional integral parts.
1225 The format of fixed-point data varies and depends on the target machine.
1227 Support for fixed-point types includes:
1228 @itemize @bullet
1229 @item
1230 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1231 @item
1232 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1233 @item
1234 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1235 @item
1236 binary shift operators (@code{<<}, @code{>>})
1237 @item
1238 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1239 @item
1240 equality operators (@code{==}, @code{!=})
1241 @item
1242 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1243 @code{<<=}, @code{>>=})
1244 @item
1245 conversions to and from integer, floating-point, or fixed-point types
1246 @end itemize
1248 Use a suffix in a fixed-point literal constant:
1249 @itemize
1250 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1251 @code{_Sat short _Fract}
1252 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1253 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1254 @code{_Sat long _Fract}
1255 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1256 @code{_Sat long long _Fract}
1257 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1258 @code{_Sat unsigned short _Fract}
1259 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1260 @code{_Sat unsigned _Fract}
1261 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1262 @code{_Sat unsigned long _Fract}
1263 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1264 and @code{_Sat unsigned long long _Fract}
1265 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1266 @code{_Sat short _Accum}
1267 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1268 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1269 @code{_Sat long _Accum}
1270 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1271 @code{_Sat long long _Accum}
1272 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1273 @code{_Sat unsigned short _Accum}
1274 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1275 @code{_Sat unsigned _Accum}
1276 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1277 @code{_Sat unsigned long _Accum}
1278 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1279 and @code{_Sat unsigned long long _Accum}
1280 @end itemize
1282 GCC support of fixed-point types as specified by the draft technical report
1283 is incomplete:
1285 @itemize @bullet
1286 @item
1287 Pragmas to control overflow and rounding behaviors are not implemented.
1288 @end itemize
1290 Fixed-point types are supported by the DWARF debug information format.
1292 @node Named Address Spaces
1293 @section Named Address Spaces
1294 @cindex Named Address Spaces
1296 As an extension, GNU C supports named address spaces as
1297 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1298 address spaces in GCC will evolve as the draft technical report
1299 changes.  Calling conventions for any target might also change.  At
1300 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1301 address spaces other than the generic address space.
1303 Address space identifiers may be used exactly like any other C type
1304 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1305 document for more details.
1307 @anchor{AVR Named Address Spaces}
1308 @subsection AVR Named Address Spaces
1310 On the AVR target, there are several address spaces that can be used
1311 in order to put read-only data into the flash memory and access that
1312 data by means of the special instructions @code{LPM} or @code{ELPM}
1313 needed to read from flash.
1315 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1316 flash memory by means of @code{LD*} instructions because the flash
1317 memory is mapped into the RAM address space.  There is @emph{no need}
1318 for language extensions like @code{__flash} or attribute
1319 @ref{AVR Variable Attributes,,@code{progmem}}.
1320 The default linker description files for these devices cater for that
1321 feature and @code{.rodata} stays in flash: The compiler just generates
1322 @code{LD*} instructions, and the linker script adds core specific
1323 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1324 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1325 See @ref{AVR Options} for a list of respective devices.
1327 For devices not in @code{avrtiny} or @code{avrxmega3},
1328 any data including read-only data is located in RAM (the generic
1329 address space) because flash memory is not visible in the RAM address
1330 space.  In order to locate read-only data in flash memory @emph{and}
1331 to generate the right instructions to access this data without
1332 using (inline) assembler code, special address spaces are needed.
1334 @table @code
1335 @item __flash
1336 @cindex @code{__flash} AVR Named Address Spaces
1337 The @code{__flash} qualifier locates data in the
1338 @code{.progmem.data} section. Data is read using the @code{LPM}
1339 instruction. Pointers to this address space are 16 bits wide.
1341 @item __flash1
1342 @itemx __flash2
1343 @itemx __flash3
1344 @itemx __flash4
1345 @itemx __flash5
1346 @cindex @code{__flash1} AVR Named Address Spaces
1347 @cindex @code{__flash2} AVR Named Address Spaces
1348 @cindex @code{__flash3} AVR Named Address Spaces
1349 @cindex @code{__flash4} AVR Named Address Spaces
1350 @cindex @code{__flash5} AVR Named Address Spaces
1351 These are 16-bit address spaces locating data in section
1352 @code{.progmem@var{N}.data} where @var{N} refers to
1353 address space @code{__flash@var{N}}.
1354 The compiler sets the @code{RAMPZ} segment register appropriately 
1355 before reading data by means of the @code{ELPM} instruction.
1357 @item __memx
1358 @cindex @code{__memx} AVR Named Address Spaces
1359 This is a 24-bit address space that linearizes flash and RAM:
1360 If the high bit of the address is set, data is read from
1361 RAM using the lower two bytes as RAM address.
1362 If the high bit of the address is clear, data is read from flash
1363 with @code{RAMPZ} set according to the high byte of the address.
1364 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1366 Objects in this address space are located in @code{.progmemx.data}.
1367 @end table
1369 @b{Example}
1371 @smallexample
1372 char my_read (const __flash char ** p)
1374     /* p is a pointer to RAM that points to a pointer to flash.
1375        The first indirection of p reads that flash pointer
1376        from RAM and the second indirection reads a char from this
1377        flash address.  */
1379     return **p;
1382 /* Locate array[] in flash memory */
1383 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1385 int i = 1;
1387 int main (void)
1389    /* Return 17 by reading from flash memory */
1390    return array[array[i]];
1392 @end smallexample
1394 @noindent
1395 For each named address space supported by avr-gcc there is an equally
1396 named but uppercase built-in macro defined. 
1397 The purpose is to facilitate testing if respective address space
1398 support is available or not:
1400 @smallexample
1401 #ifdef __FLASH
1402 const __flash int var = 1;
1404 int read_var (void)
1406     return var;
1408 #else
1409 #include <avr/pgmspace.h> /* From AVR-LibC */
1411 const int var PROGMEM = 1;
1413 int read_var (void)
1415     return (int) pgm_read_word (&var);
1417 #endif /* __FLASH */
1418 @end smallexample
1420 @noindent
1421 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1422 locates data in flash but
1423 accesses to these data read from generic address space, i.e.@:
1424 from RAM,
1425 so that you need special accessors like @code{pgm_read_byte}
1426 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1427 together with attribute @code{progmem}.
1429 @noindent
1430 @b{Limitations and caveats}
1432 @itemize
1433 @item
1434 Reading across the 64@tie{}KiB section boundary of
1435 the @code{__flash} or @code{__flash@var{N}} address spaces
1436 shows undefined behavior. The only address space that
1437 supports reading across the 64@tie{}KiB flash segment boundaries is
1438 @code{__memx}.
1440 @item
1441 If you use one of the @code{__flash@var{N}} address spaces
1442 you must arrange your linker script to locate the
1443 @code{.progmem@var{N}.data} sections according to your needs.
1445 @item
1446 Any data or pointers to the non-generic address spaces must
1447 be qualified as @code{const}, i.e.@: as read-only data.
1448 This still applies if the data in one of these address
1449 spaces like software version number or calibration lookup table are intended to
1450 be changed after load time by, say, a boot loader. In this case
1451 the right qualification is @code{const} @code{volatile} so that the compiler
1452 must not optimize away known values or insert them
1453 as immediates into operands of instructions.
1455 @item
1456 The following code initializes a variable @code{pfoo}
1457 located in static storage with a 24-bit address:
1458 @smallexample
1459 extern const __memx char foo;
1460 const __memx void *pfoo = &foo;
1461 @end smallexample
1463 @item
1464 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1465 Just use vanilla C / C++ code without overhead as outlined above.
1466 Attribute @code{progmem} is supported but works differently,
1467 see @ref{AVR Variable Attributes}.
1469 @end itemize
1471 @subsection M32C Named Address Spaces
1472 @cindex @code{__far} M32C Named Address Spaces
1474 On the M32C target, with the R8C and M16C CPU variants, variables
1475 qualified with @code{__far} are accessed using 32-bit addresses in
1476 order to access memory beyond the first 64@tie{}Ki bytes.  If
1477 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1478 effect.
1480 @subsection RL78 Named Address Spaces
1481 @cindex @code{__far} RL78 Named Address Spaces
1483 On the RL78 target, variables qualified with @code{__far} are accessed
1484 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1485 addresses.  Non-far variables are assumed to appear in the topmost
1486 64@tie{}KiB of the address space.
1488 @subsection SPU Named Address Spaces
1489 @cindex @code{__ea} SPU Named Address Spaces
1491 On the SPU target variables may be declared as
1492 belonging to another address space by qualifying the type with the
1493 @code{__ea} address space identifier:
1495 @smallexample
1496 extern int __ea i;
1497 @end smallexample
1499 @noindent 
1500 The compiler generates special code to access the variable @code{i}.
1501 It may use runtime library
1502 support, or generate special machine instructions to access that address
1503 space.
1505 @subsection x86 Named Address Spaces
1506 @cindex x86 named address spaces
1508 On the x86 target, variables may be declared as being relative
1509 to the @code{%fs} or @code{%gs} segments.
1511 @table @code
1512 @item __seg_fs
1513 @itemx __seg_gs
1514 @cindex @code{__seg_fs} x86 named address space
1515 @cindex @code{__seg_gs} x86 named address space
1516 The object is accessed with the respective segment override prefix.
1518 The respective segment base must be set via some method specific to
1519 the operating system.  Rather than require an expensive system call
1520 to retrieve the segment base, these address spaces are not considered
1521 to be subspaces of the generic (flat) address space.  This means that
1522 explicit casts are required to convert pointers between these address
1523 spaces and the generic address space.  In practice the application
1524 should cast to @code{uintptr_t} and apply the segment base offset
1525 that it installed previously.
1527 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1528 defined when these address spaces are supported.
1529 @end table
1531 @node Zero Length
1532 @section Arrays of Length Zero
1533 @cindex arrays of length zero
1534 @cindex zero-length arrays
1535 @cindex length-zero arrays
1536 @cindex flexible array members
1538 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1539 last element of a structure that is really a header for a variable-length
1540 object:
1542 @smallexample
1543 struct line @{
1544   int length;
1545   char contents[0];
1548 struct line *thisline = (struct line *)
1549   malloc (sizeof (struct line) + this_length);
1550 thisline->length = this_length;
1551 @end smallexample
1553 In ISO C90, you would have to give @code{contents} a length of 1, which
1554 means either you waste space or complicate the argument to @code{malloc}.
1556 In ISO C99, you would use a @dfn{flexible array member}, which is
1557 slightly different in syntax and semantics:
1559 @itemize @bullet
1560 @item
1561 Flexible array members are written as @code{contents[]} without
1562 the @code{0}.
1564 @item
1565 Flexible array members have incomplete type, and so the @code{sizeof}
1566 operator may not be applied.  As a quirk of the original implementation
1567 of zero-length arrays, @code{sizeof} evaluates to zero.
1569 @item
1570 Flexible array members may only appear as the last member of a
1571 @code{struct} that is otherwise non-empty.
1573 @item
1574 A structure containing a flexible array member, or a union containing
1575 such a structure (possibly recursively), may not be a member of a
1576 structure or an element of an array.  (However, these uses are
1577 permitted by GCC as extensions.)
1578 @end itemize
1580 Non-empty initialization of zero-length
1581 arrays is treated like any case where there are more initializer
1582 elements than the array holds, in that a suitable warning about ``excess
1583 elements in array'' is given, and the excess elements (all of them, in
1584 this case) are ignored.
1586 GCC allows static initialization of flexible array members.
1587 This is equivalent to defining a new structure containing the original
1588 structure followed by an array of sufficient size to contain the data.
1589 E.g.@: in the following, @code{f1} is constructed as if it were declared
1590 like @code{f2}.
1592 @smallexample
1593 struct f1 @{
1594   int x; int y[];
1595 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1597 struct f2 @{
1598   struct f1 f1; int data[3];
1599 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1600 @end smallexample
1602 @noindent
1603 The convenience of this extension is that @code{f1} has the desired
1604 type, eliminating the need to consistently refer to @code{f2.f1}.
1606 This has symmetry with normal static arrays, in that an array of
1607 unknown size is also written with @code{[]}.
1609 Of course, this extension only makes sense if the extra data comes at
1610 the end of a top-level object, as otherwise we would be overwriting
1611 data at subsequent offsets.  To avoid undue complication and confusion
1612 with initialization of deeply nested arrays, we simply disallow any
1613 non-empty initialization except when the structure is the top-level
1614 object.  For example:
1616 @smallexample
1617 struct foo @{ int x; int y[]; @};
1618 struct bar @{ struct foo z; @};
1620 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1621 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1622 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1623 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1624 @end smallexample
1626 @node Empty Structures
1627 @section Structures with No Members
1628 @cindex empty structures
1629 @cindex zero-size structures
1631 GCC permits a C structure to have no members:
1633 @smallexample
1634 struct empty @{
1636 @end smallexample
1638 The structure has size zero.  In C++, empty structures are part
1639 of the language.  G++ treats empty structures as if they had a single
1640 member of type @code{char}.
1642 @node Variable Length
1643 @section Arrays of Variable Length
1644 @cindex variable-length arrays
1645 @cindex arrays of variable length
1646 @cindex VLAs
1648 Variable-length automatic arrays are allowed in ISO C99, and as an
1649 extension GCC accepts them in C90 mode and in C++.  These arrays are
1650 declared like any other automatic arrays, but with a length that is not
1651 a constant expression.  The storage is allocated at the point of
1652 declaration and deallocated when the block scope containing the declaration
1653 exits.  For
1654 example:
1656 @smallexample
1657 FILE *
1658 concat_fopen (char *s1, char *s2, char *mode)
1660   char str[strlen (s1) + strlen (s2) + 1];
1661   strcpy (str, s1);
1662   strcat (str, s2);
1663   return fopen (str, mode);
1665 @end smallexample
1667 @cindex scope of a variable length array
1668 @cindex variable-length array scope
1669 @cindex deallocating variable length arrays
1670 Jumping or breaking out of the scope of the array name deallocates the
1671 storage.  Jumping into the scope is not allowed; you get an error
1672 message for it.
1674 @cindex variable-length array in a structure
1675 As an extension, GCC accepts variable-length arrays as a member of
1676 a structure or a union.  For example:
1678 @smallexample
1679 void
1680 foo (int n)
1682   struct S @{ int x[n]; @};
1684 @end smallexample
1686 @cindex @code{alloca} vs variable-length arrays
1687 You can use the function @code{alloca} to get an effect much like
1688 variable-length arrays.  The function @code{alloca} is available in
1689 many other C implementations (but not in all).  On the other hand,
1690 variable-length arrays are more elegant.
1692 There are other differences between these two methods.  Space allocated
1693 with @code{alloca} exists until the containing @emph{function} returns.
1694 The space for a variable-length array is deallocated as soon as the array
1695 name's scope ends, unless you also use @code{alloca} in this scope.
1697 You can also use variable-length arrays as arguments to functions:
1699 @smallexample
1700 struct entry
1701 tester (int len, char data[len][len])
1703   /* @r{@dots{}} */
1705 @end smallexample
1707 The length of an array is computed once when the storage is allocated
1708 and is remembered for the scope of the array in case you access it with
1709 @code{sizeof}.
1711 If you want to pass the array first and the length afterward, you can
1712 use a forward declaration in the parameter list---another GNU extension.
1714 @smallexample
1715 struct entry
1716 tester (int len; char data[len][len], int len)
1718   /* @r{@dots{}} */
1720 @end smallexample
1722 @cindex parameter forward declaration
1723 The @samp{int len} before the semicolon is a @dfn{parameter forward
1724 declaration}, and it serves the purpose of making the name @code{len}
1725 known when the declaration of @code{data} is parsed.
1727 You can write any number of such parameter forward declarations in the
1728 parameter list.  They can be separated by commas or semicolons, but the
1729 last one must end with a semicolon, which is followed by the ``real''
1730 parameter declarations.  Each forward declaration must match a ``real''
1731 declaration in parameter name and data type.  ISO C99 does not support
1732 parameter forward declarations.
1734 @node Variadic Macros
1735 @section Macros with a Variable Number of Arguments.
1736 @cindex variable number of arguments
1737 @cindex macro with variable arguments
1738 @cindex rest argument (in macro)
1739 @cindex variadic macros
1741 In the ISO C standard of 1999, a macro can be declared to accept a
1742 variable number of arguments much as a function can.  The syntax for
1743 defining the macro is similar to that of a function.  Here is an
1744 example:
1746 @smallexample
1747 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1748 @end smallexample
1750 @noindent
1751 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1752 such a macro, it represents the zero or more tokens until the closing
1753 parenthesis that ends the invocation, including any commas.  This set of
1754 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1755 wherever it appears.  See the CPP manual for more information.
1757 GCC has long supported variadic macros, and used a different syntax that
1758 allowed you to give a name to the variable arguments just like any other
1759 argument.  Here is an example:
1761 @smallexample
1762 #define debug(format, args...) fprintf (stderr, format, args)
1763 @end smallexample
1765 @noindent
1766 This is in all ways equivalent to the ISO C example above, but arguably
1767 more readable and descriptive.
1769 GNU CPP has two further variadic macro extensions, and permits them to
1770 be used with either of the above forms of macro definition.
1772 In standard C, you are not allowed to leave the variable argument out
1773 entirely; but you are allowed to pass an empty argument.  For example,
1774 this invocation is invalid in ISO C, because there is no comma after
1775 the string:
1777 @smallexample
1778 debug ("A message")
1779 @end smallexample
1781 GNU CPP permits you to completely omit the variable arguments in this
1782 way.  In the above examples, the compiler would complain, though since
1783 the expansion of the macro still has the extra comma after the format
1784 string.
1786 To help solve this problem, CPP behaves specially for variable arguments
1787 used with the token paste operator, @samp{##}.  If instead you write
1789 @smallexample
1790 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1791 @end smallexample
1793 @noindent
1794 and if the variable arguments are omitted or empty, the @samp{##}
1795 operator causes the preprocessor to remove the comma before it.  If you
1796 do provide some variable arguments in your macro invocation, GNU CPP
1797 does not complain about the paste operation and instead places the
1798 variable arguments after the comma.  Just like any other pasted macro
1799 argument, these arguments are not macro expanded.
1801 @node Escaped Newlines
1802 @section Slightly Looser Rules for Escaped Newlines
1803 @cindex escaped newlines
1804 @cindex newlines (escaped)
1806 The preprocessor treatment of escaped newlines is more relaxed 
1807 than that specified by the C90 standard, which requires the newline
1808 to immediately follow a backslash.  
1809 GCC's implementation allows whitespace in the form
1810 of spaces, horizontal and vertical tabs, and form feeds between the
1811 backslash and the subsequent newline.  The preprocessor issues a
1812 warning, but treats it as a valid escaped newline and combines the two
1813 lines to form a single logical line.  This works within comments and
1814 tokens, as well as between tokens.  Comments are @emph{not} treated as
1815 whitespace for the purposes of this relaxation, since they have not
1816 yet been replaced with spaces.
1818 @node Subscripting
1819 @section Non-Lvalue Arrays May Have Subscripts
1820 @cindex subscripting
1821 @cindex arrays, non-lvalue
1823 @cindex subscripting and function values
1824 In ISO C99, arrays that are not lvalues still decay to pointers, and
1825 may be subscripted, although they may not be modified or used after
1826 the next sequence point and the unary @samp{&} operator may not be
1827 applied to them.  As an extension, GNU C allows such arrays to be
1828 subscripted in C90 mode, though otherwise they do not decay to
1829 pointers outside C99 mode.  For example,
1830 this is valid in GNU C though not valid in C90:
1832 @smallexample
1833 @group
1834 struct foo @{int a[4];@};
1836 struct foo f();
1838 bar (int index)
1840   return f().a[index];
1842 @end group
1843 @end smallexample
1845 @node Pointer Arith
1846 @section Arithmetic on @code{void}- and Function-Pointers
1847 @cindex void pointers, arithmetic
1848 @cindex void, size of pointer to
1849 @cindex function pointers, arithmetic
1850 @cindex function, size of pointer to
1852 In GNU C, addition and subtraction operations are supported on pointers to
1853 @code{void} and on pointers to functions.  This is done by treating the
1854 size of a @code{void} or of a function as 1.
1856 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1857 and on function types, and returns 1.
1859 @opindex Wpointer-arith
1860 The option @option{-Wpointer-arith} requests a warning if these extensions
1861 are used.
1863 @node Pointers to Arrays
1864 @section Pointers to Arrays with Qualifiers Work as Expected
1865 @cindex pointers to arrays
1866 @cindex const qualifier
1868 In GNU C, pointers to arrays with qualifiers work similar to pointers
1869 to other qualified types. For example, a value of type @code{int (*)[5]}
1870 can be used to initialize a variable of type @code{const int (*)[5]}.
1871 These types are incompatible in ISO C because the @code{const} qualifier
1872 is formally attached to the element type of the array and not the
1873 array itself.
1875 @smallexample
1876 extern void
1877 transpose (int N, int M, double out[M][N], const double in[N][M]);
1878 double x[3][2];
1879 double y[2][3];
1880 @r{@dots{}}
1881 transpose(3, 2, y, x);
1882 @end smallexample
1884 @node Initializers
1885 @section Non-Constant Initializers
1886 @cindex initializers, non-constant
1887 @cindex non-constant initializers
1889 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1890 automatic variable are not required to be constant expressions in GNU C@.
1891 Here is an example of an initializer with run-time varying elements:
1893 @smallexample
1894 foo (float f, float g)
1896   float beat_freqs[2] = @{ f-g, f+g @};
1897   /* @r{@dots{}} */
1899 @end smallexample
1901 @node Compound Literals
1902 @section Compound Literals
1903 @cindex constructor expressions
1904 @cindex initializations in expressions
1905 @cindex structures, constructor expression
1906 @cindex expressions, constructor
1907 @cindex compound literals
1908 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1910 A compound literal looks like a cast of a brace-enclosed aggregate
1911 initializer list.  Its value is an object of the type specified in
1912 the cast, containing the elements specified in the initializer.
1913 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1914 C99 and later support compound literals.  As an extension, GCC
1915 supports compound literals also in C90 mode and in C++, although
1916 as explained below, the C++ semantics are somewhat different.
1918 Usually, the specified type of a compound literal is a structure.  Assume
1919 that @code{struct foo} and @code{structure} are declared as shown:
1921 @smallexample
1922 struct foo @{int a; char b[2];@} structure;
1923 @end smallexample
1925 @noindent
1926 Here is an example of constructing a @code{struct foo} with a compound literal:
1928 @smallexample
1929 structure = ((struct foo) @{x + y, 'a', 0@});
1930 @end smallexample
1932 @noindent
1933 This is equivalent to writing the following:
1935 @smallexample
1937   struct foo temp = @{x + y, 'a', 0@};
1938   structure = temp;
1940 @end smallexample
1942 You can also construct an array, though this is dangerous in C++, as
1943 explained below.  If all the elements of the compound literal are
1944 (made up of) simple constant expressions suitable for use in
1945 initializers of objects of static storage duration, then the compound
1946 literal can be coerced to a pointer to its first element and used in
1947 such an initializer, as shown here:
1949 @smallexample
1950 char **foo = (char *[]) @{ "x", "y", "z" @};
1951 @end smallexample
1953 Compound literals for scalar types and union types are also allowed.  In
1954 the following example the variable @code{i} is initialized to the value
1955 @code{2}, the result of incrementing the unnamed object created by
1956 the compound literal.
1958 @smallexample
1959 int i = ++(int) @{ 1 @};
1960 @end smallexample
1962 As a GNU extension, GCC allows initialization of objects with static storage
1963 duration by compound literals (which is not possible in ISO C99 because
1964 the initializer is not a constant).
1965 It is handled as if the object were initialized only with the brace-enclosed
1966 list if the types of the compound literal and the object match.
1967 The elements of the compound literal must be constant.
1968 If the object being initialized has array type of unknown size, the size is
1969 determined by the size of the compound literal.
1971 @smallexample
1972 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1973 static int y[] = (int []) @{1, 2, 3@};
1974 static int z[] = (int [3]) @{1@};
1975 @end smallexample
1977 @noindent
1978 The above lines are equivalent to the following:
1979 @smallexample
1980 static struct foo x = @{1, 'a', 'b'@};
1981 static int y[] = @{1, 2, 3@};
1982 static int z[] = @{1, 0, 0@};
1983 @end smallexample
1985 In C, a compound literal designates an unnamed object with static or
1986 automatic storage duration.  In C++, a compound literal designates a
1987 temporary object that only lives until the end of its full-expression.
1988 As a result, well-defined C code that takes the address of a subobject
1989 of a compound literal can be undefined in C++, so G++ rejects
1990 the conversion of a temporary array to a pointer.  For instance, if
1991 the array compound literal example above appeared inside a function,
1992 any subsequent use of @code{foo} in C++ would have undefined behavior
1993 because the lifetime of the array ends after the declaration of @code{foo}.
1995 As an optimization, G++ sometimes gives array compound literals longer
1996 lifetimes: when the array either appears outside a function or has
1997 a @code{const}-qualified type.  If @code{foo} and its initializer had
1998 elements of type @code{char *const} rather than @code{char *}, or if
1999 @code{foo} were a global variable, the array would have static storage
2000 duration.  But it is probably safest just to avoid the use of array
2001 compound literals in C++ code.
2003 @node Designated Inits
2004 @section Designated Initializers
2005 @cindex initializers with labeled elements
2006 @cindex labeled elements in initializers
2007 @cindex case labels in initializers
2008 @cindex designated initializers
2010 Standard C90 requires the elements of an initializer to appear in a fixed
2011 order, the same as the order of the elements in the array or structure
2012 being initialized.
2014 In ISO C99 you can give the elements in any order, specifying the array
2015 indices or structure field names they apply to, and GNU C allows this as
2016 an extension in C90 mode as well.  This extension is not
2017 implemented in GNU C++.
2019 To specify an array index, write
2020 @samp{[@var{index}] =} before the element value.  For example,
2022 @smallexample
2023 int a[6] = @{ [4] = 29, [2] = 15 @};
2024 @end smallexample
2026 @noindent
2027 is equivalent to
2029 @smallexample
2030 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2031 @end smallexample
2033 @noindent
2034 The index values must be constant expressions, even if the array being
2035 initialized is automatic.
2037 An alternative syntax for this that has been obsolete since GCC 2.5 but
2038 GCC still accepts is to write @samp{[@var{index}]} before the element
2039 value, with no @samp{=}.
2041 To initialize a range of elements to the same value, write
2042 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2043 extension.  For example,
2045 @smallexample
2046 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2047 @end smallexample
2049 @noindent
2050 If the value in it has side-effects, the side-effects happen only once,
2051 not for each initialized field by the range initializer.
2053 @noindent
2054 Note that the length of the array is the highest value specified
2055 plus one.
2057 In a structure initializer, specify the name of a field to initialize
2058 with @samp{.@var{fieldname} =} before the element value.  For example,
2059 given the following structure,
2061 @smallexample
2062 struct point @{ int x, y; @};
2063 @end smallexample
2065 @noindent
2066 the following initialization
2068 @smallexample
2069 struct point p = @{ .y = yvalue, .x = xvalue @};
2070 @end smallexample
2072 @noindent
2073 is equivalent to
2075 @smallexample
2076 struct point p = @{ xvalue, yvalue @};
2077 @end smallexample
2079 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2080 @samp{@var{fieldname}:}, as shown here:
2082 @smallexample
2083 struct point p = @{ y: yvalue, x: xvalue @};
2084 @end smallexample
2086 Omitted field members are implicitly initialized the same as objects
2087 that have static storage duration.
2089 @cindex designators
2090 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2091 @dfn{designator}.  You can also use a designator (or the obsolete colon
2092 syntax) when initializing a union, to specify which element of the union
2093 should be used.  For example,
2095 @smallexample
2096 union foo @{ int i; double d; @};
2098 union foo f = @{ .d = 4 @};
2099 @end smallexample
2101 @noindent
2102 converts 4 to a @code{double} to store it in the union using
2103 the second element.  By contrast, casting 4 to type @code{union foo}
2104 stores it into the union as the integer @code{i}, since it is
2105 an integer.  @xref{Cast to Union}.
2107 You can combine this technique of naming elements with ordinary C
2108 initialization of successive elements.  Each initializer element that
2109 does not have a designator applies to the next consecutive element of the
2110 array or structure.  For example,
2112 @smallexample
2113 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2114 @end smallexample
2116 @noindent
2117 is equivalent to
2119 @smallexample
2120 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2121 @end smallexample
2123 Labeling the elements of an array initializer is especially useful
2124 when the indices are characters or belong to an @code{enum} type.
2125 For example:
2127 @smallexample
2128 int whitespace[256]
2129   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2130       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2131 @end smallexample
2133 @cindex designator lists
2134 You can also write a series of @samp{.@var{fieldname}} and
2135 @samp{[@var{index}]} designators before an @samp{=} to specify a
2136 nested subobject to initialize; the list is taken relative to the
2137 subobject corresponding to the closest surrounding brace pair.  For
2138 example, with the @samp{struct point} declaration above:
2140 @smallexample
2141 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2142 @end smallexample
2144 @noindent
2145 If the same field is initialized multiple times, it has the value from
2146 the last initialization.  If any such overridden initialization has
2147 side-effect, it is unspecified whether the side-effect happens or not.
2148 Currently, GCC discards them and issues a warning.
2150 @node Case Ranges
2151 @section Case Ranges
2152 @cindex case ranges
2153 @cindex ranges in case statements
2155 You can specify a range of consecutive values in a single @code{case} label,
2156 like this:
2158 @smallexample
2159 case @var{low} ... @var{high}:
2160 @end smallexample
2162 @noindent
2163 This has the same effect as the proper number of individual @code{case}
2164 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2166 This feature is especially useful for ranges of ASCII character codes:
2168 @smallexample
2169 case 'A' ... 'Z':
2170 @end smallexample
2172 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2173 it may be parsed wrong when you use it with integer values.  For example,
2174 write this:
2176 @smallexample
2177 case 1 ... 5:
2178 @end smallexample
2180 @noindent
2181 rather than this:
2183 @smallexample
2184 case 1...5:
2185 @end smallexample
2187 @node Cast to Union
2188 @section Cast to a Union Type
2189 @cindex cast to a union
2190 @cindex union, casting to a
2192 A cast to union type looks similar to other casts, except that the type
2193 specified is a union type.  You can specify the type either with the
2194 @code{union} keyword or with a @code{typedef} name that refers to
2195 a union.  A cast to a union actually creates a compound literal and
2196 yields an lvalue, not an rvalue like true casts do.
2197 @xref{Compound Literals}.
2199 The types that may be cast to the union type are those of the members
2200 of the union.  Thus, given the following union and variables:
2202 @smallexample
2203 union foo @{ int i; double d; @};
2204 int x;
2205 double y;
2206 @end smallexample
2208 @noindent
2209 both @code{x} and @code{y} can be cast to type @code{union foo}.
2211 Using the cast as the right-hand side of an assignment to a variable of
2212 union type is equivalent to storing in a member of the union:
2214 @smallexample
2215 union foo u;
2216 /* @r{@dots{}} */
2217 u = (union foo) x  @equiv{}  u.i = x
2218 u = (union foo) y  @equiv{}  u.d = y
2219 @end smallexample
2221 You can also use the union cast as a function argument:
2223 @smallexample
2224 void hack (union foo);
2225 /* @r{@dots{}} */
2226 hack ((union foo) x);
2227 @end smallexample
2229 @node Mixed Declarations
2230 @section Mixed Declarations and Code
2231 @cindex mixed declarations and code
2232 @cindex declarations, mixed with code
2233 @cindex code, mixed with declarations
2235 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2236 within compound statements.  As an extension, GNU C also allows this in
2237 C90 mode.  For example, you could do:
2239 @smallexample
2240 int i;
2241 /* @r{@dots{}} */
2242 i++;
2243 int j = i + 2;
2244 @end smallexample
2246 Each identifier is visible from where it is declared until the end of
2247 the enclosing block.
2249 @node Function Attributes
2250 @section Declaring Attributes of Functions
2251 @cindex function attributes
2252 @cindex declaring attributes of functions
2253 @cindex @code{volatile} applied to function
2254 @cindex @code{const} applied to function
2256 In GNU C, you can use function attributes to declare certain things
2257 about functions called in your program which help the compiler
2258 optimize calls and check your code more carefully.  For example, you
2259 can use attributes to declare that a function never returns
2260 (@code{noreturn}), returns a value depending only on its arguments
2261 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2263 You can also use attributes to control memory placement, code
2264 generation options or call/return conventions within the function
2265 being annotated.  Many of these attributes are target-specific.  For
2266 example, many targets support attributes for defining interrupt
2267 handler functions, which typically must follow special register usage
2268 and return conventions.
2270 Function attributes are introduced by the @code{__attribute__} keyword
2271 on a declaration, followed by an attribute specification inside double
2272 parentheses.  You can specify multiple attributes in a declaration by
2273 separating them by commas within the double parentheses or by
2274 immediately following an attribute declaration with another attribute
2275 declaration.  @xref{Attribute Syntax}, for the exact rules on
2276 attribute syntax and placement.
2278 GCC also supports attributes on
2279 variable declarations (@pxref{Variable Attributes}),
2280 labels (@pxref{Label Attributes}),
2281 enumerators (@pxref{Enumerator Attributes}),
2282 statements (@pxref{Statement Attributes}),
2283 and types (@pxref{Type Attributes}).
2285 There is some overlap between the purposes of attributes and pragmas
2286 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2287 found convenient to use @code{__attribute__} to achieve a natural
2288 attachment of attributes to their corresponding declarations, whereas
2289 @code{#pragma} is of use for compatibility with other compilers
2290 or constructs that do not naturally form part of the grammar.
2292 In addition to the attributes documented here,
2293 GCC plugins may provide their own attributes.
2295 @menu
2296 * Common Function Attributes::
2297 * AArch64 Function Attributes::
2298 * ARC Function Attributes::
2299 * ARM Function Attributes::
2300 * AVR Function Attributes::
2301 * Blackfin Function Attributes::
2302 * CR16 Function Attributes::
2303 * Epiphany Function Attributes::
2304 * H8/300 Function Attributes::
2305 * IA-64 Function Attributes::
2306 * M32C Function Attributes::
2307 * M32R/D Function Attributes::
2308 * m68k Function Attributes::
2309 * MCORE Function Attributes::
2310 * MeP Function Attributes::
2311 * MicroBlaze Function Attributes::
2312 * Microsoft Windows Function Attributes::
2313 * MIPS Function Attributes::
2314 * MSP430 Function Attributes::
2315 * NDS32 Function Attributes::
2316 * Nios II Function Attributes::
2317 * Nvidia PTX Function Attributes::
2318 * PowerPC Function Attributes::
2319 * RL78 Function Attributes::
2320 * RX Function Attributes::
2321 * S/390 Function Attributes::
2322 * SH Function Attributes::
2323 * SPU Function Attributes::
2324 * Symbian OS Function Attributes::
2325 * V850 Function Attributes::
2326 * Visium Function Attributes::
2327 * x86 Function Attributes::
2328 * Xstormy16 Function Attributes::
2329 @end menu
2331 @node Common Function Attributes
2332 @subsection Common Function Attributes
2334 The following attributes are supported on most targets.
2336 @table @code
2337 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2339 @item alias ("@var{target}")
2340 @cindex @code{alias} function attribute
2341 The @code{alias} attribute causes the declaration to be emitted as an
2342 alias for another symbol, which must be specified.  For instance,
2344 @smallexample
2345 void __f () @{ /* @r{Do something.} */; @}
2346 void f () __attribute__ ((weak, alias ("__f")));
2347 @end smallexample
2349 @noindent
2350 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2351 mangled name for the target must be used.  It is an error if @samp{__f}
2352 is not defined in the same translation unit.
2354 This attribute requires assembler and object file support,
2355 and may not be available on all targets.
2357 @item aligned (@var{alignment})
2358 @cindex @code{aligned} function attribute
2359 This attribute specifies a minimum alignment for the function,
2360 measured in bytes.
2362 You cannot use this attribute to decrease the alignment of a function,
2363 only to increase it.  However, when you explicitly specify a function
2364 alignment this overrides the effect of the
2365 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2366 function.
2368 Note that the effectiveness of @code{aligned} attributes may be
2369 limited by inherent limitations in your linker.  On many systems, the
2370 linker is only able to arrange for functions to be aligned up to a
2371 certain maximum alignment.  (For some linkers, the maximum supported
2372 alignment may be very very small.)  See your linker documentation for
2373 further information.
2375 The @code{aligned} attribute can also be used for variables and fields
2376 (@pxref{Variable Attributes}.)
2378 @item alloc_align
2379 @cindex @code{alloc_align} function attribute
2380 The @code{alloc_align} attribute is used to tell the compiler that the
2381 function return value points to memory, where the returned pointer minimum
2382 alignment is given by one of the functions parameters.  GCC uses this
2383 information to improve pointer alignment analysis.
2385 The function parameter denoting the allocated alignment is specified by
2386 one integer argument, whose number is the argument of the attribute.
2387 Argument numbering starts at one.
2389 For instance,
2391 @smallexample
2392 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2393 @end smallexample
2395 @noindent
2396 declares that @code{my_memalign} returns memory with minimum alignment
2397 given by parameter 1.
2399 @item alloc_size
2400 @cindex @code{alloc_size} function attribute
2401 The @code{alloc_size} attribute is used to tell the compiler that the
2402 function return value points to memory, where the size is given by
2403 one or two of the functions parameters.  GCC uses this
2404 information to improve the correctness of @code{__builtin_object_size}.
2406 The function parameter(s) denoting the allocated size are specified by
2407 one or two integer arguments supplied to the attribute.  The allocated size
2408 is either the value of the single function argument specified or the product
2409 of the two function arguments specified.  Argument numbering starts at
2410 one.
2412 For instance,
2414 @smallexample
2415 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2416 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2417 @end smallexample
2419 @noindent
2420 declares that @code{my_calloc} returns memory of the size given by
2421 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2422 of the size given by parameter 2.
2424 @item always_inline
2425 @cindex @code{always_inline} function attribute
2426 Generally, functions are not inlined unless optimization is specified.
2427 For functions declared inline, this attribute inlines the function
2428 independent of any restrictions that otherwise apply to inlining.
2429 Failure to inline such a function is diagnosed as an error.
2430 Note that if such a function is called indirectly the compiler may
2431 or may not inline it depending on optimization level and a failure
2432 to inline an indirect call may or may not be diagnosed.
2434 @item artificial
2435 @cindex @code{artificial} function attribute
2436 This attribute is useful for small inline wrappers that if possible
2437 should appear during debugging as a unit.  Depending on the debug
2438 info format it either means marking the function as artificial
2439 or using the caller location for all instructions within the inlined
2440 body.
2442 @item assume_aligned
2443 @cindex @code{assume_aligned} function attribute
2444 The @code{assume_aligned} attribute is used to tell the compiler that the
2445 function return value points to memory, where the returned pointer minimum
2446 alignment is given by the first argument.
2447 If the attribute has two arguments, the second argument is misalignment offset.
2449 For instance
2451 @smallexample
2452 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2453 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2454 @end smallexample
2456 @noindent
2457 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2458 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2459 to 8.
2461 @item bnd_instrument
2462 @cindex @code{bnd_instrument} function attribute
2463 The @code{bnd_instrument} attribute on functions is used to inform the
2464 compiler that the function should be instrumented when compiled
2465 with the @option{-fchkp-instrument-marked-only} option.
2467 @item bnd_legacy
2468 @cindex @code{bnd_legacy} function attribute
2469 @cindex Pointer Bounds Checker attributes
2470 The @code{bnd_legacy} attribute on functions is used to inform the
2471 compiler that the function should not be instrumented when compiled
2472 with the @option{-fcheck-pointer-bounds} option.
2474 @item cold
2475 @cindex @code{cold} function attribute
2476 The @code{cold} attribute on functions is used to inform the compiler that
2477 the function is unlikely to be executed.  The function is optimized for
2478 size rather than speed and on many targets it is placed into a special
2479 subsection of the text section so all cold functions appear close together,
2480 improving code locality of non-cold parts of program.  The paths leading
2481 to calls of cold functions within code are marked as unlikely by the branch
2482 prediction mechanism.  It is thus useful to mark functions used to handle
2483 unlikely conditions, such as @code{perror}, as cold to improve optimization
2484 of hot functions that do call marked functions in rare occasions.
2486 When profile feedback is available, via @option{-fprofile-use}, cold functions
2487 are automatically detected and this attribute is ignored.
2489 @item const
2490 @cindex @code{const} function attribute
2491 @cindex functions that have no side effects
2492 Many functions do not examine any values except their arguments, and
2493 have no effects except the return value.  Basically this is just slightly
2494 more strict class than the @code{pure} attribute below, since function is not
2495 allowed to read global memory.
2497 @cindex pointer arguments
2498 Note that a function that has pointer arguments and examines the data
2499 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2500 function that calls a non-@code{const} function usually must not be
2501 @code{const}.  It does not make sense for a @code{const} function to
2502 return @code{void}.
2504 @item constructor
2505 @itemx destructor
2506 @itemx constructor (@var{priority})
2507 @itemx destructor (@var{priority})
2508 @cindex @code{constructor} function attribute
2509 @cindex @code{destructor} function attribute
2510 The @code{constructor} attribute causes the function to be called
2511 automatically before execution enters @code{main ()}.  Similarly, the
2512 @code{destructor} attribute causes the function to be called
2513 automatically after @code{main ()} completes or @code{exit ()} is
2514 called.  Functions with these attributes are useful for
2515 initializing data that is used implicitly during the execution of
2516 the program.
2518 You may provide an optional integer priority to control the order in
2519 which constructor and destructor functions are run.  A constructor
2520 with a smaller priority number runs before a constructor with a larger
2521 priority number; the opposite relationship holds for destructors.  So,
2522 if you have a constructor that allocates a resource and a destructor
2523 that deallocates the same resource, both functions typically have the
2524 same priority.  The priorities for constructor and destructor
2525 functions are the same as those specified for namespace-scope C++
2526 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2527 constructors for C++ objects with static storage duration and functions
2528 decorated with attribute @code{constructor} are invoked is unspecified.
2529 In mixed declarations, attribute @code{init_priority} can be used to
2530 impose a specific ordering.
2532 @item deprecated
2533 @itemx deprecated (@var{msg})
2534 @cindex @code{deprecated} function attribute
2535 The @code{deprecated} attribute results in a warning if the function
2536 is used anywhere in the source file.  This is useful when identifying
2537 functions that are expected to be removed in a future version of a
2538 program.  The warning also includes the location of the declaration
2539 of the deprecated function, to enable users to easily find further
2540 information about why the function is deprecated, or what they should
2541 do instead.  Note that the warnings only occurs for uses:
2543 @smallexample
2544 int old_fn () __attribute__ ((deprecated));
2545 int old_fn ();
2546 int (*fn_ptr)() = old_fn;
2547 @end smallexample
2549 @noindent
2550 results in a warning on line 3 but not line 2.  The optional @var{msg}
2551 argument, which must be a string, is printed in the warning if
2552 present.
2554 The @code{deprecated} attribute can also be used for variables and
2555 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2557 @item error ("@var{message}")
2558 @itemx warning ("@var{message}")
2559 @cindex @code{error} function attribute
2560 @cindex @code{warning} function attribute
2561 If the @code{error} or @code{warning} attribute 
2562 is used on a function declaration and a call to such a function
2563 is not eliminated through dead code elimination or other optimizations, 
2564 an error or warning (respectively) that includes @var{message} is diagnosed.  
2565 This is useful
2566 for compile-time checking, especially together with @code{__builtin_constant_p}
2567 and inline functions where checking the inline function arguments is not
2568 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2570 While it is possible to leave the function undefined and thus invoke
2571 a link failure (to define the function with
2572 a message in @code{.gnu.warning*} section),
2573 when using these attributes the problem is diagnosed
2574 earlier and with exact location of the call even in presence of inline
2575 functions or when not emitting debugging information.
2577 @item externally_visible
2578 @cindex @code{externally_visible} function attribute
2579 This attribute, attached to a global variable or function, nullifies
2580 the effect of the @option{-fwhole-program} command-line option, so the
2581 object remains visible outside the current compilation unit.
2583 If @option{-fwhole-program} is used together with @option{-flto} and 
2584 @command{gold} is used as the linker plugin, 
2585 @code{externally_visible} attributes are automatically added to functions 
2586 (not variable yet due to a current @command{gold} issue) 
2587 that are accessed outside of LTO objects according to resolution file
2588 produced by @command{gold}.
2589 For other linkers that cannot generate resolution file,
2590 explicit @code{externally_visible} attributes are still necessary.
2592 @item flatten
2593 @cindex @code{flatten} function attribute
2594 Generally, inlining into a function is limited.  For a function marked with
2595 this attribute, every call inside this function is inlined, if possible.
2596 Whether the function itself is considered for inlining depends on its size and
2597 the current inlining parameters.
2599 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2600 @cindex @code{format} function attribute
2601 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2602 @opindex Wformat
2603 The @code{format} attribute specifies that a function takes @code{printf},
2604 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2605 should be type-checked against a format string.  For example, the
2606 declaration:
2608 @smallexample
2609 extern int
2610 my_printf (void *my_object, const char *my_format, ...)
2611       __attribute__ ((format (printf, 2, 3)));
2612 @end smallexample
2614 @noindent
2615 causes the compiler to check the arguments in calls to @code{my_printf}
2616 for consistency with the @code{printf} style format string argument
2617 @code{my_format}.
2619 The parameter @var{archetype} determines how the format string is
2620 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2621 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2622 @code{strfmon}.  (You can also use @code{__printf__},
2623 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2624 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2625 @code{ms_strftime} are also present.
2626 @var{archetype} values such as @code{printf} refer to the formats accepted
2627 by the system's C runtime library,
2628 while values prefixed with @samp{gnu_} always refer
2629 to the formats accepted by the GNU C Library.  On Microsoft Windows
2630 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2631 @file{msvcrt.dll} library.
2632 The parameter @var{string-index}
2633 specifies which argument is the format string argument (starting
2634 from 1), while @var{first-to-check} is the number of the first
2635 argument to check against the format string.  For functions
2636 where the arguments are not available to be checked (such as
2637 @code{vprintf}), specify the third parameter as zero.  In this case the
2638 compiler only checks the format string for consistency.  For
2639 @code{strftime} formats, the third parameter is required to be zero.
2640 Since non-static C++ methods have an implicit @code{this} argument, the
2641 arguments of such methods should be counted from two, not one, when
2642 giving values for @var{string-index} and @var{first-to-check}.
2644 In the example above, the format string (@code{my_format}) is the second
2645 argument of the function @code{my_print}, and the arguments to check
2646 start with the third argument, so the correct parameters for the format
2647 attribute are 2 and 3.
2649 @opindex ffreestanding
2650 @opindex fno-builtin
2651 The @code{format} attribute allows you to identify your own functions
2652 that take format strings as arguments, so that GCC can check the
2653 calls to these functions for errors.  The compiler always (unless
2654 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2655 for the standard library functions @code{printf}, @code{fprintf},
2656 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2657 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2658 warnings are requested (using @option{-Wformat}), so there is no need to
2659 modify the header file @file{stdio.h}.  In C99 mode, the functions
2660 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2661 @code{vsscanf} are also checked.  Except in strictly conforming C
2662 standard modes, the X/Open function @code{strfmon} is also checked as
2663 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2664 @xref{C Dialect Options,,Options Controlling C Dialect}.
2666 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2667 recognized in the same context.  Declarations including these format attributes
2668 are parsed for correct syntax, however the result of checking of such format
2669 strings is not yet defined, and is not carried out by this version of the
2670 compiler.
2672 The target may also provide additional types of format checks.
2673 @xref{Target Format Checks,,Format Checks Specific to Particular
2674 Target Machines}.
2676 @item format_arg (@var{string-index})
2677 @cindex @code{format_arg} function attribute
2678 @opindex Wformat-nonliteral
2679 The @code{format_arg} attribute specifies that a function takes a format
2680 string for a @code{printf}, @code{scanf}, @code{strftime} or
2681 @code{strfmon} style function and modifies it (for example, to translate
2682 it into another language), so the result can be passed to a
2683 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2684 function (with the remaining arguments to the format function the same
2685 as they would have been for the unmodified string).  For example, the
2686 declaration:
2688 @smallexample
2689 extern char *
2690 my_dgettext (char *my_domain, const char *my_format)
2691       __attribute__ ((format_arg (2)));
2692 @end smallexample
2694 @noindent
2695 causes the compiler to check the arguments in calls to a @code{printf},
2696 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2697 format string argument is a call to the @code{my_dgettext} function, for
2698 consistency with the format string argument @code{my_format}.  If the
2699 @code{format_arg} attribute had not been specified, all the compiler
2700 could tell in such calls to format functions would be that the format
2701 string argument is not constant; this would generate a warning when
2702 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2703 without the attribute.
2705 The parameter @var{string-index} specifies which argument is the format
2706 string argument (starting from one).  Since non-static C++ methods have
2707 an implicit @code{this} argument, the arguments of such methods should
2708 be counted from two.
2710 The @code{format_arg} attribute allows you to identify your own
2711 functions that modify format strings, so that GCC can check the
2712 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2713 type function whose operands are a call to one of your own function.
2714 The compiler always treats @code{gettext}, @code{dgettext}, and
2715 @code{dcgettext} in this manner except when strict ISO C support is
2716 requested by @option{-ansi} or an appropriate @option{-std} option, or
2717 @option{-ffreestanding} or @option{-fno-builtin}
2718 is used.  @xref{C Dialect Options,,Options
2719 Controlling C Dialect}.
2721 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2722 @code{NSString} reference for compatibility with the @code{format} attribute
2723 above.
2725 The target may also allow additional types in @code{format-arg} attributes.
2726 @xref{Target Format Checks,,Format Checks Specific to Particular
2727 Target Machines}.
2729 @item gnu_inline
2730 @cindex @code{gnu_inline} function attribute
2731 This attribute should be used with a function that is also declared
2732 with the @code{inline} keyword.  It directs GCC to treat the function
2733 as if it were defined in gnu90 mode even when compiling in C99 or
2734 gnu99 mode.
2736 If the function is declared @code{extern}, then this definition of the
2737 function is used only for inlining.  In no case is the function
2738 compiled as a standalone function, not even if you take its address
2739 explicitly.  Such an address becomes an external reference, as if you
2740 had only declared the function, and had not defined it.  This has
2741 almost the effect of a macro.  The way to use this is to put a
2742 function definition in a header file with this attribute, and put
2743 another copy of the function, without @code{extern}, in a library
2744 file.  The definition in the header file causes most calls to the
2745 function to be inlined.  If any uses of the function remain, they
2746 refer to the single copy in the library.  Note that the two
2747 definitions of the functions need not be precisely the same, although
2748 if they do not have the same effect your program may behave oddly.
2750 In C, if the function is neither @code{extern} nor @code{static}, then
2751 the function is compiled as a standalone function, as well as being
2752 inlined where possible.
2754 This is how GCC traditionally handled functions declared
2755 @code{inline}.  Since ISO C99 specifies a different semantics for
2756 @code{inline}, this function attribute is provided as a transition
2757 measure and as a useful feature in its own right.  This attribute is
2758 available in GCC 4.1.3 and later.  It is available if either of the
2759 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2760 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2761 Function is As Fast As a Macro}.
2763 In C++, this attribute does not depend on @code{extern} in any way,
2764 but it still requires the @code{inline} keyword to enable its special
2765 behavior.
2767 @item hot
2768 @cindex @code{hot} function attribute
2769 The @code{hot} attribute on a function is used to inform the compiler that
2770 the function is a hot spot of the compiled program.  The function is
2771 optimized more aggressively and on many targets it is placed into a special
2772 subsection of the text section so all hot functions appear close together,
2773 improving locality.
2775 When profile feedback is available, via @option{-fprofile-use}, hot functions
2776 are automatically detected and this attribute is ignored.
2778 @item ifunc ("@var{resolver}")
2779 @cindex @code{ifunc} function attribute
2780 @cindex indirect functions
2781 @cindex functions that are dynamically resolved
2782 The @code{ifunc} attribute is used to mark a function as an indirect
2783 function using the STT_GNU_IFUNC symbol type extension to the ELF
2784 standard.  This allows the resolution of the symbol value to be
2785 determined dynamically at load time, and an optimized version of the
2786 routine to be selected for the particular processor or other system
2787 characteristics determined then.  To use this attribute, first define
2788 the implementation functions available, and a resolver function that
2789 returns a pointer to the selected implementation function.  The
2790 implementation functions' declarations must match the API of the
2791 function being implemented.  The resolver should be declared to
2792 be a function taking no arguments and returning a pointer to
2793 a function of the same type as the implementation.  For example:
2795 @smallexample
2796 void *my_memcpy (void *dst, const void *src, size_t len)
2798   @dots{}
2799   return dst;
2802 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2804   return my_memcpy; // we will just always select this routine
2806 @end smallexample
2808 @noindent
2809 The exported header file declaring the function the user calls would
2810 contain:
2812 @smallexample
2813 extern void *memcpy (void *, const void *, size_t);
2814 @end smallexample
2816 @noindent
2817 allowing the user to call @code{memcpy} as a regular function, unaware of
2818 the actual implementation.  Finally, the indirect function needs to be
2819 defined in the same translation unit as the resolver function:
2821 @smallexample
2822 void *memcpy (void *, const void *, size_t)
2823      __attribute__ ((ifunc ("resolve_memcpy")));
2824 @end smallexample
2826 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2827 of the resolver function.  A C++ resolver for a non-static member function
2828 of class @code{C} should be declared to return a pointer to a non-member
2829 function taking pointer to @code{C} as the first argument, followed by
2830 the same arguments as of the implementation function.  G++ checks
2831 the signatures of the two functions and issues
2832 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2833 for the necessary cast from a pointer to the implementation member function
2834 to the type of the corresponding non-member function use
2835 the @option{-Wno-pmf-conversions} option.  For example:
2837 @smallexample
2838 class S
2840 private:
2841   int debug_impl (int);
2842   int optimized_impl (int);
2844   typedef int Func (S*, int);
2846   static Func* resolver ();
2847 public:
2849   int interface (int);
2852 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2853 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2855 S::Func* S::resolver ()
2857   int (S::*pimpl) (int)
2858     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2860   // Cast triggers -Wno-pmf-conversions.
2861   return reinterpret_cast<Func*>(pimpl);
2864 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2865 @end smallexample
2867 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2868 and GNU C Library version 2.11.1 are required to use this feature.
2870 @item interrupt
2871 @itemx interrupt_handler
2872 Many GCC back ends support attributes to indicate that a function is
2873 an interrupt handler, which tells the compiler to generate function
2874 entry and exit sequences that differ from those from regular
2875 functions.  The exact syntax and behavior are target-specific;
2876 refer to the following subsections for details.
2878 @item leaf
2879 @cindex @code{leaf} function attribute
2880 Calls to external functions with this attribute must return to the
2881 current compilation unit only by return or by exception handling.  In
2882 particular, a leaf function is not allowed to invoke callback functions
2883 passed to it from the current compilation unit, directly call functions
2884 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2885 might still call functions from other compilation units and thus they
2886 are not necessarily leaf in the sense that they contain no function
2887 calls at all.
2889 The attribute is intended for library functions to improve dataflow
2890 analysis.  The compiler takes the hint that any data not escaping the
2891 current compilation unit cannot be used or modified by the leaf
2892 function.  For example, the @code{sin} function is a leaf function, but
2893 @code{qsort} is not.
2895 Note that leaf functions might indirectly run a signal handler defined
2896 in the current compilation unit that uses static variables.  Similarly,
2897 when lazy symbol resolution is in effect, leaf functions might invoke
2898 indirect functions whose resolver function or implementation function is
2899 defined in the current compilation unit and uses static variables.  There
2900 is no standard-compliant way to write such a signal handler, resolver
2901 function, or implementation function, and the best that you can do is to
2902 remove the @code{leaf} attribute or mark all such static variables
2903 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2904 interposition, care should be taken that functions defined in the
2905 current compilation unit do not unexpectedly interpose other symbols
2906 based on the defined standards mode and defined feature test macros;
2907 otherwise an inadvertent callback would be added.
2909 The attribute has no effect on functions defined within the current
2910 compilation unit.  This is to allow easy merging of multiple compilation
2911 units into one, for example, by using the link-time optimization.  For
2912 this reason the attribute is not allowed on types to annotate indirect
2913 calls.
2915 @item malloc
2916 @cindex @code{malloc} function attribute
2917 @cindex functions that behave like malloc
2918 This tells the compiler that a function is @code{malloc}-like, i.e.,
2919 that the pointer @var{P} returned by the function cannot alias any
2920 other pointer valid when the function returns, and moreover no
2921 pointers to valid objects occur in any storage addressed by @var{P}.
2923 Using this attribute can improve optimization.  Functions like
2924 @code{malloc} and @code{calloc} have this property because they return
2925 a pointer to uninitialized or zeroed-out storage.  However, functions
2926 like @code{realloc} do not have this property, as they can return a
2927 pointer to storage containing pointers.
2929 @item no_icf
2930 @cindex @code{no_icf} function attribute
2931 This function attribute prevents a functions from being merged with another
2932 semantically equivalent function.
2934 @item no_instrument_function
2935 @cindex @code{no_instrument_function} function attribute
2936 @opindex finstrument-functions
2937 If @option{-finstrument-functions} is given, profiling function calls are
2938 generated at entry and exit of most user-compiled functions.
2939 Functions with this attribute are not so instrumented.
2941 @item no_profile_instrument_function
2942 @cindex @code{no_profile_instrument_function} function attribute
2943 The @code{no_profile_instrument_function} attribute on functions is used
2944 to inform the compiler that it should not process any profile feedback based
2945 optimization code instrumentation.
2947 @item no_reorder
2948 @cindex @code{no_reorder} function attribute
2949 Do not reorder functions or variables marked @code{no_reorder}
2950 against each other or top level assembler statements the executable.
2951 The actual order in the program will depend on the linker command
2952 line. Static variables marked like this are also not removed.
2953 This has a similar effect
2954 as the @option{-fno-toplevel-reorder} option, but only applies to the
2955 marked symbols.
2957 @item no_sanitize ("@var{sanitize_option}")
2958 @cindex @code{no_sanitize} function attribute
2959 The @code{no_sanitize} attribute on functions is used
2960 to inform the compiler that it should not do sanitization of all options
2961 mentioned in @var{sanitize_option}.  A list of values acceptable by
2962 @option{-fsanitize} option can be provided.
2964 @smallexample
2965 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2966 f () @{ /* @r{Do something.} */; @}
2967 @end smallexample
2969 @item no_sanitize_address
2970 @itemx no_address_safety_analysis
2971 @cindex @code{no_sanitize_address} function attribute
2972 The @code{no_sanitize_address} attribute on functions is used
2973 to inform the compiler that it should not instrument memory accesses
2974 in the function when compiling with the @option{-fsanitize=address} option.
2975 The @code{no_address_safety_analysis} is a deprecated alias of the
2976 @code{no_sanitize_address} attribute, new code should use
2977 @code{no_sanitize_address}.
2979 @item no_sanitize_thread
2980 @cindex @code{no_sanitize_thread} function attribute
2981 The @code{no_sanitize_thread} attribute on functions is used
2982 to inform the compiler that it should not instrument memory accesses
2983 in the function when compiling with the @option{-fsanitize=thread} option.
2985 @item no_sanitize_undefined
2986 @cindex @code{no_sanitize_undefined} function attribute
2987 The @code{no_sanitize_undefined} attribute on functions is used
2988 to inform the compiler that it should not check for undefined behavior
2989 in the function when compiling with the @option{-fsanitize=undefined} option.
2991 @item no_split_stack
2992 @cindex @code{no_split_stack} function attribute
2993 @opindex fsplit-stack
2994 If @option{-fsplit-stack} is given, functions have a small
2995 prologue which decides whether to split the stack.  Functions with the
2996 @code{no_split_stack} attribute do not have that prologue, and thus
2997 may run with only a small amount of stack space available.
2999 @item no_stack_limit
3000 @cindex @code{no_stack_limit} function attribute
3001 This attribute locally overrides the @option{-fstack-limit-register}
3002 and @option{-fstack-limit-symbol} command-line options; it has the effect
3003 of disabling stack limit checking in the function it applies to.
3005 @item noclone
3006 @cindex @code{noclone} function attribute
3007 This function attribute prevents a function from being considered for
3008 cloning---a mechanism that produces specialized copies of functions
3009 and which is (currently) performed by interprocedural constant
3010 propagation.
3012 @item noinline
3013 @cindex @code{noinline} function attribute
3014 This function attribute prevents a function from being considered for
3015 inlining.
3016 @c Don't enumerate the optimizations by name here; we try to be
3017 @c future-compatible with this mechanism.
3018 If the function does not have side-effects, there are optimizations
3019 other than inlining that cause function calls to be optimized away,
3020 although the function call is live.  To keep such calls from being
3021 optimized away, put
3022 @smallexample
3023 asm ("");
3024 @end smallexample
3026 @noindent
3027 (@pxref{Extended Asm}) in the called function, to serve as a special
3028 side-effect.
3030 @item noipa
3031 @cindex @code{noipa} function attribute
3032 Disable interprocedural optimizations between the function with this
3033 attribute and its callers, as if the body of the function is not available
3034 when optimizing callers and the callers are unavailable when optimizing
3035 the body.  This attribute implies @code{noinline}, @code{noclone} and
3036 @code{no_icf} attributes.    However, this attribute is not equivalent
3037 to a combination of other attributes, because its purpose is to suppress
3038 existing and future optimizations employing interprocedural analysis,
3039 including those that do not have an attribute suitable for disabling
3040 them individually.  This attribute is supported mainly for the purpose
3041 of testing the compiler.
3043 @item nonnull (@var{arg-index}, @dots{})
3044 @cindex @code{nonnull} function attribute
3045 @cindex functions with non-null pointer arguments
3046 The @code{nonnull} attribute specifies that some function parameters should
3047 be non-null pointers.  For instance, the declaration:
3049 @smallexample
3050 extern void *
3051 my_memcpy (void *dest, const void *src, size_t len)
3052         __attribute__((nonnull (1, 2)));
3053 @end smallexample
3055 @noindent
3056 causes the compiler to check that, in calls to @code{my_memcpy},
3057 arguments @var{dest} and @var{src} are non-null.  If the compiler
3058 determines that a null pointer is passed in an argument slot marked
3059 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3060 is issued.  The compiler may also choose to make optimizations based
3061 on the knowledge that certain function arguments will never be null.
3063 If no argument index list is given to the @code{nonnull} attribute,
3064 all pointer arguments are marked as non-null.  To illustrate, the
3065 following declaration is equivalent to the previous example:
3067 @smallexample
3068 extern void *
3069 my_memcpy (void *dest, const void *src, size_t len)
3070         __attribute__((nonnull));
3071 @end smallexample
3073 @item noplt
3074 @cindex @code{noplt} function attribute
3075 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3076 Calls to functions marked with this attribute in position-independent code
3077 do not use the PLT.
3079 @smallexample
3080 @group
3081 /* Externally defined function foo.  */
3082 int foo () __attribute__ ((noplt));
3085 main (/* @r{@dots{}} */)
3087   /* @r{@dots{}} */
3088   foo ();
3089   /* @r{@dots{}} */
3091 @end group
3092 @end smallexample
3094 The @code{noplt} attribute on function @code{foo}
3095 tells the compiler to assume that
3096 the function @code{foo} is externally defined and that the call to
3097 @code{foo} must avoid the PLT
3098 in position-independent code.
3100 In position-dependent code, a few targets also convert calls to
3101 functions that are marked to not use the PLT to use the GOT instead.
3103 @item noreturn
3104 @cindex @code{noreturn} function attribute
3105 @cindex functions that never return
3106 A few standard library functions, such as @code{abort} and @code{exit},
3107 cannot return.  GCC knows this automatically.  Some programs define
3108 their own functions that never return.  You can declare them
3109 @code{noreturn} to tell the compiler this fact.  For example,
3111 @smallexample
3112 @group
3113 void fatal () __attribute__ ((noreturn));
3115 void
3116 fatal (/* @r{@dots{}} */)
3118   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3119   exit (1);
3121 @end group
3122 @end smallexample
3124 The @code{noreturn} keyword tells the compiler to assume that
3125 @code{fatal} cannot return.  It can then optimize without regard to what
3126 would happen if @code{fatal} ever did return.  This makes slightly
3127 better code.  More importantly, it helps avoid spurious warnings of
3128 uninitialized variables.
3130 The @code{noreturn} keyword does not affect the exceptional path when that
3131 applies: a @code{noreturn}-marked function may still return to the caller
3132 by throwing an exception or calling @code{longjmp}.
3134 Do not assume that registers saved by the calling function are
3135 restored before calling the @code{noreturn} function.
3137 It does not make sense for a @code{noreturn} function to have a return
3138 type other than @code{void}.
3140 @item nothrow
3141 @cindex @code{nothrow} function attribute
3142 The @code{nothrow} attribute is used to inform the compiler that a
3143 function cannot throw an exception.  For example, most functions in
3144 the standard C library can be guaranteed not to throw an exception
3145 with the notable exceptions of @code{qsort} and @code{bsearch} that
3146 take function pointer arguments.
3148 @item optimize
3149 @cindex @code{optimize} function attribute
3150 The @code{optimize} attribute is used to specify that a function is to
3151 be compiled with different optimization options than specified on the
3152 command line.  Arguments can either be numbers or strings.  Numbers
3153 are assumed to be an optimization level.  Strings that begin with
3154 @code{O} are assumed to be an optimization option, while other options
3155 are assumed to be used with a @code{-f} prefix.  You can also use the
3156 @samp{#pragma GCC optimize} pragma to set the optimization options
3157 that affect more than one function.
3158 @xref{Function Specific Option Pragmas}, for details about the
3159 @samp{#pragma GCC optimize} pragma.
3161 This attribute should be used for debugging purposes only.  It is not
3162 suitable in production code.
3164 @item patchable_function_entry
3165 @cindex @code{patchable_function_entry} function attribute
3166 @cindex extra NOP instructions at the function entry point
3167 In case the target's text segment can be made writable at run time by
3168 any means, padding the function entry with a number of NOPs can be
3169 used to provide a universal tool for instrumentation.
3171 The @code{patchable_function_entry} function attribute can be used to
3172 change the number of NOPs to any desired value.  The two-value syntax
3173 is the same as for the command-line switch
3174 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3175 the function entry point before the @var{M}th NOP instruction.
3176 @var{M} defaults to 0 if omitted e.g. function entry point is before
3177 the first NOP.
3179 If patchable function entries are enabled globally using the command-line
3180 option @option{-fpatchable-function-entry=N,M}, then you must disable
3181 instrumentation on all functions that are part of the instrumentation
3182 framework with the attribute @code{patchable_function_entry (0)}
3183 to prevent recursion.
3185 @item pure
3186 @cindex @code{pure} function attribute
3187 @cindex functions that have no side effects
3188 Many functions have no effects except the return value and their
3189 return value depends only on the parameters and/or global variables.
3190 Such a function can be subject
3191 to common subexpression elimination and loop optimization just as an
3192 arithmetic operator would be.  These functions should be declared
3193 with the attribute @code{pure}.  For example,
3195 @smallexample
3196 int square (int) __attribute__ ((pure));
3197 @end smallexample
3199 @noindent
3200 says that the hypothetical function @code{square} is safe to call
3201 fewer times than the program says.
3203 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3204 Interesting non-pure functions are functions with infinite loops or those
3205 depending on volatile memory or other system resource, that may change between
3206 two consecutive calls (such as @code{feof} in a multithreading environment).
3208 @item returns_nonnull
3209 @cindex @code{returns_nonnull} function attribute
3210 The @code{returns_nonnull} attribute specifies that the function
3211 return value should be a non-null pointer.  For instance, the declaration:
3213 @smallexample
3214 extern void *
3215 mymalloc (size_t len) __attribute__((returns_nonnull));
3216 @end smallexample
3218 @noindent
3219 lets the compiler optimize callers based on the knowledge
3220 that the return value will never be null.
3222 @item returns_twice
3223 @cindex @code{returns_twice} function attribute
3224 @cindex functions that return more than once
3225 The @code{returns_twice} attribute tells the compiler that a function may
3226 return more than one time.  The compiler ensures that all registers
3227 are dead before calling such a function and emits a warning about
3228 the variables that may be clobbered after the second return from the
3229 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3230 The @code{longjmp}-like counterpart of such function, if any, might need
3231 to be marked with the @code{noreturn} attribute.
3233 @item section ("@var{section-name}")
3234 @cindex @code{section} function attribute
3235 @cindex functions in arbitrary sections
3236 Normally, the compiler places the code it generates in the @code{text} section.
3237 Sometimes, however, you need additional sections, or you need certain
3238 particular functions to appear in special sections.  The @code{section}
3239 attribute specifies that a function lives in a particular section.
3240 For example, the declaration:
3242 @smallexample
3243 extern void foobar (void) __attribute__ ((section ("bar")));
3244 @end smallexample
3246 @noindent
3247 puts the function @code{foobar} in the @code{bar} section.
3249 Some file formats do not support arbitrary sections so the @code{section}
3250 attribute is not available on all platforms.
3251 If you need to map the entire contents of a module to a particular
3252 section, consider using the facilities of the linker instead.
3254 @item sentinel
3255 @cindex @code{sentinel} function attribute
3256 This function attribute ensures that a parameter in a function call is
3257 an explicit @code{NULL}.  The attribute is only valid on variadic
3258 functions.  By default, the sentinel is located at position zero, the
3259 last parameter of the function call.  If an optional integer position
3260 argument P is supplied to the attribute, the sentinel must be located at
3261 position P counting backwards from the end of the argument list.
3263 @smallexample
3264 __attribute__ ((sentinel))
3265 is equivalent to
3266 __attribute__ ((sentinel(0)))
3267 @end smallexample
3269 The attribute is automatically set with a position of 0 for the built-in
3270 functions @code{execl} and @code{execlp}.  The built-in function
3271 @code{execle} has the attribute set with a position of 1.
3273 A valid @code{NULL} in this context is defined as zero with any pointer
3274 type.  If your system defines the @code{NULL} macro with an integer type
3275 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3276 with a copy that redefines NULL appropriately.
3278 The warnings for missing or incorrect sentinels are enabled with
3279 @option{-Wformat}.
3281 @item simd
3282 @itemx simd("@var{mask}")
3283 @cindex @code{simd} function attribute
3284 This attribute enables creation of one or more function versions that
3285 can process multiple arguments using SIMD instructions from a
3286 single invocation.  Specifying this attribute allows compiler to
3287 assume that such versions are available at link time (provided
3288 in the same or another translation unit).  Generated versions are
3289 target-dependent and described in the corresponding Vector ABI document.  For
3290 x86_64 target this document can be found
3291 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3293 The optional argument @var{mask} may have the value
3294 @code{notinbranch} or @code{inbranch},
3295 and instructs the compiler to generate non-masked or masked
3296 clones correspondingly. By default, all clones are generated.
3298 The attribute should not be used together with Cilk Plus @code{vector}
3299 attribute on the same function.
3301 If the attribute is specified and @code{#pragma omp declare simd} is
3302 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3303 switch is specified, then the attribute is ignored.
3305 @item stack_protect
3306 @cindex @code{stack_protect} function attribute
3307 This attribute adds stack protection code to the function if 
3308 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3309 or @option{-fstack-protector-explicit} are set.
3311 @item target (@var{options})
3312 @cindex @code{target} function attribute
3313 Multiple target back ends implement the @code{target} attribute
3314 to specify that a function is to
3315 be compiled with different target options than specified on the
3316 command line.  This can be used for instance to have functions
3317 compiled with a different ISA (instruction set architecture) than the
3318 default.  You can also use the @samp{#pragma GCC target} pragma to set
3319 more than one function to be compiled with specific target options.
3320 @xref{Function Specific Option Pragmas}, for details about the
3321 @samp{#pragma GCC target} pragma.
3323 For instance, on an x86, you could declare one function with the
3324 @code{target("sse4.1,arch=core2")} attribute and another with
3325 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3326 compiling the first function with @option{-msse4.1} and
3327 @option{-march=core2} options, and the second function with
3328 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3329 to make sure that a function is only invoked on a machine that
3330 supports the particular ISA it is compiled for (for example by using
3331 @code{cpuid} on x86 to determine what feature bits and architecture
3332 family are used).
3334 @smallexample
3335 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3336 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3337 @end smallexample
3339 You can either use multiple
3340 strings separated by commas to specify multiple options,
3341 or separate the options with a comma (@samp{,}) within a single string.
3343 The options supported are specific to each target; refer to @ref{x86
3344 Function Attributes}, @ref{PowerPC Function Attributes},
3345 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3346 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3347 for details.
3349 @item target_clones (@var{options})
3350 @cindex @code{target_clones} function attribute
3351 The @code{target_clones} attribute is used to specify that a function
3352 be cloned into multiple versions compiled with different target options
3353 than specified on the command line.  The supported options and restrictions
3354 are the same as for @code{target} attribute.
3356 For instance, on an x86, you could compile a function with
3357 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3358 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3360 On a PowerPC, you can compile a function with
3361 @code{target_clones("cpu=power9,default")}.  GCC will create two
3362 function clones, one compiled with @option{-mcpu=power9} and another
3363 with the default options.  GCC must be configured to use GLIBC 2.23 or
3364 newer in order to use the @code{target_clones} attribute.
3366 It also creates a resolver function (see
3367 the @code{ifunc} attribute above) that dynamically selects a clone
3368 suitable for current architecture.  The resolver is created only if there
3369 is a usage of a function with @code{target_clones} attribute.
3371 @item unused
3372 @cindex @code{unused} function attribute
3373 This attribute, attached to a function, means that the function is meant
3374 to be possibly unused.  GCC does not produce a warning for this
3375 function.
3377 @item used
3378 @cindex @code{used} function attribute
3379 This attribute, attached to a function, means that code must be emitted
3380 for the function even if it appears that the function is not referenced.
3381 This is useful, for example, when the function is referenced only in
3382 inline assembly.
3384 When applied to a member function of a C++ class template, the
3385 attribute also means that the function is instantiated if the
3386 class itself is instantiated.
3388 @item visibility ("@var{visibility_type}")
3389 @cindex @code{visibility} function attribute
3390 This attribute affects the linkage of the declaration to which it is attached.
3391 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3392 (@pxref{Common Type Attributes}) as well as functions.
3394 There are four supported @var{visibility_type} values: default,
3395 hidden, protected or internal visibility.
3397 @smallexample
3398 void __attribute__ ((visibility ("protected")))
3399 f () @{ /* @r{Do something.} */; @}
3400 int i __attribute__ ((visibility ("hidden")));
3401 @end smallexample
3403 The possible values of @var{visibility_type} correspond to the
3404 visibility settings in the ELF gABI.
3406 @table @code
3407 @c keep this list of visibilities in alphabetical order.
3409 @item default
3410 Default visibility is the normal case for the object file format.
3411 This value is available for the visibility attribute to override other
3412 options that may change the assumed visibility of entities.
3414 On ELF, default visibility means that the declaration is visible to other
3415 modules and, in shared libraries, means that the declared entity may be
3416 overridden.
3418 On Darwin, default visibility means that the declaration is visible to
3419 other modules.
3421 Default visibility corresponds to ``external linkage'' in the language.
3423 @item hidden
3424 Hidden visibility indicates that the entity declared has a new
3425 form of linkage, which we call ``hidden linkage''.  Two
3426 declarations of an object with hidden linkage refer to the same object
3427 if they are in the same shared object.
3429 @item internal
3430 Internal visibility is like hidden visibility, but with additional
3431 processor specific semantics.  Unless otherwise specified by the
3432 psABI, GCC defines internal visibility to mean that a function is
3433 @emph{never} called from another module.  Compare this with hidden
3434 functions which, while they cannot be referenced directly by other
3435 modules, can be referenced indirectly via function pointers.  By
3436 indicating that a function cannot be called from outside the module,
3437 GCC may for instance omit the load of a PIC register since it is known
3438 that the calling function loaded the correct value.
3440 @item protected
3441 Protected visibility is like default visibility except that it
3442 indicates that references within the defining module bind to the
3443 definition in that module.  That is, the declared entity cannot be
3444 overridden by another module.
3446 @end table
3448 All visibilities are supported on many, but not all, ELF targets
3449 (supported when the assembler supports the @samp{.visibility}
3450 pseudo-op).  Default visibility is supported everywhere.  Hidden
3451 visibility is supported on Darwin targets.
3453 The visibility attribute should be applied only to declarations that
3454 would otherwise have external linkage.  The attribute should be applied
3455 consistently, so that the same entity should not be declared with
3456 different settings of the attribute.
3458 In C++, the visibility attribute applies to types as well as functions
3459 and objects, because in C++ types have linkage.  A class must not have
3460 greater visibility than its non-static data member types and bases,
3461 and class members default to the visibility of their class.  Also, a
3462 declaration without explicit visibility is limited to the visibility
3463 of its type.
3465 In C++, you can mark member functions and static member variables of a
3466 class with the visibility attribute.  This is useful if you know a
3467 particular method or static member variable should only be used from
3468 one shared object; then you can mark it hidden while the rest of the
3469 class has default visibility.  Care must be taken to avoid breaking
3470 the One Definition Rule; for example, it is usually not useful to mark
3471 an inline method as hidden without marking the whole class as hidden.
3473 A C++ namespace declaration can also have the visibility attribute.
3475 @smallexample
3476 namespace nspace1 __attribute__ ((visibility ("protected")))
3477 @{ /* @r{Do something.} */; @}
3478 @end smallexample
3480 This attribute applies only to the particular namespace body, not to
3481 other definitions of the same namespace; it is equivalent to using
3482 @samp{#pragma GCC visibility} before and after the namespace
3483 definition (@pxref{Visibility Pragmas}).
3485 In C++, if a template argument has limited visibility, this
3486 restriction is implicitly propagated to the template instantiation.
3487 Otherwise, template instantiations and specializations default to the
3488 visibility of their template.
3490 If both the template and enclosing class have explicit visibility, the
3491 visibility from the template is used.
3493 @item warn_unused_result
3494 @cindex @code{warn_unused_result} function attribute
3495 The @code{warn_unused_result} attribute causes a warning to be emitted
3496 if a caller of the function with this attribute does not use its
3497 return value.  This is useful for functions where not checking
3498 the result is either a security problem or always a bug, such as
3499 @code{realloc}.
3501 @smallexample
3502 int fn () __attribute__ ((warn_unused_result));
3503 int foo ()
3505   if (fn () < 0) return -1;
3506   fn ();
3507   return 0;
3509 @end smallexample
3511 @noindent
3512 results in warning on line 5.
3514 @item weak
3515 @cindex @code{weak} function attribute
3516 The @code{weak} attribute causes the declaration to be emitted as a weak
3517 symbol rather than a global.  This is primarily useful in defining
3518 library functions that can be overridden in user code, though it can
3519 also be used with non-function declarations.  Weak symbols are supported
3520 for ELF targets, and also for a.out targets when using the GNU assembler
3521 and linker.
3523 @item weakref
3524 @itemx weakref ("@var{target}")
3525 @cindex @code{weakref} function attribute
3526 The @code{weakref} attribute marks a declaration as a weak reference.
3527 Without arguments, it should be accompanied by an @code{alias} attribute
3528 naming the target symbol.  Optionally, the @var{target} may be given as
3529 an argument to @code{weakref} itself.  In either case, @code{weakref}
3530 implicitly marks the declaration as @code{weak}.  Without a
3531 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3532 @code{weakref} is equivalent to @code{weak}.
3534 @smallexample
3535 static int x() __attribute__ ((weakref ("y")));
3536 /* is equivalent to... */
3537 static int x() __attribute__ ((weak, weakref, alias ("y")));
3538 /* and to... */
3539 static int x() __attribute__ ((weakref));
3540 static int x() __attribute__ ((alias ("y")));
3541 @end smallexample
3543 A weak reference is an alias that does not by itself require a
3544 definition to be given for the target symbol.  If the target symbol is
3545 only referenced through weak references, then it becomes a @code{weak}
3546 undefined symbol.  If it is directly referenced, however, then such
3547 strong references prevail, and a definition is required for the
3548 symbol, not necessarily in the same translation unit.
3550 The effect is equivalent to moving all references to the alias to a
3551 separate translation unit, renaming the alias to the aliased symbol,
3552 declaring it as weak, compiling the two separate translation units and
3553 performing a reloadable link on them.
3555 At present, a declaration to which @code{weakref} is attached can
3556 only be @code{static}.
3559 @end table
3561 @c This is the end of the target-independent attribute table
3563 @node AArch64 Function Attributes
3564 @subsection AArch64 Function Attributes
3566 The following target-specific function attributes are available for the
3567 AArch64 target.  For the most part, these options mirror the behavior of
3568 similar command-line options (@pxref{AArch64 Options}), but on a
3569 per-function basis.
3571 @table @code
3572 @item general-regs-only
3573 @cindex @code{general-regs-only} function attribute, AArch64
3574 Indicates that no floating-point or Advanced SIMD registers should be
3575 used when generating code for this function.  If the function explicitly
3576 uses floating-point code, then the compiler gives an error.  This is
3577 the same behavior as that of the command-line option
3578 @option{-mgeneral-regs-only}.
3580 @item fix-cortex-a53-835769
3581 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3582 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3583 applied to this function.  To explicitly disable the workaround for this
3584 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3585 This corresponds to the behavior of the command line options
3586 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3588 @item cmodel=
3589 @cindex @code{cmodel=} function attribute, AArch64
3590 Indicates that code should be generated for a particular code model for
3591 this function.  The behavior and permissible arguments are the same as
3592 for the command line option @option{-mcmodel=}.
3594 @item strict-align
3595 @cindex @code{strict-align} function attribute, AArch64
3596 Indicates that the compiler should not assume that unaligned memory references
3597 are handled by the system.  The behavior is the same as for the command-line
3598 option @option{-mstrict-align}.
3600 @item omit-leaf-frame-pointer
3601 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3602 Indicates that the frame pointer should be omitted for a leaf function call.
3603 To keep the frame pointer, the inverse attribute
3604 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3605 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3606 and @option{-mno-omit-leaf-frame-pointer}.
3608 @item tls-dialect=
3609 @cindex @code{tls-dialect=} function attribute, AArch64
3610 Specifies the TLS dialect to use for this function.  The behavior and
3611 permissible arguments are the same as for the command-line option
3612 @option{-mtls-dialect=}.
3614 @item arch=
3615 @cindex @code{arch=} function attribute, AArch64
3616 Specifies the architecture version and architectural extensions to use
3617 for this function.  The behavior and permissible arguments are the same as
3618 for the @option{-march=} command-line option.
3620 @item tune=
3621 @cindex @code{tune=} function attribute, AArch64
3622 Specifies the core for which to tune the performance of this function.
3623 The behavior and permissible arguments are the same as for the @option{-mtune=}
3624 command-line option.
3626 @item cpu=
3627 @cindex @code{cpu=} function attribute, AArch64
3628 Specifies the core for which to tune the performance of this function and also
3629 whose architectural features to use.  The behavior and valid arguments are the
3630 same as for the @option{-mcpu=} command-line option.
3632 @item sign-return-address
3633 @cindex @code{sign-return-address} function attribute, AArch64
3634 Select the function scope on which return address signing will be applied.  The
3635 behavior and permissible arguments are the same as for the command-line option
3636 @option{-msign-return-address=}.  The default value is @code{none}.
3638 @end table
3640 The above target attributes can be specified as follows:
3642 @smallexample
3643 __attribute__((target("@var{attr-string}")))
3645 f (int a)
3647   return a + 5;
3649 @end smallexample
3651 where @code{@var{attr-string}} is one of the attribute strings specified above.
3653 Additionally, the architectural extension string may be specified on its
3654 own.  This can be used to turn on and off particular architectural extensions
3655 without having to specify a particular architecture version or core.  Example:
3657 @smallexample
3658 __attribute__((target("+crc+nocrypto")))
3660 foo (int a)
3662   return a + 5;
3664 @end smallexample
3666 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3667 extension and disables the @code{crypto} extension for the function @code{foo}
3668 without modifying an existing @option{-march=} or @option{-mcpu} option.
3670 Multiple target function attributes can be specified by separating them with
3671 a comma.  For example:
3672 @smallexample
3673 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3675 foo (int a)
3677   return a + 5;
3679 @end smallexample
3681 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3682 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3684 @subsubsection Inlining rules
3685 Specifying target attributes on individual functions or performing link-time
3686 optimization across translation units compiled with different target options
3687 can affect function inlining rules:
3689 In particular, a caller function can inline a callee function only if the
3690 architectural features available to the callee are a subset of the features
3691 available to the caller.
3692 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3693 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3694 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3695 because the all the architectural features that function @code{bar} requires
3696 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3697 inline function @code{foo}.
3699 Additionally inlining a function compiled with @option{-mstrict-align} into a
3700 function compiled without @code{-mstrict-align} is not allowed.
3701 However, inlining a function compiled without @option{-mstrict-align} into a
3702 function compiled with @option{-mstrict-align} is allowed.
3704 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3705 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3706 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3707 architectural feature rules specified above.
3709 @node ARC Function Attributes
3710 @subsection ARC Function Attributes
3712 These function attributes are supported by the ARC back end:
3714 @table @code
3715 @item interrupt
3716 @cindex @code{interrupt} function attribute, ARC
3717 Use this attribute to indicate
3718 that the specified function is an interrupt handler.  The compiler generates
3719 function entry and exit sequences suitable for use in an interrupt handler
3720 when this attribute is present.
3722 On the ARC, you must specify the kind of interrupt to be handled
3723 in a parameter to the interrupt attribute like this:
3725 @smallexample
3726 void f () __attribute__ ((interrupt ("ilink1")));
3727 @end smallexample
3729 Permissible values for this parameter are: @w{@code{ilink1}} and
3730 @w{@code{ilink2}}.
3732 @item long_call
3733 @itemx medium_call
3734 @itemx short_call
3735 @cindex @code{long_call} function attribute, ARC
3736 @cindex @code{medium_call} function attribute, ARC
3737 @cindex @code{short_call} function attribute, ARC
3738 @cindex indirect calls, ARC
3739 These attributes specify how a particular function is called.
3740 These attributes override the
3741 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3742 command-line switches and @code{#pragma long_calls} settings.
3744 For ARC, a function marked with the @code{long_call} attribute is
3745 always called using register-indirect jump-and-link instructions,
3746 thereby enabling the called function to be placed anywhere within the
3747 32-bit address space.  A function marked with the @code{medium_call}
3748 attribute will always be close enough to be called with an unconditional
3749 branch-and-link instruction, which has a 25-bit offset from
3750 the call site.  A function marked with the @code{short_call}
3751 attribute will always be close enough to be called with a conditional
3752 branch-and-link instruction, which has a 21-bit offset from
3753 the call site.
3754 @end table
3756 @node ARM Function Attributes
3757 @subsection ARM Function Attributes
3759 These function attributes are supported for ARM targets:
3761 @table @code
3762 @item interrupt
3763 @cindex @code{interrupt} function attribute, ARM
3764 Use this attribute to indicate
3765 that the specified function is an interrupt handler.  The compiler generates
3766 function entry and exit sequences suitable for use in an interrupt handler
3767 when this attribute is present.
3769 You can specify the kind of interrupt to be handled by
3770 adding an optional parameter to the interrupt attribute like this:
3772 @smallexample
3773 void f () __attribute__ ((interrupt ("IRQ")));
3774 @end smallexample
3776 @noindent
3777 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3778 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3780 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3781 may be called with a word-aligned stack pointer.
3783 @item isr
3784 @cindex @code{isr} function attribute, ARM
3785 Use this attribute on ARM to write Interrupt Service Routines. This is an
3786 alias to the @code{interrupt} attribute above.
3788 @item long_call
3789 @itemx short_call
3790 @cindex @code{long_call} function attribute, ARM
3791 @cindex @code{short_call} function attribute, ARM
3792 @cindex indirect calls, ARM
3793 These attributes specify how a particular function is called.
3794 These attributes override the
3795 @option{-mlong-calls} (@pxref{ARM Options})
3796 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3797 @code{long_call} attribute indicates that the function might be far
3798 away from the call site and require a different (more expensive)
3799 calling sequence.   The @code{short_call} attribute always places
3800 the offset to the function from the call site into the @samp{BL}
3801 instruction directly.
3803 @item naked
3804 @cindex @code{naked} function attribute, ARM
3805 This attribute allows the compiler to construct the
3806 requisite function declaration, while allowing the body of the
3807 function to be assembly code. The specified function will not have
3808 prologue/epilogue sequences generated by the compiler. Only basic
3809 @code{asm} statements can safely be included in naked functions
3810 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3811 basic @code{asm} and C code may appear to work, they cannot be
3812 depended upon to work reliably and are not supported.
3814 @item pcs
3815 @cindex @code{pcs} function attribute, ARM
3817 The @code{pcs} attribute can be used to control the calling convention
3818 used for a function on ARM.  The attribute takes an argument that specifies
3819 the calling convention to use.
3821 When compiling using the AAPCS ABI (or a variant of it) then valid
3822 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3823 order to use a variant other than @code{"aapcs"} then the compiler must
3824 be permitted to use the appropriate co-processor registers (i.e., the
3825 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3826 For example,
3828 @smallexample
3829 /* Argument passed in r0, and result returned in r0+r1.  */
3830 double f2d (float) __attribute__((pcs("aapcs")));
3831 @end smallexample
3833 Variadic functions always use the @code{"aapcs"} calling convention and
3834 the compiler rejects attempts to specify an alternative.
3836 @item target (@var{options})
3837 @cindex @code{target} function attribute
3838 As discussed in @ref{Common Function Attributes}, this attribute 
3839 allows specification of target-specific compilation options.
3841 On ARM, the following options are allowed:
3843 @table @samp
3844 @item thumb
3845 @cindex @code{target("thumb")} function attribute, ARM
3846 Force code generation in the Thumb (T16/T32) ISA, depending on the
3847 architecture level.
3849 @item arm
3850 @cindex @code{target("arm")} function attribute, ARM
3851 Force code generation in the ARM (A32) ISA.
3853 Functions from different modes can be inlined in the caller's mode.
3855 @item fpu=
3856 @cindex @code{target("fpu=")} function attribute, ARM
3857 Specifies the fpu for which to tune the performance of this function.
3858 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3859 command-line option.
3861 @end table
3863 @end table
3865 @node AVR Function Attributes
3866 @subsection AVR Function Attributes
3868 These function attributes are supported by the AVR back end:
3870 @table @code
3871 @item interrupt
3872 @cindex @code{interrupt} function attribute, AVR
3873 Use this attribute to indicate
3874 that the specified function is an interrupt handler.  The compiler generates
3875 function entry and exit sequences suitable for use in an interrupt handler
3876 when this attribute is present.
3878 On the AVR, the hardware globally disables interrupts when an
3879 interrupt is executed.  The first instruction of an interrupt handler
3880 declared with this attribute is a @code{SEI} instruction to
3881 re-enable interrupts.  See also the @code{signal} function attribute
3882 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3883 @code{interrupt} are specified for the same function, @code{signal}
3884 is silently ignored.
3886 @item naked
3887 @cindex @code{naked} function attribute, AVR
3888 This attribute allows the compiler to construct the
3889 requisite function declaration, while allowing the body of the
3890 function to be assembly code. The specified function will not have
3891 prologue/epilogue sequences generated by the compiler. Only basic
3892 @code{asm} statements can safely be included in naked functions
3893 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3894 basic @code{asm} and C code may appear to work, they cannot be
3895 depended upon to work reliably and are not supported.
3897 @item no_gccisr
3898 @cindex @code{no_gccisr} function attribute, AVR
3899 Do not use @code{__gcc_isr} pseudo instructions in a function with
3900 the @code{interrupt} or @code{signal} attribute aka. interrupt
3901 service routine (ISR).
3902 Use this attribute if the preamble of the ISR prologue should always read
3903 @example
3904 push  __zero_reg__
3905 push  __tmp_reg__
3906 in    __tmp_reg__, __SREG__
3907 push  __tmp_reg__
3908 clr   __zero_reg__
3909 @end example
3910 and accordingly for the postamble of the epilogue --- no matter whether
3911 the mentioned registers are actually used in the ISR or not.
3912 Situations where you might want to use this attribute include:
3913 @itemize @bullet
3914 @item
3915 Code that (effectively) clobbers bits of @code{SREG} other than the
3916 @code{I}-flag by writing to the memory location of @code{SREG}.
3917 @item
3918 Code that uses inline assembler to jump to a different function which
3919 expects (parts of) the prologue code as outlined above to be present.
3920 @end itemize
3921 To disable @code{__gcc_isr} generation for the whole compilation unit,
3922 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
3924 @item OS_main
3925 @itemx OS_task
3926 @cindex @code{OS_main} function attribute, AVR
3927 @cindex @code{OS_task} function attribute, AVR
3928 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3929 do not save/restore any call-saved register in their prologue/epilogue.
3931 The @code{OS_main} attribute can be used when there @emph{is
3932 guarantee} that interrupts are disabled at the time when the function
3933 is entered.  This saves resources when the stack pointer has to be
3934 changed to set up a frame for local variables.
3936 The @code{OS_task} attribute can be used when there is @emph{no
3937 guarantee} that interrupts are disabled at that time when the function
3938 is entered like for, e@.g@. task functions in a multi-threading operating
3939 system. In that case, changing the stack pointer register is
3940 guarded by save/clear/restore of the global interrupt enable flag.
3942 The differences to the @code{naked} function attribute are:
3943 @itemize @bullet
3944 @item @code{naked} functions do not have a return instruction whereas 
3945 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3946 @code{RETI} return instruction.
3947 @item @code{naked} functions do not set up a frame for local variables
3948 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3949 as needed.
3950 @end itemize
3952 @item signal
3953 @cindex @code{signal} function attribute, AVR
3954 Use this attribute on the AVR to indicate that the specified
3955 function is an interrupt handler.  The compiler generates function
3956 entry and exit sequences suitable for use in an interrupt handler when this
3957 attribute is present.
3959 See also the @code{interrupt} function attribute. 
3961 The AVR hardware globally disables interrupts when an interrupt is executed.
3962 Interrupt handler functions defined with the @code{signal} attribute
3963 do not re-enable interrupts.  It is save to enable interrupts in a
3964 @code{signal} handler.  This ``save'' only applies to the code
3965 generated by the compiler and not to the IRQ layout of the
3966 application which is responsibility of the application.
3968 If both @code{signal} and @code{interrupt} are specified for the same
3969 function, @code{signal} is silently ignored.
3970 @end table
3972 @node Blackfin Function Attributes
3973 @subsection Blackfin Function Attributes
3975 These function attributes are supported by the Blackfin back end:
3977 @table @code
3979 @item exception_handler
3980 @cindex @code{exception_handler} function attribute
3981 @cindex exception handler functions, Blackfin
3982 Use this attribute on the Blackfin to indicate that the specified function
3983 is an exception handler.  The compiler generates function entry and
3984 exit sequences suitable for use in an exception handler when this
3985 attribute is present.
3987 @item interrupt_handler
3988 @cindex @code{interrupt_handler} function attribute, Blackfin
3989 Use this attribute to
3990 indicate that the specified function is an interrupt handler.  The compiler
3991 generates function entry and exit sequences suitable for use in an
3992 interrupt handler when this attribute is present.
3994 @item kspisusp
3995 @cindex @code{kspisusp} function attribute, Blackfin
3996 @cindex User stack pointer in interrupts on the Blackfin
3997 When used together with @code{interrupt_handler}, @code{exception_handler}
3998 or @code{nmi_handler}, code is generated to load the stack pointer
3999 from the USP register in the function prologue.
4001 @item l1_text
4002 @cindex @code{l1_text} function attribute, Blackfin
4003 This attribute specifies a function to be placed into L1 Instruction
4004 SRAM@. The function is put into a specific section named @code{.l1.text}.
4005 With @option{-mfdpic}, function calls with a such function as the callee
4006 or caller uses inlined PLT.
4008 @item l2
4009 @cindex @code{l2} function attribute, Blackfin
4010 This attribute specifies a function to be placed into L2
4011 SRAM. The function is put into a specific section named
4012 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4013 an inlined PLT.
4015 @item longcall
4016 @itemx shortcall
4017 @cindex indirect calls, Blackfin
4018 @cindex @code{longcall} function attribute, Blackfin
4019 @cindex @code{shortcall} function attribute, Blackfin
4020 The @code{longcall} attribute
4021 indicates that the function might be far away from the call site and
4022 require a different (more expensive) calling sequence.  The
4023 @code{shortcall} attribute indicates that the function is always close
4024 enough for the shorter calling sequence to be used.  These attributes
4025 override the @option{-mlongcall} switch.
4027 @item nesting
4028 @cindex @code{nesting} function attribute, Blackfin
4029 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4030 Use this attribute together with @code{interrupt_handler},
4031 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4032 entry code should enable nested interrupts or exceptions.
4034 @item nmi_handler
4035 @cindex @code{nmi_handler} function attribute, Blackfin
4036 @cindex NMI handler functions on the Blackfin processor
4037 Use this attribute on the Blackfin to indicate that the specified function
4038 is an NMI handler.  The compiler generates function entry and
4039 exit sequences suitable for use in an NMI handler when this
4040 attribute is present.
4042 @item saveall
4043 @cindex @code{saveall} function attribute, Blackfin
4044 @cindex save all registers on the Blackfin
4045 Use this attribute to indicate that
4046 all registers except the stack pointer should be saved in the prologue
4047 regardless of whether they are used or not.
4048 @end table
4050 @node CR16 Function Attributes
4051 @subsection CR16 Function Attributes
4053 These function attributes are supported by the CR16 back end:
4055 @table @code
4056 @item interrupt
4057 @cindex @code{interrupt} function attribute, CR16
4058 Use this attribute to indicate
4059 that the specified function is an interrupt handler.  The compiler generates
4060 function entry and exit sequences suitable for use in an interrupt handler
4061 when this attribute is present.
4062 @end table
4064 @node Epiphany Function Attributes
4065 @subsection Epiphany Function Attributes
4067 These function attributes are supported by the Epiphany back end:
4069 @table @code
4070 @item disinterrupt
4071 @cindex @code{disinterrupt} function attribute, Epiphany
4072 This attribute causes the compiler to emit
4073 instructions to disable interrupts for the duration of the given
4074 function.
4076 @item forwarder_section
4077 @cindex @code{forwarder_section} function attribute, Epiphany
4078 This attribute modifies the behavior of an interrupt handler.
4079 The interrupt handler may be in external memory which cannot be
4080 reached by a branch instruction, so generate a local memory trampoline
4081 to transfer control.  The single parameter identifies the section where
4082 the trampoline is placed.
4084 @item interrupt
4085 @cindex @code{interrupt} function attribute, Epiphany
4086 Use this attribute to indicate
4087 that the specified function is an interrupt handler.  The compiler generates
4088 function entry and exit sequences suitable for use in an interrupt handler
4089 when this attribute is present.  It may also generate
4090 a special section with code to initialize the interrupt vector table.
4092 On Epiphany targets one or more optional parameters can be added like this:
4094 @smallexample
4095 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4096 @end smallexample
4098 Permissible values for these parameters are: @w{@code{reset}},
4099 @w{@code{software_exception}}, @w{@code{page_miss}},
4100 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4101 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4102 Multiple parameters indicate that multiple entries in the interrupt
4103 vector table should be initialized for this function, i.e.@: for each
4104 parameter @w{@var{name}}, a jump to the function is emitted in
4105 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4106 entirely, in which case no interrupt vector table entry is provided.
4108 Note that interrupts are enabled inside the function
4109 unless the @code{disinterrupt} attribute is also specified.
4111 The following examples are all valid uses of these attributes on
4112 Epiphany targets:
4113 @smallexample
4114 void __attribute__ ((interrupt)) universal_handler ();
4115 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4116 void __attribute__ ((interrupt ("dma0, dma1"))) 
4117   universal_dma_handler ();
4118 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4119   fast_timer_handler ();
4120 void __attribute__ ((interrupt ("dma0, dma1"), 
4121                      forwarder_section ("tramp")))
4122   external_dma_handler ();
4123 @end smallexample
4125 @item long_call
4126 @itemx short_call
4127 @cindex @code{long_call} function attribute, Epiphany
4128 @cindex @code{short_call} function attribute, Epiphany
4129 @cindex indirect calls, Epiphany
4130 These attributes specify how a particular function is called.
4131 These attributes override the
4132 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4133 command-line switch and @code{#pragma long_calls} settings.
4134 @end table
4137 @node H8/300 Function Attributes
4138 @subsection H8/300 Function Attributes
4140 These function attributes are available for H8/300 targets:
4142 @table @code
4143 @item function_vector
4144 @cindex @code{function_vector} function attribute, H8/300
4145 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4146 that the specified function should be called through the function vector.
4147 Calling a function through the function vector reduces code size; however,
4148 the function vector has a limited size (maximum 128 entries on the H8/300
4149 and 64 entries on the H8/300H and H8S)
4150 and shares space with the interrupt vector.
4152 @item interrupt_handler
4153 @cindex @code{interrupt_handler} function attribute, H8/300
4154 Use this attribute on the H8/300, H8/300H, and H8S to
4155 indicate that the specified function is an interrupt handler.  The compiler
4156 generates function entry and exit sequences suitable for use in an
4157 interrupt handler when this attribute is present.
4159 @item saveall
4160 @cindex @code{saveall} function attribute, H8/300
4161 @cindex save all registers on the H8/300, H8/300H, and H8S
4162 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4163 all registers except the stack pointer should be saved in the prologue
4164 regardless of whether they are used or not.
4165 @end table
4167 @node IA-64 Function Attributes
4168 @subsection IA-64 Function Attributes
4170 These function attributes are supported on IA-64 targets:
4172 @table @code
4173 @item syscall_linkage
4174 @cindex @code{syscall_linkage} function attribute, IA-64
4175 This attribute is used to modify the IA-64 calling convention by marking
4176 all input registers as live at all function exits.  This makes it possible
4177 to restart a system call after an interrupt without having to save/restore
4178 the input registers.  This also prevents kernel data from leaking into
4179 application code.
4181 @item version_id
4182 @cindex @code{version_id} function attribute, IA-64
4183 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4184 symbol to contain a version string, thus allowing for function level
4185 versioning.  HP-UX system header files may use function level versioning
4186 for some system calls.
4188 @smallexample
4189 extern int foo () __attribute__((version_id ("20040821")));
4190 @end smallexample
4192 @noindent
4193 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4194 @end table
4196 @node M32C Function Attributes
4197 @subsection M32C Function Attributes
4199 These function attributes are supported by the M32C back end:
4201 @table @code
4202 @item bank_switch
4203 @cindex @code{bank_switch} function attribute, M32C
4204 When added to an interrupt handler with the M32C port, causes the
4205 prologue and epilogue to use bank switching to preserve the registers
4206 rather than saving them on the stack.
4208 @item fast_interrupt
4209 @cindex @code{fast_interrupt} function attribute, M32C
4210 Use this attribute on the M32C port to indicate that the specified
4211 function is a fast interrupt handler.  This is just like the
4212 @code{interrupt} attribute, except that @code{freit} is used to return
4213 instead of @code{reit}.
4215 @item function_vector
4216 @cindex @code{function_vector} function attribute, M16C/M32C
4217 On M16C/M32C targets, the @code{function_vector} attribute declares a
4218 special page subroutine call function. Use of this attribute reduces
4219 the code size by 2 bytes for each call generated to the
4220 subroutine. The argument to the attribute is the vector number entry
4221 from the special page vector table which contains the 16 low-order
4222 bits of the subroutine's entry address. Each vector table has special
4223 page number (18 to 255) that is used in @code{jsrs} instructions.
4224 Jump addresses of the routines are generated by adding 0x0F0000 (in
4225 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4226 2-byte addresses set in the vector table. Therefore you need to ensure
4227 that all the special page vector routines should get mapped within the
4228 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4229 (for M32C).
4231 In the following example 2 bytes are saved for each call to
4232 function @code{foo}.
4234 @smallexample
4235 void foo (void) __attribute__((function_vector(0x18)));
4236 void foo (void)
4240 void bar (void)
4242     foo();
4244 @end smallexample
4246 If functions are defined in one file and are called in another file,
4247 then be sure to write this declaration in both files.
4249 This attribute is ignored for R8C target.
4251 @item interrupt
4252 @cindex @code{interrupt} function attribute, M32C
4253 Use this attribute to indicate
4254 that the specified function is an interrupt handler.  The compiler generates
4255 function entry and exit sequences suitable for use in an interrupt handler
4256 when this attribute is present.
4257 @end table
4259 @node M32R/D Function Attributes
4260 @subsection M32R/D Function Attributes
4262 These function attributes are supported by the M32R/D back end:
4264 @table @code
4265 @item interrupt
4266 @cindex @code{interrupt} function attribute, M32R/D
4267 Use this attribute to indicate
4268 that the specified function is an interrupt handler.  The compiler generates
4269 function entry and exit sequences suitable for use in an interrupt handler
4270 when this attribute is present.
4272 @item model (@var{model-name})
4273 @cindex @code{model} function attribute, M32R/D
4274 @cindex function addressability on the M32R/D
4276 On the M32R/D, use this attribute to set the addressability of an
4277 object, and of the code generated for a function.  The identifier
4278 @var{model-name} is one of @code{small}, @code{medium}, or
4279 @code{large}, representing each of the code models.
4281 Small model objects live in the lower 16MB of memory (so that their
4282 addresses can be loaded with the @code{ld24} instruction), and are
4283 callable with the @code{bl} instruction.
4285 Medium model objects may live anywhere in the 32-bit address space (the
4286 compiler generates @code{seth/add3} instructions to load their addresses),
4287 and are callable with the @code{bl} instruction.
4289 Large model objects may live anywhere in the 32-bit address space (the
4290 compiler generates @code{seth/add3} instructions to load their addresses),
4291 and may not be reachable with the @code{bl} instruction (the compiler
4292 generates the much slower @code{seth/add3/jl} instruction sequence).
4293 @end table
4295 @node m68k Function Attributes
4296 @subsection m68k Function Attributes
4298 These function attributes are supported by the m68k back end:
4300 @table @code
4301 @item interrupt
4302 @itemx interrupt_handler
4303 @cindex @code{interrupt} function attribute, m68k
4304 @cindex @code{interrupt_handler} function attribute, m68k
4305 Use this attribute to
4306 indicate that the specified function is an interrupt handler.  The compiler
4307 generates function entry and exit sequences suitable for use in an
4308 interrupt handler when this attribute is present.  Either name may be used.
4310 @item interrupt_thread
4311 @cindex @code{interrupt_thread} function attribute, fido
4312 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4313 that the specified function is an interrupt handler that is designed
4314 to run as a thread.  The compiler omits generate prologue/epilogue
4315 sequences and replaces the return instruction with a @code{sleep}
4316 instruction.  This attribute is available only on fido.
4317 @end table
4319 @node MCORE Function Attributes
4320 @subsection MCORE Function Attributes
4322 These function attributes are supported by the MCORE back end:
4324 @table @code
4325 @item naked
4326 @cindex @code{naked} function attribute, MCORE
4327 This attribute allows the compiler to construct the
4328 requisite function declaration, while allowing the body of the
4329 function to be assembly code. The specified function will not have
4330 prologue/epilogue sequences generated by the compiler. Only basic
4331 @code{asm} statements can safely be included in naked functions
4332 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4333 basic @code{asm} and C code may appear to work, they cannot be
4334 depended upon to work reliably and are not supported.
4335 @end table
4337 @node MeP Function Attributes
4338 @subsection MeP Function Attributes
4340 These function attributes are supported by the MeP back end:
4342 @table @code
4343 @item disinterrupt
4344 @cindex @code{disinterrupt} function attribute, MeP
4345 On MeP targets, this attribute causes the compiler to emit
4346 instructions to disable interrupts for the duration of the given
4347 function.
4349 @item interrupt
4350 @cindex @code{interrupt} function attribute, MeP
4351 Use this attribute to indicate
4352 that the specified function is an interrupt handler.  The compiler generates
4353 function entry and exit sequences suitable for use in an interrupt handler
4354 when this attribute is present.
4356 @item near
4357 @cindex @code{near} function attribute, MeP
4358 This attribute causes the compiler to assume the called
4359 function is close enough to use the normal calling convention,
4360 overriding the @option{-mtf} command-line option.
4362 @item far
4363 @cindex @code{far} function attribute, MeP
4364 On MeP targets this causes the compiler to use a calling convention
4365 that assumes the called function is too far away for the built-in
4366 addressing modes.
4368 @item vliw
4369 @cindex @code{vliw} function attribute, MeP
4370 The @code{vliw} attribute tells the compiler to emit
4371 instructions in VLIW mode instead of core mode.  Note that this
4372 attribute is not allowed unless a VLIW coprocessor has been configured
4373 and enabled through command-line options.
4374 @end table
4376 @node MicroBlaze Function Attributes
4377 @subsection MicroBlaze Function Attributes
4379 These function attributes are supported on MicroBlaze targets:
4381 @table @code
4382 @item save_volatiles
4383 @cindex @code{save_volatiles} function attribute, MicroBlaze
4384 Use this attribute to indicate that the function is
4385 an interrupt handler.  All volatile registers (in addition to non-volatile
4386 registers) are saved in the function prologue.  If the function is a leaf
4387 function, only volatiles used by the function are saved.  A normal function
4388 return is generated instead of a return from interrupt.
4390 @item break_handler
4391 @cindex @code{break_handler} function attribute, MicroBlaze
4392 @cindex break handler functions
4393 Use this attribute to indicate that
4394 the specified function is a break handler.  The compiler generates function
4395 entry and exit sequences suitable for use in an break handler when this
4396 attribute is present. The return from @code{break_handler} is done through
4397 the @code{rtbd} instead of @code{rtsd}.
4399 @smallexample
4400 void f () __attribute__ ((break_handler));
4401 @end smallexample
4403 @item interrupt_handler
4404 @itemx fast_interrupt 
4405 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4406 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4407 These attributes indicate that the specified function is an interrupt
4408 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4409 used in low-latency interrupt mode, and @code{interrupt_handler} for
4410 interrupts that do not use low-latency handlers.  In both cases, GCC
4411 emits appropriate prologue code and generates a return from the handler
4412 using @code{rtid} instead of @code{rtsd}.
4413 @end table
4415 @node Microsoft Windows Function Attributes
4416 @subsection Microsoft Windows Function Attributes
4418 The following attributes are available on Microsoft Windows and Symbian OS
4419 targets.
4421 @table @code
4422 @item dllexport
4423 @cindex @code{dllexport} function attribute
4424 @cindex @code{__declspec(dllexport)}
4425 On Microsoft Windows targets and Symbian OS targets the
4426 @code{dllexport} attribute causes the compiler to provide a global
4427 pointer to a pointer in a DLL, so that it can be referenced with the
4428 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4429 name is formed by combining @code{_imp__} and the function or variable
4430 name.
4432 You can use @code{__declspec(dllexport)} as a synonym for
4433 @code{__attribute__ ((dllexport))} for compatibility with other
4434 compilers.
4436 On systems that support the @code{visibility} attribute, this
4437 attribute also implies ``default'' visibility.  It is an error to
4438 explicitly specify any other visibility.
4440 GCC's default behavior is to emit all inline functions with the
4441 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4442 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4443 ignore the attribute for inlined functions unless the 
4444 @option{-fkeep-inline-functions} flag is used instead.
4446 The attribute is ignored for undefined symbols.
4448 When applied to C++ classes, the attribute marks defined non-inlined
4449 member functions and static data members as exports.  Static consts
4450 initialized in-class are not marked unless they are also defined
4451 out-of-class.
4453 For Microsoft Windows targets there are alternative methods for
4454 including the symbol in the DLL's export table such as using a
4455 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4456 the @option{--export-all} linker flag.
4458 @item dllimport
4459 @cindex @code{dllimport} function attribute
4460 @cindex @code{__declspec(dllimport)}
4461 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4462 attribute causes the compiler to reference a function or variable via
4463 a global pointer to a pointer that is set up by the DLL exporting the
4464 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4465 targets, the pointer name is formed by combining @code{_imp__} and the
4466 function or variable name.
4468 You can use @code{__declspec(dllimport)} as a synonym for
4469 @code{__attribute__ ((dllimport))} for compatibility with other
4470 compilers.
4472 On systems that support the @code{visibility} attribute, this
4473 attribute also implies ``default'' visibility.  It is an error to
4474 explicitly specify any other visibility.
4476 Currently, the attribute is ignored for inlined functions.  If the
4477 attribute is applied to a symbol @emph{definition}, an error is reported.
4478 If a symbol previously declared @code{dllimport} is later defined, the
4479 attribute is ignored in subsequent references, and a warning is emitted.
4480 The attribute is also overridden by a subsequent declaration as
4481 @code{dllexport}.
4483 When applied to C++ classes, the attribute marks non-inlined
4484 member functions and static data members as imports.  However, the
4485 attribute is ignored for virtual methods to allow creation of vtables
4486 using thunks.
4488 On the SH Symbian OS target the @code{dllimport} attribute also has
4489 another affect---it can cause the vtable and run-time type information
4490 for a class to be exported.  This happens when the class has a
4491 dllimported constructor or a non-inline, non-pure virtual function
4492 and, for either of those two conditions, the class also has an inline
4493 constructor or destructor and has a key function that is defined in
4494 the current translation unit.
4496 For Microsoft Windows targets the use of the @code{dllimport}
4497 attribute on functions is not necessary, but provides a small
4498 performance benefit by eliminating a thunk in the DLL@.  The use of the
4499 @code{dllimport} attribute on imported variables can be avoided by passing the
4500 @option{--enable-auto-import} switch to the GNU linker.  As with
4501 functions, using the attribute for a variable eliminates a thunk in
4502 the DLL@.
4504 One drawback to using this attribute is that a pointer to a
4505 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4506 address. However, a pointer to a @emph{function} with the
4507 @code{dllimport} attribute can be used as a constant initializer; in
4508 this case, the address of a stub function in the import lib is
4509 referenced.  On Microsoft Windows targets, the attribute can be disabled
4510 for functions by setting the @option{-mnop-fun-dllimport} flag.
4511 @end table
4513 @node MIPS Function Attributes
4514 @subsection MIPS Function Attributes
4516 These function attributes are supported by the MIPS back end:
4518 @table @code
4519 @item interrupt
4520 @cindex @code{interrupt} function attribute, MIPS
4521 Use this attribute to indicate that the specified function is an interrupt
4522 handler.  The compiler generates function entry and exit sequences suitable
4523 for use in an interrupt handler when this attribute is present.
4524 An optional argument is supported for the interrupt attribute which allows
4525 the interrupt mode to be described.  By default GCC assumes the external
4526 interrupt controller (EIC) mode is in use, this can be explicitly set using
4527 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4528 Priority Level (IPL) is copied to the current IPL which has the effect of only
4529 enabling higher priority interrupts.  To use vectored interrupt mode use
4530 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4531 the behavior of the non-masked interrupt support and GCC will arrange to mask
4532 all interrupts from sw0 up to and including the specified interrupt vector.
4534 You can use the following attributes to modify the behavior
4535 of an interrupt handler:
4536 @table @code
4537 @item use_shadow_register_set
4538 @cindex @code{use_shadow_register_set} function attribute, MIPS
4539 Assume that the handler uses a shadow register set, instead of
4540 the main general-purpose registers.  An optional argument @code{intstack} is
4541 supported to indicate that the shadow register set contains a valid stack
4542 pointer.
4544 @item keep_interrupts_masked
4545 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4546 Keep interrupts masked for the whole function.  Without this attribute,
4547 GCC tries to reenable interrupts for as much of the function as it can.
4549 @item use_debug_exception_return
4550 @cindex @code{use_debug_exception_return} function attribute, MIPS
4551 Return using the @code{deret} instruction.  Interrupt handlers that don't
4552 have this attribute return using @code{eret} instead.
4553 @end table
4555 You can use any combination of these attributes, as shown below:
4556 @smallexample
4557 void __attribute__ ((interrupt)) v0 ();
4558 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4559 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4560 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4561 void __attribute__ ((interrupt, use_shadow_register_set,
4562                      keep_interrupts_masked)) v4 ();
4563 void __attribute__ ((interrupt, use_shadow_register_set,
4564                      use_debug_exception_return)) v5 ();
4565 void __attribute__ ((interrupt, keep_interrupts_masked,
4566                      use_debug_exception_return)) v6 ();
4567 void __attribute__ ((interrupt, use_shadow_register_set,
4568                      keep_interrupts_masked,
4569                      use_debug_exception_return)) v7 ();
4570 void __attribute__ ((interrupt("eic"))) v8 ();
4571 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4572 @end smallexample
4574 @item long_call
4575 @itemx short_call
4576 @itemx near
4577 @itemx far
4578 @cindex indirect calls, MIPS
4579 @cindex @code{long_call} function attribute, MIPS
4580 @cindex @code{short_call} function attribute, MIPS
4581 @cindex @code{near} function attribute, MIPS
4582 @cindex @code{far} function attribute, MIPS
4583 These attributes specify how a particular function is called on MIPS@.
4584 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4585 command-line switch.  The @code{long_call} and @code{far} attributes are
4586 synonyms, and cause the compiler to always call
4587 the function by first loading its address into a register, and then using
4588 the contents of that register.  The @code{short_call} and @code{near}
4589 attributes are synonyms, and have the opposite
4590 effect; they specify that non-PIC calls should be made using the more
4591 efficient @code{jal} instruction.
4593 @item mips16
4594 @itemx nomips16
4595 @cindex @code{mips16} function attribute, MIPS
4596 @cindex @code{nomips16} function attribute, MIPS
4598 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4599 function attributes to locally select or turn off MIPS16 code generation.
4600 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4601 while MIPS16 code generation is disabled for functions with the
4602 @code{nomips16} attribute.  These attributes override the
4603 @option{-mips16} and @option{-mno-mips16} options on the command line
4604 (@pxref{MIPS Options}).
4606 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4607 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4608 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4609 may interact badly with some GCC extensions such as @code{__builtin_apply}
4610 (@pxref{Constructing Calls}).
4612 @item micromips, MIPS
4613 @itemx nomicromips, MIPS
4614 @cindex @code{micromips} function attribute
4615 @cindex @code{nomicromips} function attribute
4617 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4618 function attributes to locally select or turn off microMIPS code generation.
4619 A function with the @code{micromips} attribute is emitted as microMIPS code,
4620 while microMIPS code generation is disabled for functions with the
4621 @code{nomicromips} attribute.  These attributes override the
4622 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4623 (@pxref{MIPS Options}).
4625 When compiling files containing mixed microMIPS and non-microMIPS code, the
4626 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4627 command line,
4628 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4629 may interact badly with some GCC extensions such as @code{__builtin_apply}
4630 (@pxref{Constructing Calls}).
4632 @item nocompression
4633 @cindex @code{nocompression} function attribute, MIPS
4634 On MIPS targets, you can use the @code{nocompression} function attribute
4635 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4636 overrides the @option{-mips16} and @option{-mmicromips} options on the
4637 command line (@pxref{MIPS Options}).
4638 @end table
4640 @node MSP430 Function Attributes
4641 @subsection MSP430 Function Attributes
4643 These function attributes are supported by the MSP430 back end:
4645 @table @code
4646 @item critical
4647 @cindex @code{critical} function attribute, MSP430
4648 Critical functions disable interrupts upon entry and restore the
4649 previous interrupt state upon exit.  Critical functions cannot also
4650 have the @code{naked} or @code{reentrant} attributes.  They can have
4651 the @code{interrupt} attribute.
4653 @item interrupt
4654 @cindex @code{interrupt} function attribute, MSP430
4655 Use this attribute to indicate
4656 that the specified function is an interrupt handler.  The compiler generates
4657 function entry and exit sequences suitable for use in an interrupt handler
4658 when this attribute is present.
4660 You can provide an argument to the interrupt
4661 attribute which specifies a name or number.  If the argument is a
4662 number it indicates the slot in the interrupt vector table (0 - 31) to
4663 which this handler should be assigned.  If the argument is a name it
4664 is treated as a symbolic name for the vector slot.  These names should
4665 match up with appropriate entries in the linker script.  By default
4666 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4667 @code{reset} for vector 31 are recognized.
4669 @item naked
4670 @cindex @code{naked} function attribute, MSP430
4671 This attribute allows the compiler to construct the
4672 requisite function declaration, while allowing the body of the
4673 function to be assembly code. The specified function will not have
4674 prologue/epilogue sequences generated by the compiler. Only basic
4675 @code{asm} statements can safely be included in naked functions
4676 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4677 basic @code{asm} and C code may appear to work, they cannot be
4678 depended upon to work reliably and are not supported.
4680 @item reentrant
4681 @cindex @code{reentrant} function attribute, MSP430
4682 Reentrant functions disable interrupts upon entry and enable them
4683 upon exit.  Reentrant functions cannot also have the @code{naked}
4684 or @code{critical} attributes.  They can have the @code{interrupt}
4685 attribute.
4687 @item wakeup
4688 @cindex @code{wakeup} function attribute, MSP430
4689 This attribute only applies to interrupt functions.  It is silently
4690 ignored if applied to a non-interrupt function.  A wakeup interrupt
4691 function will rouse the processor from any low-power state that it
4692 might be in when the function exits.
4694 @item lower
4695 @itemx upper
4696 @itemx either
4697 @cindex @code{lower} function attribute, MSP430
4698 @cindex @code{upper} function attribute, MSP430
4699 @cindex @code{either} function attribute, MSP430
4700 On the MSP430 target these attributes can be used to specify whether
4701 the function or variable should be placed into low memory, high
4702 memory, or the placement should be left to the linker to decide.  The
4703 attributes are only significant if compiling for the MSP430X
4704 architecture.
4706 The attributes work in conjunction with a linker script that has been
4707 augmented to specify where to place sections with a @code{.lower} and
4708 a @code{.upper} prefix.  So, for example, as well as placing the
4709 @code{.data} section, the script also specifies the placement of a
4710 @code{.lower.data} and a @code{.upper.data} section.  The intention
4711 is that @code{lower} sections are placed into a small but easier to
4712 access memory region and the upper sections are placed into a larger, but
4713 slower to access, region.
4715 The @code{either} attribute is special.  It tells the linker to place
4716 the object into the corresponding @code{lower} section if there is
4717 room for it.  If there is insufficient room then the object is placed
4718 into the corresponding @code{upper} section instead.  Note that the
4719 placement algorithm is not very sophisticated.  It does not attempt to
4720 find an optimal packing of the @code{lower} sections.  It just makes
4721 one pass over the objects and does the best that it can.  Using the
4722 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4723 options can help the packing, however, since they produce smaller,
4724 easier to pack regions.
4725 @end table
4727 @node NDS32 Function Attributes
4728 @subsection NDS32 Function Attributes
4730 These function attributes are supported by the NDS32 back end:
4732 @table @code
4733 @item exception
4734 @cindex @code{exception} function attribute
4735 @cindex exception handler functions, NDS32
4736 Use this attribute on the NDS32 target to indicate that the specified function
4737 is an exception handler.  The compiler will generate corresponding sections
4738 for use in an exception handler.
4740 @item interrupt
4741 @cindex @code{interrupt} function attribute, NDS32
4742 On NDS32 target, this attribute indicates that the specified function
4743 is an interrupt handler.  The compiler generates corresponding sections
4744 for use in an interrupt handler.  You can use the following attributes
4745 to modify the behavior:
4746 @table @code
4747 @item nested
4748 @cindex @code{nested} function attribute, NDS32
4749 This interrupt service routine is interruptible.
4750 @item not_nested
4751 @cindex @code{not_nested} function attribute, NDS32
4752 This interrupt service routine is not interruptible.
4753 @item nested_ready
4754 @cindex @code{nested_ready} function attribute, NDS32
4755 This interrupt service routine is interruptible after @code{PSW.GIE}
4756 (global interrupt enable) is set.  This allows interrupt service routine to
4757 finish some short critical code before enabling interrupts.
4758 @item save_all
4759 @cindex @code{save_all} function attribute, NDS32
4760 The system will help save all registers into stack before entering
4761 interrupt handler.
4762 @item partial_save
4763 @cindex @code{partial_save} function attribute, NDS32
4764 The system will help save caller registers into stack before entering
4765 interrupt handler.
4766 @end table
4768 @item naked
4769 @cindex @code{naked} function attribute, NDS32
4770 This attribute allows the compiler to construct the
4771 requisite function declaration, while allowing the body of the
4772 function to be assembly code. The specified function will not have
4773 prologue/epilogue sequences generated by the compiler. Only basic
4774 @code{asm} statements can safely be included in naked functions
4775 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4776 basic @code{asm} and C code may appear to work, they cannot be
4777 depended upon to work reliably and are not supported.
4779 @item reset
4780 @cindex @code{reset} function attribute, NDS32
4781 @cindex reset handler functions
4782 Use this attribute on the NDS32 target to indicate that the specified function
4783 is a reset handler.  The compiler will generate corresponding sections
4784 for use in a reset handler.  You can use the following attributes
4785 to provide extra exception handling:
4786 @table @code
4787 @item nmi
4788 @cindex @code{nmi} function attribute, NDS32
4789 Provide a user-defined function to handle NMI exception.
4790 @item warm
4791 @cindex @code{warm} function attribute, NDS32
4792 Provide a user-defined function to handle warm reset exception.
4793 @end table
4794 @end table
4796 @node Nios II Function Attributes
4797 @subsection Nios II Function Attributes
4799 These function attributes are supported by the Nios II back end:
4801 @table @code
4802 @item target (@var{options})
4803 @cindex @code{target} function attribute
4804 As discussed in @ref{Common Function Attributes}, this attribute 
4805 allows specification of target-specific compilation options.
4807 When compiling for Nios II, the following options are allowed:
4809 @table @samp
4810 @item custom-@var{insn}=@var{N}
4811 @itemx no-custom-@var{insn}
4812 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4813 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4814 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4815 custom instruction with encoding @var{N} when generating code that uses 
4816 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4817 the custom instruction @var{insn}.
4818 These target attributes correspond to the
4819 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4820 command-line options, and support the same set of @var{insn} keywords.
4821 @xref{Nios II Options}, for more information.
4823 @item custom-fpu-cfg=@var{name}
4824 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4825 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4826 command-line option, to select a predefined set of custom instructions
4827 named @var{name}.
4828 @xref{Nios II Options}, for more information.
4829 @end table
4830 @end table
4832 @node Nvidia PTX Function Attributes
4833 @subsection Nvidia PTX Function Attributes
4835 These function attributes are supported by the Nvidia PTX back end:
4837 @table @code
4838 @item kernel
4839 @cindex @code{kernel} attribute, Nvidia PTX
4840 This attribute indicates that the corresponding function should be compiled
4841 as a kernel function, which can be invoked from the host via the CUDA RT 
4842 library.
4843 By default functions are only callable only from other PTX functions.
4845 Kernel functions must have @code{void} return type.
4846 @end table
4848 @node PowerPC Function Attributes
4849 @subsection PowerPC Function Attributes
4851 These function attributes are supported by the PowerPC back end:
4853 @table @code
4854 @item longcall
4855 @itemx shortcall
4856 @cindex indirect calls, PowerPC
4857 @cindex @code{longcall} function attribute, PowerPC
4858 @cindex @code{shortcall} function attribute, PowerPC
4859 The @code{longcall} attribute
4860 indicates that the function might be far away from the call site and
4861 require a different (more expensive) calling sequence.  The
4862 @code{shortcall} attribute indicates that the function is always close
4863 enough for the shorter calling sequence to be used.  These attributes
4864 override both the @option{-mlongcall} switch and
4865 the @code{#pragma longcall} setting.
4867 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4868 calls are necessary.
4870 @item target (@var{options})
4871 @cindex @code{target} function attribute
4872 As discussed in @ref{Common Function Attributes}, this attribute 
4873 allows specification of target-specific compilation options.
4875 On the PowerPC, the following options are allowed:
4877 @table @samp
4878 @item altivec
4879 @itemx no-altivec
4880 @cindex @code{target("altivec")} function attribute, PowerPC
4881 Generate code that uses (does not use) AltiVec instructions.  In
4882 32-bit code, you cannot enable AltiVec instructions unless
4883 @option{-mabi=altivec} is used on the command line.
4885 @item cmpb
4886 @itemx no-cmpb
4887 @cindex @code{target("cmpb")} function attribute, PowerPC
4888 Generate code that uses (does not use) the compare bytes instruction
4889 implemented on the POWER6 processor and other processors that support
4890 the PowerPC V2.05 architecture.
4892 @item dlmzb
4893 @itemx no-dlmzb
4894 @cindex @code{target("dlmzb")} function attribute, PowerPC
4895 Generate code that uses (does not use) the string-search @samp{dlmzb}
4896 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4897 generated by default when targeting those processors.
4899 @item fprnd
4900 @itemx no-fprnd
4901 @cindex @code{target("fprnd")} function attribute, PowerPC
4902 Generate code that uses (does not use) the FP round to integer
4903 instructions implemented on the POWER5+ processor and other processors
4904 that support the PowerPC V2.03 architecture.
4906 @item hard-dfp
4907 @itemx no-hard-dfp
4908 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4909 Generate code that uses (does not use) the decimal floating-point
4910 instructions implemented on some POWER processors.
4912 @item isel
4913 @itemx no-isel
4914 @cindex @code{target("isel")} function attribute, PowerPC
4915 Generate code that uses (does not use) ISEL instruction.
4917 @item mfcrf
4918 @itemx no-mfcrf
4919 @cindex @code{target("mfcrf")} function attribute, PowerPC
4920 Generate code that uses (does not use) the move from condition
4921 register field instruction implemented on the POWER4 processor and
4922 other processors that support the PowerPC V2.01 architecture.
4924 @item mfpgpr
4925 @itemx no-mfpgpr
4926 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4927 Generate code that uses (does not use) the FP move to/from general
4928 purpose register instructions implemented on the POWER6X processor and
4929 other processors that support the extended PowerPC V2.05 architecture.
4931 @item mulhw
4932 @itemx no-mulhw
4933 @cindex @code{target("mulhw")} function attribute, PowerPC
4934 Generate code that uses (does not use) the half-word multiply and
4935 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4936 These instructions are generated by default when targeting those
4937 processors.
4939 @item multiple
4940 @itemx no-multiple
4941 @cindex @code{target("multiple")} function attribute, PowerPC
4942 Generate code that uses (does not use) the load multiple word
4943 instructions and the store multiple word instructions.
4945 @item update
4946 @itemx no-update
4947 @cindex @code{target("update")} function attribute, PowerPC
4948 Generate code that uses (does not use) the load or store instructions
4949 that update the base register to the address of the calculated memory
4950 location.
4952 @item popcntb
4953 @itemx no-popcntb
4954 @cindex @code{target("popcntb")} function attribute, PowerPC
4955 Generate code that uses (does not use) the popcount and double-precision
4956 FP reciprocal estimate instruction implemented on the POWER5
4957 processor and other processors that support the PowerPC V2.02
4958 architecture.
4960 @item popcntd
4961 @itemx no-popcntd
4962 @cindex @code{target("popcntd")} function attribute, PowerPC
4963 Generate code that uses (does not use) the popcount instruction
4964 implemented on the POWER7 processor and other processors that support
4965 the PowerPC V2.06 architecture.
4967 @item powerpc-gfxopt
4968 @itemx no-powerpc-gfxopt
4969 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4970 Generate code that uses (does not use) the optional PowerPC
4971 architecture instructions in the Graphics group, including
4972 floating-point select.
4974 @item powerpc-gpopt
4975 @itemx no-powerpc-gpopt
4976 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4977 Generate code that uses (does not use) the optional PowerPC
4978 architecture instructions in the General Purpose group, including
4979 floating-point square root.
4981 @item recip-precision
4982 @itemx no-recip-precision
4983 @cindex @code{target("recip-precision")} function attribute, PowerPC
4984 Assume (do not assume) that the reciprocal estimate instructions
4985 provide higher-precision estimates than is mandated by the PowerPC
4986 ABI.
4988 @item string
4989 @itemx no-string
4990 @cindex @code{target("string")} function attribute, PowerPC
4991 Generate code that uses (does not use) the load string instructions
4992 and the store string word instructions to save multiple registers and
4993 do small block moves.
4995 @item vsx
4996 @itemx no-vsx
4997 @cindex @code{target("vsx")} function attribute, PowerPC
4998 Generate code that uses (does not use) vector/scalar (VSX)
4999 instructions, and also enable the use of built-in functions that allow
5000 more direct access to the VSX instruction set.  In 32-bit code, you
5001 cannot enable VSX or AltiVec instructions unless
5002 @option{-mabi=altivec} is used on the command line.
5004 @item friz
5005 @itemx no-friz
5006 @cindex @code{target("friz")} function attribute, PowerPC
5007 Generate (do not generate) the @code{friz} instruction when the
5008 @option{-funsafe-math-optimizations} option is used to optimize
5009 rounding a floating-point value to 64-bit integer and back to floating
5010 point.  The @code{friz} instruction does not return the same value if
5011 the floating-point number is too large to fit in an integer.
5013 @item avoid-indexed-addresses
5014 @itemx no-avoid-indexed-addresses
5015 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5016 Generate code that tries to avoid (not avoid) the use of indexed load
5017 or store instructions.
5019 @item paired
5020 @itemx no-paired
5021 @cindex @code{target("paired")} function attribute, PowerPC
5022 Generate code that uses (does not use) the generation of PAIRED simd
5023 instructions.
5025 @item longcall
5026 @itemx no-longcall
5027 @cindex @code{target("longcall")} function attribute, PowerPC
5028 Generate code that assumes (does not assume) that all calls are far
5029 away so that a longer more expensive calling sequence is required.
5031 @item cpu=@var{CPU}
5032 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5033 Specify the architecture to generate code for when compiling the
5034 function.  If you select the @code{target("cpu=power7")} attribute when
5035 generating 32-bit code, VSX and AltiVec instructions are not generated
5036 unless you use the @option{-mabi=altivec} option on the command line.
5038 @item tune=@var{TUNE}
5039 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5040 Specify the architecture to tune for when compiling the function.  If
5041 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5042 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5043 compilation tunes for the @var{CPU} architecture, and not the
5044 default tuning specified on the command line.
5045 @end table
5047 On the PowerPC, the inliner does not inline a
5048 function that has different target options than the caller, unless the
5049 callee has a subset of the target options of the caller.
5050 @end table
5052 @node RL78 Function Attributes
5053 @subsection RL78 Function Attributes
5055 These function attributes are supported by the RL78 back end:
5057 @table @code
5058 @item interrupt
5059 @itemx brk_interrupt
5060 @cindex @code{interrupt} function attribute, RL78
5061 @cindex @code{brk_interrupt} function attribute, RL78
5062 These attributes indicate
5063 that the specified function is an interrupt handler.  The compiler generates
5064 function entry and exit sequences suitable for use in an interrupt handler
5065 when this attribute is present.
5067 Use @code{brk_interrupt} instead of @code{interrupt} for
5068 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5069 that must end with @code{RETB} instead of @code{RETI}).
5071 @item naked
5072 @cindex @code{naked} function attribute, RL78
5073 This attribute allows the compiler to construct the
5074 requisite function declaration, while allowing the body of the
5075 function to be assembly code. The specified function will not have
5076 prologue/epilogue sequences generated by the compiler. Only basic
5077 @code{asm} statements can safely be included in naked functions
5078 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5079 basic @code{asm} and C code may appear to work, they cannot be
5080 depended upon to work reliably and are not supported.
5081 @end table
5083 @node RX Function Attributes
5084 @subsection RX Function Attributes
5086 These function attributes are supported by the RX back end:
5088 @table @code
5089 @item fast_interrupt
5090 @cindex @code{fast_interrupt} function attribute, RX
5091 Use this attribute on the RX port to indicate that the specified
5092 function is a fast interrupt handler.  This is just like the
5093 @code{interrupt} attribute, except that @code{freit} is used to return
5094 instead of @code{reit}.
5096 @item interrupt
5097 @cindex @code{interrupt} function attribute, RX
5098 Use this attribute to indicate
5099 that the specified function is an interrupt handler.  The compiler generates
5100 function entry and exit sequences suitable for use in an interrupt handler
5101 when this attribute is present.
5103 On RX targets, you may specify one or more vector numbers as arguments
5104 to the attribute, as well as naming an alternate table name.
5105 Parameters are handled sequentially, so one handler can be assigned to
5106 multiple entries in multiple tables.  One may also pass the magic
5107 string @code{"$default"} which causes the function to be used for any
5108 unfilled slots in the current table.
5110 This example shows a simple assignment of a function to one vector in
5111 the default table (note that preprocessor macros may be used for
5112 chip-specific symbolic vector names):
5113 @smallexample
5114 void __attribute__ ((interrupt (5))) txd1_handler ();
5115 @end smallexample
5117 This example assigns a function to two slots in the default table
5118 (using preprocessor macros defined elsewhere) and makes it the default
5119 for the @code{dct} table:
5120 @smallexample
5121 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5122         txd1_handler ();
5123 @end smallexample
5125 @item naked
5126 @cindex @code{naked} function attribute, RX
5127 This attribute allows the compiler to construct the
5128 requisite function declaration, while allowing the body of the
5129 function to be assembly code. The specified function will not have
5130 prologue/epilogue sequences generated by the compiler. Only basic
5131 @code{asm} statements can safely be included in naked functions
5132 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5133 basic @code{asm} and C code may appear to work, they cannot be
5134 depended upon to work reliably and are not supported.
5136 @item vector
5137 @cindex @code{vector} function attribute, RX
5138 This RX attribute is similar to the @code{interrupt} attribute, including its
5139 parameters, but does not make the function an interrupt-handler type
5140 function (i.e. it retains the normal C function calling ABI).  See the
5141 @code{interrupt} attribute for a description of its arguments.
5142 @end table
5144 @node S/390 Function Attributes
5145 @subsection S/390 Function Attributes
5147 These function attributes are supported on the S/390:
5149 @table @code
5150 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5151 @cindex @code{hotpatch} function attribute, S/390
5153 On S/390 System z targets, you can use this function attribute to
5154 make GCC generate a ``hot-patching'' function prologue.  If the
5155 @option{-mhotpatch=} command-line option is used at the same time,
5156 the @code{hotpatch} attribute takes precedence.  The first of the
5157 two arguments specifies the number of halfwords to be added before
5158 the function label.  A second argument can be used to specify the
5159 number of halfwords to be added after the function label.  For
5160 both arguments the maximum allowed value is 1000000.
5162 If both arguments are zero, hotpatching is disabled.
5164 @item target (@var{options})
5165 @cindex @code{target} function attribute
5166 As discussed in @ref{Common Function Attributes}, this attribute
5167 allows specification of target-specific compilation options.
5169 On S/390, the following options are supported:
5171 @table @samp
5172 @item arch=
5173 @item tune=
5174 @item stack-guard=
5175 @item stack-size=
5176 @item branch-cost=
5177 @item warn-framesize=
5178 @item backchain
5179 @itemx no-backchain
5180 @item hard-dfp
5181 @itemx no-hard-dfp
5182 @item hard-float
5183 @itemx soft-float
5184 @item htm
5185 @itemx no-htm
5186 @item vx
5187 @itemx no-vx
5188 @item packed-stack
5189 @itemx no-packed-stack
5190 @item small-exec
5191 @itemx no-small-exec
5192 @item mvcle
5193 @itemx no-mvcle
5194 @item warn-dynamicstack
5195 @itemx no-warn-dynamicstack
5196 @end table
5198 The options work exactly like the S/390 specific command line
5199 options (without the prefix @option{-m}) except that they do not
5200 change any feature macros.  For example,
5202 @smallexample
5203 @code{target("no-vx")}
5204 @end smallexample
5206 does not undefine the @code{__VEC__} macro.
5207 @end table
5209 @node SH Function Attributes
5210 @subsection SH Function Attributes
5212 These function attributes are supported on the SH family of processors:
5214 @table @code
5215 @item function_vector
5216 @cindex @code{function_vector} function attribute, SH
5217 @cindex calling functions through the function vector on SH2A
5218 On SH2A targets, this attribute declares a function to be called using the
5219 TBR relative addressing mode.  The argument to this attribute is the entry
5220 number of the same function in a vector table containing all the TBR
5221 relative addressable functions.  For correct operation the TBR must be setup
5222 accordingly to point to the start of the vector table before any functions with
5223 this attribute are invoked.  Usually a good place to do the initialization is
5224 the startup routine.  The TBR relative vector table can have at max 256 function
5225 entries.  The jumps to these functions are generated using a SH2A specific,
5226 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5227 from GNU binutils version 2.7 or later for this attribute to work correctly.
5229 In an application, for a function being called once, this attribute
5230 saves at least 8 bytes of code; and if other successive calls are being
5231 made to the same function, it saves 2 bytes of code per each of these
5232 calls.
5234 @item interrupt_handler
5235 @cindex @code{interrupt_handler} function attribute, SH
5236 Use this attribute to
5237 indicate that the specified function is an interrupt handler.  The compiler
5238 generates function entry and exit sequences suitable for use in an
5239 interrupt handler when this attribute is present.
5241 @item nosave_low_regs
5242 @cindex @code{nosave_low_regs} function attribute, SH
5243 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5244 function should not save and restore registers R0..R7.  This can be used on SH3*
5245 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5246 interrupt handlers.
5248 @item renesas
5249 @cindex @code{renesas} function attribute, SH
5250 On SH targets this attribute specifies that the function or struct follows the
5251 Renesas ABI.
5253 @item resbank
5254 @cindex @code{resbank} function attribute, SH
5255 On the SH2A target, this attribute enables the high-speed register
5256 saving and restoration using a register bank for @code{interrupt_handler}
5257 routines.  Saving to the bank is performed automatically after the CPU
5258 accepts an interrupt that uses a register bank.
5260 The nineteen 32-bit registers comprising general register R0 to R14,
5261 control register GBR, and system registers MACH, MACL, and PR and the
5262 vector table address offset are saved into a register bank.  Register
5263 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5264 from the bank is executed by issuing a RESBANK instruction.
5266 @item sp_switch
5267 @cindex @code{sp_switch} function attribute, SH
5268 Use this attribute on the SH to indicate an @code{interrupt_handler}
5269 function should switch to an alternate stack.  It expects a string
5270 argument that names a global variable holding the address of the
5271 alternate stack.
5273 @smallexample
5274 void *alt_stack;
5275 void f () __attribute__ ((interrupt_handler,
5276                           sp_switch ("alt_stack")));
5277 @end smallexample
5279 @item trap_exit
5280 @cindex @code{trap_exit} function attribute, SH
5281 Use this attribute on the SH for an @code{interrupt_handler} to return using
5282 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5283 argument specifying the trap number to be used.
5285 @item trapa_handler
5286 @cindex @code{trapa_handler} function attribute, SH
5287 On SH targets this function attribute is similar to @code{interrupt_handler}
5288 but it does not save and restore all registers.
5289 @end table
5291 @node SPU Function Attributes
5292 @subsection SPU Function Attributes
5294 These function attributes are supported by the SPU back end:
5296 @table @code
5297 @item naked
5298 @cindex @code{naked} function attribute, SPU
5299 This attribute allows the compiler to construct the
5300 requisite function declaration, while allowing the body of the
5301 function to be assembly code. The specified function will not have
5302 prologue/epilogue sequences generated by the compiler. Only basic
5303 @code{asm} statements can safely be included in naked functions
5304 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5305 basic @code{asm} and C code may appear to work, they cannot be
5306 depended upon to work reliably and are not supported.
5307 @end table
5309 @node Symbian OS Function Attributes
5310 @subsection Symbian OS Function Attributes
5312 @xref{Microsoft Windows Function Attributes}, for discussion of the
5313 @code{dllexport} and @code{dllimport} attributes.
5315 @node V850 Function Attributes
5316 @subsection V850 Function Attributes
5318 The V850 back end supports these function attributes:
5320 @table @code
5321 @item interrupt
5322 @itemx interrupt_handler
5323 @cindex @code{interrupt} function attribute, V850
5324 @cindex @code{interrupt_handler} function attribute, V850
5325 Use these attributes to indicate
5326 that the specified function is an interrupt handler.  The compiler generates
5327 function entry and exit sequences suitable for use in an interrupt handler
5328 when either attribute is present.
5329 @end table
5331 @node Visium Function Attributes
5332 @subsection Visium Function Attributes
5334 These function attributes are supported by the Visium back end:
5336 @table @code
5337 @item interrupt
5338 @cindex @code{interrupt} function attribute, Visium
5339 Use this attribute to indicate
5340 that the specified function is an interrupt handler.  The compiler generates
5341 function entry and exit sequences suitable for use in an interrupt handler
5342 when this attribute is present.
5343 @end table
5345 @node x86 Function Attributes
5346 @subsection x86 Function Attributes
5348 These function attributes are supported by the x86 back end:
5350 @table @code
5351 @item cdecl
5352 @cindex @code{cdecl} function attribute, x86-32
5353 @cindex functions that pop the argument stack on x86-32
5354 @opindex mrtd
5355 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5356 assume that the calling function pops off the stack space used to
5357 pass arguments.  This is
5358 useful to override the effects of the @option{-mrtd} switch.
5360 @item fastcall
5361 @cindex @code{fastcall} function attribute, x86-32
5362 @cindex functions that pop the argument stack on x86-32
5363 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5364 pass the first argument (if of integral type) in the register ECX and
5365 the second argument (if of integral type) in the register EDX@.  Subsequent
5366 and other typed arguments are passed on the stack.  The called function
5367 pops the arguments off the stack.  If the number of arguments is variable all
5368 arguments are pushed on the stack.
5370 @item thiscall
5371 @cindex @code{thiscall} function attribute, x86-32
5372 @cindex functions that pop the argument stack on x86-32
5373 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5374 pass the first argument (if of integral type) in the register ECX.
5375 Subsequent and other typed arguments are passed on the stack. The called
5376 function pops the arguments off the stack.
5377 If the number of arguments is variable all arguments are pushed on the
5378 stack.
5379 The @code{thiscall} attribute is intended for C++ non-static member functions.
5380 As a GCC extension, this calling convention can be used for C functions
5381 and for static member methods.
5383 @item ms_abi
5384 @itemx sysv_abi
5385 @cindex @code{ms_abi} function attribute, x86
5386 @cindex @code{sysv_abi} function attribute, x86
5388 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5389 to indicate which calling convention should be used for a function.  The
5390 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5391 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5392 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5393 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5395 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5396 requires the @option{-maccumulate-outgoing-args} option.
5398 @item callee_pop_aggregate_return (@var{number})
5399 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5401 On x86-32 targets, you can use this attribute to control how
5402 aggregates are returned in memory.  If the caller is responsible for
5403 popping the hidden pointer together with the rest of the arguments, specify
5404 @var{number} equal to zero.  If callee is responsible for popping the
5405 hidden pointer, specify @var{number} equal to one.  
5407 The default x86-32 ABI assumes that the callee pops the
5408 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5409 the compiler assumes that the
5410 caller pops the stack for hidden pointer.
5412 @item ms_hook_prologue
5413 @cindex @code{ms_hook_prologue} function attribute, x86
5415 On 32-bit and 64-bit x86 targets, you can use
5416 this function attribute to make GCC generate the ``hot-patching'' function
5417 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5418 and newer.
5420 @item naked
5421 @cindex @code{naked} function attribute, x86
5422 This attribute allows the compiler to construct the
5423 requisite function declaration, while allowing the body of the
5424 function to be assembly code. The specified function will not have
5425 prologue/epilogue sequences generated by the compiler. Only basic
5426 @code{asm} statements can safely be included in naked functions
5427 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5428 basic @code{asm} and C code may appear to work, they cannot be
5429 depended upon to work reliably and are not supported.
5431 @item regparm (@var{number})
5432 @cindex @code{regparm} function attribute, x86
5433 @cindex functions that are passed arguments in registers on x86-32
5434 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5435 pass arguments number one to @var{number} if they are of integral type
5436 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5437 take a variable number of arguments continue to be passed all of their
5438 arguments on the stack.
5440 Beware that on some ELF systems this attribute is unsuitable for
5441 global functions in shared libraries with lazy binding (which is the
5442 default).  Lazy binding sends the first call via resolving code in
5443 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5444 per the standard calling conventions.  Solaris 8 is affected by this.
5445 Systems with the GNU C Library version 2.1 or higher
5446 and FreeBSD are believed to be
5447 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5448 disabled with the linker or the loader if desired, to avoid the
5449 problem.)
5451 @item sseregparm
5452 @cindex @code{sseregparm} function attribute, x86
5453 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5454 causes the compiler to pass up to 3 floating-point arguments in
5455 SSE registers instead of on the stack.  Functions that take a
5456 variable number of arguments continue to pass all of their
5457 floating-point arguments on the stack.
5459 @item force_align_arg_pointer
5460 @cindex @code{force_align_arg_pointer} function attribute, x86
5461 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5462 applied to individual function definitions, generating an alternate
5463 prologue and epilogue that realigns the run-time stack if necessary.
5464 This supports mixing legacy codes that run with a 4-byte aligned stack
5465 with modern codes that keep a 16-byte stack for SSE compatibility.
5467 @item stdcall
5468 @cindex @code{stdcall} function attribute, x86-32
5469 @cindex functions that pop the argument stack on x86-32
5470 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5471 assume that the called function pops off the stack space used to
5472 pass arguments, unless it takes a variable number of arguments.
5474 @item no_caller_saved_registers
5475 @cindex @code{no_caller_saved_registers} function attribute, x86
5476 Use this attribute to indicate that the specified function has no
5477 caller-saved registers. That is, all registers are callee-saved. For
5478 example, this attribute can be used for a function called from an
5479 interrupt handler. The compiler generates proper function entry and
5480 exit sequences to save and restore any modified registers, except for
5481 the EFLAGS register.  Since GCC doesn't preserve MPX, SSE, MMX nor x87
5482 states, the GCC option @option{-mgeneral-regs-only} should be used to
5483 compile functions with @code{no_caller_saved_registers} attribute.
5485 @item interrupt
5486 @cindex @code{interrupt} function attribute, x86
5487 Use this attribute to indicate that the specified function is an
5488 interrupt handler or an exception handler (depending on parameters passed
5489 to the function, explained further).  The compiler generates function
5490 entry and exit sequences suitable for use in an interrupt handler when
5491 this attribute is present.  The @code{IRET} instruction, instead of the
5492 @code{RET} instruction, is used to return from interrupt handlers.  All
5493 registers, except for the EFLAGS register which is restored by the
5494 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5495 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5496 @option{-mgeneral-regs-only} should be used to compile interrupt and
5497 exception handlers.
5499 Any interruptible-without-stack-switch code must be compiled with
5500 @option{-mno-red-zone} since interrupt handlers can and will, because
5501 of the hardware design, touch the red zone.
5503 An interrupt handler must be declared with a mandatory pointer
5504 argument:
5506 @smallexample
5507 struct interrupt_frame;
5509 __attribute__ ((interrupt))
5510 void
5511 f (struct interrupt_frame *frame)
5514 @end smallexample
5516 @noindent
5517 and you must define @code{struct interrupt_frame} as described in the
5518 processor's manual.
5520 Exception handlers differ from interrupt handlers because the system
5521 pushes an error code on the stack.  An exception handler declaration is
5522 similar to that for an interrupt handler, but with a different mandatory
5523 function signature.  The compiler arranges to pop the error code off the
5524 stack before the @code{IRET} instruction.
5526 @smallexample
5527 #ifdef __x86_64__
5528 typedef unsigned long long int uword_t;
5529 #else
5530 typedef unsigned int uword_t;
5531 #endif
5533 struct interrupt_frame;
5535 __attribute__ ((interrupt))
5536 void
5537 f (struct interrupt_frame *frame, uword_t error_code)
5539   ...
5541 @end smallexample
5543 Exception handlers should only be used for exceptions that push an error
5544 code; you should use an interrupt handler in other cases.  The system
5545 will crash if the wrong kind of handler is used.
5547 @item target (@var{options})
5548 @cindex @code{target} function attribute
5549 As discussed in @ref{Common Function Attributes}, this attribute 
5550 allows specification of target-specific compilation options.
5552 On the x86, the following options are allowed:
5553 @table @samp
5554 @item abm
5555 @itemx no-abm
5556 @cindex @code{target("abm")} function attribute, x86
5557 Enable/disable the generation of the advanced bit instructions.
5559 @item aes
5560 @itemx no-aes
5561 @cindex @code{target("aes")} function attribute, x86
5562 Enable/disable the generation of the AES instructions.
5564 @item default
5565 @cindex @code{target("default")} function attribute, x86
5566 @xref{Function Multiversioning}, where it is used to specify the
5567 default function version.
5569 @item mmx
5570 @itemx no-mmx
5571 @cindex @code{target("mmx")} function attribute, x86
5572 Enable/disable the generation of the MMX instructions.
5574 @item pclmul
5575 @itemx no-pclmul
5576 @cindex @code{target("pclmul")} function attribute, x86
5577 Enable/disable the generation of the PCLMUL instructions.
5579 @item popcnt
5580 @itemx no-popcnt
5581 @cindex @code{target("popcnt")} function attribute, x86
5582 Enable/disable the generation of the POPCNT instruction.
5584 @item sse
5585 @itemx no-sse
5586 @cindex @code{target("sse")} function attribute, x86
5587 Enable/disable the generation of the SSE instructions.
5589 @item sse2
5590 @itemx no-sse2
5591 @cindex @code{target("sse2")} function attribute, x86
5592 Enable/disable the generation of the SSE2 instructions.
5594 @item sse3
5595 @itemx no-sse3
5596 @cindex @code{target("sse3")} function attribute, x86
5597 Enable/disable the generation of the SSE3 instructions.
5599 @item sse4
5600 @itemx no-sse4
5601 @cindex @code{target("sse4")} function attribute, x86
5602 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5603 and SSE4.2).
5605 @item sse4.1
5606 @itemx no-sse4.1
5607 @cindex @code{target("sse4.1")} function attribute, x86
5608 Enable/disable the generation of the sse4.1 instructions.
5610 @item sse4.2
5611 @itemx no-sse4.2
5612 @cindex @code{target("sse4.2")} function attribute, x86
5613 Enable/disable the generation of the sse4.2 instructions.
5615 @item sse4a
5616 @itemx no-sse4a
5617 @cindex @code{target("sse4a")} function attribute, x86
5618 Enable/disable the generation of the SSE4A instructions.
5620 @item fma4
5621 @itemx no-fma4
5622 @cindex @code{target("fma4")} function attribute, x86
5623 Enable/disable the generation of the FMA4 instructions.
5625 @item xop
5626 @itemx no-xop
5627 @cindex @code{target("xop")} function attribute, x86
5628 Enable/disable the generation of the XOP instructions.
5630 @item lwp
5631 @itemx no-lwp
5632 @cindex @code{target("lwp")} function attribute, x86
5633 Enable/disable the generation of the LWP instructions.
5635 @item ssse3
5636 @itemx no-ssse3
5637 @cindex @code{target("ssse3")} function attribute, x86
5638 Enable/disable the generation of the SSSE3 instructions.
5640 @item cld
5641 @itemx no-cld
5642 @cindex @code{target("cld")} function attribute, x86
5643 Enable/disable the generation of the CLD before string moves.
5645 @item fancy-math-387
5646 @itemx no-fancy-math-387
5647 @cindex @code{target("fancy-math-387")} function attribute, x86
5648 Enable/disable the generation of the @code{sin}, @code{cos}, and
5649 @code{sqrt} instructions on the 387 floating-point unit.
5651 @item ieee-fp
5652 @itemx no-ieee-fp
5653 @cindex @code{target("ieee-fp")} function attribute, x86
5654 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5656 @item inline-all-stringops
5657 @itemx no-inline-all-stringops
5658 @cindex @code{target("inline-all-stringops")} function attribute, x86
5659 Enable/disable inlining of string operations.
5661 @item inline-stringops-dynamically
5662 @itemx no-inline-stringops-dynamically
5663 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5664 Enable/disable the generation of the inline code to do small string
5665 operations and calling the library routines for large operations.
5667 @item align-stringops
5668 @itemx no-align-stringops
5669 @cindex @code{target("align-stringops")} function attribute, x86
5670 Do/do not align destination of inlined string operations.
5672 @item recip
5673 @itemx no-recip
5674 @cindex @code{target("recip")} function attribute, x86
5675 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5676 instructions followed an additional Newton-Raphson step instead of
5677 doing a floating-point division.
5679 @item arch=@var{ARCH}
5680 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5681 Specify the architecture to generate code for in compiling the function.
5683 @item tune=@var{TUNE}
5684 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5685 Specify the architecture to tune for in compiling the function.
5687 @item fpmath=@var{FPMATH}
5688 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5689 Specify which floating-point unit to use.  You must specify the
5690 @code{target("fpmath=sse,387")} option as
5691 @code{target("fpmath=sse+387")} because the comma would separate
5692 different options.
5693 @end table
5695 On the x86, the inliner does not inline a
5696 function that has different target options than the caller, unless the
5697 callee has a subset of the target options of the caller.  For example
5698 a function declared with @code{target("sse3")} can inline a function
5699 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5700 @end table
5702 @node Xstormy16 Function Attributes
5703 @subsection Xstormy16 Function Attributes
5705 These function attributes are supported by the Xstormy16 back end:
5707 @table @code
5708 @item interrupt
5709 @cindex @code{interrupt} function attribute, Xstormy16
5710 Use this attribute to indicate
5711 that the specified function is an interrupt handler.  The compiler generates
5712 function entry and exit sequences suitable for use in an interrupt handler
5713 when this attribute is present.
5714 @end table
5716 @node Variable Attributes
5717 @section Specifying Attributes of Variables
5718 @cindex attribute of variables
5719 @cindex variable attributes
5721 The keyword @code{__attribute__} allows you to specify special
5722 attributes of variables or structure fields.  This keyword is followed
5723 by an attribute specification inside double parentheses.  Some
5724 attributes are currently defined generically for variables.
5725 Other attributes are defined for variables on particular target
5726 systems.  Other attributes are available for functions
5727 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5728 enumerators (@pxref{Enumerator Attributes}), statements
5729 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5730 Other front ends might define more attributes
5731 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5733 @xref{Attribute Syntax}, for details of the exact syntax for using
5734 attributes.
5736 @menu
5737 * Common Variable Attributes::
5738 * AVR Variable Attributes::
5739 * Blackfin Variable Attributes::
5740 * H8/300 Variable Attributes::
5741 * IA-64 Variable Attributes::
5742 * M32R/D Variable Attributes::
5743 * MeP Variable Attributes::
5744 * Microsoft Windows Variable Attributes::
5745 * MSP430 Variable Attributes::
5746 * Nvidia PTX Variable Attributes::
5747 * PowerPC Variable Attributes::
5748 * RL78 Variable Attributes::
5749 * SPU Variable Attributes::
5750 * V850 Variable Attributes::
5751 * x86 Variable Attributes::
5752 * Xstormy16 Variable Attributes::
5753 @end menu
5755 @node Common Variable Attributes
5756 @subsection Common Variable Attributes
5758 The following attributes are supported on most targets.
5760 @table @code
5761 @cindex @code{aligned} variable attribute
5762 @item aligned (@var{alignment})
5763 This attribute specifies a minimum alignment for the variable or
5764 structure field, measured in bytes.  For example, the declaration:
5766 @smallexample
5767 int x __attribute__ ((aligned (16))) = 0;
5768 @end smallexample
5770 @noindent
5771 causes the compiler to allocate the global variable @code{x} on a
5772 16-byte boundary.  On a 68040, this could be used in conjunction with
5773 an @code{asm} expression to access the @code{move16} instruction which
5774 requires 16-byte aligned operands.
5776 You can also specify the alignment of structure fields.  For example, to
5777 create a double-word aligned @code{int} pair, you could write:
5779 @smallexample
5780 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5781 @end smallexample
5783 @noindent
5784 This is an alternative to creating a union with a @code{double} member,
5785 which forces the union to be double-word aligned.
5787 As in the preceding examples, you can explicitly specify the alignment
5788 (in bytes) that you wish the compiler to use for a given variable or
5789 structure field.  Alternatively, you can leave out the alignment factor
5790 and just ask the compiler to align a variable or field to the
5791 default alignment for the target architecture you are compiling for.
5792 The default alignment is sufficient for all scalar types, but may not be
5793 enough for all vector types on a target that supports vector operations.
5794 The default alignment is fixed for a particular target ABI.
5796 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5797 which is the largest alignment ever used for any data type on the
5798 target machine you are compiling for.  For example, you could write:
5800 @smallexample
5801 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5802 @end smallexample
5804 The compiler automatically sets the alignment for the declared
5805 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5806 often make copy operations more efficient, because the compiler can
5807 use whatever instructions copy the biggest chunks of memory when
5808 performing copies to or from the variables or fields that you have
5809 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5810 may change depending on command-line options.
5812 When used on a struct, or struct member, the @code{aligned} attribute can
5813 only increase the alignment; in order to decrease it, the @code{packed}
5814 attribute must be specified as well.  When used as part of a typedef, the
5815 @code{aligned} attribute can both increase and decrease alignment, and
5816 specifying the @code{packed} attribute generates a warning.
5818 Note that the effectiveness of @code{aligned} attributes may be limited
5819 by inherent limitations in your linker.  On many systems, the linker is
5820 only able to arrange for variables to be aligned up to a certain maximum
5821 alignment.  (For some linkers, the maximum supported alignment may
5822 be very very small.)  If your linker is only able to align variables
5823 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5824 in an @code{__attribute__} still only provides you with 8-byte
5825 alignment.  See your linker documentation for further information.
5827 The @code{aligned} attribute can also be used for functions
5828 (@pxref{Common Function Attributes}.)
5830 @cindex @code{warn_if_not_aligned} variable attribute
5831 @item warn_if_not_aligned (@var{alignment})
5832 This attribute specifies a threshold for the structure field, measured
5833 in bytes.  If the structure field is aligned below the threshold, a
5834 warning will be issued.  For example, the declaration:
5836 @smallexample
5837 struct foo
5839   int i1;
5840   int i2;
5841   unsigned long long x __attribute__((warn_if_not_aligned(16)));
5843 @end smallexample
5845 @noindent
5846 causes the compiler to issue an warning on @code{struct foo}, like
5847 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
5848 The compiler also issues a warning, like @samp{warning: 'x' offset
5849 8 in 'struct foo' isn't aligned to 16}, when the structure field has
5850 the misaligned offset:
5852 @smallexample
5853 struct foo
5855   int i1;
5856   int i2;
5857   unsigned long long x __attribute__((warn_if_not_aligned(16)));
5858 @} __attribute__((aligned(16)));
5859 @end smallexample
5861 This warning can be disabled by @option{-Wno-if-not-aligned}.
5862 The @code{warn_if_not_aligned} attribute can also be used for types
5863 (@pxref{Common Type Attributes}.)
5865 @item cleanup (@var{cleanup_function})
5866 @cindex @code{cleanup} variable attribute
5867 The @code{cleanup} attribute runs a function when the variable goes
5868 out of scope.  This attribute can only be applied to auto function
5869 scope variables; it may not be applied to parameters or variables
5870 with static storage duration.  The function must take one parameter,
5871 a pointer to a type compatible with the variable.  The return value
5872 of the function (if any) is ignored.
5874 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5875 is run during the stack unwinding that happens during the
5876 processing of the exception.  Note that the @code{cleanup} attribute
5877 does not allow the exception to be caught, only to perform an action.
5878 It is undefined what happens if @var{cleanup_function} does not
5879 return normally.
5881 @item common
5882 @itemx nocommon
5883 @cindex @code{common} variable attribute
5884 @cindex @code{nocommon} variable attribute
5885 @opindex fcommon
5886 @opindex fno-common
5887 The @code{common} attribute requests GCC to place a variable in
5888 ``common'' storage.  The @code{nocommon} attribute requests the
5889 opposite---to allocate space for it directly.
5891 These attributes override the default chosen by the
5892 @option{-fno-common} and @option{-fcommon} flags respectively.
5894 @item deprecated
5895 @itemx deprecated (@var{msg})
5896 @cindex @code{deprecated} variable attribute
5897 The @code{deprecated} attribute results in a warning if the variable
5898 is used anywhere in the source file.  This is useful when identifying
5899 variables that are expected to be removed in a future version of a
5900 program.  The warning also includes the location of the declaration
5901 of the deprecated variable, to enable users to easily find further
5902 information about why the variable is deprecated, or what they should
5903 do instead.  Note that the warning only occurs for uses:
5905 @smallexample
5906 extern int old_var __attribute__ ((deprecated));
5907 extern int old_var;
5908 int new_fn () @{ return old_var; @}
5909 @end smallexample
5911 @noindent
5912 results in a warning on line 3 but not line 2.  The optional @var{msg}
5913 argument, which must be a string, is printed in the warning if
5914 present.
5916 The @code{deprecated} attribute can also be used for functions and
5917 types (@pxref{Common Function Attributes},
5918 @pxref{Common Type Attributes}).
5920 @item nonstring (@var{nonstring})
5921 @cindex @code{nonstring} variable attribute
5922 The @code{nonstring} variable attribute specifies that an object or member
5923 declaration with type array of @code{char} or pointer to @code{char} is
5924 intended to store character arrays that do not necessarily contain
5925 a terminating @code{NUL} character.  This is useful to avoid warnings
5926 when such an array or pointer is used as an argument to a bounded string
5927 manipulation function such as @code{strncpy}.  For example, without the
5928 attribute, GCC will issue a warning for the call below because it may
5929 truncate the copy without appending the terminating NUL character.  Using
5930 the attribute makes it possible to suppress the warning.
5932 @smallexample
5933 struct Data
5935   char name [32] __attribute__ ((nonstring));
5937 void f (struct Data *pd, const char *s)
5939   strncpy (pd->name, s, sizeof pd->name);
5940   @dots{}
5942 @end smallexample
5944 @item mode (@var{mode})
5945 @cindex @code{mode} variable attribute
5946 This attribute specifies the data type for the declaration---whichever
5947 type corresponds to the mode @var{mode}.  This in effect lets you
5948 request an integer or floating-point type according to its width.
5950 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
5951 for a list of the possible keywords for @var{mode}.
5952 You may also specify a mode of @code{byte} or @code{__byte__} to
5953 indicate the mode corresponding to a one-byte integer, @code{word} or
5954 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5955 or @code{__pointer__} for the mode used to represent pointers.
5957 @item packed
5958 @cindex @code{packed} variable attribute
5959 The @code{packed} attribute specifies that a variable or structure field
5960 should have the smallest possible alignment---one byte for a variable,
5961 and one bit for a field, unless you specify a larger value with the
5962 @code{aligned} attribute.
5964 Here is a structure in which the field @code{x} is packed, so that it
5965 immediately follows @code{a}:
5967 @smallexample
5968 struct foo
5970   char a;
5971   int x[2] __attribute__ ((packed));
5973 @end smallexample
5975 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5976 @code{packed} attribute on bit-fields of type @code{char}.  This has
5977 been fixed in GCC 4.4 but the change can lead to differences in the
5978 structure layout.  See the documentation of
5979 @option{-Wpacked-bitfield-compat} for more information.
5981 @item section ("@var{section-name}")
5982 @cindex @code{section} variable attribute
5983 Normally, the compiler places the objects it generates in sections like
5984 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5985 or you need certain particular variables to appear in special sections,
5986 for example to map to special hardware.  The @code{section}
5987 attribute specifies that a variable (or function) lives in a particular
5988 section.  For example, this small program uses several specific section names:
5990 @smallexample
5991 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5992 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5993 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5994 int init_data __attribute__ ((section ("INITDATA")));
5996 main()
5998   /* @r{Initialize stack pointer} */
5999   init_sp (stack + sizeof (stack));
6001   /* @r{Initialize initialized data} */
6002   memcpy (&init_data, &data, &edata - &data);
6004   /* @r{Turn on the serial ports} */
6005   init_duart (&a);
6006   init_duart (&b);
6008 @end smallexample
6010 @noindent
6011 Use the @code{section} attribute with
6012 @emph{global} variables and not @emph{local} variables,
6013 as shown in the example.
6015 You may use the @code{section} attribute with initialized or
6016 uninitialized global variables but the linker requires
6017 each object be defined once, with the exception that uninitialized
6018 variables tentatively go in the @code{common} (or @code{bss}) section
6019 and can be multiply ``defined''.  Using the @code{section} attribute
6020 changes what section the variable goes into and may cause the
6021 linker to issue an error if an uninitialized variable has multiple
6022 definitions.  You can force a variable to be initialized with the
6023 @option{-fno-common} flag or the @code{nocommon} attribute.
6025 Some file formats do not support arbitrary sections so the @code{section}
6026 attribute is not available on all platforms.
6027 If you need to map the entire contents of a module to a particular
6028 section, consider using the facilities of the linker instead.
6030 @item tls_model ("@var{tls_model}")
6031 @cindex @code{tls_model} variable attribute
6032 The @code{tls_model} attribute sets thread-local storage model
6033 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6034 overriding @option{-ftls-model=} command-line switch on a per-variable
6035 basis.
6036 The @var{tls_model} argument should be one of @code{global-dynamic},
6037 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6039 Not all targets support this attribute.
6041 @item unused
6042 @cindex @code{unused} variable attribute
6043 This attribute, attached to a variable, means that the variable is meant
6044 to be possibly unused.  GCC does not produce a warning for this
6045 variable.
6047 @item used
6048 @cindex @code{used} variable attribute
6049 This attribute, attached to a variable with static storage, means that
6050 the variable must be emitted even if it appears that the variable is not
6051 referenced.
6053 When applied to a static data member of a C++ class template, the
6054 attribute also means that the member is instantiated if the
6055 class itself is instantiated.
6057 @item vector_size (@var{bytes})
6058 @cindex @code{vector_size} variable attribute
6059 This attribute specifies the vector size for the variable, measured in
6060 bytes.  For example, the declaration:
6062 @smallexample
6063 int foo __attribute__ ((vector_size (16)));
6064 @end smallexample
6066 @noindent
6067 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6068 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6069 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6071 This attribute is only applicable to integral and float scalars,
6072 although arrays, pointers, and function return values are allowed in
6073 conjunction with this construct.
6075 Aggregates with this attribute are invalid, even if they are of the same
6076 size as a corresponding scalar.  For example, the declaration:
6078 @smallexample
6079 struct S @{ int a; @};
6080 struct S  __attribute__ ((vector_size (16))) foo;
6081 @end smallexample
6083 @noindent
6084 is invalid even if the size of the structure is the same as the size of
6085 the @code{int}.
6087 @item visibility ("@var{visibility_type}")
6088 @cindex @code{visibility} variable attribute
6089 This attribute affects the linkage of the declaration to which it is attached.
6090 The @code{visibility} attribute is described in
6091 @ref{Common Function Attributes}.
6093 @item weak
6094 @cindex @code{weak} variable attribute
6095 The @code{weak} attribute is described in
6096 @ref{Common Function Attributes}.
6098 @end table
6100 @node AVR Variable Attributes
6101 @subsection AVR Variable Attributes
6103 @table @code
6104 @item progmem
6105 @cindex @code{progmem} variable attribute, AVR
6106 The @code{progmem} attribute is used on the AVR to place read-only
6107 data in the non-volatile program memory (flash). The @code{progmem}
6108 attribute accomplishes this by putting respective variables into a
6109 section whose name starts with @code{.progmem}.
6111 This attribute works similar to the @code{section} attribute
6112 but adds additional checking.
6114 @table @asis
6115 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6116 @code{progmem} affects the location
6117 of the data but not how this data is accessed.
6118 In order to read data located with the @code{progmem} attribute
6119 (inline) assembler must be used.
6120 @smallexample
6121 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6122 #include <avr/pgmspace.h> 
6124 /* Locate var in flash memory */
6125 const int var[2] PROGMEM = @{ 1, 2 @};
6127 int read_var (int i)
6129     /* Access var[] by accessor macro from avr/pgmspace.h */
6130     return (int) pgm_read_word (& var[i]);
6132 @end smallexample
6134 AVR is a Harvard architecture processor and data and read-only data
6135 normally resides in the data memory (RAM).
6137 See also the @ref{AVR Named Address Spaces} section for
6138 an alternate way to locate and access data in flash memory.
6140 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6141 On such devices, there is no need for attribute @code{progmem} or
6142 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6143 Just use standard C / C++.  The compiler will generate @code{LD*}
6144 instructions.  As flash memory is visible in the RAM address range,
6145 and the default linker script does @emph{not} locate @code{.rodata} in
6146 RAM, no special features are needed in order not to waste RAM for
6147 read-only data or to read from flash.  You might even get slightly better
6148 performance by
6149 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6150 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6151 an overview.
6153 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6154 The compiler adds @code{0x4000}
6155 to the addresses of objects and declarations in @code{progmem} and locates
6156 the objects in flash memory, namely in section @code{.progmem.data}.
6157 The offset is needed because the flash memory is visible in the RAM
6158 address space starting at address @code{0x4000}.
6160 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6161 no special functions or macros are needed.
6163 @smallexample
6164 /* var is located in flash memory */
6165 extern const int var[2] __attribute__((progmem));
6167 int read_var (int i)
6169     return var[i];
6171 @end smallexample
6173 Please notice that on these devices, there is no need for @code{progmem}
6174 at all.
6176 @end table
6178 @item io
6179 @itemx io (@var{addr})
6180 @cindex @code{io} variable attribute, AVR
6181 Variables with the @code{io} attribute are used to address
6182 memory-mapped peripherals in the io address range.
6183 If an address is specified, the variable
6184 is assigned that address, and the value is interpreted as an
6185 address in the data address space.
6186 Example:
6188 @smallexample
6189 volatile int porta __attribute__((io (0x22)));
6190 @end smallexample
6192 The address specified in the address in the data address range.
6194 Otherwise, the variable it is not assigned an address, but the
6195 compiler will still use in/out instructions where applicable,
6196 assuming some other module assigns an address in the io address range.
6197 Example:
6199 @smallexample
6200 extern volatile int porta __attribute__((io));
6201 @end smallexample
6203 @item io_low
6204 @itemx io_low (@var{addr})
6205 @cindex @code{io_low} variable attribute, AVR
6206 This is like the @code{io} attribute, but additionally it informs the
6207 compiler that the object lies in the lower half of the I/O area,
6208 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6209 instructions.
6211 @item address
6212 @itemx address (@var{addr})
6213 @cindex @code{address} variable attribute, AVR
6214 Variables with the @code{address} attribute are used to address
6215 memory-mapped peripherals that may lie outside the io address range.
6217 @smallexample
6218 volatile int porta __attribute__((address (0x600)));
6219 @end smallexample
6221 @item absdata
6222 @cindex @code{absdata} variable attribute, AVR
6223 Variables in static storage and with the @code{absdata} attribute can
6224 be accessed by the @code{LDS} and @code{STS} instructions which take
6225 absolute addresses.
6227 @itemize @bullet
6228 @item
6229 This attribute is only supported for the reduced AVR Tiny core
6230 like ATtiny40.
6232 @item
6233 You must make sure that respective data is located in the
6234 address range @code{0x40}@dots{}@code{0xbf} accessible by
6235 @code{LDS} and @code{STS}.  One way to achieve this as an
6236 appropriate linker description file.
6238 @item
6239 If the location does not fit the address range of @code{LDS}
6240 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6241 warning like
6242 @quotation
6243 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6244 @end quotation
6246 @end itemize
6248 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6250 @end table
6252 @node Blackfin Variable Attributes
6253 @subsection Blackfin Variable Attributes
6255 Three attributes are currently defined for the Blackfin.
6257 @table @code
6258 @item l1_data
6259 @itemx l1_data_A
6260 @itemx l1_data_B
6261 @cindex @code{l1_data} variable attribute, Blackfin
6262 @cindex @code{l1_data_A} variable attribute, Blackfin
6263 @cindex @code{l1_data_B} variable attribute, Blackfin
6264 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6265 Variables with @code{l1_data} attribute are put into the specific section
6266 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6267 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6268 attribute are put into the specific section named @code{.l1.data.B}.
6270 @item l2
6271 @cindex @code{l2} variable attribute, Blackfin
6272 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6273 Variables with @code{l2} attribute are put into the specific section
6274 named @code{.l2.data}.
6275 @end table
6277 @node H8/300 Variable Attributes
6278 @subsection H8/300 Variable Attributes
6280 These variable attributes are available for H8/300 targets:
6282 @table @code
6283 @item eightbit_data
6284 @cindex @code{eightbit_data} variable attribute, H8/300
6285 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6286 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6287 variable should be placed into the eight-bit data section.
6288 The compiler generates more efficient code for certain operations
6289 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6290 256 bytes of data.
6292 You must use GAS and GLD from GNU binutils version 2.7 or later for
6293 this attribute to work correctly.
6295 @item tiny_data
6296 @cindex @code{tiny_data} variable attribute, H8/300
6297 @cindex tiny data section on the H8/300H and H8S
6298 Use this attribute on the H8/300H and H8S to indicate that the specified
6299 variable should be placed into the tiny data section.
6300 The compiler generates more efficient code for loads and stores
6301 on data in the tiny data section.  Note the tiny data area is limited to
6302 slightly under 32KB of data.
6304 @end table
6306 @node IA-64 Variable Attributes
6307 @subsection IA-64 Variable Attributes
6309 The IA-64 back end supports the following variable attribute:
6311 @table @code
6312 @item model (@var{model-name})
6313 @cindex @code{model} variable attribute, IA-64
6315 On IA-64, use this attribute to set the addressability of an object.
6316 At present, the only supported identifier for @var{model-name} is
6317 @code{small}, indicating addressability via ``small'' (22-bit)
6318 addresses (so that their addresses can be loaded with the @code{addl}
6319 instruction).  Caveat: such addressing is by definition not position
6320 independent and hence this attribute must not be used for objects
6321 defined by shared libraries.
6323 @end table
6325 @node M32R/D Variable Attributes
6326 @subsection M32R/D Variable Attributes
6328 One attribute is currently defined for the M32R/D@.
6330 @table @code
6331 @item model (@var{model-name})
6332 @cindex @code{model-name} variable attribute, M32R/D
6333 @cindex variable addressability on the M32R/D
6334 Use this attribute on the M32R/D to set the addressability of an object.
6335 The identifier @var{model-name} is one of @code{small}, @code{medium},
6336 or @code{large}, representing each of the code models.
6338 Small model objects live in the lower 16MB of memory (so that their
6339 addresses can be loaded with the @code{ld24} instruction).
6341 Medium and large model objects may live anywhere in the 32-bit address space
6342 (the compiler generates @code{seth/add3} instructions to load their
6343 addresses).
6344 @end table
6346 @node MeP Variable Attributes
6347 @subsection MeP Variable Attributes
6349 The MeP target has a number of addressing modes and busses.  The
6350 @code{near} space spans the standard memory space's first 16 megabytes
6351 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6352 The @code{based} space is a 128-byte region in the memory space that
6353 is addressed relative to the @code{$tp} register.  The @code{tiny}
6354 space is a 65536-byte region relative to the @code{$gp} register.  In
6355 addition to these memory regions, the MeP target has a separate 16-bit
6356 control bus which is specified with @code{cb} attributes.
6358 @table @code
6360 @item based
6361 @cindex @code{based} variable attribute, MeP
6362 Any variable with the @code{based} attribute is assigned to the
6363 @code{.based} section, and is accessed with relative to the
6364 @code{$tp} register.
6366 @item tiny
6367 @cindex @code{tiny} variable attribute, MeP
6368 Likewise, the @code{tiny} attribute assigned variables to the
6369 @code{.tiny} section, relative to the @code{$gp} register.
6371 @item near
6372 @cindex @code{near} variable attribute, MeP
6373 Variables with the @code{near} attribute are assumed to have addresses
6374 that fit in a 24-bit addressing mode.  This is the default for large
6375 variables (@code{-mtiny=4} is the default) but this attribute can
6376 override @code{-mtiny=} for small variables, or override @code{-ml}.
6378 @item far
6379 @cindex @code{far} variable attribute, MeP
6380 Variables with the @code{far} attribute are addressed using a full
6381 32-bit address.  Since this covers the entire memory space, this
6382 allows modules to make no assumptions about where variables might be
6383 stored.
6385 @item io
6386 @cindex @code{io} variable attribute, MeP
6387 @itemx io (@var{addr})
6388 Variables with the @code{io} attribute are used to address
6389 memory-mapped peripherals.  If an address is specified, the variable
6390 is assigned that address, else it is not assigned an address (it is
6391 assumed some other module assigns an address).  Example:
6393 @smallexample
6394 int timer_count __attribute__((io(0x123)));
6395 @end smallexample
6397 @item cb
6398 @itemx cb (@var{addr})
6399 @cindex @code{cb} variable attribute, MeP
6400 Variables with the @code{cb} attribute are used to access the control
6401 bus, using special instructions.  @code{addr} indicates the control bus
6402 address.  Example:
6404 @smallexample
6405 int cpu_clock __attribute__((cb(0x123)));
6406 @end smallexample
6408 @end table
6410 @node Microsoft Windows Variable Attributes
6411 @subsection Microsoft Windows Variable Attributes
6413 You can use these attributes on Microsoft Windows targets.
6414 @ref{x86 Variable Attributes} for additional Windows compatibility
6415 attributes available on all x86 targets.
6417 @table @code
6418 @item dllimport
6419 @itemx dllexport
6420 @cindex @code{dllimport} variable attribute
6421 @cindex @code{dllexport} variable attribute
6422 The @code{dllimport} and @code{dllexport} attributes are described in
6423 @ref{Microsoft Windows Function Attributes}.
6425 @item selectany
6426 @cindex @code{selectany} variable attribute
6427 The @code{selectany} attribute causes an initialized global variable to
6428 have link-once semantics.  When multiple definitions of the variable are
6429 encountered by the linker, the first is selected and the remainder are
6430 discarded.  Following usage by the Microsoft compiler, the linker is told
6431 @emph{not} to warn about size or content differences of the multiple
6432 definitions.
6434 Although the primary usage of this attribute is for POD types, the
6435 attribute can also be applied to global C++ objects that are initialized
6436 by a constructor.  In this case, the static initialization and destruction
6437 code for the object is emitted in each translation defining the object,
6438 but the calls to the constructor and destructor are protected by a
6439 link-once guard variable.
6441 The @code{selectany} attribute is only available on Microsoft Windows
6442 targets.  You can use @code{__declspec (selectany)} as a synonym for
6443 @code{__attribute__ ((selectany))} for compatibility with other
6444 compilers.
6446 @item shared
6447 @cindex @code{shared} variable attribute
6448 On Microsoft Windows, in addition to putting variable definitions in a named
6449 section, the section can also be shared among all running copies of an
6450 executable or DLL@.  For example, this small program defines shared data
6451 by putting it in a named section @code{shared} and marking the section
6452 shareable:
6454 @smallexample
6455 int foo __attribute__((section ("shared"), shared)) = 0;
6458 main()
6460   /* @r{Read and write foo.  All running
6461      copies see the same value.}  */
6462   return 0;
6464 @end smallexample
6466 @noindent
6467 You may only use the @code{shared} attribute along with @code{section}
6468 attribute with a fully-initialized global definition because of the way
6469 linkers work.  See @code{section} attribute for more information.
6471 The @code{shared} attribute is only available on Microsoft Windows@.
6473 @end table
6475 @node MSP430 Variable Attributes
6476 @subsection MSP430 Variable Attributes
6478 @table @code
6479 @item noinit
6480 @cindex @code{noinit} variable attribute, MSP430 
6481 Any data with the @code{noinit} attribute will not be initialised by
6482 the C runtime startup code, or the program loader.  Not initialising
6483 data in this way can reduce program startup times.
6485 @item persistent
6486 @cindex @code{persistent} variable attribute, MSP430 
6487 Any variable with the @code{persistent} attribute will not be
6488 initialised by the C runtime startup code.  Instead its value will be
6489 set once, when the application is loaded, and then never initialised
6490 again, even if the processor is reset or the program restarts.
6491 Persistent data is intended to be placed into FLASH RAM, where its
6492 value will be retained across resets.  The linker script being used to
6493 create the application should ensure that persistent data is correctly
6494 placed.
6496 @item lower
6497 @itemx upper
6498 @itemx either
6499 @cindex @code{lower} variable attribute, MSP430 
6500 @cindex @code{upper} variable attribute, MSP430 
6501 @cindex @code{either} variable attribute, MSP430 
6502 These attributes are the same as the MSP430 function attributes of the
6503 same name (@pxref{MSP430 Function Attributes}).  
6504 These attributes can be applied to both functions and variables.
6505 @end table
6507 @node Nvidia PTX Variable Attributes
6508 @subsection Nvidia PTX Variable Attributes
6510 These variable attributes are supported by the Nvidia PTX back end:
6512 @table @code
6513 @item shared
6514 @cindex @code{shared} attribute, Nvidia PTX
6515 Use this attribute to place a variable in the @code{.shared} memory space.
6516 This memory space is private to each cooperative thread array; only threads
6517 within one thread block refer to the same instance of the variable.
6518 The runtime does not initialize variables in this memory space.
6519 @end table
6521 @node PowerPC Variable Attributes
6522 @subsection PowerPC Variable Attributes
6524 Three attributes currently are defined for PowerPC configurations:
6525 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6527 @cindex @code{ms_struct} variable attribute, PowerPC
6528 @cindex @code{gcc_struct} variable attribute, PowerPC
6529 For full documentation of the struct attributes please see the
6530 documentation in @ref{x86 Variable Attributes}.
6532 @cindex @code{altivec} variable attribute, PowerPC
6533 For documentation of @code{altivec} attribute please see the
6534 documentation in @ref{PowerPC Type Attributes}.
6536 @node RL78 Variable Attributes
6537 @subsection RL78 Variable Attributes
6539 @cindex @code{saddr} variable attribute, RL78
6540 The RL78 back end supports the @code{saddr} variable attribute.  This
6541 specifies placement of the corresponding variable in the SADDR area,
6542 which can be accessed more efficiently than the default memory region.
6544 @node SPU Variable Attributes
6545 @subsection SPU Variable Attributes
6547 @cindex @code{spu_vector} variable attribute, SPU
6548 The SPU supports the @code{spu_vector} attribute for variables.  For
6549 documentation of this attribute please see the documentation in
6550 @ref{SPU Type Attributes}.
6552 @node V850 Variable Attributes
6553 @subsection V850 Variable Attributes
6555 These variable attributes are supported by the V850 back end:
6557 @table @code
6559 @item sda
6560 @cindex @code{sda} variable attribute, V850
6561 Use this attribute to explicitly place a variable in the small data area,
6562 which can hold up to 64 kilobytes.
6564 @item tda
6565 @cindex @code{tda} variable attribute, V850
6566 Use this attribute to explicitly place a variable in the tiny data area,
6567 which can hold up to 256 bytes in total.
6569 @item zda
6570 @cindex @code{zda} variable attribute, V850
6571 Use this attribute to explicitly place a variable in the first 32 kilobytes
6572 of memory.
6573 @end table
6575 @node x86 Variable Attributes
6576 @subsection x86 Variable Attributes
6578 Two attributes are currently defined for x86 configurations:
6579 @code{ms_struct} and @code{gcc_struct}.
6581 @table @code
6582 @item ms_struct
6583 @itemx gcc_struct
6584 @cindex @code{ms_struct} variable attribute, x86
6585 @cindex @code{gcc_struct} variable attribute, x86
6587 If @code{packed} is used on a structure, or if bit-fields are used,
6588 it may be that the Microsoft ABI lays out the structure differently
6589 than the way GCC normally does.  Particularly when moving packed
6590 data between functions compiled with GCC and the native Microsoft compiler
6591 (either via function call or as data in a file), it may be necessary to access
6592 either format.
6594 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6595 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6596 command-line options, respectively;
6597 see @ref{x86 Options}, for details of how structure layout is affected.
6598 @xref{x86 Type Attributes}, for information about the corresponding
6599 attributes on types.
6601 @end table
6603 @node Xstormy16 Variable Attributes
6604 @subsection Xstormy16 Variable Attributes
6606 One attribute is currently defined for xstormy16 configurations:
6607 @code{below100}.
6609 @table @code
6610 @item below100
6611 @cindex @code{below100} variable attribute, Xstormy16
6613 If a variable has the @code{below100} attribute (@code{BELOW100} is
6614 allowed also), GCC places the variable in the first 0x100 bytes of
6615 memory and use special opcodes to access it.  Such variables are
6616 placed in either the @code{.bss_below100} section or the
6617 @code{.data_below100} section.
6619 @end table
6621 @node Type Attributes
6622 @section Specifying Attributes of Types
6623 @cindex attribute of types
6624 @cindex type attributes
6626 The keyword @code{__attribute__} allows you to specify special
6627 attributes of types.  Some type attributes apply only to @code{struct}
6628 and @code{union} types, while others can apply to any type defined
6629 via a @code{typedef} declaration.  Other attributes are defined for
6630 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6631 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6632 statements (@pxref{Statement Attributes}), and for
6633 variables (@pxref{Variable Attributes}).
6635 The @code{__attribute__} keyword is followed by an attribute specification
6636 inside double parentheses.  
6638 You may specify type attributes in an enum, struct or union type
6639 declaration or definition by placing them immediately after the
6640 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6641 syntax is to place them just past the closing curly brace of the
6642 definition.
6644 You can also include type attributes in a @code{typedef} declaration.
6645 @xref{Attribute Syntax}, for details of the exact syntax for using
6646 attributes.
6648 @menu
6649 * Common Type Attributes::
6650 * ARM Type Attributes::
6651 * MeP Type Attributes::
6652 * PowerPC Type Attributes::
6653 * SPU Type Attributes::
6654 * x86 Type Attributes::
6655 @end menu
6657 @node Common Type Attributes
6658 @subsection Common Type Attributes
6660 The following type attributes are supported on most targets.
6662 @table @code
6663 @cindex @code{aligned} type attribute
6664 @item aligned (@var{alignment})
6665 This attribute specifies a minimum alignment (in bytes) for variables
6666 of the specified type.  For example, the declarations:
6668 @smallexample
6669 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6670 typedef int more_aligned_int __attribute__ ((aligned (8)));
6671 @end smallexample
6673 @noindent
6674 force the compiler to ensure (as far as it can) that each variable whose
6675 type is @code{struct S} or @code{more_aligned_int} is allocated and
6676 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6677 variables of type @code{struct S} aligned to 8-byte boundaries allows
6678 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6679 store) instructions when copying one variable of type @code{struct S} to
6680 another, thus improving run-time efficiency.
6682 Note that the alignment of any given @code{struct} or @code{union} type
6683 is required by the ISO C standard to be at least a perfect multiple of
6684 the lowest common multiple of the alignments of all of the members of
6685 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6686 effectively adjust the alignment of a @code{struct} or @code{union}
6687 type by attaching an @code{aligned} attribute to any one of the members
6688 of such a type, but the notation illustrated in the example above is a
6689 more obvious, intuitive, and readable way to request the compiler to
6690 adjust the alignment of an entire @code{struct} or @code{union} type.
6692 As in the preceding example, you can explicitly specify the alignment
6693 (in bytes) that you wish the compiler to use for a given @code{struct}
6694 or @code{union} type.  Alternatively, you can leave out the alignment factor
6695 and just ask the compiler to align a type to the maximum
6696 useful alignment for the target machine you are compiling for.  For
6697 example, you could write:
6699 @smallexample
6700 struct S @{ short f[3]; @} __attribute__ ((aligned));
6701 @end smallexample
6703 Whenever you leave out the alignment factor in an @code{aligned}
6704 attribute specification, the compiler automatically sets the alignment
6705 for the type to the largest alignment that is ever used for any data
6706 type on the target machine you are compiling for.  Doing this can often
6707 make copy operations more efficient, because the compiler can use
6708 whatever instructions copy the biggest chunks of memory when performing
6709 copies to or from the variables that have types that you have aligned
6710 this way.
6712 In the example above, if the size of each @code{short} is 2 bytes, then
6713 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6714 power of two that is greater than or equal to that is 8, so the
6715 compiler sets the alignment for the entire @code{struct S} type to 8
6716 bytes.
6718 Note that although you can ask the compiler to select a time-efficient
6719 alignment for a given type and then declare only individual stand-alone
6720 objects of that type, the compiler's ability to select a time-efficient
6721 alignment is primarily useful only when you plan to create arrays of
6722 variables having the relevant (efficiently aligned) type.  If you
6723 declare or use arrays of variables of an efficiently-aligned type, then
6724 it is likely that your program also does pointer arithmetic (or
6725 subscripting, which amounts to the same thing) on pointers to the
6726 relevant type, and the code that the compiler generates for these
6727 pointer arithmetic operations is often more efficient for
6728 efficiently-aligned types than for other types.
6730 Note that the effectiveness of @code{aligned} attributes may be limited
6731 by inherent limitations in your linker.  On many systems, the linker is
6732 only able to arrange for variables to be aligned up to a certain maximum
6733 alignment.  (For some linkers, the maximum supported alignment may
6734 be very very small.)  If your linker is only able to align variables
6735 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6736 in an @code{__attribute__} still only provides you with 8-byte
6737 alignment.  See your linker documentation for further information.
6739 The @code{aligned} attribute can only increase alignment.  Alignment
6740 can be decreased by specifying the @code{packed} attribute.  See below.
6742 @cindex @code{warn_if_not_aligned} type attribute
6743 @item warn_if_not_aligned (@var{alignment})
6744 This attribute specifies a threshold for the structure field, measured
6745 in bytes.  If the structure field is aligned below the threshold, a
6746 warning will be issued.  For example, the declaration:
6748 @smallexample
6749 typedef unsigned long long __u64
6750    __attribute__((aligned(4),warn_if_not_aligned(8)));
6752 struct foo
6754   int i1;
6755   int i2;
6756   __u64 x;
6758 @end smallexample
6760 @noindent
6761 causes the compiler to issue an warning on @code{struct foo}, like
6762 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
6763 It is used to define @code{struct foo} in such a way that
6764 @code{struct foo} has the same layout and the structure field @code{x}
6765 has the same alignment when @code{__u64} is aligned at either 4 or
6766 8 bytes.  Align @code{struct foo} to 8 bytes:
6768 @smallexample
6769 struct foo
6771   int i1;
6772   int i2;
6773   __u64 x;
6774 @} __attribute__((aligned(8)));
6775 @end smallexample
6777 @noindent
6778 silences the warning.  The compiler also issues a warning, like
6779 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
6780 when the structure field has the misaligned offset:
6782 @smallexample
6783 struct foo
6785   int i1;
6786   int i2;
6787   int i3;
6788   __u64 x;
6789 @} __attribute__((aligned(8)));
6790 @end smallexample
6792 This warning can be disabled by @option{-Wno-if-not-aligned}.
6794 @item bnd_variable_size
6795 @cindex @code{bnd_variable_size} type attribute
6796 @cindex Pointer Bounds Checker attributes
6797 When applied to a structure field, this attribute tells Pointer
6798 Bounds Checker that the size of this field should not be computed
6799 using static type information.  It may be used to mark variably-sized
6800 static array fields placed at the end of a structure.
6802 @smallexample
6803 struct S
6805   int size;
6806   char data[1];
6808 S *p = (S *)malloc (sizeof(S) + 100);
6809 p->data[10] = 0; //Bounds violation
6810 @end smallexample
6812 @noindent
6813 By using an attribute for the field we may avoid unwanted bound
6814 violation checks:
6816 @smallexample
6817 struct S
6819   int size;
6820   char data[1] __attribute__((bnd_variable_size));
6822 S *p = (S *)malloc (sizeof(S) + 100);
6823 p->data[10] = 0; //OK
6824 @end smallexample
6826 @item deprecated
6827 @itemx deprecated (@var{msg})
6828 @cindex @code{deprecated} type attribute
6829 The @code{deprecated} attribute results in a warning if the type
6830 is used anywhere in the source file.  This is useful when identifying
6831 types that are expected to be removed in a future version of a program.
6832 If possible, the warning also includes the location of the declaration
6833 of the deprecated type, to enable users to easily find further
6834 information about why the type is deprecated, or what they should do
6835 instead.  Note that the warnings only occur for uses and then only
6836 if the type is being applied to an identifier that itself is not being
6837 declared as deprecated.
6839 @smallexample
6840 typedef int T1 __attribute__ ((deprecated));
6841 T1 x;
6842 typedef T1 T2;
6843 T2 y;
6844 typedef T1 T3 __attribute__ ((deprecated));
6845 T3 z __attribute__ ((deprecated));
6846 @end smallexample
6848 @noindent
6849 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6850 warning is issued for line 4 because T2 is not explicitly
6851 deprecated.  Line 5 has no warning because T3 is explicitly
6852 deprecated.  Similarly for line 6.  The optional @var{msg}
6853 argument, which must be a string, is printed in the warning if
6854 present.
6856 The @code{deprecated} attribute can also be used for functions and
6857 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6859 @item designated_init
6860 @cindex @code{designated_init} type attribute
6861 This attribute may only be applied to structure types.  It indicates
6862 that any initialization of an object of this type must use designated
6863 initializers rather than positional initializers.  The intent of this
6864 attribute is to allow the programmer to indicate that a structure's
6865 layout may change, and that therefore relying on positional
6866 initialization will result in future breakage.
6868 GCC emits warnings based on this attribute by default; use
6869 @option{-Wno-designated-init} to suppress them.
6871 @item may_alias
6872 @cindex @code{may_alias} type attribute
6873 Accesses through pointers to types with this attribute are not subject
6874 to type-based alias analysis, but are instead assumed to be able to alias
6875 any other type of objects.
6876 In the context of section 6.5 paragraph 7 of the C99 standard,
6877 an lvalue expression
6878 dereferencing such a pointer is treated like having a character type.
6879 See @option{-fstrict-aliasing} for more information on aliasing issues.
6880 This extension exists to support some vector APIs, in which pointers to
6881 one vector type are permitted to alias pointers to a different vector type.
6883 Note that an object of a type with this attribute does not have any
6884 special semantics.
6886 Example of use:
6888 @smallexample
6889 typedef short __attribute__((__may_alias__)) short_a;
6892 main (void)
6894   int a = 0x12345678;
6895   short_a *b = (short_a *) &a;
6897   b[1] = 0;
6899   if (a == 0x12345678)
6900     abort();
6902   exit(0);
6904 @end smallexample
6906 @noindent
6907 If you replaced @code{short_a} with @code{short} in the variable
6908 declaration, the above program would abort when compiled with
6909 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6910 above.
6912 @item packed
6913 @cindex @code{packed} type attribute
6914 This attribute, attached to @code{struct} or @code{union} type
6915 definition, specifies that each member (other than zero-width bit-fields)
6916 of the structure or union is placed to minimize the memory required.  When
6917 attached to an @code{enum} definition, it indicates that the smallest
6918 integral type should be used.
6920 @opindex fshort-enums
6921 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6922 types is equivalent to specifying the @code{packed} attribute on each
6923 of the structure or union members.  Specifying the @option{-fshort-enums}
6924 flag on the command line is equivalent to specifying the @code{packed}
6925 attribute on all @code{enum} definitions.
6927 In the following example @code{struct my_packed_struct}'s members are
6928 packed closely together, but the internal layout of its @code{s} member
6929 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6930 be packed too.
6932 @smallexample
6933 struct my_unpacked_struct
6934  @{
6935     char c;
6936     int i;
6937  @};
6939 struct __attribute__ ((__packed__)) my_packed_struct
6940   @{
6941      char c;
6942      int  i;
6943      struct my_unpacked_struct s;
6944   @};
6945 @end smallexample
6947 You may only specify the @code{packed} attribute attribute on the definition
6948 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6949 that does not also define the enumerated type, structure or union.
6951 @item scalar_storage_order ("@var{endianness}")
6952 @cindex @code{scalar_storage_order} type attribute
6953 When attached to a @code{union} or a @code{struct}, this attribute sets
6954 the storage order, aka endianness, of the scalar fields of the type, as
6955 well as the array fields whose component is scalar.  The supported
6956 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
6957 has no effects on fields which are themselves a @code{union}, a @code{struct}
6958 or an array whose component is a @code{union} or a @code{struct}, and it is
6959 possible for these fields to have a different scalar storage order than the
6960 enclosing type.
6962 This attribute is supported only for targets that use a uniform default
6963 scalar storage order (fortunately, most of them), i.e. targets that store
6964 the scalars either all in big-endian or all in little-endian.
6966 Additional restrictions are enforced for types with the reverse scalar
6967 storage order with regard to the scalar storage order of the target:
6969 @itemize
6970 @item Taking the address of a scalar field of a @code{union} or a
6971 @code{struct} with reverse scalar storage order is not permitted and yields
6972 an error.
6973 @item Taking the address of an array field, whose component is scalar, of
6974 a @code{union} or a @code{struct} with reverse scalar storage order is
6975 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6976 is specified.
6977 @item Taking the address of a @code{union} or a @code{struct} with reverse
6978 scalar storage order is permitted.
6979 @end itemize
6981 These restrictions exist because the storage order attribute is lost when
6982 the address of a scalar or the address of an array with scalar component is
6983 taken, so storing indirectly through this address generally does not work.
6984 The second case is nevertheless allowed to be able to perform a block copy
6985 from or to the array.
6987 Moreover, the use of type punning or aliasing to toggle the storage order
6988 is not supported; that is to say, a given scalar object cannot be accessed
6989 through distinct types that assign a different storage order to it.
6991 @item transparent_union
6992 @cindex @code{transparent_union} type attribute
6994 This attribute, attached to a @code{union} type definition, indicates
6995 that any function parameter having that union type causes calls to that
6996 function to be treated in a special way.
6998 First, the argument corresponding to a transparent union type can be of
6999 any type in the union; no cast is required.  Also, if the union contains
7000 a pointer type, the corresponding argument can be a null pointer
7001 constant or a void pointer expression; and if the union contains a void
7002 pointer type, the corresponding argument can be any pointer expression.
7003 If the union member type is a pointer, qualifiers like @code{const} on
7004 the referenced type must be respected, just as with normal pointer
7005 conversions.
7007 Second, the argument is passed to the function using the calling
7008 conventions of the first member of the transparent union, not the calling
7009 conventions of the union itself.  All members of the union must have the
7010 same machine representation; this is necessary for this argument passing
7011 to work properly.
7013 Transparent unions are designed for library functions that have multiple
7014 interfaces for compatibility reasons.  For example, suppose the
7015 @code{wait} function must accept either a value of type @code{int *} to
7016 comply with POSIX, or a value of type @code{union wait *} to comply with
7017 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7018 @code{wait} would accept both kinds of arguments, but it would also
7019 accept any other pointer type and this would make argument type checking
7020 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7021 as follows:
7023 @smallexample
7024 typedef union __attribute__ ((__transparent_union__))
7025   @{
7026     int *__ip;
7027     union wait *__up;
7028   @} wait_status_ptr_t;
7030 pid_t wait (wait_status_ptr_t);
7031 @end smallexample
7033 @noindent
7034 This interface allows either @code{int *} or @code{union wait *}
7035 arguments to be passed, using the @code{int *} calling convention.
7036 The program can call @code{wait} with arguments of either type:
7038 @smallexample
7039 int w1 () @{ int w; return wait (&w); @}
7040 int w2 () @{ union wait w; return wait (&w); @}
7041 @end smallexample
7043 @noindent
7044 With this interface, @code{wait}'s implementation might look like this:
7046 @smallexample
7047 pid_t wait (wait_status_ptr_t p)
7049   return waitpid (-1, p.__ip, 0);
7051 @end smallexample
7053 @item unused
7054 @cindex @code{unused} type attribute
7055 When attached to a type (including a @code{union} or a @code{struct}),
7056 this attribute means that variables of that type are meant to appear
7057 possibly unused.  GCC does not produce a warning for any variables of
7058 that type, even if the variable appears to do nothing.  This is often
7059 the case with lock or thread classes, which are usually defined and then
7060 not referenced, but contain constructors and destructors that have
7061 nontrivial bookkeeping functions.
7063 @item visibility
7064 @cindex @code{visibility} type attribute
7065 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7066 applied to class, struct, union and enum types.  Unlike other type
7067 attributes, the attribute must appear between the initial keyword and
7068 the name of the type; it cannot appear after the body of the type.
7070 Note that the type visibility is applied to vague linkage entities
7071 associated with the class (vtable, typeinfo node, etc.).  In
7072 particular, if a class is thrown as an exception in one shared object
7073 and caught in another, the class must have default visibility.
7074 Otherwise the two shared objects are unable to use the same
7075 typeinfo node and exception handling will break.
7077 @end table
7079 To specify multiple attributes, separate them by commas within the
7080 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7081 packed))}.
7083 @node ARM Type Attributes
7084 @subsection ARM Type Attributes
7086 @cindex @code{notshared} type attribute, ARM
7087 On those ARM targets that support @code{dllimport} (such as Symbian
7088 OS), you can use the @code{notshared} attribute to indicate that the
7089 virtual table and other similar data for a class should not be
7090 exported from a DLL@.  For example:
7092 @smallexample
7093 class __declspec(notshared) C @{
7094 public:
7095   __declspec(dllimport) C();
7096   virtual void f();
7099 __declspec(dllexport)
7100 C::C() @{@}
7101 @end smallexample
7103 @noindent
7104 In this code, @code{C::C} is exported from the current DLL, but the
7105 virtual table for @code{C} is not exported.  (You can use
7106 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7107 most Symbian OS code uses @code{__declspec}.)
7109 @node MeP Type Attributes
7110 @subsection MeP Type Attributes
7112 @cindex @code{based} type attribute, MeP
7113 @cindex @code{tiny} type attribute, MeP
7114 @cindex @code{near} type attribute, MeP
7115 @cindex @code{far} type attribute, MeP
7116 Many of the MeP variable attributes may be applied to types as well.
7117 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7118 @code{far} attributes may be applied to either.  The @code{io} and
7119 @code{cb} attributes may not be applied to types.
7121 @node PowerPC Type Attributes
7122 @subsection PowerPC Type Attributes
7124 Three attributes currently are defined for PowerPC configurations:
7125 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7127 @cindex @code{ms_struct} type attribute, PowerPC
7128 @cindex @code{gcc_struct} type attribute, PowerPC
7129 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7130 attributes please see the documentation in @ref{x86 Type Attributes}.
7132 @cindex @code{altivec} type attribute, PowerPC
7133 The @code{altivec} attribute allows one to declare AltiVec vector data
7134 types supported by the AltiVec Programming Interface Manual.  The
7135 attribute requires an argument to specify one of three vector types:
7136 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7137 and @code{bool__} (always followed by unsigned).
7139 @smallexample
7140 __attribute__((altivec(vector__)))
7141 __attribute__((altivec(pixel__))) unsigned short
7142 __attribute__((altivec(bool__))) unsigned
7143 @end smallexample
7145 These attributes mainly are intended to support the @code{__vector},
7146 @code{__pixel}, and @code{__bool} AltiVec keywords.
7148 @node SPU Type Attributes
7149 @subsection SPU Type Attributes
7151 @cindex @code{spu_vector} type attribute, SPU
7152 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7153 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7154 Language Extensions Specification.  It is intended to support the
7155 @code{__vector} keyword.
7157 @node x86 Type Attributes
7158 @subsection x86 Type Attributes
7160 Two attributes are currently defined for x86 configurations:
7161 @code{ms_struct} and @code{gcc_struct}.
7163 @table @code
7165 @item ms_struct
7166 @itemx gcc_struct
7167 @cindex @code{ms_struct} type attribute, x86
7168 @cindex @code{gcc_struct} type attribute, x86
7170 If @code{packed} is used on a structure, or if bit-fields are used
7171 it may be that the Microsoft ABI packs them differently
7172 than GCC normally packs them.  Particularly when moving packed
7173 data between functions compiled with GCC and the native Microsoft compiler
7174 (either via function call or as data in a file), it may be necessary to access
7175 either format.
7177 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7178 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7179 command-line options, respectively;
7180 see @ref{x86 Options}, for details of how structure layout is affected.
7181 @xref{x86 Variable Attributes}, for information about the corresponding
7182 attributes on variables.
7184 @end table
7186 @node Label Attributes
7187 @section Label Attributes
7188 @cindex Label Attributes
7190 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7191 details of the exact syntax for using attributes.  Other attributes are 
7192 available for functions (@pxref{Function Attributes}), variables 
7193 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7194 statements (@pxref{Statement Attributes}), and for types
7195 (@pxref{Type Attributes}).
7197 This example uses the @code{cold} label attribute to indicate the 
7198 @code{ErrorHandling} branch is unlikely to be taken and that the
7199 @code{ErrorHandling} label is unused:
7201 @smallexample
7203    asm goto ("some asm" : : : : NoError);
7205 /* This branch (the fall-through from the asm) is less commonly used */
7206 ErrorHandling: 
7207    __attribute__((cold, unused)); /* Semi-colon is required here */
7208    printf("error\n");
7209    return 0;
7211 NoError:
7212    printf("no error\n");
7213    return 1;
7214 @end smallexample
7216 @table @code
7217 @item unused
7218 @cindex @code{unused} label attribute
7219 This feature is intended for program-generated code that may contain 
7220 unused labels, but which is compiled with @option{-Wall}.  It is
7221 not normally appropriate to use in it human-written code, though it
7222 could be useful in cases where the code that jumps to the label is
7223 contained within an @code{#ifdef} conditional.
7225 @item hot
7226 @cindex @code{hot} label attribute
7227 The @code{hot} attribute on a label is used to inform the compiler that
7228 the path following the label is more likely than paths that are not so
7229 annotated.  This attribute is used in cases where @code{__builtin_expect}
7230 cannot be used, for instance with computed goto or @code{asm goto}.
7232 @item cold
7233 @cindex @code{cold} label attribute
7234 The @code{cold} attribute on labels is used to inform the compiler that
7235 the path following the label is unlikely to be executed.  This attribute
7236 is used in cases where @code{__builtin_expect} cannot be used, for instance
7237 with computed goto or @code{asm goto}.
7239 @end table
7241 @node Enumerator Attributes
7242 @section Enumerator Attributes
7243 @cindex Enumerator Attributes
7245 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7246 details of the exact syntax for using attributes.  Other attributes are
7247 available for functions (@pxref{Function Attributes}), variables
7248 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7249 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7251 This example uses the @code{deprecated} enumerator attribute to indicate the
7252 @code{oldval} enumerator is deprecated:
7254 @smallexample
7255 enum E @{
7256   oldval __attribute__((deprecated)),
7257   newval
7261 fn (void)
7263   return oldval;
7265 @end smallexample
7267 @table @code
7268 @item deprecated
7269 @cindex @code{deprecated} enumerator attribute
7270 The @code{deprecated} attribute results in a warning if the enumerator
7271 is used anywhere in the source file.  This is useful when identifying
7272 enumerators that are expected to be removed in a future version of a
7273 program.  The warning also includes the location of the declaration
7274 of the deprecated enumerator, to enable users to easily find further
7275 information about why the enumerator is deprecated, or what they should
7276 do instead.  Note that the warnings only occurs for uses.
7278 @end table
7280 @node Statement Attributes
7281 @section Statement Attributes
7282 @cindex Statement Attributes
7284 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7285 for details of the exact syntax for using attributes.  Other attributes are
7286 available for functions (@pxref{Function Attributes}), variables
7287 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7288 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7290 This example uses the @code{fallthrough} statement attribute to indicate that
7291 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7293 @smallexample
7294 switch (cond)
7295   @{
7296   case 1:
7297     bar (1);
7298     __attribute__((fallthrough));
7299   case 2:
7300     @dots{}
7301   @}
7302 @end smallexample
7304 @table @code
7305 @item fallthrough
7306 @cindex @code{fallthrough} statement attribute
7307 The @code{fallthrough} attribute with a null statement serves as a
7308 fallthrough statement.  It hints to the compiler that a statement
7309 that falls through to another case label, or user-defined label
7310 in a switch statement is intentional and thus the
7311 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7312 fallthrough attribute may appear at most once in each attribute
7313 list, and may not be mixed with other attributes.  It can only
7314 be used in a switch statement (the compiler will issue an error
7315 otherwise), after a preceding statement and before a logically
7316 succeeding case label, or user-defined label.
7318 @end table
7320 @node Attribute Syntax
7321 @section Attribute Syntax
7322 @cindex attribute syntax
7324 This section describes the syntax with which @code{__attribute__} may be
7325 used, and the constructs to which attribute specifiers bind, for the C
7326 language.  Some details may vary for C++ and Objective-C@.  Because of
7327 infelicities in the grammar for attributes, some forms described here
7328 may not be successfully parsed in all cases.
7330 There are some problems with the semantics of attributes in C++.  For
7331 example, there are no manglings for attributes, although they may affect
7332 code generation, so problems may arise when attributed types are used in
7333 conjunction with templates or overloading.  Similarly, @code{typeid}
7334 does not distinguish between types with different attributes.  Support
7335 for attributes in C++ may be restricted in future to attributes on
7336 declarations only, but not on nested declarators.
7338 @xref{Function Attributes}, for details of the semantics of attributes
7339 applying to functions.  @xref{Variable Attributes}, for details of the
7340 semantics of attributes applying to variables.  @xref{Type Attributes},
7341 for details of the semantics of attributes applying to structure, union
7342 and enumerated types.
7343 @xref{Label Attributes}, for details of the semantics of attributes 
7344 applying to labels.
7345 @xref{Enumerator Attributes}, for details of the semantics of attributes
7346 applying to enumerators.
7347 @xref{Statement Attributes}, for details of the semantics of attributes
7348 applying to statements.
7350 An @dfn{attribute specifier} is of the form
7351 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7352 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7353 each attribute is one of the following:
7355 @itemize @bullet
7356 @item
7357 Empty.  Empty attributes are ignored.
7359 @item
7360 An attribute name
7361 (which may be an identifier such as @code{unused}, or a reserved
7362 word such as @code{const}).
7364 @item
7365 An attribute name followed by a parenthesized list of
7366 parameters for the attribute.
7367 These parameters take one of the following forms:
7369 @itemize @bullet
7370 @item
7371 An identifier.  For example, @code{mode} attributes use this form.
7373 @item
7374 An identifier followed by a comma and a non-empty comma-separated list
7375 of expressions.  For example, @code{format} attributes use this form.
7377 @item
7378 A possibly empty comma-separated list of expressions.  For example,
7379 @code{format_arg} attributes use this form with the list being a single
7380 integer constant expression, and @code{alias} attributes use this form
7381 with the list being a single string constant.
7382 @end itemize
7383 @end itemize
7385 An @dfn{attribute specifier list} is a sequence of one or more attribute
7386 specifiers, not separated by any other tokens.
7388 You may optionally specify attribute names with @samp{__}
7389 preceding and following the name.
7390 This allows you to use them in header files without
7391 being concerned about a possible macro of the same name.  For example,
7392 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7395 @subsubheading Label Attributes
7397 In GNU C, an attribute specifier list may appear after the colon following a
7398 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7399 attributes on labels if the attribute specifier is immediately
7400 followed by a semicolon (i.e., the label applies to an empty
7401 statement).  If the semicolon is missing, C++ label attributes are
7402 ambiguous, as it is permissible for a declaration, which could begin
7403 with an attribute list, to be labelled in C++.  Declarations cannot be
7404 labelled in C90 or C99, so the ambiguity does not arise there.
7406 @subsubheading Enumerator Attributes
7408 In GNU C, an attribute specifier list may appear as part of an enumerator.
7409 The attribute goes after the enumeration constant, before @code{=}, if
7410 present.  The optional attribute in the enumerator appertains to the
7411 enumeration constant.  It is not possible to place the attribute after
7412 the constant expression, if present.
7414 @subsubheading Statement Attributes
7415 In GNU C, an attribute specifier list may appear as part of a null
7416 statement.  The attribute goes before the semicolon.
7418 @subsubheading Type Attributes
7420 An attribute specifier list may appear as part of a @code{struct},
7421 @code{union} or @code{enum} specifier.  It may go either immediately
7422 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7423 the closing brace.  The former syntax is preferred.
7424 Where attribute specifiers follow the closing brace, they are considered
7425 to relate to the structure, union or enumerated type defined, not to any
7426 enclosing declaration the type specifier appears in, and the type
7427 defined is not complete until after the attribute specifiers.
7428 @c Otherwise, there would be the following problems: a shift/reduce
7429 @c conflict between attributes binding the struct/union/enum and
7430 @c binding to the list of specifiers/qualifiers; and "aligned"
7431 @c attributes could use sizeof for the structure, but the size could be
7432 @c changed later by "packed" attributes.
7435 @subsubheading All other attributes
7437 Otherwise, an attribute specifier appears as part of a declaration,
7438 counting declarations of unnamed parameters and type names, and relates
7439 to that declaration (which may be nested in another declaration, for
7440 example in the case of a parameter declaration), or to a particular declarator
7441 within a declaration.  Where an
7442 attribute specifier is applied to a parameter declared as a function or
7443 an array, it should apply to the function or array rather than the
7444 pointer to which the parameter is implicitly converted, but this is not
7445 yet correctly implemented.
7447 Any list of specifiers and qualifiers at the start of a declaration may
7448 contain attribute specifiers, whether or not such a list may in that
7449 context contain storage class specifiers.  (Some attributes, however,
7450 are essentially in the nature of storage class specifiers, and only make
7451 sense where storage class specifiers may be used; for example,
7452 @code{section}.)  There is one necessary limitation to this syntax: the
7453 first old-style parameter declaration in a function definition cannot
7454 begin with an attribute specifier, because such an attribute applies to
7455 the function instead by syntax described below (which, however, is not
7456 yet implemented in this case).  In some other cases, attribute
7457 specifiers are permitted by this grammar but not yet supported by the
7458 compiler.  All attribute specifiers in this place relate to the
7459 declaration as a whole.  In the obsolescent usage where a type of
7460 @code{int} is implied by the absence of type specifiers, such a list of
7461 specifiers and qualifiers may be an attribute specifier list with no
7462 other specifiers or qualifiers.
7464 At present, the first parameter in a function prototype must have some
7465 type specifier that is not an attribute specifier; this resolves an
7466 ambiguity in the interpretation of @code{void f(int
7467 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7468 the parentheses of a function declarator contain only attributes then
7469 those attributes are ignored, rather than yielding an error or warning
7470 or implying a single parameter of type int, but this is subject to
7471 change.
7473 An attribute specifier list may appear immediately before a declarator
7474 (other than the first) in a comma-separated list of declarators in a
7475 declaration of more than one identifier using a single list of
7476 specifiers and qualifiers.  Such attribute specifiers apply
7477 only to the identifier before whose declarator they appear.  For
7478 example, in
7480 @smallexample
7481 __attribute__((noreturn)) void d0 (void),
7482     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7483      d2 (void);
7484 @end smallexample
7486 @noindent
7487 the @code{noreturn} attribute applies to all the functions
7488 declared; the @code{format} attribute only applies to @code{d1}.
7490 An attribute specifier list may appear immediately before the comma,
7491 @code{=} or semicolon terminating the declaration of an identifier other
7492 than a function definition.  Such attribute specifiers apply
7493 to the declared object or function.  Where an
7494 assembler name for an object or function is specified (@pxref{Asm
7495 Labels}), the attribute must follow the @code{asm}
7496 specification.
7498 An attribute specifier list may, in future, be permitted to appear after
7499 the declarator in a function definition (before any old-style parameter
7500 declarations or the function body).
7502 Attribute specifiers may be mixed with type qualifiers appearing inside
7503 the @code{[]} of a parameter array declarator, in the C99 construct by
7504 which such qualifiers are applied to the pointer to which the array is
7505 implicitly converted.  Such attribute specifiers apply to the pointer,
7506 not to the array, but at present this is not implemented and they are
7507 ignored.
7509 An attribute specifier list may appear at the start of a nested
7510 declarator.  At present, there are some limitations in this usage: the
7511 attributes correctly apply to the declarator, but for most individual
7512 attributes the semantics this implies are not implemented.
7513 When attribute specifiers follow the @code{*} of a pointer
7514 declarator, they may be mixed with any type qualifiers present.
7515 The following describes the formal semantics of this syntax.  It makes the
7516 most sense if you are familiar with the formal specification of
7517 declarators in the ISO C standard.
7519 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7520 D1}, where @code{T} contains declaration specifiers that specify a type
7521 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7522 contains an identifier @var{ident}.  The type specified for @var{ident}
7523 for derived declarators whose type does not include an attribute
7524 specifier is as in the ISO C standard.
7526 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7527 and the declaration @code{T D} specifies the type
7528 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7529 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7530 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7532 If @code{D1} has the form @code{*
7533 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7534 declaration @code{T D} specifies the type
7535 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7536 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7537 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7538 @var{ident}.
7540 For example,
7542 @smallexample
7543 void (__attribute__((noreturn)) ****f) (void);
7544 @end smallexample
7546 @noindent
7547 specifies the type ``pointer to pointer to pointer to pointer to
7548 non-returning function returning @code{void}''.  As another example,
7550 @smallexample
7551 char *__attribute__((aligned(8))) *f;
7552 @end smallexample
7554 @noindent
7555 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7556 Note again that this does not work with most attributes; for example,
7557 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7558 is not yet supported.
7560 For compatibility with existing code written for compiler versions that
7561 did not implement attributes on nested declarators, some laxity is
7562 allowed in the placing of attributes.  If an attribute that only applies
7563 to types is applied to a declaration, it is treated as applying to
7564 the type of that declaration.  If an attribute that only applies to
7565 declarations is applied to the type of a declaration, it is treated
7566 as applying to that declaration; and, for compatibility with code
7567 placing the attributes immediately before the identifier declared, such
7568 an attribute applied to a function return type is treated as
7569 applying to the function type, and such an attribute applied to an array
7570 element type is treated as applying to the array type.  If an
7571 attribute that only applies to function types is applied to a
7572 pointer-to-function type, it is treated as applying to the pointer
7573 target type; if such an attribute is applied to a function return type
7574 that is not a pointer-to-function type, it is treated as applying
7575 to the function type.
7577 @node Function Prototypes
7578 @section Prototypes and Old-Style Function Definitions
7579 @cindex function prototype declarations
7580 @cindex old-style function definitions
7581 @cindex promotion of formal parameters
7583 GNU C extends ISO C to allow a function prototype to override a later
7584 old-style non-prototype definition.  Consider the following example:
7586 @smallexample
7587 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7588 #ifdef __STDC__
7589 #define P(x) x
7590 #else
7591 #define P(x) ()
7592 #endif
7594 /* @r{Prototype function declaration.}  */
7595 int isroot P((uid_t));
7597 /* @r{Old-style function definition.}  */
7599 isroot (x)   /* @r{??? lossage here ???} */
7600      uid_t x;
7602   return x == 0;
7604 @end smallexample
7606 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7607 not allow this example, because subword arguments in old-style
7608 non-prototype definitions are promoted.  Therefore in this example the
7609 function definition's argument is really an @code{int}, which does not
7610 match the prototype argument type of @code{short}.
7612 This restriction of ISO C makes it hard to write code that is portable
7613 to traditional C compilers, because the programmer does not know
7614 whether the @code{uid_t} type is @code{short}, @code{int}, or
7615 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7616 to override a later old-style definition.  More precisely, in GNU C, a
7617 function prototype argument type overrides the argument type specified
7618 by a later old-style definition if the former type is the same as the
7619 latter type before promotion.  Thus in GNU C the above example is
7620 equivalent to the following:
7622 @smallexample
7623 int isroot (uid_t);
7626 isroot (uid_t x)
7628   return x == 0;
7630 @end smallexample
7632 @noindent
7633 GNU C++ does not support old-style function definitions, so this
7634 extension is irrelevant.
7636 @node C++ Comments
7637 @section C++ Style Comments
7638 @cindex @code{//}
7639 @cindex C++ comments
7640 @cindex comments, C++ style
7642 In GNU C, you may use C++ style comments, which start with @samp{//} and
7643 continue until the end of the line.  Many other C implementations allow
7644 such comments, and they are included in the 1999 C standard.  However,
7645 C++ style comments are not recognized if you specify an @option{-std}
7646 option specifying a version of ISO C before C99, or @option{-ansi}
7647 (equivalent to @option{-std=c90}).
7649 @node Dollar Signs
7650 @section Dollar Signs in Identifier Names
7651 @cindex $
7652 @cindex dollar signs in identifier names
7653 @cindex identifier names, dollar signs in
7655 In GNU C, you may normally use dollar signs in identifier names.
7656 This is because many traditional C implementations allow such identifiers.
7657 However, dollar signs in identifiers are not supported on a few target
7658 machines, typically because the target assembler does not allow them.
7660 @node Character Escapes
7661 @section The Character @key{ESC} in Constants
7663 You can use the sequence @samp{\e} in a string or character constant to
7664 stand for the ASCII character @key{ESC}.
7666 @node Alignment
7667 @section Inquiring on Alignment of Types or Variables
7668 @cindex alignment
7669 @cindex type alignment
7670 @cindex variable alignment
7672 The keyword @code{__alignof__} allows you to inquire about how an object
7673 is aligned, or the minimum alignment usually required by a type.  Its
7674 syntax is just like @code{sizeof}.
7676 For example, if the target machine requires a @code{double} value to be
7677 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7678 This is true on many RISC machines.  On more traditional machine
7679 designs, @code{__alignof__ (double)} is 4 or even 2.
7681 Some machines never actually require alignment; they allow reference to any
7682 data type even at an odd address.  For these machines, @code{__alignof__}
7683 reports the smallest alignment that GCC gives the data type, usually as
7684 mandated by the target ABI.
7686 If the operand of @code{__alignof__} is an lvalue rather than a type,
7687 its value is the required alignment for its type, taking into account
7688 any minimum alignment specified with GCC's @code{__attribute__}
7689 extension (@pxref{Variable Attributes}).  For example, after this
7690 declaration:
7692 @smallexample
7693 struct foo @{ int x; char y; @} foo1;
7694 @end smallexample
7696 @noindent
7697 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7698 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7700 It is an error to ask for the alignment of an incomplete type.
7703 @node Inline
7704 @section An Inline Function is As Fast As a Macro
7705 @cindex inline functions
7706 @cindex integrating function code
7707 @cindex open coding
7708 @cindex macros, inline alternative
7710 By declaring a function inline, you can direct GCC to make
7711 calls to that function faster.  One way GCC can achieve this is to
7712 integrate that function's code into the code for its callers.  This
7713 makes execution faster by eliminating the function-call overhead; in
7714 addition, if any of the actual argument values are constant, their
7715 known values may permit simplifications at compile time so that not
7716 all of the inline function's code needs to be included.  The effect on
7717 code size is less predictable; object code may be larger or smaller
7718 with function inlining, depending on the particular case.  You can
7719 also direct GCC to try to integrate all ``simple enough'' functions
7720 into their callers with the option @option{-finline-functions}.
7722 GCC implements three different semantics of declaring a function
7723 inline.  One is available with @option{-std=gnu89} or
7724 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7725 on all inline declarations, another when
7726 @option{-std=c99}, @option{-std=c11},
7727 @option{-std=gnu99} or @option{-std=gnu11}
7728 (without @option{-fgnu89-inline}), and the third
7729 is used when compiling C++.
7731 To declare a function inline, use the @code{inline} keyword in its
7732 declaration, like this:
7734 @smallexample
7735 static inline int
7736 inc (int *a)
7738   return (*a)++;
7740 @end smallexample
7742 If you are writing a header file to be included in ISO C90 programs, write
7743 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7745 The three types of inlining behave similarly in two important cases:
7746 when the @code{inline} keyword is used on a @code{static} function,
7747 like the example above, and when a function is first declared without
7748 using the @code{inline} keyword and then is defined with
7749 @code{inline}, like this:
7751 @smallexample
7752 extern int inc (int *a);
7753 inline int
7754 inc (int *a)
7756   return (*a)++;
7758 @end smallexample
7760 In both of these common cases, the program behaves the same as if you
7761 had not used the @code{inline} keyword, except for its speed.
7763 @cindex inline functions, omission of
7764 @opindex fkeep-inline-functions
7765 When a function is both inline and @code{static}, if all calls to the
7766 function are integrated into the caller, and the function's address is
7767 never used, then the function's own assembler code is never referenced.
7768 In this case, GCC does not actually output assembler code for the
7769 function, unless you specify the option @option{-fkeep-inline-functions}.
7770 If there is a nonintegrated call, then the function is compiled to
7771 assembler code as usual.  The function must also be compiled as usual if
7772 the program refers to its address, because that cannot be inlined.
7774 @opindex Winline
7775 Note that certain usages in a function definition can make it unsuitable
7776 for inline substitution.  Among these usages are: variadic functions,
7777 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7778 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7779 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7780 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7781 function marked @code{inline} could not be substituted, and gives the
7782 reason for the failure.
7784 @cindex automatic @code{inline} for C++ member fns
7785 @cindex @code{inline} automatic for C++ member fns
7786 @cindex member fns, automatically @code{inline}
7787 @cindex C++ member fns, automatically @code{inline}
7788 @opindex fno-default-inline
7789 As required by ISO C++, GCC considers member functions defined within
7790 the body of a class to be marked inline even if they are
7791 not explicitly declared with the @code{inline} keyword.  You can
7792 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7793 Options,,Options Controlling C++ Dialect}.
7795 GCC does not inline any functions when not optimizing unless you specify
7796 the @samp{always_inline} attribute for the function, like this:
7798 @smallexample
7799 /* @r{Prototype.}  */
7800 inline void foo (const char) __attribute__((always_inline));
7801 @end smallexample
7803 The remainder of this section is specific to GNU C90 inlining.
7805 @cindex non-static inline function
7806 When an inline function is not @code{static}, then the compiler must assume
7807 that there may be calls from other source files; since a global symbol can
7808 be defined only once in any program, the function must not be defined in
7809 the other source files, so the calls therein cannot be integrated.
7810 Therefore, a non-@code{static} inline function is always compiled on its
7811 own in the usual fashion.
7813 If you specify both @code{inline} and @code{extern} in the function
7814 definition, then the definition is used only for inlining.  In no case
7815 is the function compiled on its own, not even if you refer to its
7816 address explicitly.  Such an address becomes an external reference, as
7817 if you had only declared the function, and had not defined it.
7819 This combination of @code{inline} and @code{extern} has almost the
7820 effect of a macro.  The way to use it is to put a function definition in
7821 a header file with these keywords, and put another copy of the
7822 definition (lacking @code{inline} and @code{extern}) in a library file.
7823 The definition in the header file causes most calls to the function
7824 to be inlined.  If any uses of the function remain, they refer to
7825 the single copy in the library.
7827 @node Volatiles
7828 @section When is a Volatile Object Accessed?
7829 @cindex accessing volatiles
7830 @cindex volatile read
7831 @cindex volatile write
7832 @cindex volatile access
7834 C has the concept of volatile objects.  These are normally accessed by
7835 pointers and used for accessing hardware or inter-thread
7836 communication.  The standard encourages compilers to refrain from
7837 optimizations concerning accesses to volatile objects, but leaves it
7838 implementation defined as to what constitutes a volatile access.  The
7839 minimum requirement is that at a sequence point all previous accesses
7840 to volatile objects have stabilized and no subsequent accesses have
7841 occurred.  Thus an implementation is free to reorder and combine
7842 volatile accesses that occur between sequence points, but cannot do
7843 so for accesses across a sequence point.  The use of volatile does
7844 not allow you to violate the restriction on updating objects multiple
7845 times between two sequence points.
7847 Accesses to non-volatile objects are not ordered with respect to
7848 volatile accesses.  You cannot use a volatile object as a memory
7849 barrier to order a sequence of writes to non-volatile memory.  For
7850 instance:
7852 @smallexample
7853 int *ptr = @var{something};
7854 volatile int vobj;
7855 *ptr = @var{something};
7856 vobj = 1;
7857 @end smallexample
7859 @noindent
7860 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7861 that the write to @var{*ptr} occurs by the time the update
7862 of @var{vobj} happens.  If you need this guarantee, you must use
7863 a stronger memory barrier such as:
7865 @smallexample
7866 int *ptr = @var{something};
7867 volatile int vobj;
7868 *ptr = @var{something};
7869 asm volatile ("" : : : "memory");
7870 vobj = 1;
7871 @end smallexample
7873 A scalar volatile object is read when it is accessed in a void context:
7875 @smallexample
7876 volatile int *src = @var{somevalue};
7877 *src;
7878 @end smallexample
7880 Such expressions are rvalues, and GCC implements this as a
7881 read of the volatile object being pointed to.
7883 Assignments are also expressions and have an rvalue.  However when
7884 assigning to a scalar volatile, the volatile object is not reread,
7885 regardless of whether the assignment expression's rvalue is used or
7886 not.  If the assignment's rvalue is used, the value is that assigned
7887 to the volatile object.  For instance, there is no read of @var{vobj}
7888 in all the following cases:
7890 @smallexample
7891 int obj;
7892 volatile int vobj;
7893 vobj = @var{something};
7894 obj = vobj = @var{something};
7895 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7896 obj = (@var{something}, vobj = @var{anotherthing});
7897 @end smallexample
7899 If you need to read the volatile object after an assignment has
7900 occurred, you must use a separate expression with an intervening
7901 sequence point.
7903 As bit-fields are not individually addressable, volatile bit-fields may
7904 be implicitly read when written to, or when adjacent bit-fields are
7905 accessed.  Bit-field operations may be optimized such that adjacent
7906 bit-fields are only partially accessed, if they straddle a storage unit
7907 boundary.  For these reasons it is unwise to use volatile bit-fields to
7908 access hardware.
7910 @node Using Assembly Language with C
7911 @section How to Use Inline Assembly Language in C Code
7912 @cindex @code{asm} keyword
7913 @cindex assembly language in C
7914 @cindex inline assembly language
7915 @cindex mixing assembly language and C
7917 The @code{asm} keyword allows you to embed assembler instructions
7918 within C code.  GCC provides two forms of inline @code{asm}
7919 statements.  A @dfn{basic @code{asm}} statement is one with no
7920 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7921 statement (@pxref{Extended Asm}) includes one or more operands.  
7922 The extended form is preferred for mixing C and assembly language
7923 within a function, but to include assembly language at
7924 top level you must use basic @code{asm}.
7926 You can also use the @code{asm} keyword to override the assembler name
7927 for a C symbol, or to place a C variable in a specific register.
7929 @menu
7930 * Basic Asm::          Inline assembler without operands.
7931 * Extended Asm::       Inline assembler with operands.
7932 * Constraints::        Constraints for @code{asm} operands
7933 * Asm Labels::         Specifying the assembler name to use for a C symbol.
7934 * Explicit Register Variables::  Defining variables residing in specified 
7935                        registers.
7936 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
7937 @end menu
7939 @node Basic Asm
7940 @subsection Basic Asm --- Assembler Instructions Without Operands
7941 @cindex basic @code{asm}
7942 @cindex assembly language in C, basic
7944 A basic @code{asm} statement has the following syntax:
7946 @example
7947 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7948 @end example
7950 The @code{asm} keyword is a GNU extension.
7951 When writing code that can be compiled with @option{-ansi} and the
7952 various @option{-std} options, use @code{__asm__} instead of 
7953 @code{asm} (@pxref{Alternate Keywords}).
7955 @subsubheading Qualifiers
7956 @table @code
7957 @item volatile
7958 The optional @code{volatile} qualifier has no effect. 
7959 All basic @code{asm} blocks are implicitly volatile.
7960 @end table
7962 @subsubheading Parameters
7963 @table @var
7965 @item AssemblerInstructions
7966 This is a literal string that specifies the assembler code. The string can 
7967 contain any instructions recognized by the assembler, including directives. 
7968 GCC does not parse the assembler instructions themselves and 
7969 does not know what they mean or even whether they are valid assembler input. 
7971 You may place multiple assembler instructions together in a single @code{asm} 
7972 string, separated by the characters normally used in assembly code for the 
7973 system. A combination that works in most places is a newline to break the 
7974 line, plus a tab character (written as @samp{\n\t}).
7975 Some assemblers allow semicolons as a line separator. However, 
7976 note that some assembler dialects use semicolons to start a comment. 
7977 @end table
7979 @subsubheading Remarks
7980 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7981 smaller, safer, and more efficient code, and in most cases it is a
7982 better solution than basic @code{asm}.  However, there are two
7983 situations where only basic @code{asm} can be used:
7985 @itemize @bullet
7986 @item
7987 Extended @code{asm} statements have to be inside a C
7988 function, so to write inline assembly language at file scope (``top-level''),
7989 outside of C functions, you must use basic @code{asm}.
7990 You can use this technique to emit assembler directives,
7991 define assembly language macros that can be invoked elsewhere in the file,
7992 or write entire functions in assembly language.
7994 @item
7995 Functions declared
7996 with the @code{naked} attribute also require basic @code{asm}
7997 (@pxref{Function Attributes}).
7998 @end itemize
8000 Safely accessing C data and calling functions from basic @code{asm} is more 
8001 complex than it may appear. To access C data, it is better to use extended 
8002 @code{asm}.
8004 Do not expect a sequence of @code{asm} statements to remain perfectly 
8005 consecutive after compilation. If certain instructions need to remain 
8006 consecutive in the output, put them in a single multi-instruction @code{asm}
8007 statement. Note that GCC's optimizers can move @code{asm} statements 
8008 relative to other code, including across jumps.
8010 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8011 GCC does not know about these jumps, and therefore cannot take 
8012 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8013 labels are only supported in extended @code{asm}.
8015 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8016 assembly code when optimizing. This can lead to unexpected duplicate 
8017 symbol errors during compilation if your assembly code defines symbols or 
8018 labels.
8020 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8021 making it a potential source of incompatibilities between compilers.  These
8022 incompatibilities may not produce compiler warnings/errors.
8024 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8025 means there is no way to communicate to the compiler what is happening
8026 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8027 discard them as unreferenced.  It also does not know about side effects of
8028 the assembler code, such as modifications to memory or registers.  Unlike
8029 some compilers, GCC assumes that no changes to general purpose registers
8030 occur.  This assumption may change in a future release.
8032 To avoid complications from future changes to the semantics and the
8033 compatibility issues between compilers, consider replacing basic @code{asm}
8034 with extended @code{asm}.  See
8035 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8036 from basic asm to extended asm} for information about how to perform this
8037 conversion.
8039 The compiler copies the assembler instructions in a basic @code{asm} 
8040 verbatim to the assembly language output file, without 
8041 processing dialects or any of the @samp{%} operators that are available with
8042 extended @code{asm}. This results in minor differences between basic 
8043 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8044 registers you might use @samp{%eax} in basic @code{asm} and
8045 @samp{%%eax} in extended @code{asm}.
8047 On targets such as x86 that support multiple assembler dialects,
8048 all basic @code{asm} blocks use the assembler dialect specified by the 
8049 @option{-masm} command-line option (@pxref{x86 Options}).  
8050 Basic @code{asm} provides no
8051 mechanism to provide different assembler strings for different dialects.
8053 For basic @code{asm} with non-empty assembler string GCC assumes
8054 the assembler block does not change any general purpose registers,
8055 but it may read or write any globally accessible variable.
8057 Here is an example of basic @code{asm} for i386:
8059 @example
8060 /* Note that this code will not compile with -masm=intel */
8061 #define DebugBreak() asm("int $3")
8062 @end example
8064 @node Extended Asm
8065 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8066 @cindex extended @code{asm}
8067 @cindex assembly language in C, extended
8069 With extended @code{asm} you can read and write C variables from 
8070 assembler and perform jumps from assembler code to C labels.  
8071 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8072 the operand parameters after the assembler template:
8074 @example
8075 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
8076                  : @var{OutputOperands} 
8077                  @r{[} : @var{InputOperands}
8078                  @r{[} : @var{Clobbers} @r{]} @r{]})
8080 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
8081                       : 
8082                       : @var{InputOperands}
8083                       : @var{Clobbers}
8084                       : @var{GotoLabels})
8085 @end example
8087 The @code{asm} keyword is a GNU extension.
8088 When writing code that can be compiled with @option{-ansi} and the
8089 various @option{-std} options, use @code{__asm__} instead of 
8090 @code{asm} (@pxref{Alternate Keywords}).
8092 @subsubheading Qualifiers
8093 @table @code
8095 @item volatile
8096 The typical use of extended @code{asm} statements is to manipulate input 
8097 values to produce output values. However, your @code{asm} statements may 
8098 also produce side effects. If so, you may need to use the @code{volatile} 
8099 qualifier to disable certain optimizations. @xref{Volatile}.
8101 @item goto
8102 This qualifier informs the compiler that the @code{asm} statement may 
8103 perform a jump to one of the labels listed in the @var{GotoLabels}.
8104 @xref{GotoLabels}.
8105 @end table
8107 @subsubheading Parameters
8108 @table @var
8109 @item AssemblerTemplate
8110 This is a literal string that is the template for the assembler code. It is a 
8111 combination of fixed text and tokens that refer to the input, output, 
8112 and goto parameters. @xref{AssemblerTemplate}.
8114 @item OutputOperands
8115 A comma-separated list of the C variables modified by the instructions in the 
8116 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8118 @item InputOperands
8119 A comma-separated list of C expressions read by the instructions in the 
8120 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8122 @item Clobbers
8123 A comma-separated list of registers or other values changed by the 
8124 @var{AssemblerTemplate}, beyond those listed as outputs.
8125 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8127 @item GotoLabels
8128 When you are using the @code{goto} form of @code{asm}, this section contains 
8129 the list of all C labels to which the code in the 
8130 @var{AssemblerTemplate} may jump. 
8131 @xref{GotoLabels}.
8133 @code{asm} statements may not perform jumps into other @code{asm} statements,
8134 only to the listed @var{GotoLabels}.
8135 GCC's optimizers do not know about other jumps; therefore they cannot take 
8136 account of them when deciding how to optimize.
8137 @end table
8139 The total number of input + output + goto operands is limited to 30.
8141 @subsubheading Remarks
8142 The @code{asm} statement allows you to include assembly instructions directly 
8143 within C code. This may help you to maximize performance in time-sensitive 
8144 code or to access assembly instructions that are not readily available to C 
8145 programs.
8147 Note that extended @code{asm} statements must be inside a function. Only 
8148 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8149 Functions declared with the @code{naked} attribute also require basic 
8150 @code{asm} (@pxref{Function Attributes}).
8152 While the uses of @code{asm} are many and varied, it may help to think of an 
8153 @code{asm} statement as a series of low-level instructions that convert input 
8154 parameters to output parameters. So a simple (if not particularly useful) 
8155 example for i386 using @code{asm} might look like this:
8157 @example
8158 int src = 1;
8159 int dst;   
8161 asm ("mov %1, %0\n\t"
8162     "add $1, %0"
8163     : "=r" (dst) 
8164     : "r" (src));
8166 printf("%d\n", dst);
8167 @end example
8169 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8171 @anchor{Volatile}
8172 @subsubsection Volatile
8173 @cindex volatile @code{asm}
8174 @cindex @code{asm} volatile
8176 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8177 there is no need for the output variables. Also, the optimizers may move 
8178 code out of loops if they believe that the code will always return the same 
8179 result (i.e. none of its input values change between calls). Using the 
8180 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8181 that have no output operands, including @code{asm goto} statements, 
8182 are implicitly volatile.
8184 This i386 code demonstrates a case that does not use (or require) the 
8185 @code{volatile} qualifier. If it is performing assertion checking, this code 
8186 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8187 unreferenced by any code. As a result, the optimizers can discard the 
8188 @code{asm} statement, which in turn removes the need for the entire 
8189 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8190 isn't needed you allow the optimizers to produce the most efficient code 
8191 possible.
8193 @example
8194 void DoCheck(uint32_t dwSomeValue)
8196    uint32_t dwRes;
8198    // Assumes dwSomeValue is not zero.
8199    asm ("bsfl %1,%0"
8200      : "=r" (dwRes)
8201      : "r" (dwSomeValue)
8202      : "cc");
8204    assert(dwRes > 3);
8206 @end example
8208 The next example shows a case where the optimizers can recognize that the input 
8209 (@code{dwSomeValue}) never changes during the execution of the function and can 
8210 therefore move the @code{asm} outside the loop to produce more efficient code. 
8211 Again, using @code{volatile} disables this type of optimization.
8213 @example
8214 void do_print(uint32_t dwSomeValue)
8216    uint32_t dwRes;
8218    for (uint32_t x=0; x < 5; x++)
8219    @{
8220       // Assumes dwSomeValue is not zero.
8221       asm ("bsfl %1,%0"
8222         : "=r" (dwRes)
8223         : "r" (dwSomeValue)
8224         : "cc");
8226       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8227    @}
8229 @end example
8231 The following example demonstrates a case where you need to use the 
8232 @code{volatile} qualifier. 
8233 It uses the x86 @code{rdtsc} instruction, which reads 
8234 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8235 the optimizers might assume that the @code{asm} block will always return the 
8236 same value and therefore optimize away the second call.
8238 @example
8239 uint64_t msr;
8241 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8242         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8243         "or %%rdx, %0"        // 'Or' in the lower bits.
8244         : "=a" (msr)
8245         : 
8246         : "rdx");
8248 printf("msr: %llx\n", msr);
8250 // Do other work...
8252 // Reprint the timestamp
8253 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8254         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8255         "or %%rdx, %0"        // 'Or' in the lower bits.
8256         : "=a" (msr)
8257         : 
8258         : "rdx");
8260 printf("msr: %llx\n", msr);
8261 @end example
8263 GCC's optimizers do not treat this code like the non-volatile code in the 
8264 earlier examples. They do not move it out of loops or omit it on the 
8265 assumption that the result from a previous call is still valid.
8267 Note that the compiler can move even volatile @code{asm} instructions relative 
8268 to other code, including across jump instructions. For example, on many 
8269 targets there is a system register that controls the rounding mode of 
8270 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8271 following PowerPC example, does not work reliably.
8273 @example
8274 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8275 sum = x + y;
8276 @end example
8278 The compiler may move the addition back before the volatile @code{asm}. To 
8279 make it work as expected, add an artificial dependency to the @code{asm} by 
8280 referencing a variable in the subsequent code, for example: 
8282 @example
8283 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8284 sum = x + y;
8285 @end example
8287 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8288 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8289 errors during compilation if your asm code defines symbols or labels. 
8290 Using @samp{%=} 
8291 (@pxref{AssemblerTemplate}) may help resolve this problem.
8293 @anchor{AssemblerTemplate}
8294 @subsubsection Assembler Template
8295 @cindex @code{asm} assembler template
8297 An assembler template is a literal string containing assembler instructions.
8298 The compiler replaces tokens in the template that refer 
8299 to inputs, outputs, and goto labels,
8300 and then outputs the resulting string to the assembler. The 
8301 string can contain any instructions recognized by the assembler, including 
8302 directives. GCC does not parse the assembler instructions 
8303 themselves and does not know what they mean or even whether they are valid 
8304 assembler input. However, it does count the statements 
8305 (@pxref{Size of an asm}).
8307 You may place multiple assembler instructions together in a single @code{asm} 
8308 string, separated by the characters normally used in assembly code for the 
8309 system. A combination that works in most places is a newline to break the 
8310 line, plus a tab character to move to the instruction field (written as 
8311 @samp{\n\t}). 
8312 Some assemblers allow semicolons as a line separator. However, note 
8313 that some assembler dialects use semicolons to start a comment. 
8315 Do not expect a sequence of @code{asm} statements to remain perfectly 
8316 consecutive after compilation, even when you are using the @code{volatile} 
8317 qualifier. If certain instructions need to remain consecutive in the output, 
8318 put them in a single multi-instruction asm statement.
8320 Accessing data from C programs without using input/output operands (such as 
8321 by using global symbols directly from the assembler template) may not work as 
8322 expected. Similarly, calling functions directly from an assembler template 
8323 requires a detailed understanding of the target assembler and ABI.
8325 Since GCC does not parse the assembler template,
8326 it has no visibility of any 
8327 symbols it references. This may result in GCC discarding those symbols as 
8328 unreferenced unless they are also listed as input, output, or goto operands.
8330 @subsubheading Special format strings
8332 In addition to the tokens described by the input, output, and goto operands, 
8333 these tokens have special meanings in the assembler template:
8335 @table @samp
8336 @item %% 
8337 Outputs a single @samp{%} into the assembler code.
8339 @item %= 
8340 Outputs a number that is unique to each instance of the @code{asm} 
8341 statement in the entire compilation. This option is useful when creating local 
8342 labels and referring to them multiple times in a single template that 
8343 generates multiple assembler instructions. 
8345 @item %@{
8346 @itemx %|
8347 @itemx %@}
8348 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8349 into the assembler code.  When unescaped, these characters have special
8350 meaning to indicate multiple assembler dialects, as described below.
8351 @end table
8353 @subsubheading Multiple assembler dialects in @code{asm} templates
8355 On targets such as x86, GCC supports multiple assembler dialects.
8356 The @option{-masm} option controls which dialect GCC uses as its 
8357 default for inline assembler. The target-specific documentation for the 
8358 @option{-masm} option contains the list of supported dialects, as well as the 
8359 default dialect if the option is not specified. This information may be 
8360 important to understand, since assembler code that works correctly when 
8361 compiled using one dialect will likely fail if compiled using another.
8362 @xref{x86 Options}.
8364 If your code needs to support multiple assembler dialects (for example, if 
8365 you are writing public headers that need to support a variety of compilation 
8366 options), use constructs of this form:
8368 @example
8369 @{ dialect0 | dialect1 | dialect2... @}
8370 @end example
8372 This construct outputs @code{dialect0} 
8373 when using dialect #0 to compile the code, 
8374 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8375 braces than the number of dialects the compiler supports, the construct 
8376 outputs nothing.
8378 For example, if an x86 compiler supports two dialects
8379 (@samp{att}, @samp{intel}), an 
8380 assembler template such as this:
8382 @example
8383 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8384 @end example
8386 @noindent
8387 is equivalent to one of
8389 @example
8390 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8391 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8392 @end example
8394 Using that same compiler, this code:
8396 @example
8397 "xchg@{l@}\t@{%%@}ebx, %1"
8398 @end example
8400 @noindent
8401 corresponds to either
8403 @example
8404 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8405 "xchg\tebx, %1"                    @r{/* intel dialect */}
8406 @end example
8408 There is no support for nesting dialect alternatives.
8410 @anchor{OutputOperands}
8411 @subsubsection Output Operands
8412 @cindex @code{asm} output operands
8414 An @code{asm} statement has zero or more output operands indicating the names
8415 of C variables modified by the assembler code.
8417 In this i386 example, @code{old} (referred to in the template string as 
8418 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8419 (@code{%2}) is an input:
8421 @example
8422 bool old;
8424 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8425          "sbb %0,%0"      // Use the CF to calculate old.
8426    : "=r" (old), "+rm" (*Base)
8427    : "Ir" (Offset)
8428    : "cc");
8430 return old;
8431 @end example
8433 Operands are separated by commas.  Each operand has this format:
8435 @example
8436 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8437 @end example
8439 @table @var
8440 @item asmSymbolicName
8441 Specifies a symbolic name for the operand.
8442 Reference the name in the assembler template 
8443 by enclosing it in square brackets 
8444 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8445 that contains the definition. Any valid C variable name is acceptable, 
8446 including names already defined in the surrounding code. No two operands 
8447 within the same @code{asm} statement can use the same symbolic name.
8449 When not using an @var{asmSymbolicName}, use the (zero-based) position
8450 of the operand 
8451 in the list of operands in the assembler template. For example if there are 
8452 three output operands, use @samp{%0} in the template to refer to the first, 
8453 @samp{%1} for the second, and @samp{%2} for the third. 
8455 @item constraint
8456 A string constant specifying constraints on the placement of the operand; 
8457 @xref{Constraints}, for details.
8459 Output constraints must begin with either @samp{=} (a variable overwriting an 
8460 existing value) or @samp{+} (when reading and writing). When using 
8461 @samp{=}, do not assume the location contains the existing value
8462 on entry to the @code{asm}, except 
8463 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8465 After the prefix, there must be one or more additional constraints 
8466 (@pxref{Constraints}) that describe where the value resides. Common 
8467 constraints include @samp{r} for register and @samp{m} for memory. 
8468 When you list more than one possible location (for example, @code{"=rm"}),
8469 the compiler chooses the most efficient one based on the current context. 
8470 If you list as many alternates as the @code{asm} statement allows, you permit 
8471 the optimizers to produce the best possible code. 
8472 If you must use a specific register, but your Machine Constraints do not
8473 provide sufficient control to select the specific register you want, 
8474 local register variables may provide a solution (@pxref{Local Register 
8475 Variables}).
8477 @item cvariablename
8478 Specifies a C lvalue expression to hold the output, typically a variable name.
8479 The enclosing parentheses are a required part of the syntax.
8481 @end table
8483 When the compiler selects the registers to use to 
8484 represent the output operands, it does not use any of the clobbered registers 
8485 (@pxref{Clobbers and Scratch Registers}).
8487 Output operand expressions must be lvalues. The compiler cannot check whether 
8488 the operands have data types that are reasonable for the instruction being 
8489 executed. For output expressions that are not directly addressable (for 
8490 example a bit-field), the constraint must allow a register. In that case, GCC 
8491 uses the register as the output of the @code{asm}, and then stores that 
8492 register into the output. 
8494 Operands using the @samp{+} constraint modifier count as two operands 
8495 (that is, both as input and output) towards the total maximum of 30 operands
8496 per @code{asm} statement.
8498 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8499 operands that must not overlap an input.  Otherwise, 
8500 GCC may allocate the output operand in the same register as an unrelated 
8501 input operand, on the assumption that the assembler code consumes its 
8502 inputs before producing outputs. This assumption may be false if the assembler 
8503 code actually consists of more than one instruction.
8505 The same problem can occur if one output parameter (@var{a}) allows a register 
8506 constraint and another output parameter (@var{b}) allows a memory constraint.
8507 The code generated by GCC to access the memory address in @var{b} can contain
8508 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8509 registers to be inputs to the asm. As above, GCC assumes that such input
8510 registers are consumed before any outputs are written. This assumption may 
8511 result in incorrect behavior if the asm writes to @var{a} before using 
8512 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8513 ensures that modifying @var{a} does not affect the address referenced by 
8514 @var{b}. Otherwise, the location of @var{b} 
8515 is undefined if @var{a} is modified before using @var{b}.
8517 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8518 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8519 dependent. The list of supported modifiers for x86 is found at 
8520 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8522 If the C code that follows the @code{asm} makes no use of any of the output 
8523 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8524 optimizers from discarding the @code{asm} statement as unneeded 
8525 (see @ref{Volatile}).
8527 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8528 references the first output operand as @code{%0} (were there a second, it 
8529 would be @code{%1}, etc). The number of the first input operand is one greater 
8530 than that of the last output operand. In this i386 example, that makes 
8531 @code{Mask} referenced as @code{%1}:
8533 @example
8534 uint32_t Mask = 1234;
8535 uint32_t Index;
8537   asm ("bsfl %1, %0"
8538      : "=r" (Index)
8539      : "r" (Mask)
8540      : "cc");
8541 @end example
8543 That code overwrites the variable @code{Index} (@samp{=}),
8544 placing the value in a register (@samp{r}).
8545 Using the generic @samp{r} constraint instead of a constraint for a specific 
8546 register allows the compiler to pick the register to use, which can result 
8547 in more efficient code. This may not be possible if an assembler instruction 
8548 requires a specific register.
8550 The following i386 example uses the @var{asmSymbolicName} syntax.
8551 It produces the 
8552 same result as the code above, but some may consider it more readable or more 
8553 maintainable since reordering index numbers is not necessary when adding or 
8554 removing operands. The names @code{aIndex} and @code{aMask}
8555 are only used in this example to emphasize which 
8556 names get used where.
8557 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8559 @example
8560 uint32_t Mask = 1234;
8561 uint32_t Index;
8563   asm ("bsfl %[aMask], %[aIndex]"
8564      : [aIndex] "=r" (Index)
8565      : [aMask] "r" (Mask)
8566      : "cc");
8567 @end example
8569 Here are some more examples of output operands.
8571 @example
8572 uint32_t c = 1;
8573 uint32_t d;
8574 uint32_t *e = &c;
8576 asm ("mov %[e], %[d]"
8577    : [d] "=rm" (d)
8578    : [e] "rm" (*e));
8579 @end example
8581 Here, @code{d} may either be in a register or in memory. Since the compiler 
8582 might already have the current value of the @code{uint32_t} location
8583 pointed to by @code{e}
8584 in a register, you can enable it to choose the best location
8585 for @code{d} by specifying both constraints.
8587 @anchor{FlagOutputOperands}
8588 @subsubsection Flag Output Operands
8589 @cindex @code{asm} flag output operands
8591 Some targets have a special register that holds the ``flags'' for the
8592 result of an operation or comparison.  Normally, the contents of that
8593 register are either unmodifed by the asm, or the asm is considered to
8594 clobber the contents.
8596 On some targets, a special form of output operand exists by which
8597 conditions in the flags register may be outputs of the asm.  The set of
8598 conditions supported are target specific, but the general rule is that
8599 the output variable must be a scalar integer, and the value is boolean.
8600 When supported, the target defines the preprocessor symbol
8601 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8603 Because of the special nature of the flag output operands, the constraint
8604 may not include alternatives.
8606 Most often, the target has only one flags register, and thus is an implied
8607 operand of many instructions.  In this case, the operand should not be
8608 referenced within the assembler template via @code{%0} etc, as there's
8609 no corresponding text in the assembly language.
8611 @table @asis
8612 @item x86 family
8613 The flag output constraints for the x86 family are of the form
8614 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8615 conditions defined in the ISA manual for @code{j@var{cc}} or
8616 @code{set@var{cc}}.
8618 @table @code
8619 @item a
8620 ``above'' or unsigned greater than
8621 @item ae
8622 ``above or equal'' or unsigned greater than or equal
8623 @item b
8624 ``below'' or unsigned less than
8625 @item be
8626 ``below or equal'' or unsigned less than or equal
8627 @item c
8628 carry flag set
8629 @item e
8630 @itemx z
8631 ``equal'' or zero flag set
8632 @item g
8633 signed greater than
8634 @item ge
8635 signed greater than or equal
8636 @item l
8637 signed less than
8638 @item le
8639 signed less than or equal
8640 @item o
8641 overflow flag set
8642 @item p
8643 parity flag set
8644 @item s
8645 sign flag set
8646 @item na
8647 @itemx nae
8648 @itemx nb
8649 @itemx nbe
8650 @itemx nc
8651 @itemx ne
8652 @itemx ng
8653 @itemx nge
8654 @itemx nl
8655 @itemx nle
8656 @itemx no
8657 @itemx np
8658 @itemx ns
8659 @itemx nz
8660 ``not'' @var{flag}, or inverted versions of those above
8661 @end table
8663 @end table
8665 @anchor{InputOperands}
8666 @subsubsection Input Operands
8667 @cindex @code{asm} input operands
8668 @cindex @code{asm} expressions
8670 Input operands make values from C variables and expressions available to the 
8671 assembly code.
8673 Operands are separated by commas.  Each operand has this format:
8675 @example
8676 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8677 @end example
8679 @table @var
8680 @item asmSymbolicName
8681 Specifies a symbolic name for the operand.
8682 Reference the name in the assembler template 
8683 by enclosing it in square brackets 
8684 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8685 that contains the definition. Any valid C variable name is acceptable, 
8686 including names already defined in the surrounding code. No two operands 
8687 within the same @code{asm} statement can use the same symbolic name.
8689 When not using an @var{asmSymbolicName}, use the (zero-based) position
8690 of the operand 
8691 in the list of operands in the assembler template. For example if there are
8692 two output operands and three inputs,
8693 use @samp{%2} in the template to refer to the first input operand,
8694 @samp{%3} for the second, and @samp{%4} for the third. 
8696 @item constraint
8697 A string constant specifying constraints on the placement of the operand; 
8698 @xref{Constraints}, for details.
8700 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8701 When you list more than one possible location (for example, @samp{"irm"}), 
8702 the compiler chooses the most efficient one based on the current context.
8703 If you must use a specific register, but your Machine Constraints do not
8704 provide sufficient control to select the specific register you want, 
8705 local register variables may provide a solution (@pxref{Local Register 
8706 Variables}).
8708 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8709 that the specified input must be in the same place as the output constraint 
8710 at the (zero-based) index in the output constraint list. 
8711 When using @var{asmSymbolicName} syntax for the output operands,
8712 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8714 @item cexpression
8715 This is the C variable or expression being passed to the @code{asm} statement 
8716 as input.  The enclosing parentheses are a required part of the syntax.
8718 @end table
8720 When the compiler selects the registers to use to represent the input 
8721 operands, it does not use any of the clobbered registers
8722 (@pxref{Clobbers and Scratch Registers}).
8724 If there are no output operands but there are input operands, place two 
8725 consecutive colons where the output operands would go:
8727 @example
8728 __asm__ ("some instructions"
8729    : /* No outputs. */
8730    : "r" (Offset / 8));
8731 @end example
8733 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8734 (except for inputs tied to outputs). The compiler assumes that on exit from 
8735 the @code{asm} statement these operands contain the same values as they 
8736 had before executing the statement. 
8737 It is @emph{not} possible to use clobbers
8738 to inform the compiler that the values in these inputs are changing. One 
8739 common work-around is to tie the changing input variable to an output variable 
8740 that never gets used. Note, however, that if the code that follows the 
8741 @code{asm} statement makes no use of any of the output operands, the GCC 
8742 optimizers may discard the @code{asm} statement as unneeded 
8743 (see @ref{Volatile}).
8745 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8746 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8747 dependent. The list of supported modifiers for x86 is found at 
8748 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8750 In this example using the fictitious @code{combine} instruction, the 
8751 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8752 location as output operand 0. Only input operands may use numbers in 
8753 constraints, and they must each refer to an output operand. Only a number (or 
8754 the symbolic assembler name) in the constraint can guarantee that one operand 
8755 is in the same place as another. The mere fact that @code{foo} is the value of 
8756 both operands is not enough to guarantee that they are in the same place in 
8757 the generated assembler code.
8759 @example
8760 asm ("combine %2, %0" 
8761    : "=r" (foo) 
8762    : "0" (foo), "g" (bar));
8763 @end example
8765 Here is an example using symbolic names.
8767 @example
8768 asm ("cmoveq %1, %2, %[result]" 
8769    : [result] "=r"(result) 
8770    : "r" (test), "r" (new), "[result]" (old));
8771 @end example
8773 @anchor{Clobbers and Scratch Registers}
8774 @subsubsection Clobbers and Scratch Registers
8775 @cindex @code{asm} clobbers
8776 @cindex @code{asm} scratch registers
8778 While the compiler is aware of changes to entries listed in the output 
8779 operands, the inline @code{asm} code may modify more than just the outputs. For 
8780 example, calculations may require additional registers, or the processor may 
8781 overwrite a register as a side effect of a particular assembler instruction. 
8782 In order to inform the compiler of these changes, list them in the clobber 
8783 list. Clobber list items are either register names or the special clobbers 
8784 (listed below). Each clobber list item is a string constant 
8785 enclosed in double quotes and separated by commas.
8787 Clobber descriptions may not in any way overlap with an input or output 
8788 operand. For example, you may not have an operand describing a register class 
8789 with one member when listing that register in the clobber list. Variables 
8790 declared to live in specific registers (@pxref{Explicit Register 
8791 Variables}) and used 
8792 as @code{asm} input or output operands must have no part mentioned in the 
8793 clobber description. In particular, there is no way to specify that input 
8794 operands get modified without also specifying them as output operands.
8796 When the compiler selects which registers to use to represent input and output 
8797 operands, it does not use any of the clobbered registers. As a result, 
8798 clobbered registers are available for any use in the assembler code.
8800 Here is a realistic example for the VAX showing the use of clobbered 
8801 registers: 
8803 @example
8804 asm volatile ("movc3 %0, %1, %2"
8805                    : /* No outputs. */
8806                    : "g" (from), "g" (to), "g" (count)
8807                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
8808 @end example
8810 Also, there are two special clobber arguments:
8812 @table @code
8813 @item "cc"
8814 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
8815 register. On some machines, GCC represents the condition codes as a specific 
8816 hardware register; @code{"cc"} serves to name this register.
8817 On other machines, condition code handling is different, 
8818 and specifying @code{"cc"} has no effect. But 
8819 it is valid no matter what the target.
8821 @item "memory"
8822 The @code{"memory"} clobber tells the compiler that the assembly code
8823 performs memory 
8824 reads or writes to items other than those listed in the input and output 
8825 operands (for example, accessing the memory pointed to by one of the input 
8826 parameters). To ensure memory contains correct values, GCC may need to flush 
8827 specific register values to memory before executing the @code{asm}. Further, 
8828 the compiler does not assume that any values read from memory before an 
8829 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
8830 needed.  
8831 Using the @code{"memory"} clobber effectively forms a read/write
8832 memory barrier for the compiler.
8834 Note that this clobber does not prevent the @emph{processor} from doing 
8835 speculative reads past the @code{asm} statement. To prevent that, you need 
8836 processor-specific fence instructions.
8838 @end table
8840 Flushing registers to memory has performance implications and may be
8841 an issue for time-sensitive code.  You can provide better information
8842 to GCC to avoid this, as shown in the following examples.  At a
8843 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
8844 need to be flushed.
8846 Here is a fictitious sum of squares instruction, that takes two
8847 pointers to floating point values in memory and produces a floating
8848 point register output.
8849 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
8850 parameters, once to specify memory accessed, and once to specify a
8851 base register used by the @code{asm}.  You won't normally be wasting a
8852 register by doing this as GCC can use the same register for both
8853 purposes.  However, it would be foolish to use both @code{%1} and
8854 @code{%3} for @code{x} in this @code{asm} and expect them to be the
8855 same.  In fact, @code{%3} may well not be a register.  It might be a
8856 symbolic memory reference to the object pointed to by @code{x}.
8858 @smallexample
8859 asm ("sumsq %0, %1, %2"
8860      : "+f" (result)
8861      : "r" (x), "r" (y), "m" (*x), "m" (*y));
8862 @end smallexample
8864 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
8865 Notice that the @code{x}, @code{y} and @code{z} pointer registers
8866 must be specified as input/output because the @code{asm} modifies
8867 them.
8869 @smallexample
8870 asm ("vecmul %0, %1, %2"
8871      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
8872      : "m" (*x), "m" (*y));
8873 @end smallexample
8875 An x86 example where the string memory argument is of unknown length.
8877 @smallexample
8878 asm("repne scasb"
8879     : "=c" (count), "+D" (p)
8880     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
8881 @end smallexample
8883 If you know the above will only be reading a ten byte array then you
8884 could instead use a memory input like:
8885 @code{"m" (*(const char (*)[10]) p)}.
8887 Here is an example of a PowerPC vector scale implemented in assembly,
8888 complete with vector and condition code clobbers, and some initialized
8889 offset registers that are unchanged by the @code{asm}.
8891 @smallexample
8892 void
8893 dscal (size_t n, double *x, double alpha)
8895   asm ("/* lots of asm here */"
8896        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
8897        : "d" (alpha), "b" (32), "b" (48), "b" (64),
8898          "b" (80), "b" (96), "b" (112)
8899        : "cr0",
8900          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
8901          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
8903 @end smallexample
8905 Rather than allocating fixed registers via clobbers to provide scratch
8906 registers for an @code{asm} statement, an alternative is to define a
8907 variable and make it an early-clobber output as with @code{a2} and
8908 @code{a3} in the example below.  This gives the compiler register
8909 allocator more freedom.  You can also define a variable and make it an
8910 output tied to an input as with @code{a0} and @code{a1}, tied
8911 respectively to @code{ap} and @code{lda}.  Of course, with tied
8912 outputs your @code{asm} can't use the input value after modifying the
8913 output register since they are one and the same register.  What's
8914 more, if you omit the early-clobber on the output, it is possible that
8915 GCC might allocate the same register to another of the inputs if GCC
8916 could prove they had the same value on entry to the @code{asm}.  This
8917 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
8918 might conceivably be known to have the value 16 and without an
8919 early-clobber share the same register as @code{%11}.  On the other
8920 hand, @code{ap} can't be the same as any of the other inputs, so an
8921 early-clobber on @code{a0} is not needed.  It is also not desirable in
8922 this case.  An early-clobber on @code{a0} would cause GCC to allocate
8923 a separate register for the @code{"m" (*(const double (*)[]) ap)}
8924 input.  Note that tying an input to an output is the way to set up an
8925 initialized temporary register modified by an @code{asm} statement.
8926 An input not tied to an output is assumed by GCC to be unchanged, for
8927 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
8928 use that register in following code if the value 16 happened to be
8929 needed.  You can even use a normal @code{asm} output for a scratch if
8930 all inputs that might share the same register are consumed before the
8931 scratch is used.  The VSX registers clobbered by the @code{asm}
8932 statement could have used this technique except for GCC's limit on the
8933 number of @code{asm} parameters.
8935 @smallexample
8936 static void
8937 dgemv_kernel_4x4 (long n, const double *ap, long lda,
8938                   const double *x, double *y, double alpha)
8940   double *a0;
8941   double *a1;
8942   double *a2;
8943   double *a3;
8945   __asm__
8946     (
8947      /* lots of asm here */
8948      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
8949      "#a0=%3 a1=%4 a2=%5 a3=%6"
8950      :
8951        "+m" (*(double (*)[n]) y),
8952        "+&r" (n),       // 1
8953        "+b" (y),        // 2
8954        "=b" (a0),       // 3
8955        "=&b" (a1),      // 4
8956        "=&b" (a2),      // 5
8957        "=&b" (a3)       // 6
8958      :
8959        "m" (*(const double (*)[n]) x),
8960        "m" (*(const double (*)[]) ap),
8961        "d" (alpha),     // 9
8962        "r" (x),         // 10
8963        "b" (16),        // 11
8964        "3" (ap),        // 12
8965        "4" (lda)        // 13
8966      :
8967        "cr0",
8968        "vs32","vs33","vs34","vs35","vs36","vs37",
8969        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
8970      );
8972 @end smallexample
8974 @anchor{GotoLabels}
8975 @subsubsection Goto Labels
8976 @cindex @code{asm} goto labels
8978 @code{asm goto} allows assembly code to jump to one or more C labels.  The
8979 @var{GotoLabels} section in an @code{asm goto} statement contains 
8980 a comma-separated 
8981 list of all C labels to which the assembler code may jump. GCC assumes that 
8982 @code{asm} execution falls through to the next statement (if this is not the 
8983 case, consider using the @code{__builtin_unreachable} intrinsic after the 
8984 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
8985 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
8986 Attributes}).
8988 An @code{asm goto} statement cannot have outputs.
8989 This is due to an internal restriction of 
8990 the compiler: control transfer instructions cannot have outputs. 
8991 If the assembler code does modify anything, use the @code{"memory"} clobber 
8992 to force the 
8993 optimizers to flush all register values to memory and reload them if 
8994 necessary after the @code{asm} statement.
8996 Also note that an @code{asm goto} statement is always implicitly
8997 considered volatile.
8999 To reference a label in the assembler template,
9000 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9001 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9002 operands.  For example, if the @code{asm} has three inputs and references two 
9003 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9005 Alternately, you can reference labels using the actual C label name enclosed
9006 in brackets.  For example, to reference a label named @code{carry}, you can
9007 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9008 section when using this approach.
9010 Here is an example of @code{asm goto} for i386:
9012 @example
9013 asm goto (
9014     "btl %1, %0\n\t"
9015     "jc %l2"
9016     : /* No outputs. */
9017     : "r" (p1), "r" (p2) 
9018     : "cc" 
9019     : carry);
9021 return 0;
9023 carry:
9024 return 1;
9025 @end example
9027 The following example shows an @code{asm goto} that uses a memory clobber.
9029 @example
9030 int frob(int x)
9032   int y;
9033   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9034             : /* No outputs. */
9035             : "r"(x), "r"(&y)
9036             : "r5", "memory" 
9037             : error);
9038   return y;
9039 error:
9040   return -1;
9042 @end example
9044 @anchor{x86Operandmodifiers}
9045 @subsubsection x86 Operand Modifiers
9047 References to input, output, and goto operands in the assembler template
9048 of extended @code{asm} statements can use 
9049 modifiers to affect the way the operands are formatted in 
9050 the code output to the assembler. For example, the 
9051 following code uses the @samp{h} and @samp{b} modifiers for x86:
9053 @example
9054 uint16_t  num;
9055 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9056 @end example
9058 @noindent
9059 These modifiers generate this assembler code:
9061 @example
9062 xchg %ah, %al
9063 @end example
9065 The rest of this discussion uses the following code for illustrative purposes.
9067 @example
9068 int main()
9070    int iInt = 1;
9072 top:
9074    asm volatile goto ("some assembler instructions here"
9075    : /* No outputs. */
9076    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
9077    : /* No clobbers. */
9078    : top);
9080 @end example
9082 With no modifiers, this is what the output from the operands would be for the 
9083 @samp{att} and @samp{intel} dialects of assembler:
9085 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9086 @headitem Operand @tab @samp{att} @tab @samp{intel}
9087 @item @code{%0}
9088 @tab @code{%eax}
9089 @tab @code{eax}
9090 @item @code{%1}
9091 @tab @code{$2}
9092 @tab @code{2}
9093 @item @code{%2}
9094 @tab @code{$.L2}
9095 @tab @code{OFFSET FLAT:.L2}
9096 @end multitable
9098 The table below shows the list of supported modifiers and their effects.
9100 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9101 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9102 @item @code{z}
9103 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9104 @tab @code{%z0}
9105 @tab @code{l}
9106 @tab 
9107 @item @code{b}
9108 @tab Print the QImode name of the register.
9109 @tab @code{%b0}
9110 @tab @code{%al}
9111 @tab @code{al}
9112 @item @code{h}
9113 @tab Print the QImode name for a ``high'' register.
9114 @tab @code{%h0}
9115 @tab @code{%ah}
9116 @tab @code{ah}
9117 @item @code{w}
9118 @tab Print the HImode name of the register.
9119 @tab @code{%w0}
9120 @tab @code{%ax}
9121 @tab @code{ax}
9122 @item @code{k}
9123 @tab Print the SImode name of the register.
9124 @tab @code{%k0}
9125 @tab @code{%eax}
9126 @tab @code{eax}
9127 @item @code{q}
9128 @tab Print the DImode name of the register.
9129 @tab @code{%q0}
9130 @tab @code{%rax}
9131 @tab @code{rax}
9132 @item @code{l}
9133 @tab Print the label name with no punctuation.
9134 @tab @code{%l2}
9135 @tab @code{.L2}
9136 @tab @code{.L2}
9137 @item @code{c}
9138 @tab Require a constant operand and print the constant expression with no punctuation.
9139 @tab @code{%c1}
9140 @tab @code{2}
9141 @tab @code{2}
9142 @end multitable
9144 @anchor{x86floatingpointasmoperands}
9145 @subsubsection x86 Floating-Point @code{asm} Operands
9147 On x86 targets, there are several rules on the usage of stack-like registers
9148 in the operands of an @code{asm}.  These rules apply only to the operands
9149 that are stack-like registers:
9151 @enumerate
9152 @item
9153 Given a set of input registers that die in an @code{asm}, it is
9154 necessary to know which are implicitly popped by the @code{asm}, and
9155 which must be explicitly popped by GCC@.
9157 An input register that is implicitly popped by the @code{asm} must be
9158 explicitly clobbered, unless it is constrained to match an
9159 output operand.
9161 @item
9162 For any input register that is implicitly popped by an @code{asm}, it is
9163 necessary to know how to adjust the stack to compensate for the pop.
9164 If any non-popped input is closer to the top of the reg-stack than
9165 the implicitly popped register, it would not be possible to know what the
9166 stack looked like---it's not clear how the rest of the stack ``slides
9167 up''.
9169 All implicitly popped input registers must be closer to the top of
9170 the reg-stack than any input that is not implicitly popped.
9172 It is possible that if an input dies in an @code{asm}, the compiler might
9173 use the input register for an output reload.  Consider this example:
9175 @smallexample
9176 asm ("foo" : "=t" (a) : "f" (b));
9177 @end smallexample
9179 @noindent
9180 This code says that input @code{b} is not popped by the @code{asm}, and that
9181 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9182 deeper after the @code{asm} than it was before.  But, it is possible that
9183 reload may think that it can use the same register for both the input and
9184 the output.
9186 To prevent this from happening,
9187 if any input operand uses the @samp{f} constraint, all output register
9188 constraints must use the @samp{&} early-clobber modifier.
9190 The example above is correctly written as:
9192 @smallexample
9193 asm ("foo" : "=&t" (a) : "f" (b));
9194 @end smallexample
9196 @item
9197 Some operands need to be in particular places on the stack.  All
9198 output operands fall in this category---GCC has no other way to
9199 know which registers the outputs appear in unless you indicate
9200 this in the constraints.
9202 Output operands must specifically indicate which register an output
9203 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9204 constraints must select a class with a single register.
9206 @item
9207 Output operands may not be ``inserted'' between existing stack registers.
9208 Since no 387 opcode uses a read/write operand, all output operands
9209 are dead before the @code{asm}, and are pushed by the @code{asm}.
9210 It makes no sense to push anywhere but the top of the reg-stack.
9212 Output operands must start at the top of the reg-stack: output
9213 operands may not ``skip'' a register.
9215 @item
9216 Some @code{asm} statements may need extra stack space for internal
9217 calculations.  This can be guaranteed by clobbering stack registers
9218 unrelated to the inputs and outputs.
9220 @end enumerate
9222 This @code{asm}
9223 takes one input, which is internally popped, and produces two outputs.
9225 @smallexample
9226 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9227 @end smallexample
9229 @noindent
9230 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9231 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9232 for the compiler to know that @code{fyl2xp1} pops both inputs.
9234 @smallexample
9235 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9236 @end smallexample
9238 @lowersections
9239 @include md.texi
9240 @raisesections
9242 @node Asm Labels
9243 @subsection Controlling Names Used in Assembler Code
9244 @cindex assembler names for identifiers
9245 @cindex names used in assembler code
9246 @cindex identifiers, names in assembler code
9248 You can specify the name to be used in the assembler code for a C
9249 function or variable by writing the @code{asm} (or @code{__asm__})
9250 keyword after the declarator.
9251 It is up to you to make sure that the assembler names you choose do not
9252 conflict with any other assembler symbols, or reference registers.
9254 @subsubheading Assembler names for data:
9256 This sample shows how to specify the assembler name for data:
9258 @smallexample
9259 int foo asm ("myfoo") = 2;
9260 @end smallexample
9262 @noindent
9263 This specifies that the name to be used for the variable @code{foo} in
9264 the assembler code should be @samp{myfoo} rather than the usual
9265 @samp{_foo}.
9267 On systems where an underscore is normally prepended to the name of a C
9268 variable, this feature allows you to define names for the
9269 linker that do not start with an underscore.
9271 GCC does not support using this feature with a non-static local variable 
9272 since such variables do not have assembler names.  If you are
9273 trying to put the variable in a particular register, see 
9274 @ref{Explicit Register Variables}.
9276 @subsubheading Assembler names for functions:
9278 To specify the assembler name for functions, write a declaration for the 
9279 function before its definition and put @code{asm} there, like this:
9281 @smallexample
9282 int func (int x, int y) asm ("MYFUNC");
9283      
9284 int func (int x, int y)
9286    /* @r{@dots{}} */
9287 @end smallexample
9289 @noindent
9290 This specifies that the name to be used for the function @code{func} in
9291 the assembler code should be @code{MYFUNC}.
9293 @node Explicit Register Variables
9294 @subsection Variables in Specified Registers
9295 @anchor{Explicit Reg Vars}
9296 @cindex explicit register variables
9297 @cindex variables in specified registers
9298 @cindex specified registers
9300 GNU C allows you to associate specific hardware registers with C 
9301 variables.  In almost all cases, allowing the compiler to assign
9302 registers produces the best code.  However under certain unusual
9303 circumstances, more precise control over the variable storage is 
9304 required.
9306 Both global and local variables can be associated with a register.  The
9307 consequences of performing this association are very different between
9308 the two, as explained in the sections below.
9310 @menu
9311 * Global Register Variables::   Variables declared at global scope.
9312 * Local Register Variables::    Variables declared within a function.
9313 @end menu
9315 @node Global Register Variables
9316 @subsubsection Defining Global Register Variables
9317 @anchor{Global Reg Vars}
9318 @cindex global register variables
9319 @cindex registers, global variables in
9320 @cindex registers, global allocation
9322 You can define a global register variable and associate it with a specified 
9323 register like this:
9325 @smallexample
9326 register int *foo asm ("r12");
9327 @end smallexample
9329 @noindent
9330 Here @code{r12} is the name of the register that should be used. Note that 
9331 this is the same syntax used for defining local register variables, but for 
9332 a global variable the declaration appears outside a function. The 
9333 @code{register} keyword is required, and cannot be combined with 
9334 @code{static}. The register name must be a valid register name for the
9335 target platform.
9337 Registers are a scarce resource on most systems and allowing the 
9338 compiler to manage their usage usually results in the best code. However, 
9339 under special circumstances it can make sense to reserve some globally.
9340 For example this may be useful in programs such as programming language 
9341 interpreters that have a couple of global variables that are accessed 
9342 very often.
9344 After defining a global register variable, for the current compilation
9345 unit:
9347 @itemize @bullet
9348 @item The register is reserved entirely for this use, and will not be 
9349 allocated for any other purpose.
9350 @item The register is not saved and restored by any functions.
9351 @item Stores into this register are never deleted even if they appear to be 
9352 dead, but references may be deleted, moved or simplified.
9353 @end itemize
9355 Note that these points @emph{only} apply to code that is compiled with the
9356 definition. The behavior of code that is merely linked in (for example 
9357 code from libraries) is not affected.
9359 If you want to recompile source files that do not actually use your global 
9360 register variable so they do not use the specified register for any other 
9361 purpose, you need not actually add the global register declaration to 
9362 their source code. It suffices to specify the compiler option 
9363 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9364 register.
9366 @subsubheading Declaring the variable
9368 Global register variables can not have initial values, because an
9369 executable file has no means to supply initial contents for a register.
9371 When selecting a register, choose one that is normally saved and 
9372 restored by function calls on your machine. This ensures that code
9373 which is unaware of this reservation (such as library routines) will 
9374 restore it before returning.
9376 On machines with register windows, be sure to choose a global
9377 register that is not affected magically by the function call mechanism.
9379 @subsubheading Using the variable
9381 @cindex @code{qsort}, and global register variables
9382 When calling routines that are not aware of the reservation, be 
9383 cautious if those routines call back into code which uses them. As an 
9384 example, if you call the system library version of @code{qsort}, it may 
9385 clobber your registers during execution, but (if you have selected 
9386 appropriate registers) it will restore them before returning. However 
9387 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9388 function. As a result, global values will not reliably be available to 
9389 the comparison function unless the @code{qsort} function itself is rebuilt.
9391 Similarly, it is not safe to access the global register variables from signal
9392 handlers or from more than one thread of control. Unless you recompile 
9393 them specially for the task at hand, the system library routines may 
9394 temporarily use the register for other things.
9396 @cindex register variable after @code{longjmp}
9397 @cindex global register after @code{longjmp}
9398 @cindex value after @code{longjmp}
9399 @findex longjmp
9400 @findex setjmp
9401 On most machines, @code{longjmp} restores to each global register
9402 variable the value it had at the time of the @code{setjmp}. On some
9403 machines, however, @code{longjmp} does not change the value of global
9404 register variables. To be portable, the function that called @code{setjmp}
9405 should make other arrangements to save the values of the global register
9406 variables, and to restore them in a @code{longjmp}. This way, the same
9407 thing happens regardless of what @code{longjmp} does.
9409 Eventually there may be a way of asking the compiler to choose a register 
9410 automatically, but first we need to figure out how it should choose and 
9411 how to enable you to guide the choice.  No solution is evident.
9413 @node Local Register Variables
9414 @subsubsection Specifying Registers for Local Variables
9415 @anchor{Local Reg Vars}
9416 @cindex local variables, specifying registers
9417 @cindex specifying registers for local variables
9418 @cindex registers for local variables
9420 You can define a local register variable and associate it with a specified 
9421 register like this:
9423 @smallexample
9424 register int *foo asm ("r12");
9425 @end smallexample
9427 @noindent
9428 Here @code{r12} is the name of the register that should be used.  Note
9429 that this is the same syntax used for defining global register variables, 
9430 but for a local variable the declaration appears within a function.  The 
9431 @code{register} keyword is required, and cannot be combined with 
9432 @code{static}.  The register name must be a valid register name for the
9433 target platform.
9435 As with global register variables, it is recommended that you choose 
9436 a register that is normally saved and restored by function calls on your 
9437 machine, so that calls to library routines will not clobber it.
9439 The only supported use for this feature is to specify registers
9440 for input and output operands when calling Extended @code{asm} 
9441 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9442 particular machine don't provide sufficient control to select the desired 
9443 register.  To force an operand into a register, create a local variable 
9444 and specify the register name after the variable's declaration.  Then use 
9445 the local variable for the @code{asm} operand and specify any constraint 
9446 letter that matches the register:
9448 @smallexample
9449 register int *p1 asm ("r0") = @dots{};
9450 register int *p2 asm ("r1") = @dots{};
9451 register int *result asm ("r0");
9452 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9453 @end smallexample
9455 @emph{Warning:} In the above example, be aware that a register (for example 
9456 @code{r0}) can be call-clobbered by subsequent code, including function 
9457 calls and library calls for arithmetic operators on other variables (for 
9458 example the initialization of @code{p2}).  In this case, use temporary 
9459 variables for expressions between the register assignments:
9461 @smallexample
9462 int t1 = @dots{};
9463 register int *p1 asm ("r0") = @dots{};
9464 register int *p2 asm ("r1") = t1;
9465 register int *result asm ("r0");
9466 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9467 @end smallexample
9469 Defining a register variable does not reserve the register.  Other than
9470 when invoking the Extended @code{asm}, the contents of the specified 
9471 register are not guaranteed.  For this reason, the following uses 
9472 are explicitly @emph{not} supported.  If they appear to work, it is only 
9473 happenstance, and may stop working as intended due to (seemingly) 
9474 unrelated changes in surrounding code, or even minor changes in the 
9475 optimization of a future version of gcc:
9477 @itemize @bullet
9478 @item Passing parameters to or from Basic @code{asm}
9479 @item Passing parameters to or from Extended @code{asm} without using input 
9480 or output operands.
9481 @item Passing parameters to or from routines written in assembler (or
9482 other languages) using non-standard calling conventions.
9483 @end itemize
9485 Some developers use Local Register Variables in an attempt to improve 
9486 gcc's allocation of registers, especially in large functions.  In this 
9487 case the register name is essentially a hint to the register allocator.
9488 While in some instances this can generate better code, improvements are
9489 subject to the whims of the allocator/optimizers.  Since there are no
9490 guarantees that your improvements won't be lost, this usage of Local
9491 Register Variables is discouraged.
9493 On the MIPS platform, there is related use for local register variables 
9494 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9495 Defining coprocessor specifics for MIPS targets, gccint, 
9496 GNU Compiler Collection (GCC) Internals}).
9498 @node Size of an asm
9499 @subsection Size of an @code{asm}
9501 Some targets require that GCC track the size of each instruction used
9502 in order to generate correct code.  Because the final length of the
9503 code produced by an @code{asm} statement is only known by the
9504 assembler, GCC must make an estimate as to how big it will be.  It
9505 does this by counting the number of instructions in the pattern of the
9506 @code{asm} and multiplying that by the length of the longest
9507 instruction supported by that processor.  (When working out the number
9508 of instructions, it assumes that any occurrence of a newline or of
9509 whatever statement separator character is supported by the assembler --
9510 typically @samp{;} --- indicates the end of an instruction.)
9512 Normally, GCC's estimate is adequate to ensure that correct
9513 code is generated, but it is possible to confuse the compiler if you use
9514 pseudo instructions or assembler macros that expand into multiple real
9515 instructions, or if you use assembler directives that expand to more
9516 space in the object file than is needed for a single instruction.
9517 If this happens then the assembler may produce a diagnostic saying that
9518 a label is unreachable.
9520 @node Alternate Keywords
9521 @section Alternate Keywords
9522 @cindex alternate keywords
9523 @cindex keywords, alternate
9525 @option{-ansi} and the various @option{-std} options disable certain
9526 keywords.  This causes trouble when you want to use GNU C extensions, or
9527 a general-purpose header file that should be usable by all programs,
9528 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9529 @code{inline} are not available in programs compiled with
9530 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9531 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9532 ISO C99 keyword
9533 @code{restrict} is only available when @option{-std=gnu99} (which will
9534 eventually be the default) or @option{-std=c99} (or the equivalent
9535 @option{-std=iso9899:1999}), or an option for a later standard
9536 version, is used.
9538 The way to solve these problems is to put @samp{__} at the beginning and
9539 end of each problematical keyword.  For example, use @code{__asm__}
9540 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9542 Other C compilers won't accept these alternative keywords; if you want to
9543 compile with another compiler, you can define the alternate keywords as
9544 macros to replace them with the customary keywords.  It looks like this:
9546 @smallexample
9547 #ifndef __GNUC__
9548 #define __asm__ asm
9549 #endif
9550 @end smallexample
9552 @findex __extension__
9553 @opindex pedantic
9554 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9555 You can
9556 prevent such warnings within one expression by writing
9557 @code{__extension__} before the expression.  @code{__extension__} has no
9558 effect aside from this.
9560 @node Incomplete Enums
9561 @section Incomplete @code{enum} Types
9563 You can define an @code{enum} tag without specifying its possible values.
9564 This results in an incomplete type, much like what you get if you write
9565 @code{struct foo} without describing the elements.  A later declaration
9566 that does specify the possible values completes the type.
9568 You cannot allocate variables or storage using the type while it is
9569 incomplete.  However, you can work with pointers to that type.
9571 This extension may not be very useful, but it makes the handling of
9572 @code{enum} more consistent with the way @code{struct} and @code{union}
9573 are handled.
9575 This extension is not supported by GNU C++.
9577 @node Function Names
9578 @section Function Names as Strings
9579 @cindex @code{__func__} identifier
9580 @cindex @code{__FUNCTION__} identifier
9581 @cindex @code{__PRETTY_FUNCTION__} identifier
9583 GCC provides three magic constants that hold the name of the current
9584 function as a string.  In C++11 and later modes, all three are treated
9585 as constant expressions and can be used in @code{constexpr} constexts.
9586 The first of these constants is @code{__func__}, which is part of
9587 the C99 standard:
9589 The identifier @code{__func__} is implicitly declared by the translator
9590 as if, immediately following the opening brace of each function
9591 definition, the declaration
9593 @smallexample
9594 static const char __func__[] = "function-name";
9595 @end smallexample
9597 @noindent
9598 appeared, where function-name is the name of the lexically-enclosing
9599 function.  This name is the unadorned name of the function.  As an
9600 extension, at file (or, in C++, namespace scope), @code{__func__}
9601 evaluates to the empty string.
9603 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9604 backward compatibility with old versions of GCC.
9606 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9607 @code{__func__}, except that at file (or, in C++, namespace scope),
9608 it evaluates to the string @code{"top level"}.  In addition, in C++,
9609 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9610 well as its bare name.  For example, this program:
9612 @smallexample
9613 extern "C" int printf (const char *, ...);
9615 class a @{
9616  public:
9617   void sub (int i)
9618     @{
9619       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9620       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9621     @}
9625 main (void)
9627   a ax;
9628   ax.sub (0);
9629   return 0;
9631 @end smallexample
9633 @noindent
9634 gives this output:
9636 @smallexample
9637 __FUNCTION__ = sub
9638 __PRETTY_FUNCTION__ = void a::sub(int)
9639 @end smallexample
9641 These identifiers are variables, not preprocessor macros, and may not
9642 be used to initialize @code{char} arrays or be concatenated with string
9643 literals.
9645 @node Return Address
9646 @section Getting the Return or Frame Address of a Function
9648 These functions may be used to get information about the callers of a
9649 function.
9651 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9652 This function returns the return address of the current function, or of
9653 one of its callers.  The @var{level} argument is number of frames to
9654 scan up the call stack.  A value of @code{0} yields the return address
9655 of the current function, a value of @code{1} yields the return address
9656 of the caller of the current function, and so forth.  When inlining
9657 the expected behavior is that the function returns the address of
9658 the function that is returned to.  To work around this behavior use
9659 the @code{noinline} function attribute.
9661 The @var{level} argument must be a constant integer.
9663 On some machines it may be impossible to determine the return address of
9664 any function other than the current one; in such cases, or when the top
9665 of the stack has been reached, this function returns @code{0} or a
9666 random value.  In addition, @code{__builtin_frame_address} may be used
9667 to determine if the top of the stack has been reached.
9669 Additional post-processing of the returned value may be needed, see
9670 @code{__builtin_extract_return_addr}.
9672 Calling this function with a nonzero argument can have unpredictable
9673 effects, including crashing the calling program.  As a result, calls
9674 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9675 option is in effect.  Such calls should only be made in debugging
9676 situations.
9677 @end deftypefn
9679 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9680 The address as returned by @code{__builtin_return_address} may have to be fed
9681 through this function to get the actual encoded address.  For example, on the
9682 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9683 platforms an offset has to be added for the true next instruction to be
9684 executed.
9686 If no fixup is needed, this function simply passes through @var{addr}.
9687 @end deftypefn
9689 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9690 This function does the reverse of @code{__builtin_extract_return_addr}.
9691 @end deftypefn
9693 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9694 This function is similar to @code{__builtin_return_address}, but it
9695 returns the address of the function frame rather than the return address
9696 of the function.  Calling @code{__builtin_frame_address} with a value of
9697 @code{0} yields the frame address of the current function, a value of
9698 @code{1} yields the frame address of the caller of the current function,
9699 and so forth.
9701 The frame is the area on the stack that holds local variables and saved
9702 registers.  The frame address is normally the address of the first word
9703 pushed on to the stack by the function.  However, the exact definition
9704 depends upon the processor and the calling convention.  If the processor
9705 has a dedicated frame pointer register, and the function has a frame,
9706 then @code{__builtin_frame_address} returns the value of the frame
9707 pointer register.
9709 On some machines it may be impossible to determine the frame address of
9710 any function other than the current one; in such cases, or when the top
9711 of the stack has been reached, this function returns @code{0} if
9712 the first frame pointer is properly initialized by the startup code.
9714 Calling this function with a nonzero argument can have unpredictable
9715 effects, including crashing the calling program.  As a result, calls
9716 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9717 option is in effect.  Such calls should only be made in debugging
9718 situations.
9719 @end deftypefn
9721 @node Vector Extensions
9722 @section Using Vector Instructions through Built-in Functions
9724 On some targets, the instruction set contains SIMD vector instructions which
9725 operate on multiple values contained in one large register at the same time.
9726 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9727 this way.
9729 The first step in using these extensions is to provide the necessary data
9730 types.  This should be done using an appropriate @code{typedef}:
9732 @smallexample
9733 typedef int v4si __attribute__ ((vector_size (16)));
9734 @end smallexample
9736 @noindent
9737 The @code{int} type specifies the base type, while the attribute specifies
9738 the vector size for the variable, measured in bytes.  For example, the
9739 declaration above causes the compiler to set the mode for the @code{v4si}
9740 type to be 16 bytes wide and divided into @code{int} sized units.  For
9741 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9742 corresponding mode of @code{foo} is @acronym{V4SI}.
9744 The @code{vector_size} attribute is only applicable to integral and
9745 float scalars, although arrays, pointers, and function return values
9746 are allowed in conjunction with this construct. Only sizes that are
9747 a power of two are currently allowed.
9749 All the basic integer types can be used as base types, both as signed
9750 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9751 @code{long long}.  In addition, @code{float} and @code{double} can be
9752 used to build floating-point vector types.
9754 Specifying a combination that is not valid for the current architecture
9755 causes GCC to synthesize the instructions using a narrower mode.
9756 For example, if you specify a variable of type @code{V4SI} and your
9757 architecture does not allow for this specific SIMD type, GCC
9758 produces code that uses 4 @code{SIs}.
9760 The types defined in this manner can be used with a subset of normal C
9761 operations.  Currently, GCC allows using the following operators
9762 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9764 The operations behave like C++ @code{valarrays}.  Addition is defined as
9765 the addition of the corresponding elements of the operands.  For
9766 example, in the code below, each of the 4 elements in @var{a} is
9767 added to the corresponding 4 elements in @var{b} and the resulting
9768 vector is stored in @var{c}.
9770 @smallexample
9771 typedef int v4si __attribute__ ((vector_size (16)));
9773 v4si a, b, c;
9775 c = a + b;
9776 @end smallexample
9778 Subtraction, multiplication, division, and the logical operations
9779 operate in a similar manner.  Likewise, the result of using the unary
9780 minus or complement operators on a vector type is a vector whose
9781 elements are the negative or complemented values of the corresponding
9782 elements in the operand.
9784 It is possible to use shifting operators @code{<<}, @code{>>} on
9785 integer-type vectors. The operation is defined as following: @code{@{a0,
9786 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9787 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9788 elements. 
9790 For convenience, it is allowed to use a binary vector operation
9791 where one operand is a scalar. In that case the compiler transforms
9792 the scalar operand into a vector where each element is the scalar from
9793 the operation. The transformation happens only if the scalar could be
9794 safely converted to the vector-element type.
9795 Consider the following code.
9797 @smallexample
9798 typedef int v4si __attribute__ ((vector_size (16)));
9800 v4si a, b, c;
9801 long l;
9803 a = b + 1;    /* a = b + @{1,1,1,1@}; */
9804 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
9806 a = l + a;    /* Error, cannot convert long to int. */
9807 @end smallexample
9809 Vectors can be subscripted as if the vector were an array with
9810 the same number of elements and base type.  Out of bound accesses
9811 invoke undefined behavior at run time.  Warnings for out of bound
9812 accesses for vector subscription can be enabled with
9813 @option{-Warray-bounds}.
9815 Vector comparison is supported with standard comparison
9816 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9817 vector expressions of integer-type or real-type. Comparison between
9818 integer-type vectors and real-type vectors are not supported.  The
9819 result of the comparison is a vector of the same width and number of
9820 elements as the comparison operands with a signed integral element
9821 type.
9823 Vectors are compared element-wise producing 0 when comparison is false
9824 and -1 (constant of the appropriate type where all bits are set)
9825 otherwise. Consider the following example.
9827 @smallexample
9828 typedef int v4si __attribute__ ((vector_size (16)));
9830 v4si a = @{1,2,3,4@};
9831 v4si b = @{3,2,1,4@};
9832 v4si c;
9834 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
9835 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
9836 @end smallexample
9838 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9839 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9840 integer vector with the same number of elements of the same size as @code{b}
9841 and @code{c}, computes all three arguments and creates a vector
9842 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
9843 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9844 As in the case of binary operations, this syntax is also accepted when
9845 one of @code{b} or @code{c} is a scalar that is then transformed into a
9846 vector. If both @code{b} and @code{c} are scalars and the type of
9847 @code{true?b:c} has the same size as the element type of @code{a}, then
9848 @code{b} and @code{c} are converted to a vector type whose elements have
9849 this type and with the same number of elements as @code{a}.
9851 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9852 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9853 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9854 For mixed operations between a scalar @code{s} and a vector @code{v},
9855 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9856 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9858 @findex __builtin_shuffle
9859 Vector shuffling is available using functions
9860 @code{__builtin_shuffle (vec, mask)} and
9861 @code{__builtin_shuffle (vec0, vec1, mask)}.
9862 Both functions construct a permutation of elements from one or two
9863 vectors and return a vector of the same type as the input vector(s).
9864 The @var{mask} is an integral vector with the same width (@var{W})
9865 and element count (@var{N}) as the output vector.
9867 The elements of the input vectors are numbered in memory ordering of
9868 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
9869 elements of @var{mask} are considered modulo @var{N} in the single-operand
9870 case and modulo @math{2*@var{N}} in the two-operand case.
9872 Consider the following example,
9874 @smallexample
9875 typedef int v4si __attribute__ ((vector_size (16)));
9877 v4si a = @{1,2,3,4@};
9878 v4si b = @{5,6,7,8@};
9879 v4si mask1 = @{0,1,1,3@};
9880 v4si mask2 = @{0,4,2,5@};
9881 v4si res;
9883 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
9884 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
9885 @end smallexample
9887 Note that @code{__builtin_shuffle} is intentionally semantically
9888 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9890 You can declare variables and use them in function calls and returns, as
9891 well as in assignments and some casts.  You can specify a vector type as
9892 a return type for a function.  Vector types can also be used as function
9893 arguments.  It is possible to cast from one vector type to another,
9894 provided they are of the same size (in fact, you can also cast vectors
9895 to and from other datatypes of the same size).
9897 You cannot operate between vectors of different lengths or different
9898 signedness without a cast.
9900 @node Offsetof
9901 @section Support for @code{offsetof}
9902 @findex __builtin_offsetof
9904 GCC implements for both C and C++ a syntactic extension to implement
9905 the @code{offsetof} macro.
9907 @smallexample
9908 primary:
9909         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9911 offsetof_member_designator:
9912           @code{identifier}
9913         | offsetof_member_designator "." @code{identifier}
9914         | offsetof_member_designator "[" @code{expr} "]"
9915 @end smallexample
9917 This extension is sufficient such that
9919 @smallexample
9920 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
9921 @end smallexample
9923 @noindent
9924 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
9925 may be dependent.  In either case, @var{member} may consist of a single
9926 identifier, or a sequence of member accesses and array references.
9928 @node __sync Builtins
9929 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9931 The following built-in functions
9932 are intended to be compatible with those described
9933 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9934 section 7.4.  As such, they depart from normal GCC practice by not using
9935 the @samp{__builtin_} prefix and also by being overloaded so that they
9936 work on multiple types.
9938 The definition given in the Intel documentation allows only for the use of
9939 the types @code{int}, @code{long}, @code{long long} or their unsigned
9940 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9941 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9942 Operations on pointer arguments are performed as if the operands were
9943 of the @code{uintptr_t} type.  That is, they are not scaled by the size
9944 of the type to which the pointer points.
9946 These functions are implemented in terms of the @samp{__atomic}
9947 builtins (@pxref{__atomic Builtins}).  They should not be used for new
9948 code which should use the @samp{__atomic} builtins instead.
9950 Not all operations are supported by all target processors.  If a particular
9951 operation cannot be implemented on the target processor, a warning is
9952 generated and a call to an external function is generated.  The external
9953 function carries the same name as the built-in version,
9954 with an additional suffix
9955 @samp{_@var{n}} where @var{n} is the size of the data type.
9957 @c ??? Should we have a mechanism to suppress this warning?  This is almost
9958 @c useful for implementing the operation under the control of an external
9959 @c mutex.
9961 In most cases, these built-in functions are considered a @dfn{full barrier}.
9962 That is,
9963 no memory operand is moved across the operation, either forward or
9964 backward.  Further, instructions are issued as necessary to prevent the
9965 processor from speculating loads across the operation and from queuing stores
9966 after the operation.
9968 All of the routines are described in the Intel documentation to take
9969 ``an optional list of variables protected by the memory barrier''.  It's
9970 not clear what is meant by that; it could mean that @emph{only} the
9971 listed variables are protected, or it could mean a list of additional
9972 variables to be protected.  The list is ignored by GCC which treats it as
9973 empty.  GCC interprets an empty list as meaning that all globally
9974 accessible variables should be protected.
9976 @table @code
9977 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9978 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9979 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9980 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9981 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9982 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9983 @findex __sync_fetch_and_add
9984 @findex __sync_fetch_and_sub
9985 @findex __sync_fetch_and_or
9986 @findex __sync_fetch_and_and
9987 @findex __sync_fetch_and_xor
9988 @findex __sync_fetch_and_nand
9989 These built-in functions perform the operation suggested by the name, and
9990 returns the value that had previously been in memory.  That is, operations
9991 on integer operands have the following semantics.  Operations on pointer
9992 arguments are performed as if the operands were of the @code{uintptr_t}
9993 type.  That is, they are not scaled by the size of the type to which
9994 the pointer points.
9996 @smallexample
9997 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9998 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
9999 @end smallexample
10001 The object pointed to by the first argument must be of integer or pointer
10002 type.  It must not be a boolean type.
10004 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10005 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10007 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10008 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10009 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10010 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10011 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10012 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10013 @findex __sync_add_and_fetch
10014 @findex __sync_sub_and_fetch
10015 @findex __sync_or_and_fetch
10016 @findex __sync_and_and_fetch
10017 @findex __sync_xor_and_fetch
10018 @findex __sync_nand_and_fetch
10019 These built-in functions perform the operation suggested by the name, and
10020 return the new value.  That is, operations on integer operands have
10021 the following semantics.  Operations on pointer operands are performed as
10022 if the operand's type were @code{uintptr_t}.
10024 @smallexample
10025 @{ *ptr @var{op}= value; return *ptr; @}
10026 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10027 @end smallexample
10029 The same constraints on arguments apply as for the corresponding
10030 @code{__sync_op_and_fetch} built-in functions.
10032 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10033 as @code{*ptr = ~(*ptr & value)} instead of
10034 @code{*ptr = ~*ptr & value}.
10036 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10037 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10038 @findex __sync_bool_compare_and_swap
10039 @findex __sync_val_compare_and_swap
10040 These built-in functions perform an atomic compare and swap.
10041 That is, if the current
10042 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10043 @code{*@var{ptr}}.
10045 The ``bool'' version returns true if the comparison is successful and
10046 @var{newval} is written.  The ``val'' version returns the contents
10047 of @code{*@var{ptr}} before the operation.
10049 @item __sync_synchronize (...)
10050 @findex __sync_synchronize
10051 This built-in function issues a full memory barrier.
10053 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10054 @findex __sync_lock_test_and_set
10055 This built-in function, as described by Intel, is not a traditional test-and-set
10056 operation, but rather an atomic exchange operation.  It writes @var{value}
10057 into @code{*@var{ptr}}, and returns the previous contents of
10058 @code{*@var{ptr}}.
10060 Many targets have only minimal support for such locks, and do not support
10061 a full exchange operation.  In this case, a target may support reduced
10062 functionality here by which the @emph{only} valid value to store is the
10063 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10064 is implementation defined.
10066 This built-in function is not a full barrier,
10067 but rather an @dfn{acquire barrier}.
10068 This means that references after the operation cannot move to (or be
10069 speculated to) before the operation, but previous memory stores may not
10070 be globally visible yet, and previous memory loads may not yet be
10071 satisfied.
10073 @item void __sync_lock_release (@var{type} *ptr, ...)
10074 @findex __sync_lock_release
10075 This built-in function releases the lock acquired by
10076 @code{__sync_lock_test_and_set}.
10077 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10079 This built-in function is not a full barrier,
10080 but rather a @dfn{release barrier}.
10081 This means that all previous memory stores are globally visible, and all
10082 previous memory loads have been satisfied, but following memory reads
10083 are not prevented from being speculated to before the barrier.
10084 @end table
10086 @node __atomic Builtins
10087 @section Built-in Functions for Memory Model Aware Atomic Operations
10089 The following built-in functions approximately match the requirements
10090 for the C++11 memory model.  They are all
10091 identified by being prefixed with @samp{__atomic} and most are
10092 overloaded so that they work with multiple types.
10094 These functions are intended to replace the legacy @samp{__sync}
10095 builtins.  The main difference is that the memory order that is requested
10096 is a parameter to the functions.  New code should always use the
10097 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10099 Note that the @samp{__atomic} builtins assume that programs will
10100 conform to the C++11 memory model.  In particular, they assume
10101 that programs are free of data races.  See the C++11 standard for
10102 detailed requirements.
10104 The @samp{__atomic} builtins can be used with any integral scalar or
10105 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10106 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10107 supported by the architecture.
10109 The four non-arithmetic functions (load, store, exchange, and 
10110 compare_exchange) all have a generic version as well.  This generic
10111 version works on any data type.  It uses the lock-free built-in function
10112 if the specific data type size makes that possible; otherwise, an
10113 external call is left to be resolved at run time.  This external call is
10114 the same format with the addition of a @samp{size_t} parameter inserted
10115 as the first parameter indicating the size of the object being pointed to.
10116 All objects must be the same size.
10118 There are 6 different memory orders that can be specified.  These map
10119 to the C++11 memory orders with the same names, see the C++11 standard
10120 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10121 on atomic synchronization} for detailed definitions.  Individual
10122 targets may also support additional memory orders for use on specific
10123 architectures.  Refer to the target documentation for details of
10124 these.
10126 An atomic operation can both constrain code motion and
10127 be mapped to hardware instructions for synchronization between threads
10128 (e.g., a fence).  To which extent this happens is controlled by the
10129 memory orders, which are listed here in approximately ascending order of
10130 strength.  The description of each memory order is only meant to roughly
10131 illustrate the effects and is not a specification; see the C++11
10132 memory model for precise semantics.
10134 @table  @code
10135 @item __ATOMIC_RELAXED
10136 Implies no inter-thread ordering constraints.
10137 @item __ATOMIC_CONSUME
10138 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10139 memory order because of a deficiency in C++11's semantics for
10140 @code{memory_order_consume}.
10141 @item __ATOMIC_ACQUIRE
10142 Creates an inter-thread happens-before constraint from the release (or
10143 stronger) semantic store to this acquire load.  Can prevent hoisting
10144 of code to before the operation.
10145 @item __ATOMIC_RELEASE
10146 Creates an inter-thread happens-before constraint to acquire (or stronger)
10147 semantic loads that read from this release store.  Can prevent sinking
10148 of code to after the operation.
10149 @item __ATOMIC_ACQ_REL
10150 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10151 @code{__ATOMIC_RELEASE}.
10152 @item __ATOMIC_SEQ_CST
10153 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10154 @end table
10156 Note that in the C++11 memory model, @emph{fences} (e.g.,
10157 @samp{__atomic_thread_fence}) take effect in combination with other
10158 atomic operations on specific memory locations (e.g., atomic loads);
10159 operations on specific memory locations do not necessarily affect other
10160 operations in the same way.
10162 Target architectures are encouraged to provide their own patterns for
10163 each of the atomic built-in functions.  If no target is provided, the original
10164 non-memory model set of @samp{__sync} atomic built-in functions are
10165 used, along with any required synchronization fences surrounding it in
10166 order to achieve the proper behavior.  Execution in this case is subject
10167 to the same restrictions as those built-in functions.
10169 If there is no pattern or mechanism to provide a lock-free instruction
10170 sequence, a call is made to an external routine with the same parameters
10171 to be resolved at run time.
10173 When implementing patterns for these built-in functions, the memory order
10174 parameter can be ignored as long as the pattern implements the most
10175 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10176 orders execute correctly with this memory order but they may not execute as
10177 efficiently as they could with a more appropriate implementation of the
10178 relaxed requirements.
10180 Note that the C++11 standard allows for the memory order parameter to be
10181 determined at run time rather than at compile time.  These built-in
10182 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10183 than invoke a runtime library call or inline a switch statement.  This is
10184 standard compliant, safe, and the simplest approach for now.
10186 The memory order parameter is a signed int, but only the lower 16 bits are
10187 reserved for the memory order.  The remainder of the signed int is reserved
10188 for target use and should be 0.  Use of the predefined atomic values
10189 ensures proper usage.
10191 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10192 This built-in function implements an atomic load operation.  It returns the
10193 contents of @code{*@var{ptr}}.
10195 The valid memory order variants are
10196 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10197 and @code{__ATOMIC_CONSUME}.
10199 @end deftypefn
10201 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10202 This is the generic version of an atomic load.  It returns the
10203 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10205 @end deftypefn
10207 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10208 This built-in function implements an atomic store operation.  It writes 
10209 @code{@var{val}} into @code{*@var{ptr}}.  
10211 The valid memory order variants are
10212 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10214 @end deftypefn
10216 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10217 This is the generic version of an atomic store.  It stores the value
10218 of @code{*@var{val}} into @code{*@var{ptr}}.
10220 @end deftypefn
10222 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10223 This built-in function implements an atomic exchange operation.  It writes
10224 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10225 @code{*@var{ptr}}.
10227 The valid memory order variants are
10228 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10229 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10231 @end deftypefn
10233 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10234 This is the generic version of an atomic exchange.  It stores the
10235 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10236 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10238 @end deftypefn
10240 @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)
10241 This built-in function implements an atomic compare and exchange operation.
10242 This compares the contents of @code{*@var{ptr}} with the contents of
10243 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10244 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10245 equal, the operation is a @emph{read} and the current contents of
10246 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
10247 for weak compare_exchange, which may fail spuriously, and false for
10248 the strong variation, which never fails spuriously.  Many targets
10249 only offer the strong variation and ignore the parameter.  When in doubt, use
10250 the strong variation.
10252 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10253 and memory is affected according to the
10254 memory order specified by @var{success_memorder}.  There are no
10255 restrictions on what memory order can be used here.
10257 Otherwise, false is returned and memory is affected according
10258 to @var{failure_memorder}. This memory order cannot be
10259 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10260 stronger order than that specified by @var{success_memorder}.
10262 @end deftypefn
10264 @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)
10265 This built-in function implements the generic version of
10266 @code{__atomic_compare_exchange}.  The function is virtually identical to
10267 @code{__atomic_compare_exchange_n}, except the desired value is also a
10268 pointer.
10270 @end deftypefn
10272 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10273 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10274 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10275 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10276 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10277 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10278 These built-in functions perform the operation suggested by the name, and
10279 return the result of the operation.  Operations on pointer arguments are
10280 performed as if the operands were of the @code{uintptr_t} type.  That is,
10281 they are not scaled by the size of the type to which the pointer points.
10283 @smallexample
10284 @{ *ptr @var{op}= val; return *ptr; @}
10285 @end smallexample
10287 The object pointed to by the first argument must be of integer or pointer
10288 type.  It must not be a boolean type.  All memory orders are valid.
10290 @end deftypefn
10292 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10293 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10294 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10295 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10296 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10297 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10298 These built-in functions perform the operation suggested by the name, and
10299 return the value that had previously been in @code{*@var{ptr}}.  Operations
10300 on pointer arguments are performed as if the operands were of
10301 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10302 the type to which the pointer points.
10304 @smallexample
10305 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10306 @end smallexample
10308 The same constraints on arguments apply as for the corresponding
10309 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10311 @end deftypefn
10313 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10315 This built-in function performs an atomic test-and-set operation on
10316 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10317 defined nonzero ``set'' value and the return value is @code{true} if and only
10318 if the previous contents were ``set''.
10319 It should be only used for operands of type @code{bool} or @code{char}. For 
10320 other types only part of the value may be set.
10322 All memory orders are valid.
10324 @end deftypefn
10326 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10328 This built-in function performs an atomic clear operation on
10329 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10330 It should be only used for operands of type @code{bool} or @code{char} and 
10331 in conjunction with @code{__atomic_test_and_set}.
10332 For other types it may only clear partially. If the type is not @code{bool}
10333 prefer using @code{__atomic_store}.
10335 The valid memory order variants are
10336 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10337 @code{__ATOMIC_RELEASE}.
10339 @end deftypefn
10341 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10343 This built-in function acts as a synchronization fence between threads
10344 based on the specified memory order.
10346 All memory orders are valid.
10348 @end deftypefn
10350 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10352 This built-in function acts as a synchronization fence between a thread
10353 and signal handlers based in the same thread.
10355 All memory orders are valid.
10357 @end deftypefn
10359 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10361 This built-in function returns true if objects of @var{size} bytes always
10362 generate lock-free atomic instructions for the target architecture.
10363 @var{size} must resolve to a compile-time constant and the result also
10364 resolves to a compile-time constant.
10366 @var{ptr} is an optional pointer to the object that may be used to determine
10367 alignment.  A value of 0 indicates typical alignment should be used.  The 
10368 compiler may also ignore this parameter.
10370 @smallexample
10371 if (__atomic_always_lock_free (sizeof (long long), 0))
10372 @end smallexample
10374 @end deftypefn
10376 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10378 This built-in function returns true if objects of @var{size} bytes always
10379 generate lock-free atomic instructions for the target architecture.  If
10380 the built-in function is not known to be lock-free, a call is made to a
10381 runtime routine named @code{__atomic_is_lock_free}.
10383 @var{ptr} is an optional pointer to the object that may be used to determine
10384 alignment.  A value of 0 indicates typical alignment should be used.  The 
10385 compiler may also ignore this parameter.
10386 @end deftypefn
10388 @node Integer Overflow Builtins
10389 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10391 The following built-in functions allow performing simple arithmetic operations
10392 together with checking whether the operations overflowed.
10394 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10395 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10396 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10397 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10398 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10399 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10400 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10402 These built-in functions promote the first two operands into infinite precision signed
10403 type and perform addition on those promoted operands.  The result is then
10404 cast to the type the third pointer argument points to and stored there.
10405 If the stored result is equal to the infinite precision result, the built-in
10406 functions return false, otherwise they return true.  As the addition is
10407 performed in infinite signed precision, these built-in functions have fully defined
10408 behavior for all argument values.
10410 The first built-in function allows arbitrary integral types for operands and
10411 the result type must be pointer to some integral type other than enumerated or
10412 boolean type, the rest of the built-in functions have explicit integer types.
10414 The compiler will attempt to use hardware instructions to implement
10415 these built-in functions where possible, like conditional jump on overflow
10416 after addition, conditional jump on carry etc.
10418 @end deftypefn
10420 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10421 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10422 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10423 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10424 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10425 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10426 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10428 These built-in functions are similar to the add overflow checking built-in
10429 functions above, except they perform subtraction, subtract the second argument
10430 from the first one, instead of addition.
10432 @end deftypefn
10434 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10435 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10436 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10437 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10438 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10439 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10440 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10442 These built-in functions are similar to the add overflow checking built-in
10443 functions above, except they perform multiplication, instead of addition.
10445 @end deftypefn
10447 The following built-in functions allow checking if simple arithmetic operation
10448 would overflow.
10450 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10451 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10452 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10454 These built-in functions are similar to @code{__builtin_add_overflow},
10455 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10456 they don't store the result of the arithmetic operation anywhere and the
10457 last argument is not a pointer, but some expression with integral type other
10458 than enumerated or boolean type.
10460 The built-in functions promote the first two operands into infinite precision signed type
10461 and perform addition on those promoted operands. The result is then
10462 cast to the type of the third argument.  If the cast result is equal to the infinite
10463 precision result, the built-in functions return false, otherwise they return true.
10464 The value of the third argument is ignored, just the side-effects in the third argument
10465 are evaluated, and no integral argument promotions are performed on the last argument.
10466 If the third argument is a bit-field, the type used for the result cast has the
10467 precision and signedness of the given bit-field, rather than precision and signedness
10468 of the underlying type.
10470 For example, the following macro can be used to portably check, at
10471 compile-time, whether or not adding two constant integers will overflow,
10472 and perform the addition only when it is known to be safe and not to trigger
10473 a @option{-Woverflow} warning.
10475 @smallexample
10476 #define INT_ADD_OVERFLOW_P(a, b) \
10477    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10479 enum @{
10480     A = INT_MAX, B = 3,
10481     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10482     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10484 @end smallexample
10486 The compiler will attempt to use hardware instructions to implement
10487 these built-in functions where possible, like conditional jump on overflow
10488 after addition, conditional jump on carry etc.
10490 @end deftypefn
10492 @node x86 specific memory model extensions for transactional memory
10493 @section x86-Specific Memory Model Extensions for Transactional Memory
10495 The x86 architecture supports additional memory ordering flags
10496 to mark critical sections for hardware lock elision. 
10497 These must be specified in addition to an existing memory order to
10498 atomic intrinsics.
10500 @table @code
10501 @item __ATOMIC_HLE_ACQUIRE
10502 Start lock elision on a lock variable.
10503 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10504 @item __ATOMIC_HLE_RELEASE
10505 End lock elision on a lock variable.
10506 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10507 @end table
10509 When a lock acquire fails, it is required for good performance to abort
10510 the transaction quickly. This can be done with a @code{_mm_pause}.
10512 @smallexample
10513 #include <immintrin.h> // For _mm_pause
10515 int lockvar;
10517 /* Acquire lock with lock elision */
10518 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10519     _mm_pause(); /* Abort failed transaction */
10521 /* Free lock with lock elision */
10522 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10523 @end smallexample
10525 @node Object Size Checking
10526 @section Object Size Checking Built-in Functions
10527 @findex __builtin_object_size
10528 @findex __builtin___memcpy_chk
10529 @findex __builtin___mempcpy_chk
10530 @findex __builtin___memmove_chk
10531 @findex __builtin___memset_chk
10532 @findex __builtin___strcpy_chk
10533 @findex __builtin___stpcpy_chk
10534 @findex __builtin___strncpy_chk
10535 @findex __builtin___strcat_chk
10536 @findex __builtin___strncat_chk
10537 @findex __builtin___sprintf_chk
10538 @findex __builtin___snprintf_chk
10539 @findex __builtin___vsprintf_chk
10540 @findex __builtin___vsnprintf_chk
10541 @findex __builtin___printf_chk
10542 @findex __builtin___vprintf_chk
10543 @findex __builtin___fprintf_chk
10544 @findex __builtin___vfprintf_chk
10546 GCC implements a limited buffer overflow protection mechanism that can
10547 prevent some buffer overflow attacks by determining the sizes of objects
10548 into which data is about to be written and preventing the writes when
10549 the size isn't sufficient.  The built-in functions described below yield
10550 the best results when used together and when optimization is enabled.
10551 For example, to detect object sizes across function boundaries or to
10552 follow pointer assignments through non-trivial control flow they rely
10553 on various optimization passes enabled with @option{-O2}.  However, to
10554 a limited extent, they can be used without optimization as well.
10556 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10557 is a built-in construct that returns a constant number of bytes from
10558 @var{ptr} to the end of the object @var{ptr} pointer points to
10559 (if known at compile time).  @code{__builtin_object_size} never evaluates
10560 its arguments for side-effects.  If there are any side-effects in them, it
10561 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10562 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10563 point to and all of them are known at compile time, the returned number
10564 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10565 0 and minimum if nonzero.  If it is not possible to determine which objects
10566 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10567 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10568 for @var{type} 2 or 3.
10570 @var{type} is an integer constant from 0 to 3.  If the least significant
10571 bit is clear, objects are whole variables, if it is set, a closest
10572 surrounding subobject is considered the object a pointer points to.
10573 The second bit determines if maximum or minimum of remaining bytes
10574 is computed.
10576 @smallexample
10577 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10578 char *p = &var.buf1[1], *q = &var.b;
10580 /* Here the object p points to is var.  */
10581 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10582 /* The subobject p points to is var.buf1.  */
10583 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10584 /* The object q points to is var.  */
10585 assert (__builtin_object_size (q, 0)
10586         == (char *) (&var + 1) - (char *) &var.b);
10587 /* The subobject q points to is var.b.  */
10588 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10589 @end smallexample
10590 @end deftypefn
10592 There are built-in functions added for many common string operation
10593 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10594 built-in is provided.  This built-in has an additional last argument,
10595 which is the number of bytes remaining in the object the @var{dest}
10596 argument points to or @code{(size_t) -1} if the size is not known.
10598 The built-in functions are optimized into the normal string functions
10599 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10600 it is known at compile time that the destination object will not
10601 be overflowed.  If the compiler can determine at compile time that the
10602 object will always be overflowed, it issues a warning.
10604 The intended use can be e.g.@:
10606 @smallexample
10607 #undef memcpy
10608 #define bos0(dest) __builtin_object_size (dest, 0)
10609 #define memcpy(dest, src, n) \
10610   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10612 char *volatile p;
10613 char buf[10];
10614 /* It is unknown what object p points to, so this is optimized
10615    into plain memcpy - no checking is possible.  */
10616 memcpy (p, "abcde", n);
10617 /* Destination is known and length too.  It is known at compile
10618    time there will be no overflow.  */
10619 memcpy (&buf[5], "abcde", 5);
10620 /* Destination is known, but the length is not known at compile time.
10621    This will result in __memcpy_chk call that can check for overflow
10622    at run time.  */
10623 memcpy (&buf[5], "abcde", n);
10624 /* Destination is known and it is known at compile time there will
10625    be overflow.  There will be a warning and __memcpy_chk call that
10626    will abort the program at run time.  */
10627 memcpy (&buf[6], "abcde", 5);
10628 @end smallexample
10630 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10631 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10632 @code{strcat} and @code{strncat}.
10634 There are also checking built-in functions for formatted output functions.
10635 @smallexample
10636 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10637 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10638                               const char *fmt, ...);
10639 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10640                               va_list ap);
10641 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10642                                const char *fmt, va_list ap);
10643 @end smallexample
10645 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10646 etc.@: functions and can contain implementation specific flags on what
10647 additional security measures the checking function might take, such as
10648 handling @code{%n} differently.
10650 The @var{os} argument is the object size @var{s} points to, like in the
10651 other built-in functions.  There is a small difference in the behavior
10652 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10653 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10654 the checking function is called with @var{os} argument set to
10655 @code{(size_t) -1}.
10657 In addition to this, there are checking built-in functions
10658 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10659 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10660 These have just one additional argument, @var{flag}, right before
10661 format string @var{fmt}.  If the compiler is able to optimize them to
10662 @code{fputc} etc.@: functions, it does, otherwise the checking function
10663 is called and the @var{flag} argument passed to it.
10665 @node Pointer Bounds Checker builtins
10666 @section Pointer Bounds Checker Built-in Functions
10667 @cindex Pointer Bounds Checker builtins
10668 @findex __builtin___bnd_set_ptr_bounds
10669 @findex __builtin___bnd_narrow_ptr_bounds
10670 @findex __builtin___bnd_copy_ptr_bounds
10671 @findex __builtin___bnd_init_ptr_bounds
10672 @findex __builtin___bnd_null_ptr_bounds
10673 @findex __builtin___bnd_store_ptr_bounds
10674 @findex __builtin___bnd_chk_ptr_lbounds
10675 @findex __builtin___bnd_chk_ptr_ubounds
10676 @findex __builtin___bnd_chk_ptr_bounds
10677 @findex __builtin___bnd_get_ptr_lbound
10678 @findex __builtin___bnd_get_ptr_ubound
10680 GCC provides a set of built-in functions to control Pointer Bounds Checker
10681 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
10682 even if you compile with Pointer Bounds Checker off
10683 (@option{-fno-check-pointer-bounds}).
10684 The behavior may differ in such case as documented below.
10686 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10688 This built-in function returns a new pointer with the value of @var{q}, and
10689 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
10690 Bounds Checker off, the built-in function just returns the first argument.
10692 @smallexample
10693 extern void *__wrap_malloc (size_t n)
10695   void *p = (void *)__real_malloc (n);
10696   if (!p) return __builtin___bnd_null_ptr_bounds (p);
10697   return __builtin___bnd_set_ptr_bounds (p, n);
10699 @end smallexample
10701 @end deftypefn
10703 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
10705 This built-in function returns a new pointer with the value of @var{p}
10706 and associates it with the narrowed bounds formed by the intersection
10707 of bounds associated with @var{q} and the bounds
10708 [@var{p}, @var{p} + @var{size} - 1].
10709 With Pointer Bounds Checker off, the built-in function just returns the first
10710 argument.
10712 @smallexample
10713 void init_objects (object *objs, size_t size)
10715   size_t i;
10716   /* Initialize objects one-by-one passing pointers with bounds of 
10717      an object, not the full array of objects.  */
10718   for (i = 0; i < size; i++)
10719     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10720                                                     sizeof(object)));
10722 @end smallexample
10724 @end deftypefn
10726 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10728 This built-in function returns a new pointer with the value of @var{q},
10729 and associates it with the bounds already associated with pointer @var{r}.
10730 With Pointer Bounds Checker off, the built-in function just returns the first
10731 argument.
10733 @smallexample
10734 /* Here is a way to get pointer to object's field but
10735    still with the full object's bounds.  */
10736 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
10737                                                   objptr);
10738 @end smallexample
10740 @end deftypefn
10742 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10744 This built-in function returns a new pointer with the value of @var{q}, and
10745 associates it with INIT (allowing full memory access) bounds. With Pointer
10746 Bounds Checker off, the built-in function just returns the first argument.
10748 @end deftypefn
10750 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10752 This built-in function returns a new pointer with the value of @var{q}, and
10753 associates it with NULL (allowing no memory access) bounds. With Pointer
10754 Bounds Checker off, the built-in function just returns the first argument.
10756 @end deftypefn
10758 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10760 This built-in function stores the bounds associated with pointer @var{ptr_val}
10761 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
10762 bounds from legacy code without touching the associated pointer's memory when
10763 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
10764 function call is ignored.
10766 @end deftypefn
10768 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10770 This built-in function checks if the pointer @var{q} is within the lower
10771 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10772 function call is ignored.
10774 @smallexample
10775 extern void *__wrap_memset (void *dst, int c, size_t len)
10777   if (len > 0)
10778     @{
10779       __builtin___bnd_chk_ptr_lbounds (dst);
10780       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10781       __real_memset (dst, c, len);
10782     @}
10783   return dst;
10785 @end smallexample
10787 @end deftypefn
10789 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10791 This built-in function checks if the pointer @var{q} is within the upper
10792 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10793 function call is ignored.
10795 @end deftypefn
10797 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10799 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10800 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
10801 off, the built-in function call is ignored.
10803 @smallexample
10804 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10806   if (n > 0)
10807     @{
10808       __bnd_chk_ptr_bounds (dst, n);
10809       __bnd_chk_ptr_bounds (src, n);
10810       __real_memcpy (dst, src, n);
10811     @}
10812   return dst;
10814 @end smallexample
10816 @end deftypefn
10818 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10820 This built-in function returns the lower bound associated
10821 with the pointer @var{q}, as a pointer value.  
10822 This is useful for debugging using @code{printf}.
10823 With Pointer Bounds Checker off, the built-in function returns 0.
10825 @smallexample
10826 void *lb = __builtin___bnd_get_ptr_lbound (q);
10827 void *ub = __builtin___bnd_get_ptr_ubound (q);
10828 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
10829 @end smallexample
10831 @end deftypefn
10833 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10835 This built-in function returns the upper bound (which is a pointer) associated
10836 with the pointer @var{q}.  With Pointer Bounds Checker off,
10837 the built-in function returns -1.
10839 @end deftypefn
10841 @node Cilk Plus Builtins
10842 @section Cilk Plus C/C++ Language Extension Built-in Functions
10844 GCC provides support for the following built-in reduction functions if Cilk Plus
10845 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10847 @itemize @bullet
10848 @item @code{__sec_implicit_index}
10849 @item @code{__sec_reduce}
10850 @item @code{__sec_reduce_add}
10851 @item @code{__sec_reduce_all_nonzero}
10852 @item @code{__sec_reduce_all_zero}
10853 @item @code{__sec_reduce_any_nonzero}
10854 @item @code{__sec_reduce_any_zero}
10855 @item @code{__sec_reduce_max}
10856 @item @code{__sec_reduce_min}
10857 @item @code{__sec_reduce_max_ind}
10858 @item @code{__sec_reduce_min_ind}
10859 @item @code{__sec_reduce_mul}
10860 @item @code{__sec_reduce_mutating}
10861 @end itemize
10863 Further details and examples about these built-in functions are described 
10864 in the Cilk Plus language manual which can be found at 
10865 @uref{https://www.cilkplus.org}.
10867 @node Other Builtins
10868 @section Other Built-in Functions Provided by GCC
10869 @cindex built-in functions
10870 @findex __builtin_alloca
10871 @findex __builtin_alloca_with_align
10872 @findex __builtin_alloca_with_align_and_max
10873 @findex __builtin_call_with_static_chain
10874 @findex __builtin_fpclassify
10875 @findex __builtin_isfinite
10876 @findex __builtin_isnormal
10877 @findex __builtin_isgreater
10878 @findex __builtin_isgreaterequal
10879 @findex __builtin_isinf_sign
10880 @findex __builtin_isless
10881 @findex __builtin_islessequal
10882 @findex __builtin_islessgreater
10883 @findex __builtin_isunordered
10884 @findex __builtin_powi
10885 @findex __builtin_powif
10886 @findex __builtin_powil
10887 @findex _Exit
10888 @findex _exit
10889 @findex abort
10890 @findex abs
10891 @findex acos
10892 @findex acosf
10893 @findex acosh
10894 @findex acoshf
10895 @findex acoshl
10896 @findex acosl
10897 @findex alloca
10898 @findex asin
10899 @findex asinf
10900 @findex asinh
10901 @findex asinhf
10902 @findex asinhl
10903 @findex asinl
10904 @findex atan
10905 @findex atan2
10906 @findex atan2f
10907 @findex atan2l
10908 @findex atanf
10909 @findex atanh
10910 @findex atanhf
10911 @findex atanhl
10912 @findex atanl
10913 @findex bcmp
10914 @findex bzero
10915 @findex cabs
10916 @findex cabsf
10917 @findex cabsl
10918 @findex cacos
10919 @findex cacosf
10920 @findex cacosh
10921 @findex cacoshf
10922 @findex cacoshl
10923 @findex cacosl
10924 @findex calloc
10925 @findex carg
10926 @findex cargf
10927 @findex cargl
10928 @findex casin
10929 @findex casinf
10930 @findex casinh
10931 @findex casinhf
10932 @findex casinhl
10933 @findex casinl
10934 @findex catan
10935 @findex catanf
10936 @findex catanh
10937 @findex catanhf
10938 @findex catanhl
10939 @findex catanl
10940 @findex cbrt
10941 @findex cbrtf
10942 @findex cbrtl
10943 @findex ccos
10944 @findex ccosf
10945 @findex ccosh
10946 @findex ccoshf
10947 @findex ccoshl
10948 @findex ccosl
10949 @findex ceil
10950 @findex ceilf
10951 @findex ceill
10952 @findex cexp
10953 @findex cexpf
10954 @findex cexpl
10955 @findex cimag
10956 @findex cimagf
10957 @findex cimagl
10958 @findex clog
10959 @findex clogf
10960 @findex clogl
10961 @findex clog10
10962 @findex clog10f
10963 @findex clog10l
10964 @findex conj
10965 @findex conjf
10966 @findex conjl
10967 @findex copysign
10968 @findex copysignf
10969 @findex copysignl
10970 @findex cos
10971 @findex cosf
10972 @findex cosh
10973 @findex coshf
10974 @findex coshl
10975 @findex cosl
10976 @findex cpow
10977 @findex cpowf
10978 @findex cpowl
10979 @findex cproj
10980 @findex cprojf
10981 @findex cprojl
10982 @findex creal
10983 @findex crealf
10984 @findex creall
10985 @findex csin
10986 @findex csinf
10987 @findex csinh
10988 @findex csinhf
10989 @findex csinhl
10990 @findex csinl
10991 @findex csqrt
10992 @findex csqrtf
10993 @findex csqrtl
10994 @findex ctan
10995 @findex ctanf
10996 @findex ctanh
10997 @findex ctanhf
10998 @findex ctanhl
10999 @findex ctanl
11000 @findex dcgettext
11001 @findex dgettext
11002 @findex drem
11003 @findex dremf
11004 @findex dreml
11005 @findex erf
11006 @findex erfc
11007 @findex erfcf
11008 @findex erfcl
11009 @findex erff
11010 @findex erfl
11011 @findex exit
11012 @findex exp
11013 @findex exp10
11014 @findex exp10f
11015 @findex exp10l
11016 @findex exp2
11017 @findex exp2f
11018 @findex exp2l
11019 @findex expf
11020 @findex expl
11021 @findex expm1
11022 @findex expm1f
11023 @findex expm1l
11024 @findex fabs
11025 @findex fabsf
11026 @findex fabsl
11027 @findex fdim
11028 @findex fdimf
11029 @findex fdiml
11030 @findex ffs
11031 @findex floor
11032 @findex floorf
11033 @findex floorl
11034 @findex fma
11035 @findex fmaf
11036 @findex fmal
11037 @findex fmax
11038 @findex fmaxf
11039 @findex fmaxl
11040 @findex fmin
11041 @findex fminf
11042 @findex fminl
11043 @findex fmod
11044 @findex fmodf
11045 @findex fmodl
11046 @findex fprintf
11047 @findex fprintf_unlocked
11048 @findex fputs
11049 @findex fputs_unlocked
11050 @findex frexp
11051 @findex frexpf
11052 @findex frexpl
11053 @findex fscanf
11054 @findex gamma
11055 @findex gammaf
11056 @findex gammal
11057 @findex gamma_r
11058 @findex gammaf_r
11059 @findex gammal_r
11060 @findex gettext
11061 @findex hypot
11062 @findex hypotf
11063 @findex hypotl
11064 @findex ilogb
11065 @findex ilogbf
11066 @findex ilogbl
11067 @findex imaxabs
11068 @findex index
11069 @findex isalnum
11070 @findex isalpha
11071 @findex isascii
11072 @findex isblank
11073 @findex iscntrl
11074 @findex isdigit
11075 @findex isgraph
11076 @findex islower
11077 @findex isprint
11078 @findex ispunct
11079 @findex isspace
11080 @findex isupper
11081 @findex iswalnum
11082 @findex iswalpha
11083 @findex iswblank
11084 @findex iswcntrl
11085 @findex iswdigit
11086 @findex iswgraph
11087 @findex iswlower
11088 @findex iswprint
11089 @findex iswpunct
11090 @findex iswspace
11091 @findex iswupper
11092 @findex iswxdigit
11093 @findex isxdigit
11094 @findex j0
11095 @findex j0f
11096 @findex j0l
11097 @findex j1
11098 @findex j1f
11099 @findex j1l
11100 @findex jn
11101 @findex jnf
11102 @findex jnl
11103 @findex labs
11104 @findex ldexp
11105 @findex ldexpf
11106 @findex ldexpl
11107 @findex lgamma
11108 @findex lgammaf
11109 @findex lgammal
11110 @findex lgamma_r
11111 @findex lgammaf_r
11112 @findex lgammal_r
11113 @findex llabs
11114 @findex llrint
11115 @findex llrintf
11116 @findex llrintl
11117 @findex llround
11118 @findex llroundf
11119 @findex llroundl
11120 @findex log
11121 @findex log10
11122 @findex log10f
11123 @findex log10l
11124 @findex log1p
11125 @findex log1pf
11126 @findex log1pl
11127 @findex log2
11128 @findex log2f
11129 @findex log2l
11130 @findex logb
11131 @findex logbf
11132 @findex logbl
11133 @findex logf
11134 @findex logl
11135 @findex lrint
11136 @findex lrintf
11137 @findex lrintl
11138 @findex lround
11139 @findex lroundf
11140 @findex lroundl
11141 @findex malloc
11142 @findex memchr
11143 @findex memcmp
11144 @findex memcpy
11145 @findex mempcpy
11146 @findex memset
11147 @findex modf
11148 @findex modff
11149 @findex modfl
11150 @findex nearbyint
11151 @findex nearbyintf
11152 @findex nearbyintl
11153 @findex nextafter
11154 @findex nextafterf
11155 @findex nextafterl
11156 @findex nexttoward
11157 @findex nexttowardf
11158 @findex nexttowardl
11159 @findex pow
11160 @findex pow10
11161 @findex pow10f
11162 @findex pow10l
11163 @findex powf
11164 @findex powl
11165 @findex printf
11166 @findex printf_unlocked
11167 @findex putchar
11168 @findex puts
11169 @findex remainder
11170 @findex remainderf
11171 @findex remainderl
11172 @findex remquo
11173 @findex remquof
11174 @findex remquol
11175 @findex rindex
11176 @findex rint
11177 @findex rintf
11178 @findex rintl
11179 @findex round
11180 @findex roundf
11181 @findex roundl
11182 @findex scalb
11183 @findex scalbf
11184 @findex scalbl
11185 @findex scalbln
11186 @findex scalblnf
11187 @findex scalblnf
11188 @findex scalbn
11189 @findex scalbnf
11190 @findex scanfnl
11191 @findex signbit
11192 @findex signbitf
11193 @findex signbitl
11194 @findex signbitd32
11195 @findex signbitd64
11196 @findex signbitd128
11197 @findex significand
11198 @findex significandf
11199 @findex significandl
11200 @findex sin
11201 @findex sincos
11202 @findex sincosf
11203 @findex sincosl
11204 @findex sinf
11205 @findex sinh
11206 @findex sinhf
11207 @findex sinhl
11208 @findex sinl
11209 @findex snprintf
11210 @findex sprintf
11211 @findex sqrt
11212 @findex sqrtf
11213 @findex sqrtl
11214 @findex sscanf
11215 @findex stpcpy
11216 @findex stpncpy
11217 @findex strcasecmp
11218 @findex strcat
11219 @findex strchr
11220 @findex strcmp
11221 @findex strcpy
11222 @findex strcspn
11223 @findex strdup
11224 @findex strfmon
11225 @findex strftime
11226 @findex strlen
11227 @findex strncasecmp
11228 @findex strncat
11229 @findex strncmp
11230 @findex strncpy
11231 @findex strndup
11232 @findex strpbrk
11233 @findex strrchr
11234 @findex strspn
11235 @findex strstr
11236 @findex tan
11237 @findex tanf
11238 @findex tanh
11239 @findex tanhf
11240 @findex tanhl
11241 @findex tanl
11242 @findex tgamma
11243 @findex tgammaf
11244 @findex tgammal
11245 @findex toascii
11246 @findex tolower
11247 @findex toupper
11248 @findex towlower
11249 @findex towupper
11250 @findex trunc
11251 @findex truncf
11252 @findex truncl
11253 @findex vfprintf
11254 @findex vfscanf
11255 @findex vprintf
11256 @findex vscanf
11257 @findex vsnprintf
11258 @findex vsprintf
11259 @findex vsscanf
11260 @findex y0
11261 @findex y0f
11262 @findex y0l
11263 @findex y1
11264 @findex y1f
11265 @findex y1l
11266 @findex yn
11267 @findex ynf
11268 @findex ynl
11270 GCC provides a large number of built-in functions other than the ones
11271 mentioned above.  Some of these are for internal use in the processing
11272 of exceptions or variable-length argument lists and are not
11273 documented here because they may change from time to time; we do not
11274 recommend general use of these functions.
11276 The remaining functions are provided for optimization purposes.
11278 With the exception of built-ins that have library equivalents such as
11279 the standard C library functions discussed below, or that expand to
11280 library calls, GCC built-in functions are always expanded inline and
11281 thus do not have corresponding entry points and their address cannot
11282 be obtained.  Attempting to use them in an expression other than
11283 a function call results in a compile-time error.
11285 @opindex fno-builtin
11286 GCC includes built-in versions of many of the functions in the standard
11287 C library.  These functions come in two forms: one whose names start with
11288 the @code{__builtin_} prefix, and the other without.  Both forms have the
11289 same type (including prototype), the same address (when their address is
11290 taken), and the same meaning as the C library functions even if you specify
11291 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11292 functions are only optimized in certain cases; if they are not optimized in
11293 a particular case, a call to the library function is emitted.
11295 @opindex ansi
11296 @opindex std
11297 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11298 @option{-std=c99} or @option{-std=c11}), the functions
11299 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11300 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11301 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11302 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11303 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11304 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11305 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11306 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11307 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11308 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11309 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11310 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11311 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11312 @code{significandl}, @code{significand}, @code{sincosf},
11313 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11314 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11315 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
11316 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11317 @code{yn}
11318 may be handled as built-in functions.
11319 All these functions have corresponding versions
11320 prefixed with @code{__builtin_}, which may be used even in strict C90
11321 mode.
11323 The ISO C99 functions
11324 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11325 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11326 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11327 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11328 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11329 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11330 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11331 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11332 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11333 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11334 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11335 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11336 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11337 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11338 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11339 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11340 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11341 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11342 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11343 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11344 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11345 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11346 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11347 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11348 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11349 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11350 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11351 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11352 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11353 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11354 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11355 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11356 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11357 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11358 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11359 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11360 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11361 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11362 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11363 are handled as built-in functions
11364 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11366 There are also built-in versions of the ISO C99 functions
11367 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11368 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11369 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11370 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11371 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11372 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11373 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11374 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11375 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11376 that are recognized in any mode since ISO C90 reserves these names for
11377 the purpose to which ISO C99 puts them.  All these functions have
11378 corresponding versions prefixed with @code{__builtin_}.
11380 There are also built-in functions @code{__builtin_fabsf@var{n}},
11381 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11382 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11383 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11384 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11385 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11387 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11388 @code{clog10l} which names are reserved by ISO C99 for future use.
11389 All these functions have versions prefixed with @code{__builtin_}.
11391 The ISO C94 functions
11392 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11393 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11394 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11395 @code{towupper}
11396 are handled as built-in functions
11397 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11399 The ISO C90 functions
11400 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11401 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11402 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11403 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11404 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11405 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11406 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11407 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11408 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11409 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11410 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11411 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11412 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11413 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11414 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11415 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11416 are all recognized as built-in functions unless
11417 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11418 is specified for an individual function).  All of these functions have
11419 corresponding versions prefixed with @code{__builtin_}.
11421 GCC provides built-in versions of the ISO C99 floating-point comparison
11422 macros that avoid raising exceptions for unordered operands.  They have
11423 the same names as the standard macros ( @code{isgreater},
11424 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11425 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11426 prefixed.  We intend for a library implementor to be able to simply
11427 @code{#define} each standard macro to its built-in equivalent.
11428 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11429 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11430 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11431 built-in functions appear both with and without the @code{__builtin_} prefix.
11433 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11434 The @code{__builtin_alloca} function must be called at block scope.
11435 The function allocates an object @var{size} bytes large on the stack
11436 of the calling function.  The object is aligned on the default stack
11437 alignment boundary for the target determined by the
11438 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11439 function returns a pointer to the first byte of the allocated object.
11440 The lifetime of the allocated object ends just before the calling
11441 function returns to its caller.   This is so even when
11442 @code{__builtin_alloca} is called within a nested block.
11444 For example, the following function allocates eight objects of @code{n}
11445 bytes each on the stack, storing a pointer to each in consecutive elements
11446 of the array @code{a}.  It then passes the array to function @code{g}
11447 which can safely use the storage pointed to by each of the array elements.
11449 @smallexample
11450 void f (unsigned n)
11452   void *a [8];
11453   for (int i = 0; i != 8; ++i)
11454     a [i] = __builtin_alloca (n);
11456   g (a, n);   // @r{safe}
11458 @end smallexample
11460 Since the @code{__builtin_alloca} function doesn't validate its argument
11461 it is the responsibility of its caller to make sure the argument doesn't
11462 cause it to exceed the stack size limit.
11463 The @code{__builtin_alloca} function is provided to make it possible to
11464 allocate on the stack arrays of bytes with an upper bound that may be
11465 computed at run time.  Since C99 Variable Length Arrays offer
11466 similar functionality under a portable, more convenient, and safer
11467 interface they are recommended instead, in both C99 and C++ programs
11468 where GCC provides them as an extension.
11469 @xref{Variable Length}, for details.
11471 @end deftypefn
11473 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11474 The @code{__builtin_alloca_with_align} function must be called at block
11475 scope.  The function allocates an object @var{size} bytes large on
11476 the stack of the calling function.  The allocated object is aligned on
11477 the boundary specified by the argument @var{alignment} whose unit is given
11478 in bits (not bytes).  The @var{size} argument must be positive and not
11479 exceed the stack size limit.  The @var{alignment} argument must be a constant
11480 integer expression that evaluates to a power of 2 greater than or equal to
11481 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11482 with other values are rejected with an error indicating the valid bounds.
11483 The function returns a pointer to the first byte of the allocated object.
11484 The lifetime of the allocated object ends at the end of the block in which
11485 the function was called.  The allocated storage is released no later than
11486 just before the calling function returns to its caller, but may be released
11487 at the end of the block in which the function was called.
11489 For example, in the following function the call to @code{g} is unsafe
11490 because when @code{overalign} is non-zero, the space allocated by
11491 @code{__builtin_alloca_with_align} may have been released at the end
11492 of the @code{if} statement in which it was called.
11494 @smallexample
11495 void f (unsigned n, bool overalign)
11497   void *p;
11498   if (overalign)
11499     p = __builtin_alloca_with_align (n, 64 /* bits */);
11500   else
11501     p = __builtin_alloc (n);
11503   g (p, n);   // @r{unsafe}
11505 @end smallexample
11507 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11508 @var{size} argument it is the responsibility of its caller to make sure
11509 the argument doesn't cause it to exceed the stack size limit.
11510 The @code{__builtin_alloca_with_align} function is provided to make
11511 it possible to allocate on the stack overaligned arrays of bytes with
11512 an upper bound that may be computed at run time.  Since C99
11513 Variable Length Arrays offer the same functionality under
11514 a portable, more convenient, and safer interface they are recommended
11515 instead, in both C99 and C++ programs where GCC provides them as
11516 an extension.  @xref{Variable Length}, for details.
11518 @end deftypefn
11520 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11521 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11522 specifying an upper bound for @var{size} in case its value cannot be computed
11523 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11524 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11525 expression, it has no effect on code generation and no attempt is made to
11526 check its compatibility with @var{size}.
11528 @end deftypefn
11530 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11532 You can use the built-in function @code{__builtin_types_compatible_p} to
11533 determine whether two types are the same.
11535 This built-in function returns 1 if the unqualified versions of the
11536 types @var{type1} and @var{type2} (which are types, not expressions) are
11537 compatible, 0 otherwise.  The result of this built-in function can be
11538 used in integer constant expressions.
11540 This built-in function ignores top level qualifiers (e.g., @code{const},
11541 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11542 int}.
11544 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11545 hand, @code{int} and @code{char *} are not compatible, even if the size
11546 of their types, on the particular architecture are the same.  Also, the
11547 amount of pointer indirection is taken into account when determining
11548 similarity.  Consequently, @code{short *} is not similar to
11549 @code{short **}.  Furthermore, two types that are typedefed are
11550 considered compatible if their underlying types are compatible.
11552 An @code{enum} type is not considered to be compatible with another
11553 @code{enum} type even if both are compatible with the same integer
11554 type; this is what the C standard specifies.
11555 For example, @code{enum @{foo, bar@}} is not similar to
11556 @code{enum @{hot, dog@}}.
11558 You typically use this function in code whose execution varies
11559 depending on the arguments' types.  For example:
11561 @smallexample
11562 #define foo(x)                                                  \
11563   (@{                                                           \
11564     typeof (x) tmp = (x);                                       \
11565     if (__builtin_types_compatible_p (typeof (x), long double)) \
11566       tmp = foo_long_double (tmp);                              \
11567     else if (__builtin_types_compatible_p (typeof (x), double)) \
11568       tmp = foo_double (tmp);                                   \
11569     else if (__builtin_types_compatible_p (typeof (x), float))  \
11570       tmp = foo_float (tmp);                                    \
11571     else                                                        \
11572       abort ();                                                 \
11573     tmp;                                                        \
11574   @})
11575 @end smallexample
11577 @emph{Note:} This construct is only available for C@.
11579 @end deftypefn
11581 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11583 The @var{call_exp} expression must be a function call, and the
11584 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11585 is passed to the function call in the target's static chain location.
11586 The result of builtin is the result of the function call.
11588 @emph{Note:} This builtin is only available for C@.
11589 This builtin can be used to call Go closures from C.
11591 @end deftypefn
11593 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11595 You can use the built-in function @code{__builtin_choose_expr} to
11596 evaluate code depending on the value of a constant expression.  This
11597 built-in function returns @var{exp1} if @var{const_exp}, which is an
11598 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11600 This built-in function is analogous to the @samp{? :} operator in C,
11601 except that the expression returned has its type unaltered by promotion
11602 rules.  Also, the built-in function does not evaluate the expression
11603 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11604 @var{exp2} is not evaluated even if it has side-effects.
11606 This built-in function can return an lvalue if the chosen argument is an
11607 lvalue.
11609 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11610 type.  Similarly, if @var{exp2} is returned, its return type is the same
11611 as @var{exp2}.
11613 Example:
11615 @smallexample
11616 #define foo(x)                                                    \
11617   __builtin_choose_expr (                                         \
11618     __builtin_types_compatible_p (typeof (x), double),            \
11619     foo_double (x),                                               \
11620     __builtin_choose_expr (                                       \
11621       __builtin_types_compatible_p (typeof (x), float),           \
11622       foo_float (x),                                              \
11623       /* @r{The void expression results in a compile-time error}  \
11624          @r{when assigning the result to something.}  */          \
11625       (void)0))
11626 @end smallexample
11628 @emph{Note:} This construct is only available for C@.  Furthermore, the
11629 unused expression (@var{exp1} or @var{exp2} depending on the value of
11630 @var{const_exp}) may still generate syntax errors.  This may change in
11631 future revisions.
11633 @end deftypefn
11635 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11637 The built-in function @code{__builtin_complex} is provided for use in
11638 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11639 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11640 real binary floating-point type, and the result has the corresponding
11641 complex type with real and imaginary parts @var{real} and @var{imag}.
11642 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11643 infinities, NaNs and negative zeros are involved.
11645 @end deftypefn
11647 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11648 You can use the built-in function @code{__builtin_constant_p} to
11649 determine if a value is known to be constant at compile time and hence
11650 that GCC can perform constant-folding on expressions involving that
11651 value.  The argument of the function is the value to test.  The function
11652 returns the integer 1 if the argument is known to be a compile-time
11653 constant and 0 if it is not known to be a compile-time constant.  A
11654 return of 0 does not indicate that the value is @emph{not} a constant,
11655 but merely that GCC cannot prove it is a constant with the specified
11656 value of the @option{-O} option.
11658 You typically use this function in an embedded application where
11659 memory is a critical resource.  If you have some complex calculation,
11660 you may want it to be folded if it involves constants, but need to call
11661 a function if it does not.  For example:
11663 @smallexample
11664 #define Scale_Value(X)      \
11665   (__builtin_constant_p (X) \
11666   ? ((X) * SCALE + OFFSET) : Scale (X))
11667 @end smallexample
11669 You may use this built-in function in either a macro or an inline
11670 function.  However, if you use it in an inlined function and pass an
11671 argument of the function as the argument to the built-in, GCC 
11672 never returns 1 when you call the inline function with a string constant
11673 or compound literal (@pxref{Compound Literals}) and does not return 1
11674 when you pass a constant numeric value to the inline function unless you
11675 specify the @option{-O} option.
11677 You may also use @code{__builtin_constant_p} in initializers for static
11678 data.  For instance, you can write
11680 @smallexample
11681 static const int table[] = @{
11682    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11683    /* @r{@dots{}} */
11685 @end smallexample
11687 @noindent
11688 This is an acceptable initializer even if @var{EXPRESSION} is not a
11689 constant expression, including the case where
11690 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11691 folded to a constant but @var{EXPRESSION} contains operands that are
11692 not otherwise permitted in a static initializer (for example,
11693 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11694 built-in in this case, because it has no opportunity to perform
11695 optimization.
11696 @end deftypefn
11698 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11699 @opindex fprofile-arcs
11700 You may use @code{__builtin_expect} to provide the compiler with
11701 branch prediction information.  In general, you should prefer to
11702 use actual profile feedback for this (@option{-fprofile-arcs}), as
11703 programmers are notoriously bad at predicting how their programs
11704 actually perform.  However, there are applications in which this
11705 data is hard to collect.
11707 The return value is the value of @var{exp}, which should be an integral
11708 expression.  The semantics of the built-in are that it is expected that
11709 @var{exp} == @var{c}.  For example:
11711 @smallexample
11712 if (__builtin_expect (x, 0))
11713   foo ();
11714 @end smallexample
11716 @noindent
11717 indicates that we do not expect to call @code{foo}, since
11718 we expect @code{x} to be zero.  Since you are limited to integral
11719 expressions for @var{exp}, you should use constructions such as
11721 @smallexample
11722 if (__builtin_expect (ptr != NULL, 1))
11723   foo (*ptr);
11724 @end smallexample
11726 @noindent
11727 when testing pointer or floating-point values.
11728 @end deftypefn
11730 @deftypefn {Built-in Function} void __builtin_trap (void)
11731 This function causes the program to exit abnormally.  GCC implements
11732 this function by using a target-dependent mechanism (such as
11733 intentionally executing an illegal instruction) or by calling
11734 @code{abort}.  The mechanism used may vary from release to release so
11735 you should not rely on any particular implementation.
11736 @end deftypefn
11738 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11739 If control flow reaches the point of the @code{__builtin_unreachable},
11740 the program is undefined.  It is useful in situations where the
11741 compiler cannot deduce the unreachability of the code.
11743 One such case is immediately following an @code{asm} statement that
11744 either never terminates, or one that transfers control elsewhere
11745 and never returns.  In this example, without the
11746 @code{__builtin_unreachable}, GCC issues a warning that control
11747 reaches the end of a non-void function.  It also generates code
11748 to return after the @code{asm}.
11750 @smallexample
11751 int f (int c, int v)
11753   if (c)
11754     @{
11755       return v;
11756     @}
11757   else
11758     @{
11759       asm("jmp error_handler");
11760       __builtin_unreachable ();
11761     @}
11763 @end smallexample
11765 @noindent
11766 Because the @code{asm} statement unconditionally transfers control out
11767 of the function, control never reaches the end of the function
11768 body.  The @code{__builtin_unreachable} is in fact unreachable and
11769 communicates this fact to the compiler.
11771 Another use for @code{__builtin_unreachable} is following a call a
11772 function that never returns but that is not declared
11773 @code{__attribute__((noreturn))}, as in this example:
11775 @smallexample
11776 void function_that_never_returns (void);
11778 int g (int c)
11780   if (c)
11781     @{
11782       return 1;
11783     @}
11784   else
11785     @{
11786       function_that_never_returns ();
11787       __builtin_unreachable ();
11788     @}
11790 @end smallexample
11792 @end deftypefn
11794 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11795 This function returns its first argument, and allows the compiler
11796 to assume that the returned pointer is at least @var{align} bytes
11797 aligned.  This built-in can have either two or three arguments,
11798 if it has three, the third argument should have integer type, and
11799 if it is nonzero means misalignment offset.  For example:
11801 @smallexample
11802 void *x = __builtin_assume_aligned (arg, 16);
11803 @end smallexample
11805 @noindent
11806 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11807 16-byte aligned, while:
11809 @smallexample
11810 void *x = __builtin_assume_aligned (arg, 32, 8);
11811 @end smallexample
11813 @noindent
11814 means that the compiler can assume for @code{x}, set to @code{arg}, that
11815 @code{(char *) x - 8} is 32-byte aligned.
11816 @end deftypefn
11818 @deftypefn {Built-in Function} int __builtin_LINE ()
11819 This function is the equivalent of the preprocessor @code{__LINE__}
11820 macro and returns a constant integer expression that evaluates to
11821 the line number of the invocation of the built-in.  When used as a C++
11822 default argument for a function @var{F}, it returns the line number
11823 of the call to @var{F}.
11824 @end deftypefn
11826 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11827 This function is the equivalent of the @code{__FUNCTION__} symbol
11828 and returns an address constant pointing to the name of the function
11829 from which the built-in was invoked, or the empty string if
11830 the invocation is not at function scope.  When used as a C++ default
11831 argument for a function @var{F}, it returns the name of @var{F}'s
11832 caller or the empty string if the call was not made at function
11833 scope.
11834 @end deftypefn
11836 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11837 This function is the equivalent of the preprocessor @code{__FILE__}
11838 macro and returns an address constant pointing to the file name
11839 containing the invocation of the built-in, or the empty string if
11840 the invocation is not at function scope.  When used as a C++ default
11841 argument for a function @var{F}, it returns the file name of the call
11842 to @var{F} or the empty string if the call was not made at function
11843 scope.
11845 For example, in the following, each call to function @code{foo} will
11846 print a line similar to @code{"file.c:123: foo: message"} with the name
11847 of the file and the line number of the @code{printf} call, the name of
11848 the function @code{foo}, followed by the word @code{message}.
11850 @smallexample
11851 const char*
11852 function (const char *func = __builtin_FUNCTION ())
11854   return func;
11857 void foo (void)
11859   printf ("%s:%i: %s: message\n", file (), line (), function ());
11861 @end smallexample
11863 @end deftypefn
11865 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11866 This function is used to flush the processor's instruction cache for
11867 the region of memory between @var{begin} inclusive and @var{end}
11868 exclusive.  Some targets require that the instruction cache be
11869 flushed, after modifying memory containing code, in order to obtain
11870 deterministic behavior.
11872 If the target does not require instruction cache flushes,
11873 @code{__builtin___clear_cache} has no effect.  Otherwise either
11874 instructions are emitted in-line to clear the instruction cache or a
11875 call to the @code{__clear_cache} function in libgcc is made.
11876 @end deftypefn
11878 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11879 This function is used to minimize cache-miss latency by moving data into
11880 a cache before it is accessed.
11881 You can insert calls to @code{__builtin_prefetch} into code for which
11882 you know addresses of data in memory that is likely to be accessed soon.
11883 If the target supports them, data prefetch instructions are generated.
11884 If the prefetch is done early enough before the access then the data will
11885 be in the cache by the time it is accessed.
11887 The value of @var{addr} is the address of the memory to prefetch.
11888 There are two optional arguments, @var{rw} and @var{locality}.
11889 The value of @var{rw} is a compile-time constant one or zero; one
11890 means that the prefetch is preparing for a write to the memory address
11891 and zero, the default, means that the prefetch is preparing for a read.
11892 The value @var{locality} must be a compile-time constant integer between
11893 zero and three.  A value of zero means that the data has no temporal
11894 locality, so it need not be left in the cache after the access.  A value
11895 of three means that the data has a high degree of temporal locality and
11896 should be left in all levels of cache possible.  Values of one and two
11897 mean, respectively, a low or moderate degree of temporal locality.  The
11898 default is three.
11900 @smallexample
11901 for (i = 0; i < n; i++)
11902   @{
11903     a[i] = a[i] + b[i];
11904     __builtin_prefetch (&a[i+j], 1, 1);
11905     __builtin_prefetch (&b[i+j], 0, 1);
11906     /* @r{@dots{}} */
11907   @}
11908 @end smallexample
11910 Data prefetch does not generate faults if @var{addr} is invalid, but
11911 the address expression itself must be valid.  For example, a prefetch
11912 of @code{p->next} does not fault if @code{p->next} is not a valid
11913 address, but evaluation faults if @code{p} is not a valid address.
11915 If the target does not support data prefetch, the address expression
11916 is evaluated if it includes side effects but no other code is generated
11917 and GCC does not issue a warning.
11918 @end deftypefn
11920 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11921 Returns a positive infinity, if supported by the floating-point format,
11922 else @code{DBL_MAX}.  This function is suitable for implementing the
11923 ISO C macro @code{HUGE_VAL}.
11924 @end deftypefn
11926 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11927 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11928 @end deftypefn
11930 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11931 Similar to @code{__builtin_huge_val}, except the return
11932 type is @code{long double}.
11933 @end deftypefn
11935 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11936 Similar to @code{__builtin_huge_val}, except the return type is
11937 @code{_Float@var{n}}.
11938 @end deftypefn
11940 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11941 Similar to @code{__builtin_huge_val}, except the return type is
11942 @code{_Float@var{n}x}.
11943 @end deftypefn
11945 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11946 This built-in implements the C99 fpclassify functionality.  The first
11947 five int arguments should be the target library's notion of the
11948 possible FP classes and are used for return values.  They must be
11949 constant values and they must appear in this order: @code{FP_NAN},
11950 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11951 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
11952 to classify.  GCC treats the last argument as type-generic, which
11953 means it does not do default promotion from float to double.
11954 @end deftypefn
11956 @deftypefn {Built-in Function} double __builtin_inf (void)
11957 Similar to @code{__builtin_huge_val}, except a warning is generated
11958 if the target floating-point format does not support infinities.
11959 @end deftypefn
11961 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11962 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11963 @end deftypefn
11965 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11966 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11967 @end deftypefn
11969 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11970 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11971 @end deftypefn
11973 @deftypefn {Built-in Function} float __builtin_inff (void)
11974 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11975 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11976 @end deftypefn
11978 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11979 Similar to @code{__builtin_inf}, except the return
11980 type is @code{long double}.
11981 @end deftypefn
11983 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11984 Similar to @code{__builtin_inf}, except the return
11985 type is @code{_Float@var{n}}.
11986 @end deftypefn
11988 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11989 Similar to @code{__builtin_inf}, except the return
11990 type is @code{_Float@var{n}x}.
11991 @end deftypefn
11993 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11994 Similar to @code{isinf}, except the return value is -1 for
11995 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11996 Note while the parameter list is an
11997 ellipsis, this function only accepts exactly one floating-point
11998 argument.  GCC treats this parameter as type-generic, which means it
11999 does not do default promotion from float to double.
12000 @end deftypefn
12002 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12003 This is an implementation of the ISO C99 function @code{nan}.
12005 Since ISO C99 defines this function in terms of @code{strtod}, which we
12006 do not implement, a description of the parsing is in order.  The string
12007 is parsed as by @code{strtol}; that is, the base is recognized by
12008 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12009 in the significand such that the least significant bit of the number
12010 is at the least significant bit of the significand.  The number is
12011 truncated to fit the significand field provided.  The significand is
12012 forced to be a quiet NaN@.
12014 This function, if given a string literal all of which would have been
12015 consumed by @code{strtol}, is evaluated early enough that it is considered a
12016 compile-time constant.
12017 @end deftypefn
12019 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12020 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12021 @end deftypefn
12023 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12024 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12025 @end deftypefn
12027 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12028 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12029 @end deftypefn
12031 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12032 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12033 @end deftypefn
12035 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12036 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12037 @end deftypefn
12039 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12040 Similar to @code{__builtin_nan}, except the return type is
12041 @code{_Float@var{n}}.
12042 @end deftypefn
12044 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12045 Similar to @code{__builtin_nan}, except the return type is
12046 @code{_Float@var{n}x}.
12047 @end deftypefn
12049 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12050 Similar to @code{__builtin_nan}, except the significand is forced
12051 to be a signaling NaN@.  The @code{nans} function is proposed by
12052 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12053 @end deftypefn
12055 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12056 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12057 @end deftypefn
12059 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12060 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12061 @end deftypefn
12063 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12064 Similar to @code{__builtin_nans}, except the return type is
12065 @code{_Float@var{n}}.
12066 @end deftypefn
12068 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12069 Similar to @code{__builtin_nans}, except the return type is
12070 @code{_Float@var{n}x}.
12071 @end deftypefn
12073 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12074 Returns one plus the index of the least significant 1-bit of @var{x}, or
12075 if @var{x} is zero, returns zero.
12076 @end deftypefn
12078 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12079 Returns the number of leading 0-bits in @var{x}, starting at the most
12080 significant bit position.  If @var{x} is 0, the result is undefined.
12081 @end deftypefn
12083 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12084 Returns the number of trailing 0-bits in @var{x}, starting at the least
12085 significant bit position.  If @var{x} is 0, the result is undefined.
12086 @end deftypefn
12088 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12089 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12090 number of bits following the most significant bit that are identical
12091 to it.  There are no special cases for 0 or other values. 
12092 @end deftypefn
12094 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12095 Returns the number of 1-bits in @var{x}.
12096 @end deftypefn
12098 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12099 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12100 modulo 2.
12101 @end deftypefn
12103 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12104 Similar to @code{__builtin_ffs}, except the argument type is
12105 @code{long}.
12106 @end deftypefn
12108 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12109 Similar to @code{__builtin_clz}, except the argument type is
12110 @code{unsigned long}.
12111 @end deftypefn
12113 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12114 Similar to @code{__builtin_ctz}, except the argument type is
12115 @code{unsigned long}.
12116 @end deftypefn
12118 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12119 Similar to @code{__builtin_clrsb}, except the argument type is
12120 @code{long}.
12121 @end deftypefn
12123 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12124 Similar to @code{__builtin_popcount}, except the argument type is
12125 @code{unsigned long}.
12126 @end deftypefn
12128 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12129 Similar to @code{__builtin_parity}, except the argument type is
12130 @code{unsigned long}.
12131 @end deftypefn
12133 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12134 Similar to @code{__builtin_ffs}, except the argument type is
12135 @code{long long}.
12136 @end deftypefn
12138 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12139 Similar to @code{__builtin_clz}, except the argument type is
12140 @code{unsigned long long}.
12141 @end deftypefn
12143 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12144 Similar to @code{__builtin_ctz}, except the argument type is
12145 @code{unsigned long long}.
12146 @end deftypefn
12148 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12149 Similar to @code{__builtin_clrsb}, except the argument type is
12150 @code{long long}.
12151 @end deftypefn
12153 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12154 Similar to @code{__builtin_popcount}, except the argument type is
12155 @code{unsigned long long}.
12156 @end deftypefn
12158 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12159 Similar to @code{__builtin_parity}, except the argument type is
12160 @code{unsigned long long}.
12161 @end deftypefn
12163 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12164 Returns the first argument raised to the power of the second.  Unlike the
12165 @code{pow} function no guarantees about precision and rounding are made.
12166 @end deftypefn
12168 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12169 Similar to @code{__builtin_powi}, except the argument and return types
12170 are @code{float}.
12171 @end deftypefn
12173 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12174 Similar to @code{__builtin_powi}, except the argument and return types
12175 are @code{long double}.
12176 @end deftypefn
12178 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12179 Returns @var{x} with the order of the bytes reversed; for example,
12180 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12181 exactly 8 bits.
12182 @end deftypefn
12184 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12185 Similar to @code{__builtin_bswap16}, except the argument and return types
12186 are 32 bit.
12187 @end deftypefn
12189 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12190 Similar to @code{__builtin_bswap32}, except the argument and return types
12191 are 64 bit.
12192 @end deftypefn
12194 @node Target Builtins
12195 @section Built-in Functions Specific to Particular Target Machines
12197 On some target machines, GCC supports many built-in functions specific
12198 to those machines.  Generally these generate calls to specific machine
12199 instructions, but allow the compiler to schedule those calls.
12201 @menu
12202 * AArch64 Built-in Functions::
12203 * Alpha Built-in Functions::
12204 * Altera Nios II Built-in Functions::
12205 * ARC Built-in Functions::
12206 * ARC SIMD Built-in Functions::
12207 * ARM iWMMXt Built-in Functions::
12208 * ARM C Language Extensions (ACLE)::
12209 * ARM Floating Point Status and Control Intrinsics::
12210 * ARM ARMv8-M Security Extensions::
12211 * AVR Built-in Functions::
12212 * Blackfin Built-in Functions::
12213 * FR-V Built-in Functions::
12214 * MIPS DSP Built-in Functions::
12215 * MIPS Paired-Single Support::
12216 * MIPS Loongson Built-in Functions::
12217 * MIPS SIMD Architecture (MSA) Support::
12218 * Other MIPS Built-in Functions::
12219 * MSP430 Built-in Functions::
12220 * NDS32 Built-in Functions::
12221 * picoChip Built-in Functions::
12222 * PowerPC Built-in Functions::
12223 * PowerPC AltiVec/VSX Built-in Functions::
12224 * PowerPC Hardware Transactional Memory Built-in Functions::
12225 * PowerPC Atomic Memory Operation Functions::
12226 * RX Built-in Functions::
12227 * S/390 System z Built-in Functions::
12228 * SH Built-in Functions::
12229 * SPARC VIS Built-in Functions::
12230 * SPU Built-in Functions::
12231 * TI C6X Built-in Functions::
12232 * TILE-Gx Built-in Functions::
12233 * TILEPro Built-in Functions::
12234 * x86 Built-in Functions::
12235 * x86 transactional memory intrinsics::
12236 @end menu
12238 @node AArch64 Built-in Functions
12239 @subsection AArch64 Built-in Functions
12241 These built-in functions are available for the AArch64 family of
12242 processors.
12243 @smallexample
12244 unsigned int __builtin_aarch64_get_fpcr ()
12245 void __builtin_aarch64_set_fpcr (unsigned int)
12246 unsigned int __builtin_aarch64_get_fpsr ()
12247 void __builtin_aarch64_set_fpsr (unsigned int)
12248 @end smallexample
12250 @node Alpha Built-in Functions
12251 @subsection Alpha Built-in Functions
12253 These built-in functions are available for the Alpha family of
12254 processors, depending on the command-line switches used.
12256 The following built-in functions are always available.  They
12257 all generate the machine instruction that is part of the name.
12259 @smallexample
12260 long __builtin_alpha_implver (void)
12261 long __builtin_alpha_rpcc (void)
12262 long __builtin_alpha_amask (long)
12263 long __builtin_alpha_cmpbge (long, long)
12264 long __builtin_alpha_extbl (long, long)
12265 long __builtin_alpha_extwl (long, long)
12266 long __builtin_alpha_extll (long, long)
12267 long __builtin_alpha_extql (long, long)
12268 long __builtin_alpha_extwh (long, long)
12269 long __builtin_alpha_extlh (long, long)
12270 long __builtin_alpha_extqh (long, long)
12271 long __builtin_alpha_insbl (long, long)
12272 long __builtin_alpha_inswl (long, long)
12273 long __builtin_alpha_insll (long, long)
12274 long __builtin_alpha_insql (long, long)
12275 long __builtin_alpha_inswh (long, long)
12276 long __builtin_alpha_inslh (long, long)
12277 long __builtin_alpha_insqh (long, long)
12278 long __builtin_alpha_mskbl (long, long)
12279 long __builtin_alpha_mskwl (long, long)
12280 long __builtin_alpha_mskll (long, long)
12281 long __builtin_alpha_mskql (long, long)
12282 long __builtin_alpha_mskwh (long, long)
12283 long __builtin_alpha_msklh (long, long)
12284 long __builtin_alpha_mskqh (long, long)
12285 long __builtin_alpha_umulh (long, long)
12286 long __builtin_alpha_zap (long, long)
12287 long __builtin_alpha_zapnot (long, long)
12288 @end smallexample
12290 The following built-in functions are always with @option{-mmax}
12291 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12292 later.  They all generate the machine instruction that is part
12293 of the name.
12295 @smallexample
12296 long __builtin_alpha_pklb (long)
12297 long __builtin_alpha_pkwb (long)
12298 long __builtin_alpha_unpkbl (long)
12299 long __builtin_alpha_unpkbw (long)
12300 long __builtin_alpha_minub8 (long, long)
12301 long __builtin_alpha_minsb8 (long, long)
12302 long __builtin_alpha_minuw4 (long, long)
12303 long __builtin_alpha_minsw4 (long, long)
12304 long __builtin_alpha_maxub8 (long, long)
12305 long __builtin_alpha_maxsb8 (long, long)
12306 long __builtin_alpha_maxuw4 (long, long)
12307 long __builtin_alpha_maxsw4 (long, long)
12308 long __builtin_alpha_perr (long, long)
12309 @end smallexample
12311 The following built-in functions are always with @option{-mcix}
12312 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12313 later.  They all generate the machine instruction that is part
12314 of the name.
12316 @smallexample
12317 long __builtin_alpha_cttz (long)
12318 long __builtin_alpha_ctlz (long)
12319 long __builtin_alpha_ctpop (long)
12320 @end smallexample
12322 The following built-in functions are available on systems that use the OSF/1
12323 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12324 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12325 @code{rdval} and @code{wrval}.
12327 @smallexample
12328 void *__builtin_thread_pointer (void)
12329 void __builtin_set_thread_pointer (void *)
12330 @end smallexample
12332 @node Altera Nios II Built-in Functions
12333 @subsection Altera Nios II Built-in Functions
12335 These built-in functions are available for the Altera Nios II
12336 family of processors.
12338 The following built-in functions are always available.  They
12339 all generate the machine instruction that is part of the name.
12341 @example
12342 int __builtin_ldbio (volatile const void *)
12343 int __builtin_ldbuio (volatile const void *)
12344 int __builtin_ldhio (volatile const void *)
12345 int __builtin_ldhuio (volatile const void *)
12346 int __builtin_ldwio (volatile const void *)
12347 void __builtin_stbio (volatile void *, int)
12348 void __builtin_sthio (volatile void *, int)
12349 void __builtin_stwio (volatile void *, int)
12350 void __builtin_sync (void)
12351 int __builtin_rdctl (int) 
12352 int __builtin_rdprs (int, int)
12353 void __builtin_wrctl (int, int)
12354 void __builtin_flushd (volatile void *)
12355 void __builtin_flushda (volatile void *)
12356 int __builtin_wrpie (int);
12357 void __builtin_eni (int);
12358 int __builtin_ldex (volatile const void *)
12359 int __builtin_stex (volatile void *, int)
12360 int __builtin_ldsex (volatile const void *)
12361 int __builtin_stsex (volatile void *, int)
12362 @end example
12364 The following built-in functions are always available.  They
12365 all generate a Nios II Custom Instruction. The name of the
12366 function represents the types that the function takes and
12367 returns. The letter before the @code{n} is the return type
12368 or void if absent. The @code{n} represents the first parameter
12369 to all the custom instructions, the custom instruction number.
12370 The two letters after the @code{n} represent the up to two
12371 parameters to the function.
12373 The letters represent the following data types:
12374 @table @code
12375 @item <no letter>
12376 @code{void} for return type and no parameter for parameter types.
12378 @item i
12379 @code{int} for return type and parameter type
12381 @item f
12382 @code{float} for return type and parameter type
12384 @item p
12385 @code{void *} for return type and parameter type
12387 @end table
12389 And the function names are:
12390 @example
12391 void __builtin_custom_n (void)
12392 void __builtin_custom_ni (int)
12393 void __builtin_custom_nf (float)
12394 void __builtin_custom_np (void *)
12395 void __builtin_custom_nii (int, int)
12396 void __builtin_custom_nif (int, float)
12397 void __builtin_custom_nip (int, void *)
12398 void __builtin_custom_nfi (float, int)
12399 void __builtin_custom_nff (float, float)
12400 void __builtin_custom_nfp (float, void *)
12401 void __builtin_custom_npi (void *, int)
12402 void __builtin_custom_npf (void *, float)
12403 void __builtin_custom_npp (void *, void *)
12404 int __builtin_custom_in (void)
12405 int __builtin_custom_ini (int)
12406 int __builtin_custom_inf (float)
12407 int __builtin_custom_inp (void *)
12408 int __builtin_custom_inii (int, int)
12409 int __builtin_custom_inif (int, float)
12410 int __builtin_custom_inip (int, void *)
12411 int __builtin_custom_infi (float, int)
12412 int __builtin_custom_inff (float, float)
12413 int __builtin_custom_infp (float, void *)
12414 int __builtin_custom_inpi (void *, int)
12415 int __builtin_custom_inpf (void *, float)
12416 int __builtin_custom_inpp (void *, void *)
12417 float __builtin_custom_fn (void)
12418 float __builtin_custom_fni (int)
12419 float __builtin_custom_fnf (float)
12420 float __builtin_custom_fnp (void *)
12421 float __builtin_custom_fnii (int, int)
12422 float __builtin_custom_fnif (int, float)
12423 float __builtin_custom_fnip (int, void *)
12424 float __builtin_custom_fnfi (float, int)
12425 float __builtin_custom_fnff (float, float)
12426 float __builtin_custom_fnfp (float, void *)
12427 float __builtin_custom_fnpi (void *, int)
12428 float __builtin_custom_fnpf (void *, float)
12429 float __builtin_custom_fnpp (void *, void *)
12430 void * __builtin_custom_pn (void)
12431 void * __builtin_custom_pni (int)
12432 void * __builtin_custom_pnf (float)
12433 void * __builtin_custom_pnp (void *)
12434 void * __builtin_custom_pnii (int, int)
12435 void * __builtin_custom_pnif (int, float)
12436 void * __builtin_custom_pnip (int, void *)
12437 void * __builtin_custom_pnfi (float, int)
12438 void * __builtin_custom_pnff (float, float)
12439 void * __builtin_custom_pnfp (float, void *)
12440 void * __builtin_custom_pnpi (void *, int)
12441 void * __builtin_custom_pnpf (void *, float)
12442 void * __builtin_custom_pnpp (void *, void *)
12443 @end example
12445 @node ARC Built-in Functions
12446 @subsection ARC Built-in Functions
12448 The following built-in functions are provided for ARC targets.  The
12449 built-ins generate the corresponding assembly instructions.  In the
12450 examples given below, the generated code often requires an operand or
12451 result to be in a register.  Where necessary further code will be
12452 generated to ensure this is true, but for brevity this is not
12453 described in each case.
12455 @emph{Note:} Using a built-in to generate an instruction not supported
12456 by a target may cause problems. At present the compiler is not
12457 guaranteed to detect such misuse, and as a result an internal compiler
12458 error may be generated.
12460 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12461 Return 1 if @var{val} is known to have the byte alignment given
12462 by @var{alignval}, otherwise return 0.
12463 Note that this is different from
12464 @smallexample
12465 __alignof__(*(char *)@var{val}) >= alignval
12466 @end smallexample
12467 because __alignof__ sees only the type of the dereference, whereas
12468 __builtin_arc_align uses alignment information from the pointer
12469 as well as from the pointed-to type.
12470 The information available will depend on optimization level.
12471 @end deftypefn
12473 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12474 Generates
12475 @example
12477 @end example
12478 @end deftypefn
12480 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12481 The operand is the number of a register to be read.  Generates:
12482 @example
12483 mov  @var{dest}, r@var{regno}
12484 @end example
12485 where the value in @var{dest} will be the result returned from the
12486 built-in.
12487 @end deftypefn
12489 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12490 The first operand is the number of a register to be written, the
12491 second operand is a compile time constant to write into that
12492 register.  Generates:
12493 @example
12494 mov  r@var{regno}, @var{val}
12495 @end example
12496 @end deftypefn
12498 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12499 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12500 Generates:
12501 @example
12502 divaw  @var{dest}, @var{a}, @var{b}
12503 @end example
12504 where the value in @var{dest} will be the result returned from the
12505 built-in.
12506 @end deftypefn
12508 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12509 Generates
12510 @example
12511 flag  @var{a}
12512 @end example
12513 @end deftypefn
12515 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12516 The operand, @var{auxv}, is the address of an auxiliary register and
12517 must be a compile time constant.  Generates:
12518 @example
12519 lr  @var{dest}, [@var{auxr}]
12520 @end example
12521 Where the value in @var{dest} will be the result returned from the
12522 built-in.
12523 @end deftypefn
12525 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12526 Only available with @option{-mmul64}.  Generates:
12527 @example
12528 mul64  @var{a}, @var{b}
12529 @end example
12530 @end deftypefn
12532 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12533 Only available with @option{-mmul64}.  Generates:
12534 @example
12535 mulu64  @var{a}, @var{b}
12536 @end example
12537 @end deftypefn
12539 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12540 Generates:
12541 @example
12543 @end example
12544 @end deftypefn
12546 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12547 Only valid if the @samp{norm} instruction is available through the
12548 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12549 Generates:
12550 @example
12551 norm  @var{dest}, @var{src}
12552 @end example
12553 Where the value in @var{dest} will be the result returned from the
12554 built-in.
12555 @end deftypefn
12557 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12558 Only valid if the @samp{normw} instruction is available through the
12559 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12560 Generates:
12561 @example
12562 normw  @var{dest}, @var{src}
12563 @end example
12564 Where the value in @var{dest} will be the result returned from the
12565 built-in.
12566 @end deftypefn
12568 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12569 Generates:
12570 @example
12571 rtie
12572 @end example
12573 @end deftypefn
12575 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12576 Generates:
12577 @example
12578 sleep  @var{a}
12579 @end example
12580 @end deftypefn
12582 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12583 The first argument, @var{auxv}, is the address of an auxiliary
12584 register, the second argument, @var{val}, is a compile time constant
12585 to be written to the register.  Generates:
12586 @example
12587 sr  @var{auxr}, [@var{val}]
12588 @end example
12589 @end deftypefn
12591 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12592 Only valid with @option{-mswap}.  Generates:
12593 @example
12594 swap  @var{dest}, @var{src}
12595 @end example
12596 Where the value in @var{dest} will be the result returned from the
12597 built-in.
12598 @end deftypefn
12600 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12601 Generates:
12602 @example
12604 @end example
12605 @end deftypefn
12607 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12608 Only available with @option{-mcpu=ARC700}.  Generates:
12609 @example
12610 sync
12611 @end example
12612 @end deftypefn
12614 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12615 Only available with @option{-mcpu=ARC700}.  Generates:
12616 @example
12617 trap_s  @var{c}
12618 @end example
12619 @end deftypefn
12621 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12622 Only available with @option{-mcpu=ARC700}.  Generates:
12623 @example
12624 unimp_s
12625 @end example
12626 @end deftypefn
12628 The instructions generated by the following builtins are not
12629 considered as candidates for scheduling.  They are not moved around by
12630 the compiler during scheduling, and thus can be expected to appear
12631 where they are put in the C code:
12632 @example
12633 __builtin_arc_brk()
12634 __builtin_arc_core_read()
12635 __builtin_arc_core_write()
12636 __builtin_arc_flag()
12637 __builtin_arc_lr()
12638 __builtin_arc_sleep()
12639 __builtin_arc_sr()
12640 __builtin_arc_swi()
12641 @end example
12643 @node ARC SIMD Built-in Functions
12644 @subsection ARC SIMD Built-in Functions
12646 SIMD builtins provided by the compiler can be used to generate the
12647 vector instructions.  This section describes the available builtins
12648 and their usage in programs.  With the @option{-msimd} option, the
12649 compiler provides 128-bit vector types, which can be specified using
12650 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12651 can be included to use the following predefined types:
12652 @example
12653 typedef int __v4si   __attribute__((vector_size(16)));
12654 typedef short __v8hi __attribute__((vector_size(16)));
12655 @end example
12657 These types can be used to define 128-bit variables.  The built-in
12658 functions listed in the following section can be used on these
12659 variables to generate the vector operations.
12661 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12662 @file{arc-simd.h} also provides equivalent macros called
12663 @code{_@var{someinsn}} that can be used for programming ease and
12664 improved readability.  The following macros for DMA control are also
12665 provided:
12666 @example
12667 #define _setup_dma_in_channel_reg _vdiwr
12668 #define _setup_dma_out_channel_reg _vdowr
12669 @end example
12671 The following is a complete list of all the SIMD built-ins provided
12672 for ARC, grouped by calling signature.
12674 The following take two @code{__v8hi} arguments and return a
12675 @code{__v8hi} result:
12676 @example
12677 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12678 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12679 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12680 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12681 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12682 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12683 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12684 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12685 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12686 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12687 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12688 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12689 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12690 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12691 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12692 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12693 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12694 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12695 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12696 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12697 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12698 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12699 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12700 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12701 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12702 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12703 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12704 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12705 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12706 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12707 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12708 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12709 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12710 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12711 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12712 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12713 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12714 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12715 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12716 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12717 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12718 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12719 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12720 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12721 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12722 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12723 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12724 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12725 @end example
12727 The following take one @code{__v8hi} and one @code{int} argument and return a
12728 @code{__v8hi} result:
12730 @example
12731 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12732 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12733 __v8hi __builtin_arc_vbminw (__v8hi, int)
12734 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12735 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12736 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12737 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12738 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12739 @end example
12741 The following take one @code{__v8hi} argument and one @code{int} argument which
12742 must be a 3-bit compile time constant indicating a register number
12743 I0-I7.  They return a @code{__v8hi} result.
12744 @example
12745 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12746 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12747 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12748 @end example
12750 The following take one @code{__v8hi} argument and one @code{int}
12751 argument which must be a 6-bit compile time constant.  They return a
12752 @code{__v8hi} result.
12753 @example
12754 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12755 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12756 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12757 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12758 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12759 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12760 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12761 @end example
12763 The following take one @code{__v8hi} argument and one @code{int} argument which
12764 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12765 result.
12766 @example
12767 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12768 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12769 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12770 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12771 @end example
12773 The following take two @code{int} arguments, the second of which which
12774 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12775 result:
12776 @example
12777 __v8hi __builtin_arc_vmovaw (int, const int)
12778 __v8hi __builtin_arc_vmovw (int, const int)
12779 __v8hi __builtin_arc_vmovzw (int, const int)
12780 @end example
12782 The following take a single @code{__v8hi} argument and return a
12783 @code{__v8hi} result:
12784 @example
12785 __v8hi __builtin_arc_vabsaw (__v8hi)
12786 __v8hi __builtin_arc_vabsw (__v8hi)
12787 __v8hi __builtin_arc_vaddsuw (__v8hi)
12788 __v8hi __builtin_arc_vexch1 (__v8hi)
12789 __v8hi __builtin_arc_vexch2 (__v8hi)
12790 __v8hi __builtin_arc_vexch4 (__v8hi)
12791 __v8hi __builtin_arc_vsignw (__v8hi)
12792 __v8hi __builtin_arc_vupbaw (__v8hi)
12793 __v8hi __builtin_arc_vupbw (__v8hi)
12794 __v8hi __builtin_arc_vupsbaw (__v8hi)
12795 __v8hi __builtin_arc_vupsbw (__v8hi)
12796 @end example
12798 The following take two @code{int} arguments and return no result:
12799 @example
12800 void __builtin_arc_vdirun (int, int)
12801 void __builtin_arc_vdorun (int, int)
12802 @end example
12804 The following take two @code{int} arguments and return no result.  The
12805 first argument must a 3-bit compile time constant indicating one of
12806 the DR0-DR7 DMA setup channels:
12807 @example
12808 void __builtin_arc_vdiwr (const int, int)
12809 void __builtin_arc_vdowr (const int, int)
12810 @end example
12812 The following take an @code{int} argument and return no result:
12813 @example
12814 void __builtin_arc_vendrec (int)
12815 void __builtin_arc_vrec (int)
12816 void __builtin_arc_vrecrun (int)
12817 void __builtin_arc_vrun (int)
12818 @end example
12820 The following take a @code{__v8hi} argument and two @code{int}
12821 arguments and return a @code{__v8hi} result.  The second argument must
12822 be a 3-bit compile time constants, indicating one the registers I0-I7,
12823 and the third argument must be an 8-bit compile time constant.
12825 @emph{Note:} Although the equivalent hardware instructions do not take
12826 an SIMD register as an operand, these builtins overwrite the relevant
12827 bits of the @code{__v8hi} register provided as the first argument with
12828 the value loaded from the @code{[Ib, u8]} location in the SDM.
12830 @example
12831 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12832 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12833 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12834 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12835 @end example
12837 The following take two @code{int} arguments and return a @code{__v8hi}
12838 result.  The first argument must be a 3-bit compile time constants,
12839 indicating one the registers I0-I7, and the second argument must be an
12840 8-bit compile time constant.
12842 @example
12843 __v8hi __builtin_arc_vld128 (const int, const int)
12844 __v8hi __builtin_arc_vld64w (const int, const int)
12845 @end example
12847 The following take a @code{__v8hi} argument and two @code{int}
12848 arguments and return no result.  The second argument must be a 3-bit
12849 compile time constants, indicating one the registers I0-I7, and the
12850 third argument must be an 8-bit compile time constant.
12852 @example
12853 void __builtin_arc_vst128 (__v8hi, const int, const int)
12854 void __builtin_arc_vst64 (__v8hi, const int, const int)
12855 @end example
12857 The following take a @code{__v8hi} argument and three @code{int}
12858 arguments and return no result.  The second argument must be a 3-bit
12859 compile-time constant, identifying the 16-bit sub-register to be
12860 stored, the third argument must be a 3-bit compile time constants,
12861 indicating one the registers I0-I7, and the fourth argument must be an
12862 8-bit compile time constant.
12864 @example
12865 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12866 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12867 @end example
12869 @node ARM iWMMXt Built-in Functions
12870 @subsection ARM iWMMXt Built-in Functions
12872 These built-in functions are available for the ARM family of
12873 processors when the @option{-mcpu=iwmmxt} switch is used:
12875 @smallexample
12876 typedef int v2si __attribute__ ((vector_size (8)));
12877 typedef short v4hi __attribute__ ((vector_size (8)));
12878 typedef char v8qi __attribute__ ((vector_size (8)));
12880 int __builtin_arm_getwcgr0 (void)
12881 void __builtin_arm_setwcgr0 (int)
12882 int __builtin_arm_getwcgr1 (void)
12883 void __builtin_arm_setwcgr1 (int)
12884 int __builtin_arm_getwcgr2 (void)
12885 void __builtin_arm_setwcgr2 (int)
12886 int __builtin_arm_getwcgr3 (void)
12887 void __builtin_arm_setwcgr3 (int)
12888 int __builtin_arm_textrmsb (v8qi, int)
12889 int __builtin_arm_textrmsh (v4hi, int)
12890 int __builtin_arm_textrmsw (v2si, int)
12891 int __builtin_arm_textrmub (v8qi, int)
12892 int __builtin_arm_textrmuh (v4hi, int)
12893 int __builtin_arm_textrmuw (v2si, int)
12894 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12895 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12896 v2si __builtin_arm_tinsrw (v2si, int, int)
12897 long long __builtin_arm_tmia (long long, int, int)
12898 long long __builtin_arm_tmiabb (long long, int, int)
12899 long long __builtin_arm_tmiabt (long long, int, int)
12900 long long __builtin_arm_tmiaph (long long, int, int)
12901 long long __builtin_arm_tmiatb (long long, int, int)
12902 long long __builtin_arm_tmiatt (long long, int, int)
12903 int __builtin_arm_tmovmskb (v8qi)
12904 int __builtin_arm_tmovmskh (v4hi)
12905 int __builtin_arm_tmovmskw (v2si)
12906 long long __builtin_arm_waccb (v8qi)
12907 long long __builtin_arm_wacch (v4hi)
12908 long long __builtin_arm_waccw (v2si)
12909 v8qi __builtin_arm_waddb (v8qi, v8qi)
12910 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12911 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12912 v4hi __builtin_arm_waddh (v4hi, v4hi)
12913 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12914 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12915 v2si __builtin_arm_waddw (v2si, v2si)
12916 v2si __builtin_arm_waddwss (v2si, v2si)
12917 v2si __builtin_arm_waddwus (v2si, v2si)
12918 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12919 long long __builtin_arm_wand(long long, long long)
12920 long long __builtin_arm_wandn (long long, long long)
12921 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12922 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12923 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12924 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12925 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12926 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12927 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12928 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12929 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12930 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12931 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12932 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12933 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12934 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12935 long long __builtin_arm_wmacsz (v4hi, v4hi)
12936 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12937 long long __builtin_arm_wmacuz (v4hi, v4hi)
12938 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12939 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12940 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12941 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12942 v2si __builtin_arm_wmaxsw (v2si, v2si)
12943 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12944 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12945 v2si __builtin_arm_wmaxuw (v2si, v2si)
12946 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12947 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12948 v2si __builtin_arm_wminsw (v2si, v2si)
12949 v8qi __builtin_arm_wminub (v8qi, v8qi)
12950 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12951 v2si __builtin_arm_wminuw (v2si, v2si)
12952 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12953 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12954 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12955 long long __builtin_arm_wor (long long, long long)
12956 v2si __builtin_arm_wpackdss (long long, long long)
12957 v2si __builtin_arm_wpackdus (long long, long long)
12958 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12959 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12960 v4hi __builtin_arm_wpackwss (v2si, v2si)
12961 v4hi __builtin_arm_wpackwus (v2si, v2si)
12962 long long __builtin_arm_wrord (long long, long long)
12963 long long __builtin_arm_wrordi (long long, int)
12964 v4hi __builtin_arm_wrorh (v4hi, long long)
12965 v4hi __builtin_arm_wrorhi (v4hi, int)
12966 v2si __builtin_arm_wrorw (v2si, long long)
12967 v2si __builtin_arm_wrorwi (v2si, int)
12968 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12969 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12970 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12971 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12972 v4hi __builtin_arm_wshufh (v4hi, int)
12973 long long __builtin_arm_wslld (long long, long long)
12974 long long __builtin_arm_wslldi (long long, int)
12975 v4hi __builtin_arm_wsllh (v4hi, long long)
12976 v4hi __builtin_arm_wsllhi (v4hi, int)
12977 v2si __builtin_arm_wsllw (v2si, long long)
12978 v2si __builtin_arm_wsllwi (v2si, int)
12979 long long __builtin_arm_wsrad (long long, long long)
12980 long long __builtin_arm_wsradi (long long, int)
12981 v4hi __builtin_arm_wsrah (v4hi, long long)
12982 v4hi __builtin_arm_wsrahi (v4hi, int)
12983 v2si __builtin_arm_wsraw (v2si, long long)
12984 v2si __builtin_arm_wsrawi (v2si, int)
12985 long long __builtin_arm_wsrld (long long, long long)
12986 long long __builtin_arm_wsrldi (long long, int)
12987 v4hi __builtin_arm_wsrlh (v4hi, long long)
12988 v4hi __builtin_arm_wsrlhi (v4hi, int)
12989 v2si __builtin_arm_wsrlw (v2si, long long)
12990 v2si __builtin_arm_wsrlwi (v2si, int)
12991 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12992 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12993 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12994 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12995 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12996 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12997 v2si __builtin_arm_wsubw (v2si, v2si)
12998 v2si __builtin_arm_wsubwss (v2si, v2si)
12999 v2si __builtin_arm_wsubwus (v2si, v2si)
13000 v4hi __builtin_arm_wunpckehsb (v8qi)
13001 v2si __builtin_arm_wunpckehsh (v4hi)
13002 long long __builtin_arm_wunpckehsw (v2si)
13003 v4hi __builtin_arm_wunpckehub (v8qi)
13004 v2si __builtin_arm_wunpckehuh (v4hi)
13005 long long __builtin_arm_wunpckehuw (v2si)
13006 v4hi __builtin_arm_wunpckelsb (v8qi)
13007 v2si __builtin_arm_wunpckelsh (v4hi)
13008 long long __builtin_arm_wunpckelsw (v2si)
13009 v4hi __builtin_arm_wunpckelub (v8qi)
13010 v2si __builtin_arm_wunpckeluh (v4hi)
13011 long long __builtin_arm_wunpckeluw (v2si)
13012 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13013 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13014 v2si __builtin_arm_wunpckihw (v2si, v2si)
13015 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13016 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13017 v2si __builtin_arm_wunpckilw (v2si, v2si)
13018 long long __builtin_arm_wxor (long long, long long)
13019 long long __builtin_arm_wzero ()
13020 @end smallexample
13023 @node ARM C Language Extensions (ACLE)
13024 @subsection ARM C Language Extensions (ACLE)
13026 GCC implements extensions for C as described in the ARM C Language
13027 Extensions (ACLE) specification, which can be found at
13028 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13030 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13031 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13032 intrinsics can be found at
13033 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13034 The built-in intrinsics for the Advanced SIMD extension are available when
13035 NEON is enabled.
13037 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13038 back ends support CRC32 intrinsics and the ARM back end supports the
13039 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13040 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13041 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13042 intrinsics yet.
13044 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13045 availability of extensions.
13047 @node ARM Floating Point Status and Control Intrinsics
13048 @subsection ARM Floating Point Status and Control Intrinsics
13050 These built-in functions are available for the ARM family of
13051 processors with floating-point unit.
13053 @smallexample
13054 unsigned int __builtin_arm_get_fpscr ()
13055 void __builtin_arm_set_fpscr (unsigned int)
13056 @end smallexample
13058 @node ARM ARMv8-M Security Extensions
13059 @subsection ARM ARMv8-M Security Extensions
13061 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13062 Security Extensions: Requirements on Development Tools Engineering
13063 Specification, which can be found at
13064 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13066 As part of the Security Extensions GCC implements two new function attributes:
13067 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13069 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13070 is used here to mean any function pointer type.
13072 @smallexample
13073 cmse_address_info_t cmse_TT (void *)
13074 cmse_address_info_t cmse_TT_fptr (FPTR)
13075 cmse_address_info_t cmse_TTT (void *)
13076 cmse_address_info_t cmse_TTT_fptr (FPTR)
13077 cmse_address_info_t cmse_TTA (void *)
13078 cmse_address_info_t cmse_TTA_fptr (FPTR)
13079 cmse_address_info_t cmse_TTAT (void *)
13080 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13081 void * cmse_check_address_range (void *, size_t, int)
13082 typeof(p) cmse_nsfptr_create (FPTR p)
13083 intptr_t cmse_is_nsfptr (FPTR)
13084 int cmse_nonsecure_caller (void)
13085 @end smallexample
13087 @node AVR Built-in Functions
13088 @subsection AVR Built-in Functions
13090 For each built-in function for AVR, there is an equally named,
13091 uppercase built-in macro defined. That way users can easily query if
13092 or if not a specific built-in is implemented or not. For example, if
13093 @code{__builtin_avr_nop} is available the macro
13094 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13096 @table @code
13098 @item void __builtin_avr_nop (void)
13099 @itemx void __builtin_avr_sei (void)
13100 @itemx void __builtin_avr_cli (void)
13101 @itemx void __builtin_avr_sleep (void)
13102 @itemx void __builtin_avr_wdr (void)
13103 @itemx unsigned char __builtin_avr_swap (unsigned char)
13104 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13105 @itemx int __builtin_avr_fmuls (char, char)
13106 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13107 These built-in functions map to the respective machine
13108 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13109 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13110 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13111 as library call if no hardware multiplier is available.
13113 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13114 Delay execution for @var{ticks} cycles. Note that this
13115 built-in does not take into account the effect of interrupts that
13116 might increase delay time. @var{ticks} must be a compile-time
13117 integer constant; delays with a variable number of cycles are not supported.
13119 @item char __builtin_avr_flash_segment (const __memx void*)
13120 This built-in takes a byte address to the 24-bit
13121 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13122 the number of the flash segment (the 64 KiB chunk) where the address
13123 points to.  Counting starts at @code{0}.
13124 If the address does not point to flash memory, return @code{-1}.
13126 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13127 Insert bits from @var{bits} into @var{val} and return the resulting
13128 value. The nibbles of @var{map} determine how the insertion is
13129 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13130 @enumerate
13131 @item If @var{X} is @code{0xf},
13132 then the @var{n}-th bit of @var{val} is returned unaltered.
13134 @item If X is in the range 0@dots{}7,
13135 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13137 @item If X is in the range 8@dots{}@code{0xe},
13138 then the @var{n}-th result bit is undefined.
13139 @end enumerate
13141 @noindent
13142 One typical use case for this built-in is adjusting input and
13143 output values to non-contiguous port layouts. Some examples:
13145 @smallexample
13146 // same as val, bits is unused
13147 __builtin_avr_insert_bits (0xffffffff, bits, val)
13148 @end smallexample
13150 @smallexample
13151 // same as bits, val is unused
13152 __builtin_avr_insert_bits (0x76543210, bits, val)
13153 @end smallexample
13155 @smallexample
13156 // same as rotating bits by 4
13157 __builtin_avr_insert_bits (0x32107654, bits, 0)
13158 @end smallexample
13160 @smallexample
13161 // high nibble of result is the high nibble of val
13162 // low nibble of result is the low nibble of bits
13163 __builtin_avr_insert_bits (0xffff3210, bits, val)
13164 @end smallexample
13166 @smallexample
13167 // reverse the bit order of bits
13168 __builtin_avr_insert_bits (0x01234567, bits, 0)
13169 @end smallexample
13171 @item void __builtin_avr_nops (unsigned count)
13172 Insert @var{count} @code{NOP} instructions.
13173 The number of instructions must be a compile-time integer constant.
13175 @end table
13177 @noindent
13178 There are many more AVR-specific built-in functions that are used to
13179 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13180 section 7.18a.6.  You don't need to use these built-ins directly.
13181 Instead, use the declarations as supplied by the @code{stdfix.h} header
13182 with GNU-C99:
13184 @smallexample
13185 #include <stdfix.h>
13187 // Re-interpret the bit representation of unsigned 16-bit
13188 // integer @var{uval} as Q-format 0.16 value.
13189 unsigned fract get_bits (uint_ur_t uval)
13191     return urbits (uval);
13193 @end smallexample
13195 @node Blackfin Built-in Functions
13196 @subsection Blackfin Built-in Functions
13198 Currently, there are two Blackfin-specific built-in functions.  These are
13199 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13200 using inline assembly; by using these built-in functions the compiler can
13201 automatically add workarounds for hardware errata involving these
13202 instructions.  These functions are named as follows:
13204 @smallexample
13205 void __builtin_bfin_csync (void)
13206 void __builtin_bfin_ssync (void)
13207 @end smallexample
13209 @node FR-V Built-in Functions
13210 @subsection FR-V Built-in Functions
13212 GCC provides many FR-V-specific built-in functions.  In general,
13213 these functions are intended to be compatible with those described
13214 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13215 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13216 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13217 pointer rather than by value.
13219 Most of the functions are named after specific FR-V instructions.
13220 Such functions are said to be ``directly mapped'' and are summarized
13221 here in tabular form.
13223 @menu
13224 * Argument Types::
13225 * Directly-mapped Integer Functions::
13226 * Directly-mapped Media Functions::
13227 * Raw read/write Functions::
13228 * Other Built-in Functions::
13229 @end menu
13231 @node Argument Types
13232 @subsubsection Argument Types
13234 The arguments to the built-in functions can be divided into three groups:
13235 register numbers, compile-time constants and run-time values.  In order
13236 to make this classification clear at a glance, the arguments and return
13237 values are given the following pseudo types:
13239 @multitable @columnfractions .20 .30 .15 .35
13240 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13241 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13242 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13243 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13244 @item @code{uw2} @tab @code{unsigned long long} @tab No
13245 @tab an unsigned doubleword
13246 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13247 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13248 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13249 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13250 @end multitable
13252 These pseudo types are not defined by GCC, they are simply a notational
13253 convenience used in this manual.
13255 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13256 and @code{sw2} are evaluated at run time.  They correspond to
13257 register operands in the underlying FR-V instructions.
13259 @code{const} arguments represent immediate operands in the underlying
13260 FR-V instructions.  They must be compile-time constants.
13262 @code{acc} arguments are evaluated at compile time and specify the number
13263 of an accumulator register.  For example, an @code{acc} argument of 2
13264 selects the ACC2 register.
13266 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13267 number of an IACC register.  See @pxref{Other Built-in Functions}
13268 for more details.
13270 @node Directly-mapped Integer Functions
13271 @subsubsection Directly-Mapped Integer Functions
13273 The functions listed below map directly to FR-V I-type instructions.
13275 @multitable @columnfractions .45 .32 .23
13276 @item Function prototype @tab Example usage @tab Assembly output
13277 @item @code{sw1 __ADDSS (sw1, sw1)}
13278 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13279 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13280 @item @code{sw1 __SCAN (sw1, sw1)}
13281 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13282 @tab @code{SCAN @var{a},@var{b},@var{c}}
13283 @item @code{sw1 __SCUTSS (sw1)}
13284 @tab @code{@var{b} = __SCUTSS (@var{a})}
13285 @tab @code{SCUTSS @var{a},@var{b}}
13286 @item @code{sw1 __SLASS (sw1, sw1)}
13287 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13288 @tab @code{SLASS @var{a},@var{b},@var{c}}
13289 @item @code{void __SMASS (sw1, sw1)}
13290 @tab @code{__SMASS (@var{a}, @var{b})}
13291 @tab @code{SMASS @var{a},@var{b}}
13292 @item @code{void __SMSSS (sw1, sw1)}
13293 @tab @code{__SMSSS (@var{a}, @var{b})}
13294 @tab @code{SMSSS @var{a},@var{b}}
13295 @item @code{void __SMU (sw1, sw1)}
13296 @tab @code{__SMU (@var{a}, @var{b})}
13297 @tab @code{SMU @var{a},@var{b}}
13298 @item @code{sw2 __SMUL (sw1, sw1)}
13299 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13300 @tab @code{SMUL @var{a},@var{b},@var{c}}
13301 @item @code{sw1 __SUBSS (sw1, sw1)}
13302 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13303 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13304 @item @code{uw2 __UMUL (uw1, uw1)}
13305 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13306 @tab @code{UMUL @var{a},@var{b},@var{c}}
13307 @end multitable
13309 @node Directly-mapped Media Functions
13310 @subsubsection Directly-Mapped Media Functions
13312 The functions listed below map directly to FR-V M-type instructions.
13314 @multitable @columnfractions .45 .32 .23
13315 @item Function prototype @tab Example usage @tab Assembly output
13316 @item @code{uw1 __MABSHS (sw1)}
13317 @tab @code{@var{b} = __MABSHS (@var{a})}
13318 @tab @code{MABSHS @var{a},@var{b}}
13319 @item @code{void __MADDACCS (acc, acc)}
13320 @tab @code{__MADDACCS (@var{b}, @var{a})}
13321 @tab @code{MADDACCS @var{a},@var{b}}
13322 @item @code{sw1 __MADDHSS (sw1, sw1)}
13323 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13324 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13325 @item @code{uw1 __MADDHUS (uw1, uw1)}
13326 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13327 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13328 @item @code{uw1 __MAND (uw1, uw1)}
13329 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13330 @tab @code{MAND @var{a},@var{b},@var{c}}
13331 @item @code{void __MASACCS (acc, acc)}
13332 @tab @code{__MASACCS (@var{b}, @var{a})}
13333 @tab @code{MASACCS @var{a},@var{b}}
13334 @item @code{uw1 __MAVEH (uw1, uw1)}
13335 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13336 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13337 @item @code{uw2 __MBTOH (uw1)}
13338 @tab @code{@var{b} = __MBTOH (@var{a})}
13339 @tab @code{MBTOH @var{a},@var{b}}
13340 @item @code{void __MBTOHE (uw1 *, uw1)}
13341 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13342 @tab @code{MBTOHE @var{a},@var{b}}
13343 @item @code{void __MCLRACC (acc)}
13344 @tab @code{__MCLRACC (@var{a})}
13345 @tab @code{MCLRACC @var{a}}
13346 @item @code{void __MCLRACCA (void)}
13347 @tab @code{__MCLRACCA ()}
13348 @tab @code{MCLRACCA}
13349 @item @code{uw1 __Mcop1 (uw1, uw1)}
13350 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13351 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13352 @item @code{uw1 __Mcop2 (uw1, uw1)}
13353 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13354 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13355 @item @code{uw1 __MCPLHI (uw2, const)}
13356 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13357 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13358 @item @code{uw1 __MCPLI (uw2, const)}
13359 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13360 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13361 @item @code{void __MCPXIS (acc, sw1, sw1)}
13362 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13363 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13364 @item @code{void __MCPXIU (acc, uw1, uw1)}
13365 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13366 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13367 @item @code{void __MCPXRS (acc, sw1, sw1)}
13368 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13369 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13370 @item @code{void __MCPXRU (acc, uw1, uw1)}
13371 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13372 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13373 @item @code{uw1 __MCUT (acc, uw1)}
13374 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13375 @tab @code{MCUT @var{a},@var{b},@var{c}}
13376 @item @code{uw1 __MCUTSS (acc, sw1)}
13377 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13378 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13379 @item @code{void __MDADDACCS (acc, acc)}
13380 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13381 @tab @code{MDADDACCS @var{a},@var{b}}
13382 @item @code{void __MDASACCS (acc, acc)}
13383 @tab @code{__MDASACCS (@var{b}, @var{a})}
13384 @tab @code{MDASACCS @var{a},@var{b}}
13385 @item @code{uw2 __MDCUTSSI (acc, const)}
13386 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13387 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13388 @item @code{uw2 __MDPACKH (uw2, uw2)}
13389 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13390 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13391 @item @code{uw2 __MDROTLI (uw2, const)}
13392 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13393 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13394 @item @code{void __MDSUBACCS (acc, acc)}
13395 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13396 @tab @code{MDSUBACCS @var{a},@var{b}}
13397 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13398 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13399 @tab @code{MDUNPACKH @var{a},@var{b}}
13400 @item @code{uw2 __MEXPDHD (uw1, const)}
13401 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13402 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13403 @item @code{uw1 __MEXPDHW (uw1, const)}
13404 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13405 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13406 @item @code{uw1 __MHDSETH (uw1, const)}
13407 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13408 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13409 @item @code{sw1 __MHDSETS (const)}
13410 @tab @code{@var{b} = __MHDSETS (@var{a})}
13411 @tab @code{MHDSETS #@var{a},@var{b}}
13412 @item @code{uw1 __MHSETHIH (uw1, const)}
13413 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13414 @tab @code{MHSETHIH #@var{a},@var{b}}
13415 @item @code{sw1 __MHSETHIS (sw1, const)}
13416 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13417 @tab @code{MHSETHIS #@var{a},@var{b}}
13418 @item @code{uw1 __MHSETLOH (uw1, const)}
13419 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13420 @tab @code{MHSETLOH #@var{a},@var{b}}
13421 @item @code{sw1 __MHSETLOS (sw1, const)}
13422 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13423 @tab @code{MHSETLOS #@var{a},@var{b}}
13424 @item @code{uw1 __MHTOB (uw2)}
13425 @tab @code{@var{b} = __MHTOB (@var{a})}
13426 @tab @code{MHTOB @var{a},@var{b}}
13427 @item @code{void __MMACHS (acc, sw1, sw1)}
13428 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13429 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13430 @item @code{void __MMACHU (acc, uw1, uw1)}
13431 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13432 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13433 @item @code{void __MMRDHS (acc, sw1, sw1)}
13434 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13435 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13436 @item @code{void __MMRDHU (acc, uw1, uw1)}
13437 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13438 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13439 @item @code{void __MMULHS (acc, sw1, sw1)}
13440 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13441 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13442 @item @code{void __MMULHU (acc, uw1, uw1)}
13443 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13444 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13445 @item @code{void __MMULXHS (acc, sw1, sw1)}
13446 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13447 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13448 @item @code{void __MMULXHU (acc, uw1, uw1)}
13449 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13450 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13451 @item @code{uw1 __MNOT (uw1)}
13452 @tab @code{@var{b} = __MNOT (@var{a})}
13453 @tab @code{MNOT @var{a},@var{b}}
13454 @item @code{uw1 __MOR (uw1, uw1)}
13455 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13456 @tab @code{MOR @var{a},@var{b},@var{c}}
13457 @item @code{uw1 __MPACKH (uh, uh)}
13458 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13459 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13460 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13461 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13462 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13463 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13464 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13465 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13466 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13467 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13468 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13469 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13470 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13471 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13472 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13473 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13474 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13475 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13476 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13477 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13478 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13479 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13480 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13481 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13482 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13483 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13484 @item @code{void __MQMACHS (acc, sw2, sw2)}
13485 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13486 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13487 @item @code{void __MQMACHU (acc, uw2, uw2)}
13488 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13489 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13490 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13491 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13492 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13493 @item @code{void __MQMULHS (acc, sw2, sw2)}
13494 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13495 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13496 @item @code{void __MQMULHU (acc, uw2, uw2)}
13497 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13498 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13499 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13500 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13501 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13502 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13503 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13504 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13505 @item @code{sw2 __MQSATHS (sw2, sw2)}
13506 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13507 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13508 @item @code{uw2 __MQSLLHI (uw2, int)}
13509 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13510 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13511 @item @code{sw2 __MQSRAHI (sw2, int)}
13512 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13513 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13514 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13515 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13516 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13517 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13518 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13519 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13520 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13521 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13522 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13523 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13524 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13525 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13526 @item @code{uw1 __MRDACC (acc)}
13527 @tab @code{@var{b} = __MRDACC (@var{a})}
13528 @tab @code{MRDACC @var{a},@var{b}}
13529 @item @code{uw1 __MRDACCG (acc)}
13530 @tab @code{@var{b} = __MRDACCG (@var{a})}
13531 @tab @code{MRDACCG @var{a},@var{b}}
13532 @item @code{uw1 __MROTLI (uw1, const)}
13533 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13534 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13535 @item @code{uw1 __MROTRI (uw1, const)}
13536 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13537 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13538 @item @code{sw1 __MSATHS (sw1, sw1)}
13539 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13540 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13541 @item @code{uw1 __MSATHU (uw1, uw1)}
13542 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13543 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13544 @item @code{uw1 __MSLLHI (uw1, const)}
13545 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13546 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13547 @item @code{sw1 __MSRAHI (sw1, const)}
13548 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13549 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13550 @item @code{uw1 __MSRLHI (uw1, const)}
13551 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13552 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13553 @item @code{void __MSUBACCS (acc, acc)}
13554 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13555 @tab @code{MSUBACCS @var{a},@var{b}}
13556 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13557 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13558 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13559 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13560 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13561 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13562 @item @code{void __MTRAP (void)}
13563 @tab @code{__MTRAP ()}
13564 @tab @code{MTRAP}
13565 @item @code{uw2 __MUNPACKH (uw1)}
13566 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13567 @tab @code{MUNPACKH @var{a},@var{b}}
13568 @item @code{uw1 __MWCUT (uw2, uw1)}
13569 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13570 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13571 @item @code{void __MWTACC (acc, uw1)}
13572 @tab @code{__MWTACC (@var{b}, @var{a})}
13573 @tab @code{MWTACC @var{a},@var{b}}
13574 @item @code{void __MWTACCG (acc, uw1)}
13575 @tab @code{__MWTACCG (@var{b}, @var{a})}
13576 @tab @code{MWTACCG @var{a},@var{b}}
13577 @item @code{uw1 __MXOR (uw1, uw1)}
13578 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13579 @tab @code{MXOR @var{a},@var{b},@var{c}}
13580 @end multitable
13582 @node Raw read/write Functions
13583 @subsubsection Raw Read/Write Functions
13585 This sections describes built-in functions related to read and write
13586 instructions to access memory.  These functions generate
13587 @code{membar} instructions to flush the I/O load and stores where
13588 appropriate, as described in Fujitsu's manual described above.
13590 @table @code
13592 @item unsigned char __builtin_read8 (void *@var{data})
13593 @item unsigned short __builtin_read16 (void *@var{data})
13594 @item unsigned long __builtin_read32 (void *@var{data})
13595 @item unsigned long long __builtin_read64 (void *@var{data})
13597 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13598 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13599 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13600 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13601 @end table
13603 @node Other Built-in Functions
13604 @subsubsection Other Built-in Functions
13606 This section describes built-in functions that are not named after
13607 a specific FR-V instruction.
13609 @table @code
13610 @item sw2 __IACCreadll (iacc @var{reg})
13611 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13612 for future expansion and must be 0.
13614 @item sw1 __IACCreadl (iacc @var{reg})
13615 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13616 Other values of @var{reg} are rejected as invalid.
13618 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13619 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13620 is reserved for future expansion and must be 0.
13622 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13623 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13624 is 1.  Other values of @var{reg} are rejected as invalid.
13626 @item void __data_prefetch0 (const void *@var{x})
13627 Use the @code{dcpl} instruction to load the contents of address @var{x}
13628 into the data cache.
13630 @item void __data_prefetch (const void *@var{x})
13631 Use the @code{nldub} instruction to load the contents of address @var{x}
13632 into the data cache.  The instruction is issued in slot I1@.
13633 @end table
13635 @node MIPS DSP Built-in Functions
13636 @subsection MIPS DSP Built-in Functions
13638 The MIPS DSP Application-Specific Extension (ASE) includes new
13639 instructions that are designed to improve the performance of DSP and
13640 media applications.  It provides instructions that operate on packed
13641 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13643 GCC supports MIPS DSP operations using both the generic
13644 vector extensions (@pxref{Vector Extensions}) and a collection of
13645 MIPS-specific built-in functions.  Both kinds of support are
13646 enabled by the @option{-mdsp} command-line option.
13648 Revision 2 of the ASE was introduced in the second half of 2006.
13649 This revision adds extra instructions to the original ASE, but is
13650 otherwise backwards-compatible with it.  You can select revision 2
13651 using the command-line option @option{-mdspr2}; this option implies
13652 @option{-mdsp}.
13654 The SCOUNT and POS bits of the DSP control register are global.  The
13655 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13656 POS bits.  During optimization, the compiler does not delete these
13657 instructions and it does not delete calls to functions containing
13658 these instructions.
13660 At present, GCC only provides support for operations on 32-bit
13661 vectors.  The vector type associated with 8-bit integer data is
13662 usually called @code{v4i8}, the vector type associated with Q7
13663 is usually called @code{v4q7}, the vector type associated with 16-bit
13664 integer data is usually called @code{v2i16}, and the vector type
13665 associated with Q15 is usually called @code{v2q15}.  They can be
13666 defined in C as follows:
13668 @smallexample
13669 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13670 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13671 typedef short v2i16 __attribute__ ((vector_size(4)));
13672 typedef short v2q15 __attribute__ ((vector_size(4)));
13673 @end smallexample
13675 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13676 initialized in the same way as aggregates.  For example:
13678 @smallexample
13679 v4i8 a = @{1, 2, 3, 4@};
13680 v4i8 b;
13681 b = (v4i8) @{5, 6, 7, 8@};
13683 v2q15 c = @{0x0fcb, 0x3a75@};
13684 v2q15 d;
13685 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13686 @end smallexample
13688 @emph{Note:} The CPU's endianness determines the order in which values
13689 are packed.  On little-endian targets, the first value is the least
13690 significant and the last value is the most significant.  The opposite
13691 order applies to big-endian targets.  For example, the code above
13692 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13693 and @code{4} on big-endian targets.
13695 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13696 representation.  As shown in this example, the integer representation
13697 of a Q7 value can be obtained by multiplying the fractional value by
13698 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13699 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13700 @code{0x1.0p31}.
13702 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13703 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13704 and @code{c} and @code{d} are @code{v2q15} values.
13706 @multitable @columnfractions .50 .50
13707 @item C code @tab MIPS instruction
13708 @item @code{a + b} @tab @code{addu.qb}
13709 @item @code{c + d} @tab @code{addq.ph}
13710 @item @code{a - b} @tab @code{subu.qb}
13711 @item @code{c - d} @tab @code{subq.ph}
13712 @end multitable
13714 The table below lists the @code{v2i16} operation for which
13715 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13716 @code{v2i16} values.
13718 @multitable @columnfractions .50 .50
13719 @item C code @tab MIPS instruction
13720 @item @code{e * f} @tab @code{mul.ph}
13721 @end multitable
13723 It is easier to describe the DSP built-in functions if we first define
13724 the following types:
13726 @smallexample
13727 typedef int q31;
13728 typedef int i32;
13729 typedef unsigned int ui32;
13730 typedef long long a64;
13731 @end smallexample
13733 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13734 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13735 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13736 @code{long long}, but we use @code{a64} to indicate values that are
13737 placed in one of the four DSP accumulators (@code{$ac0},
13738 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13740 Also, some built-in functions prefer or require immediate numbers as
13741 parameters, because the corresponding DSP instructions accept both immediate
13742 numbers and register operands, or accept immediate numbers only.  The
13743 immediate parameters are listed as follows.
13745 @smallexample
13746 imm0_3: 0 to 3.
13747 imm0_7: 0 to 7.
13748 imm0_15: 0 to 15.
13749 imm0_31: 0 to 31.
13750 imm0_63: 0 to 63.
13751 imm0_255: 0 to 255.
13752 imm_n32_31: -32 to 31.
13753 imm_n512_511: -512 to 511.
13754 @end smallexample
13756 The following built-in functions map directly to a particular MIPS DSP
13757 instruction.  Please refer to the architecture specification
13758 for details on what each instruction does.
13760 @smallexample
13761 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13762 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13763 q31 __builtin_mips_addq_s_w (q31, q31)
13764 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13765 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13766 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13767 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13768 q31 __builtin_mips_subq_s_w (q31, q31)
13769 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13770 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13771 i32 __builtin_mips_addsc (i32, i32)
13772 i32 __builtin_mips_addwc (i32, i32)
13773 i32 __builtin_mips_modsub (i32, i32)
13774 i32 __builtin_mips_raddu_w_qb (v4i8)
13775 v2q15 __builtin_mips_absq_s_ph (v2q15)
13776 q31 __builtin_mips_absq_s_w (q31)
13777 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13778 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13779 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13780 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13781 q31 __builtin_mips_preceq_w_phl (v2q15)
13782 q31 __builtin_mips_preceq_w_phr (v2q15)
13783 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13784 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13785 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13786 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13787 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13788 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13789 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13790 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13791 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13792 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13793 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13794 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13795 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13796 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13797 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13798 q31 __builtin_mips_shll_s_w (q31, i32)
13799 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13800 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13801 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13802 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13803 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13804 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13805 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13806 q31 __builtin_mips_shra_r_w (q31, i32)
13807 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13808 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13809 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13810 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13811 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13812 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13813 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13814 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13815 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13816 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13817 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13818 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13819 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13820 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13821 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13822 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13823 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13824 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13825 i32 __builtin_mips_bitrev (i32)
13826 i32 __builtin_mips_insv (i32, i32)
13827 v4i8 __builtin_mips_repl_qb (imm0_255)
13828 v4i8 __builtin_mips_repl_qb (i32)
13829 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13830 v2q15 __builtin_mips_repl_ph (i32)
13831 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13832 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13833 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13834 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13835 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13836 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13837 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13838 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13839 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13840 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13841 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13842 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13843 i32 __builtin_mips_extr_w (a64, imm0_31)
13844 i32 __builtin_mips_extr_w (a64, i32)
13845 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13846 i32 __builtin_mips_extr_s_h (a64, i32)
13847 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13848 i32 __builtin_mips_extr_rs_w (a64, i32)
13849 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13850 i32 __builtin_mips_extr_r_w (a64, i32)
13851 i32 __builtin_mips_extp (a64, imm0_31)
13852 i32 __builtin_mips_extp (a64, i32)
13853 i32 __builtin_mips_extpdp (a64, imm0_31)
13854 i32 __builtin_mips_extpdp (a64, i32)
13855 a64 __builtin_mips_shilo (a64, imm_n32_31)
13856 a64 __builtin_mips_shilo (a64, i32)
13857 a64 __builtin_mips_mthlip (a64, i32)
13858 void __builtin_mips_wrdsp (i32, imm0_63)
13859 i32 __builtin_mips_rddsp (imm0_63)
13860 i32 __builtin_mips_lbux (void *, i32)
13861 i32 __builtin_mips_lhx (void *, i32)
13862 i32 __builtin_mips_lwx (void *, i32)
13863 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13864 i32 __builtin_mips_bposge32 (void)
13865 a64 __builtin_mips_madd (a64, i32, i32);
13866 a64 __builtin_mips_maddu (a64, ui32, ui32);
13867 a64 __builtin_mips_msub (a64, i32, i32);
13868 a64 __builtin_mips_msubu (a64, ui32, ui32);
13869 a64 __builtin_mips_mult (i32, i32);
13870 a64 __builtin_mips_multu (ui32, ui32);
13871 @end smallexample
13873 The following built-in functions map directly to a particular MIPS DSP REV 2
13874 instruction.  Please refer to the architecture specification
13875 for details on what each instruction does.
13877 @smallexample
13878 v4q7 __builtin_mips_absq_s_qb (v4q7);
13879 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13880 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13881 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13882 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13883 i32 __builtin_mips_append (i32, i32, imm0_31);
13884 i32 __builtin_mips_balign (i32, i32, imm0_3);
13885 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13886 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13887 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13888 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13889 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13890 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13891 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13892 q31 __builtin_mips_mulq_rs_w (q31, q31);
13893 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13894 q31 __builtin_mips_mulq_s_w (q31, q31);
13895 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13896 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13897 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13898 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13899 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13900 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13901 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13902 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13903 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13904 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13905 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13906 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13907 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13908 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13909 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13910 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13911 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13912 q31 __builtin_mips_addqh_w (q31, q31);
13913 q31 __builtin_mips_addqh_r_w (q31, q31);
13914 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13915 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13916 q31 __builtin_mips_subqh_w (q31, q31);
13917 q31 __builtin_mips_subqh_r_w (q31, q31);
13918 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13919 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13920 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13921 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13922 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13923 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13924 @end smallexample
13927 @node MIPS Paired-Single Support
13928 @subsection MIPS Paired-Single Support
13930 The MIPS64 architecture includes a number of instructions that
13931 operate on pairs of single-precision floating-point values.
13932 Each pair is packed into a 64-bit floating-point register,
13933 with one element being designated the ``upper half'' and
13934 the other being designated the ``lower half''.
13936 GCC supports paired-single operations using both the generic
13937 vector extensions (@pxref{Vector Extensions}) and a collection of
13938 MIPS-specific built-in functions.  Both kinds of support are
13939 enabled by the @option{-mpaired-single} command-line option.
13941 The vector type associated with paired-single values is usually
13942 called @code{v2sf}.  It can be defined in C as follows:
13944 @smallexample
13945 typedef float v2sf __attribute__ ((vector_size (8)));
13946 @end smallexample
13948 @code{v2sf} values are initialized in the same way as aggregates.
13949 For example:
13951 @smallexample
13952 v2sf a = @{1.5, 9.1@};
13953 v2sf b;
13954 float e, f;
13955 b = (v2sf) @{e, f@};
13956 @end smallexample
13958 @emph{Note:} The CPU's endianness determines which value is stored in
13959 the upper half of a register and which value is stored in the lower half.
13960 On little-endian targets, the first value is the lower one and the second
13961 value is the upper one.  The opposite order applies to big-endian targets.
13962 For example, the code above sets the lower half of @code{a} to
13963 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13965 @node MIPS Loongson Built-in Functions
13966 @subsection MIPS Loongson Built-in Functions
13968 GCC provides intrinsics to access the SIMD instructions provided by the
13969 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13970 available after inclusion of the @code{loongson.h} header file,
13971 operate on the following 64-bit vector types:
13973 @itemize
13974 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13975 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13976 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13977 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13978 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13979 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13980 @end itemize
13982 The intrinsics provided are listed below; each is named after the
13983 machine instruction to which it corresponds, with suffixes added as
13984 appropriate to distinguish intrinsics that expand to the same machine
13985 instruction yet have different argument types.  Refer to the architecture
13986 documentation for a description of the functionality of each
13987 instruction.
13989 @smallexample
13990 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13991 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13992 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13993 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13994 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13995 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13996 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13997 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13998 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13999 uint64_t paddd_u (uint64_t s, uint64_t t);
14000 int64_t paddd_s (int64_t s, int64_t t);
14001 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14002 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14003 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14004 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14005 uint64_t pandn_ud (uint64_t s, uint64_t t);
14006 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14007 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14008 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14009 int64_t pandn_sd (int64_t s, int64_t t);
14010 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14011 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14012 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14013 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14014 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14015 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14016 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14017 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14018 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14019 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14020 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14021 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14022 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14023 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14024 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14025 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14026 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14027 uint16x4_t pextrh_u (uint16x4_t s, int field);
14028 int16x4_t pextrh_s (int16x4_t s, int field);
14029 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14030 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14031 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14032 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14033 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14034 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14035 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14036 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14037 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14038 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14039 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14040 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14041 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14042 uint8x8_t pmovmskb_u (uint8x8_t s);
14043 int8x8_t pmovmskb_s (int8x8_t s);
14044 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14045 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14046 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14047 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14048 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14049 uint16x4_t biadd (uint8x8_t s);
14050 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14051 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14052 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14053 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14054 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14055 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14056 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14057 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14058 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14059 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14060 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14061 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14062 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14063 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14064 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14065 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14066 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14067 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14068 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14069 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14070 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14071 uint64_t psubd_u (uint64_t s, uint64_t t);
14072 int64_t psubd_s (int64_t s, int64_t t);
14073 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14074 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14075 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14076 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14077 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14078 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14079 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14080 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14081 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14082 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14083 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14084 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14085 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14086 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14087 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14088 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14089 @end smallexample
14091 @menu
14092 * Paired-Single Arithmetic::
14093 * Paired-Single Built-in Functions::
14094 * MIPS-3D Built-in Functions::
14095 @end menu
14097 @node Paired-Single Arithmetic
14098 @subsubsection Paired-Single Arithmetic
14100 The table below lists the @code{v2sf} operations for which hardware
14101 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14102 values and @code{x} is an integral value.
14104 @multitable @columnfractions .50 .50
14105 @item C code @tab MIPS instruction
14106 @item @code{a + b} @tab @code{add.ps}
14107 @item @code{a - b} @tab @code{sub.ps}
14108 @item @code{-a} @tab @code{neg.ps}
14109 @item @code{a * b} @tab @code{mul.ps}
14110 @item @code{a * b + c} @tab @code{madd.ps}
14111 @item @code{a * b - c} @tab @code{msub.ps}
14112 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14113 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14114 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14115 @end multitable
14117 Note that the multiply-accumulate instructions can be disabled
14118 using the command-line option @code{-mno-fused-madd}.
14120 @node Paired-Single Built-in Functions
14121 @subsubsection Paired-Single Built-in Functions
14123 The following paired-single functions map directly to a particular
14124 MIPS instruction.  Please refer to the architecture specification
14125 for details on what each instruction does.
14127 @table @code
14128 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14129 Pair lower lower (@code{pll.ps}).
14131 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14132 Pair upper lower (@code{pul.ps}).
14134 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14135 Pair lower upper (@code{plu.ps}).
14137 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14138 Pair upper upper (@code{puu.ps}).
14140 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14141 Convert pair to paired single (@code{cvt.ps.s}).
14143 @item float __builtin_mips_cvt_s_pl (v2sf)
14144 Convert pair lower to single (@code{cvt.s.pl}).
14146 @item float __builtin_mips_cvt_s_pu (v2sf)
14147 Convert pair upper to single (@code{cvt.s.pu}).
14149 @item v2sf __builtin_mips_abs_ps (v2sf)
14150 Absolute value (@code{abs.ps}).
14152 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14153 Align variable (@code{alnv.ps}).
14155 @emph{Note:} The value of the third parameter must be 0 or 4
14156 modulo 8, otherwise the result is unpredictable.  Please read the
14157 instruction description for details.
14158 @end table
14160 The following multi-instruction functions are also available.
14161 In each case, @var{cond} can be any of the 16 floating-point conditions:
14162 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14163 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14164 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14166 @table @code
14167 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14168 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14169 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14170 @code{movt.ps}/@code{movf.ps}).
14172 The @code{movt} functions return the value @var{x} computed by:
14174 @smallexample
14175 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14176 mov.ps @var{x},@var{c}
14177 movt.ps @var{x},@var{d},@var{cc}
14178 @end smallexample
14180 The @code{movf} functions are similar but use @code{movf.ps} instead
14181 of @code{movt.ps}.
14183 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14184 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14185 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14186 @code{bc1t}/@code{bc1f}).
14188 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14189 and return either the upper or lower half of the result.  For example:
14191 @smallexample
14192 v2sf a, b;
14193 if (__builtin_mips_upper_c_eq_ps (a, b))
14194   upper_halves_are_equal ();
14195 else
14196   upper_halves_are_unequal ();
14198 if (__builtin_mips_lower_c_eq_ps (a, b))
14199   lower_halves_are_equal ();
14200 else
14201   lower_halves_are_unequal ();
14202 @end smallexample
14203 @end table
14205 @node MIPS-3D Built-in Functions
14206 @subsubsection MIPS-3D Built-in Functions
14208 The MIPS-3D Application-Specific Extension (ASE) includes additional
14209 paired-single instructions that are designed to improve the performance
14210 of 3D graphics operations.  Support for these instructions is controlled
14211 by the @option{-mips3d} command-line option.
14213 The functions listed below map directly to a particular MIPS-3D
14214 instruction.  Please refer to the architecture specification for
14215 more details on what each instruction does.
14217 @table @code
14218 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14219 Reduction add (@code{addr.ps}).
14221 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14222 Reduction multiply (@code{mulr.ps}).
14224 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14225 Convert paired single to paired word (@code{cvt.pw.ps}).
14227 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14228 Convert paired word to paired single (@code{cvt.ps.pw}).
14230 @item float __builtin_mips_recip1_s (float)
14231 @itemx double __builtin_mips_recip1_d (double)
14232 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14233 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14235 @item float __builtin_mips_recip2_s (float, float)
14236 @itemx double __builtin_mips_recip2_d (double, double)
14237 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14238 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14240 @item float __builtin_mips_rsqrt1_s (float)
14241 @itemx double __builtin_mips_rsqrt1_d (double)
14242 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14243 Reduced-precision reciprocal square root (sequence step 1)
14244 (@code{rsqrt1.@var{fmt}}).
14246 @item float __builtin_mips_rsqrt2_s (float, float)
14247 @itemx double __builtin_mips_rsqrt2_d (double, double)
14248 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14249 Reduced-precision reciprocal square root (sequence step 2)
14250 (@code{rsqrt2.@var{fmt}}).
14251 @end table
14253 The following multi-instruction functions are also available.
14254 In each case, @var{cond} can be any of the 16 floating-point conditions:
14255 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14256 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14257 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14259 @table @code
14260 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14261 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14262 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14263 @code{bc1t}/@code{bc1f}).
14265 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14266 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14267 For example:
14269 @smallexample
14270 float a, b;
14271 if (__builtin_mips_cabs_eq_s (a, b))
14272   true ();
14273 else
14274   false ();
14275 @end smallexample
14277 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14278 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14279 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14280 @code{bc1t}/@code{bc1f}).
14282 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14283 and return either the upper or lower half of the result.  For example:
14285 @smallexample
14286 v2sf a, b;
14287 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14288   upper_halves_are_equal ();
14289 else
14290   upper_halves_are_unequal ();
14292 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14293   lower_halves_are_equal ();
14294 else
14295   lower_halves_are_unequal ();
14296 @end smallexample
14298 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14299 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14300 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14301 @code{movt.ps}/@code{movf.ps}).
14303 The @code{movt} functions return the value @var{x} computed by:
14305 @smallexample
14306 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14307 mov.ps @var{x},@var{c}
14308 movt.ps @var{x},@var{d},@var{cc}
14309 @end smallexample
14311 The @code{movf} functions are similar but use @code{movf.ps} instead
14312 of @code{movt.ps}.
14314 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14315 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14316 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14317 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14318 Comparison of two paired-single values
14319 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14320 @code{bc1any2t}/@code{bc1any2f}).
14322 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14323 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
14324 result is true and the @code{all} forms return true if both results are true.
14325 For example:
14327 @smallexample
14328 v2sf a, b;
14329 if (__builtin_mips_any_c_eq_ps (a, b))
14330   one_is_true ();
14331 else
14332   both_are_false ();
14334 if (__builtin_mips_all_c_eq_ps (a, b))
14335   both_are_true ();
14336 else
14337   one_is_false ();
14338 @end smallexample
14340 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14341 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14342 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14343 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14344 Comparison of four paired-single values
14345 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14346 @code{bc1any4t}/@code{bc1any4f}).
14348 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14349 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14350 The @code{any} forms return true if any of the four results are true
14351 and the @code{all} forms return true if all four results are true.
14352 For example:
14354 @smallexample
14355 v2sf a, b, c, d;
14356 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14357   some_are_true ();
14358 else
14359   all_are_false ();
14361 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14362   all_are_true ();
14363 else
14364   some_are_false ();
14365 @end smallexample
14366 @end table
14368 @node MIPS SIMD Architecture (MSA) Support
14369 @subsection MIPS SIMD Architecture (MSA) Support
14371 @menu
14372 * MIPS SIMD Architecture Built-in Functions::
14373 @end menu
14375 GCC provides intrinsics to access the SIMD instructions provided by the
14376 MSA MIPS SIMD Architecture.  The interface is made available by including
14377 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14378 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14379 @code{__msa_*}.
14381 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14382 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14383 data elements.  The following vectors typedefs are included in @code{msa.h}:
14384 @itemize
14385 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14386 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14387 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14388 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14389 @item @code{v4i32}, a vector of four signed 32-bit integers;
14390 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14391 @item @code{v2i64}, a vector of two signed 64-bit integers;
14392 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14393 @item @code{v4f32}, a vector of four 32-bit floats;
14394 @item @code{v2f64}, a vector of two 64-bit doubles.
14395 @end itemize
14397 Instructions and corresponding built-ins may have additional restrictions and/or
14398 input/output values manipulated:
14399 @itemize
14400 @item @code{imm0_1}, an integer literal in range 0 to 1;
14401 @item @code{imm0_3}, an integer literal in range 0 to 3;
14402 @item @code{imm0_7}, an integer literal in range 0 to 7;
14403 @item @code{imm0_15}, an integer literal in range 0 to 15;
14404 @item @code{imm0_31}, an integer literal in range 0 to 31;
14405 @item @code{imm0_63}, an integer literal in range 0 to 63;
14406 @item @code{imm0_255}, an integer literal in range 0 to 255;
14407 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14408 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14409 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14410 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14411 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14412 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14413 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14414 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14415 @item @code{imm1_4}, an integer literal in range 1 to 4;
14416 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14417 @end itemize
14419 @smallexample
14421 typedef int i32;
14422 #if __LONG_MAX__ == __LONG_LONG_MAX__
14423 typedef long i64;
14424 #else
14425 typedef long long i64;
14426 #endif
14428 typedef unsigned int u32;
14429 #if __LONG_MAX__ == __LONG_LONG_MAX__
14430 typedef unsigned long u64;
14431 #else
14432 typedef unsigned long long u64;
14433 #endif
14435 typedef double f64;
14436 typedef float f32;
14438 @end smallexample
14440 @node MIPS SIMD Architecture Built-in Functions
14441 @subsubsection MIPS SIMD Architecture Built-in Functions
14443 The intrinsics provided are listed below; each is named after the
14444 machine instruction.
14446 @smallexample
14447 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14448 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14449 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14450 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14452 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14453 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14454 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14455 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14457 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14458 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14459 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14460 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14462 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14463 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14464 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14465 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14467 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14468 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14469 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14470 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14472 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14473 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14474 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14475 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14477 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14479 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14481 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14482 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14483 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14484 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14486 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14487 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14488 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14489 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14491 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14492 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14493 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14494 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14496 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14497 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14498 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14499 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14501 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14502 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14503 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14504 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14506 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14507 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14508 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14509 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14511 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14512 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14513 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14514 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14516 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14517 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14518 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14519 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14521 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14522 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14523 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14524 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14526 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14527 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14528 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14529 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14531 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14532 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14533 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14534 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14536 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14537 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14538 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14539 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14541 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14543 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14545 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14547 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14549 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14550 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14551 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14552 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14554 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14555 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14556 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14557 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14559 i32 __builtin_msa_bnz_b (v16u8);
14560 i32 __builtin_msa_bnz_h (v8u16);
14561 i32 __builtin_msa_bnz_w (v4u32);
14562 i32 __builtin_msa_bnz_d (v2u64);
14564 i32 __builtin_msa_bnz_v (v16u8);
14566 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14568 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14570 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14571 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14572 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14573 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14575 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14576 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14577 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14578 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14580 i32 __builtin_msa_bz_b (v16u8);
14581 i32 __builtin_msa_bz_h (v8u16);
14582 i32 __builtin_msa_bz_w (v4u32);
14583 i32 __builtin_msa_bz_d (v2u64);
14585 i32 __builtin_msa_bz_v (v16u8);
14587 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14588 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14589 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14590 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14592 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14593 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14594 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14595 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14597 i32 __builtin_msa_cfcmsa (imm0_31);
14599 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14600 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14601 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14602 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14604 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14605 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14606 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14607 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14609 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14610 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14611 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14612 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14614 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14615 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14616 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14617 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14619 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14620 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14621 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14622 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14624 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14625 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14626 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14627 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14629 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14630 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14631 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14632 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14634 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14635 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14636 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14637 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14639 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14640 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14641 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14642 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14644 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14645 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14646 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14647 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14649 void __builtin_msa_ctcmsa (imm0_31, i32);
14651 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14652 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14653 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14654 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14656 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14657 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14658 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14659 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14661 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14662 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14663 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14665 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14666 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14667 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14669 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14670 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14671 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14673 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14674 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14675 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14677 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14678 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14679 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14681 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14682 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14683 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14685 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14686 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14688 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14689 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14691 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14692 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14694 v4i32 __builtin_msa_fclass_w (v4f32);
14695 v2i64 __builtin_msa_fclass_d (v2f64);
14697 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14698 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14700 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14701 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14703 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14704 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14706 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14707 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14709 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14710 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14712 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14713 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14715 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14716 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14718 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14719 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14721 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14722 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14724 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14725 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14727 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14728 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14730 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14731 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14733 v4f32 __builtin_msa_fexupl_w (v8i16);
14734 v2f64 __builtin_msa_fexupl_d (v4f32);
14736 v4f32 __builtin_msa_fexupr_w (v8i16);
14737 v2f64 __builtin_msa_fexupr_d (v4f32);
14739 v4f32 __builtin_msa_ffint_s_w (v4i32);
14740 v2f64 __builtin_msa_ffint_s_d (v2i64);
14742 v4f32 __builtin_msa_ffint_u_w (v4u32);
14743 v2f64 __builtin_msa_ffint_u_d (v2u64);
14745 v4f32 __builtin_msa_ffql_w (v8i16);
14746 v2f64 __builtin_msa_ffql_d (v4i32);
14748 v4f32 __builtin_msa_ffqr_w (v8i16);
14749 v2f64 __builtin_msa_ffqr_d (v4i32);
14751 v16i8 __builtin_msa_fill_b (i32);
14752 v8i16 __builtin_msa_fill_h (i32);
14753 v4i32 __builtin_msa_fill_w (i32);
14754 v2i64 __builtin_msa_fill_d (i64);
14756 v4f32 __builtin_msa_flog2_w (v4f32);
14757 v2f64 __builtin_msa_flog2_d (v2f64);
14759 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14760 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14762 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14763 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14765 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14766 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14768 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14769 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14771 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14772 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14774 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14775 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14777 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14778 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14780 v4f32 __builtin_msa_frint_w (v4f32);
14781 v2f64 __builtin_msa_frint_d (v2f64);
14783 v4f32 __builtin_msa_frcp_w (v4f32);
14784 v2f64 __builtin_msa_frcp_d (v2f64);
14786 v4f32 __builtin_msa_frsqrt_w (v4f32);
14787 v2f64 __builtin_msa_frsqrt_d (v2f64);
14789 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14790 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14792 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14793 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14795 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14796 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14798 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14799 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14801 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14802 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14804 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14805 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14807 v4f32 __builtin_msa_fsqrt_w (v4f32);
14808 v2f64 __builtin_msa_fsqrt_d (v2f64);
14810 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14811 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14813 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14814 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14816 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14817 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14819 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14820 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14822 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14823 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14825 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14826 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14828 v4i32 __builtin_msa_ftint_s_w (v4f32);
14829 v2i64 __builtin_msa_ftint_s_d (v2f64);
14831 v4u32 __builtin_msa_ftint_u_w (v4f32);
14832 v2u64 __builtin_msa_ftint_u_d (v2f64);
14834 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14835 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14837 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14838 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14840 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14841 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14843 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14844 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14845 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14847 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14848 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14849 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14851 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14852 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14853 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14855 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14856 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14857 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14859 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14860 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14861 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14862 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14864 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14865 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14866 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14867 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14869 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14870 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14871 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14872 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14874 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14875 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14876 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14877 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14879 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14880 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14881 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14882 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14884 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14885 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14886 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14887 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14889 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14890 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14891 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14892 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14894 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14895 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14896 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14897 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14899 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14900 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14902 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14903 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14905 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14906 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14907 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14908 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14910 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14911 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14912 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14913 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14915 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14916 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14917 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14918 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14920 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14921 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14922 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14923 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14925 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14926 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14927 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14928 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14930 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14931 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14932 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14933 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14935 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14936 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14937 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14938 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14940 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14941 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14942 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14943 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14945 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14946 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14947 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14948 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14950 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14951 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14952 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14953 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14955 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14956 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14957 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14958 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14960 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14961 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14962 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14963 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14965 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14966 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14967 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14968 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14970 v16i8 __builtin_msa_move_v (v16i8);
14972 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14973 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14975 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14976 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14978 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14979 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14980 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14981 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14983 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14984 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14986 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14987 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14989 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14990 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14991 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14992 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14994 v16i8 __builtin_msa_nloc_b (v16i8);
14995 v8i16 __builtin_msa_nloc_h (v8i16);
14996 v4i32 __builtin_msa_nloc_w (v4i32);
14997 v2i64 __builtin_msa_nloc_d (v2i64);
14999 v16i8 __builtin_msa_nlzc_b (v16i8);
15000 v8i16 __builtin_msa_nlzc_h (v8i16);
15001 v4i32 __builtin_msa_nlzc_w (v4i32);
15002 v2i64 __builtin_msa_nlzc_d (v2i64);
15004 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15006 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15008 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15010 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15012 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15013 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15014 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15015 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15017 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15018 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15019 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15020 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15022 v16i8 __builtin_msa_pcnt_b (v16i8);
15023 v8i16 __builtin_msa_pcnt_h (v8i16);
15024 v4i32 __builtin_msa_pcnt_w (v4i32);
15025 v2i64 __builtin_msa_pcnt_d (v2i64);
15027 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15028 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15029 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15030 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15032 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15033 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15034 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15035 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15037 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15038 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15039 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15041 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15042 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15043 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15044 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15046 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15047 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15048 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15049 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15051 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15052 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15053 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15054 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15056 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15057 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15058 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15059 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15061 v16i8 __builtin_msa_splat_b (v16i8, i32);
15062 v8i16 __builtin_msa_splat_h (v8i16, i32);
15063 v4i32 __builtin_msa_splat_w (v4i32, i32);
15064 v2i64 __builtin_msa_splat_d (v2i64, i32);
15066 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15067 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15068 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15069 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15071 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15072 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15073 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15074 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15076 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15077 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15078 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15079 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15081 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15082 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15083 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15084 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15086 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15087 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15088 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15089 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15091 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15092 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15093 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15094 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15096 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15097 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15098 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15099 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15101 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15102 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15103 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15104 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15106 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15107 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15108 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15109 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15111 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15112 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15113 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15114 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15116 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15117 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15118 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15119 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15121 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15122 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15123 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15124 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15126 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15127 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15128 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15129 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15131 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15132 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15133 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15134 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15136 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15137 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15138 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15139 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15141 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15142 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15143 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15144 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15146 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15147 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15148 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15149 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15151 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15153 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15154 @end smallexample
15156 @node Other MIPS Built-in Functions
15157 @subsection Other MIPS Built-in Functions
15159 GCC provides other MIPS-specific built-in functions:
15161 @table @code
15162 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15163 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15164 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15165 when this function is available.
15167 @item unsigned int __builtin_mips_get_fcsr (void)
15168 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15169 Get and set the contents of the floating-point control and status register
15170 (FPU control register 31).  These functions are only available in hard-float
15171 code but can be called in both MIPS16 and non-MIPS16 contexts.
15173 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15174 register except the condition codes, which GCC assumes are preserved.
15175 @end table
15177 @node MSP430 Built-in Functions
15178 @subsection MSP430 Built-in Functions
15180 GCC provides a couple of special builtin functions to aid in the
15181 writing of interrupt handlers in C.
15183 @table @code
15184 @item __bic_SR_register_on_exit (int @var{mask})
15185 This clears the indicated bits in the saved copy of the status register
15186 currently residing on the stack.  This only works inside interrupt
15187 handlers and the changes to the status register will only take affect
15188 once the handler returns.
15190 @item __bis_SR_register_on_exit (int @var{mask})
15191 This sets the indicated bits in the saved copy of the status register
15192 currently residing on the stack.  This only works inside interrupt
15193 handlers and the changes to the status register will only take affect
15194 once the handler returns.
15196 @item __delay_cycles (long long @var{cycles})
15197 This inserts an instruction sequence that takes exactly @var{cycles}
15198 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15199 may use jumps, loops, or no-ops, and does not interfere with any other
15200 instructions.  Note that @var{cycles} must be a compile-time constant
15201 integer - that is, you must pass a number, not a variable that may be
15202 optimized to a constant later.  The number of cycles delayed by this
15203 builtin is exact.
15204 @end table
15206 @node NDS32 Built-in Functions
15207 @subsection NDS32 Built-in Functions
15209 These built-in functions are available for the NDS32 target:
15211 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15212 Insert an ISYNC instruction into the instruction stream where
15213 @var{addr} is an instruction address for serialization.
15214 @end deftypefn
15216 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15217 Insert an ISB instruction into the instruction stream.
15218 @end deftypefn
15220 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15221 Return the content of a system register which is mapped by @var{sr}.
15222 @end deftypefn
15224 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15225 Return the content of a user space register which is mapped by @var{usr}.
15226 @end deftypefn
15228 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15229 Move the @var{value} to a system register which is mapped by @var{sr}.
15230 @end deftypefn
15232 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15233 Move the @var{value} to a user space register which is mapped by @var{usr}.
15234 @end deftypefn
15236 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15237 Enable global interrupt.
15238 @end deftypefn
15240 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15241 Disable global interrupt.
15242 @end deftypefn
15244 @node picoChip Built-in Functions
15245 @subsection picoChip Built-in Functions
15247 GCC provides an interface to selected machine instructions from the
15248 picoChip instruction set.
15250 @table @code
15251 @item int __builtin_sbc (int @var{value})
15252 Sign bit count.  Return the number of consecutive bits in @var{value}
15253 that have the same value as the sign bit.  The result is the number of
15254 leading sign bits minus one, giving the number of redundant sign bits in
15255 @var{value}.
15257 @item int __builtin_byteswap (int @var{value})
15258 Byte swap.  Return the result of swapping the upper and lower bytes of
15259 @var{value}.
15261 @item int __builtin_brev (int @var{value})
15262 Bit reversal.  Return the result of reversing the bits in
15263 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15264 and so on.
15266 @item int __builtin_adds (int @var{x}, int @var{y})
15267 Saturating addition.  Return the result of adding @var{x} and @var{y},
15268 storing the value 32767 if the result overflows.
15270 @item int __builtin_subs (int @var{x}, int @var{y})
15271 Saturating subtraction.  Return the result of subtracting @var{y} from
15272 @var{x}, storing the value @minus{}32768 if the result overflows.
15274 @item void __builtin_halt (void)
15275 Halt.  The processor stops execution.  This built-in is useful for
15276 implementing assertions.
15278 @end table
15280 @node PowerPC Built-in Functions
15281 @subsection PowerPC Built-in Functions
15283 The following built-in functions are always available and can be used to
15284 check the PowerPC target platform type:
15286 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15287 This function is a @code{nop} on the PowerPC platform and is included solely
15288 to maintain API compatibility with the x86 builtins.
15289 @end deftypefn
15291 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15292 This function returns a value of @code{1} if the run-time CPU is of type
15293 @var{cpuname} and returns @code{0} otherwise
15295 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15296 which exports the hardware capability bits.  GCC defines the macro
15297 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15298 built-in function is fully supported.
15300 If GCC was configured to use a GLIBC before 2.23, the built-in
15301 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15302 issues a warning.
15304 The following CPU names can be detected:
15306 @table @samp
15307 @item power9
15308 IBM POWER9 Server CPU.
15309 @item power8
15310 IBM POWER8 Server CPU.
15311 @item power7
15312 IBM POWER7 Server CPU.
15313 @item power6x
15314 IBM POWER6 Server CPU (RAW mode).
15315 @item power6
15316 IBM POWER6 Server CPU (Architected mode).
15317 @item power5+
15318 IBM POWER5+ Server CPU.
15319 @item power5
15320 IBM POWER5 Server CPU.
15321 @item ppc970
15322 IBM 970 Server CPU (ie, Apple G5).
15323 @item power4
15324 IBM POWER4 Server CPU.
15325 @item ppca2
15326 IBM A2 64-bit Embedded CPU
15327 @item ppc476
15328 IBM PowerPC 476FP 32-bit Embedded CPU.
15329 @item ppc464
15330 IBM PowerPC 464 32-bit Embedded CPU.
15331 @item ppc440
15332 PowerPC 440 32-bit Embedded CPU.
15333 @item ppc405
15334 PowerPC 405 32-bit Embedded CPU.
15335 @item ppc-cell-be
15336 IBM PowerPC Cell Broadband Engine Architecture CPU.
15337 @end table
15339 Here is an example:
15340 @smallexample
15341 #ifdef __BUILTIN_CPU_SUPPORTS__
15342   if (__builtin_cpu_is ("power8"))
15343     @{
15344        do_power8 (); // POWER8 specific implementation.
15345     @}
15346   else
15347 #endif
15348     @{
15349        do_generic (); // Generic implementation.
15350     @}
15351 @end smallexample
15352 @end deftypefn
15354 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15355 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15356 feature @var{feature} and returns @code{0} otherwise.
15358 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15359 newer which exports the hardware capability bits.  GCC defines the
15360 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15361 @code{__builtin_cpu_supports} built-in function is fully supported.
15363 If GCC was configured to use a GLIBC before 2.23, the built-in
15364 function @code{__builtin_cpu_suports} always returns a 0 and the
15365 compiler issues a warning.
15367 The following features can be
15368 detected:
15370 @table @samp
15371 @item 4xxmac
15372 4xx CPU has a Multiply Accumulator.
15373 @item altivec
15374 CPU has a SIMD/Vector Unit.
15375 @item arch_2_05
15376 CPU supports ISA 2.05 (eg, POWER6)
15377 @item arch_2_06
15378 CPU supports ISA 2.06 (eg, POWER7)
15379 @item arch_2_07
15380 CPU supports ISA 2.07 (eg, POWER8)
15381 @item arch_3_00
15382 CPU supports ISA 3.0 (eg, POWER9)
15383 @item archpmu
15384 CPU supports the set of compatible performance monitoring events.
15385 @item booke
15386 CPU supports the Embedded ISA category.
15387 @item cellbe
15388 CPU has a CELL broadband engine.
15389 @item dfp
15390 CPU has a decimal floating point unit.
15391 @item dscr
15392 CPU supports the data stream control register.
15393 @item ebb
15394 CPU supports event base branching.
15395 @item efpdouble
15396 CPU has a SPE double precision floating point unit.
15397 @item efpsingle
15398 CPU has a SPE single precision floating point unit.
15399 @item fpu
15400 CPU has a floating point unit.
15401 @item htm
15402 CPU has hardware transaction memory instructions.
15403 @item htm-nosc
15404 Kernel aborts hardware transactions when a syscall is made.
15405 @item ic_snoop
15406 CPU supports icache snooping capabilities.
15407 @item ieee128
15408 CPU supports 128-bit IEEE binary floating point instructions.
15409 @item isel
15410 CPU supports the integer select instruction.
15411 @item mmu
15412 CPU has a memory management unit.
15413 @item notb
15414 CPU does not have a timebase (eg, 601 and 403gx).
15415 @item pa6t
15416 CPU supports the PA Semi 6T CORE ISA.
15417 @item power4
15418 CPU supports ISA 2.00 (eg, POWER4)
15419 @item power5
15420 CPU supports ISA 2.02 (eg, POWER5)
15421 @item power5+
15422 CPU supports ISA 2.03 (eg, POWER5+)
15423 @item power6x
15424 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15425 @item ppc32
15426 CPU supports 32-bit mode execution.
15427 @item ppc601
15428 CPU supports the old POWER ISA (eg, 601)
15429 @item ppc64
15430 CPU supports 64-bit mode execution.
15431 @item ppcle
15432 CPU supports a little-endian mode that uses address swizzling.
15433 @item smt
15434 CPU support simultaneous multi-threading.
15435 @item spe
15436 CPU has a signal processing extension unit.
15437 @item tar
15438 CPU supports the target address register.
15439 @item true_le
15440 CPU supports true little-endian mode.
15441 @item ucache
15442 CPU has unified I/D cache.
15443 @item vcrypto
15444 CPU supports the vector cryptography instructions.
15445 @item vsx
15446 CPU supports the vector-scalar extension.
15447 @end table
15449 Here is an example:
15450 @smallexample
15451 #ifdef __BUILTIN_CPU_SUPPORTS__
15452   if (__builtin_cpu_supports ("fpu"))
15453     @{
15454        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15455     @}
15456   else
15457 #endif
15458     @{
15459        dst = __fadd (src1, src2); // Software FP addition function.
15460     @}
15461 @end smallexample
15462 @end deftypefn
15464 These built-in functions are available for the PowerPC family of
15465 processors:
15466 @smallexample
15467 float __builtin_recipdivf (float, float);
15468 float __builtin_rsqrtf (float);
15469 double __builtin_recipdiv (double, double);
15470 double __builtin_rsqrt (double);
15471 uint64_t __builtin_ppc_get_timebase ();
15472 unsigned long __builtin_ppc_mftb ();
15473 double __builtin_unpack_longdouble (long double, int);
15474 long double __builtin_pack_longdouble (double, double);
15475 @end smallexample
15477 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15478 @code{__builtin_rsqrtf} functions generate multiple instructions to
15479 implement the reciprocal sqrt functionality using reciprocal sqrt
15480 estimate instructions.
15482 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15483 functions generate multiple instructions to implement division using
15484 the reciprocal estimate instructions.
15486 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15487 functions generate instructions to read the Time Base Register.  The
15488 @code{__builtin_ppc_get_timebase} function may generate multiple
15489 instructions and always returns the 64 bits of the Time Base Register.
15490 The @code{__builtin_ppc_mftb} function always generates one instruction and
15491 returns the Time Base Register value as an unsigned long, throwing away
15492 the most significant word on 32-bit environments.
15494 Additional built-in functions are available for the 64-bit PowerPC
15495 family of processors, for efficient use of 128-bit floating point
15496 (@code{__float128}) values.
15498 The following floating-point built-in functions are available with
15499 @code{-mfloat128} and Altivec support.  All of them implement the
15500 function that is part of the name.
15502 @smallexample
15503 __float128 __builtin_fabsq (__float128)
15504 __float128 __builtin_copysignq (__float128, __float128)
15505 @end smallexample
15507 The following built-in functions are available with @code{-mfloat128}
15508 and Altivec support.
15510 @table @code
15511 @item __float128 __builtin_infq (void)
15512 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15513 @findex __builtin_infq
15515 @item __float128 __builtin_huge_valq (void)
15516 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15517 @findex __builtin_huge_valq
15519 @item __float128 __builtin_nanq (void)
15520 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
15521 @findex __builtin_nanq
15523 @item __float128 __builtin_nansq (void)
15524 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
15525 @findex __builtin_nansq
15526 @end table
15528 The following built-in functions are available on Linux 64-bit systems
15529 that use the ISA 3.0 instruction set.
15531 @table @code
15532 @item __float128 __builtin_sqrtf128 (__float128)
15533 Perform a 128-bit IEEE floating point square root operation.
15534 @findex __builtin_sqrtf128
15536 @item __float128 __builtin_fmaf128 (__float128, __float128, __float128)
15537 Perform a 128-bit IEEE floating point fused multiply and add operation.
15538 @findex __builtin_fmaf128
15540 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
15541 Perform a 128-bit IEEE floating point add using round to odd as the
15542 rounding mode.
15543 @findex __builtin_addf128_round_to_odd
15545 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
15546 Perform a 128-bit IEEE floating point subtract using round to odd as
15547 the rounding mode.
15548 @findex __builtin_subf128_round_to_odd
15550 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
15551 Perform a 128-bit IEEE floating point multiply using round to odd as
15552 the rounding mode.
15553 @findex __builtin_mulf128_round_to_odd
15555 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
15556 Perform a 128-bit IEEE floating point divide using round to odd as
15557 the rounding mode.
15558 @findex __builtin_divf128_round_to_odd
15560 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
15561 Perform a 128-bit IEEE floating point square root using round to odd
15562 as the rounding mode.
15563 @findex __builtin_sqrtf128_round_to_odd
15565 @item __float128 __builtin_fmaf128 (__float128, __float128, __float128)
15566 Perform a 128-bit IEEE floating point fused multiply and add operation
15567 using round to odd as the rounding mode.
15568 @findex __builtin_fmaf128_round_to_odd
15570 @item double __builtin_truncf128_round_to_odd (__float128)
15571 Convert a 128-bit IEEE floating point value to @code{double} using
15572 round to odd as the rounding mode.
15573 @findex __builtin_truncf128_round_to_odd
15574 @end table
15576 The following built-in functions are available for the PowerPC family
15577 of processors, starting with ISA 2.05 or later (@option{-mcpu=power6}
15578 or @option{-mcmpb}):
15579 @smallexample
15580 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15581 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15582 @end smallexample
15584 The @code{__builtin_cmpb} function
15585 performs a byte-wise compare on the contents of its two arguments,
15586 returning the result of the byte-wise comparison as the returned
15587 value.  For each byte comparison, the corresponding byte of the return
15588 value holds 0xff if the input bytes are equal and 0 if the input bytes
15589 are not equal.  If either of the arguments to this built-in function
15590 is wider than 32 bits, the function call expands into the form that
15591 expects @code{unsigned long long int} arguments
15592 which is only available on 64-bit targets.
15594 The following built-in functions are available for the PowerPC family
15595 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15596 or @option{-mpopcntd}):
15597 @smallexample
15598 long __builtin_bpermd (long, long);
15599 int __builtin_divwe (int, int);
15600 int __builtin_divweo (int, int);
15601 unsigned int __builtin_divweu (unsigned int, unsigned int);
15602 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15603 long __builtin_divde (long, long);
15604 long __builtin_divdeo (long, long);
15605 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15606 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15607 unsigned int cdtbcd (unsigned int);
15608 unsigned int cbcdtd (unsigned int);
15609 unsigned int addg6s (unsigned int, unsigned int);
15610 @end smallexample
15612 The @code{__builtin_divde}, @code{__builtin_divdeo},
15613 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15614 64-bit environment support ISA 2.06 or later.
15616 The following built-in functions are available for the PowerPC family
15617 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15618 @smallexample
15619 long long __builtin_darn (void);
15620 long long __builtin_darn_raw (void);
15621 int __builtin_darn_32 (void);
15623 unsigned int scalar_extract_exp (double source);
15624 unsigned long long int scalar_extract_exp (__ieee128 source);
15626 unsigned long long int scalar_extract_sig (double source);
15627 unsigned __int128 scalar_extract_sig (__ieee128 source);
15629 double
15630 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15631 double
15632 scalar_insert_exp (double significand, unsigned long long int exponent);
15634 ieee_128
15635 scalar_insert_exp (unsigned __int128 significand, unsigned long long int exponent);
15636 ieee_128
15637 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
15639 int scalar_cmp_exp_gt (double arg1, double arg2);
15640 int scalar_cmp_exp_lt (double arg1, double arg2);
15641 int scalar_cmp_exp_eq (double arg1, double arg2);
15642 int scalar_cmp_exp_unordered (double arg1, double arg2);
15644 bool scalar_test_data_class (float source, const int condition);
15645 bool scalar_test_data_class (double source, const int condition);
15646 bool scalar_test_data_class (__ieee128 source, const int condition);
15648 bool scalar_test_neg (float source);
15649 bool scalar_test_neg (double source);
15650 bool scalar_test_neg (__ieee128 source);
15652 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15653 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15654 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15656 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15657 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15658 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15659 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15661 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15662 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15663 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15664 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15666 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15667 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15668 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15669 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15671 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15672 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15673 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15674 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15675 @end smallexample
15677 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15678 functions require a
15679 64-bit environment supporting ISA 3.0 or later.
15680 The @code{__builtin_darn} function provides a 64-bit conditioned
15681 random number.  The @code{__builtin_darn_raw} function provides a
15682 64-bit raw random number.  The @code{__builtin_darn_32} function
15683 provides a 32-bit random number.
15685 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
15686 functions require a 64-bit environment supporting ISA 3.0 or later.
15687 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
15688 functions return the significand and the biased exponent value
15689 respectively of their @code{source} arguments.
15690 When supplied with a 64-bit @code{source} argument, the
15691 result returned by @code{scalar_extract_sig} has
15692 the @code{0x0010000000000000} bit set if the
15693 function's @code{source} argument is in normalized form.
15694 Otherwise, this bit is set to 0.
15695 When supplied with a 128-bit @code{source} argument, the
15696 @code{0x00010000000000000000000000000000} bit of the result is
15697 treated similarly.
15698 Note that the sign of the significand is not represented in the result
15699 returned from the @code{scalar_extract_sig} function.  Use the
15700 @code{scalar_test_neg} function to test the sign of its @code{double}
15701 argument.
15703 The @code{scalar_insert_exp}
15704 functions require a 64-bit environment supporting ISA 3.0 or later.
15705 When supplied with a 64-bit first argument, the
15706 @code{scalar_insert_exp} built-in function returns a double-precision
15707 floating point value that is constructed by assembling the values of its
15708 @code{significand} and @code{exponent} arguments.  The sign of the
15709 result is copied from the most significant bit of the
15710 @code{significand} argument.  The significand and exponent components
15711 of the result are composed of the least significant 11 bits of the
15712 @code{exponent} argument and the least significant 52 bits of the
15713 @code{significand} argument respectively.
15715 When supplied with a 128-bit first argument, the
15716 @code{scalar_insert_exp} built-in function returns a quad-precision
15717 ieee floating point value.  The sign bit of the result is copied from
15718 the most significant bit of the @code{significand} argument.
15719 The significand and exponent components of the result are composed of
15720 the least significant 15 bits of the @code{exponent} argument and the
15721 least significant 112 bits of the @code{significand} argument respectively.
15723 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15724 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15725 functions return a non-zero value if @code{arg1} is greater than, less
15726 than, equal to, or not comparable to @code{arg2} respectively.  The
15727 arguments are not comparable if one or the other equals NaN (not a
15728 number). 
15730 The @code{scalar_test_data_class} built-in function returns 1
15731 if any of the condition tests enabled by the value of the
15732 @code{condition} variable are true, and 0 otherwise.  The
15733 @code{condition} argument must be a compile-time constant integer with
15734 value not exceeding 127.  The
15735 @code{condition} argument is encoded as a bitmask with each bit
15736 enabling the testing of a different condition, as characterized by the
15737 following:
15738 @smallexample
15739 0x40    Test for NaN
15740 0x20    Test for +Infinity
15741 0x10    Test for -Infinity
15742 0x08    Test for +Zero
15743 0x04    Test for -Zero
15744 0x02    Test for +Denormal
15745 0x01    Test for -Denormal
15746 @end smallexample
15748 The @code{scalar_test_neg} built-in function returns 1 if its
15749 @code{source} argument holds a negative value, 0 otherwise.
15751 The @code{__builtin_byte_in_set} function requires a
15752 64-bit environment supporting ISA 3.0 or later.  This function returns
15753 a non-zero value if and only if its @code{u} argument exactly equals one of
15754 the eight bytes contained within its 64-bit @code{set} argument.
15756 The @code{__builtin_byte_in_range} and
15757 @code{__builtin_byte_in_either_range} require an environment
15758 supporting ISA 3.0 or later.  For these two functions, the
15759 @code{range} argument is encoded as 4 bytes, organized as
15760 @code{hi_1:lo_1:hi_2:lo_2}.
15761 The @code{__builtin_byte_in_range} function returns a
15762 non-zero value if and only if its @code{u} argument is within the
15763 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15764 The @code{__builtin_byte_in_either_range} function returns non-zero if
15765 and only if its @code{u} argument is within either the range bounded
15766 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15767 between @code{lo_2} and @code{hi_2} inclusive.
15769 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15770 if and only if the number of signficant digits of its @code{value} argument
15771 is less than its @code{comparison} argument.  The
15772 @code{__builtin_dfp_dtstsfi_lt_dd} and
15773 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15774 require that the type of the @code{value} argument be
15775 @code{__Decimal64} and @code{__Decimal128} respectively.
15777 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15778 if and only if the number of signficant digits of its @code{value} argument
15779 is greater than its @code{comparison} argument.  The
15780 @code{__builtin_dfp_dtstsfi_gt_dd} and
15781 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15782 require that the type of the @code{value} argument be
15783 @code{__Decimal64} and @code{__Decimal128} respectively.
15785 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15786 if and only if the number of signficant digits of its @code{value} argument
15787 equals its @code{comparison} argument.  The
15788 @code{__builtin_dfp_dtstsfi_eq_dd} and
15789 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15790 require that the type of the @code{value} argument be
15791 @code{__Decimal64} and @code{__Decimal128} respectively.
15793 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15794 if and only if its @code{value} argument has an undefined number of
15795 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15796 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15797 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15798 require that the type of the @code{value} argument be
15799 @code{__Decimal64} and @code{__Decimal128} respectively.
15801 The following built-in functions are also available for the PowerPC family
15802 of processors, starting with ISA 3.0 or later
15803 (@option{-mcpu=power9}).  These string functions are described
15804 separately in order to group the descriptions closer to the function
15805 prototypes:
15806 @smallexample
15807 int vec_all_nez (vector signed char, vector signed char);
15808 int vec_all_nez (vector unsigned char, vector unsigned char);
15809 int vec_all_nez (vector signed short, vector signed short);
15810 int vec_all_nez (vector unsigned short, vector unsigned short);
15811 int vec_all_nez (vector signed int, vector signed int);
15812 int vec_all_nez (vector unsigned int, vector unsigned int);
15814 int vec_any_eqz (vector signed char, vector signed char);
15815 int vec_any_eqz (vector unsigned char, vector unsigned char);
15816 int vec_any_eqz (vector signed short, vector signed short);
15817 int vec_any_eqz (vector unsigned short, vector unsigned short);
15818 int vec_any_eqz (vector signed int, vector signed int);
15819 int vec_any_eqz (vector unsigned int, vector unsigned int);
15821 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15822 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15823 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15824 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15825 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15826 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15828 vector signed char vec_cnttz (vector signed char);
15829 vector unsigned char vec_cnttz (vector unsigned char);
15830 vector signed short vec_cnttz (vector signed short);
15831 vector unsigned short vec_cnttz (vector unsigned short);
15832 vector signed int vec_cnttz (vector signed int);
15833 vector unsigned int vec_cnttz (vector unsigned int);
15834 vector signed long long vec_cnttz (vector signed long long);
15835 vector unsigned long long vec_cnttz (vector unsigned long long);
15837 signed int vec_cntlz_lsbb (vector signed char);
15838 signed int vec_cntlz_lsbb (vector unsigned char);
15840 signed int vec_cnttz_lsbb (vector signed char);
15841 signed int vec_cnttz_lsbb (vector unsigned char);
15843 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
15845 vector signed char vec_xl_be (signed long long, signed char *);
15846 vector unsigned char vec_xl_be (signed long long, unsigned char *);
15847 vector signed int vec_xl_be (signed long long, signed int *);
15848 vector unsigned int vec_xl_be (signed long long, unsigned int *);
15849 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
15850 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
15851 vector signed long long vec_xl_be (signed long long, signed long long *);
15852 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
15853 vector signed short vec_xl_be (signed long long, signed short *);
15854 vector unsigned short vec_xl_be (signed long long, unsigned short *);
15855 vector double vec_xl_be (signed long long, double *);
15856 vector float vec_xl_be (signed long long, float *);
15858 vector signed char vec_xl_len (signed char *addr, size_t len);
15859 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
15860 vector signed int vec_xl_len (signed int *addr, size_t len);
15861 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
15862 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
15863 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
15864 vector signed long long vec_xl_len (signed long long *addr, size_t len);
15865 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
15866 vector signed short vec_xl_len (signed short *addr, size_t len);
15867 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
15868 vector double vec_xl_len (double *addr, size_t len);
15869 vector float vec_xl_len (float *addr, size_t len);
15871 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
15873 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
15874 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
15875 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
15876 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
15877 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
15878 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
15879 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
15880 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
15881 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
15882 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
15883 void vec_xst_len (vector double data, double *addr, size_t len);
15884 void vec_xst_len (vector float data, float *addr, size_t len);
15886 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
15888 signed char vec_xlx (unsigned int index, vector signed char data);
15889 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
15890 signed short vec_xlx (unsigned int index, vector signed short data);
15891 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
15892 signed int vec_xlx (unsigned int index, vector signed int data);
15893 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
15894 float vec_xlx (unsigned int index, vector float data);
15896 signed char vec_xrx (unsigned int index, vector signed char data);
15897 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
15898 signed short vec_xrx (unsigned int index, vector signed short data);
15899 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
15900 signed int vec_xrx (unsigned int index, vector signed int data);
15901 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
15902 float vec_xrx (unsigned int index, vector float data);
15903 @end smallexample
15905 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
15906 perform pairwise comparisons between the elements at the same
15907 positions within their two vector arguments.
15908 The @code{vec_all_nez} function returns a
15909 non-zero value if and only if all pairwise comparisons are not
15910 equal and no element of either vector argument contains a zero.
15911 The @code{vec_any_eqz} function returns a
15912 non-zero value if and only if at least one pairwise comparison is equal
15913 or if at least one element of either vector argument contains a zero.
15914 The @code{vec_cmpnez} function returns a vector of the same type as
15915 its two arguments, within which each element consists of all ones to
15916 denote that either the corresponding elements of the incoming arguments are
15917 not equal or that at least one of the corresponding elements contains
15918 zero.  Otherwise, the element of the returned vector contains all zeros.
15920 The @code{vec_cntlz_lsbb} function returns the count of the number of
15921 consecutive leading byte elements (starting from position 0 within the
15922 supplied vector argument) for which the least-significant bit
15923 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
15924 the number of consecutive trailing byte elements (starting from
15925 position 15 and counting backwards within the supplied vector
15926 argument) for which the least-significant bit equals zero.
15928 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
15929 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
15930 function loads a variable length vector from memory.  The
15931 @code{vec_xst_len} function stores a variable length vector to memory.
15932 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
15933 @code{addr} argument represents the memory address to or from which
15934 data will be transferred, and the
15935 @code{len} argument represents the number of bytes to be
15936 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
15937 If this expression's value is not a multiple of the vector element's
15938 size, the behavior of this function is undefined.
15939 In the case that the underlying computer is configured to run in
15940 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
15941 the corresponding vector.  In little-endian mode, the data transfer
15942 moves bytes @code{(16 - len)} to @code{15} of the corresponding
15943 vector.  For the load function, any bytes of the result vector that
15944 are not loaded from memory are set to zero.
15945 The value of the @code{addr} argument need not be aligned on a
15946 multiple of the vector's element size.
15948 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
15949 element selected by the @code{index} argument from the vector
15950 represented by the @code{data} argument.  The @code{index} argument
15951 always specifies a byte offset, regardless of the size of the vector
15952 element.  With @code{vec_xlx}, @code{index} is the offset of the first
15953 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
15954 represents the last byte of the element to be extracted, measured
15955 from the right end of the vector.  In other words, the last byte of
15956 the element to be extracted is found at position @code{(15 - index)}.
15957 There is no requirement that @code{index} be a multiple of the vector
15958 element size.  However, if the size of the vector element added to
15959 @code{index} is greater than 15, the content of the returned value is
15960 undefined.
15962 The following built-in functions are available for the PowerPC family
15963 of processors when hardware decimal floating point
15964 (@option{-mhard-dfp}) is available:
15965 @smallexample
15966 long long __builtin_dxex (_Decimal64);
15967 long long __builtin_dxexq (_Decimal128);
15968 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15969 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15970 _Decimal64 __builtin_denbcd (int, _Decimal64);
15971 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15972 _Decimal64 __builtin_diex (long long, _Decimal64);
15973 _Decimal128 _builtin_diexq (long long, _Decimal128);
15974 _Decimal64 __builtin_dscli (_Decimal64, int);
15975 _Decimal128 __builtin_dscliq (_Decimal128, int);
15976 _Decimal64 __builtin_dscri (_Decimal64, int);
15977 _Decimal128 __builtin_dscriq (_Decimal128, int);
15978 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15979 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15980 @end smallexample
15982 The following built-in functions are available for the PowerPC family
15983 of processors when the Vector Scalar (vsx) instruction set is
15984 available:
15985 @smallexample
15986 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15987 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15988                                                 unsigned long long);
15989 @end smallexample
15991 @node PowerPC AltiVec/VSX Built-in Functions
15992 @subsection PowerPC AltiVec Built-in Functions
15994 GCC provides an interface for the PowerPC family of processors to access
15995 the AltiVec operations described in Motorola's AltiVec Programming
15996 Interface Manual.  The interface is made available by including
15997 @code{<altivec.h>} and using @option{-maltivec} and
15998 @option{-mabi=altivec}.  The interface supports the following vector
15999 types.
16001 @smallexample
16002 vector unsigned char
16003 vector signed char
16004 vector bool char
16006 vector unsigned short
16007 vector signed short
16008 vector bool short
16009 vector pixel
16011 vector unsigned int
16012 vector signed int
16013 vector bool int
16014 vector float
16015 @end smallexample
16017 If @option{-mvsx} is used the following additional vector types are
16018 implemented.
16020 @smallexample
16021 vector unsigned long
16022 vector signed long
16023 vector double
16024 @end smallexample
16026 The long types are only implemented for 64-bit code generation, and
16027 the long type is only used in the floating point/integer conversion
16028 instructions.
16030 GCC's implementation of the high-level language interface available from
16031 C and C++ code differs from Motorola's documentation in several ways.
16033 @itemize @bullet
16035 @item
16036 A vector constant is a list of constant expressions within curly braces.
16038 @item
16039 A vector initializer requires no cast if the vector constant is of the
16040 same type as the variable it is initializing.
16042 @item
16043 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16044 vector type is the default signedness of the base type.  The default
16045 varies depending on the operating system, so a portable program should
16046 always specify the signedness.
16048 @item
16049 Compiling with @option{-maltivec} adds keywords @code{__vector},
16050 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16051 @code{bool}.  When compiling ISO C, the context-sensitive substitution
16052 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16053 disabled.  To use them, you must include @code{<altivec.h>} instead.
16055 @item
16056 GCC allows using a @code{typedef} name as the type specifier for a
16057 vector type.
16059 @item
16060 For C, overloaded functions are implemented with macros so the following
16061 does not work:
16063 @smallexample
16064   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16065 @end smallexample
16067 @noindent
16068 Since @code{vec_add} is a macro, the vector constant in the example
16069 is treated as four separate arguments.  Wrap the entire argument in
16070 parentheses for this to work.
16071 @end itemize
16073 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16074 Internally, GCC uses built-in functions to achieve the functionality in
16075 the aforementioned header file, but they are not supported and are
16076 subject to change without notice.
16078 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16079 which may be found at
16080 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16081 Appendix A of this document lists the vector API interfaces that must be
16082 provided by compliant compilers.  Programmers should preferentially use
16083 the interfaces described therein.  However, historically GCC has provided
16084 additional interfaces for access to vector instructions.  These are
16085 briefly described below.
16087 The following interfaces are supported for the generic and specific
16088 AltiVec operations and the AltiVec predicates.  In cases where there
16089 is a direct mapping between generic and specific operations, only the
16090 generic names are shown here, although the specific operations can also
16091 be used.
16093 Arguments that are documented as @code{const int} require literal
16094 integral values within the range required for that operation.
16096 @smallexample
16097 vector signed char vec_abs (vector signed char);
16098 vector signed short vec_abs (vector signed short);
16099 vector signed int vec_abs (vector signed int);
16100 vector float vec_abs (vector float);
16102 vector signed char vec_abss (vector signed char);
16103 vector signed short vec_abss (vector signed short);
16104 vector signed int vec_abss (vector signed int);
16106 vector signed char vec_add (vector bool char, vector signed char);
16107 vector signed char vec_add (vector signed char, vector bool char);
16108 vector signed char vec_add (vector signed char, vector signed char);
16109 vector unsigned char vec_add (vector bool char, vector unsigned char);
16110 vector unsigned char vec_add (vector unsigned char, vector bool char);
16111 vector unsigned char vec_add (vector unsigned char,
16112                               vector unsigned char);
16113 vector signed short vec_add (vector bool short, vector signed short);
16114 vector signed short vec_add (vector signed short, vector bool short);
16115 vector signed short vec_add (vector signed short, vector signed short);
16116 vector unsigned short vec_add (vector bool short,
16117                                vector unsigned short);
16118 vector unsigned short vec_add (vector unsigned short,
16119                                vector bool short);
16120 vector unsigned short vec_add (vector unsigned short,
16121                                vector unsigned short);
16122 vector signed int vec_add (vector bool int, vector signed int);
16123 vector signed int vec_add (vector signed int, vector bool int);
16124 vector signed int vec_add (vector signed int, vector signed int);
16125 vector unsigned int vec_add (vector bool int, vector unsigned int);
16126 vector unsigned int vec_add (vector unsigned int, vector bool int);
16127 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16128 vector float vec_add (vector float, vector float);
16130 vector float vec_vaddfp (vector float, vector float);
16132 vector signed int vec_vadduwm (vector bool int, vector signed int);
16133 vector signed int vec_vadduwm (vector signed int, vector bool int);
16134 vector signed int vec_vadduwm (vector signed int, vector signed int);
16135 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
16136 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
16137 vector unsigned int vec_vadduwm (vector unsigned int,
16138                                  vector unsigned int);
16140 vector signed short vec_vadduhm (vector bool short,
16141                                  vector signed short);
16142 vector signed short vec_vadduhm (vector signed short,
16143                                  vector bool short);
16144 vector signed short vec_vadduhm (vector signed short,
16145                                  vector signed short);
16146 vector unsigned short vec_vadduhm (vector bool short,
16147                                    vector unsigned short);
16148 vector unsigned short vec_vadduhm (vector unsigned short,
16149                                    vector bool short);
16150 vector unsigned short vec_vadduhm (vector unsigned short,
16151                                    vector unsigned short);
16153 vector signed char vec_vaddubm (vector bool char, vector signed char);
16154 vector signed char vec_vaddubm (vector signed char, vector bool char);
16155 vector signed char vec_vaddubm (vector signed char, vector signed char);
16156 vector unsigned char vec_vaddubm (vector bool char,
16157                                   vector unsigned char);
16158 vector unsigned char vec_vaddubm (vector unsigned char,
16159                                   vector bool char);
16160 vector unsigned char vec_vaddubm (vector unsigned char,
16161                                   vector unsigned char);
16163 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16165 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16166 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16167 vector unsigned char vec_adds (vector unsigned char,
16168                                vector unsigned char);
16169 vector signed char vec_adds (vector bool char, vector signed char);
16170 vector signed char vec_adds (vector signed char, vector bool char);
16171 vector signed char vec_adds (vector signed char, vector signed char);
16172 vector unsigned short vec_adds (vector bool short,
16173                                 vector unsigned short);
16174 vector unsigned short vec_adds (vector unsigned short,
16175                                 vector bool short);
16176 vector unsigned short vec_adds (vector unsigned short,
16177                                 vector unsigned short);
16178 vector signed short vec_adds (vector bool short, vector signed short);
16179 vector signed short vec_adds (vector signed short, vector bool short);
16180 vector signed short vec_adds (vector signed short, vector signed short);
16181 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16182 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16183 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16184 vector signed int vec_adds (vector bool int, vector signed int);
16185 vector signed int vec_adds (vector signed int, vector bool int);
16186 vector signed int vec_adds (vector signed int, vector signed int);
16188 vector signed int vec_vaddsws (vector bool int, vector signed int);
16189 vector signed int vec_vaddsws (vector signed int, vector bool int);
16190 vector signed int vec_vaddsws (vector signed int, vector signed int);
16192 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
16193 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
16194 vector unsigned int vec_vadduws (vector unsigned int,
16195                                  vector unsigned int);
16197 vector signed short vec_vaddshs (vector bool short,
16198                                  vector signed short);
16199 vector signed short vec_vaddshs (vector signed short,
16200                                  vector bool short);
16201 vector signed short vec_vaddshs (vector signed short,
16202                                  vector signed short);
16204 vector unsigned short vec_vadduhs (vector bool short,
16205                                    vector unsigned short);
16206 vector unsigned short vec_vadduhs (vector unsigned short,
16207                                    vector bool short);
16208 vector unsigned short vec_vadduhs (vector unsigned short,
16209                                    vector unsigned short);
16211 vector signed char vec_vaddsbs (vector bool char, vector signed char);
16212 vector signed char vec_vaddsbs (vector signed char, vector bool char);
16213 vector signed char vec_vaddsbs (vector signed char, vector signed char);
16215 vector unsigned char vec_vaddubs (vector bool char,
16216                                   vector unsigned char);
16217 vector unsigned char vec_vaddubs (vector unsigned char,
16218                                   vector bool char);
16219 vector unsigned char vec_vaddubs (vector unsigned char,
16220                                   vector unsigned char);
16222 vector float vec_and (vector float, vector float);
16223 vector float vec_and (vector float, vector bool int);
16224 vector float vec_and (vector bool int, vector float);
16225 vector bool int vec_and (vector bool int, vector bool int);
16226 vector signed int vec_and (vector bool int, vector signed int);
16227 vector signed int vec_and (vector signed int, vector bool int);
16228 vector signed int vec_and (vector signed int, vector signed int);
16229 vector unsigned int vec_and (vector bool int, vector unsigned int);
16230 vector unsigned int vec_and (vector unsigned int, vector bool int);
16231 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16232 vector bool short vec_and (vector bool short, vector bool short);
16233 vector signed short vec_and (vector bool short, vector signed short);
16234 vector signed short vec_and (vector signed short, vector bool short);
16235 vector signed short vec_and (vector signed short, vector signed short);
16236 vector unsigned short vec_and (vector bool short,
16237                                vector unsigned short);
16238 vector unsigned short vec_and (vector unsigned short,
16239                                vector bool short);
16240 vector unsigned short vec_and (vector unsigned short,
16241                                vector unsigned short);
16242 vector signed char vec_and (vector bool char, vector signed char);
16243 vector bool char vec_and (vector bool char, vector bool char);
16244 vector signed char vec_and (vector signed char, vector bool char);
16245 vector signed char vec_and (vector signed char, vector signed char);
16246 vector unsigned char vec_and (vector bool char, vector unsigned char);
16247 vector unsigned char vec_and (vector unsigned char, vector bool char);
16248 vector unsigned char vec_and (vector unsigned char,
16249                               vector unsigned char);
16251 vector float vec_andc (vector float, vector float);
16252 vector float vec_andc (vector float, vector bool int);
16253 vector float vec_andc (vector bool int, vector float);
16254 vector bool int vec_andc (vector bool int, vector bool int);
16255 vector signed int vec_andc (vector bool int, vector signed int);
16256 vector signed int vec_andc (vector signed int, vector bool int);
16257 vector signed int vec_andc (vector signed int, vector signed int);
16258 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16259 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16260 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16261 vector bool short vec_andc (vector bool short, vector bool short);
16262 vector signed short vec_andc (vector bool short, vector signed short);
16263 vector signed short vec_andc (vector signed short, vector bool short);
16264 vector signed short vec_andc (vector signed short, vector signed short);
16265 vector unsigned short vec_andc (vector bool short,
16266                                 vector unsigned short);
16267 vector unsigned short vec_andc (vector unsigned short,
16268                                 vector bool short);
16269 vector unsigned short vec_andc (vector unsigned short,
16270                                 vector unsigned short);
16271 vector signed char vec_andc (vector bool char, vector signed char);
16272 vector bool char vec_andc (vector bool char, vector bool char);
16273 vector signed char vec_andc (vector signed char, vector bool char);
16274 vector signed char vec_andc (vector signed char, vector signed char);
16275 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16276 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16277 vector unsigned char vec_andc (vector unsigned char,
16278                                vector unsigned char);
16280 vector unsigned char vec_avg (vector unsigned char,
16281                               vector unsigned char);
16282 vector signed char vec_avg (vector signed char, vector signed char);
16283 vector unsigned short vec_avg (vector unsigned short,
16284                                vector unsigned short);
16285 vector signed short vec_avg (vector signed short, vector signed short);
16286 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16287 vector signed int vec_avg (vector signed int, vector signed int);
16289 vector signed int vec_vavgsw (vector signed int, vector signed int);
16291 vector unsigned int vec_vavguw (vector unsigned int,
16292                                 vector unsigned int);
16294 vector signed short vec_vavgsh (vector signed short,
16295                                 vector signed short);
16297 vector unsigned short vec_vavguh (vector unsigned short,
16298                                   vector unsigned short);
16300 vector signed char vec_vavgsb (vector signed char, vector signed char);
16302 vector unsigned char vec_vavgub (vector unsigned char,
16303                                  vector unsigned char);
16305 vector float vec_copysign (vector float);
16307 vector float vec_ceil (vector float);
16309 vector signed int vec_cmpb (vector float, vector float);
16311 vector bool char vec_cmpeq (vector bool char, vector bool char);
16312 vector bool short vec_cmpeq (vector bool short, vector bool short);
16313 vector bool int vec_cmpeq (vector bool int, vector bool int);
16314 vector bool char vec_cmpeq (vector signed char, vector signed char);
16315 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16316 vector bool short vec_cmpeq (vector signed short, vector signed short);
16317 vector bool short vec_cmpeq (vector unsigned short,
16318                              vector unsigned short);
16319 vector bool int vec_cmpeq (vector signed int, vector signed int);
16320 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16321 vector bool int vec_cmpeq (vector float, vector float);
16323 vector bool int vec_vcmpeqfp (vector float, vector float);
16325 vector bool int vec_vcmpequw (vector signed int, vector signed int);
16326 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
16328 vector bool short vec_vcmpequh (vector signed short,
16329                                 vector signed short);
16330 vector bool short vec_vcmpequh (vector unsigned short,
16331                                 vector unsigned short);
16333 vector bool char vec_vcmpequb (vector signed char, vector signed char);
16334 vector bool char vec_vcmpequb (vector unsigned char,
16335                                vector unsigned char);
16337 vector bool int vec_cmpge (vector float, vector float);
16339 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16340 vector bool char vec_cmpgt (vector signed char, vector signed char);
16341 vector bool short vec_cmpgt (vector unsigned short,
16342                              vector unsigned short);
16343 vector bool short vec_cmpgt (vector signed short, vector signed short);
16344 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16345 vector bool int vec_cmpgt (vector signed int, vector signed int);
16346 vector bool int vec_cmpgt (vector float, vector float);
16348 vector bool int vec_vcmpgtfp (vector float, vector float);
16350 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
16352 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
16354 vector bool short vec_vcmpgtsh (vector signed short,
16355                                 vector signed short);
16357 vector bool short vec_vcmpgtuh (vector unsigned short,
16358                                 vector unsigned short);
16360 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
16362 vector bool char vec_vcmpgtub (vector unsigned char,
16363                                vector unsigned char);
16365 vector bool int vec_cmple (vector float, vector float);
16367 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16368 vector bool char vec_cmplt (vector signed char, vector signed char);
16369 vector bool short vec_cmplt (vector unsigned short,
16370                              vector unsigned short);
16371 vector bool short vec_cmplt (vector signed short, vector signed short);
16372 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16373 vector bool int vec_cmplt (vector signed int, vector signed int);
16374 vector bool int vec_cmplt (vector float, vector float);
16376 vector float vec_cpsgn (vector float, vector float);
16378 vector float vec_ctf (vector unsigned int, const int);
16379 vector float vec_ctf (vector signed int, const int);
16380 vector double vec_ctf (vector unsigned long, const int);
16381 vector double vec_ctf (vector signed long, const int);
16383 vector float vec_vcfsx (vector signed int, const int);
16385 vector float vec_vcfux (vector unsigned int, const int);
16387 vector signed int vec_cts (vector float, const int);
16388 vector signed long vec_cts (vector double, const int);
16390 vector unsigned int vec_ctu (vector float, const int);
16391 vector unsigned long vec_ctu (vector double, const int);
16393 vector double vec_doublee (vector float);
16394 vector double vec_doublee (vector signed int);
16395 vector double vec_doublee (vector unsigned int);
16397 vector double vec_doubleo (vector float);
16398 vector double vec_doubleo (vector signed int);
16399 vector double vec_doubleo (vector unsigned int);
16401 vector double vec_doubleh (vector float);
16402 vector double vec_doubleh (vector signed int);
16403 vector double vec_doubleh (vector unsigned int);
16405 vector double vec_doublel (vector float);
16406 vector double vec_doublel (vector signed int);
16407 vector double vec_doublel (vector unsigned int);
16409 void vec_dss (const int);
16411 void vec_dssall (void);
16413 void vec_dst (const vector unsigned char *, int, const int);
16414 void vec_dst (const vector signed char *, int, const int);
16415 void vec_dst (const vector bool char *, int, const int);
16416 void vec_dst (const vector unsigned short *, int, const int);
16417 void vec_dst (const vector signed short *, int, const int);
16418 void vec_dst (const vector bool short *, int, const int);
16419 void vec_dst (const vector pixel *, int, const int);
16420 void vec_dst (const vector unsigned int *, int, const int);
16421 void vec_dst (const vector signed int *, int, const int);
16422 void vec_dst (const vector bool int *, int, const int);
16423 void vec_dst (const vector float *, int, const int);
16424 void vec_dst (const unsigned char *, int, const int);
16425 void vec_dst (const signed char *, int, const int);
16426 void vec_dst (const unsigned short *, int, const int);
16427 void vec_dst (const short *, int, const int);
16428 void vec_dst (const unsigned int *, int, const int);
16429 void vec_dst (const int *, int, const int);
16430 void vec_dst (const unsigned long *, int, const int);
16431 void vec_dst (const long *, int, const int);
16432 void vec_dst (const float *, int, const int);
16434 void vec_dstst (const vector unsigned char *, int, const int);
16435 void vec_dstst (const vector signed char *, int, const int);
16436 void vec_dstst (const vector bool char *, int, const int);
16437 void vec_dstst (const vector unsigned short *, int, const int);
16438 void vec_dstst (const vector signed short *, int, const int);
16439 void vec_dstst (const vector bool short *, int, const int);
16440 void vec_dstst (const vector pixel *, int, const int);
16441 void vec_dstst (const vector unsigned int *, int, const int);
16442 void vec_dstst (const vector signed int *, int, const int);
16443 void vec_dstst (const vector bool int *, int, const int);
16444 void vec_dstst (const vector float *, int, const int);
16445 void vec_dstst (const unsigned char *, int, const int);
16446 void vec_dstst (const signed char *, int, const int);
16447 void vec_dstst (const unsigned short *, int, const int);
16448 void vec_dstst (const short *, int, const int);
16449 void vec_dstst (const unsigned int *, int, const int);
16450 void vec_dstst (const int *, int, const int);
16451 void vec_dstst (const unsigned long *, int, const int);
16452 void vec_dstst (const long *, int, const int);
16453 void vec_dstst (const float *, int, const int);
16455 void vec_dststt (const vector unsigned char *, int, const int);
16456 void vec_dststt (const vector signed char *, int, const int);
16457 void vec_dststt (const vector bool char *, int, const int);
16458 void vec_dststt (const vector unsigned short *, int, const int);
16459 void vec_dststt (const vector signed short *, int, const int);
16460 void vec_dststt (const vector bool short *, int, const int);
16461 void vec_dststt (const vector pixel *, int, const int);
16462 void vec_dststt (const vector unsigned int *, int, const int);
16463 void vec_dststt (const vector signed int *, int, const int);
16464 void vec_dststt (const vector bool int *, int, const int);
16465 void vec_dststt (const vector float *, int, const int);
16466 void vec_dststt (const unsigned char *, int, const int);
16467 void vec_dststt (const signed char *, int, const int);
16468 void vec_dststt (const unsigned short *, int, const int);
16469 void vec_dststt (const short *, int, const int);
16470 void vec_dststt (const unsigned int *, int, const int);
16471 void vec_dststt (const int *, int, const int);
16472 void vec_dststt (const unsigned long *, int, const int);
16473 void vec_dststt (const long *, int, const int);
16474 void vec_dststt (const float *, int, const int);
16476 void vec_dstt (const vector unsigned char *, int, const int);
16477 void vec_dstt (const vector signed char *, int, const int);
16478 void vec_dstt (const vector bool char *, int, const int);
16479 void vec_dstt (const vector unsigned short *, int, const int);
16480 void vec_dstt (const vector signed short *, int, const int);
16481 void vec_dstt (const vector bool short *, int, const int);
16482 void vec_dstt (const vector pixel *, int, const int);
16483 void vec_dstt (const vector unsigned int *, int, const int);
16484 void vec_dstt (const vector signed int *, int, const int);
16485 void vec_dstt (const vector bool int *, int, const int);
16486 void vec_dstt (const vector float *, int, const int);
16487 void vec_dstt (const unsigned char *, int, const int);
16488 void vec_dstt (const signed char *, int, const int);
16489 void vec_dstt (const unsigned short *, int, const int);
16490 void vec_dstt (const short *, int, const int);
16491 void vec_dstt (const unsigned int *, int, const int);
16492 void vec_dstt (const int *, int, const int);
16493 void vec_dstt (const unsigned long *, int, const int);
16494 void vec_dstt (const long *, int, const int);
16495 void vec_dstt (const float *, int, const int);
16497 vector float vec_expte (vector float);
16499 vector float vec_floor (vector float);
16501 vector float vec_float (vector signed int);
16502 vector float vec_float (vector unsigned int);
16504 vector float vec_float2 (vector signed long long, vector signed long long);
16505 vector float vec_float2 (vector unsigned long long, vector signed long long);
16507 vector float vec_floate (vector double);
16508 vector float vec_floate (vector signed long long);
16509 vector float vec_floate (vector unsigned long long);
16511 vector float vec_floato (vector double);
16512 vector float vec_floato (vector signed long long);
16513 vector float vec_floato (vector unsigned long long);
16515 vector float vec_ld (int, const vector float *);
16516 vector float vec_ld (int, const float *);
16517 vector bool int vec_ld (int, const vector bool int *);
16518 vector signed int vec_ld (int, const vector signed int *);
16519 vector signed int vec_ld (int, const int *);
16520 vector signed int vec_ld (int, const long *);
16521 vector unsigned int vec_ld (int, const vector unsigned int *);
16522 vector unsigned int vec_ld (int, const unsigned int *);
16523 vector unsigned int vec_ld (int, const unsigned long *);
16524 vector bool short vec_ld (int, const vector bool short *);
16525 vector pixel vec_ld (int, const vector pixel *);
16526 vector signed short vec_ld (int, const vector signed short *);
16527 vector signed short vec_ld (int, const short *);
16528 vector unsigned short vec_ld (int, const vector unsigned short *);
16529 vector unsigned short vec_ld (int, const unsigned short *);
16530 vector bool char vec_ld (int, const vector bool char *);
16531 vector signed char vec_ld (int, const vector signed char *);
16532 vector signed char vec_ld (int, const signed char *);
16533 vector unsigned char vec_ld (int, const vector unsigned char *);
16534 vector unsigned char vec_ld (int, const unsigned char *);
16536 vector signed char vec_lde (int, const signed char *);
16537 vector unsigned char vec_lde (int, const unsigned char *);
16538 vector signed short vec_lde (int, const short *);
16539 vector unsigned short vec_lde (int, const unsigned short *);
16540 vector float vec_lde (int, const float *);
16541 vector signed int vec_lde (int, const int *);
16542 vector unsigned int vec_lde (int, const unsigned int *);
16543 vector signed int vec_lde (int, const long *);
16544 vector unsigned int vec_lde (int, const unsigned long *);
16546 vector float vec_lvewx (int, float *);
16547 vector signed int vec_lvewx (int, int *);
16548 vector unsigned int vec_lvewx (int, unsigned int *);
16549 vector signed int vec_lvewx (int, long *);
16550 vector unsigned int vec_lvewx (int, unsigned long *);
16552 vector signed short vec_lvehx (int, short *);
16553 vector unsigned short vec_lvehx (int, unsigned short *);
16555 vector signed char vec_lvebx (int, char *);
16556 vector unsigned char vec_lvebx (int, unsigned char *);
16558 vector float vec_ldl (int, const vector float *);
16559 vector float vec_ldl (int, const float *);
16560 vector bool int vec_ldl (int, const vector bool int *);
16561 vector signed int vec_ldl (int, const vector signed int *);
16562 vector signed int vec_ldl (int, const int *);
16563 vector signed int vec_ldl (int, const long *);
16564 vector unsigned int vec_ldl (int, const vector unsigned int *);
16565 vector unsigned int vec_ldl (int, const unsigned int *);
16566 vector unsigned int vec_ldl (int, const unsigned long *);
16567 vector bool short vec_ldl (int, const vector bool short *);
16568 vector pixel vec_ldl (int, const vector pixel *);
16569 vector signed short vec_ldl (int, const vector signed short *);
16570 vector signed short vec_ldl (int, const short *);
16571 vector unsigned short vec_ldl (int, const vector unsigned short *);
16572 vector unsigned short vec_ldl (int, const unsigned short *);
16573 vector bool char vec_ldl (int, const vector bool char *);
16574 vector signed char vec_ldl (int, const vector signed char *);
16575 vector signed char vec_ldl (int, const signed char *);
16576 vector unsigned char vec_ldl (int, const vector unsigned char *);
16577 vector unsigned char vec_ldl (int, const unsigned char *);
16579 vector float vec_loge (vector float);
16581 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16582 vector unsigned char vec_lvsl (int, const volatile signed char *);
16583 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16584 vector unsigned char vec_lvsl (int, const volatile short *);
16585 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16586 vector unsigned char vec_lvsl (int, const volatile int *);
16587 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16588 vector unsigned char vec_lvsl (int, const volatile long *);
16589 vector unsigned char vec_lvsl (int, const volatile float *);
16591 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16592 vector unsigned char vec_lvsr (int, const volatile signed char *);
16593 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16594 vector unsigned char vec_lvsr (int, const volatile short *);
16595 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16596 vector unsigned char vec_lvsr (int, const volatile int *);
16597 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16598 vector unsigned char vec_lvsr (int, const volatile long *);
16599 vector unsigned char vec_lvsr (int, const volatile float *);
16601 vector float vec_madd (vector float, vector float, vector float);
16603 vector signed short vec_madds (vector signed short,
16604                                vector signed short,
16605                                vector signed short);
16607 vector unsigned char vec_max (vector bool char, vector unsigned char);
16608 vector unsigned char vec_max (vector unsigned char, vector bool char);
16609 vector unsigned char vec_max (vector unsigned char,
16610                               vector unsigned char);
16611 vector signed char vec_max (vector bool char, vector signed char);
16612 vector signed char vec_max (vector signed char, vector bool char);
16613 vector signed char vec_max (vector signed char, vector signed char);
16614 vector unsigned short vec_max (vector bool short,
16615                                vector unsigned short);
16616 vector unsigned short vec_max (vector unsigned short,
16617                                vector bool short);
16618 vector unsigned short vec_max (vector unsigned short,
16619                                vector unsigned short);
16620 vector signed short vec_max (vector bool short, vector signed short);
16621 vector signed short vec_max (vector signed short, vector bool short);
16622 vector signed short vec_max (vector signed short, vector signed short);
16623 vector unsigned int vec_max (vector bool int, vector unsigned int);
16624 vector unsigned int vec_max (vector unsigned int, vector bool int);
16625 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16626 vector signed int vec_max (vector bool int, vector signed int);
16627 vector signed int vec_max (vector signed int, vector bool int);
16628 vector signed int vec_max (vector signed int, vector signed int);
16629 vector float vec_max (vector float, vector float);
16631 vector float vec_vmaxfp (vector float, vector float);
16633 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16634 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16635 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16637 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16638 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16639 vector unsigned int vec_vmaxuw (vector unsigned int,
16640                                 vector unsigned int);
16642 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16643 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16644 vector signed short vec_vmaxsh (vector signed short,
16645                                 vector signed short);
16647 vector unsigned short vec_vmaxuh (vector bool short,
16648                                   vector unsigned short);
16649 vector unsigned short vec_vmaxuh (vector unsigned short,
16650                                   vector bool short);
16651 vector unsigned short vec_vmaxuh (vector unsigned short,
16652                                   vector unsigned short);
16654 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16655 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16656 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16658 vector unsigned char vec_vmaxub (vector bool char,
16659                                  vector unsigned char);
16660 vector unsigned char vec_vmaxub (vector unsigned char,
16661                                  vector bool char);
16662 vector unsigned char vec_vmaxub (vector unsigned char,
16663                                  vector unsigned char);
16665 vector bool char vec_mergeh (vector bool char, vector bool char);
16666 vector signed char vec_mergeh (vector signed char, vector signed char);
16667 vector unsigned char vec_mergeh (vector unsigned char,
16668                                  vector unsigned char);
16669 vector bool short vec_mergeh (vector bool short, vector bool short);
16670 vector pixel vec_mergeh (vector pixel, vector pixel);
16671 vector signed short vec_mergeh (vector signed short,
16672                                 vector signed short);
16673 vector unsigned short vec_mergeh (vector unsigned short,
16674                                   vector unsigned short);
16675 vector float vec_mergeh (vector float, vector float);
16676 vector bool int vec_mergeh (vector bool int, vector bool int);
16677 vector signed int vec_mergeh (vector signed int, vector signed int);
16678 vector unsigned int vec_mergeh (vector unsigned int,
16679                                 vector unsigned int);
16681 vector float vec_vmrghw (vector float, vector float);
16682 vector bool int vec_vmrghw (vector bool int, vector bool int);
16683 vector signed int vec_vmrghw (vector signed int, vector signed int);
16684 vector unsigned int vec_vmrghw (vector unsigned int,
16685                                 vector unsigned int);
16687 vector bool short vec_vmrghh (vector bool short, vector bool short);
16688 vector signed short vec_vmrghh (vector signed short,
16689                                 vector signed short);
16690 vector unsigned short vec_vmrghh (vector unsigned short,
16691                                   vector unsigned short);
16692 vector pixel vec_vmrghh (vector pixel, vector pixel);
16694 vector bool char vec_vmrghb (vector bool char, vector bool char);
16695 vector signed char vec_vmrghb (vector signed char, vector signed char);
16696 vector unsigned char vec_vmrghb (vector unsigned char,
16697                                  vector unsigned char);
16699 vector bool char vec_mergel (vector bool char, vector bool char);
16700 vector signed char vec_mergel (vector signed char, vector signed char);
16701 vector unsigned char vec_mergel (vector unsigned char,
16702                                  vector unsigned char);
16703 vector bool short vec_mergel (vector bool short, vector bool short);
16704 vector pixel vec_mergel (vector pixel, vector pixel);
16705 vector signed short vec_mergel (vector signed short,
16706                                 vector signed short);
16707 vector unsigned short vec_mergel (vector unsigned short,
16708                                   vector unsigned short);
16709 vector float vec_mergel (vector float, vector float);
16710 vector bool int vec_mergel (vector bool int, vector bool int);
16711 vector signed int vec_mergel (vector signed int, vector signed int);
16712 vector unsigned int vec_mergel (vector unsigned int,
16713                                 vector unsigned int);
16715 vector float vec_vmrglw (vector float, vector float);
16716 vector signed int vec_vmrglw (vector signed int, vector signed int);
16717 vector unsigned int vec_vmrglw (vector unsigned int,
16718                                 vector unsigned int);
16719 vector bool int vec_vmrglw (vector bool int, vector bool int);
16721 vector bool short vec_vmrglh (vector bool short, vector bool short);
16722 vector signed short vec_vmrglh (vector signed short,
16723                                 vector signed short);
16724 vector unsigned short vec_vmrglh (vector unsigned short,
16725                                   vector unsigned short);
16726 vector pixel vec_vmrglh (vector pixel, vector pixel);
16728 vector bool char vec_vmrglb (vector bool char, vector bool char);
16729 vector signed char vec_vmrglb (vector signed char, vector signed char);
16730 vector unsigned char vec_vmrglb (vector unsigned char,
16731                                  vector unsigned char);
16733 vector unsigned short vec_mfvscr (void);
16735 vector unsigned char vec_min (vector bool char, vector unsigned char);
16736 vector unsigned char vec_min (vector unsigned char, vector bool char);
16737 vector unsigned char vec_min (vector unsigned char,
16738                               vector unsigned char);
16739 vector signed char vec_min (vector bool char, vector signed char);
16740 vector signed char vec_min (vector signed char, vector bool char);
16741 vector signed char vec_min (vector signed char, vector signed char);
16742 vector unsigned short vec_min (vector bool short,
16743                                vector unsigned short);
16744 vector unsigned short vec_min (vector unsigned short,
16745                                vector bool short);
16746 vector unsigned short vec_min (vector unsigned short,
16747                                vector unsigned short);
16748 vector signed short vec_min (vector bool short, vector signed short);
16749 vector signed short vec_min (vector signed short, vector bool short);
16750 vector signed short vec_min (vector signed short, vector signed short);
16751 vector unsigned int vec_min (vector bool int, vector unsigned int);
16752 vector unsigned int vec_min (vector unsigned int, vector bool int);
16753 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16754 vector signed int vec_min (vector bool int, vector signed int);
16755 vector signed int vec_min (vector signed int, vector bool int);
16756 vector signed int vec_min (vector signed int, vector signed int);
16757 vector float vec_min (vector float, vector float);
16759 vector float vec_vminfp (vector float, vector float);
16761 vector signed int vec_vminsw (vector bool int, vector signed int);
16762 vector signed int vec_vminsw (vector signed int, vector bool int);
16763 vector signed int vec_vminsw (vector signed int, vector signed int);
16765 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16766 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16767 vector unsigned int vec_vminuw (vector unsigned int,
16768                                 vector unsigned int);
16770 vector signed short vec_vminsh (vector bool short, vector signed short);
16771 vector signed short vec_vminsh (vector signed short, vector bool short);
16772 vector signed short vec_vminsh (vector signed short,
16773                                 vector signed short);
16775 vector unsigned short vec_vminuh (vector bool short,
16776                                   vector unsigned short);
16777 vector unsigned short vec_vminuh (vector unsigned short,
16778                                   vector bool short);
16779 vector unsigned short vec_vminuh (vector unsigned short,
16780                                   vector unsigned short);
16782 vector signed char vec_vminsb (vector bool char, vector signed char);
16783 vector signed char vec_vminsb (vector signed char, vector bool char);
16784 vector signed char vec_vminsb (vector signed char, vector signed char);
16786 vector unsigned char vec_vminub (vector bool char,
16787                                  vector unsigned char);
16788 vector unsigned char vec_vminub (vector unsigned char,
16789                                  vector bool char);
16790 vector unsigned char vec_vminub (vector unsigned char,
16791                                  vector unsigned char);
16793 vector signed short vec_mladd (vector signed short,
16794                                vector signed short,
16795                                vector signed short);
16796 vector signed short vec_mladd (vector signed short,
16797                                vector unsigned short,
16798                                vector unsigned short);
16799 vector signed short vec_mladd (vector unsigned short,
16800                                vector signed short,
16801                                vector signed short);
16802 vector unsigned short vec_mladd (vector unsigned short,
16803                                  vector unsigned short,
16804                                  vector unsigned short);
16806 vector signed short vec_mradds (vector signed short,
16807                                 vector signed short,
16808                                 vector signed short);
16810 vector unsigned int vec_msum (vector unsigned char,
16811                               vector unsigned char,
16812                               vector unsigned int);
16813 vector signed int vec_msum (vector signed char,
16814                             vector unsigned char,
16815                             vector signed int);
16816 vector unsigned int vec_msum (vector unsigned short,
16817                               vector unsigned short,
16818                               vector unsigned int);
16819 vector signed int vec_msum (vector signed short,
16820                             vector signed short,
16821                             vector signed int);
16823 vector signed int vec_vmsumshm (vector signed short,
16824                                 vector signed short,
16825                                 vector signed int);
16827 vector unsigned int vec_vmsumuhm (vector unsigned short,
16828                                   vector unsigned short,
16829                                   vector unsigned int);
16831 vector signed int vec_vmsummbm (vector signed char,
16832                                 vector unsigned char,
16833                                 vector signed int);
16835 vector unsigned int vec_vmsumubm (vector unsigned char,
16836                                   vector unsigned char,
16837                                   vector unsigned int);
16839 vector unsigned int vec_msums (vector unsigned short,
16840                                vector unsigned short,
16841                                vector unsigned int);
16842 vector signed int vec_msums (vector signed short,
16843                              vector signed short,
16844                              vector signed int);
16846 vector signed int vec_vmsumshs (vector signed short,
16847                                 vector signed short,
16848                                 vector signed int);
16850 vector unsigned int vec_vmsumuhs (vector unsigned short,
16851                                   vector unsigned short,
16852                                   vector unsigned int);
16854 void vec_mtvscr (vector signed int);
16855 void vec_mtvscr (vector unsigned int);
16856 void vec_mtvscr (vector bool int);
16857 void vec_mtvscr (vector signed short);
16858 void vec_mtvscr (vector unsigned short);
16859 void vec_mtvscr (vector bool short);
16860 void vec_mtvscr (vector pixel);
16861 void vec_mtvscr (vector signed char);
16862 void vec_mtvscr (vector unsigned char);
16863 void vec_mtvscr (vector bool char);
16865 vector unsigned short vec_mule (vector unsigned char,
16866                                 vector unsigned char);
16867 vector signed short vec_mule (vector signed char,
16868                               vector signed char);
16869 vector unsigned int vec_mule (vector unsigned short,
16870                               vector unsigned short);
16871 vector signed int vec_mule (vector signed short, vector signed short);
16872 vector unsigned long long vec_mule (vector unsigned int,
16873                                     vector unsigned int);
16874 vector signed long long vec_mule (vector signed int,
16875                                   vector signed int);
16877 vector signed int vec_vmulesh (vector signed short,
16878                                vector signed short);
16880 vector unsigned int vec_vmuleuh (vector unsigned short,
16881                                  vector unsigned short);
16883 vector signed short vec_vmulesb (vector signed char,
16884                                  vector signed char);
16886 vector unsigned short vec_vmuleub (vector unsigned char,
16887                                   vector unsigned char);
16889 vector unsigned short vec_mulo (vector unsigned char,
16890                                 vector unsigned char);
16891 vector signed short vec_mulo (vector signed char, vector signed char);
16892 vector unsigned int vec_mulo (vector unsigned short,
16893                               vector unsigned short);
16894 vector signed int vec_mulo (vector signed short, vector signed short);
16895 vector unsigned long long vec_mulo (vector unsigned int,
16896                                     vector unsigned int);
16897 vector signed long long vec_mulo (vector signed int,
16898                                   vector signed int);
16900 vector signed int vec_vmulosh (vector signed short,
16901                                vector signed short);
16903 vector unsigned int vec_vmulouh (vector unsigned short,
16904                                  vector unsigned short);
16906 vector signed short vec_vmulosb (vector signed char,
16907                                  vector signed char);
16909 vector unsigned short vec_vmuloub (vector unsigned char,
16910                                    vector unsigned char);
16912 vector float vec_nmsub (vector float, vector float, vector float);
16914 vector signed char vec_nabs (vector signed char);
16915 vector signed short vec_nabs (vector signed short);
16916 vector signed int vec_nabs (vector signed int);
16917 vector float vec_nabs (vector float);
16918 vector double vec_nabs (vector double);
16920 vector signed char vec_neg (vector signed char);
16921 vector signed short vec_neg (vector signed short);
16922 vector signed int vec_neg (vector signed int);
16923 vector signed long long vec_neg (vector signed long long);
16924 vector float  char vec_neg (vector float);
16925 vector double vec_neg (vector double);
16927 vector float vec_nor (vector float, vector float);
16928 vector signed int vec_nor (vector signed int, vector signed int);
16929 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16930 vector bool int vec_nor (vector bool int, vector bool int);
16931 vector signed short vec_nor (vector signed short, vector signed short);
16932 vector unsigned short vec_nor (vector unsigned short,
16933                                vector unsigned short);
16934 vector bool short vec_nor (vector bool short, vector bool short);
16935 vector signed char vec_nor (vector signed char, vector signed char);
16936 vector unsigned char vec_nor (vector unsigned char,
16937                               vector unsigned char);
16938 vector bool char vec_nor (vector bool char, vector bool char);
16940 vector float vec_or (vector float, vector float);
16941 vector float vec_or (vector float, vector bool int);
16942 vector float vec_or (vector bool int, vector float);
16943 vector bool int vec_or (vector bool int, vector bool int);
16944 vector signed int vec_or (vector bool int, vector signed int);
16945 vector signed int vec_or (vector signed int, vector bool int);
16946 vector signed int vec_or (vector signed int, vector signed int);
16947 vector unsigned int vec_or (vector bool int, vector unsigned int);
16948 vector unsigned int vec_or (vector unsigned int, vector bool int);
16949 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16950 vector bool short vec_or (vector bool short, vector bool short);
16951 vector signed short vec_or (vector bool short, vector signed short);
16952 vector signed short vec_or (vector signed short, vector bool short);
16953 vector signed short vec_or (vector signed short, vector signed short);
16954 vector unsigned short vec_or (vector bool short, vector unsigned short);
16955 vector unsigned short vec_or (vector unsigned short, vector bool short);
16956 vector unsigned short vec_or (vector unsigned short,
16957                               vector unsigned short);
16958 vector signed char vec_or (vector bool char, vector signed char);
16959 vector bool char vec_or (vector bool char, vector bool char);
16960 vector signed char vec_or (vector signed char, vector bool char);
16961 vector signed char vec_or (vector signed char, vector signed char);
16962 vector unsigned char vec_or (vector bool char, vector unsigned char);
16963 vector unsigned char vec_or (vector unsigned char, vector bool char);
16964 vector unsigned char vec_or (vector unsigned char,
16965                              vector unsigned char);
16967 vector signed char vec_pack (vector signed short, vector signed short);
16968 vector unsigned char vec_pack (vector unsigned short,
16969                                vector unsigned short);
16970 vector bool char vec_pack (vector bool short, vector bool short);
16971 vector signed short vec_pack (vector signed int, vector signed int);
16972 vector unsigned short vec_pack (vector unsigned int,
16973                                 vector unsigned int);
16974 vector bool short vec_pack (vector bool int, vector bool int);
16976 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16977 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16978 vector unsigned short vec_vpkuwum (vector unsigned int,
16979                                    vector unsigned int);
16981 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16982 vector signed char vec_vpkuhum (vector signed short,
16983                                 vector signed short);
16984 vector unsigned char vec_vpkuhum (vector unsigned short,
16985                                   vector unsigned short);
16987 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16989 vector unsigned char vec_packs (vector unsigned short,
16990                                 vector unsigned short);
16991 vector signed char vec_packs (vector signed short, vector signed short);
16992 vector unsigned short vec_packs (vector unsigned int,
16993                                  vector unsigned int);
16994 vector signed short vec_packs (vector signed int, vector signed int);
16996 vector signed short vec_vpkswss (vector signed int, vector signed int);
16998 vector unsigned short vec_vpkuwus (vector unsigned int,
16999                                    vector unsigned int);
17001 vector signed char vec_vpkshss (vector signed short,
17002                                 vector signed short);
17004 vector unsigned char vec_vpkuhus (vector unsigned short,
17005                                   vector unsigned short);
17007 vector unsigned char vec_packsu (vector unsigned short,
17008                                  vector unsigned short);
17009 vector unsigned char vec_packsu (vector signed short,
17010                                  vector signed short);
17011 vector unsigned short vec_packsu (vector unsigned int,
17012                                   vector unsigned int);
17013 vector unsigned short vec_packsu (vector signed int, vector signed int);
17015 vector unsigned short vec_vpkswus (vector signed int,
17016                                    vector signed int);
17018 vector unsigned char vec_vpkshus (vector signed short,
17019                                   vector signed short);
17021 vector float vec_perm (vector float,
17022                        vector float,
17023                        vector unsigned char);
17024 vector signed int vec_perm (vector signed int,
17025                             vector signed int,
17026                             vector unsigned char);
17027 vector unsigned int vec_perm (vector unsigned int,
17028                               vector unsigned int,
17029                               vector unsigned char);
17030 vector bool int vec_perm (vector bool int,
17031                           vector bool int,
17032                           vector unsigned char);
17033 vector signed short vec_perm (vector signed short,
17034                               vector signed short,
17035                               vector unsigned char);
17036 vector unsigned short vec_perm (vector unsigned short,
17037                                 vector unsigned short,
17038                                 vector unsigned char);
17039 vector bool short vec_perm (vector bool short,
17040                             vector bool short,
17041                             vector unsigned char);
17042 vector pixel vec_perm (vector pixel,
17043                        vector pixel,
17044                        vector unsigned char);
17045 vector signed char vec_perm (vector signed char,
17046                              vector signed char,
17047                              vector unsigned char);
17048 vector unsigned char vec_perm (vector unsigned char,
17049                                vector unsigned char,
17050                                vector unsigned char);
17051 vector bool char vec_perm (vector bool char,
17052                            vector bool char,
17053                            vector unsigned char);
17055 vector float vec_re (vector float);
17057 vector bool char vec_reve (vector bool char);
17058 vector signed char vec_reve (vector signed char);
17059 vector unsigned char vec_reve (vector unsigned char);
17060 vector bool int vec_reve (vector bool int);
17061 vector signed int vec_reve (vector signed int);
17062 vector unsigned int vec_reve (vector unsigned int);
17063 vector bool long long vec_reve (vector bool long long);
17064 vector signed long long vec_reve (vector signed long long);
17065 vector unsigned long long vec_reve (vector unsigned long long);
17066 vector bool short vec_reve (vector bool short);
17067 vector signed short vec_reve (vector signed short);
17068 vector unsigned short vec_reve (vector unsigned short);
17070 vector signed char vec_rl (vector signed char,
17071                            vector unsigned char);
17072 vector unsigned char vec_rl (vector unsigned char,
17073                              vector unsigned char);
17074 vector signed short vec_rl (vector signed short, vector unsigned short);
17075 vector unsigned short vec_rl (vector unsigned short,
17076                               vector unsigned short);
17077 vector signed int vec_rl (vector signed int, vector unsigned int);
17078 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17080 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17081 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17083 vector signed short vec_vrlh (vector signed short,
17084                               vector unsigned short);
17085 vector unsigned short vec_vrlh (vector unsigned short,
17086                                 vector unsigned short);
17088 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17089 vector unsigned char vec_vrlb (vector unsigned char,
17090                                vector unsigned char);
17092 vector float vec_round (vector float);
17094 vector float vec_recip (vector float, vector float);
17096 vector float vec_rsqrt (vector float);
17098 vector float vec_rsqrte (vector float);
17100 vector float vec_sel (vector float, vector float, vector bool int);
17101 vector float vec_sel (vector float, vector float, vector unsigned int);
17102 vector signed int vec_sel (vector signed int,
17103                            vector signed int,
17104                            vector bool int);
17105 vector signed int vec_sel (vector signed int,
17106                            vector signed int,
17107                            vector unsigned int);
17108 vector unsigned int vec_sel (vector unsigned int,
17109                              vector unsigned int,
17110                              vector bool int);
17111 vector unsigned int vec_sel (vector unsigned int,
17112                              vector unsigned int,
17113                              vector unsigned int);
17114 vector bool int vec_sel (vector bool int,
17115                          vector bool int,
17116                          vector bool int);
17117 vector bool int vec_sel (vector bool int,
17118                          vector bool int,
17119                          vector unsigned int);
17120 vector signed short vec_sel (vector signed short,
17121                              vector signed short,
17122                              vector bool short);
17123 vector signed short vec_sel (vector signed short,
17124                              vector signed short,
17125                              vector unsigned short);
17126 vector unsigned short vec_sel (vector unsigned short,
17127                                vector unsigned short,
17128                                vector bool short);
17129 vector unsigned short vec_sel (vector unsigned short,
17130                                vector unsigned short,
17131                                vector unsigned short);
17132 vector bool short vec_sel (vector bool short,
17133                            vector bool short,
17134                            vector bool short);
17135 vector bool short vec_sel (vector bool short,
17136                            vector bool short,
17137                            vector unsigned short);
17138 vector signed char vec_sel (vector signed char,
17139                             vector signed char,
17140                             vector bool char);
17141 vector signed char vec_sel (vector signed char,
17142                             vector signed char,
17143                             vector unsigned char);
17144 vector unsigned char vec_sel (vector unsigned char,
17145                               vector unsigned char,
17146                               vector bool char);
17147 vector unsigned char vec_sel (vector unsigned char,
17148                               vector unsigned char,
17149                               vector unsigned char);
17150 vector bool char vec_sel (vector bool char,
17151                           vector bool char,
17152                           vector bool char);
17153 vector bool char vec_sel (vector bool char,
17154                           vector bool char,
17155                           vector unsigned char);
17157 vector signed long long vec_signed (vector double);
17158 vector signed int vec_signed (vector float);
17160 vector signed int vec_signede (vector double);
17161 vector signed int vec_signedo (vector double);
17162 vector signed int vec_signed2 (vector double, vector double);
17164 vector signed char vec_sl (vector signed char,
17165                            vector unsigned char);
17166 vector unsigned char vec_sl (vector unsigned char,
17167                              vector unsigned char);
17168 vector signed short vec_sl (vector signed short, vector unsigned short);
17169 vector unsigned short vec_sl (vector unsigned short,
17170                               vector unsigned short);
17171 vector signed int vec_sl (vector signed int, vector unsigned int);
17172 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17174 vector signed int vec_vslw (vector signed int, vector unsigned int);
17175 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17177 vector signed short vec_vslh (vector signed short,
17178                               vector unsigned short);
17179 vector unsigned short vec_vslh (vector unsigned short,
17180                                 vector unsigned short);
17182 vector signed char vec_vslb (vector signed char, vector unsigned char);
17183 vector unsigned char vec_vslb (vector unsigned char,
17184                                vector unsigned char);
17186 vector float vec_sld (vector float, vector float, const int);
17187 vector double vec_sld (vector double, vector double, const int);
17189 vector signed int vec_sld (vector signed int,
17190                            vector signed int,
17191                            const int);
17192 vector unsigned int vec_sld (vector unsigned int,
17193                              vector unsigned int,
17194                              const int);
17195 vector bool int vec_sld (vector bool int,
17196                          vector bool int,
17197                          const int);
17198 vector signed short vec_sld (vector signed short,
17199                              vector signed short,
17200                              const int);
17201 vector unsigned short vec_sld (vector unsigned short,
17202                                vector unsigned short,
17203                                const int);
17204 vector bool short vec_sld (vector bool short,
17205                            vector bool short,
17206                            const int);
17207 vector pixel vec_sld (vector pixel,
17208                       vector pixel,
17209                       const int);
17210 vector signed char vec_sld (vector signed char,
17211                             vector signed char,
17212                             const int);
17213 vector unsigned char vec_sld (vector unsigned char,
17214                               vector unsigned char,
17215                               const int);
17216 vector bool char vec_sld (vector bool char,
17217                           vector bool char,
17218                           const int);
17220 vector signed char vec_sldw (vector signed char,
17221                              vector signed char,
17222                              const int);
17223 vector unsigned char vec_sldw (vector unsigned char,
17224                                vector unsigned char,
17225                                const int);
17226 vector signed short vec_sldw (vector signed short,
17227                               vector signed short,
17228                               const int);
17229 vector unsigned short vec_sldw (vector unsigned short,
17230                                 vector unsigned short,
17231                                 const int);
17232 vector signed int vec_sldw (vector signed int,
17233                             vector signed int,
17234                             const int);
17235 vector unsigned int vec_sldw (vector unsigned int,
17236                               vector unsigned int,
17237                               const int);
17238 vector signed long long vec_sldw (vector signed long long,
17239                                   vector signed long long,
17240                                   const int);
17241 vector unsigned long long vec_sldw (vector unsigned long long,
17242                                     vector unsigned long long,
17243                                     const int);
17245 vector signed int vec_sll (vector signed int,
17246                            vector unsigned int);
17247 vector signed int vec_sll (vector signed int,
17248                            vector unsigned short);
17249 vector signed int vec_sll (vector signed int,
17250                            vector unsigned char);
17251 vector unsigned int vec_sll (vector unsigned int,
17252                              vector unsigned int);
17253 vector unsigned int vec_sll (vector unsigned int,
17254                              vector unsigned short);
17255 vector unsigned int vec_sll (vector unsigned int,
17256                              vector unsigned char);
17257 vector bool int vec_sll (vector bool int,
17258                          vector unsigned int);
17259 vector bool int vec_sll (vector bool int,
17260                          vector unsigned short);
17261 vector bool int vec_sll (vector bool int,
17262                          vector unsigned char);
17263 vector signed short vec_sll (vector signed short,
17264                              vector unsigned int);
17265 vector signed short vec_sll (vector signed short,
17266                              vector unsigned short);
17267 vector signed short vec_sll (vector signed short,
17268                              vector unsigned char);
17269 vector unsigned short vec_sll (vector unsigned short,
17270                                vector unsigned int);
17271 vector unsigned short vec_sll (vector unsigned short,
17272                                vector unsigned short);
17273 vector unsigned short vec_sll (vector unsigned short,
17274                                vector unsigned char);
17275 vector bool short vec_sll (vector bool short, vector unsigned int);
17276 vector bool short vec_sll (vector bool short, vector unsigned short);
17277 vector bool short vec_sll (vector bool short, vector unsigned char);
17278 vector pixel vec_sll (vector pixel, vector unsigned int);
17279 vector pixel vec_sll (vector pixel, vector unsigned short);
17280 vector pixel vec_sll (vector pixel, vector unsigned char);
17281 vector signed char vec_sll (vector signed char, vector unsigned int);
17282 vector signed char vec_sll (vector signed char, vector unsigned short);
17283 vector signed char vec_sll (vector signed char, vector unsigned char);
17284 vector unsigned char vec_sll (vector unsigned char,
17285                               vector unsigned int);
17286 vector unsigned char vec_sll (vector unsigned char,
17287                               vector unsigned short);
17288 vector unsigned char vec_sll (vector unsigned char,
17289                               vector unsigned char);
17290 vector bool char vec_sll (vector bool char, vector unsigned int);
17291 vector bool char vec_sll (vector bool char, vector unsigned short);
17292 vector bool char vec_sll (vector bool char, vector unsigned char);
17294 vector float vec_slo (vector float, vector signed char);
17295 vector float vec_slo (vector float, vector unsigned char);
17296 vector signed int vec_slo (vector signed int, vector signed char);
17297 vector signed int vec_slo (vector signed int, vector unsigned char);
17298 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17299 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17300 vector signed short vec_slo (vector signed short, vector signed char);
17301 vector signed short vec_slo (vector signed short, vector unsigned char);
17302 vector unsigned short vec_slo (vector unsigned short,
17303                                vector signed char);
17304 vector unsigned short vec_slo (vector unsigned short,
17305                                vector unsigned char);
17306 vector pixel vec_slo (vector pixel, vector signed char);
17307 vector pixel vec_slo (vector pixel, vector unsigned char);
17308 vector signed char vec_slo (vector signed char, vector signed char);
17309 vector signed char vec_slo (vector signed char, vector unsigned char);
17310 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17311 vector unsigned char vec_slo (vector unsigned char,
17312                               vector unsigned char);
17313 vector signed long long vec_slo (vector signed long long, vector signed char);
17314 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17315 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17316 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17318 vector signed char vec_splat (vector signed char, const int);
17319 vector unsigned char vec_splat (vector unsigned char, const int);
17320 vector bool char vec_splat (vector bool char, const int);
17321 vector signed short vec_splat (vector signed short, const int);
17322 vector unsigned short vec_splat (vector unsigned short, const int);
17323 vector bool short vec_splat (vector bool short, const int);
17324 vector pixel vec_splat (vector pixel, const int);
17325 vector float vec_splat (vector float, const int);
17326 vector signed int vec_splat (vector signed int, const int);
17327 vector unsigned int vec_splat (vector unsigned int, const int);
17328 vector bool int vec_splat (vector bool int, const int);
17329 vector signed long vec_splat (vector signed long, const int);
17330 vector unsigned long vec_splat (vector unsigned long, const int);
17332 vector signed char vec_splats (signed char);
17333 vector unsigned char vec_splats (unsigned char);
17334 vector signed short vec_splats (signed short);
17335 vector unsigned short vec_splats (unsigned short);
17336 vector signed int vec_splats (signed int);
17337 vector unsigned int vec_splats (unsigned int);
17338 vector float vec_splats (float);
17340 vector float vec_vspltw (vector float, const int);
17341 vector signed int vec_vspltw (vector signed int, const int);
17342 vector unsigned int vec_vspltw (vector unsigned int, const int);
17343 vector bool int vec_vspltw (vector bool int, const int);
17345 vector bool short vec_vsplth (vector bool short, const int);
17346 vector signed short vec_vsplth (vector signed short, const int);
17347 vector unsigned short vec_vsplth (vector unsigned short, const int);
17348 vector pixel vec_vsplth (vector pixel, const int);
17350 vector signed char vec_vspltb (vector signed char, const int);
17351 vector unsigned char vec_vspltb (vector unsigned char, const int);
17352 vector bool char vec_vspltb (vector bool char, const int);
17354 vector signed char vec_splat_s8 (const int);
17356 vector signed short vec_splat_s16 (const int);
17358 vector signed int vec_splat_s32 (const int);
17360 vector unsigned char vec_splat_u8 (const int);
17362 vector unsigned short vec_splat_u16 (const int);
17364 vector unsigned int vec_splat_u32 (const int);
17366 vector signed char vec_sr (vector signed char, vector unsigned char);
17367 vector unsigned char vec_sr (vector unsigned char,
17368                              vector unsigned char);
17369 vector signed short vec_sr (vector signed short,
17370                             vector unsigned short);
17371 vector unsigned short vec_sr (vector unsigned short,
17372                               vector unsigned short);
17373 vector signed int vec_sr (vector signed int, vector unsigned int);
17374 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17376 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17377 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17379 vector signed short vec_vsrh (vector signed short,
17380                               vector unsigned short);
17381 vector unsigned short vec_vsrh (vector unsigned short,
17382                                 vector unsigned short);
17384 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17385 vector unsigned char vec_vsrb (vector unsigned char,
17386                                vector unsigned char);
17388 vector signed char vec_sra (vector signed char, vector unsigned char);
17389 vector unsigned char vec_sra (vector unsigned char,
17390                               vector unsigned char);
17391 vector signed short vec_sra (vector signed short,
17392                              vector unsigned short);
17393 vector unsigned short vec_sra (vector unsigned short,
17394                                vector unsigned short);
17395 vector signed int vec_sra (vector signed int, vector unsigned int);
17396 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17398 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17399 vector unsigned int vec_vsraw (vector unsigned int,
17400                                vector unsigned int);
17402 vector signed short vec_vsrah (vector signed short,
17403                                vector unsigned short);
17404 vector unsigned short vec_vsrah (vector unsigned short,
17405                                  vector unsigned short);
17407 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17408 vector unsigned char vec_vsrab (vector unsigned char,
17409                                 vector unsigned char);
17411 vector signed int vec_srl (vector signed int, vector unsigned int);
17412 vector signed int vec_srl (vector signed int, vector unsigned short);
17413 vector signed int vec_srl (vector signed int, vector unsigned char);
17414 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17415 vector unsigned int vec_srl (vector unsigned int,
17416                              vector unsigned short);
17417 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17418 vector bool int vec_srl (vector bool int, vector unsigned int);
17419 vector bool int vec_srl (vector bool int, vector unsigned short);
17420 vector bool int vec_srl (vector bool int, vector unsigned char);
17421 vector signed short vec_srl (vector signed short, vector unsigned int);
17422 vector signed short vec_srl (vector signed short,
17423                              vector unsigned short);
17424 vector signed short vec_srl (vector signed short, vector unsigned char);
17425 vector unsigned short vec_srl (vector unsigned short,
17426                                vector unsigned int);
17427 vector unsigned short vec_srl (vector unsigned short,
17428                                vector unsigned short);
17429 vector unsigned short vec_srl (vector unsigned short,
17430                                vector unsigned char);
17431 vector bool short vec_srl (vector bool short, vector unsigned int);
17432 vector bool short vec_srl (vector bool short, vector unsigned short);
17433 vector bool short vec_srl (vector bool short, vector unsigned char);
17434 vector pixel vec_srl (vector pixel, vector unsigned int);
17435 vector pixel vec_srl (vector pixel, vector unsigned short);
17436 vector pixel vec_srl (vector pixel, vector unsigned char);
17437 vector signed char vec_srl (vector signed char, vector unsigned int);
17438 vector signed char vec_srl (vector signed char, vector unsigned short);
17439 vector signed char vec_srl (vector signed char, vector unsigned char);
17440 vector unsigned char vec_srl (vector unsigned char,
17441                               vector unsigned int);
17442 vector unsigned char vec_srl (vector unsigned char,
17443                               vector unsigned short);
17444 vector unsigned char vec_srl (vector unsigned char,
17445                               vector unsigned char);
17446 vector bool char vec_srl (vector bool char, vector unsigned int);
17447 vector bool char vec_srl (vector bool char, vector unsigned short);
17448 vector bool char vec_srl (vector bool char, vector unsigned char);
17450 vector float vec_sro (vector float, vector signed char);
17451 vector float vec_sro (vector float, vector unsigned char);
17452 vector signed int vec_sro (vector signed int, vector signed char);
17453 vector signed int vec_sro (vector signed int, vector unsigned char);
17454 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17455 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17456 vector signed short vec_sro (vector signed short, vector signed char);
17457 vector signed short vec_sro (vector signed short, vector unsigned char);
17458 vector unsigned short vec_sro (vector unsigned short,
17459                                vector signed char);
17460 vector unsigned short vec_sro (vector unsigned short,
17461                                vector unsigned char);
17462 vector pixel vec_sro (vector pixel, vector signed char);
17463 vector pixel vec_sro (vector pixel, vector unsigned char);
17464 vector signed char vec_sro (vector signed char, vector signed char);
17465 vector signed char vec_sro (vector signed char, vector unsigned char);
17466 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17467 vector unsigned char vec_sro (vector unsigned char,
17468                               vector unsigned char);
17470 void vec_st (vector float, int, vector float *);
17471 void vec_st (vector float, int, float *);
17472 void vec_st (vector signed int, int, vector signed int *);
17473 void vec_st (vector signed int, int, int *);
17474 void vec_st (vector unsigned int, int, vector unsigned int *);
17475 void vec_st (vector unsigned int, int, unsigned int *);
17476 void vec_st (vector bool int, int, vector bool int *);
17477 void vec_st (vector bool int, int, unsigned int *);
17478 void vec_st (vector bool int, int, int *);
17479 void vec_st (vector signed short, int, vector signed short *);
17480 void vec_st (vector signed short, int, short *);
17481 void vec_st (vector unsigned short, int, vector unsigned short *);
17482 void vec_st (vector unsigned short, int, unsigned short *);
17483 void vec_st (vector bool short, int, vector bool short *);
17484 void vec_st (vector bool short, int, unsigned short *);
17485 void vec_st (vector pixel, int, vector pixel *);
17486 void vec_st (vector pixel, int, unsigned short *);
17487 void vec_st (vector pixel, int, short *);
17488 void vec_st (vector bool short, int, short *);
17489 void vec_st (vector signed char, int, vector signed char *);
17490 void vec_st (vector signed char, int, signed char *);
17491 void vec_st (vector unsigned char, int, vector unsigned char *);
17492 void vec_st (vector unsigned char, int, unsigned char *);
17493 void vec_st (vector bool char, int, vector bool char *);
17494 void vec_st (vector bool char, int, unsigned char *);
17495 void vec_st (vector bool char, int, signed char *);
17497 void vec_ste (vector signed char, int, signed char *);
17498 void vec_ste (vector unsigned char, int, unsigned char *);
17499 void vec_ste (vector bool char, int, signed char *);
17500 void vec_ste (vector bool char, int, unsigned char *);
17501 void vec_ste (vector signed short, int, short *);
17502 void vec_ste (vector unsigned short, int, unsigned short *);
17503 void vec_ste (vector bool short, int, short *);
17504 void vec_ste (vector bool short, int, unsigned short *);
17505 void vec_ste (vector pixel, int, short *);
17506 void vec_ste (vector pixel, int, unsigned short *);
17507 void vec_ste (vector float, int, float *);
17508 void vec_ste (vector signed int, int, int *);
17509 void vec_ste (vector unsigned int, int, unsigned int *);
17510 void vec_ste (vector bool int, int, int *);
17511 void vec_ste (vector bool int, int, unsigned int *);
17513 void vec_stvewx (vector float, int, float *);
17514 void vec_stvewx (vector signed int, int, int *);
17515 void vec_stvewx (vector unsigned int, int, unsigned int *);
17516 void vec_stvewx (vector bool int, int, int *);
17517 void vec_stvewx (vector bool int, int, unsigned int *);
17519 void vec_stvehx (vector signed short, int, short *);
17520 void vec_stvehx (vector unsigned short, int, unsigned short *);
17521 void vec_stvehx (vector bool short, int, short *);
17522 void vec_stvehx (vector bool short, int, unsigned short *);
17523 void vec_stvehx (vector pixel, int, short *);
17524 void vec_stvehx (vector pixel, int, unsigned short *);
17526 void vec_stvebx (vector signed char, int, signed char *);
17527 void vec_stvebx (vector unsigned char, int, unsigned char *);
17528 void vec_stvebx (vector bool char, int, signed char *);
17529 void vec_stvebx (vector bool char, int, unsigned char *);
17531 void vec_stl (vector float, int, vector float *);
17532 void vec_stl (vector float, int, float *);
17533 void vec_stl (vector signed int, int, vector signed int *);
17534 void vec_stl (vector signed int, int, int *);
17535 void vec_stl (vector unsigned int, int, vector unsigned int *);
17536 void vec_stl (vector unsigned int, int, unsigned int *);
17537 void vec_stl (vector bool int, int, vector bool int *);
17538 void vec_stl (vector bool int, int, unsigned int *);
17539 void vec_stl (vector bool int, int, int *);
17540 void vec_stl (vector signed short, int, vector signed short *);
17541 void vec_stl (vector signed short, int, short *);
17542 void vec_stl (vector unsigned short, int, vector unsigned short *);
17543 void vec_stl (vector unsigned short, int, unsigned short *);
17544 void vec_stl (vector bool short, int, vector bool short *);
17545 void vec_stl (vector bool short, int, unsigned short *);
17546 void vec_stl (vector bool short, int, short *);
17547 void vec_stl (vector pixel, int, vector pixel *);
17548 void vec_stl (vector pixel, int, unsigned short *);
17549 void vec_stl (vector pixel, int, short *);
17550 void vec_stl (vector signed char, int, vector signed char *);
17551 void vec_stl (vector signed char, int, signed char *);
17552 void vec_stl (vector unsigned char, int, vector unsigned char *);
17553 void vec_stl (vector unsigned char, int, unsigned char *);
17554 void vec_stl (vector bool char, int, vector bool char *);
17555 void vec_stl (vector bool char, int, unsigned char *);
17556 void vec_stl (vector bool char, int, signed char *);
17558 vector signed char vec_sub (vector bool char, vector signed char);
17559 vector signed char vec_sub (vector signed char, vector bool char);
17560 vector signed char vec_sub (vector signed char, vector signed char);
17561 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17562 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17563 vector unsigned char vec_sub (vector unsigned char,
17564                               vector unsigned char);
17565 vector signed short vec_sub (vector bool short, vector signed short);
17566 vector signed short vec_sub (vector signed short, vector bool short);
17567 vector signed short vec_sub (vector signed short, vector signed short);
17568 vector unsigned short vec_sub (vector bool short,
17569                                vector unsigned short);
17570 vector unsigned short vec_sub (vector unsigned short,
17571                                vector bool short);
17572 vector unsigned short vec_sub (vector unsigned short,
17573                                vector unsigned short);
17574 vector signed int vec_sub (vector bool int, vector signed int);
17575 vector signed int vec_sub (vector signed int, vector bool int);
17576 vector signed int vec_sub (vector signed int, vector signed int);
17577 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17578 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17579 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17580 vector float vec_sub (vector float, vector float);
17582 vector float vec_vsubfp (vector float, vector float);
17584 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17585 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17586 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17587 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17588 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17589 vector unsigned int vec_vsubuwm (vector unsigned int,
17590                                  vector unsigned int);
17592 vector signed short vec_vsubuhm (vector bool short,
17593                                  vector signed short);
17594 vector signed short vec_vsubuhm (vector signed short,
17595                                  vector bool short);
17596 vector signed short vec_vsubuhm (vector signed short,
17597                                  vector signed short);
17598 vector unsigned short vec_vsubuhm (vector bool short,
17599                                    vector unsigned short);
17600 vector unsigned short vec_vsubuhm (vector unsigned short,
17601                                    vector bool short);
17602 vector unsigned short vec_vsubuhm (vector unsigned short,
17603                                    vector unsigned short);
17605 vector signed char vec_vsububm (vector bool char, vector signed char);
17606 vector signed char vec_vsububm (vector signed char, vector bool char);
17607 vector signed char vec_vsububm (vector signed char, vector signed char);
17608 vector unsigned char vec_vsububm (vector bool char,
17609                                   vector unsigned char);
17610 vector unsigned char vec_vsububm (vector unsigned char,
17611                                   vector bool char);
17612 vector unsigned char vec_vsububm (vector unsigned char,
17613                                   vector unsigned char);
17615 vector signed int vec_subc (vector signed int, vector signed int);
17616 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17617 vector signed __int128 vec_subc (vector signed __int128,
17618                                  vector signed __int128);
17619 vector unsigned __int128 vec_subc (vector unsigned __int128,
17620                                    vector unsigned __int128);
17622 vector signed int vec_sube (vector signed int, vector signed int,
17623                             vector signed int);
17624 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17625                               vector unsigned int);
17626 vector signed __int128 vec_sube (vector signed __int128,
17627                                  vector signed __int128,
17628                                  vector signed __int128);
17629 vector unsigned __int128 vec_sube (vector unsigned __int128,
17630                                    vector unsigned __int128,
17631                                    vector unsigned __int128);
17633 vector signed int vec_subec (vector signed int, vector signed int,
17634                              vector signed int);
17635 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17636                                vector unsigned int);
17637 vector signed __int128 vec_subec (vector signed __int128,
17638                                   vector signed __int128,
17639                                   vector signed __int128);
17640 vector unsigned __int128 vec_subec (vector unsigned __int128,
17641                                     vector unsigned __int128,
17642                                     vector unsigned __int128);
17644 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17645 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17646 vector unsigned char vec_subs (vector unsigned char,
17647                                vector unsigned char);
17648 vector signed char vec_subs (vector bool char, vector signed char);
17649 vector signed char vec_subs (vector signed char, vector bool char);
17650 vector signed char vec_subs (vector signed char, vector signed char);
17651 vector unsigned short vec_subs (vector bool short,
17652                                 vector unsigned short);
17653 vector unsigned short vec_subs (vector unsigned short,
17654                                 vector bool short);
17655 vector unsigned short vec_subs (vector unsigned short,
17656                                 vector unsigned short);
17657 vector signed short vec_subs (vector bool short, vector signed short);
17658 vector signed short vec_subs (vector signed short, vector bool short);
17659 vector signed short vec_subs (vector signed short, vector signed short);
17660 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17661 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17662 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17663 vector signed int vec_subs (vector bool int, vector signed int);
17664 vector signed int vec_subs (vector signed int, vector bool int);
17665 vector signed int vec_subs (vector signed int, vector signed int);
17667 vector signed int vec_vsubsws (vector bool int, vector signed int);
17668 vector signed int vec_vsubsws (vector signed int, vector bool int);
17669 vector signed int vec_vsubsws (vector signed int, vector signed int);
17671 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17672 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17673 vector unsigned int vec_vsubuws (vector unsigned int,
17674                                  vector unsigned int);
17676 vector signed short vec_vsubshs (vector bool short,
17677                                  vector signed short);
17678 vector signed short vec_vsubshs (vector signed short,
17679                                  vector bool short);
17680 vector signed short vec_vsubshs (vector signed short,
17681                                  vector signed short);
17683 vector unsigned short vec_vsubuhs (vector bool short,
17684                                    vector unsigned short);
17685 vector unsigned short vec_vsubuhs (vector unsigned short,
17686                                    vector bool short);
17687 vector unsigned short vec_vsubuhs (vector unsigned short,
17688                                    vector unsigned short);
17690 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17691 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17692 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17694 vector unsigned char vec_vsububs (vector bool char,
17695                                   vector unsigned char);
17696 vector unsigned char vec_vsububs (vector unsigned char,
17697                                   vector bool char);
17698 vector unsigned char vec_vsububs (vector unsigned char,
17699                                   vector unsigned char);
17701 vector unsigned int vec_sum4s (vector unsigned char,
17702                                vector unsigned int);
17703 vector signed int vec_sum4s (vector signed char, vector signed int);
17704 vector signed int vec_sum4s (vector signed short, vector signed int);
17706 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17708 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17710 vector unsigned int vec_vsum4ubs (vector unsigned char,
17711                                   vector unsigned int);
17713 vector signed int vec_sum2s (vector signed int, vector signed int);
17715 vector signed int vec_sums (vector signed int, vector signed int);
17717 vector float vec_trunc (vector float);
17719 vector signed long long vec_unsigned (vector double);
17720 vector signed int vec_unsigned (vector float);
17722 vector signed int vec_unsignede (vector double);
17723 vector signed int vec_unsignedo (vector double);
17724 vector signed int vec_unsigned2 (vector double, vector double);
17726 vector signed short vec_unpackh (vector signed char);
17727 vector bool short vec_unpackh (vector bool char);
17728 vector signed int vec_unpackh (vector signed short);
17729 vector bool int vec_unpackh (vector bool short);
17730 vector unsigned int vec_unpackh (vector pixel);
17732 vector bool int vec_vupkhsh (vector bool short);
17733 vector signed int vec_vupkhsh (vector signed short);
17735 vector unsigned int vec_vupkhpx (vector pixel);
17737 vector bool short vec_vupkhsb (vector bool char);
17738 vector signed short vec_vupkhsb (vector signed char);
17740 vector signed short vec_unpackl (vector signed char);
17741 vector bool short vec_unpackl (vector bool char);
17742 vector unsigned int vec_unpackl (vector pixel);
17743 vector signed int vec_unpackl (vector signed short);
17744 vector bool int vec_unpackl (vector bool short);
17746 vector unsigned int vec_vupklpx (vector pixel);
17748 vector bool int vec_vupklsh (vector bool short);
17749 vector signed int vec_vupklsh (vector signed short);
17751 vector bool short vec_vupklsb (vector bool char);
17752 vector signed short vec_vupklsb (vector signed char);
17754 vector float vec_xor (vector float, vector float);
17755 vector float vec_xor (vector float, vector bool int);
17756 vector float vec_xor (vector bool int, vector float);
17757 vector bool int vec_xor (vector bool int, vector bool int);
17758 vector signed int vec_xor (vector bool int, vector signed int);
17759 vector signed int vec_xor (vector signed int, vector bool int);
17760 vector signed int vec_xor (vector signed int, vector signed int);
17761 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17762 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17763 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17764 vector bool short vec_xor (vector bool short, vector bool short);
17765 vector signed short vec_xor (vector bool short, vector signed short);
17766 vector signed short vec_xor (vector signed short, vector bool short);
17767 vector signed short vec_xor (vector signed short, vector signed short);
17768 vector unsigned short vec_xor (vector bool short,
17769                                vector unsigned short);
17770 vector unsigned short vec_xor (vector unsigned short,
17771                                vector bool short);
17772 vector unsigned short vec_xor (vector unsigned short,
17773                                vector unsigned short);
17774 vector signed char vec_xor (vector bool char, vector signed char);
17775 vector bool char vec_xor (vector bool char, vector bool char);
17776 vector signed char vec_xor (vector signed char, vector bool char);
17777 vector signed char vec_xor (vector signed char, vector signed char);
17778 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17779 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17780 vector unsigned char vec_xor (vector unsigned char,
17781                               vector unsigned char);
17783 int vec_all_eq (vector signed char, vector bool char);
17784 int vec_all_eq (vector signed char, vector signed char);
17785 int vec_all_eq (vector unsigned char, vector bool char);
17786 int vec_all_eq (vector unsigned char, vector unsigned char);
17787 int vec_all_eq (vector bool char, vector bool char);
17788 int vec_all_eq (vector bool char, vector unsigned char);
17789 int vec_all_eq (vector bool char, vector signed char);
17790 int vec_all_eq (vector signed short, vector bool short);
17791 int vec_all_eq (vector signed short, vector signed short);
17792 int vec_all_eq (vector unsigned short, vector bool short);
17793 int vec_all_eq (vector unsigned short, vector unsigned short);
17794 int vec_all_eq (vector bool short, vector bool short);
17795 int vec_all_eq (vector bool short, vector unsigned short);
17796 int vec_all_eq (vector bool short, vector signed short);
17797 int vec_all_eq (vector pixel, vector pixel);
17798 int vec_all_eq (vector signed int, vector bool int);
17799 int vec_all_eq (vector signed int, vector signed int);
17800 int vec_all_eq (vector unsigned int, vector bool int);
17801 int vec_all_eq (vector unsigned int, vector unsigned int);
17802 int vec_all_eq (vector bool int, vector bool int);
17803 int vec_all_eq (vector bool int, vector unsigned int);
17804 int vec_all_eq (vector bool int, vector signed int);
17805 int vec_all_eq (vector float, vector float);
17807 int vec_all_ge (vector bool char, vector unsigned char);
17808 int vec_all_ge (vector unsigned char, vector bool char);
17809 int vec_all_ge (vector unsigned char, vector unsigned char);
17810 int vec_all_ge (vector bool char, vector signed char);
17811 int vec_all_ge (vector signed char, vector bool char);
17812 int vec_all_ge (vector signed char, vector signed char);
17813 int vec_all_ge (vector bool short, vector unsigned short);
17814 int vec_all_ge (vector unsigned short, vector bool short);
17815 int vec_all_ge (vector unsigned short, vector unsigned short);
17816 int vec_all_ge (vector signed short, vector signed short);
17817 int vec_all_ge (vector bool short, vector signed short);
17818 int vec_all_ge (vector signed short, vector bool short);
17819 int vec_all_ge (vector bool int, vector unsigned int);
17820 int vec_all_ge (vector unsigned int, vector bool int);
17821 int vec_all_ge (vector unsigned int, vector unsigned int);
17822 int vec_all_ge (vector bool int, vector signed int);
17823 int vec_all_ge (vector signed int, vector bool int);
17824 int vec_all_ge (vector signed int, vector signed int);
17825 int vec_all_ge (vector float, vector float);
17827 int vec_all_gt (vector bool char, vector unsigned char);
17828 int vec_all_gt (vector unsigned char, vector bool char);
17829 int vec_all_gt (vector unsigned char, vector unsigned char);
17830 int vec_all_gt (vector bool char, vector signed char);
17831 int vec_all_gt (vector signed char, vector bool char);
17832 int vec_all_gt (vector signed char, vector signed char);
17833 int vec_all_gt (vector bool short, vector unsigned short);
17834 int vec_all_gt (vector unsigned short, vector bool short);
17835 int vec_all_gt (vector unsigned short, vector unsigned short);
17836 int vec_all_gt (vector bool short, vector signed short);
17837 int vec_all_gt (vector signed short, vector bool short);
17838 int vec_all_gt (vector signed short, vector signed short);
17839 int vec_all_gt (vector bool int, vector unsigned int);
17840 int vec_all_gt (vector unsigned int, vector bool int);
17841 int vec_all_gt (vector unsigned int, vector unsigned int);
17842 int vec_all_gt (vector bool int, vector signed int);
17843 int vec_all_gt (vector signed int, vector bool int);
17844 int vec_all_gt (vector signed int, vector signed int);
17845 int vec_all_gt (vector float, vector float);
17847 int vec_all_in (vector float, vector float);
17849 int vec_all_le (vector bool char, vector unsigned char);
17850 int vec_all_le (vector unsigned char, vector bool char);
17851 int vec_all_le (vector unsigned char, vector unsigned char);
17852 int vec_all_le (vector bool char, vector signed char);
17853 int vec_all_le (vector signed char, vector bool char);
17854 int vec_all_le (vector signed char, vector signed char);
17855 int vec_all_le (vector bool short, vector unsigned short);
17856 int vec_all_le (vector unsigned short, vector bool short);
17857 int vec_all_le (vector unsigned short, vector unsigned short);
17858 int vec_all_le (vector bool short, vector signed short);
17859 int vec_all_le (vector signed short, vector bool short);
17860 int vec_all_le (vector signed short, vector signed short);
17861 int vec_all_le (vector bool int, vector unsigned int);
17862 int vec_all_le (vector unsigned int, vector bool int);
17863 int vec_all_le (vector unsigned int, vector unsigned int);
17864 int vec_all_le (vector bool int, vector signed int);
17865 int vec_all_le (vector signed int, vector bool int);
17866 int vec_all_le (vector signed int, vector signed int);
17867 int vec_all_le (vector float, vector float);
17869 int vec_all_lt (vector bool char, vector unsigned char);
17870 int vec_all_lt (vector unsigned char, vector bool char);
17871 int vec_all_lt (vector unsigned char, vector unsigned char);
17872 int vec_all_lt (vector bool char, vector signed char);
17873 int vec_all_lt (vector signed char, vector bool char);
17874 int vec_all_lt (vector signed char, vector signed char);
17875 int vec_all_lt (vector bool short, vector unsigned short);
17876 int vec_all_lt (vector unsigned short, vector bool short);
17877 int vec_all_lt (vector unsigned short, vector unsigned short);
17878 int vec_all_lt (vector bool short, vector signed short);
17879 int vec_all_lt (vector signed short, vector bool short);
17880 int vec_all_lt (vector signed short, vector signed short);
17881 int vec_all_lt (vector bool int, vector unsigned int);
17882 int vec_all_lt (vector unsigned int, vector bool int);
17883 int vec_all_lt (vector unsigned int, vector unsigned int);
17884 int vec_all_lt (vector bool int, vector signed int);
17885 int vec_all_lt (vector signed int, vector bool int);
17886 int vec_all_lt (vector signed int, vector signed int);
17887 int vec_all_lt (vector float, vector float);
17889 int vec_all_nan (vector float);
17891 int vec_all_ne (vector signed char, vector bool char);
17892 int vec_all_ne (vector signed char, vector signed char);
17893 int vec_all_ne (vector unsigned char, vector bool char);
17894 int vec_all_ne (vector unsigned char, vector unsigned char);
17895 int vec_all_ne (vector bool char, vector bool char);
17896 int vec_all_ne (vector bool char, vector unsigned char);
17897 int vec_all_ne (vector bool char, vector signed char);
17898 int vec_all_ne (vector signed short, vector bool short);
17899 int vec_all_ne (vector signed short, vector signed short);
17900 int vec_all_ne (vector unsigned short, vector bool short);
17901 int vec_all_ne (vector unsigned short, vector unsigned short);
17902 int vec_all_ne (vector bool short, vector bool short);
17903 int vec_all_ne (vector bool short, vector unsigned short);
17904 int vec_all_ne (vector bool short, vector signed short);
17905 int vec_all_ne (vector pixel, vector pixel);
17906 int vec_all_ne (vector signed int, vector bool int);
17907 int vec_all_ne (vector signed int, vector signed int);
17908 int vec_all_ne (vector unsigned int, vector bool int);
17909 int vec_all_ne (vector unsigned int, vector unsigned int);
17910 int vec_all_ne (vector bool int, vector bool int);
17911 int vec_all_ne (vector bool int, vector unsigned int);
17912 int vec_all_ne (vector bool int, vector signed int);
17913 int vec_all_ne (vector float, vector float);
17915 int vec_all_nge (vector float, vector float);
17917 int vec_all_ngt (vector float, vector float);
17919 int vec_all_nle (vector float, vector float);
17921 int vec_all_nlt (vector float, vector float);
17923 int vec_all_numeric (vector float);
17925 int vec_any_eq (vector signed char, vector bool char);
17926 int vec_any_eq (vector signed char, vector signed char);
17927 int vec_any_eq (vector unsigned char, vector bool char);
17928 int vec_any_eq (vector unsigned char, vector unsigned char);
17929 int vec_any_eq (vector bool char, vector bool char);
17930 int vec_any_eq (vector bool char, vector unsigned char);
17931 int vec_any_eq (vector bool char, vector signed char);
17932 int vec_any_eq (vector signed short, vector bool short);
17933 int vec_any_eq (vector signed short, vector signed short);
17934 int vec_any_eq (vector unsigned short, vector bool short);
17935 int vec_any_eq (vector unsigned short, vector unsigned short);
17936 int vec_any_eq (vector bool short, vector bool short);
17937 int vec_any_eq (vector bool short, vector unsigned short);
17938 int vec_any_eq (vector bool short, vector signed short);
17939 int vec_any_eq (vector pixel, vector pixel);
17940 int vec_any_eq (vector signed int, vector bool int);
17941 int vec_any_eq (vector signed int, vector signed int);
17942 int vec_any_eq (vector unsigned int, vector bool int);
17943 int vec_any_eq (vector unsigned int, vector unsigned int);
17944 int vec_any_eq (vector bool int, vector bool int);
17945 int vec_any_eq (vector bool int, vector unsigned int);
17946 int vec_any_eq (vector bool int, vector signed int);
17947 int vec_any_eq (vector float, vector float);
17949 int vec_any_ge (vector signed char, vector bool char);
17950 int vec_any_ge (vector unsigned char, vector bool char);
17951 int vec_any_ge (vector unsigned char, vector unsigned char);
17952 int vec_any_ge (vector signed char, vector signed char);
17953 int vec_any_ge (vector bool char, vector unsigned char);
17954 int vec_any_ge (vector bool char, vector signed char);
17955 int vec_any_ge (vector unsigned short, vector bool short);
17956 int vec_any_ge (vector unsigned short, vector unsigned short);
17957 int vec_any_ge (vector signed short, vector signed short);
17958 int vec_any_ge (vector signed short, vector bool short);
17959 int vec_any_ge (vector bool short, vector unsigned short);
17960 int vec_any_ge (vector bool short, vector signed short);
17961 int vec_any_ge (vector signed int, vector bool int);
17962 int vec_any_ge (vector unsigned int, vector bool int);
17963 int vec_any_ge (vector unsigned int, vector unsigned int);
17964 int vec_any_ge (vector signed int, vector signed int);
17965 int vec_any_ge (vector bool int, vector unsigned int);
17966 int vec_any_ge (vector bool int, vector signed int);
17967 int vec_any_ge (vector float, vector float);
17969 int vec_any_gt (vector bool char, vector unsigned char);
17970 int vec_any_gt (vector unsigned char, vector bool char);
17971 int vec_any_gt (vector unsigned char, vector unsigned char);
17972 int vec_any_gt (vector bool char, vector signed char);
17973 int vec_any_gt (vector signed char, vector bool char);
17974 int vec_any_gt (vector signed char, vector signed char);
17975 int vec_any_gt (vector bool short, vector unsigned short);
17976 int vec_any_gt (vector unsigned short, vector bool short);
17977 int vec_any_gt (vector unsigned short, vector unsigned short);
17978 int vec_any_gt (vector bool short, vector signed short);
17979 int vec_any_gt (vector signed short, vector bool short);
17980 int vec_any_gt (vector signed short, vector signed short);
17981 int vec_any_gt (vector bool int, vector unsigned int);
17982 int vec_any_gt (vector unsigned int, vector bool int);
17983 int vec_any_gt (vector unsigned int, vector unsigned int);
17984 int vec_any_gt (vector bool int, vector signed int);
17985 int vec_any_gt (vector signed int, vector bool int);
17986 int vec_any_gt (vector signed int, vector signed int);
17987 int vec_any_gt (vector float, vector float);
17989 int vec_any_le (vector bool char, vector unsigned char);
17990 int vec_any_le (vector unsigned char, vector bool char);
17991 int vec_any_le (vector unsigned char, vector unsigned char);
17992 int vec_any_le (vector bool char, vector signed char);
17993 int vec_any_le (vector signed char, vector bool char);
17994 int vec_any_le (vector signed char, vector signed char);
17995 int vec_any_le (vector bool short, vector unsigned short);
17996 int vec_any_le (vector unsigned short, vector bool short);
17997 int vec_any_le (vector unsigned short, vector unsigned short);
17998 int vec_any_le (vector bool short, vector signed short);
17999 int vec_any_le (vector signed short, vector bool short);
18000 int vec_any_le (vector signed short, vector signed short);
18001 int vec_any_le (vector bool int, vector unsigned int);
18002 int vec_any_le (vector unsigned int, vector bool int);
18003 int vec_any_le (vector unsigned int, vector unsigned int);
18004 int vec_any_le (vector bool int, vector signed int);
18005 int vec_any_le (vector signed int, vector bool int);
18006 int vec_any_le (vector signed int, vector signed int);
18007 int vec_any_le (vector float, vector float);
18009 int vec_any_lt (vector bool char, vector unsigned char);
18010 int vec_any_lt (vector unsigned char, vector bool char);
18011 int vec_any_lt (vector unsigned char, vector unsigned char);
18012 int vec_any_lt (vector bool char, vector signed char);
18013 int vec_any_lt (vector signed char, vector bool char);
18014 int vec_any_lt (vector signed char, vector signed char);
18015 int vec_any_lt (vector bool short, vector unsigned short);
18016 int vec_any_lt (vector unsigned short, vector bool short);
18017 int vec_any_lt (vector unsigned short, vector unsigned short);
18018 int vec_any_lt (vector bool short, vector signed short);
18019 int vec_any_lt (vector signed short, vector bool short);
18020 int vec_any_lt (vector signed short, vector signed short);
18021 int vec_any_lt (vector bool int, vector unsigned int);
18022 int vec_any_lt (vector unsigned int, vector bool int);
18023 int vec_any_lt (vector unsigned int, vector unsigned int);
18024 int vec_any_lt (vector bool int, vector signed int);
18025 int vec_any_lt (vector signed int, vector bool int);
18026 int vec_any_lt (vector signed int, vector signed int);
18027 int vec_any_lt (vector float, vector float);
18029 int vec_any_nan (vector float);
18031 int vec_any_ne (vector signed char, vector bool char);
18032 int vec_any_ne (vector signed char, vector signed char);
18033 int vec_any_ne (vector unsigned char, vector bool char);
18034 int vec_any_ne (vector unsigned char, vector unsigned char);
18035 int vec_any_ne (vector bool char, vector bool char);
18036 int vec_any_ne (vector bool char, vector unsigned char);
18037 int vec_any_ne (vector bool char, vector signed char);
18038 int vec_any_ne (vector signed short, vector bool short);
18039 int vec_any_ne (vector signed short, vector signed short);
18040 int vec_any_ne (vector unsigned short, vector bool short);
18041 int vec_any_ne (vector unsigned short, vector unsigned short);
18042 int vec_any_ne (vector bool short, vector bool short);
18043 int vec_any_ne (vector bool short, vector unsigned short);
18044 int vec_any_ne (vector bool short, vector signed short);
18045 int vec_any_ne (vector pixel, vector pixel);
18046 int vec_any_ne (vector signed int, vector bool int);
18047 int vec_any_ne (vector signed int, vector signed int);
18048 int vec_any_ne (vector unsigned int, vector bool int);
18049 int vec_any_ne (vector unsigned int, vector unsigned int);
18050 int vec_any_ne (vector bool int, vector bool int);
18051 int vec_any_ne (vector bool int, vector unsigned int);
18052 int vec_any_ne (vector bool int, vector signed int);
18053 int vec_any_ne (vector float, vector float);
18055 int vec_any_nge (vector float, vector float);
18057 int vec_any_ngt (vector float, vector float);
18059 int vec_any_nle (vector float, vector float);
18061 int vec_any_nlt (vector float, vector float);
18063 int vec_any_numeric (vector float);
18065 int vec_any_out (vector float, vector float);
18066 @end smallexample
18068 If the vector/scalar (VSX) instruction set is available, the following
18069 additional functions are available:
18071 @smallexample
18072 vector double vec_abs (vector double);
18073 vector double vec_add (vector double, vector double);
18074 vector double vec_and (vector double, vector double);
18075 vector double vec_and (vector double, vector bool long);
18076 vector double vec_and (vector bool long, vector double);
18077 vector long vec_and (vector long, vector long);
18078 vector long vec_and (vector long, vector bool long);
18079 vector long vec_and (vector bool long, vector long);
18080 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18081 vector unsigned long vec_and (vector unsigned long, vector bool long);
18082 vector unsigned long vec_and (vector bool long, vector unsigned long);
18083 vector double vec_andc (vector double, vector double);
18084 vector double vec_andc (vector double, vector bool long);
18085 vector double vec_andc (vector bool long, vector double);
18086 vector long vec_andc (vector long, vector long);
18087 vector long vec_andc (vector long, vector bool long);
18088 vector long vec_andc (vector bool long, vector long);
18089 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18090 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18091 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18092 vector double vec_ceil (vector double);
18093 vector bool long vec_cmpeq (vector double, vector double);
18094 vector bool long vec_cmpge (vector double, vector double);
18095 vector bool long vec_cmpgt (vector double, vector double);
18096 vector bool long vec_cmple (vector double, vector double);
18097 vector bool long vec_cmplt (vector double, vector double);
18098 vector double vec_cpsgn (vector double, vector double);
18099 vector float vec_div (vector float, vector float);
18100 vector double vec_div (vector double, vector double);
18101 vector long vec_div (vector long, vector long);
18102 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18103 vector double vec_floor (vector double);
18104 vector double vec_ld (int, const vector double *);
18105 vector double vec_ld (int, const double *);
18106 vector double vec_ldl (int, const vector double *);
18107 vector double vec_ldl (int, const double *);
18108 vector unsigned char vec_lvsl (int, const volatile double *);
18109 vector unsigned char vec_lvsr (int, const volatile double *);
18110 vector double vec_madd (vector double, vector double, vector double);
18111 vector double vec_max (vector double, vector double);
18112 vector signed long vec_mergeh (vector signed long, vector signed long);
18113 vector signed long vec_mergeh (vector signed long, vector bool long);
18114 vector signed long vec_mergeh (vector bool long, vector signed long);
18115 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18116 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18117 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18118 vector signed long vec_mergel (vector signed long, vector signed long);
18119 vector signed long vec_mergel (vector signed long, vector bool long);
18120 vector signed long vec_mergel (vector bool long, vector signed long);
18121 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18122 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18123 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18124 vector double vec_min (vector double, vector double);
18125 vector float vec_msub (vector float, vector float, vector float);
18126 vector double vec_msub (vector double, vector double, vector double);
18127 vector float vec_mul (vector float, vector float);
18128 vector double vec_mul (vector double, vector double);
18129 vector long vec_mul (vector long, vector long);
18130 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18131 vector float vec_nearbyint (vector float);
18132 vector double vec_nearbyint (vector double);
18133 vector float vec_nmadd (vector float, vector float, vector float);
18134 vector double vec_nmadd (vector double, vector double, vector double);
18135 vector double vec_nmsub (vector double, vector double, vector double);
18136 vector double vec_nor (vector double, vector double);
18137 vector long vec_nor (vector long, vector long);
18138 vector long vec_nor (vector long, vector bool long);
18139 vector long vec_nor (vector bool long, vector long);
18140 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18141 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18142 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18143 vector double vec_or (vector double, vector double);
18144 vector double vec_or (vector double, vector bool long);
18145 vector double vec_or (vector bool long, vector double);
18146 vector long vec_or (vector long, vector long);
18147 vector long vec_or (vector long, vector bool long);
18148 vector long vec_or (vector bool long, vector long);
18149 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18150 vector unsigned long vec_or (vector unsigned long, vector bool long);
18151 vector unsigned long vec_or (vector bool long, vector unsigned long);
18152 vector double vec_perm (vector double, vector double, vector unsigned char);
18153 vector long vec_perm (vector long, vector long, vector unsigned char);
18154 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18155                                vector unsigned char);
18156 vector double vec_rint (vector double);
18157 vector double vec_recip (vector double, vector double);
18158 vector double vec_rsqrt (vector double);
18159 vector double vec_rsqrte (vector double);
18160 vector double vec_sel (vector double, vector double, vector bool long);
18161 vector double vec_sel (vector double, vector double, vector unsigned long);
18162 vector long vec_sel (vector long, vector long, vector long);
18163 vector long vec_sel (vector long, vector long, vector unsigned long);
18164 vector long vec_sel (vector long, vector long, vector bool long);
18165 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18166                               vector long);
18167 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18168                               vector unsigned long);
18169 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18170                               vector bool long);
18171 vector double vec_splats (double);
18172 vector signed long vec_splats (signed long);
18173 vector unsigned long vec_splats (unsigned long);
18174 vector float vec_sqrt (vector float);
18175 vector double vec_sqrt (vector double);
18176 void vec_st (vector double, int, vector double *);
18177 void vec_st (vector double, int, double *);
18178 vector double vec_sub (vector double, vector double);
18179 vector double vec_trunc (vector double);
18180 vector double vec_xl (int, vector double *);
18181 vector double vec_xl (int, double *);
18182 vector long long vec_xl (int, vector long long *);
18183 vector long long vec_xl (int, long long *);
18184 vector unsigned long long vec_xl (int, vector unsigned long long *);
18185 vector unsigned long long vec_xl (int, unsigned long long *);
18186 vector float vec_xl (int, vector float *);
18187 vector float vec_xl (int, float *);
18188 vector int vec_xl (int, vector int *);
18189 vector int vec_xl (int, int *);
18190 vector unsigned int vec_xl (int, vector unsigned int *);
18191 vector unsigned int vec_xl (int, unsigned int *);
18192 vector double vec_xor (vector double, vector double);
18193 vector double vec_xor (vector double, vector bool long);
18194 vector double vec_xor (vector bool long, vector double);
18195 vector long vec_xor (vector long, vector long);
18196 vector long vec_xor (vector long, vector bool long);
18197 vector long vec_xor (vector bool long, vector long);
18198 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18199 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18200 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18201 void vec_xst (vector double, int, vector double *);
18202 void vec_xst (vector double, int, double *);
18203 void vec_xst (vector long long, int, vector long long *);
18204 void vec_xst (vector long long, int, long long *);
18205 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18206 void vec_xst (vector unsigned long long, int, unsigned long long *);
18207 void vec_xst (vector float, int, vector float *);
18208 void vec_xst (vector float, int, float *);
18209 void vec_xst (vector int, int, vector int *);
18210 void vec_xst (vector int, int, int *);
18211 void vec_xst (vector unsigned int, int, vector unsigned int *);
18212 void vec_xst (vector unsigned int, int, unsigned int *);
18213 int vec_all_eq (vector double, vector double);
18214 int vec_all_ge (vector double, vector double);
18215 int vec_all_gt (vector double, vector double);
18216 int vec_all_le (vector double, vector double);
18217 int vec_all_lt (vector double, vector double);
18218 int vec_all_nan (vector double);
18219 int vec_all_ne (vector double, vector double);
18220 int vec_all_nge (vector double, vector double);
18221 int vec_all_ngt (vector double, vector double);
18222 int vec_all_nle (vector double, vector double);
18223 int vec_all_nlt (vector double, vector double);
18224 int vec_all_numeric (vector double);
18225 int vec_any_eq (vector double, vector double);
18226 int vec_any_ge (vector double, vector double);
18227 int vec_any_gt (vector double, vector double);
18228 int vec_any_le (vector double, vector double);
18229 int vec_any_lt (vector double, vector double);
18230 int vec_any_nan (vector double);
18231 int vec_any_ne (vector double, vector double);
18232 int vec_any_nge (vector double, vector double);
18233 int vec_any_ngt (vector double, vector double);
18234 int vec_any_nle (vector double, vector double);
18235 int vec_any_nlt (vector double, vector double);
18236 int vec_any_numeric (vector double);
18238 vector double vec_vsx_ld (int, const vector double *);
18239 vector double vec_vsx_ld (int, const double *);
18240 vector float vec_vsx_ld (int, const vector float *);
18241 vector float vec_vsx_ld (int, const float *);
18242 vector bool int vec_vsx_ld (int, const vector bool int *);
18243 vector signed int vec_vsx_ld (int, const vector signed int *);
18244 vector signed int vec_vsx_ld (int, const int *);
18245 vector signed int vec_vsx_ld (int, const long *);
18246 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18247 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18248 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18249 vector bool short vec_vsx_ld (int, const vector bool short *);
18250 vector pixel vec_vsx_ld (int, const vector pixel *);
18251 vector signed short vec_vsx_ld (int, const vector signed short *);
18252 vector signed short vec_vsx_ld (int, const short *);
18253 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18254 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18255 vector bool char vec_vsx_ld (int, const vector bool char *);
18256 vector signed char vec_vsx_ld (int, const vector signed char *);
18257 vector signed char vec_vsx_ld (int, const signed char *);
18258 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18259 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18261 void vec_vsx_st (vector double, int, vector double *);
18262 void vec_vsx_st (vector double, int, double *);
18263 void vec_vsx_st (vector float, int, vector float *);
18264 void vec_vsx_st (vector float, int, float *);
18265 void vec_vsx_st (vector signed int, int, vector signed int *);
18266 void vec_vsx_st (vector signed int, int, int *);
18267 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18268 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18269 void vec_vsx_st (vector bool int, int, vector bool int *);
18270 void vec_vsx_st (vector bool int, int, unsigned int *);
18271 void vec_vsx_st (vector bool int, int, int *);
18272 void vec_vsx_st (vector signed short, int, vector signed short *);
18273 void vec_vsx_st (vector signed short, int, short *);
18274 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18275 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18276 void vec_vsx_st (vector bool short, int, vector bool short *);
18277 void vec_vsx_st (vector bool short, int, unsigned short *);
18278 void vec_vsx_st (vector pixel, int, vector pixel *);
18279 void vec_vsx_st (vector pixel, int, unsigned short *);
18280 void vec_vsx_st (vector pixel, int, short *);
18281 void vec_vsx_st (vector bool short, int, short *);
18282 void vec_vsx_st (vector signed char, int, vector signed char *);
18283 void vec_vsx_st (vector signed char, int, signed char *);
18284 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18285 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18286 void vec_vsx_st (vector bool char, int, vector bool char *);
18287 void vec_vsx_st (vector bool char, int, unsigned char *);
18288 void vec_vsx_st (vector bool char, int, signed char *);
18290 vector double vec_xxpermdi (vector double, vector double, const int);
18291 vector float vec_xxpermdi (vector float, vector float, const int);
18292 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18293 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18294                                         vector unsigned long long, const int);
18295 vector int vec_xxpermdi (vector int, vector int, const int);
18296 vector unsigned int vec_xxpermdi (vector unsigned int,
18297                                   vector unsigned int, const int);
18298 vector short vec_xxpermdi (vector short, vector short, const int);
18299 vector unsigned short vec_xxpermdi (vector unsigned short,
18300                                     vector unsigned short, const int);
18301 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18302                                  const int);
18303 vector unsigned char vec_xxpermdi (vector unsigned char,
18304                                    vector unsigned char, const int);
18306 vector double vec_xxsldi (vector double, vector double, int);
18307 vector float vec_xxsldi (vector float, vector float, int);
18308 vector long long vec_xxsldi (vector long long, vector long long, int);
18309 vector unsigned long long vec_xxsldi (vector unsigned long long,
18310                                       vector unsigned long long, int);
18311 vector int vec_xxsldi (vector int, vector int, int);
18312 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18313 vector short vec_xxsldi (vector short, vector short, int);
18314 vector unsigned short vec_xxsldi (vector unsigned short,
18315                                   vector unsigned short, int);
18316 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18317 vector unsigned char vec_xxsldi (vector unsigned char,
18318                                  vector unsigned char, int);
18319 @end smallexample
18321 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18322 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18323 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
18324 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18325 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18327 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18328 instruction set are available, the following additional functions are
18329 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
18330 can use @var{vector long} instead of @var{vector long long},
18331 @var{vector bool long} instead of @var{vector bool long long}, and
18332 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18334 @smallexample
18335 vector long long vec_abs (vector long long);
18337 vector long long vec_add (vector long long, vector long long);
18338 vector unsigned long long vec_add (vector unsigned long long,
18339                                    vector unsigned long long);
18341 int vec_all_eq (vector long long, vector long long);
18342 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18343 int vec_all_ge (vector long long, vector long long);
18344 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18345 int vec_all_gt (vector long long, vector long long);
18346 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18347 int vec_all_le (vector long long, vector long long);
18348 int vec_all_le (vector unsigned long long, vector unsigned long long);
18349 int vec_all_lt (vector long long, vector long long);
18350 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18351 int vec_all_ne (vector long long, vector long long);
18352 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18354 int vec_any_eq (vector long long, vector long long);
18355 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18356 int vec_any_ge (vector long long, vector long long);
18357 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18358 int vec_any_gt (vector long long, vector long long);
18359 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18360 int vec_any_le (vector long long, vector long long);
18361 int vec_any_le (vector unsigned long long, vector unsigned long long);
18362 int vec_any_lt (vector long long, vector long long);
18363 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18364 int vec_any_ne (vector long long, vector long long);
18365 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18367 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18369 vector long long vec_eqv (vector long long, vector long long);
18370 vector long long vec_eqv (vector bool long long, vector long long);
18371 vector long long vec_eqv (vector long long, vector bool long long);
18372 vector unsigned long long vec_eqv (vector unsigned long long,
18373                                    vector unsigned long long);
18374 vector unsigned long long vec_eqv (vector bool long long,
18375                                    vector unsigned long long);
18376 vector unsigned long long vec_eqv (vector unsigned long long,
18377                                    vector bool long long);
18378 vector int vec_eqv (vector int, vector int);
18379 vector int vec_eqv (vector bool int, vector int);
18380 vector int vec_eqv (vector int, vector bool int);
18381 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18382 vector unsigned int vec_eqv (vector bool unsigned int,
18383                              vector unsigned int);
18384 vector unsigned int vec_eqv (vector unsigned int,
18385                              vector bool unsigned int);
18386 vector short vec_eqv (vector short, vector short);
18387 vector short vec_eqv (vector bool short, vector short);
18388 vector short vec_eqv (vector short, vector bool short);
18389 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18390 vector unsigned short vec_eqv (vector bool unsigned short,
18391                                vector unsigned short);
18392 vector unsigned short vec_eqv (vector unsigned short,
18393                                vector bool unsigned short);
18394 vector signed char vec_eqv (vector signed char, vector signed char);
18395 vector signed char vec_eqv (vector bool signed char, vector signed char);
18396 vector signed char vec_eqv (vector signed char, vector bool signed char);
18397 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18398 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18399 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18401 vector long long vec_max (vector long long, vector long long);
18402 vector unsigned long long vec_max (vector unsigned long long,
18403                                    vector unsigned long long);
18405 vector signed int vec_mergee (vector signed int, vector signed int);
18406 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18407 vector bool int vec_mergee (vector bool int, vector bool int);
18409 vector signed int vec_mergeo (vector signed int, vector signed int);
18410 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18411 vector bool int vec_mergeo (vector bool int, vector bool int);
18413 vector long long vec_min (vector long long, vector long long);
18414 vector unsigned long long vec_min (vector unsigned long long,
18415                                    vector unsigned long long);
18417 vector signed long long vec_nabs (vector signed long long);
18419 vector long long vec_nand (vector long long, vector long long);
18420 vector long long vec_nand (vector bool long long, vector long long);
18421 vector long long vec_nand (vector long long, vector bool long long);
18422 vector unsigned long long vec_nand (vector unsigned long long,
18423                                     vector unsigned long long);
18424 vector unsigned long long vec_nand (vector bool long long,
18425                                    vector unsigned long long);
18426 vector unsigned long long vec_nand (vector unsigned long long,
18427                                     vector bool long long);
18428 vector int vec_nand (vector int, vector int);
18429 vector int vec_nand (vector bool int, vector int);
18430 vector int vec_nand (vector int, vector bool int);
18431 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18432 vector unsigned int vec_nand (vector bool unsigned int,
18433                               vector unsigned int);
18434 vector unsigned int vec_nand (vector unsigned int,
18435                               vector bool unsigned int);
18436 vector short vec_nand (vector short, vector short);
18437 vector short vec_nand (vector bool short, vector short);
18438 vector short vec_nand (vector short, vector bool short);
18439 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18440 vector unsigned short vec_nand (vector bool unsigned short,
18441                                 vector unsigned short);
18442 vector unsigned short vec_nand (vector unsigned short,
18443                                 vector bool unsigned short);
18444 vector signed char vec_nand (vector signed char, vector signed char);
18445 vector signed char vec_nand (vector bool signed char, vector signed char);
18446 vector signed char vec_nand (vector signed char, vector bool signed char);
18447 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18448 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18449 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18451 vector long long vec_orc (vector long long, vector long long);
18452 vector long long vec_orc (vector bool long long, vector long long);
18453 vector long long vec_orc (vector long long, vector bool long long);
18454 vector unsigned long long vec_orc (vector unsigned long long,
18455                                    vector unsigned long long);
18456 vector unsigned long long vec_orc (vector bool long long,
18457                                    vector unsigned long long);
18458 vector unsigned long long vec_orc (vector unsigned long long,
18459                                    vector bool long long);
18460 vector int vec_orc (vector int, vector int);
18461 vector int vec_orc (vector bool int, vector int);
18462 vector int vec_orc (vector int, vector bool int);
18463 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18464 vector unsigned int vec_orc (vector bool unsigned int,
18465                              vector unsigned int);
18466 vector unsigned int vec_orc (vector unsigned int,
18467                              vector bool unsigned int);
18468 vector short vec_orc (vector short, vector short);
18469 vector short vec_orc (vector bool short, vector short);
18470 vector short vec_orc (vector short, vector bool short);
18471 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18472 vector unsigned short vec_orc (vector bool unsigned short,
18473                                vector unsigned short);
18474 vector unsigned short vec_orc (vector unsigned short,
18475                                vector bool unsigned short);
18476 vector signed char vec_orc (vector signed char, vector signed char);
18477 vector signed char vec_orc (vector bool signed char, vector signed char);
18478 vector signed char vec_orc (vector signed char, vector bool signed char);
18479 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18480 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18481 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18483 vector int vec_pack (vector long long, vector long long);
18484 vector unsigned int vec_pack (vector unsigned long long,
18485                               vector unsigned long long);
18486 vector bool int vec_pack (vector bool long long, vector bool long long);
18487 vector float vec_pack (vector double, vector double);
18489 vector int vec_packs (vector long long, vector long long);
18490 vector unsigned int vec_packs (vector unsigned long long,
18491                                vector unsigned long long);
18493 vector unsigned int vec_packsu (vector long long, vector long long);
18494 vector unsigned int vec_packsu (vector unsigned long long,
18495                                 vector unsigned long long);
18497 vector unsigned char vec_popcnt (vector signed char);
18498 vector unsigned char vec_popcnt (vector unsigned char);
18499 vector unsigned short vec_popcnt (vector signed short);
18500 vector unsigned short vec_popcnt (vector unsigned short);
18501 vector unsigned int vec_popcnt (vector signed int);
18502 vector unsigned int vec_popcnt (vector unsigned int);
18503 vector unsigned long long vec_popcnt (vector signed long long);
18504 vector unsigned long long vec_popcnt (vector unsigned long long);
18506 vector long long vec_rl (vector long long,
18507                          vector unsigned long long);
18508 vector long long vec_rl (vector unsigned long long,
18509                          vector unsigned long long);
18511 vector long long vec_sl (vector long long, vector unsigned long long);
18512 vector long long vec_sl (vector unsigned long long,
18513                          vector unsigned long long);
18515 vector long long vec_sr (vector long long, vector unsigned long long);
18516 vector unsigned long long char vec_sr (vector unsigned long long,
18517                                        vector unsigned long long);
18519 vector long long vec_sra (vector long long, vector unsigned long long);
18520 vector unsigned long long vec_sra (vector unsigned long long,
18521                                    vector unsigned long long);
18523 vector long long vec_sub (vector long long, vector long long);
18524 vector unsigned long long vec_sub (vector unsigned long long,
18525                                    vector unsigned long long);
18527 vector long long vec_unpackh (vector int);
18528 vector unsigned long long vec_unpackh (vector unsigned int);
18530 vector long long vec_unpackl (vector int);
18531 vector unsigned long long vec_unpackl (vector unsigned int);
18533 vector long long vec_vaddudm (vector long long, vector long long);
18534 vector long long vec_vaddudm (vector bool long long, vector long long);
18535 vector long long vec_vaddudm (vector long long, vector bool long long);
18536 vector unsigned long long vec_vaddudm (vector unsigned long long,
18537                                        vector unsigned long long);
18538 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18539                                        vector unsigned long long);
18540 vector unsigned long long vec_vaddudm (vector unsigned long long,
18541                                        vector bool unsigned long long);
18543 vector long long vec_vbpermq (vector signed char, vector signed char);
18544 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18546 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18547 vector unsigned char vec_bperm (vector unsigned long long,
18548                                 vector unsigned char);
18549 vector unsigned long long vec_bperm (vector unsigned __int128,
18550                                      vector unsigned char);
18552 vector long long vec_cntlz (vector long long);
18553 vector unsigned long long vec_cntlz (vector unsigned long long);
18554 vector int vec_cntlz (vector int);
18555 vector unsigned int vec_cntlz (vector int);
18556 vector short vec_cntlz (vector short);
18557 vector unsigned short vec_cntlz (vector unsigned short);
18558 vector signed char vec_cntlz (vector signed char);
18559 vector unsigned char vec_cntlz (vector unsigned char);
18561 vector long long vec_vclz (vector long long);
18562 vector unsigned long long vec_vclz (vector unsigned long long);
18563 vector int vec_vclz (vector int);
18564 vector unsigned int vec_vclz (vector int);
18565 vector short vec_vclz (vector short);
18566 vector unsigned short vec_vclz (vector unsigned short);
18567 vector signed char vec_vclz (vector signed char);
18568 vector unsigned char vec_vclz (vector unsigned char);
18570 vector signed char vec_vclzb (vector signed char);
18571 vector unsigned char vec_vclzb (vector unsigned char);
18573 vector long long vec_vclzd (vector long long);
18574 vector unsigned long long vec_vclzd (vector unsigned long long);
18576 vector short vec_vclzh (vector short);
18577 vector unsigned short vec_vclzh (vector unsigned short);
18579 vector int vec_vclzw (vector int);
18580 vector unsigned int vec_vclzw (vector int);
18582 vector signed char vec_vgbbd (vector signed char);
18583 vector unsigned char vec_vgbbd (vector unsigned char);
18585 vector long long vec_vmaxsd (vector long long, vector long long);
18587 vector unsigned long long vec_vmaxud (vector unsigned long long,
18588                                       unsigned vector long long);
18590 vector long long vec_vminsd (vector long long, vector long long);
18592 vector unsigned long long vec_vminud (vector long long,
18593                                       vector long long);
18595 vector int vec_vpksdss (vector long long, vector long long);
18596 vector unsigned int vec_vpksdss (vector long long, vector long long);
18598 vector unsigned int vec_vpkudus (vector unsigned long long,
18599                                  vector unsigned long long);
18601 vector int vec_vpkudum (vector long long, vector long long);
18602 vector unsigned int vec_vpkudum (vector unsigned long long,
18603                                  vector unsigned long long);
18604 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18606 vector long long vec_vpopcnt (vector long long);
18607 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18608 vector int vec_vpopcnt (vector int);
18609 vector unsigned int vec_vpopcnt (vector int);
18610 vector short vec_vpopcnt (vector short);
18611 vector unsigned short vec_vpopcnt (vector unsigned short);
18612 vector signed char vec_vpopcnt (vector signed char);
18613 vector unsigned char vec_vpopcnt (vector unsigned char);
18615 vector signed char vec_vpopcntb (vector signed char);
18616 vector unsigned char vec_vpopcntb (vector unsigned char);
18618 vector long long vec_vpopcntd (vector long long);
18619 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18621 vector short vec_vpopcnth (vector short);
18622 vector unsigned short vec_vpopcnth (vector unsigned short);
18624 vector int vec_vpopcntw (vector int);
18625 vector unsigned int vec_vpopcntw (vector int);
18627 vector long long vec_vrld (vector long long, vector unsigned long long);
18628 vector unsigned long long vec_vrld (vector unsigned long long,
18629                                     vector unsigned long long);
18631 vector long long vec_vsld (vector long long, vector unsigned long long);
18632 vector long long vec_vsld (vector unsigned long long,
18633                            vector unsigned long long);
18635 vector long long vec_vsrad (vector long long, vector unsigned long long);
18636 vector unsigned long long vec_vsrad (vector unsigned long long,
18637                                      vector unsigned long long);
18639 vector long long vec_vsrd (vector long long, vector unsigned long long);
18640 vector unsigned long long char vec_vsrd (vector unsigned long long,
18641                                          vector unsigned long long);
18643 vector long long vec_vsubudm (vector long long, vector long long);
18644 vector long long vec_vsubudm (vector bool long long, vector long long);
18645 vector long long vec_vsubudm (vector long long, vector bool long long);
18646 vector unsigned long long vec_vsubudm (vector unsigned long long,
18647                                        vector unsigned long long);
18648 vector unsigned long long vec_vsubudm (vector bool long long,
18649                                        vector unsigned long long);
18650 vector unsigned long long vec_vsubudm (vector unsigned long long,
18651                                        vector bool long long);
18653 vector long long vec_vupkhsw (vector int);
18654 vector unsigned long long vec_vupkhsw (vector unsigned int);
18656 vector long long vec_vupklsw (vector int);
18657 vector unsigned long long vec_vupklsw (vector int);
18658 @end smallexample
18660 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18661 instruction set are available, the following additional functions are
18662 available for 64-bit targets.  New vector types
18663 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18664 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18665 builtins.
18667 The normal vector extract, and set operations work on
18668 @var{vector __int128_t} and @var{vector __uint128_t} types,
18669 but the index value must be 0.
18671 @smallexample
18672 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18673 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18675 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18676 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18678 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18679                                 vector __int128_t);
18680 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18681                                  vector __uint128_t);
18683 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18684                                 vector __int128_t);
18685 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18686                                  vector __uint128_t);
18688 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18689                                 vector __int128_t);
18690 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18691                                  vector __uint128_t);
18693 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18694                                 vector __int128_t);
18695 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18696                                  vector __uint128_t);
18698 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18699 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18701 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18702 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18704 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
18705 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
18706 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
18707 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
18708 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
18709 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
18710 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
18711 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
18712 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
18713 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
18714 @end smallexample
18716 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18717 are available:
18719 @smallexample
18720 vector unsigned long long vec_bperm (vector unsigned long long,
18721                                      vector unsigned char);
18723 vector bool char vec_cmpne (vector bool char, vector bool char);
18724 vector bool short vec_cmpne (vector bool short, vector bool short);
18725 vector bool int vec_cmpne (vector bool int, vector bool int);
18726 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18728 vector float vec_extract_fp32_from_shorth (vector unsigned short);
18729 vector float vec_extract_fp32_from_shortl (vector unsigned short);
18731 vector long long vec_vctz (vector long long);
18732 vector unsigned long long vec_vctz (vector unsigned long long);
18733 vector int vec_vctz (vector int);
18734 vector unsigned int vec_vctz (vector int);
18735 vector short vec_vctz (vector short);
18736 vector unsigned short vec_vctz (vector unsigned short);
18737 vector signed char vec_vctz (vector signed char);
18738 vector unsigned char vec_vctz (vector unsigned char);
18740 vector signed char vec_vctzb (vector signed char);
18741 vector unsigned char vec_vctzb (vector unsigned char);
18743 vector long long vec_vctzd (vector long long);
18744 vector unsigned long long vec_vctzd (vector unsigned long long);
18746 vector short vec_vctzh (vector short);
18747 vector unsigned short vec_vctzh (vector unsigned short);
18749 vector int vec_vctzw (vector int);
18750 vector unsigned int vec_vctzw (vector int);
18752 long long vec_vextract4b (const vector signed char, const int);
18753 long long vec_vextract4b (const vector unsigned char, const int);
18755 vector signed char vec_insert4b (vector int, vector signed char, const int);
18756 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18757                                    const int);
18758 vector signed char vec_insert4b (long long, vector signed char, const int);
18759 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
18761 vector unsigned int vec_parity_lsbb (vector signed int);
18762 vector unsigned int vec_parity_lsbb (vector unsigned int);
18763 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
18764 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
18765 vector unsigned long long vec_parity_lsbb (vector signed long long);
18766 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
18768 vector int vec_vprtyb (vector int);
18769 vector unsigned int vec_vprtyb (vector unsigned int);
18770 vector long long vec_vprtyb (vector long long);
18771 vector unsigned long long vec_vprtyb (vector unsigned long long);
18773 vector int vec_vprtybw (vector int);
18774 vector unsigned int vec_vprtybw (vector unsigned int);
18776 vector long long vec_vprtybd (vector long long);
18777 vector unsigned long long vec_vprtybd (vector unsigned long long);
18778 @end smallexample
18780 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18781 are available:
18783 @smallexample
18784 vector long vec_vprtyb (vector long);
18785 vector unsigned long vec_vprtyb (vector unsigned long);
18786 vector __int128_t vec_vprtyb (vector __int128_t);
18787 vector __uint128_t vec_vprtyb (vector __uint128_t);
18789 vector long vec_vprtybd (vector long);
18790 vector unsigned long vec_vprtybd (vector unsigned long);
18792 vector __int128_t vec_vprtybq (vector __int128_t);
18793 vector __uint128_t vec_vprtybd (vector __uint128_t);
18794 @end smallexample
18796 The following built-in vector functions are available for the PowerPC family
18797 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18798 @smallexample
18799 __vector unsigned char
18800 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18801 __vector unsigned char
18802 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18803 @end smallexample
18805 The @code{vec_slv} and @code{vec_srv} functions operate on
18806 all of the bytes of their @code{src} and @code{shift_distance}
18807 arguments in parallel.  The behavior of the @code{vec_slv} is as if
18808 there existed a temporary array of 17 unsigned characters
18809 @code{slv_array} within which elements 0 through 15 are the same as
18810 the entries in the @code{src} array and element 16 equals 0.  The
18811 result returned from the @code{vec_slv} function is a
18812 @code{__vector} of 16 unsigned characters within which element
18813 @code{i} is computed using the C expression
18814 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18815 shift_distance[i]))},
18816 with this resulting value coerced to the @code{unsigned char} type.
18817 The behavior of the @code{vec_srv} is as if
18818 there existed a temporary array of 17 unsigned characters
18819 @code{srv_array} within which element 0 equals zero and
18820 elements 1 through 16 equal the elements 0 through 15 of
18821 the @code{src} array.  The
18822 result returned from the @code{vec_srv} function is a
18823 @code{__vector} of 16 unsigned characters within which element
18824 @code{i} is computed using the C expression
18825 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18826 (0x07 & shift_distance[i]))},
18827 with this resulting value coerced to the @code{unsigned char} type.
18829 The following built-in functions are available for the PowerPC family
18830 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18831 @smallexample
18832 __vector unsigned char
18833 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18834 __vector unsigned short
18835 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18836 __vector unsigned int
18837 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18839 __vector unsigned char
18840 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18841 __vector unsigned short
18842 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18843 __vector unsigned int
18844 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18845 @end smallexample
18847 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18848 @code{vec_absdw} built-in functions each computes the absolute
18849 differences of the pairs of vector elements supplied in its two vector
18850 arguments, placing the absolute differences into the corresponding
18851 elements of the vector result.
18853 The following built-in functions are available for the PowerPC family
18854 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18855 @smallexample
18856 __vector unsigned int
18857 vec_extract_exp (__vector float source);
18858 __vector unsigned long long int
18859 vec_extract_exp (__vector double source);
18861 __vector unsigned int
18862 vec_extract_sig (__vector float source);
18863 __vector unsigned long long int
18864 vec_extract_sig (__vector double source);
18866 __vector float
18867 vec_insert_exp (__vector unsigned int significands,
18868                 __vector unsigned int exponents);
18869 __vector float
18870 vec_insert_exp (__vector unsigned float significands,
18871                 __vector unsigned int exponents);
18872 __vector double
18873 vec_insert_exp (__vector unsigned long long int significands,
18874                 __vector unsigned long long int exponents);
18875 __vector double
18876 vec_insert_exp (__vector unsigned double significands,
18877                 __vector unsigned long long int exponents);
18879 __vector bool int vec_test_data_class (__vector float source,
18880                                        const int condition);
18881 __vector bool long long int vec_test_data_class (__vector double source,
18882                                                  const int condition);
18883 @end smallexample
18885 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18886 functions return vectors representing the significands and biased
18887 exponent values of their @code{source} arguments respectively.
18888 Within the result vector returned by @code{vec_extract_sig}, the
18889 @code{0x800000} bit of each vector element returned when the
18890 function's @code{source} argument is of type @code{float} is set to 1
18891 if the corresponding floating point value is in normalized form.
18892 Otherwise, this bit is set to 0.  When the @code{source} argument is
18893 of type @code{double}, the @code{0x10000000000000} bit within each of
18894 the result vector's elements is set according to the same rules.
18895 Note that the sign of the significand is not represented in the result
18896 returned from the @code{vec_extract_sig} function.  To extract the
18897 sign bits, use the
18898 @code{vec_cpsgn} function, which returns a new vector within which all
18899 of the sign bits of its second argument vector are overwritten with the
18900 sign bits copied from the coresponding elements of its first argument
18901 vector, and all other (non-sign) bits of the second argument vector
18902 are copied unchanged into the result vector.
18904 The @code{vec_insert_exp} built-in functions return a vector of
18905 single- or double-precision floating
18906 point values constructed by assembling the values of their
18907 @code{significands} and @code{exponents} arguments into the
18908 corresponding elements of the returned vector.
18909 The sign of each
18910 element of the result is copied from the most significant bit of the
18911 corresponding entry within the @code{significands} argument.
18912 Note that the relevant
18913 bits of the @code{significands} argument are the same, for both integer
18914 and floating point types.
18916 significand and exponent components of each element of the result are
18917 composed of the least significant bits of the corresponding
18918 @code{significands} element and the least significant bits of the
18919 corresponding @code{exponents} element.
18921 The @code{vec_test_data_class} built-in function returns a vector
18922 representing the results of testing the @code{source} vector for the
18923 condition selected by the @code{condition} argument.  The
18924 @code{condition} argument must be a compile-time constant integer with
18925 value not exceeding 127.  The
18926 @code{condition} argument is encoded as a bitmask with each bit
18927 enabling the testing of a different condition, as characterized by the
18928 following:
18929 @smallexample
18930 0x40    Test for NaN
18931 0x20    Test for +Infinity
18932 0x10    Test for -Infinity
18933 0x08    Test for +Zero
18934 0x04    Test for -Zero
18935 0x02    Test for +Denormal
18936 0x01    Test for -Denormal
18937 @end smallexample
18939 If any of the enabled test conditions is true, the corresponding entry
18940 in the result vector is -1.  Otherwise (all of the enabled test
18941 conditions are false), the corresponding entry of the result vector is 0.
18943 The following built-in functions are available for the PowerPC family
18944 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18945 @smallexample
18946 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
18947                               vector unsigned int);
18948 vector unsigned long long vec_rlmi (vector unsigned long long,
18949                                     vector unsigned long long,
18950                                     vector unsigned long long);
18951 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
18952                               vector unsigned int);
18953 vector unsigned long long vec_rlnm (vector unsigned long long,
18954                                     vector unsigned long long,
18955                                     vector unsigned long long);
18956 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
18957 vector unsigned long long vec_vrlnm (vector unsigned long long,
18958                                      vector unsigned long long);
18959 @end smallexample
18961 The result of @code{vec_rlmi} is obtained by rotating each element of
18962 the first argument vector left and inserting it under mask into the
18963 second argument vector.  The third argument vector contains the mask
18964 beginning in bits 11:15, the mask end in bits 19:23, and the shift
18965 count in bits 27:31, of each element.
18967 The result of @code{vec_rlnm} is obtained by rotating each element of
18968 the first argument vector left and ANDing it with a mask specified by
18969 the second and third argument vectors.  The second argument vector
18970 contains the shift count for each element in the low-order byte.  The
18971 third argument vector contains the mask end for each element in the
18972 low-order byte, with the mask begin in the next higher byte.
18974 The result of @code{vec_vrlnm} is obtained by rotating each element
18975 of the first argument vector left and ANDing it with a mask.  The
18976 second argument vector contains the mask  beginning in bits 11:15,
18977 the mask end in bits 19:23, and the shift count in bits 27:31,
18978 of each element.
18980 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18981 are available:
18982 @smallexample
18983 vector signed bool char vec_revb (vector signed char);
18984 vector signed char vec_revb (vector signed char);
18985 vector unsigned char vec_revb (vector unsigned char);
18986 vector bool short vec_revb (vector bool short);
18987 vector short vec_revb (vector short);
18988 vector unsigned short vec_revb (vector unsigned short);
18989 vector bool int vec_revb (vector bool int);
18990 vector int vec_revb (vector int);
18991 vector unsigned int vec_revb (vector unsigned int);
18992 vector float vec_revb (vector float);
18993 vector bool long long vec_revb (vector bool long long);
18994 vector long long vec_revb (vector long long);
18995 vector unsigned long long vec_revb (vector unsigned long long);
18996 vector double vec_revb (vector double);
18997 @end smallexample
18999 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19000 are available:
19001 @smallexample
19002 vector long vec_revb (vector long);
19003 vector unsigned long vec_revb (vector unsigned long);
19004 vector __int128_t vec_revb (vector __int128_t);
19005 vector __uint128_t vec_revb (vector __uint128_t);
19006 @end smallexample
19008 The @code{vec_revb} built-in function reverses the bytes on an element
19009 by element basis.  A vector of @code{vector unsigned char} or
19010 @code{vector signed char} reverses the bytes in the whole word.
19012 If the cryptographic instructions are enabled (@option{-mcrypto} or
19013 @option{-mcpu=power8}), the following builtins are enabled.
19015 @smallexample
19016 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19018 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19019                                                     vector unsigned long long);
19021 vector unsigned long long __builtin_crypto_vcipherlast
19022                                      (vector unsigned long long,
19023                                       vector unsigned long long);
19025 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19026                                                      vector unsigned long long);
19028 vector unsigned long long __builtin_crypto_vncipherlast
19029                                      (vector unsigned long long,
19030                                       vector unsigned long long);
19032 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19033                                                 vector unsigned char,
19034                                                 vector unsigned char);
19036 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19037                                                  vector unsigned short,
19038                                                  vector unsigned short);
19040 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19041                                                vector unsigned int,
19042                                                vector unsigned int);
19044 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19045                                                      vector unsigned long long,
19046                                                      vector unsigned long long);
19048 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19049                                                vector unsigned char);
19051 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19052                                                 vector unsigned short);
19054 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19055                                               vector unsigned int);
19057 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19058                                                     vector unsigned long long);
19060 vector unsigned long long __builtin_crypto_vshasigmad
19061                                (vector unsigned long long, int, int);
19063 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
19064                                                  int, int);
19065 @end smallexample
19067 The second argument to @var{__builtin_crypto_vshasigmad} and
19068 @var{__builtin_crypto_vshasigmaw} must be a constant
19069 integer that is 0 or 1.  The third argument to these built-in functions
19070 must be a constant integer in the range of 0 to 15.
19072 If the ISA 3.0 instruction set additions 
19073 are enabled (@option{-mcpu=power9}), the following additional
19074 functions are available for both 32-bit and 64-bit targets.
19076 vector short vec_xl (int, vector short *);
19077 vector short vec_xl (int, short *);
19078 vector unsigned short vec_xl (int, vector unsigned short *);
19079 vector unsigned short vec_xl (int, unsigned short *);
19080 vector char vec_xl (int, vector char *);
19081 vector char vec_xl (int, char *);
19082 vector unsigned char vec_xl (int, vector unsigned char *);
19083 vector unsigned char vec_xl (int, unsigned char *);
19085 void vec_xst (vector short, int, vector short *);
19086 void vec_xst (vector short, int, short *);
19087 void vec_xst (vector unsigned short, int, vector unsigned short *);
19088 void vec_xst (vector unsigned short, int, unsigned short *);
19089 void vec_xst (vector char, int, vector char *);
19090 void vec_xst (vector char, int, char *);
19091 void vec_xst (vector unsigned char, int, vector unsigned char *);
19092 void vec_xst (vector unsigned char, int, unsigned char *);
19094 @node PowerPC Hardware Transactional Memory Built-in Functions
19095 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19096 GCC provides two interfaces for accessing the Hardware Transactional
19097 Memory (HTM) instructions available on some of the PowerPC family
19098 of processors (eg, POWER8).  The two interfaces come in a low level
19099 interface, consisting of built-in functions specific to PowerPC and a
19100 higher level interface consisting of inline functions that are common
19101 between PowerPC and S/390.
19103 @subsubsection PowerPC HTM Low Level Built-in Functions
19105 The following low level built-in functions are available with
19106 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19107 They all generate the machine instruction that is part of the name.
19109 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19110 the full 4-bit condition register value set by their associated hardware
19111 instruction.  The header file @code{htmintrin.h} defines some macros that can
19112 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
19113 returns a simple true or false value depending on whether a transaction was
19114 successfully started or not.  The arguments of the builtins match exactly the
19115 type and order of the associated hardware instruction's operands, except for
19116 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19117 Refer to the ISA manual for a description of each instruction's operands.
19119 @smallexample
19120 unsigned int __builtin_tbegin (unsigned int)
19121 unsigned int __builtin_tend (unsigned int)
19123 unsigned int __builtin_tabort (unsigned int)
19124 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19125 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19126 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19127 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19129 unsigned int __builtin_tcheck (void)
19130 unsigned int __builtin_treclaim (unsigned int)
19131 unsigned int __builtin_trechkpt (void)
19132 unsigned int __builtin_tsr (unsigned int)
19133 @end smallexample
19135 In addition to the above HTM built-ins, we have added built-ins for
19136 some common extended mnemonics of the HTM instructions:
19138 @smallexample
19139 unsigned int __builtin_tendall (void)
19140 unsigned int __builtin_tresume (void)
19141 unsigned int __builtin_tsuspend (void)
19142 @end smallexample
19144 Note that the semantics of the above HTM builtins are required to mimic
19145 the locking semantics used for critical sections.  Builtins that are used
19146 to create a new transaction or restart a suspended transaction must have
19147 lock acquisition like semantics while those builtins that end or suspend a
19148 transaction must have lock release like semantics.  Specifically, this must
19149 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19150 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19151 that returns 0, and lock release is as-if an execution of
19152 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19153 implicit implementation-defined lock used for all transactions.  The HTM
19154 instructions associated with with the builtins inherently provide the
19155 correct acquisition and release hardware barriers required.  However,
19156 the compiler must also be prohibited from moving loads and stores across
19157 the builtins in a way that would violate their semantics.  This has been
19158 accomplished by adding memory barriers to the associated HTM instructions
19159 (which is a conservative approach to provide acquire and release semantics).
19160 Earlier versions of the compiler did not treat the HTM instructions as
19161 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19162 be used to determine whether the current compiler treats HTM instructions
19163 as memory barriers or not.  This allows the user to explicitly add memory
19164 barriers to their code when using an older version of the compiler.
19166 The following set of built-in functions are available to gain access
19167 to the HTM specific special purpose registers.
19169 @smallexample
19170 unsigned long __builtin_get_texasr (void)
19171 unsigned long __builtin_get_texasru (void)
19172 unsigned long __builtin_get_tfhar (void)
19173 unsigned long __builtin_get_tfiar (void)
19175 void __builtin_set_texasr (unsigned long);
19176 void __builtin_set_texasru (unsigned long);
19177 void __builtin_set_tfhar (unsigned long);
19178 void __builtin_set_tfiar (unsigned long);
19179 @end smallexample
19181 Example usage of these low level built-in functions may look like:
19183 @smallexample
19184 #include <htmintrin.h>
19186 int num_retries = 10;
19188 while (1)
19189   @{
19190     if (__builtin_tbegin (0))
19191       @{
19192         /* Transaction State Initiated.  */
19193         if (is_locked (lock))
19194           __builtin_tabort (0);
19195         ... transaction code...
19196         __builtin_tend (0);
19197         break;
19198       @}
19199     else
19200       @{
19201         /* Transaction State Failed.  Use locks if the transaction
19202            failure is "persistent" or we've tried too many times.  */
19203         if (num_retries-- <= 0
19204             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19205           @{
19206             acquire_lock (lock);
19207             ... non transactional fallback path...
19208             release_lock (lock);
19209             break;
19210           @}
19211       @}
19212   @}
19213 @end smallexample
19215 One final built-in function has been added that returns the value of
19216 the 2-bit Transaction State field of the Machine Status Register (MSR)
19217 as stored in @code{CR0}.
19219 @smallexample
19220 unsigned long __builtin_ttest (void)
19221 @end smallexample
19223 This built-in can be used to determine the current transaction state
19224 using the following code example:
19226 @smallexample
19227 #include <htmintrin.h>
19229 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19231 if (tx_state == _HTM_TRANSACTIONAL)
19232   @{
19233     /* Code to use in transactional state.  */
19234   @}
19235 else if (tx_state == _HTM_NONTRANSACTIONAL)
19236   @{
19237     /* Code to use in non-transactional state.  */
19238   @}
19239 else if (tx_state == _HTM_SUSPENDED)
19240   @{
19241     /* Code to use in transaction suspended state.  */
19242   @}
19243 @end smallexample
19245 @subsubsection PowerPC HTM High Level Inline Functions
19247 The following high level HTM interface is made available by including
19248 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19249 where CPU is `power8' or later.  This interface is common between PowerPC
19250 and S/390, allowing users to write one HTM source implementation that
19251 can be compiled and executed on either system.
19253 @smallexample
19254 long __TM_simple_begin (void)
19255 long __TM_begin (void* const TM_buff)
19256 long __TM_end (void)
19257 void __TM_abort (void)
19258 void __TM_named_abort (unsigned char const code)
19259 void __TM_resume (void)
19260 void __TM_suspend (void)
19262 long __TM_is_user_abort (void* const TM_buff)
19263 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19264 long __TM_is_illegal (void* const TM_buff)
19265 long __TM_is_footprint_exceeded (void* const TM_buff)
19266 long __TM_nesting_depth (void* const TM_buff)
19267 long __TM_is_nested_too_deep(void* const TM_buff)
19268 long __TM_is_conflict(void* const TM_buff)
19269 long __TM_is_failure_persistent(void* const TM_buff)
19270 long __TM_failure_address(void* const TM_buff)
19271 long long __TM_failure_code(void* const TM_buff)
19272 @end smallexample
19274 Using these common set of HTM inline functions, we can create
19275 a more portable version of the HTM example in the previous
19276 section that will work on either PowerPC or S/390:
19278 @smallexample
19279 #include <htmxlintrin.h>
19281 int num_retries = 10;
19282 TM_buff_type TM_buff;
19284 while (1)
19285   @{
19286     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19287       @{
19288         /* Transaction State Initiated.  */
19289         if (is_locked (lock))
19290           __TM_abort ();
19291         ... transaction code...
19292         __TM_end ();
19293         break;
19294       @}
19295     else
19296       @{
19297         /* Transaction State Failed.  Use locks if the transaction
19298            failure is "persistent" or we've tried too many times.  */
19299         if (num_retries-- <= 0
19300             || __TM_is_failure_persistent (TM_buff))
19301           @{
19302             acquire_lock (lock);
19303             ... non transactional fallback path...
19304             release_lock (lock);
19305             break;
19306           @}
19307       @}
19308   @}
19309 @end smallexample
19311 @node PowerPC Atomic Memory Operation Functions
19312 @subsection PowerPC Atomic Memory Operation Functions
19313 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19314 instructions.  GCC provides support for these instructions in 64-bit
19315 environments.  All of the functions are declared in the include file
19316 @code{amo.h}.
19318 The functions supported are:
19320 @smallexample
19321 #include <amo.h>
19323 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19324 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19325 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19326 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19327 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19328 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19329 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19331 int32_t amo_lwat_sadd (int32_t *, int32_t);
19332 int32_t amo_lwat_smax (int32_t *, int32_t);
19333 int32_t amo_lwat_smin (int32_t *, int32_t);
19334 int32_t amo_lwat_sswap (int32_t *, int32_t);
19336 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19337 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19338 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19339 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19340 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19341 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19342 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19344 int64_t amo_ldat_sadd (int64_t *, int64_t);
19345 int64_t amo_ldat_smax (int64_t *, int64_t);
19346 int64_t amo_ldat_smin (int64_t *, int64_t);
19347 int64_t amo_ldat_sswap (int64_t *, int64_t);
19349 void amo_stwat_add (uint32_t *, uint32_t);
19350 void amo_stwat_xor (uint32_t *, uint32_t);
19351 void amo_stwat_ior (uint32_t *, uint32_t);
19352 void amo_stwat_and (uint32_t *, uint32_t);
19353 void amo_stwat_umax (uint32_t *, uint32_t);
19354 void amo_stwat_umin (uint32_t *, uint32_t);
19356 void amo_stwat_sadd (int32_t *, int32_t);
19357 void amo_stwat_smax (int32_t *, int32_t);
19358 void amo_stwat_smin (int32_t *, int32_t);
19360 void amo_stdat_add (uint64_t *, uint64_t);
19361 void amo_stdat_xor (uint64_t *, uint64_t);
19362 void amo_stdat_ior (uint64_t *, uint64_t);
19363 void amo_stdat_and (uint64_t *, uint64_t);
19364 void amo_stdat_umax (uint64_t *, uint64_t);
19365 void amo_stdat_umin (uint64_t *, uint64_t);
19367 void amo_stdat_sadd (int64_t *, int64_t);
19368 void amo_stdat_smax (int64_t *, int64_t);
19369 void amo_stdat_smin (int64_t *, int64_t);
19370 @end smallexample
19372 @node RX Built-in Functions
19373 @subsection RX Built-in Functions
19374 GCC supports some of the RX instructions which cannot be expressed in
19375 the C programming language via the use of built-in functions.  The
19376 following functions are supported:
19378 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19379 Generates the @code{brk} machine instruction.
19380 @end deftypefn
19382 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19383 Generates the @code{clrpsw} machine instruction to clear the specified
19384 bit in the processor status word.
19385 @end deftypefn
19387 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19388 Generates the @code{int} machine instruction to generate an interrupt
19389 with the specified value.
19390 @end deftypefn
19392 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19393 Generates the @code{machi} machine instruction to add the result of
19394 multiplying the top 16 bits of the two arguments into the
19395 accumulator.
19396 @end deftypefn
19398 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19399 Generates the @code{maclo} machine instruction to add the result of
19400 multiplying the bottom 16 bits of the two arguments into the
19401 accumulator.
19402 @end deftypefn
19404 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19405 Generates the @code{mulhi} machine instruction to place the result of
19406 multiplying the top 16 bits of the two arguments into the
19407 accumulator.
19408 @end deftypefn
19410 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19411 Generates the @code{mullo} machine instruction to place the result of
19412 multiplying the bottom 16 bits of the two arguments into the
19413 accumulator.
19414 @end deftypefn
19416 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19417 Generates the @code{mvfachi} machine instruction to read the top
19418 32 bits of the accumulator.
19419 @end deftypefn
19421 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19422 Generates the @code{mvfacmi} machine instruction to read the middle
19423 32 bits of the accumulator.
19424 @end deftypefn
19426 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19427 Generates the @code{mvfc} machine instruction which reads the control
19428 register specified in its argument and returns its value.
19429 @end deftypefn
19431 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19432 Generates the @code{mvtachi} machine instruction to set the top
19433 32 bits of the accumulator.
19434 @end deftypefn
19436 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19437 Generates the @code{mvtaclo} machine instruction to set the bottom
19438 32 bits of the accumulator.
19439 @end deftypefn
19441 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19442 Generates the @code{mvtc} machine instruction which sets control
19443 register number @code{reg} to @code{val}.
19444 @end deftypefn
19446 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19447 Generates the @code{mvtipl} machine instruction set the interrupt
19448 priority level.
19449 @end deftypefn
19451 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19452 Generates the @code{racw} machine instruction to round the accumulator
19453 according to the specified mode.
19454 @end deftypefn
19456 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19457 Generates the @code{revw} machine instruction which swaps the bytes in
19458 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19459 and also bits 16--23 occupy bits 24--31 and vice versa.
19460 @end deftypefn
19462 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19463 Generates the @code{rmpa} machine instruction which initiates a
19464 repeated multiply and accumulate sequence.
19465 @end deftypefn
19467 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19468 Generates the @code{round} machine instruction which returns the
19469 floating-point argument rounded according to the current rounding mode
19470 set in the floating-point status word register.
19471 @end deftypefn
19473 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19474 Generates the @code{sat} machine instruction which returns the
19475 saturated value of the argument.
19476 @end deftypefn
19478 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19479 Generates the @code{setpsw} machine instruction to set the specified
19480 bit in the processor status word.
19481 @end deftypefn
19483 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19484 Generates the @code{wait} machine instruction.
19485 @end deftypefn
19487 @node S/390 System z Built-in Functions
19488 @subsection S/390 System z Built-in Functions
19489 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19490 Generates the @code{tbegin} machine instruction starting a
19491 non-constrained hardware transaction.  If the parameter is non-NULL the
19492 memory area is used to store the transaction diagnostic buffer and
19493 will be passed as first operand to @code{tbegin}.  This buffer can be
19494 defined using the @code{struct __htm_tdb} C struct defined in
19495 @code{htmintrin.h} and must reside on a double-word boundary.  The
19496 second tbegin operand is set to @code{0xff0c}. This enables
19497 save/restore of all GPRs and disables aborts for FPR and AR
19498 manipulations inside the transaction body.  The condition code set by
19499 the tbegin instruction is returned as integer value.  The tbegin
19500 instruction by definition overwrites the content of all FPRs.  The
19501 compiler will generate code which saves and restores the FPRs.  For
19502 soft-float code it is recommended to used the @code{*_nofloat}
19503 variant.  In order to prevent a TDB from being written it is required
19504 to pass a constant zero value as parameter.  Passing a zero value
19505 through a variable is not sufficient.  Although modifications of
19506 access registers inside the transaction will not trigger an
19507 transaction abort it is not supported to actually modify them.  Access
19508 registers do not get saved when entering a transaction. They will have
19509 undefined state when reaching the abort code.
19510 @end deftypefn
19512 Macros for the possible return codes of tbegin are defined in the
19513 @code{htmintrin.h} header file:
19515 @table @code
19516 @item _HTM_TBEGIN_STARTED
19517 @code{tbegin} has been executed as part of normal processing.  The
19518 transaction body is supposed to be executed.
19519 @item _HTM_TBEGIN_INDETERMINATE
19520 The transaction was aborted due to an indeterminate condition which
19521 might be persistent.
19522 @item _HTM_TBEGIN_TRANSIENT
19523 The transaction aborted due to a transient failure.  The transaction
19524 should be re-executed in that case.
19525 @item _HTM_TBEGIN_PERSISTENT
19526 The transaction aborted due to a persistent failure.  Re-execution
19527 under same circumstances will not be productive.
19528 @end table
19530 @defmac _HTM_FIRST_USER_ABORT_CODE
19531 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19532 specifies the first abort code which can be used for
19533 @code{__builtin_tabort}.  Values below this threshold are reserved for
19534 machine use.
19535 @end defmac
19537 @deftp {Data type} {struct __htm_tdb}
19538 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19539 the structure of the transaction diagnostic block as specified in the
19540 Principles of Operation manual chapter 5-91.
19541 @end deftp
19543 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19544 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19545 Using this variant in code making use of FPRs will leave the FPRs in
19546 undefined state when entering the transaction abort handler code.
19547 @end deftypefn
19549 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19550 In addition to @code{__builtin_tbegin} a loop for transient failures
19551 is generated.  If tbegin returns a condition code of 2 the transaction
19552 will be retried as often as specified in the second argument.  The
19553 perform processor assist instruction is used to tell the CPU about the
19554 number of fails so far.
19555 @end deftypefn
19557 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19558 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19559 restores.  Using this variant in code making use of FPRs will leave
19560 the FPRs in undefined state when entering the transaction abort
19561 handler code.
19562 @end deftypefn
19564 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19565 Generates the @code{tbeginc} machine instruction starting a constrained
19566 hardware transaction.  The second operand is set to @code{0xff08}.
19567 @end deftypefn
19569 @deftypefn {Built-in Function} int __builtin_tend (void)
19570 Generates the @code{tend} machine instruction finishing a transaction
19571 and making the changes visible to other threads.  The condition code
19572 generated by tend is returned as integer value.
19573 @end deftypefn
19575 @deftypefn {Built-in Function} void __builtin_tabort (int)
19576 Generates the @code{tabort} machine instruction with the specified
19577 abort code.  Abort codes from 0 through 255 are reserved and will
19578 result in an error message.
19579 @end deftypefn
19581 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19582 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19583 integer parameter is loaded into rX and a value of zero is loaded into
19584 rY.  The integer parameter specifies the number of times the
19585 transaction repeatedly aborted.
19586 @end deftypefn
19588 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19589 Generates the @code{etnd} machine instruction.  The current nesting
19590 depth is returned as integer value.  For a nesting depth of 0 the code
19591 is not executed as part of an transaction.
19592 @end deftypefn
19594 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19596 Generates the @code{ntstg} machine instruction.  The second argument
19597 is written to the first arguments location.  The store operation will
19598 not be rolled-back in case of an transaction abort.
19599 @end deftypefn
19601 @node SH Built-in Functions
19602 @subsection SH Built-in Functions
19603 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19604 families of processors:
19606 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19607 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
19608 used by system code that manages threads and execution contexts.  The compiler
19609 normally does not generate code that modifies the contents of @samp{GBR} and
19610 thus the value is preserved across function calls.  Changing the @samp{GBR}
19611 value in user code must be done with caution, since the compiler might use
19612 @samp{GBR} in order to access thread local variables.
19614 @end deftypefn
19616 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19617 Returns the value that is currently set in the @samp{GBR} register.
19618 Memory loads and stores that use the thread pointer as a base address are
19619 turned into @samp{GBR} based displacement loads and stores, if possible.
19620 For example:
19621 @smallexample
19622 struct my_tcb
19624    int a, b, c, d, e;
19627 int get_tcb_value (void)
19629   // Generate @samp{mov.l @@(8,gbr),r0} instruction
19630   return ((my_tcb*)__builtin_thread_pointer ())->c;
19633 @end smallexample
19634 @end deftypefn
19636 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19637 Returns the value that is currently set in the @samp{FPSCR} register.
19638 @end deftypefn
19640 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19641 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19642 preserving the current values of the FR, SZ and PR bits.
19643 @end deftypefn
19645 @node SPARC VIS Built-in Functions
19646 @subsection SPARC VIS Built-in Functions
19648 GCC supports SIMD operations on the SPARC using both the generic vector
19649 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19650 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
19651 switch, the VIS extension is exposed as the following built-in functions:
19653 @smallexample
19654 typedef int v1si __attribute__ ((vector_size (4)));
19655 typedef int v2si __attribute__ ((vector_size (8)));
19656 typedef short v4hi __attribute__ ((vector_size (8)));
19657 typedef short v2hi __attribute__ ((vector_size (4)));
19658 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19659 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19661 void __builtin_vis_write_gsr (int64_t);
19662 int64_t __builtin_vis_read_gsr (void);
19664 void * __builtin_vis_alignaddr (void *, long);
19665 void * __builtin_vis_alignaddrl (void *, long);
19666 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19667 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19668 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19669 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19671 v4hi __builtin_vis_fexpand (v4qi);
19673 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19674 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19675 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19676 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19677 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19678 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19679 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19681 v4qi __builtin_vis_fpack16 (v4hi);
19682 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19683 v2hi __builtin_vis_fpackfix (v2si);
19684 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19686 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19688 long __builtin_vis_edge8 (void *, void *);
19689 long __builtin_vis_edge8l (void *, void *);
19690 long __builtin_vis_edge16 (void *, void *);
19691 long __builtin_vis_edge16l (void *, void *);
19692 long __builtin_vis_edge32 (void *, void *);
19693 long __builtin_vis_edge32l (void *, void *);
19695 long __builtin_vis_fcmple16 (v4hi, v4hi);
19696 long __builtin_vis_fcmple32 (v2si, v2si);
19697 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19698 long __builtin_vis_fcmpne32 (v2si, v2si);
19699 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19700 long __builtin_vis_fcmpgt32 (v2si, v2si);
19701 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19702 long __builtin_vis_fcmpeq32 (v2si, v2si);
19704 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19705 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19706 v2si __builtin_vis_fpadd32 (v2si, v2si);
19707 v1si __builtin_vis_fpadd32s (v1si, v1si);
19708 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19709 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19710 v2si __builtin_vis_fpsub32 (v2si, v2si);
19711 v1si __builtin_vis_fpsub32s (v1si, v1si);
19713 long __builtin_vis_array8 (long, long);
19714 long __builtin_vis_array16 (long, long);
19715 long __builtin_vis_array32 (long, long);
19716 @end smallexample
19718 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19719 functions also become available:
19721 @smallexample
19722 long __builtin_vis_bmask (long, long);
19723 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19724 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19725 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19726 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19728 long __builtin_vis_edge8n (void *, void *);
19729 long __builtin_vis_edge8ln (void *, void *);
19730 long __builtin_vis_edge16n (void *, void *);
19731 long __builtin_vis_edge16ln (void *, void *);
19732 long __builtin_vis_edge32n (void *, void *);
19733 long __builtin_vis_edge32ln (void *, void *);
19734 @end smallexample
19736 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19737 functions also become available:
19739 @smallexample
19740 void __builtin_vis_cmask8 (long);
19741 void __builtin_vis_cmask16 (long);
19742 void __builtin_vis_cmask32 (long);
19744 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19746 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19747 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19748 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19749 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19750 v2si __builtin_vis_fsll16 (v2si, v2si);
19751 v2si __builtin_vis_fslas16 (v2si, v2si);
19752 v2si __builtin_vis_fsrl16 (v2si, v2si);
19753 v2si __builtin_vis_fsra16 (v2si, v2si);
19755 long __builtin_vis_pdistn (v8qi, v8qi);
19757 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19759 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19760 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19762 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19763 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19764 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19765 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19766 v2si __builtin_vis_fpadds32 (v2si, v2si);
19767 v1si __builtin_vis_fpadds32s (v1si, v1si);
19768 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19769 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19771 long __builtin_vis_fucmple8 (v8qi, v8qi);
19772 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19773 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19774 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19776 float __builtin_vis_fhadds (float, float);
19777 double __builtin_vis_fhaddd (double, double);
19778 float __builtin_vis_fhsubs (float, float);
19779 double __builtin_vis_fhsubd (double, double);
19780 float __builtin_vis_fnhadds (float, float);
19781 double __builtin_vis_fnhaddd (double, double);
19783 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19784 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19785 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19786 @end smallexample
19788 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19789 functions also become available:
19791 @smallexample
19792 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19793 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19794 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19795 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19797 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19798 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19799 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19800 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19802 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19803 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19804 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19805 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19806 long __builtin_vis_fpcmpule32 (v2si, v2si);
19807 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19809 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19810 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19811 v2si __builtin_vis_fpmax32 (v2si, v2si);
19813 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19814 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19815 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19818 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19819 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19820 v2si __builtin_vis_fpmin32 (v2si, v2si);
19822 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19823 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19824 v2si __builtin_vis_fpminu32 (v2si, v2si);
19825 @end smallexample
19827 When you use the @option{-mvis4b} switch, the VIS version 4.0B
19828 built-in functions also become available:
19830 @smallexample
19831 v8qi __builtin_vis_dictunpack8 (double, int);
19832 v4hi __builtin_vis_dictunpack16 (double, int);
19833 v2si __builtin_vis_dictunpack32 (double, int);
19835 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
19836 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
19837 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
19838 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
19840 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
19841 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
19842 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
19843 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
19845 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
19846 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
19847 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
19848 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
19850 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
19851 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
19852 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
19853 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
19854 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
19855 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
19857 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
19858 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
19859 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
19861 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
19862 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
19863 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
19864 @end smallexample
19866 @node SPU Built-in Functions
19867 @subsection SPU Built-in Functions
19869 GCC provides extensions for the SPU processor as described in the
19870 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
19871 implementation differs in several ways.
19873 @itemize @bullet
19875 @item
19876 The optional extension of specifying vector constants in parentheses is
19877 not supported.
19879 @item
19880 A vector initializer requires no cast if the vector constant is of the
19881 same type as the variable it is initializing.
19883 @item
19884 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19885 vector type is the default signedness of the base type.  The default
19886 varies depending on the operating system, so a portable program should
19887 always specify the signedness.
19889 @item
19890 By default, the keyword @code{__vector} is added. The macro
19891 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19892 undefined.
19894 @item
19895 GCC allows using a @code{typedef} name as the type specifier for a
19896 vector type.
19898 @item
19899 For C, overloaded functions are implemented with macros so the following
19900 does not work:
19902 @smallexample
19903   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
19904 @end smallexample
19906 @noindent
19907 Since @code{spu_add} is a macro, the vector constant in the example
19908 is treated as four separate arguments.  Wrap the entire argument in
19909 parentheses for this to work.
19911 @item
19912 The extended version of @code{__builtin_expect} is not supported.
19914 @end itemize
19916 @emph{Note:} Only the interface described in the aforementioned
19917 specification is supported. Internally, GCC uses built-in functions to
19918 implement the required functionality, but these are not supported and
19919 are subject to change without notice.
19921 @node TI C6X Built-in Functions
19922 @subsection TI C6X Built-in Functions
19924 GCC provides intrinsics to access certain instructions of the TI C6X
19925 processors.  These intrinsics, listed below, are available after
19926 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
19927 to C6X instructions.
19929 @smallexample
19931 int _sadd (int, int)
19932 int _ssub (int, int)
19933 int _sadd2 (int, int)
19934 int _ssub2 (int, int)
19935 long long _mpy2 (int, int)
19936 long long _smpy2 (int, int)
19937 int _add4 (int, int)
19938 int _sub4 (int, int)
19939 int _saddu4 (int, int)
19941 int _smpy (int, int)
19942 int _smpyh (int, int)
19943 int _smpyhl (int, int)
19944 int _smpylh (int, int)
19946 int _sshl (int, int)
19947 int _subc (int, int)
19949 int _avg2 (int, int)
19950 int _avgu4 (int, int)
19952 int _clrr (int, int)
19953 int _extr (int, int)
19954 int _extru (int, int)
19955 int _abs (int)
19956 int _abs2 (int)
19958 @end smallexample
19960 @node TILE-Gx Built-in Functions
19961 @subsection TILE-Gx Built-in Functions
19963 GCC provides intrinsics to access every instruction of the TILE-Gx
19964 processor.  The intrinsics are of the form:
19966 @smallexample
19968 unsigned long long __insn_@var{op} (...)
19970 @end smallexample
19972 Where @var{op} is the name of the instruction.  Refer to the ISA manual
19973 for the complete list of instructions.
19975 GCC also provides intrinsics to directly access the network registers.
19976 The intrinsics are:
19978 @smallexample
19980 unsigned long long __tile_idn0_receive (void)
19981 unsigned long long __tile_idn1_receive (void)
19982 unsigned long long __tile_udn0_receive (void)
19983 unsigned long long __tile_udn1_receive (void)
19984 unsigned long long __tile_udn2_receive (void)
19985 unsigned long long __tile_udn3_receive (void)
19986 void __tile_idn_send (unsigned long long)
19987 void __tile_udn_send (unsigned long long)
19989 @end smallexample
19991 The intrinsic @code{void __tile_network_barrier (void)} is used to
19992 guarantee that no network operations before it are reordered with
19993 those after it.
19995 @node TILEPro Built-in Functions
19996 @subsection TILEPro Built-in Functions
19998 GCC provides intrinsics to access every instruction of the TILEPro
19999 processor.  The intrinsics are of the form:
20001 @smallexample
20003 unsigned __insn_@var{op} (...)
20005 @end smallexample
20007 @noindent
20008 where @var{op} is the name of the instruction.  Refer to the ISA manual
20009 for the complete list of instructions.
20011 GCC also provides intrinsics to directly access the network registers.
20012 The intrinsics are:
20014 @smallexample
20016 unsigned __tile_idn0_receive (void)
20017 unsigned __tile_idn1_receive (void)
20018 unsigned __tile_sn_receive (void)
20019 unsigned __tile_udn0_receive (void)
20020 unsigned __tile_udn1_receive (void)
20021 unsigned __tile_udn2_receive (void)
20022 unsigned __tile_udn3_receive (void)
20023 void __tile_idn_send (unsigned)
20024 void __tile_sn_send (unsigned)
20025 void __tile_udn_send (unsigned)
20027 @end smallexample
20029 The intrinsic @code{void __tile_network_barrier (void)} is used to
20030 guarantee that no network operations before it are reordered with
20031 those after it.
20033 @node x86 Built-in Functions
20034 @subsection x86 Built-in Functions
20036 These built-in functions are available for the x86-32 and x86-64 family
20037 of computers, depending on the command-line switches used.
20039 If you specify command-line switches such as @option{-msse},
20040 the compiler could use the extended instruction sets even if the built-ins
20041 are not used explicitly in the program.  For this reason, applications
20042 that perform run-time CPU detection must compile separate files for each
20043 supported architecture, using the appropriate flags.  In particular,
20044 the file containing the CPU detection code should be compiled without
20045 these options.
20047 The following machine modes are available for use with MMX built-in functions
20048 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20049 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20050 vector of eight 8-bit integers.  Some of the built-in functions operate on
20051 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20053 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20054 of two 32-bit floating-point values.
20056 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20057 floating-point values.  Some instructions use a vector of four 32-bit
20058 integers, these use @code{V4SI}.  Finally, some instructions operate on an
20059 entire vector register, interpreting it as a 128-bit integer, these use mode
20060 @code{TI}.
20062 The x86-32 and x86-64 family of processors use additional built-in
20063 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20064 floating point and @code{TC} 128-bit complex floating-point values.
20066 The following floating-point built-in functions are always available.  All
20067 of them implement the function that is part of the name.
20069 @smallexample
20070 __float128 __builtin_fabsq (__float128)
20071 __float128 __builtin_copysignq (__float128, __float128)
20072 @end smallexample
20074 The following built-in functions are always available.
20076 @table @code
20077 @item __float128 __builtin_infq (void)
20078 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20079 @findex __builtin_infq
20081 @item __float128 __builtin_huge_valq (void)
20082 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20083 @findex __builtin_huge_valq
20085 @item __float128 __builtin_nanq (void)
20086 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20087 @findex __builtin_nanq
20089 @item __float128 __builtin_nansq (void)
20090 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20091 @findex __builtin_nansq
20092 @end table
20094 The following built-in function is always available.
20096 @table @code
20097 @item void __builtin_ia32_pause (void)
20098 Generates the @code{pause} machine instruction with a compiler memory
20099 barrier.
20100 @end table
20102 The following built-in functions are always available and can be used to
20103 check the target platform type.
20105 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20106 This function runs the CPU detection code to check the type of CPU and the
20107 features supported.  This built-in function needs to be invoked along with the built-in functions
20108 to check CPU type and features, @code{__builtin_cpu_is} and
20109 @code{__builtin_cpu_supports}, only when used in a function that is
20110 executed before any constructors are called.  The CPU detection code is
20111 automatically executed in a very high priority constructor.
20113 For example, this function has to be used in @code{ifunc} resolvers that
20114 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20115 and @code{__builtin_cpu_supports}, or in constructors on targets that
20116 don't support constructor priority.
20117 @smallexample
20119 static void (*resolve_memcpy (void)) (void)
20121   // ifunc resolvers fire before constructors, explicitly call the init
20122   // function.
20123   __builtin_cpu_init ();
20124   if (__builtin_cpu_supports ("ssse3"))
20125     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20126   else
20127     return default_memcpy;
20130 void *memcpy (void *, const void *, size_t)
20131      __attribute__ ((ifunc ("resolve_memcpy")));
20132 @end smallexample
20134 @end deftypefn
20136 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20137 This function returns a positive integer if the run-time CPU
20138 is of type @var{cpuname}
20139 and returns @code{0} otherwise. The following CPU names can be detected:
20141 @table @samp
20142 @item intel
20143 Intel CPU.
20145 @item atom
20146 Intel Atom CPU.
20148 @item core2
20149 Intel Core 2 CPU.
20151 @item corei7
20152 Intel Core i7 CPU.
20154 @item nehalem
20155 Intel Core i7 Nehalem CPU.
20157 @item westmere
20158 Intel Core i7 Westmere CPU.
20160 @item sandybridge
20161 Intel Core i7 Sandy Bridge CPU.
20163 @item amd
20164 AMD CPU.
20166 @item amdfam10h
20167 AMD Family 10h CPU.
20169 @item barcelona
20170 AMD Family 10h Barcelona CPU.
20172 @item shanghai
20173 AMD Family 10h Shanghai CPU.
20175 @item istanbul
20176 AMD Family 10h Istanbul CPU.
20178 @item btver1
20179 AMD Family 14h CPU.
20181 @item amdfam15h
20182 AMD Family 15h CPU.
20184 @item bdver1
20185 AMD Family 15h Bulldozer version 1.
20187 @item bdver2
20188 AMD Family 15h Bulldozer version 2.
20190 @item bdver3
20191 AMD Family 15h Bulldozer version 3.
20193 @item bdver4
20194 AMD Family 15h Bulldozer version 4.
20196 @item btver2
20197 AMD Family 16h CPU.
20199 @item amdfam17h
20200 AMD Family 17h CPU.
20202 @item znver1
20203 AMD Family 17h Zen version 1.
20204 @end table
20206 Here is an example:
20207 @smallexample
20208 if (__builtin_cpu_is ("corei7"))
20209   @{
20210      do_corei7 (); // Core i7 specific implementation.
20211   @}
20212 else
20213   @{
20214      do_generic (); // Generic implementation.
20215   @}
20216 @end smallexample
20217 @end deftypefn
20219 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20220 This function returns a positive integer if the run-time CPU
20221 supports @var{feature}
20222 and returns @code{0} otherwise. The following features can be detected:
20224 @table @samp
20225 @item cmov
20226 CMOV instruction.
20227 @item mmx
20228 MMX instructions.
20229 @item popcnt
20230 POPCNT instruction.
20231 @item sse
20232 SSE instructions.
20233 @item sse2
20234 SSE2 instructions.
20235 @item sse3
20236 SSE3 instructions.
20237 @item ssse3
20238 SSSE3 instructions.
20239 @item sse4.1
20240 SSE4.1 instructions.
20241 @item sse4.2
20242 SSE4.2 instructions.
20243 @item avx
20244 AVX instructions.
20245 @item avx2
20246 AVX2 instructions.
20247 @item avx512f
20248 AVX512F instructions.
20249 @end table
20251 Here is an example:
20252 @smallexample
20253 if (__builtin_cpu_supports ("popcnt"))
20254   @{
20255      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20256   @}
20257 else
20258   @{
20259      count = generic_countbits (n); //generic implementation.
20260   @}
20261 @end smallexample
20262 @end deftypefn
20265 The following built-in functions are made available by @option{-mmmx}.
20266 All of them generate the machine instruction that is part of the name.
20268 @smallexample
20269 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20270 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20271 v2si __builtin_ia32_paddd (v2si, v2si)
20272 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20273 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20274 v2si __builtin_ia32_psubd (v2si, v2si)
20275 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20276 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20277 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20278 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20279 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20280 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20281 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20282 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20283 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20284 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20285 di __builtin_ia32_pand (di, di)
20286 di __builtin_ia32_pandn (di,di)
20287 di __builtin_ia32_por (di, di)
20288 di __builtin_ia32_pxor (di, di)
20289 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20290 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20291 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20292 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20293 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20294 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20295 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20296 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20297 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20298 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20299 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20300 v2si __builtin_ia32_punpckldq (v2si, v2si)
20301 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20302 v4hi __builtin_ia32_packssdw (v2si, v2si)
20303 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20305 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20306 v2si __builtin_ia32_pslld (v2si, v2si)
20307 v1di __builtin_ia32_psllq (v1di, v1di)
20308 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20309 v2si __builtin_ia32_psrld (v2si, v2si)
20310 v1di __builtin_ia32_psrlq (v1di, v1di)
20311 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20312 v2si __builtin_ia32_psrad (v2si, v2si)
20313 v4hi __builtin_ia32_psllwi (v4hi, int)
20314 v2si __builtin_ia32_pslldi (v2si, int)
20315 v1di __builtin_ia32_psllqi (v1di, int)
20316 v4hi __builtin_ia32_psrlwi (v4hi, int)
20317 v2si __builtin_ia32_psrldi (v2si, int)
20318 v1di __builtin_ia32_psrlqi (v1di, int)
20319 v4hi __builtin_ia32_psrawi (v4hi, int)
20320 v2si __builtin_ia32_psradi (v2si, int)
20322 @end smallexample
20324 The following built-in functions are made available either with
20325 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20326 the machine instruction that is part of the name.
20328 @smallexample
20329 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20330 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20331 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20332 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20333 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20334 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20335 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20336 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20337 int __builtin_ia32_pmovmskb (v8qi)
20338 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20339 void __builtin_ia32_movntq (di *, di)
20340 void __builtin_ia32_sfence (void)
20341 @end smallexample
20343 The following built-in functions are available when @option{-msse} is used.
20344 All of them generate the machine instruction that is part of the name.
20346 @smallexample
20347 int __builtin_ia32_comieq (v4sf, v4sf)
20348 int __builtin_ia32_comineq (v4sf, v4sf)
20349 int __builtin_ia32_comilt (v4sf, v4sf)
20350 int __builtin_ia32_comile (v4sf, v4sf)
20351 int __builtin_ia32_comigt (v4sf, v4sf)
20352 int __builtin_ia32_comige (v4sf, v4sf)
20353 int __builtin_ia32_ucomieq (v4sf, v4sf)
20354 int __builtin_ia32_ucomineq (v4sf, v4sf)
20355 int __builtin_ia32_ucomilt (v4sf, v4sf)
20356 int __builtin_ia32_ucomile (v4sf, v4sf)
20357 int __builtin_ia32_ucomigt (v4sf, v4sf)
20358 int __builtin_ia32_ucomige (v4sf, v4sf)
20359 v4sf __builtin_ia32_addps (v4sf, v4sf)
20360 v4sf __builtin_ia32_subps (v4sf, v4sf)
20361 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20362 v4sf __builtin_ia32_divps (v4sf, v4sf)
20363 v4sf __builtin_ia32_addss (v4sf, v4sf)
20364 v4sf __builtin_ia32_subss (v4sf, v4sf)
20365 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20366 v4sf __builtin_ia32_divss (v4sf, v4sf)
20367 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20368 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20369 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20370 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20371 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20372 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20373 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20374 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20375 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20376 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20377 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20378 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20379 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20380 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20381 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20382 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20383 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20384 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20385 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20386 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20387 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20388 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20389 v4sf __builtin_ia32_minps (v4sf, v4sf)
20390 v4sf __builtin_ia32_minss (v4sf, v4sf)
20391 v4sf __builtin_ia32_andps (v4sf, v4sf)
20392 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20393 v4sf __builtin_ia32_orps (v4sf, v4sf)
20394 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20395 v4sf __builtin_ia32_movss (v4sf, v4sf)
20396 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20397 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20398 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20399 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20400 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20401 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20402 v2si __builtin_ia32_cvtps2pi (v4sf)
20403 int __builtin_ia32_cvtss2si (v4sf)
20404 v2si __builtin_ia32_cvttps2pi (v4sf)
20405 int __builtin_ia32_cvttss2si (v4sf)
20406 v4sf __builtin_ia32_rcpps (v4sf)
20407 v4sf __builtin_ia32_rsqrtps (v4sf)
20408 v4sf __builtin_ia32_sqrtps (v4sf)
20409 v4sf __builtin_ia32_rcpss (v4sf)
20410 v4sf __builtin_ia32_rsqrtss (v4sf)
20411 v4sf __builtin_ia32_sqrtss (v4sf)
20412 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20413 void __builtin_ia32_movntps (float *, v4sf)
20414 int __builtin_ia32_movmskps (v4sf)
20415 @end smallexample
20417 The following built-in functions are available when @option{-msse} is used.
20419 @table @code
20420 @item v4sf __builtin_ia32_loadups (float *)
20421 Generates the @code{movups} machine instruction as a load from memory.
20422 @item void __builtin_ia32_storeups (float *, v4sf)
20423 Generates the @code{movups} machine instruction as a store to memory.
20424 @item v4sf __builtin_ia32_loadss (float *)
20425 Generates the @code{movss} machine instruction as a load from memory.
20426 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20427 Generates the @code{movhps} machine instruction as a load from memory.
20428 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20429 Generates the @code{movlps} machine instruction as a load from memory
20430 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20431 Generates the @code{movhps} machine instruction as a store to memory.
20432 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20433 Generates the @code{movlps} machine instruction as a store to memory.
20434 @end table
20436 The following built-in functions are available when @option{-msse2} is used.
20437 All of them generate the machine instruction that is part of the name.
20439 @smallexample
20440 int __builtin_ia32_comisdeq (v2df, v2df)
20441 int __builtin_ia32_comisdlt (v2df, v2df)
20442 int __builtin_ia32_comisdle (v2df, v2df)
20443 int __builtin_ia32_comisdgt (v2df, v2df)
20444 int __builtin_ia32_comisdge (v2df, v2df)
20445 int __builtin_ia32_comisdneq (v2df, v2df)
20446 int __builtin_ia32_ucomisdeq (v2df, v2df)
20447 int __builtin_ia32_ucomisdlt (v2df, v2df)
20448 int __builtin_ia32_ucomisdle (v2df, v2df)
20449 int __builtin_ia32_ucomisdgt (v2df, v2df)
20450 int __builtin_ia32_ucomisdge (v2df, v2df)
20451 int __builtin_ia32_ucomisdneq (v2df, v2df)
20452 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20453 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20454 v2df __builtin_ia32_cmplepd (v2df, v2df)
20455 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20456 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20457 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20458 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20459 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20460 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20461 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20462 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20463 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20464 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20465 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20466 v2df __builtin_ia32_cmplesd (v2df, v2df)
20467 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20468 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20469 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20470 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20471 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20472 v2di __builtin_ia32_paddq (v2di, v2di)
20473 v2di __builtin_ia32_psubq (v2di, v2di)
20474 v2df __builtin_ia32_addpd (v2df, v2df)
20475 v2df __builtin_ia32_subpd (v2df, v2df)
20476 v2df __builtin_ia32_mulpd (v2df, v2df)
20477 v2df __builtin_ia32_divpd (v2df, v2df)
20478 v2df __builtin_ia32_addsd (v2df, v2df)
20479 v2df __builtin_ia32_subsd (v2df, v2df)
20480 v2df __builtin_ia32_mulsd (v2df, v2df)
20481 v2df __builtin_ia32_divsd (v2df, v2df)
20482 v2df __builtin_ia32_minpd (v2df, v2df)
20483 v2df __builtin_ia32_maxpd (v2df, v2df)
20484 v2df __builtin_ia32_minsd (v2df, v2df)
20485 v2df __builtin_ia32_maxsd (v2df, v2df)
20486 v2df __builtin_ia32_andpd (v2df, v2df)
20487 v2df __builtin_ia32_andnpd (v2df, v2df)
20488 v2df __builtin_ia32_orpd (v2df, v2df)
20489 v2df __builtin_ia32_xorpd (v2df, v2df)
20490 v2df __builtin_ia32_movsd (v2df, v2df)
20491 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20492 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20493 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20494 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20495 v4si __builtin_ia32_paddd128 (v4si, v4si)
20496 v2di __builtin_ia32_paddq128 (v2di, v2di)
20497 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20498 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20499 v4si __builtin_ia32_psubd128 (v4si, v4si)
20500 v2di __builtin_ia32_psubq128 (v2di, v2di)
20501 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20502 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20503 v2di __builtin_ia32_pand128 (v2di, v2di)
20504 v2di __builtin_ia32_pandn128 (v2di, v2di)
20505 v2di __builtin_ia32_por128 (v2di, v2di)
20506 v2di __builtin_ia32_pxor128 (v2di, v2di)
20507 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20508 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20509 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20510 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20511 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20512 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20513 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20514 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20515 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20516 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20517 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20518 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20519 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20520 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20521 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20522 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20523 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20524 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20525 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20526 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20527 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20528 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20529 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20530 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20531 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20532 v2df __builtin_ia32_loadupd (double *)
20533 void __builtin_ia32_storeupd (double *, v2df)
20534 v2df __builtin_ia32_loadhpd (v2df, double const *)
20535 v2df __builtin_ia32_loadlpd (v2df, double const *)
20536 int __builtin_ia32_movmskpd (v2df)
20537 int __builtin_ia32_pmovmskb128 (v16qi)
20538 void __builtin_ia32_movnti (int *, int)
20539 void __builtin_ia32_movnti64 (long long int *, long long int)
20540 void __builtin_ia32_movntpd (double *, v2df)
20541 void __builtin_ia32_movntdq (v2df *, v2df)
20542 v4si __builtin_ia32_pshufd (v4si, int)
20543 v8hi __builtin_ia32_pshuflw (v8hi, int)
20544 v8hi __builtin_ia32_pshufhw (v8hi, int)
20545 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20546 v2df __builtin_ia32_sqrtpd (v2df)
20547 v2df __builtin_ia32_sqrtsd (v2df)
20548 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20549 v2df __builtin_ia32_cvtdq2pd (v4si)
20550 v4sf __builtin_ia32_cvtdq2ps (v4si)
20551 v4si __builtin_ia32_cvtpd2dq (v2df)
20552 v2si __builtin_ia32_cvtpd2pi (v2df)
20553 v4sf __builtin_ia32_cvtpd2ps (v2df)
20554 v4si __builtin_ia32_cvttpd2dq (v2df)
20555 v2si __builtin_ia32_cvttpd2pi (v2df)
20556 v2df __builtin_ia32_cvtpi2pd (v2si)
20557 int __builtin_ia32_cvtsd2si (v2df)
20558 int __builtin_ia32_cvttsd2si (v2df)
20559 long long __builtin_ia32_cvtsd2si64 (v2df)
20560 long long __builtin_ia32_cvttsd2si64 (v2df)
20561 v4si __builtin_ia32_cvtps2dq (v4sf)
20562 v2df __builtin_ia32_cvtps2pd (v4sf)
20563 v4si __builtin_ia32_cvttps2dq (v4sf)
20564 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20565 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20566 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20567 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20568 void __builtin_ia32_clflush (const void *)
20569 void __builtin_ia32_lfence (void)
20570 void __builtin_ia32_mfence (void)
20571 v16qi __builtin_ia32_loaddqu (const char *)
20572 void __builtin_ia32_storedqu (char *, v16qi)
20573 v1di __builtin_ia32_pmuludq (v2si, v2si)
20574 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20575 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20576 v4si __builtin_ia32_pslld128 (v4si, v4si)
20577 v2di __builtin_ia32_psllq128 (v2di, v2di)
20578 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20579 v4si __builtin_ia32_psrld128 (v4si, v4si)
20580 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20581 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20582 v4si __builtin_ia32_psrad128 (v4si, v4si)
20583 v2di __builtin_ia32_pslldqi128 (v2di, int)
20584 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20585 v4si __builtin_ia32_pslldi128 (v4si, int)
20586 v2di __builtin_ia32_psllqi128 (v2di, int)
20587 v2di __builtin_ia32_psrldqi128 (v2di, int)
20588 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20589 v4si __builtin_ia32_psrldi128 (v4si, int)
20590 v2di __builtin_ia32_psrlqi128 (v2di, int)
20591 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20592 v4si __builtin_ia32_psradi128 (v4si, int)
20593 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20594 v2di __builtin_ia32_movq128 (v2di)
20595 @end smallexample
20597 The following built-in functions are available when @option{-msse3} is used.
20598 All of them generate the machine instruction that is part of the name.
20600 @smallexample
20601 v2df __builtin_ia32_addsubpd (v2df, v2df)
20602 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20603 v2df __builtin_ia32_haddpd (v2df, v2df)
20604 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20605 v2df __builtin_ia32_hsubpd (v2df, v2df)
20606 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20607 v16qi __builtin_ia32_lddqu (char const *)
20608 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20609 v4sf __builtin_ia32_movshdup (v4sf)
20610 v4sf __builtin_ia32_movsldup (v4sf)
20611 void __builtin_ia32_mwait (unsigned int, unsigned int)
20612 @end smallexample
20614 The following built-in functions are available when @option{-mssse3} is used.
20615 All of them generate the machine instruction that is part of the name.
20617 @smallexample
20618 v2si __builtin_ia32_phaddd (v2si, v2si)
20619 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20620 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20621 v2si __builtin_ia32_phsubd (v2si, v2si)
20622 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20623 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20624 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20625 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20626 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20627 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20628 v2si __builtin_ia32_psignd (v2si, v2si)
20629 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20630 v1di __builtin_ia32_palignr (v1di, v1di, int)
20631 v8qi __builtin_ia32_pabsb (v8qi)
20632 v2si __builtin_ia32_pabsd (v2si)
20633 v4hi __builtin_ia32_pabsw (v4hi)
20634 @end smallexample
20636 The following built-in functions are available when @option{-mssse3} is used.
20637 All of them generate the machine instruction that is part of the name.
20639 @smallexample
20640 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20641 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20642 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20643 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20644 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20645 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20646 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20647 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20648 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20649 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20650 v4si __builtin_ia32_psignd128 (v4si, v4si)
20651 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20652 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20653 v16qi __builtin_ia32_pabsb128 (v16qi)
20654 v4si __builtin_ia32_pabsd128 (v4si)
20655 v8hi __builtin_ia32_pabsw128 (v8hi)
20656 @end smallexample
20658 The following built-in functions are available when @option{-msse4.1} is
20659 used.  All of them generate the machine instruction that is part of the
20660 name.
20662 @smallexample
20663 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20664 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20665 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20666 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20667 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20668 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20669 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20670 v2di __builtin_ia32_movntdqa (v2di *);
20671 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20672 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20673 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20674 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20675 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20676 v8hi __builtin_ia32_phminposuw128 (v8hi)
20677 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20678 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20679 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20680 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20681 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20682 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20683 v4si __builtin_ia32_pminud128 (v4si, v4si)
20684 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20685 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20686 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20687 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20688 v2di __builtin_ia32_pmovsxdq128 (v4si)
20689 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20690 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20691 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20692 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20693 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20694 v2di __builtin_ia32_pmovzxdq128 (v4si)
20695 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20696 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20697 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20698 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20699 int __builtin_ia32_ptestc128 (v2di, v2di)
20700 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20701 int __builtin_ia32_ptestz128 (v2di, v2di)
20702 v2df __builtin_ia32_roundpd (v2df, const int)
20703 v4sf __builtin_ia32_roundps (v4sf, const int)
20704 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20705 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20706 @end smallexample
20708 The following built-in functions are available when @option{-msse4.1} is
20709 used.
20711 @table @code
20712 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20713 Generates the @code{insertps} machine instruction.
20714 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20715 Generates the @code{pextrb} machine instruction.
20716 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20717 Generates the @code{pinsrb} machine instruction.
20718 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20719 Generates the @code{pinsrd} machine instruction.
20720 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20721 Generates the @code{pinsrq} machine instruction in 64bit mode.
20722 @end table
20724 The following built-in functions are changed to generate new SSE4.1
20725 instructions when @option{-msse4.1} is used.
20727 @table @code
20728 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20729 Generates the @code{extractps} machine instruction.
20730 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20731 Generates the @code{pextrd} machine instruction.
20732 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20733 Generates the @code{pextrq} machine instruction in 64bit mode.
20734 @end table
20736 The following built-in functions are available when @option{-msse4.2} is
20737 used.  All of them generate the machine instruction that is part of the
20738 name.
20740 @smallexample
20741 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20742 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20743 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20744 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20745 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20746 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20747 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20748 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20749 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20750 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20751 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20752 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20753 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20754 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20755 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20756 @end smallexample
20758 The following built-in functions are available when @option{-msse4.2} is
20759 used.
20761 @table @code
20762 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20763 Generates the @code{crc32b} machine instruction.
20764 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20765 Generates the @code{crc32w} machine instruction.
20766 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20767 Generates the @code{crc32l} machine instruction.
20768 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20769 Generates the @code{crc32q} machine instruction.
20770 @end table
20772 The following built-in functions are changed to generate new SSE4.2
20773 instructions when @option{-msse4.2} is used.
20775 @table @code
20776 @item int __builtin_popcount (unsigned int)
20777 Generates the @code{popcntl} machine instruction.
20778 @item int __builtin_popcountl (unsigned long)
20779 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20780 depending on the size of @code{unsigned long}.
20781 @item int __builtin_popcountll (unsigned long long)
20782 Generates the @code{popcntq} machine instruction.
20783 @end table
20785 The following built-in functions are available when @option{-mavx} is
20786 used. All of them generate the machine instruction that is part of the
20787 name.
20789 @smallexample
20790 v4df __builtin_ia32_addpd256 (v4df,v4df)
20791 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20792 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20793 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20794 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20795 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20796 v4df __builtin_ia32_andpd256 (v4df,v4df)
20797 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20798 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20799 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20800 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20801 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20802 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20803 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20804 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20805 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20806 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20807 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20808 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20809 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20810 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20811 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20812 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20813 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20814 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20815 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20816 v4df __builtin_ia32_divpd256 (v4df,v4df)
20817 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20818 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20819 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20820 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20821 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20822 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20823 v32qi __builtin_ia32_lddqu256 (pcchar)
20824 v32qi __builtin_ia32_loaddqu256 (pcchar)
20825 v4df __builtin_ia32_loadupd256 (pcdouble)
20826 v8sf __builtin_ia32_loadups256 (pcfloat)
20827 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20828 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20829 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20830 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20831 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20832 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20833 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20834 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20835 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20836 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20837 v4df __builtin_ia32_minpd256 (v4df,v4df)
20838 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20839 v4df __builtin_ia32_movddup256 (v4df)
20840 int __builtin_ia32_movmskpd256 (v4df)
20841 int __builtin_ia32_movmskps256 (v8sf)
20842 v8sf __builtin_ia32_movshdup256 (v8sf)
20843 v8sf __builtin_ia32_movsldup256 (v8sf)
20844 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20845 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20846 v4df __builtin_ia32_orpd256 (v4df,v4df)
20847 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20848 v2df __builtin_ia32_pd_pd256 (v4df)
20849 v4df __builtin_ia32_pd256_pd (v2df)
20850 v4sf __builtin_ia32_ps_ps256 (v8sf)
20851 v8sf __builtin_ia32_ps256_ps (v4sf)
20852 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20853 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20854 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20855 v8sf __builtin_ia32_rcpps256 (v8sf)
20856 v4df __builtin_ia32_roundpd256 (v4df,int)
20857 v8sf __builtin_ia32_roundps256 (v8sf,int)
20858 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20859 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20860 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20861 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20862 v4si __builtin_ia32_si_si256 (v8si)
20863 v8si __builtin_ia32_si256_si (v4si)
20864 v4df __builtin_ia32_sqrtpd256 (v4df)
20865 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20866 v8sf __builtin_ia32_sqrtps256 (v8sf)
20867 void __builtin_ia32_storedqu256 (pchar,v32qi)
20868 void __builtin_ia32_storeupd256 (pdouble,v4df)
20869 void __builtin_ia32_storeups256 (pfloat,v8sf)
20870 v4df __builtin_ia32_subpd256 (v4df,v4df)
20871 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20872 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20873 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20874 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20875 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20876 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20877 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20878 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20879 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20880 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20881 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20882 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20883 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20884 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20885 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20886 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20887 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20888 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20889 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20890 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20891 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20892 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20893 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20894 v2df __builtin_ia32_vpermilpd (v2df,int)
20895 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20896 v4sf __builtin_ia32_vpermilps (v4sf,int)
20897 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
20898 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
20899 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
20900 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
20901 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
20902 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
20903 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
20904 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
20905 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
20906 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
20907 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
20908 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
20909 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
20910 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
20911 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
20912 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
20913 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
20914 void __builtin_ia32_vzeroall (void)
20915 void __builtin_ia32_vzeroupper (void)
20916 v4df __builtin_ia32_xorpd256 (v4df,v4df)
20917 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
20918 @end smallexample
20920 The following built-in functions are available when @option{-mavx2} is
20921 used. All of them generate the machine instruction that is part of the
20922 name.
20924 @smallexample
20925 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
20926 v32qi __builtin_ia32_pabsb256 (v32qi)
20927 v16hi __builtin_ia32_pabsw256 (v16hi)
20928 v8si __builtin_ia32_pabsd256 (v8si)
20929 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
20930 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
20931 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
20932 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
20933 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
20934 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
20935 v8si __builtin_ia32_paddd256 (v8si,v8si)
20936 v4di __builtin_ia32_paddq256 (v4di,v4di)
20937 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
20938 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
20939 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20940 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20941 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20942 v4di __builtin_ia32_andsi256 (v4di,v4di)
20943 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20944 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20945 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20946 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20947 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20948 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20949 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20950 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20951 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20952 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20953 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20954 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20955 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20956 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20957 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20958 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20959 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20960 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20961 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20962 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20963 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20964 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20965 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20966 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20967 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20968 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20969 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20970 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20971 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20972 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20973 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20974 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20975 v8si __builtin_ia32_pminud256 (v8si,v8si)
20976 int __builtin_ia32_pmovmskb256 (v32qi)
20977 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20978 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20979 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20980 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20981 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20982 v4di __builtin_ia32_pmovsxdq256 (v4si)
20983 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20984 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20985 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20986 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20987 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20988 v4di __builtin_ia32_pmovzxdq256 (v4si)
20989 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20990 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20991 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20992 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20993 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20994 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20995 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20996 v4di __builtin_ia32_por256 (v4di,v4di)
20997 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20998 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20999 v8si __builtin_ia32_pshufd256 (v8si,int)
21000 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21001 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21002 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21003 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21004 v8si __builtin_ia32_psignd256 (v8si,v8si)
21005 v4di __builtin_ia32_pslldqi256 (v4di,int)
21006 v16hi __builtin_ia32_psllwi256 (16hi,int)
21007 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21008 v8si __builtin_ia32_pslldi256 (v8si,int)
21009 v8si __builtin_ia32_pslld256(v8si,v4si)
21010 v4di __builtin_ia32_psllqi256 (v4di,int)
21011 v4di __builtin_ia32_psllq256(v4di,v2di)
21012 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21013 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21014 v8si __builtin_ia32_psradi256 (v8si,int)
21015 v8si __builtin_ia32_psrad256 (v8si,v4si)
21016 v4di __builtin_ia32_psrldqi256 (v4di, int)
21017 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21018 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21019 v8si __builtin_ia32_psrldi256 (v8si,int)
21020 v8si __builtin_ia32_psrld256 (v8si,v4si)
21021 v4di __builtin_ia32_psrlqi256 (v4di,int)
21022 v4di __builtin_ia32_psrlq256(v4di,v2di)
21023 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21024 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21025 v8si __builtin_ia32_psubd256 (v8si,v8si)
21026 v4di __builtin_ia32_psubq256 (v4di,v4di)
21027 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21028 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21029 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21030 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21031 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21032 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21033 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21034 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21035 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21036 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21037 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21038 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21039 v4di __builtin_ia32_pxor256 (v4di,v4di)
21040 v4di __builtin_ia32_movntdqa256 (pv4di)
21041 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21042 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21043 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21044 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21045 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21046 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21047 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21048 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21049 v8si __builtin_ia32_pbroadcastd256 (v4si)
21050 v4di __builtin_ia32_pbroadcastq256 (v2di)
21051 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21052 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21053 v4si __builtin_ia32_pbroadcastd128 (v4si)
21054 v2di __builtin_ia32_pbroadcastq128 (v2di)
21055 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21056 v4df __builtin_ia32_permdf256 (v4df,int)
21057 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21058 v4di __builtin_ia32_permdi256 (v4di,int)
21059 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21060 v4di __builtin_ia32_extract128i256 (v4di,int)
21061 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21062 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21063 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21064 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21065 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21066 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21067 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21068 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21069 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21070 v8si __builtin_ia32_psllv8si (v8si,v8si)
21071 v4si __builtin_ia32_psllv4si (v4si,v4si)
21072 v4di __builtin_ia32_psllv4di (v4di,v4di)
21073 v2di __builtin_ia32_psllv2di (v2di,v2di)
21074 v8si __builtin_ia32_psrav8si (v8si,v8si)
21075 v4si __builtin_ia32_psrav4si (v4si,v4si)
21076 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21077 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21078 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21079 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21080 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21081 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21082 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21083 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21084 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21085 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21086 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21087 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21088 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21089 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21090 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21091 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21092 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21093 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21094 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21095 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21096 @end smallexample
21098 The following built-in functions are available when @option{-maes} is
21099 used.  All of them generate the machine instruction that is part of the
21100 name.
21102 @smallexample
21103 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21104 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21105 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21106 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21107 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21108 v2di __builtin_ia32_aesimc128 (v2di)
21109 @end smallexample
21111 The following built-in function is available when @option{-mpclmul} is
21112 used.
21114 @table @code
21115 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21116 Generates the @code{pclmulqdq} machine instruction.
21117 @end table
21119 The following built-in function is available when @option{-mfsgsbase} is
21120 used.  All of them generate the machine instruction that is part of the
21121 name.
21123 @smallexample
21124 unsigned int __builtin_ia32_rdfsbase32 (void)
21125 unsigned long long __builtin_ia32_rdfsbase64 (void)
21126 unsigned int __builtin_ia32_rdgsbase32 (void)
21127 unsigned long long __builtin_ia32_rdgsbase64 (void)
21128 void _writefsbase_u32 (unsigned int)
21129 void _writefsbase_u64 (unsigned long long)
21130 void _writegsbase_u32 (unsigned int)
21131 void _writegsbase_u64 (unsigned long long)
21132 @end smallexample
21134 The following built-in function is available when @option{-mrdrnd} is
21135 used.  All of them generate the machine instruction that is part of the
21136 name.
21138 @smallexample
21139 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21140 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21141 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21142 @end smallexample
21144 The following built-in functions are available when @option{-msse4a} is used.
21145 All of them generate the machine instruction that is part of the name.
21147 @smallexample
21148 void __builtin_ia32_movntsd (double *, v2df)
21149 void __builtin_ia32_movntss (float *, v4sf)
21150 v2di __builtin_ia32_extrq  (v2di, v16qi)
21151 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21152 v2di __builtin_ia32_insertq (v2di, v2di)
21153 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21154 @end smallexample
21156 The following built-in functions are available when @option{-mxop} is used.
21157 @smallexample
21158 v2df __builtin_ia32_vfrczpd (v2df)
21159 v4sf __builtin_ia32_vfrczps (v4sf)
21160 v2df __builtin_ia32_vfrczsd (v2df)
21161 v4sf __builtin_ia32_vfrczss (v4sf)
21162 v4df __builtin_ia32_vfrczpd256 (v4df)
21163 v8sf __builtin_ia32_vfrczps256 (v8sf)
21164 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21165 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21166 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21167 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21168 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21169 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21170 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21171 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21172 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21173 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21174 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21175 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21176 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21177 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21178 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21179 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21180 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21181 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21182 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21183 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21184 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21185 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21186 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21187 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21188 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21189 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21190 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21191 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21192 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21193 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21194 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21195 v4si __builtin_ia32_vpcomged (v4si, v4si)
21196 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21197 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21198 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21199 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21200 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21201 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21202 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21203 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21204 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21205 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21206 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21207 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21208 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21209 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21210 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21211 v4si __builtin_ia32_vpcomled (v4si, v4si)
21212 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21213 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21214 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21215 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21216 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21217 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21218 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21219 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21220 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21221 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21222 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21223 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21224 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21225 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21226 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21227 v4si __builtin_ia32_vpcomned (v4si, v4si)
21228 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21229 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21230 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21231 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21232 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21233 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21234 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21235 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21236 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21237 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21238 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21239 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21240 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21241 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21242 v4si __builtin_ia32_vphaddbd (v16qi)
21243 v2di __builtin_ia32_vphaddbq (v16qi)
21244 v8hi __builtin_ia32_vphaddbw (v16qi)
21245 v2di __builtin_ia32_vphadddq (v4si)
21246 v4si __builtin_ia32_vphaddubd (v16qi)
21247 v2di __builtin_ia32_vphaddubq (v16qi)
21248 v8hi __builtin_ia32_vphaddubw (v16qi)
21249 v2di __builtin_ia32_vphaddudq (v4si)
21250 v4si __builtin_ia32_vphadduwd (v8hi)
21251 v2di __builtin_ia32_vphadduwq (v8hi)
21252 v4si __builtin_ia32_vphaddwd (v8hi)
21253 v2di __builtin_ia32_vphaddwq (v8hi)
21254 v8hi __builtin_ia32_vphsubbw (v16qi)
21255 v2di __builtin_ia32_vphsubdq (v4si)
21256 v4si __builtin_ia32_vphsubwd (v8hi)
21257 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21258 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21259 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21260 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21261 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21262 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21263 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21264 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21265 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21266 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21267 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21268 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21269 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21270 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21271 v4si __builtin_ia32_vprotd (v4si, v4si)
21272 v2di __builtin_ia32_vprotq (v2di, v2di)
21273 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21274 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21275 v4si __builtin_ia32_vpshad (v4si, v4si)
21276 v2di __builtin_ia32_vpshaq (v2di, v2di)
21277 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21278 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21279 v4si __builtin_ia32_vpshld (v4si, v4si)
21280 v2di __builtin_ia32_vpshlq (v2di, v2di)
21281 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21282 @end smallexample
21284 The following built-in functions are available when @option{-mfma4} is used.
21285 All of them generate the machine instruction that is part of the name.
21287 @smallexample
21288 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21289 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21290 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21291 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21292 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21293 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21294 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21295 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21296 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21297 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21298 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21299 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21300 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21301 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21302 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21303 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21304 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21305 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21306 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21307 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21308 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21309 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21310 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21311 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21312 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21313 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21314 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21315 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21316 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21317 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21318 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21319 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21321 @end smallexample
21323 The following built-in functions are available when @option{-mlwp} is used.
21325 @smallexample
21326 void __builtin_ia32_llwpcb16 (void *);
21327 void __builtin_ia32_llwpcb32 (void *);
21328 void __builtin_ia32_llwpcb64 (void *);
21329 void * __builtin_ia32_llwpcb16 (void);
21330 void * __builtin_ia32_llwpcb32 (void);
21331 void * __builtin_ia32_llwpcb64 (void);
21332 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21333 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21334 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21335 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21336 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21337 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21338 @end smallexample
21340 The following built-in functions are available when @option{-mbmi} is used.
21341 All of them generate the machine instruction that is part of the name.
21342 @smallexample
21343 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21344 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21345 @end smallexample
21347 The following built-in functions are available when @option{-mbmi2} is used.
21348 All of them generate the machine instruction that is part of the name.
21349 @smallexample
21350 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21351 unsigned int _pdep_u32 (unsigned int, unsigned int)
21352 unsigned int _pext_u32 (unsigned int, unsigned int)
21353 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21354 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21355 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21356 @end smallexample
21358 The following built-in functions are available when @option{-mlzcnt} is used.
21359 All of them generate the machine instruction that is part of the name.
21360 @smallexample
21361 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21362 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21363 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21364 @end smallexample
21366 The following built-in functions are available when @option{-mfxsr} is used.
21367 All of them generate the machine instruction that is part of the name.
21368 @smallexample
21369 void __builtin_ia32_fxsave (void *)
21370 void __builtin_ia32_fxrstor (void *)
21371 void __builtin_ia32_fxsave64 (void *)
21372 void __builtin_ia32_fxrstor64 (void *)
21373 @end smallexample
21375 The following built-in functions are available when @option{-mxsave} is used.
21376 All of them generate the machine instruction that is part of the name.
21377 @smallexample
21378 void __builtin_ia32_xsave (void *, long long)
21379 void __builtin_ia32_xrstor (void *, long long)
21380 void __builtin_ia32_xsave64 (void *, long long)
21381 void __builtin_ia32_xrstor64 (void *, long long)
21382 @end smallexample
21384 The following built-in functions are available when @option{-mxsaveopt} is used.
21385 All of them generate the machine instruction that is part of the name.
21386 @smallexample
21387 void __builtin_ia32_xsaveopt (void *, long long)
21388 void __builtin_ia32_xsaveopt64 (void *, long long)
21389 @end smallexample
21391 The following built-in functions are available when @option{-mtbm} is used.
21392 Both of them generate the immediate form of the bextr machine instruction.
21393 @smallexample
21394 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21395                                         const unsigned int);
21396 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21397                                               const unsigned long long);
21398 @end smallexample
21401 The following built-in functions are available when @option{-m3dnow} is used.
21402 All of them generate the machine instruction that is part of the name.
21404 @smallexample
21405 void __builtin_ia32_femms (void)
21406 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21407 v2si __builtin_ia32_pf2id (v2sf)
21408 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21409 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21410 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21411 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21412 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21413 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21414 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21415 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21416 v2sf __builtin_ia32_pfrcp (v2sf)
21417 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21418 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21419 v2sf __builtin_ia32_pfrsqrt (v2sf)
21420 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21421 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21422 v2sf __builtin_ia32_pi2fd (v2si)
21423 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21424 @end smallexample
21426 The following built-in functions are available when @option{-m3dnowa} is used.
21427 All of them generate the machine instruction that is part of the name.
21429 @smallexample
21430 v2si __builtin_ia32_pf2iw (v2sf)
21431 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21432 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21433 v2sf __builtin_ia32_pi2fw (v2si)
21434 v2sf __builtin_ia32_pswapdsf (v2sf)
21435 v2si __builtin_ia32_pswapdsi (v2si)
21436 @end smallexample
21438 The following built-in functions are available when @option{-mrtm} is used
21439 They are used for restricted transactional memory. These are the internal
21440 low level functions. Normally the functions in 
21441 @ref{x86 transactional memory intrinsics} should be used instead.
21443 @smallexample
21444 int __builtin_ia32_xbegin ()
21445 void __builtin_ia32_xend ()
21446 void __builtin_ia32_xabort (status)
21447 int __builtin_ia32_xtest ()
21448 @end smallexample
21450 The following built-in functions are available when @option{-mmwaitx} is used.
21451 All of them generate the machine instruction that is part of the name.
21452 @smallexample
21453 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21454 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21455 @end smallexample
21457 The following built-in functions are available when @option{-mclzero} is used.
21458 All of them generate the machine instruction that is part of the name.
21459 @smallexample
21460 void __builtin_i32_clzero (void *)
21461 @end smallexample
21463 The following built-in functions are available when @option{-mpku} is used.
21464 They generate reads and writes to PKRU.
21465 @smallexample
21466 void __builtin_ia32_wrpkru (unsigned int)
21467 unsigned int __builtin_ia32_rdpkru ()
21468 @end smallexample
21470 @node x86 transactional memory intrinsics
21471 @subsection x86 Transactional Memory Intrinsics
21473 These hardware transactional memory intrinsics for x86 allow you to use
21474 memory transactions with RTM (Restricted Transactional Memory).
21475 This support is enabled with the @option{-mrtm} option.
21476 For using HLE (Hardware Lock Elision) see 
21477 @ref{x86 specific memory model extensions for transactional memory} instead.
21479 A memory transaction commits all changes to memory in an atomic way,
21480 as visible to other threads. If the transaction fails it is rolled back
21481 and all side effects discarded.
21483 Generally there is no guarantee that a memory transaction ever succeeds
21484 and suitable fallback code always needs to be supplied.
21486 @deftypefn {RTM Function} {unsigned} _xbegin ()
21487 Start a RTM (Restricted Transactional Memory) transaction. 
21488 Returns @code{_XBEGIN_STARTED} when the transaction
21489 started successfully (note this is not 0, so the constant has to be 
21490 explicitly tested).  
21492 If the transaction aborts, all side-effects 
21493 are undone and an abort code encoded as a bit mask is returned.
21494 The following macros are defined:
21496 @table @code
21497 @item _XABORT_EXPLICIT
21498 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
21499 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21500 @item _XABORT_RETRY
21501 Transaction retry is possible.
21502 @item _XABORT_CONFLICT
21503 Transaction abort due to a memory conflict with another thread.
21504 @item _XABORT_CAPACITY
21505 Transaction abort due to the transaction using too much memory.
21506 @item _XABORT_DEBUG
21507 Transaction abort due to a debug trap.
21508 @item _XABORT_NESTED
21509 Transaction abort in an inner nested transaction.
21510 @end table
21512 There is no guarantee
21513 any transaction ever succeeds, so there always needs to be a valid
21514 fallback path.
21515 @end deftypefn
21517 @deftypefn {RTM Function} {void} _xend ()
21518 Commit the current transaction. When no transaction is active this faults.
21519 All memory side-effects of the transaction become visible
21520 to other threads in an atomic manner.
21521 @end deftypefn
21523 @deftypefn {RTM Function} {int} _xtest ()
21524 Return a nonzero value if a transaction is currently active, otherwise 0.
21525 @end deftypefn
21527 @deftypefn {RTM Function} {void} _xabort (status)
21528 Abort the current transaction. When no transaction is active this is a no-op.
21529 The @var{status} is an 8-bit constant; its value is encoded in the return 
21530 value from @code{_xbegin}.
21531 @end deftypefn
21533 Here is an example showing handling for @code{_XABORT_RETRY}
21534 and a fallback path for other failures:
21536 @smallexample
21537 #include <immintrin.h>
21539 int n_tries, max_tries;
21540 unsigned status = _XABORT_EXPLICIT;
21543 for (n_tries = 0; n_tries < max_tries; n_tries++) 
21544   @{
21545     status = _xbegin ();
21546     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21547       break;
21548   @}
21549 if (status == _XBEGIN_STARTED) 
21550   @{
21551     ... transaction code...
21552     _xend ();
21553   @} 
21554 else 
21555   @{
21556     ... non-transactional fallback path...
21557   @}
21558 @end smallexample
21560 @noindent
21561 Note that, in most cases, the transactional and non-transactional code
21562 must synchronize together to ensure consistency.
21564 @node Target Format Checks
21565 @section Format Checks Specific to Particular Target Machines
21567 For some target machines, GCC supports additional options to the
21568 format attribute
21569 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
21571 @menu
21572 * Solaris Format Checks::
21573 * Darwin Format Checks::
21574 @end menu
21576 @node Solaris Format Checks
21577 @subsection Solaris Format Checks
21579 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
21580 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
21581 conversions, and the two-argument @code{%b} conversion for displaying
21582 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
21584 @node Darwin Format Checks
21585 @subsection Darwin Format Checks
21587 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
21588 attribute context.  Declarations made with such attribution are parsed for correct syntax
21589 and format argument types.  However, parsing of the format string itself is currently undefined
21590 and is not carried out by this version of the compiler.
21592 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
21593 also be used as format arguments.  Note that the relevant headers are only likely to be
21594 available on Darwin (OSX) installations.  On such installations, the XCode and system
21595 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
21596 associated functions.
21598 @node Pragmas
21599 @section Pragmas Accepted by GCC
21600 @cindex pragmas
21601 @cindex @code{#pragma}
21603 GCC supports several types of pragmas, primarily in order to compile
21604 code originally written for other compilers.  Note that in general
21605 we do not recommend the use of pragmas; @xref{Function Attributes},
21606 for further explanation.
21608 @menu
21609 * AArch64 Pragmas::
21610 * ARM Pragmas::
21611 * M32C Pragmas::
21612 * MeP Pragmas::
21613 * RS/6000 and PowerPC Pragmas::
21614 * S/390 Pragmas::
21615 * Darwin Pragmas::
21616 * Solaris Pragmas::
21617 * Symbol-Renaming Pragmas::
21618 * Structure-Layout Pragmas::
21619 * Weak Pragmas::
21620 * Diagnostic Pragmas::
21621 * Visibility Pragmas::
21622 * Push/Pop Macro Pragmas::
21623 * Function Specific Option Pragmas::
21624 * Loop-Specific Pragmas::
21625 @end menu
21627 @node AArch64 Pragmas
21628 @subsection AArch64 Pragmas
21630 The pragmas defined by the AArch64 target correspond to the AArch64
21631 target function attributes.  They can be specified as below:
21632 @smallexample
21633 #pragma GCC target("string")
21634 @end smallexample
21636 where @code{@var{string}} can be any string accepted as an AArch64 target
21637 attribute.  @xref{AArch64 Function Attributes}, for more details
21638 on the permissible values of @code{string}.
21640 @node ARM Pragmas
21641 @subsection ARM Pragmas
21643 The ARM target defines pragmas for controlling the default addition of
21644 @code{long_call} and @code{short_call} attributes to functions.
21645 @xref{Function Attributes}, for information about the effects of these
21646 attributes.
21648 @table @code
21649 @item long_calls
21650 @cindex pragma, long_calls
21651 Set all subsequent functions to have the @code{long_call} attribute.
21653 @item no_long_calls
21654 @cindex pragma, no_long_calls
21655 Set all subsequent functions to have the @code{short_call} attribute.
21657 @item long_calls_off
21658 @cindex pragma, long_calls_off
21659 Do not affect the @code{long_call} or @code{short_call} attributes of
21660 subsequent functions.
21661 @end table
21663 @node M32C Pragmas
21664 @subsection M32C Pragmas
21666 @table @code
21667 @item GCC memregs @var{number}
21668 @cindex pragma, memregs
21669 Overrides the command-line option @code{-memregs=} for the current
21670 file.  Use with care!  This pragma must be before any function in the
21671 file, and mixing different memregs values in different objects may
21672 make them incompatible.  This pragma is useful when a
21673 performance-critical function uses a memreg for temporary values,
21674 as it may allow you to reduce the number of memregs used.
21676 @item ADDRESS @var{name} @var{address}
21677 @cindex pragma, address
21678 For any declared symbols matching @var{name}, this does three things
21679 to that symbol: it forces the symbol to be located at the given
21680 address (a number), it forces the symbol to be volatile, and it
21681 changes the symbol's scope to be static.  This pragma exists for
21682 compatibility with other compilers, but note that the common
21683 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21684 instead).  Example:
21686 @smallexample
21687 #pragma ADDRESS port3 0x103
21688 char port3;
21689 @end smallexample
21691 @end table
21693 @node MeP Pragmas
21694 @subsection MeP Pragmas
21696 @table @code
21698 @item custom io_volatile (on|off)
21699 @cindex pragma, custom io_volatile
21700 Overrides the command-line option @code{-mio-volatile} for the current
21701 file.  Note that for compatibility with future GCC releases, this
21702 option should only be used once before any @code{io} variables in each
21703 file.
21705 @item GCC coprocessor available @var{registers}
21706 @cindex pragma, coprocessor available
21707 Specifies which coprocessor registers are available to the register
21708 allocator.  @var{registers} may be a single register, register range
21709 separated by ellipses, or comma-separated list of those.  Example:
21711 @smallexample
21712 #pragma GCC coprocessor available $c0...$c10, $c28
21713 @end smallexample
21715 @item GCC coprocessor call_saved @var{registers}
21716 @cindex pragma, coprocessor call_saved
21717 Specifies which coprocessor registers are to be saved and restored by
21718 any function using them.  @var{registers} may be a single register,
21719 register range separated by ellipses, or comma-separated list of
21720 those.  Example:
21722 @smallexample
21723 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21724 @end smallexample
21726 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21727 @cindex pragma, coprocessor subclass
21728 Creates and defines a register class.  These register classes can be
21729 used by inline @code{asm} constructs.  @var{registers} may be a single
21730 register, register range separated by ellipses, or comma-separated
21731 list of those.  Example:
21733 @smallexample
21734 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21736 asm ("cpfoo %0" : "=B" (x));
21737 @end smallexample
21739 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21740 @cindex pragma, disinterrupt
21741 For the named functions, the compiler adds code to disable interrupts
21742 for the duration of those functions.  If any functions so named 
21743 are not encountered in the source, a warning is emitted that the pragma is
21744 not used.  Examples:
21746 @smallexample
21747 #pragma disinterrupt foo
21748 #pragma disinterrupt bar, grill
21749 int foo () @{ @dots{} @}
21750 @end smallexample
21752 @item GCC call @var{name} , @var{name} @dots{}
21753 @cindex pragma, call
21754 For the named functions, the compiler always uses a register-indirect
21755 call model when calling the named functions.  Examples:
21757 @smallexample
21758 extern int foo ();
21759 #pragma call foo
21760 @end smallexample
21762 @end table
21764 @node RS/6000 and PowerPC Pragmas
21765 @subsection RS/6000 and PowerPC Pragmas
21767 The RS/6000 and PowerPC targets define one pragma for controlling
21768 whether or not the @code{longcall} attribute is added to function
21769 declarations by default.  This pragma overrides the @option{-mlongcall}
21770 option, but not the @code{longcall} and @code{shortcall} attributes.
21771 @xref{RS/6000 and PowerPC Options}, for more information about when long
21772 calls are and are not necessary.
21774 @table @code
21775 @item longcall (1)
21776 @cindex pragma, longcall
21777 Apply the @code{longcall} attribute to all subsequent function
21778 declarations.
21780 @item longcall (0)
21781 Do not apply the @code{longcall} attribute to subsequent function
21782 declarations.
21783 @end table
21785 @c Describe h8300 pragmas here.
21786 @c Describe sh pragmas here.
21787 @c Describe v850 pragmas here.
21789 @node S/390 Pragmas
21790 @subsection S/390 Pragmas
21792 The pragmas defined by the S/390 target correspond to the S/390
21793 target function attributes and some the additional options:
21795 @table @samp
21796 @item zvector
21797 @itemx no-zvector
21798 @end table
21800 Note that options of the pragma, unlike options of the target
21801 attribute, do change the value of preprocessor macros like
21802 @code{__VEC__}.  They can be specified as below:
21804 @smallexample
21805 #pragma GCC target("string[,string]...")
21806 #pragma GCC target("string"[,"string"]...)
21807 @end smallexample
21809 @node Darwin Pragmas
21810 @subsection Darwin Pragmas
21812 The following pragmas are available for all architectures running the
21813 Darwin operating system.  These are useful for compatibility with other
21814 Mac OS compilers.
21816 @table @code
21817 @item mark @var{tokens}@dots{}
21818 @cindex pragma, mark
21819 This pragma is accepted, but has no effect.
21821 @item options align=@var{alignment}
21822 @cindex pragma, options align
21823 This pragma sets the alignment of fields in structures.  The values of
21824 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21825 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
21826 properly; to restore the previous setting, use @code{reset} for the
21827 @var{alignment}.
21829 @item segment @var{tokens}@dots{}
21830 @cindex pragma, segment
21831 This pragma is accepted, but has no effect.
21833 @item unused (@var{var} [, @var{var}]@dots{})
21834 @cindex pragma, unused
21835 This pragma declares variables to be possibly unused.  GCC does not
21836 produce warnings for the listed variables.  The effect is similar to
21837 that of the @code{unused} attribute, except that this pragma may appear
21838 anywhere within the variables' scopes.
21839 @end table
21841 @node Solaris Pragmas
21842 @subsection Solaris Pragmas
21844 The Solaris target supports @code{#pragma redefine_extname}
21845 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
21846 @code{#pragma} directives for compatibility with the system compiler.
21848 @table @code
21849 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
21850 @cindex pragma, align
21852 Increase the minimum alignment of each @var{variable} to @var{alignment}.
21853 This is the same as GCC's @code{aligned} attribute @pxref{Variable
21854 Attributes}).  Macro expansion occurs on the arguments to this pragma
21855 when compiling C and Objective-C@.  It does not currently occur when
21856 compiling C++, but this is a bug which may be fixed in a future
21857 release.
21859 @item fini (@var{function} [, @var{function}]...)
21860 @cindex pragma, fini
21862 This pragma causes each listed @var{function} to be called after
21863 main, or during shared module unloading, by adding a call to the
21864 @code{.fini} section.
21866 @item init (@var{function} [, @var{function}]...)
21867 @cindex pragma, init
21869 This pragma causes each listed @var{function} to be called during
21870 initialization (before @code{main}) or during shared module loading, by
21871 adding a call to the @code{.init} section.
21873 @end table
21875 @node Symbol-Renaming Pragmas
21876 @subsection Symbol-Renaming Pragmas
21878 GCC supports a @code{#pragma} directive that changes the name used in
21879 assembly for a given declaration. While this pragma is supported on all
21880 platforms, it is intended primarily to provide compatibility with the
21881 Solaris system headers. This effect can also be achieved using the asm
21882 labels extension (@pxref{Asm Labels}).
21884 @table @code
21885 @item redefine_extname @var{oldname} @var{newname}
21886 @cindex pragma, redefine_extname
21888 This pragma gives the C function @var{oldname} the assembly symbol
21889 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
21890 is defined if this pragma is available (currently on all platforms).
21891 @end table
21893 This pragma and the asm labels extension interact in a complicated
21894 manner.  Here are some corner cases you may want to be aware of:
21896 @enumerate
21897 @item This pragma silently applies only to declarations with external
21898 linkage.  Asm labels do not have this restriction.
21900 @item In C++, this pragma silently applies only to declarations with
21901 ``C'' linkage.  Again, asm labels do not have this restriction.
21903 @item If either of the ways of changing the assembly name of a
21904 declaration are applied to a declaration whose assembly name has
21905 already been determined (either by a previous use of one of these
21906 features, or because the compiler needed the assembly name in order to
21907 generate code), and the new name is different, a warning issues and
21908 the name does not change.
21910 @item The @var{oldname} used by @code{#pragma redefine_extname} is
21911 always the C-language name.
21912 @end enumerate
21914 @node Structure-Layout Pragmas
21915 @subsection Structure-Layout Pragmas
21917 For compatibility with Microsoft Windows compilers, GCC supports a
21918 set of @code{#pragma} directives that change the maximum alignment of
21919 members of structures (other than zero-width bit-fields), unions, and
21920 classes subsequently defined. The @var{n} value below always is required
21921 to be a small power of two and specifies the new alignment in bytes.
21923 @enumerate
21924 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
21925 @item @code{#pragma pack()} sets the alignment to the one that was in
21926 effect when compilation started (see also command-line option
21927 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
21928 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
21929 setting on an internal stack and then optionally sets the new alignment.
21930 @item @code{#pragma pack(pop)} restores the alignment setting to the one
21931 saved at the top of the internal stack (and removes that stack entry).
21932 Note that @code{#pragma pack([@var{n}])} does not influence this internal
21933 stack; thus it is possible to have @code{#pragma pack(push)} followed by
21934 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
21935 @code{#pragma pack(pop)}.
21936 @end enumerate
21938 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
21939 directive which lays out structures and unions subsequently defined as the
21940 documented @code{__attribute__ ((ms_struct))}.
21942 @enumerate
21943 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21944 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21945 @item @code{#pragma ms_struct reset} goes back to the default layout.
21946 @end enumerate
21948 Most targets also support the @code{#pragma scalar_storage_order} directive
21949 which lays out structures and unions subsequently defined as the documented
21950 @code{__attribute__ ((scalar_storage_order))}.
21952 @enumerate
21953 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21954 of the scalar fields to big-endian.
21955 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21956 of the scalar fields to little-endian.
21957 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21958 that was in effect when compilation started (see also command-line option
21959 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21960 @end enumerate
21962 @node Weak Pragmas
21963 @subsection Weak Pragmas
21965 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21966 directives for declaring symbols to be weak, and defining weak
21967 aliases.
21969 @table @code
21970 @item #pragma weak @var{symbol}
21971 @cindex pragma, weak
21972 This pragma declares @var{symbol} to be weak, as if the declaration
21973 had the attribute of the same name.  The pragma may appear before
21974 or after the declaration of @var{symbol}.  It is not an error for
21975 @var{symbol} to never be defined at all.
21977 @item #pragma weak @var{symbol1} = @var{symbol2}
21978 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21979 It is an error if @var{symbol2} is not defined in the current
21980 translation unit.
21981 @end table
21983 @node Diagnostic Pragmas
21984 @subsection Diagnostic Pragmas
21986 GCC allows the user to selectively enable or disable certain types of
21987 diagnostics, and change the kind of the diagnostic.  For example, a
21988 project's policy might require that all sources compile with
21989 @option{-Werror} but certain files might have exceptions allowing
21990 specific types of warnings.  Or, a project might selectively enable
21991 diagnostics and treat them as errors depending on which preprocessor
21992 macros are defined.
21994 @table @code
21995 @item #pragma GCC diagnostic @var{kind} @var{option}
21996 @cindex pragma, diagnostic
21998 Modifies the disposition of a diagnostic.  Note that not all
21999 diagnostics are modifiable; at the moment only warnings (normally
22000 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22001 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22002 are controllable and which option controls them.
22004 @var{kind} is @samp{error} to treat this diagnostic as an error,
22005 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22006 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22007 @var{option} is a double quoted string that matches the command-line
22008 option.
22010 @smallexample
22011 #pragma GCC diagnostic warning "-Wformat"
22012 #pragma GCC diagnostic error "-Wformat"
22013 #pragma GCC diagnostic ignored "-Wformat"
22014 @end smallexample
22016 Note that these pragmas override any command-line options.  GCC keeps
22017 track of the location of each pragma, and issues diagnostics according
22018 to the state as of that point in the source file.  Thus, pragmas occurring
22019 after a line do not affect diagnostics caused by that line.
22021 @item #pragma GCC diagnostic push
22022 @itemx #pragma GCC diagnostic pop
22024 Causes GCC to remember the state of the diagnostics as of each
22025 @code{push}, and restore to that point at each @code{pop}.  If a
22026 @code{pop} has no matching @code{push}, the command-line options are
22027 restored.
22029 @smallexample
22030 #pragma GCC diagnostic error "-Wuninitialized"
22031   foo(a);                       /* error is given for this one */
22032 #pragma GCC diagnostic push
22033 #pragma GCC diagnostic ignored "-Wuninitialized"
22034   foo(b);                       /* no diagnostic for this one */
22035 #pragma GCC diagnostic pop
22036   foo(c);                       /* error is given for this one */
22037 #pragma GCC diagnostic pop
22038   foo(d);                       /* depends on command-line options */
22039 @end smallexample
22041 @end table
22043 GCC also offers a simple mechanism for printing messages during
22044 compilation.
22046 @table @code
22047 @item #pragma message @var{string}
22048 @cindex pragma, diagnostic
22050 Prints @var{string} as a compiler message on compilation.  The message
22051 is informational only, and is neither a compilation warning nor an error.
22053 @smallexample
22054 #pragma message "Compiling " __FILE__ "..."
22055 @end smallexample
22057 @var{string} may be parenthesized, and is printed with location
22058 information.  For example,
22060 @smallexample
22061 #define DO_PRAGMA(x) _Pragma (#x)
22062 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22064 TODO(Remember to fix this)
22065 @end smallexample
22067 @noindent
22068 prints @samp{/tmp/file.c:4: note: #pragma message:
22069 TODO - Remember to fix this}.
22071 @end table
22073 @node Visibility Pragmas
22074 @subsection Visibility Pragmas
22076 @table @code
22077 @item #pragma GCC visibility push(@var{visibility})
22078 @itemx #pragma GCC visibility pop
22079 @cindex pragma, visibility
22081 This pragma allows the user to set the visibility for multiple
22082 declarations without having to give each a visibility attribute
22083 (@pxref{Function Attributes}).
22085 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22086 declarations.  Class members and template specializations are not
22087 affected; if you want to override the visibility for a particular
22088 member or instantiation, you must use an attribute.
22090 @end table
22093 @node Push/Pop Macro Pragmas
22094 @subsection Push/Pop Macro Pragmas
22096 For compatibility with Microsoft Windows compilers, GCC supports
22097 @samp{#pragma push_macro(@var{"macro_name"})}
22098 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22100 @table @code
22101 @item #pragma push_macro(@var{"macro_name"})
22102 @cindex pragma, push_macro
22103 This pragma saves the value of the macro named as @var{macro_name} to
22104 the top of the stack for this macro.
22106 @item #pragma pop_macro(@var{"macro_name"})
22107 @cindex pragma, pop_macro
22108 This pragma sets the value of the macro named as @var{macro_name} to
22109 the value on top of the stack for this macro. If the stack for
22110 @var{macro_name} is empty, the value of the macro remains unchanged.
22111 @end table
22113 For example:
22115 @smallexample
22116 #define X  1
22117 #pragma push_macro("X")
22118 #undef X
22119 #define X -1
22120 #pragma pop_macro("X")
22121 int x [X];
22122 @end smallexample
22124 @noindent
22125 In this example, the definition of X as 1 is saved by @code{#pragma
22126 push_macro} and restored by @code{#pragma pop_macro}.
22128 @node Function Specific Option Pragmas
22129 @subsection Function Specific Option Pragmas
22131 @table @code
22132 @item #pragma GCC target (@var{"string"}...)
22133 @cindex pragma GCC target
22135 This pragma allows you to set target specific options for functions
22136 defined later in the source file.  One or more strings can be
22137 specified.  Each function that is defined after this point is as
22138 if @code{attribute((target("STRING")))} was specified for that
22139 function.  The parenthesis around the options is optional.
22140 @xref{Function Attributes}, for more information about the
22141 @code{target} attribute and the attribute syntax.
22143 The @code{#pragma GCC target} pragma is presently implemented for
22144 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22145 @end table
22147 @table @code
22148 @item #pragma GCC optimize (@var{"string"}...)
22149 @cindex pragma GCC optimize
22151 This pragma allows you to set global optimization options for functions
22152 defined later in the source file.  One or more strings can be
22153 specified.  Each function that is defined after this point is as
22154 if @code{attribute((optimize("STRING")))} was specified for that
22155 function.  The parenthesis around the options is optional.
22156 @xref{Function Attributes}, for more information about the
22157 @code{optimize} attribute and the attribute syntax.
22158 @end table
22160 @table @code
22161 @item #pragma GCC push_options
22162 @itemx #pragma GCC pop_options
22163 @cindex pragma GCC push_options
22164 @cindex pragma GCC pop_options
22166 These pragmas maintain a stack of the current target and optimization
22167 options.  It is intended for include files where you temporarily want
22168 to switch to using a different @samp{#pragma GCC target} or
22169 @samp{#pragma GCC optimize} and then to pop back to the previous
22170 options.
22171 @end table
22173 @table @code
22174 @item #pragma GCC reset_options
22175 @cindex pragma GCC reset_options
22177 This pragma clears the current @code{#pragma GCC target} and
22178 @code{#pragma GCC optimize} to use the default switches as specified
22179 on the command line.
22180 @end table
22182 @node Loop-Specific Pragmas
22183 @subsection Loop-Specific Pragmas
22185 @table @code
22186 @item #pragma GCC ivdep
22187 @cindex pragma GCC ivdep
22188 @end table
22190 With this pragma, the programmer asserts that there are no loop-carried
22191 dependencies which would prevent consecutive iterations of
22192 the following loop from executing concurrently with SIMD
22193 (single instruction multiple data) instructions.
22195 For example, the compiler can only unconditionally vectorize the following
22196 loop with the pragma:
22198 @smallexample
22199 void foo (int n, int *a, int *b, int *c)
22201   int i, j;
22202 #pragma GCC ivdep
22203   for (i = 0; i < n; ++i)
22204     a[i] = b[i] + c[i];
22206 @end smallexample
22208 @noindent
22209 In this example, using the @code{restrict} qualifier had the same
22210 effect. In the following example, that would not be possible. Assume
22211 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22212 that it can unconditionally vectorize the following loop:
22214 @smallexample
22215 void ignore_vec_dep (int *a, int k, int c, int m)
22217 #pragma GCC ivdep
22218   for (int i = 0; i < m; i++)
22219     a[i] = a[i + k] * c;
22221 @end smallexample
22224 @node Unnamed Fields
22225 @section Unnamed Structure and Union Fields
22226 @cindex @code{struct}
22227 @cindex @code{union}
22229 As permitted by ISO C11 and for compatibility with other compilers,
22230 GCC allows you to define
22231 a structure or union that contains, as fields, structures and unions
22232 without names.  For example:
22234 @smallexample
22235 struct @{
22236   int a;
22237   union @{
22238     int b;
22239     float c;
22240   @};
22241   int d;
22242 @} foo;
22243 @end smallexample
22245 @noindent
22246 In this example, you are able to access members of the unnamed
22247 union with code like @samp{foo.b}.  Note that only unnamed structs and
22248 unions are allowed, you may not have, for example, an unnamed
22249 @code{int}.
22251 You must never create such structures that cause ambiguous field definitions.
22252 For example, in this structure:
22254 @smallexample
22255 struct @{
22256   int a;
22257   struct @{
22258     int a;
22259   @};
22260 @} foo;
22261 @end smallexample
22263 @noindent
22264 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22265 The compiler gives errors for such constructs.
22267 @opindex fms-extensions
22268 Unless @option{-fms-extensions} is used, the unnamed field must be a
22269 structure or union definition without a tag (for example, @samp{struct
22270 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22271 also be a definition with a tag such as @samp{struct foo @{ int a;
22272 @};}, a reference to a previously defined structure or union such as
22273 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22274 previously defined structure or union type.
22276 @opindex fplan9-extensions
22277 The option @option{-fplan9-extensions} enables
22278 @option{-fms-extensions} as well as two other extensions.  First, a
22279 pointer to a structure is automatically converted to a pointer to an
22280 anonymous field for assignments and function calls.  For example:
22282 @smallexample
22283 struct s1 @{ int a; @};
22284 struct s2 @{ struct s1; @};
22285 extern void f1 (struct s1 *);
22286 void f2 (struct s2 *p) @{ f1 (p); @}
22287 @end smallexample
22289 @noindent
22290 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22291 converted into a pointer to the anonymous field.
22293 Second, when the type of an anonymous field is a @code{typedef} for a
22294 @code{struct} or @code{union}, code may refer to the field using the
22295 name of the @code{typedef}.
22297 @smallexample
22298 typedef struct @{ int a; @} s1;
22299 struct s2 @{ s1; @};
22300 s1 f1 (struct s2 *p) @{ return p->s1; @}
22301 @end smallexample
22303 These usages are only permitted when they are not ambiguous.
22305 @node Thread-Local
22306 @section Thread-Local Storage
22307 @cindex Thread-Local Storage
22308 @cindex @acronym{TLS}
22309 @cindex @code{__thread}
22311 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22312 are allocated such that there is one instance of the variable per extant
22313 thread.  The runtime model GCC uses to implement this originates
22314 in the IA-64 processor-specific ABI, but has since been migrated
22315 to other processors as well.  It requires significant support from
22316 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22317 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22318 is not available everywhere.
22320 At the user level, the extension is visible with a new storage
22321 class keyword: @code{__thread}.  For example:
22323 @smallexample
22324 __thread int i;
22325 extern __thread struct state s;
22326 static __thread char *p;
22327 @end smallexample
22329 The @code{__thread} specifier may be used alone, with the @code{extern}
22330 or @code{static} specifiers, but with no other storage class specifier.
22331 When used with @code{extern} or @code{static}, @code{__thread} must appear
22332 immediately after the other storage class specifier.
22334 The @code{__thread} specifier may be applied to any global, file-scoped
22335 static, function-scoped static, or static data member of a class.  It may
22336 not be applied to block-scoped automatic or non-static data member.
22338 When the address-of operator is applied to a thread-local variable, it is
22339 evaluated at run time and returns the address of the current thread's
22340 instance of that variable.  An address so obtained may be used by any
22341 thread.  When a thread terminates, any pointers to thread-local variables
22342 in that thread become invalid.
22344 No static initialization may refer to the address of a thread-local variable.
22346 In C++, if an initializer is present for a thread-local variable, it must
22347 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22348 standard.
22350 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22351 ELF Handling For Thread-Local Storage} for a detailed explanation of
22352 the four thread-local storage addressing models, and how the runtime
22353 is expected to function.
22355 @menu
22356 * C99 Thread-Local Edits::
22357 * C++98 Thread-Local Edits::
22358 @end menu
22360 @node C99 Thread-Local Edits
22361 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22363 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22364 that document the exact semantics of the language extension.
22366 @itemize @bullet
22367 @item
22368 @cite{5.1.2  Execution environments}
22370 Add new text after paragraph 1
22372 @quotation
22373 Within either execution environment, a @dfn{thread} is a flow of
22374 control within a program.  It is implementation defined whether
22375 or not there may be more than one thread associated with a program.
22376 It is implementation defined how threads beyond the first are
22377 created, the name and type of the function called at thread
22378 startup, and how threads may be terminated.  However, objects
22379 with thread storage duration shall be initialized before thread
22380 startup.
22381 @end quotation
22383 @item
22384 @cite{6.2.4  Storage durations of objects}
22386 Add new text before paragraph 3
22388 @quotation
22389 An object whose identifier is declared with the storage-class
22390 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22391 Its lifetime is the entire execution of the thread, and its
22392 stored value is initialized only once, prior to thread startup.
22393 @end quotation
22395 @item
22396 @cite{6.4.1  Keywords}
22398 Add @code{__thread}.
22400 @item
22401 @cite{6.7.1  Storage-class specifiers}
22403 Add @code{__thread} to the list of storage class specifiers in
22404 paragraph 1.
22406 Change paragraph 2 to
22408 @quotation
22409 With the exception of @code{__thread}, at most one storage-class
22410 specifier may be given [@dots{}].  The @code{__thread} specifier may
22411 be used alone, or immediately following @code{extern} or
22412 @code{static}.
22413 @end quotation
22415 Add new text after paragraph 6
22417 @quotation
22418 The declaration of an identifier for a variable that has
22419 block scope that specifies @code{__thread} shall also
22420 specify either @code{extern} or @code{static}.
22422 The @code{__thread} specifier shall be used only with
22423 variables.
22424 @end quotation
22425 @end itemize
22427 @node C++98 Thread-Local Edits
22428 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22430 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22431 that document the exact semantics of the language extension.
22433 @itemize @bullet
22434 @item
22435 @b{[intro.execution]}
22437 New text after paragraph 4
22439 @quotation
22440 A @dfn{thread} is a flow of control within the abstract machine.
22441 It is implementation defined whether or not there may be more than
22442 one thread.
22443 @end quotation
22445 New text after paragraph 7
22447 @quotation
22448 It is unspecified whether additional action must be taken to
22449 ensure when and whether side effects are visible to other threads.
22450 @end quotation
22452 @item
22453 @b{[lex.key]}
22455 Add @code{__thread}.
22457 @item
22458 @b{[basic.start.main]}
22460 Add after paragraph 5
22462 @quotation
22463 The thread that begins execution at the @code{main} function is called
22464 the @dfn{main thread}.  It is implementation defined how functions
22465 beginning threads other than the main thread are designated or typed.
22466 A function so designated, as well as the @code{main} function, is called
22467 a @dfn{thread startup function}.  It is implementation defined what
22468 happens if a thread startup function returns.  It is implementation
22469 defined what happens to other threads when any thread calls @code{exit}.
22470 @end quotation
22472 @item
22473 @b{[basic.start.init]}
22475 Add after paragraph 4
22477 @quotation
22478 The storage for an object of thread storage duration shall be
22479 statically initialized before the first statement of the thread startup
22480 function.  An object of thread storage duration shall not require
22481 dynamic initialization.
22482 @end quotation
22484 @item
22485 @b{[basic.start.term]}
22487 Add after paragraph 3
22489 @quotation
22490 The type of an object with thread storage duration shall not have a
22491 non-trivial destructor, nor shall it be an array type whose elements
22492 (directly or indirectly) have non-trivial destructors.
22493 @end quotation
22495 @item
22496 @b{[basic.stc]}
22498 Add ``thread storage duration'' to the list in paragraph 1.
22500 Change paragraph 2
22502 @quotation
22503 Thread, static, and automatic storage durations are associated with
22504 objects introduced by declarations [@dots{}].
22505 @end quotation
22507 Add @code{__thread} to the list of specifiers in paragraph 3.
22509 @item
22510 @b{[basic.stc.thread]}
22512 New section before @b{[basic.stc.static]}
22514 @quotation
22515 The keyword @code{__thread} applied to a non-local object gives the
22516 object thread storage duration.
22518 A local variable or class data member declared both @code{static}
22519 and @code{__thread} gives the variable or member thread storage
22520 duration.
22521 @end quotation
22523 @item
22524 @b{[basic.stc.static]}
22526 Change paragraph 1
22528 @quotation
22529 All objects that have neither thread storage duration, dynamic
22530 storage duration nor are local [@dots{}].
22531 @end quotation
22533 @item
22534 @b{[dcl.stc]}
22536 Add @code{__thread} to the list in paragraph 1.
22538 Change paragraph 1
22540 @quotation
22541 With the exception of @code{__thread}, at most one
22542 @var{storage-class-specifier} shall appear in a given
22543 @var{decl-specifier-seq}.  The @code{__thread} specifier may
22544 be used alone, or immediately following the @code{extern} or
22545 @code{static} specifiers.  [@dots{}]
22546 @end quotation
22548 Add after paragraph 5
22550 @quotation
22551 The @code{__thread} specifier can be applied only to the names of objects
22552 and to anonymous unions.
22553 @end quotation
22555 @item
22556 @b{[class.mem]}
22558 Add after paragraph 6
22560 @quotation
22561 Non-@code{static} members shall not be @code{__thread}.
22562 @end quotation
22563 @end itemize
22565 @node Binary constants
22566 @section Binary Constants using the @samp{0b} Prefix
22567 @cindex Binary constants using the @samp{0b} prefix
22569 Integer constants can be written as binary constants, consisting of a
22570 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
22571 @samp{0B}.  This is particularly useful in environments that operate a
22572 lot on the bit level (like microcontrollers).
22574 The following statements are identical:
22576 @smallexample
22577 i =       42;
22578 i =     0x2a;
22579 i =      052;
22580 i = 0b101010;
22581 @end smallexample
22583 The type of these constants follows the same rules as for octal or
22584 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
22585 can be applied.
22587 @node C++ Extensions
22588 @chapter Extensions to the C++ Language
22589 @cindex extensions, C++ language
22590 @cindex C++ language extensions
22592 The GNU compiler provides these extensions to the C++ language (and you
22593 can also use most of the C language extensions in your C++ programs).  If you
22594 want to write code that checks whether these features are available, you can
22595 test for the GNU compiler the same way as for C programs: check for a
22596 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
22597 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
22598 Predefined Macros,cpp,The GNU C Preprocessor}).
22600 @menu
22601 * C++ Volatiles::       What constitutes an access to a volatile object.
22602 * Restricted Pointers:: C99 restricted pointers and references.
22603 * Vague Linkage::       Where G++ puts inlines, vtables and such.
22604 * C++ Interface::       You can use a single C++ header file for both
22605                         declarations and definitions.
22606 * Template Instantiation:: Methods for ensuring that exactly one copy of
22607                         each needed template instantiation is emitted.
22608 * Bound member functions:: You can extract a function pointer to the
22609                         method denoted by a @samp{->*} or @samp{.*} expression.
22610 * C++ Attributes::      Variable, function, and type attributes for C++ only.
22611 * Function Multiversioning::   Declaring multiple function versions.
22612 * Type Traits::         Compiler support for type traits.
22613 * C++ Concepts::        Improved support for generic programming.
22614 * Deprecated Features:: Things will disappear from G++.
22615 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22616 @end menu
22618 @node C++ Volatiles
22619 @section When is a Volatile C++ Object Accessed?
22620 @cindex accessing volatiles
22621 @cindex volatile read
22622 @cindex volatile write
22623 @cindex volatile access
22625 The C++ standard differs from the C standard in its treatment of
22626 volatile objects.  It fails to specify what constitutes a volatile
22627 access, except to say that C++ should behave in a similar manner to C
22628 with respect to volatiles, where possible.  However, the different
22629 lvalueness of expressions between C and C++ complicate the behavior.
22630 G++ behaves the same as GCC for volatile access, @xref{C
22631 Extensions,,Volatiles}, for a description of GCC's behavior.
22633 The C and C++ language specifications differ when an object is
22634 accessed in a void context:
22636 @smallexample
22637 volatile int *src = @var{somevalue};
22638 *src;
22639 @end smallexample
22641 The C++ standard specifies that such expressions do not undergo lvalue
22642 to rvalue conversion, and that the type of the dereferenced object may
22643 be incomplete.  The C++ standard does not specify explicitly that it
22644 is lvalue to rvalue conversion that is responsible for causing an
22645 access.  There is reason to believe that it is, because otherwise
22646 certain simple expressions become undefined.  However, because it
22647 would surprise most programmers, G++ treats dereferencing a pointer to
22648 volatile object of complete type as GCC would do for an equivalent
22649 type in C@.  When the object has incomplete type, G++ issues a
22650 warning; if you wish to force an error, you must force a conversion to
22651 rvalue with, for instance, a static cast.
22653 When using a reference to volatile, G++ does not treat equivalent
22654 expressions as accesses to volatiles, but instead issues a warning that
22655 no volatile is accessed.  The rationale for this is that otherwise it
22656 becomes difficult to determine where volatile access occur, and not
22657 possible to ignore the return value from functions returning volatile
22658 references.  Again, if you wish to force a read, cast the reference to
22659 an rvalue.
22661 G++ implements the same behavior as GCC does when assigning to a
22662 volatile object---there is no reread of the assigned-to object, the
22663 assigned rvalue is reused.  Note that in C++ assignment expressions
22664 are lvalues, and if used as an lvalue, the volatile object is
22665 referred to.  For instance, @var{vref} refers to @var{vobj}, as
22666 expected, in the following example:
22668 @smallexample
22669 volatile int vobj;
22670 volatile int &vref = vobj = @var{something};
22671 @end smallexample
22673 @node Restricted Pointers
22674 @section Restricting Pointer Aliasing
22675 @cindex restricted pointers
22676 @cindex restricted references
22677 @cindex restricted this pointer
22679 As with the C front end, G++ understands the C99 feature of restricted pointers,
22680 specified with the @code{__restrict__}, or @code{__restrict} type
22681 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
22682 language flag, @code{restrict} is not a keyword in C++.
22684 In addition to allowing restricted pointers, you can specify restricted
22685 references, which indicate that the reference is not aliased in the local
22686 context.
22688 @smallexample
22689 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22691   /* @r{@dots{}} */
22693 @end smallexample
22695 @noindent
22696 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22697 @var{rref} refers to a (different) unaliased integer.
22699 You may also specify whether a member function's @var{this} pointer is
22700 unaliased by using @code{__restrict__} as a member function qualifier.
22702 @smallexample
22703 void T::fn () __restrict__
22705   /* @r{@dots{}} */
22707 @end smallexample
22709 @noindent
22710 Within the body of @code{T::fn}, @var{this} has the effective
22711 definition @code{T *__restrict__ const this}.  Notice that the
22712 interpretation of a @code{__restrict__} member function qualifier is
22713 different to that of @code{const} or @code{volatile} qualifier, in that it
22714 is applied to the pointer rather than the object.  This is consistent with
22715 other compilers that implement restricted pointers.
22717 As with all outermost parameter qualifiers, @code{__restrict__} is
22718 ignored in function definition matching.  This means you only need to
22719 specify @code{__restrict__} in a function definition, rather than
22720 in a function prototype as well.
22722 @node Vague Linkage
22723 @section Vague Linkage
22724 @cindex vague linkage
22726 There are several constructs in C++ that require space in the object
22727 file but are not clearly tied to a single translation unit.  We say that
22728 these constructs have ``vague linkage''.  Typically such constructs are
22729 emitted wherever they are needed, though sometimes we can be more
22730 clever.
22732 @table @asis
22733 @item Inline Functions
22734 Inline functions are typically defined in a header file which can be
22735 included in many different compilations.  Hopefully they can usually be
22736 inlined, but sometimes an out-of-line copy is necessary, if the address
22737 of the function is taken or if inlining fails.  In general, we emit an
22738 out-of-line copy in all translation units where one is needed.  As an
22739 exception, we only emit inline virtual functions with the vtable, since
22740 it always requires a copy.
22742 Local static variables and string constants used in an inline function
22743 are also considered to have vague linkage, since they must be shared
22744 between all inlined and out-of-line instances of the function.
22746 @item VTables
22747 @cindex vtable
22748 C++ virtual functions are implemented in most compilers using a lookup
22749 table, known as a vtable.  The vtable contains pointers to the virtual
22750 functions provided by a class, and each object of the class contains a
22751 pointer to its vtable (or vtables, in some multiple-inheritance
22752 situations).  If the class declares any non-inline, non-pure virtual
22753 functions, the first one is chosen as the ``key method'' for the class,
22754 and the vtable is only emitted in the translation unit where the key
22755 method is defined.
22757 @emph{Note:} If the chosen key method is later defined as inline, the
22758 vtable is still emitted in every translation unit that defines it.
22759 Make sure that any inline virtuals are declared inline in the class
22760 body, even if they are not defined there.
22762 @item @code{type_info} objects
22763 @cindex @code{type_info}
22764 @cindex RTTI
22765 C++ requires information about types to be written out in order to
22766 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
22767 For polymorphic classes (classes with virtual functions), the @samp{type_info}
22768 object is written out along with the vtable so that @samp{dynamic_cast}
22769 can determine the dynamic type of a class object at run time.  For all
22770 other types, we write out the @samp{type_info} object when it is used: when
22771 applying @samp{typeid} to an expression, throwing an object, or
22772 referring to a type in a catch clause or exception specification.
22774 @item Template Instantiations
22775 Most everything in this section also applies to template instantiations,
22776 but there are other options as well.
22777 @xref{Template Instantiation,,Where's the Template?}.
22779 @end table
22781 When used with GNU ld version 2.8 or later on an ELF system such as
22782 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
22783 these constructs will be discarded at link time.  This is known as
22784 COMDAT support.
22786 On targets that don't support COMDAT, but do support weak symbols, GCC
22787 uses them.  This way one copy overrides all the others, but
22788 the unused copies still take up space in the executable.
22790 For targets that do not support either COMDAT or weak symbols,
22791 most entities with vague linkage are emitted as local symbols to
22792 avoid duplicate definition errors from the linker.  This does not happen
22793 for local statics in inlines, however, as having multiple copies
22794 almost certainly breaks things.
22796 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
22797 another way to control placement of these constructs.
22799 @node C++ Interface
22800 @section C++ Interface and Implementation Pragmas
22802 @cindex interface and implementation headers, C++
22803 @cindex C++ interface and implementation headers
22804 @cindex pragmas, interface and implementation
22806 @code{#pragma interface} and @code{#pragma implementation} provide the
22807 user with a way of explicitly directing the compiler to emit entities
22808 with vague linkage (and debugging information) in a particular
22809 translation unit.
22811 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
22812 by COMDAT support and the ``key method'' heuristic
22813 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
22814 program to grow due to unnecessary out-of-line copies of inline
22815 functions.
22817 @table @code
22818 @item #pragma interface
22819 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
22820 @kindex #pragma interface
22821 Use this directive in @emph{header files} that define object classes, to save
22822 space in most of the object files that use those classes.  Normally,
22823 local copies of certain information (backup copies of inline member
22824 functions, debugging information, and the internal tables that implement
22825 virtual functions) must be kept in each object file that includes class
22826 definitions.  You can use this pragma to avoid such duplication.  When a
22827 header file containing @samp{#pragma interface} is included in a
22828 compilation, this auxiliary information is not generated (unless
22829 the main input source file itself uses @samp{#pragma implementation}).
22830 Instead, the object files contain references to be resolved at link
22831 time.
22833 The second form of this directive is useful for the case where you have
22834 multiple headers with the same name in different directories.  If you
22835 use this form, you must specify the same string to @samp{#pragma
22836 implementation}.
22838 @item #pragma implementation
22839 @itemx #pragma implementation "@var{objects}.h"
22840 @kindex #pragma implementation
22841 Use this pragma in a @emph{main input file}, when you want full output from
22842 included header files to be generated (and made globally visible).  The
22843 included header file, in turn, should use @samp{#pragma interface}.
22844 Backup copies of inline member functions, debugging information, and the
22845 internal tables used to implement virtual functions are all generated in
22846 implementation files.
22848 @cindex implied @code{#pragma implementation}
22849 @cindex @code{#pragma implementation}, implied
22850 @cindex naming convention, implementation headers
22851 If you use @samp{#pragma implementation} with no argument, it applies to
22852 an include file with the same basename@footnote{A file's @dfn{basename}
22853 is the name stripped of all leading path information and of trailing
22854 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
22855 file.  For example, in @file{allclass.cc}, giving just
22856 @samp{#pragma implementation}
22857 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
22859 Use the string argument if you want a single implementation file to
22860 include code from multiple header files.  (You must also use
22861 @samp{#include} to include the header file; @samp{#pragma
22862 implementation} only specifies how to use the file---it doesn't actually
22863 include it.)
22865 There is no way to split up the contents of a single header file into
22866 multiple implementation files.
22867 @end table
22869 @cindex inlining and C++ pragmas
22870 @cindex C++ pragmas, effect on inlining
22871 @cindex pragmas in C++, effect on inlining
22872 @samp{#pragma implementation} and @samp{#pragma interface} also have an
22873 effect on function inlining.
22875 If you define a class in a header file marked with @samp{#pragma
22876 interface}, the effect on an inline function defined in that class is
22877 similar to an explicit @code{extern} declaration---the compiler emits
22878 no code at all to define an independent version of the function.  Its
22879 definition is used only for inlining with its callers.
22881 @opindex fno-implement-inlines
22882 Conversely, when you include the same header file in a main source file
22883 that declares it as @samp{#pragma implementation}, the compiler emits
22884 code for the function itself; this defines a version of the function
22885 that can be found via pointers (or by callers compiled without
22886 inlining).  If all calls to the function can be inlined, you can avoid
22887 emitting the function by compiling with @option{-fno-implement-inlines}.
22888 If any calls are not inlined, you will get linker errors.
22890 @node Template Instantiation
22891 @section Where's the Template?
22892 @cindex template instantiation
22894 C++ templates were the first language feature to require more
22895 intelligence from the environment than was traditionally found on a UNIX
22896 system.  Somehow the compiler and linker have to make sure that each
22897 template instance occurs exactly once in the executable if it is needed,
22898 and not at all otherwise.  There are two basic approaches to this
22899 problem, which are referred to as the Borland model and the Cfront model.
22901 @table @asis
22902 @item Borland model
22903 Borland C++ solved the template instantiation problem by adding the code
22904 equivalent of common blocks to their linker; the compiler emits template
22905 instances in each translation unit that uses them, and the linker
22906 collapses them together.  The advantage of this model is that the linker
22907 only has to consider the object files themselves; there is no external
22908 complexity to worry about.  The disadvantage is that compilation time
22909 is increased because the template code is being compiled repeatedly.
22910 Code written for this model tends to include definitions of all
22911 templates in the header file, since they must be seen to be
22912 instantiated.
22914 @item Cfront model
22915 The AT&T C++ translator, Cfront, solved the template instantiation
22916 problem by creating the notion of a template repository, an
22917 automatically maintained place where template instances are stored.  A
22918 more modern version of the repository works as follows: As individual
22919 object files are built, the compiler places any template definitions and
22920 instantiations encountered in the repository.  At link time, the link
22921 wrapper adds in the objects in the repository and compiles any needed
22922 instances that were not previously emitted.  The advantages of this
22923 model are more optimal compilation speed and the ability to use the
22924 system linker; to implement the Borland model a compiler vendor also
22925 needs to replace the linker.  The disadvantages are vastly increased
22926 complexity, and thus potential for error; for some code this can be
22927 just as transparent, but in practice it can been very difficult to build
22928 multiple programs in one directory and one program in multiple
22929 directories.  Code written for this model tends to separate definitions
22930 of non-inline member templates into a separate file, which should be
22931 compiled separately.
22932 @end table
22934 G++ implements the Borland model on targets where the linker supports it,
22935 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
22936 Otherwise G++ implements neither automatic model.
22938 You have the following options for dealing with template instantiations:
22940 @enumerate
22941 @item
22942 Do nothing.  Code written for the Borland model works fine, but
22943 each translation unit contains instances of each of the templates it
22944 uses.  The duplicate instances will be discarded by the linker, but in
22945 a large program, this can lead to an unacceptable amount of code
22946 duplication in object files or shared libraries.
22948 Duplicate instances of a template can be avoided by defining an explicit
22949 instantiation in one object file, and preventing the compiler from doing
22950 implicit instantiations in any other object files by using an explicit
22951 instantiation declaration, using the @code{extern template} syntax:
22953 @smallexample
22954 extern template int max (int, int);
22955 @end smallexample
22957 This syntax is defined in the C++ 2011 standard, but has been supported by
22958 G++ and other compilers since well before 2011.
22960 Explicit instantiations can be used for the largest or most frequently
22961 duplicated instances, without having to know exactly which other instances
22962 are used in the rest of the program.  You can scatter the explicit
22963 instantiations throughout your program, perhaps putting them in the
22964 translation units where the instances are used or the translation units
22965 that define the templates themselves; you can put all of the explicit
22966 instantiations you need into one big file; or you can create small files
22967 like
22969 @smallexample
22970 #include "Foo.h"
22971 #include "Foo.cc"
22973 template class Foo<int>;
22974 template ostream& operator <<
22975                 (ostream&, const Foo<int>&);
22976 @end smallexample
22978 @noindent
22979 for each of the instances you need, and create a template instantiation
22980 library from those.
22982 This is the simplest option, but also offers flexibility and
22983 fine-grained control when necessary. It is also the most portable
22984 alternative and programs using this approach will work with most modern
22985 compilers.
22987 @item
22988 @opindex frepo
22989 Compile your template-using code with @option{-frepo}.  The compiler
22990 generates files with the extension @samp{.rpo} listing all of the
22991 template instantiations used in the corresponding object files that
22992 could be instantiated there; the link wrapper, @samp{collect2},
22993 then updates the @samp{.rpo} files to tell the compiler where to place
22994 those instantiations and rebuild any affected object files.  The
22995 link-time overhead is negligible after the first pass, as the compiler
22996 continues to place the instantiations in the same files.
22998 This can be a suitable option for application code written for the Borland
22999 model, as it usually just works.  Code written for the Cfront model 
23000 needs to be modified so that the template definitions are available at
23001 one or more points of instantiation; usually this is as simple as adding
23002 @code{#include <tmethods.cc>} to the end of each template header.
23004 For library code, if you want the library to provide all of the template
23005 instantiations it needs, just try to link all of its object files
23006 together; the link will fail, but cause the instantiations to be
23007 generated as a side effect.  Be warned, however, that this may cause
23008 conflicts if multiple libraries try to provide the same instantiations.
23009 For greater control, use explicit instantiation as described in the next
23010 option.
23012 @item
23013 @opindex fno-implicit-templates
23014 Compile your code with @option{-fno-implicit-templates} to disable the
23015 implicit generation of template instances, and explicitly instantiate
23016 all the ones you use.  This approach requires more knowledge of exactly
23017 which instances you need than do the others, but it's less
23018 mysterious and allows greater control if you want to ensure that only
23019 the intended instances are used.
23021 If you are using Cfront-model code, you can probably get away with not
23022 using @option{-fno-implicit-templates} when compiling files that don't
23023 @samp{#include} the member template definitions.
23025 If you use one big file to do the instantiations, you may want to
23026 compile it without @option{-fno-implicit-templates} so you get all of the
23027 instances required by your explicit instantiations (but not by any
23028 other files) without having to specify them as well.
23030 In addition to forward declaration of explicit instantiations
23031 (with @code{extern}), G++ has extended the template instantiation
23032 syntax to support instantiation of the compiler support data for a
23033 template class (i.e.@: the vtable) without instantiating any of its
23034 members (with @code{inline}), and instantiation of only the static data
23035 members of a template class, without the support data or member
23036 functions (with @code{static}):
23038 @smallexample
23039 inline template class Foo<int>;
23040 static template class Foo<int>;
23041 @end smallexample
23042 @end enumerate
23044 @node Bound member functions
23045 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23046 @cindex pmf
23047 @cindex pointer to member function
23048 @cindex bound pointer to member function
23050 In C++, pointer to member functions (PMFs) are implemented using a wide
23051 pointer of sorts to handle all the possible call mechanisms; the PMF
23052 needs to store information about how to adjust the @samp{this} pointer,
23053 and if the function pointed to is virtual, where to find the vtable, and
23054 where in the vtable to look for the member function.  If you are using
23055 PMFs in an inner loop, you should really reconsider that decision.  If
23056 that is not an option, you can extract the pointer to the function that
23057 would be called for a given object/PMF pair and call it directly inside
23058 the inner loop, to save a bit of time.
23060 Note that you still pay the penalty for the call through a
23061 function pointer; on most modern architectures, such a call defeats the
23062 branch prediction features of the CPU@.  This is also true of normal
23063 virtual function calls.
23065 The syntax for this extension is
23067 @smallexample
23068 extern A a;
23069 extern int (A::*fp)();
23070 typedef int (*fptr)(A *);
23072 fptr p = (fptr)(a.*fp);
23073 @end smallexample
23075 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23076 no object is needed to obtain the address of the function.  They can be
23077 converted to function pointers directly:
23079 @smallexample
23080 fptr p1 = (fptr)(&A::foo);
23081 @end smallexample
23083 @opindex Wno-pmf-conversions
23084 You must specify @option{-Wno-pmf-conversions} to use this extension.
23086 @node C++ Attributes
23087 @section C++-Specific Variable, Function, and Type Attributes
23089 Some attributes only make sense for C++ programs.
23091 @table @code
23092 @item abi_tag ("@var{tag}", ...)
23093 @cindex @code{abi_tag} function attribute
23094 @cindex @code{abi_tag} variable attribute
23095 @cindex @code{abi_tag} type attribute
23096 The @code{abi_tag} attribute can be applied to a function, variable, or class
23097 declaration.  It modifies the mangled name of the entity to
23098 incorporate the tag name, in order to distinguish the function or
23099 class from an earlier version with a different ABI; perhaps the class
23100 has changed size, or the function has a different return type that is
23101 not encoded in the mangled name.
23103 The attribute can also be applied to an inline namespace, but does not
23104 affect the mangled name of the namespace; in this case it is only used
23105 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23106 variables.  Tagging inline namespaces is generally preferable to
23107 tagging individual declarations, but the latter is sometimes
23108 necessary, such as when only certain members of a class need to be
23109 tagged.
23111 The argument can be a list of strings of arbitrary length.  The
23112 strings are sorted on output, so the order of the list is
23113 unimportant.
23115 A redeclaration of an entity must not add new ABI tags,
23116 since doing so would change the mangled name.
23118 The ABI tags apply to a name, so all instantiations and
23119 specializations of a template have the same tags.  The attribute will
23120 be ignored if applied to an explicit specialization or instantiation.
23122 The @option{-Wabi-tag} flag enables a warning about a class which does
23123 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23124 that needs to coexist with an earlier ABI, using this option can help
23125 to find all affected types that need to be tagged.
23127 When a type involving an ABI tag is used as the type of a variable or
23128 return type of a function where that tag is not already present in the
23129 signature of the function, the tag is automatically applied to the
23130 variable or function.  @option{-Wabi-tag} also warns about this
23131 situation; this warning can be avoided by explicitly tagging the
23132 variable or function or moving it into a tagged inline namespace.
23134 @item init_priority (@var{priority})
23135 @cindex @code{init_priority} variable attribute
23137 In Standard C++, objects defined at namespace scope are guaranteed to be
23138 initialized in an order in strict accordance with that of their definitions
23139 @emph{in a given translation unit}.  No guarantee is made for initializations
23140 across translation units.  However, GNU C++ allows users to control the
23141 order of initialization of objects defined at namespace scope with the
23142 @code{init_priority} attribute by specifying a relative @var{priority},
23143 a constant integral expression currently bounded between 101 and 65535
23144 inclusive.  Lower numbers indicate a higher priority.
23146 In the following example, @code{A} would normally be created before
23147 @code{B}, but the @code{init_priority} attribute reverses that order:
23149 @smallexample
23150 Some_Class  A  __attribute__ ((init_priority (2000)));
23151 Some_Class  B  __attribute__ ((init_priority (543)));
23152 @end smallexample
23154 @noindent
23155 Note that the particular values of @var{priority} do not matter; only their
23156 relative ordering.
23158 @item warn_unused
23159 @cindex @code{warn_unused} type attribute
23161 For C++ types with non-trivial constructors and/or destructors it is
23162 impossible for the compiler to determine whether a variable of this
23163 type is truly unused if it is not referenced. This type attribute
23164 informs the compiler that variables of this type should be warned
23165 about if they appear to be unused, just like variables of fundamental
23166 types.
23168 This attribute is appropriate for types which just represent a value,
23169 such as @code{std::string}; it is not appropriate for types which
23170 control a resource, such as @code{std::lock_guard}.
23172 This attribute is also accepted in C, but it is unnecessary because C
23173 does not have constructors or destructors.
23175 @end table
23177 @node Function Multiversioning
23178 @section Function Multiversioning
23179 @cindex function versions
23181 With the GNU C++ front end, for x86 targets, you may specify multiple
23182 versions of a function, where each function is specialized for a
23183 specific target feature.  At runtime, the appropriate version of the
23184 function is automatically executed depending on the characteristics of
23185 the execution platform.  Here is an example.
23187 @smallexample
23188 __attribute__ ((target ("default")))
23189 int foo ()
23191   // The default version of foo.
23192   return 0;
23195 __attribute__ ((target ("sse4.2")))
23196 int foo ()
23198   // foo version for SSE4.2
23199   return 1;
23202 __attribute__ ((target ("arch=atom")))
23203 int foo ()
23205   // foo version for the Intel ATOM processor
23206   return 2;
23209 __attribute__ ((target ("arch=amdfam10")))
23210 int foo ()
23212   // foo version for the AMD Family 0x10 processors.
23213   return 3;
23216 int main ()
23218   int (*p)() = &foo;
23219   assert ((*p) () == foo ());
23220   return 0;
23222 @end smallexample
23224 In the above example, four versions of function foo are created. The
23225 first version of foo with the target attribute "default" is the default
23226 version.  This version gets executed when no other target specific
23227 version qualifies for execution on a particular platform. A new version
23228 of foo is created by using the same function signature but with a
23229 different target string.  Function foo is called or a pointer to it is
23230 taken just like a regular function.  GCC takes care of doing the
23231 dispatching to call the right version at runtime.  Refer to the
23232 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23233 Function Multiversioning} for more details.
23235 @node Type Traits
23236 @section Type Traits
23238 The C++ front end implements syntactic extensions that allow
23239 compile-time determination of 
23240 various characteristics of a type (or of a
23241 pair of types).
23243 @table @code
23244 @item __has_nothrow_assign (type)
23245 If @code{type} is const qualified or is a reference type then the trait is
23246 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23247 is true, else if @code{type} is a cv class or union type with copy assignment
23248 operators that are known not to throw an exception then the trait is true,
23249 else it is false.  Requires: @code{type} shall be a complete type,
23250 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23252 @item __has_nothrow_copy (type)
23253 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23254 @code{type} is a cv class or union type with copy constructors that
23255 are known not to throw an exception then the trait is true, else it is false.
23256 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23257 @code{void}, or an array of unknown bound.
23259 @item __has_nothrow_constructor (type)
23260 If @code{__has_trivial_constructor (type)} is true then the trait is
23261 true, else if @code{type} is a cv class or union type (or array
23262 thereof) with a default constructor that is known not to throw an
23263 exception then the trait is true, else it is false.  Requires:
23264 @code{type} shall be a complete type, (possibly cv-qualified)
23265 @code{void}, or an array of unknown bound.
23267 @item __has_trivial_assign (type)
23268 If @code{type} is const qualified or is a reference type then the trait is
23269 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
23270 true, else if @code{type} is a cv class or union type with a trivial
23271 copy assignment ([class.copy]) then the trait is true, else it is
23272 false.  Requires: @code{type} shall be a complete type, (possibly
23273 cv-qualified) @code{void}, or an array of unknown bound.
23275 @item __has_trivial_copy (type)
23276 If @code{__is_pod (type)} is true or @code{type} is a reference type
23277 then the trait is true, else if @code{type} is a cv class or union type
23278 with a trivial copy constructor ([class.copy]) then the trait
23279 is true, else it is false.  Requires: @code{type} shall be a complete
23280 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23282 @item __has_trivial_constructor (type)
23283 If @code{__is_pod (type)} is true then the trait is true, else if
23284 @code{type} is a cv class or union type (or array thereof) with a
23285 trivial default constructor ([class.ctor]) then the trait is true,
23286 else it is false.  Requires: @code{type} shall be a complete
23287 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23289 @item __has_trivial_destructor (type)
23290 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23291 the trait is true, else if @code{type} is a cv class or union type (or
23292 array thereof) with a trivial destructor ([class.dtor]) then the trait
23293 is true, else it is false.  Requires: @code{type} shall be a complete
23294 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23296 @item __has_virtual_destructor (type)
23297 If @code{type} is a class type with a virtual destructor
23298 ([class.dtor]) then the trait is true, else it is false.  Requires:
23299 @code{type} shall be a complete type, (possibly cv-qualified)
23300 @code{void}, or an array of unknown bound.
23302 @item __is_abstract (type)
23303 If @code{type} is an abstract class ([class.abstract]) then the trait
23304 is true, else it is false.  Requires: @code{type} shall be a complete
23305 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23307 @item __is_base_of (base_type, derived_type)
23308 If @code{base_type} is a base class of @code{derived_type}
23309 ([class.derived]) then the trait is true, otherwise it is false.
23310 Top-level cv qualifications of @code{base_type} and
23311 @code{derived_type} are ignored.  For the purposes of this trait, a
23312 class type is considered is own base.  Requires: if @code{__is_class
23313 (base_type)} and @code{__is_class (derived_type)} are true and
23314 @code{base_type} and @code{derived_type} are not the same type
23315 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23316 type.  A diagnostic is produced if this requirement is not met.
23318 @item __is_class (type)
23319 If @code{type} is a cv class type, and not a union type
23320 ([basic.compound]) the trait is true, else it is false.
23322 @item __is_empty (type)
23323 If @code{__is_class (type)} is false then the trait is false.
23324 Otherwise @code{type} is considered empty if and only if: @code{type}
23325 has no non-static data members, or all non-static data members, if
23326 any, are bit-fields of length 0, and @code{type} has no virtual
23327 members, and @code{type} has no virtual base classes, and @code{type}
23328 has no base classes @code{base_type} for which
23329 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
23330 be a complete type, (possibly cv-qualified) @code{void}, or an array
23331 of unknown bound.
23333 @item __is_enum (type)
23334 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23335 true, else it is false.
23337 @item __is_literal_type (type)
23338 If @code{type} is a literal type ([basic.types]) the trait is
23339 true, else it is false.  Requires: @code{type} shall be a complete type,
23340 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23342 @item __is_pod (type)
23343 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23344 else it is false.  Requires: @code{type} shall be a complete type,
23345 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23347 @item __is_polymorphic (type)
23348 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23349 is true, else it is false.  Requires: @code{type} shall be a complete
23350 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23352 @item __is_standard_layout (type)
23353 If @code{type} is a standard-layout type ([basic.types]) the trait is
23354 true, else it is false.  Requires: @code{type} shall be a complete
23355 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23357 @item __is_trivial (type)
23358 If @code{type} is a trivial type ([basic.types]) the trait is
23359 true, else it is false.  Requires: @code{type} shall be a complete
23360 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23362 @item __is_union (type)
23363 If @code{type} is a cv union type ([basic.compound]) the trait is
23364 true, else it is false.
23366 @item __underlying_type (type)
23367 The underlying type of @code{type}.  Requires: @code{type} shall be
23368 an enumeration type ([dcl.enum]).
23370 @item __integer_pack (length)
23371 When used as the pattern of a pack expansion within a template
23372 definition, expands to a template argument pack containing integers
23373 from @code{0} to @code{length-1}.  This is provided for efficient
23374 implementation of @code{std::make_integer_sequence}.
23376 @end table
23379 @node C++ Concepts
23380 @section C++ Concepts
23382 C++ concepts provide much-improved support for generic programming. In
23383 particular, they allow the specification of constraints on template arguments.
23384 The constraints are used to extend the usual overloading and partial
23385 specialization capabilities of the language, allowing generic data structures
23386 and algorithms to be ``refined'' based on their properties rather than their
23387 type names.
23389 The following keywords are reserved for concepts.
23391 @table @code
23392 @item assumes
23393 States an expression as an assumption, and if possible, verifies that the
23394 assumption is valid. For example, @code{assume(n > 0)}.
23396 @item axiom
23397 Introduces an axiom definition. Axioms introduce requirements on values.
23399 @item forall
23400 Introduces a universally quantified object in an axiom. For example,
23401 @code{forall (int n) n + 0 == n}).
23403 @item concept
23404 Introduces a concept definition. Concepts are sets of syntactic and semantic
23405 requirements on types and their values.
23407 @item requires
23408 Introduces constraints on template arguments or requirements for a member
23409 function of a class template.
23411 @end table
23413 The front end also exposes a number of internal mechanism that can be used
23414 to simplify the writing of type traits. Note that some of these traits are
23415 likely to be removed in the future.
23417 @table @code
23418 @item __is_same (type1, type2)
23419 A binary type trait: true whenever the type arguments are the same.
23421 @end table
23424 @node Deprecated Features
23425 @section Deprecated Features
23427 In the past, the GNU C++ compiler was extended to experiment with new
23428 features, at a time when the C++ language was still evolving.  Now that
23429 the C++ standard is complete, some of those features are superseded by
23430 superior alternatives.  Using the old features might cause a warning in
23431 some cases that the feature will be dropped in the future.  In other
23432 cases, the feature might be gone already.
23434 While the list below is not exhaustive, it documents some of the options
23435 that are now deprecated:
23437 @table @code
23438 @item -fexternal-templates
23439 @itemx -falt-external-templates
23440 These are two of the many ways for G++ to implement template
23441 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
23442 defines how template definitions have to be organized across
23443 implementation units.  G++ has an implicit instantiation mechanism that
23444 should work just fine for standard-conforming code.
23446 @item -fstrict-prototype
23447 @itemx -fno-strict-prototype
23448 Previously it was possible to use an empty prototype parameter list to
23449 indicate an unspecified number of parameters (like C), rather than no
23450 parameters, as C++ demands.  This feature has been removed, except where
23451 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
23452 @end table
23454 G++ allows a virtual function returning @samp{void *} to be overridden
23455 by one returning a different pointer type.  This extension to the
23456 covariant return type rules is now deprecated and will be removed from a
23457 future version.
23459 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
23460 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
23461 and are now removed from G++.  Code using these operators should be
23462 modified to use @code{std::min} and @code{std::max} instead.
23464 The named return value extension has been deprecated, and is now
23465 removed from G++.
23467 The use of initializer lists with new expressions has been deprecated,
23468 and is now removed from G++.
23470 Floating and complex non-type template parameters have been deprecated,
23471 and are now removed from G++.
23473 The implicit typename extension has been deprecated and is now
23474 removed from G++.
23476 The use of default arguments in function pointers, function typedefs
23477 and other places where they are not permitted by the standard is
23478 deprecated and will be removed from a future version of G++.
23480 G++ allows floating-point literals to appear in integral constant expressions,
23481 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23482 This extension is deprecated and will be removed from a future version.
23484 G++ allows static data members of const floating-point type to be declared
23485 with an initializer in a class definition. The standard only allows
23486 initializers for static members of const integral types and const
23487 enumeration types so this extension has been deprecated and will be removed
23488 from a future version.
23490 @node Backwards Compatibility
23491 @section Backwards Compatibility
23492 @cindex Backwards Compatibility
23493 @cindex ARM [Annotated C++ Reference Manual]
23495 Now that there is a definitive ISO standard C++, G++ has a specification
23496 to adhere to.  The C++ language evolved over time, and features that
23497 used to be acceptable in previous drafts of the standard, such as the ARM
23498 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
23499 compilation of C++ written to such drafts, G++ contains some backwards
23500 compatibilities.  @emph{All such backwards compatibility features are
23501 liable to disappear in future versions of G++.} They should be considered
23502 deprecated.   @xref{Deprecated Features}.
23504 @table @code
23505 @item For scope
23506 If a variable is declared at for scope, it used to remain in scope until
23507 the end of the scope that contained the for statement (rather than just
23508 within the for scope).  G++ retains this, but issues a warning, if such a
23509 variable is accessed outside the for scope.
23511 @item Implicit C language
23512 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23513 scope to set the language.  On such systems, all header files are
23514 implicitly scoped inside a C language scope.  Also, an empty prototype
23515 @code{()} is treated as an unspecified number of arguments, rather
23516 than no arguments, as C++ demands.
23517 @end table
23519 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
23520 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr