Reverted r249005 until PowerPC and AIX issues sorted.
[official-gcc.git] / gcc / doc / extend.texi
blobd467a1652eeaba47140734796b1c75322527cd9f
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 Per default, any data including read-only data is located in RAM
1316 (the generic address space) so that non-generic address spaces are
1317 needed to locate read-only data in flash memory
1318 @emph{and} to generate the right instructions to access this data
1319 without using (inline) assembler code.
1321 @table @code
1322 @item __flash
1323 @cindex @code{__flash} AVR Named Address Spaces
1324 The @code{__flash} qualifier locates data in the
1325 @code{.progmem.data} section. Data is read using the @code{LPM}
1326 instruction. Pointers to this address space are 16 bits wide.
1328 @item __flash1
1329 @itemx __flash2
1330 @itemx __flash3
1331 @itemx __flash4
1332 @itemx __flash5
1333 @cindex @code{__flash1} AVR Named Address Spaces
1334 @cindex @code{__flash2} AVR Named Address Spaces
1335 @cindex @code{__flash3} AVR Named Address Spaces
1336 @cindex @code{__flash4} AVR Named Address Spaces
1337 @cindex @code{__flash5} AVR Named Address Spaces
1338 These are 16-bit address spaces locating data in section
1339 @code{.progmem@var{N}.data} where @var{N} refers to
1340 address space @code{__flash@var{N}}.
1341 The compiler sets the @code{RAMPZ} segment register appropriately 
1342 before reading data by means of the @code{ELPM} instruction.
1344 @item __memx
1345 @cindex @code{__memx} AVR Named Address Spaces
1346 This is a 24-bit address space that linearizes flash and RAM:
1347 If the high bit of the address is set, data is read from
1348 RAM using the lower two bytes as RAM address.
1349 If the high bit of the address is clear, data is read from flash
1350 with @code{RAMPZ} set according to the high byte of the address.
1351 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1353 Objects in this address space are located in @code{.progmemx.data}.
1354 @end table
1356 @b{Example}
1358 @smallexample
1359 char my_read (const __flash char ** p)
1361     /* p is a pointer to RAM that points to a pointer to flash.
1362        The first indirection of p reads that flash pointer
1363        from RAM and the second indirection reads a char from this
1364        flash address.  */
1366     return **p;
1369 /* Locate array[] in flash memory */
1370 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1372 int i = 1;
1374 int main (void)
1376    /* Return 17 by reading from flash memory */
1377    return array[array[i]];
1379 @end smallexample
1381 @noindent
1382 For each named address space supported by avr-gcc there is an equally
1383 named but uppercase built-in macro defined. 
1384 The purpose is to facilitate testing if respective address space
1385 support is available or not:
1387 @smallexample
1388 #ifdef __FLASH
1389 const __flash int var = 1;
1391 int read_var (void)
1393     return var;
1395 #else
1396 #include <avr/pgmspace.h> /* From AVR-LibC */
1398 const int var PROGMEM = 1;
1400 int read_var (void)
1402     return (int) pgm_read_word (&var);
1404 #endif /* __FLASH */
1405 @end smallexample
1407 @noindent
1408 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1409 locates data in flash but
1410 accesses to these data read from generic address space, i.e.@:
1411 from RAM,
1412 so that you need special accessors like @code{pgm_read_byte}
1413 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1414 together with attribute @code{progmem}.
1416 @noindent
1417 @b{Limitations and caveats}
1419 @itemize
1420 @item
1421 Reading across the 64@tie{}KiB section boundary of
1422 the @code{__flash} or @code{__flash@var{N}} address spaces
1423 shows undefined behavior. The only address space that
1424 supports reading across the 64@tie{}KiB flash segment boundaries is
1425 @code{__memx}.
1427 @item
1428 If you use one of the @code{__flash@var{N}} address spaces
1429 you must arrange your linker script to locate the
1430 @code{.progmem@var{N}.data} sections according to your needs.
1432 @item
1433 Any data or pointers to the non-generic address spaces must
1434 be qualified as @code{const}, i.e.@: as read-only data.
1435 This still applies if the data in one of these address
1436 spaces like software version number or calibration lookup table are intended to
1437 be changed after load time by, say, a boot loader. In this case
1438 the right qualification is @code{const} @code{volatile} so that the compiler
1439 must not optimize away known values or insert them
1440 as immediates into operands of instructions.
1442 @item
1443 The following code initializes a variable @code{pfoo}
1444 located in static storage with a 24-bit address:
1445 @smallexample
1446 extern const __memx char foo;
1447 const __memx void *pfoo = &foo;
1448 @end smallexample
1450 @noindent
1451 Such code requires at least binutils 2.23, see
1452 @w{@uref{https://sourceware.org/PR13503,PR13503}}.
1454 @item
1455 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1456 Data can be put into and read from flash memory by means of
1457 attribute @code{progmem}, see @ref{AVR Variable Attributes}.
1459 @end itemize
1461 @subsection M32C Named Address Spaces
1462 @cindex @code{__far} M32C Named Address Spaces
1464 On the M32C target, with the R8C and M16C CPU variants, variables
1465 qualified with @code{__far} are accessed using 32-bit addresses in
1466 order to access memory beyond the first 64@tie{}Ki bytes.  If
1467 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1468 effect.
1470 @subsection RL78 Named Address Spaces
1471 @cindex @code{__far} RL78 Named Address Spaces
1473 On the RL78 target, variables qualified with @code{__far} are accessed
1474 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1475 addresses.  Non-far variables are assumed to appear in the topmost
1476 64@tie{}KiB of the address space.
1478 @subsection SPU Named Address Spaces
1479 @cindex @code{__ea} SPU Named Address Spaces
1481 On the SPU target variables may be declared as
1482 belonging to another address space by qualifying the type with the
1483 @code{__ea} address space identifier:
1485 @smallexample
1486 extern int __ea i;
1487 @end smallexample
1489 @noindent 
1490 The compiler generates special code to access the variable @code{i}.
1491 It may use runtime library
1492 support, or generate special machine instructions to access that address
1493 space.
1495 @subsection x86 Named Address Spaces
1496 @cindex x86 named address spaces
1498 On the x86 target, variables may be declared as being relative
1499 to the @code{%fs} or @code{%gs} segments.
1501 @table @code
1502 @item __seg_fs
1503 @itemx __seg_gs
1504 @cindex @code{__seg_fs} x86 named address space
1505 @cindex @code{__seg_gs} x86 named address space
1506 The object is accessed with the respective segment override prefix.
1508 The respective segment base must be set via some method specific to
1509 the operating system.  Rather than require an expensive system call
1510 to retrieve the segment base, these address spaces are not considered
1511 to be subspaces of the generic (flat) address space.  This means that
1512 explicit casts are required to convert pointers between these address
1513 spaces and the generic address space.  In practice the application
1514 should cast to @code{uintptr_t} and apply the segment base offset
1515 that it installed previously.
1517 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1518 defined when these address spaces are supported.
1519 @end table
1521 @node Zero Length
1522 @section Arrays of Length Zero
1523 @cindex arrays of length zero
1524 @cindex zero-length arrays
1525 @cindex length-zero arrays
1526 @cindex flexible array members
1528 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1529 last element of a structure that is really a header for a variable-length
1530 object:
1532 @smallexample
1533 struct line @{
1534   int length;
1535   char contents[0];
1538 struct line *thisline = (struct line *)
1539   malloc (sizeof (struct line) + this_length);
1540 thisline->length = this_length;
1541 @end smallexample
1543 In ISO C90, you would have to give @code{contents} a length of 1, which
1544 means either you waste space or complicate the argument to @code{malloc}.
1546 In ISO C99, you would use a @dfn{flexible array member}, which is
1547 slightly different in syntax and semantics:
1549 @itemize @bullet
1550 @item
1551 Flexible array members are written as @code{contents[]} without
1552 the @code{0}.
1554 @item
1555 Flexible array members have incomplete type, and so the @code{sizeof}
1556 operator may not be applied.  As a quirk of the original implementation
1557 of zero-length arrays, @code{sizeof} evaluates to zero.
1559 @item
1560 Flexible array members may only appear as the last member of a
1561 @code{struct} that is otherwise non-empty.
1563 @item
1564 A structure containing a flexible array member, or a union containing
1565 such a structure (possibly recursively), may not be a member of a
1566 structure or an element of an array.  (However, these uses are
1567 permitted by GCC as extensions.)
1568 @end itemize
1570 Non-empty initialization of zero-length
1571 arrays is treated like any case where there are more initializer
1572 elements than the array holds, in that a suitable warning about ``excess
1573 elements in array'' is given, and the excess elements (all of them, in
1574 this case) are ignored.
1576 GCC allows static initialization of flexible array members.
1577 This is equivalent to defining a new structure containing the original
1578 structure followed by an array of sufficient size to contain the data.
1579 E.g.@: in the following, @code{f1} is constructed as if it were declared
1580 like @code{f2}.
1582 @smallexample
1583 struct f1 @{
1584   int x; int y[];
1585 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1587 struct f2 @{
1588   struct f1 f1; int data[3];
1589 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1590 @end smallexample
1592 @noindent
1593 The convenience of this extension is that @code{f1} has the desired
1594 type, eliminating the need to consistently refer to @code{f2.f1}.
1596 This has symmetry with normal static arrays, in that an array of
1597 unknown size is also written with @code{[]}.
1599 Of course, this extension only makes sense if the extra data comes at
1600 the end of a top-level object, as otherwise we would be overwriting
1601 data at subsequent offsets.  To avoid undue complication and confusion
1602 with initialization of deeply nested arrays, we simply disallow any
1603 non-empty initialization except when the structure is the top-level
1604 object.  For example:
1606 @smallexample
1607 struct foo @{ int x; int y[]; @};
1608 struct bar @{ struct foo z; @};
1610 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1611 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1612 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1613 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1614 @end smallexample
1616 @node Empty Structures
1617 @section Structures with No Members
1618 @cindex empty structures
1619 @cindex zero-size structures
1621 GCC permits a C structure to have no members:
1623 @smallexample
1624 struct empty @{
1626 @end smallexample
1628 The structure has size zero.  In C++, empty structures are part
1629 of the language.  G++ treats empty structures as if they had a single
1630 member of type @code{char}.
1632 @node Variable Length
1633 @section Arrays of Variable Length
1634 @cindex variable-length arrays
1635 @cindex arrays of variable length
1636 @cindex VLAs
1638 Variable-length automatic arrays are allowed in ISO C99, and as an
1639 extension GCC accepts them in C90 mode and in C++.  These arrays are
1640 declared like any other automatic arrays, but with a length that is not
1641 a constant expression.  The storage is allocated at the point of
1642 declaration and deallocated when the block scope containing the declaration
1643 exits.  For
1644 example:
1646 @smallexample
1647 FILE *
1648 concat_fopen (char *s1, char *s2, char *mode)
1650   char str[strlen (s1) + strlen (s2) + 1];
1651   strcpy (str, s1);
1652   strcat (str, s2);
1653   return fopen (str, mode);
1655 @end smallexample
1657 @cindex scope of a variable length array
1658 @cindex variable-length array scope
1659 @cindex deallocating variable length arrays
1660 Jumping or breaking out of the scope of the array name deallocates the
1661 storage.  Jumping into the scope is not allowed; you get an error
1662 message for it.
1664 @cindex variable-length array in a structure
1665 As an extension, GCC accepts variable-length arrays as a member of
1666 a structure or a union.  For example:
1668 @smallexample
1669 void
1670 foo (int n)
1672   struct S @{ int x[n]; @};
1674 @end smallexample
1676 @cindex @code{alloca} vs variable-length arrays
1677 You can use the function @code{alloca} to get an effect much like
1678 variable-length arrays.  The function @code{alloca} is available in
1679 many other C implementations (but not in all).  On the other hand,
1680 variable-length arrays are more elegant.
1682 There are other differences between these two methods.  Space allocated
1683 with @code{alloca} exists until the containing @emph{function} returns.
1684 The space for a variable-length array is deallocated as soon as the array
1685 name's scope ends, unless you also use @code{alloca} in this scope.
1687 You can also use variable-length arrays as arguments to functions:
1689 @smallexample
1690 struct entry
1691 tester (int len, char data[len][len])
1693   /* @r{@dots{}} */
1695 @end smallexample
1697 The length of an array is computed once when the storage is allocated
1698 and is remembered for the scope of the array in case you access it with
1699 @code{sizeof}.
1701 If you want to pass the array first and the length afterward, you can
1702 use a forward declaration in the parameter list---another GNU extension.
1704 @smallexample
1705 struct entry
1706 tester (int len; char data[len][len], int len)
1708   /* @r{@dots{}} */
1710 @end smallexample
1712 @cindex parameter forward declaration
1713 The @samp{int len} before the semicolon is a @dfn{parameter forward
1714 declaration}, and it serves the purpose of making the name @code{len}
1715 known when the declaration of @code{data} is parsed.
1717 You can write any number of such parameter forward declarations in the
1718 parameter list.  They can be separated by commas or semicolons, but the
1719 last one must end with a semicolon, which is followed by the ``real''
1720 parameter declarations.  Each forward declaration must match a ``real''
1721 declaration in parameter name and data type.  ISO C99 does not support
1722 parameter forward declarations.
1724 @node Variadic Macros
1725 @section Macros with a Variable Number of Arguments.
1726 @cindex variable number of arguments
1727 @cindex macro with variable arguments
1728 @cindex rest argument (in macro)
1729 @cindex variadic macros
1731 In the ISO C standard of 1999, a macro can be declared to accept a
1732 variable number of arguments much as a function can.  The syntax for
1733 defining the macro is similar to that of a function.  Here is an
1734 example:
1736 @smallexample
1737 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1738 @end smallexample
1740 @noindent
1741 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1742 such a macro, it represents the zero or more tokens until the closing
1743 parenthesis that ends the invocation, including any commas.  This set of
1744 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1745 wherever it appears.  See the CPP manual for more information.
1747 GCC has long supported variadic macros, and used a different syntax that
1748 allowed you to give a name to the variable arguments just like any other
1749 argument.  Here is an example:
1751 @smallexample
1752 #define debug(format, args...) fprintf (stderr, format, args)
1753 @end smallexample
1755 @noindent
1756 This is in all ways equivalent to the ISO C example above, but arguably
1757 more readable and descriptive.
1759 GNU CPP has two further variadic macro extensions, and permits them to
1760 be used with either of the above forms of macro definition.
1762 In standard C, you are not allowed to leave the variable argument out
1763 entirely; but you are allowed to pass an empty argument.  For example,
1764 this invocation is invalid in ISO C, because there is no comma after
1765 the string:
1767 @smallexample
1768 debug ("A message")
1769 @end smallexample
1771 GNU CPP permits you to completely omit the variable arguments in this
1772 way.  In the above examples, the compiler would complain, though since
1773 the expansion of the macro still has the extra comma after the format
1774 string.
1776 To help solve this problem, CPP behaves specially for variable arguments
1777 used with the token paste operator, @samp{##}.  If instead you write
1779 @smallexample
1780 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1781 @end smallexample
1783 @noindent
1784 and if the variable arguments are omitted or empty, the @samp{##}
1785 operator causes the preprocessor to remove the comma before it.  If you
1786 do provide some variable arguments in your macro invocation, GNU CPP
1787 does not complain about the paste operation and instead places the
1788 variable arguments after the comma.  Just like any other pasted macro
1789 argument, these arguments are not macro expanded.
1791 @node Escaped Newlines
1792 @section Slightly Looser Rules for Escaped Newlines
1793 @cindex escaped newlines
1794 @cindex newlines (escaped)
1796 The preprocessor treatment of escaped newlines is more relaxed 
1797 than that specified by the C90 standard, which requires the newline
1798 to immediately follow a backslash.  
1799 GCC's implementation allows whitespace in the form
1800 of spaces, horizontal and vertical tabs, and form feeds between the
1801 backslash and the subsequent newline.  The preprocessor issues a
1802 warning, but treats it as a valid escaped newline and combines the two
1803 lines to form a single logical line.  This works within comments and
1804 tokens, as well as between tokens.  Comments are @emph{not} treated as
1805 whitespace for the purposes of this relaxation, since they have not
1806 yet been replaced with spaces.
1808 @node Subscripting
1809 @section Non-Lvalue Arrays May Have Subscripts
1810 @cindex subscripting
1811 @cindex arrays, non-lvalue
1813 @cindex subscripting and function values
1814 In ISO C99, arrays that are not lvalues still decay to pointers, and
1815 may be subscripted, although they may not be modified or used after
1816 the next sequence point and the unary @samp{&} operator may not be
1817 applied to them.  As an extension, GNU C allows such arrays to be
1818 subscripted in C90 mode, though otherwise they do not decay to
1819 pointers outside C99 mode.  For example,
1820 this is valid in GNU C though not valid in C90:
1822 @smallexample
1823 @group
1824 struct foo @{int a[4];@};
1826 struct foo f();
1828 bar (int index)
1830   return f().a[index];
1832 @end group
1833 @end smallexample
1835 @node Pointer Arith
1836 @section Arithmetic on @code{void}- and Function-Pointers
1837 @cindex void pointers, arithmetic
1838 @cindex void, size of pointer to
1839 @cindex function pointers, arithmetic
1840 @cindex function, size of pointer to
1842 In GNU C, addition and subtraction operations are supported on pointers to
1843 @code{void} and on pointers to functions.  This is done by treating the
1844 size of a @code{void} or of a function as 1.
1846 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1847 and on function types, and returns 1.
1849 @opindex Wpointer-arith
1850 The option @option{-Wpointer-arith} requests a warning if these extensions
1851 are used.
1853 @node Pointers to Arrays
1854 @section Pointers to Arrays with Qualifiers Work as Expected
1855 @cindex pointers to arrays
1856 @cindex const qualifier
1858 In GNU C, pointers to arrays with qualifiers work similar to pointers
1859 to other qualified types. For example, a value of type @code{int (*)[5]}
1860 can be used to initialize a variable of type @code{const int (*)[5]}.
1861 These types are incompatible in ISO C because the @code{const} qualifier
1862 is formally attached to the element type of the array and not the
1863 array itself.
1865 @smallexample
1866 extern void
1867 transpose (int N, int M, double out[M][N], const double in[N][M]);
1868 double x[3][2];
1869 double y[2][3];
1870 @r{@dots{}}
1871 transpose(3, 2, y, x);
1872 @end smallexample
1874 @node Initializers
1875 @section Non-Constant Initializers
1876 @cindex initializers, non-constant
1877 @cindex non-constant initializers
1879 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1880 automatic variable are not required to be constant expressions in GNU C@.
1881 Here is an example of an initializer with run-time varying elements:
1883 @smallexample
1884 foo (float f, float g)
1886   float beat_freqs[2] = @{ f-g, f+g @};
1887   /* @r{@dots{}} */
1889 @end smallexample
1891 @node Compound Literals
1892 @section Compound Literals
1893 @cindex constructor expressions
1894 @cindex initializations in expressions
1895 @cindex structures, constructor expression
1896 @cindex expressions, constructor
1897 @cindex compound literals
1898 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1900 A compound literal looks like a cast of a brace-enclosed aggregate
1901 initializer list.  Its value is an object of the type specified in
1902 the cast, containing the elements specified in the initializer.
1903 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1904 C99 and later support compound literals.  As an extension, GCC
1905 supports compound literals also in C90 mode and in C++, although
1906 as explained below, the C++ semantics are somewhat different.
1908 Usually, the specified type of a compound literal is a structure.  Assume
1909 that @code{struct foo} and @code{structure} are declared as shown:
1911 @smallexample
1912 struct foo @{int a; char b[2];@} structure;
1913 @end smallexample
1915 @noindent
1916 Here is an example of constructing a @code{struct foo} with a compound literal:
1918 @smallexample
1919 structure = ((struct foo) @{x + y, 'a', 0@});
1920 @end smallexample
1922 @noindent
1923 This is equivalent to writing the following:
1925 @smallexample
1927   struct foo temp = @{x + y, 'a', 0@};
1928   structure = temp;
1930 @end smallexample
1932 You can also construct an array, though this is dangerous in C++, as
1933 explained below.  If all the elements of the compound literal are
1934 (made up of) simple constant expressions suitable for use in
1935 initializers of objects of static storage duration, then the compound
1936 literal can be coerced to a pointer to its first element and used in
1937 such an initializer, as shown here:
1939 @smallexample
1940 char **foo = (char *[]) @{ "x", "y", "z" @};
1941 @end smallexample
1943 Compound literals for scalar types and union types are also allowed.  In
1944 the following example the variable @code{i} is initialized to the value
1945 @code{2}, the result of incrementing the unnamed object created by
1946 the compound literal.
1948 @smallexample
1949 int i = ++(int) @{ 1 @};
1950 @end smallexample
1952 As a GNU extension, GCC allows initialization of objects with static storage
1953 duration by compound literals (which is not possible in ISO C99 because
1954 the initializer is not a constant).
1955 It is handled as if the object were initialized only with the brace-enclosed
1956 list if the types of the compound literal and the object match.
1957 The elements of the compound literal must be constant.
1958 If the object being initialized has array type of unknown size, the size is
1959 determined by the size of the compound literal.
1961 @smallexample
1962 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1963 static int y[] = (int []) @{1, 2, 3@};
1964 static int z[] = (int [3]) @{1@};
1965 @end smallexample
1967 @noindent
1968 The above lines are equivalent to the following:
1969 @smallexample
1970 static struct foo x = @{1, 'a', 'b'@};
1971 static int y[] = @{1, 2, 3@};
1972 static int z[] = @{1, 0, 0@};
1973 @end smallexample
1975 In C, a compound literal designates an unnamed object with static or
1976 automatic storage duration.  In C++, a compound literal designates a
1977 temporary object that only lives until the end of its full-expression.
1978 As a result, well-defined C code that takes the address of a subobject
1979 of a compound literal can be undefined in C++, so G++ rejects
1980 the conversion of a temporary array to a pointer.  For instance, if
1981 the array compound literal example above appeared inside a function,
1982 any subsequent use of @code{foo} in C++ would have undefined behavior
1983 because the lifetime of the array ends after the declaration of @code{foo}.
1985 As an optimization, G++ sometimes gives array compound literals longer
1986 lifetimes: when the array either appears outside a function or has
1987 a @code{const}-qualified type.  If @code{foo} and its initializer had
1988 elements of type @code{char *const} rather than @code{char *}, or if
1989 @code{foo} were a global variable, the array would have static storage
1990 duration.  But it is probably safest just to avoid the use of array
1991 compound literals in C++ code.
1993 @node Designated Inits
1994 @section Designated Initializers
1995 @cindex initializers with labeled elements
1996 @cindex labeled elements in initializers
1997 @cindex case labels in initializers
1998 @cindex designated initializers
2000 Standard C90 requires the elements of an initializer to appear in a fixed
2001 order, the same as the order of the elements in the array or structure
2002 being initialized.
2004 In ISO C99 you can give the elements in any order, specifying the array
2005 indices or structure field names they apply to, and GNU C allows this as
2006 an extension in C90 mode as well.  This extension is not
2007 implemented in GNU C++.
2009 To specify an array index, write
2010 @samp{[@var{index}] =} before the element value.  For example,
2012 @smallexample
2013 int a[6] = @{ [4] = 29, [2] = 15 @};
2014 @end smallexample
2016 @noindent
2017 is equivalent to
2019 @smallexample
2020 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2021 @end smallexample
2023 @noindent
2024 The index values must be constant expressions, even if the array being
2025 initialized is automatic.
2027 An alternative syntax for this that has been obsolete since GCC 2.5 but
2028 GCC still accepts is to write @samp{[@var{index}]} before the element
2029 value, with no @samp{=}.
2031 To initialize a range of elements to the same value, write
2032 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2033 extension.  For example,
2035 @smallexample
2036 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2037 @end smallexample
2039 @noindent
2040 If the value in it has side-effects, the side-effects happen only once,
2041 not for each initialized field by the range initializer.
2043 @noindent
2044 Note that the length of the array is the highest value specified
2045 plus one.
2047 In a structure initializer, specify the name of a field to initialize
2048 with @samp{.@var{fieldname} =} before the element value.  For example,
2049 given the following structure,
2051 @smallexample
2052 struct point @{ int x, y; @};
2053 @end smallexample
2055 @noindent
2056 the following initialization
2058 @smallexample
2059 struct point p = @{ .y = yvalue, .x = xvalue @};
2060 @end smallexample
2062 @noindent
2063 is equivalent to
2065 @smallexample
2066 struct point p = @{ xvalue, yvalue @};
2067 @end smallexample
2069 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2070 @samp{@var{fieldname}:}, as shown here:
2072 @smallexample
2073 struct point p = @{ y: yvalue, x: xvalue @};
2074 @end smallexample
2076 Omitted field members are implicitly initialized the same as objects
2077 that have static storage duration.
2079 @cindex designators
2080 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2081 @dfn{designator}.  You can also use a designator (or the obsolete colon
2082 syntax) when initializing a union, to specify which element of the union
2083 should be used.  For example,
2085 @smallexample
2086 union foo @{ int i; double d; @};
2088 union foo f = @{ .d = 4 @};
2089 @end smallexample
2091 @noindent
2092 converts 4 to a @code{double} to store it in the union using
2093 the second element.  By contrast, casting 4 to type @code{union foo}
2094 stores it into the union as the integer @code{i}, since it is
2095 an integer.  @xref{Cast to Union}.
2097 You can combine this technique of naming elements with ordinary C
2098 initialization of successive elements.  Each initializer element that
2099 does not have a designator applies to the next consecutive element of the
2100 array or structure.  For example,
2102 @smallexample
2103 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2104 @end smallexample
2106 @noindent
2107 is equivalent to
2109 @smallexample
2110 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2111 @end smallexample
2113 Labeling the elements of an array initializer is especially useful
2114 when the indices are characters or belong to an @code{enum} type.
2115 For example:
2117 @smallexample
2118 int whitespace[256]
2119   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2120       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2121 @end smallexample
2123 @cindex designator lists
2124 You can also write a series of @samp{.@var{fieldname}} and
2125 @samp{[@var{index}]} designators before an @samp{=} to specify a
2126 nested subobject to initialize; the list is taken relative to the
2127 subobject corresponding to the closest surrounding brace pair.  For
2128 example, with the @samp{struct point} declaration above:
2130 @smallexample
2131 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2132 @end smallexample
2134 @noindent
2135 If the same field is initialized multiple times, it has the value from
2136 the last initialization.  If any such overridden initialization has
2137 side-effect, it is unspecified whether the side-effect happens or not.
2138 Currently, GCC discards them and issues a warning.
2140 @node Case Ranges
2141 @section Case Ranges
2142 @cindex case ranges
2143 @cindex ranges in case statements
2145 You can specify a range of consecutive values in a single @code{case} label,
2146 like this:
2148 @smallexample
2149 case @var{low} ... @var{high}:
2150 @end smallexample
2152 @noindent
2153 This has the same effect as the proper number of individual @code{case}
2154 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2156 This feature is especially useful for ranges of ASCII character codes:
2158 @smallexample
2159 case 'A' ... 'Z':
2160 @end smallexample
2162 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2163 it may be parsed wrong when you use it with integer values.  For example,
2164 write this:
2166 @smallexample
2167 case 1 ... 5:
2168 @end smallexample
2170 @noindent
2171 rather than this:
2173 @smallexample
2174 case 1...5:
2175 @end smallexample
2177 @node Cast to Union
2178 @section Cast to a Union Type
2179 @cindex cast to a union
2180 @cindex union, casting to a
2182 A cast to union type looks similar to other casts, except that the type
2183 specified is a union type.  You can specify the type either with the
2184 @code{union} keyword or with a @code{typedef} name that refers to
2185 a union.  A cast to a union actually creates a compound literal and
2186 yields an lvalue, not an rvalue like true casts do.
2187 @xref{Compound Literals}.
2189 The types that may be cast to the union type are those of the members
2190 of the union.  Thus, given the following union and variables:
2192 @smallexample
2193 union foo @{ int i; double d; @};
2194 int x;
2195 double y;
2196 @end smallexample
2198 @noindent
2199 both @code{x} and @code{y} can be cast to type @code{union foo}.
2201 Using the cast as the right-hand side of an assignment to a variable of
2202 union type is equivalent to storing in a member of the union:
2204 @smallexample
2205 union foo u;
2206 /* @r{@dots{}} */
2207 u = (union foo) x  @equiv{}  u.i = x
2208 u = (union foo) y  @equiv{}  u.d = y
2209 @end smallexample
2211 You can also use the union cast as a function argument:
2213 @smallexample
2214 void hack (union foo);
2215 /* @r{@dots{}} */
2216 hack ((union foo) x);
2217 @end smallexample
2219 @node Mixed Declarations
2220 @section Mixed Declarations and Code
2221 @cindex mixed declarations and code
2222 @cindex declarations, mixed with code
2223 @cindex code, mixed with declarations
2225 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2226 within compound statements.  As an extension, GNU C also allows this in
2227 C90 mode.  For example, you could do:
2229 @smallexample
2230 int i;
2231 /* @r{@dots{}} */
2232 i++;
2233 int j = i + 2;
2234 @end smallexample
2236 Each identifier is visible from where it is declared until the end of
2237 the enclosing block.
2239 @node Function Attributes
2240 @section Declaring Attributes of Functions
2241 @cindex function attributes
2242 @cindex declaring attributes of functions
2243 @cindex @code{volatile} applied to function
2244 @cindex @code{const} applied to function
2246 In GNU C, you can use function attributes to declare certain things
2247 about functions called in your program which help the compiler
2248 optimize calls and check your code more carefully.  For example, you
2249 can use attributes to declare that a function never returns
2250 (@code{noreturn}), returns a value depending only on its arguments
2251 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2253 You can also use attributes to control memory placement, code
2254 generation options or call/return conventions within the function
2255 being annotated.  Many of these attributes are target-specific.  For
2256 example, many targets support attributes for defining interrupt
2257 handler functions, which typically must follow special register usage
2258 and return conventions.
2260 Function attributes are introduced by the @code{__attribute__} keyword
2261 on a declaration, followed by an attribute specification inside double
2262 parentheses.  You can specify multiple attributes in a declaration by
2263 separating them by commas within the double parentheses or by
2264 immediately following an attribute declaration with another attribute
2265 declaration.  @xref{Attribute Syntax}, for the exact rules on
2266 attribute syntax and placement.
2268 GCC also supports attributes on
2269 variable declarations (@pxref{Variable Attributes}),
2270 labels (@pxref{Label Attributes}),
2271 enumerators (@pxref{Enumerator Attributes}),
2272 statements (@pxref{Statement Attributes}),
2273 and types (@pxref{Type Attributes}).
2275 There is some overlap between the purposes of attributes and pragmas
2276 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2277 found convenient to use @code{__attribute__} to achieve a natural
2278 attachment of attributes to their corresponding declarations, whereas
2279 @code{#pragma} is of use for compatibility with other compilers
2280 or constructs that do not naturally form part of the grammar.
2282 In addition to the attributes documented here,
2283 GCC plugins may provide their own attributes.
2285 @menu
2286 * Common Function Attributes::
2287 * AArch64 Function Attributes::
2288 * ARC Function Attributes::
2289 * ARM Function Attributes::
2290 * AVR Function Attributes::
2291 * Blackfin Function Attributes::
2292 * CR16 Function Attributes::
2293 * Epiphany Function Attributes::
2294 * H8/300 Function Attributes::
2295 * IA-64 Function Attributes::
2296 * M32C Function Attributes::
2297 * M32R/D Function Attributes::
2298 * m68k Function Attributes::
2299 * MCORE Function Attributes::
2300 * MeP Function Attributes::
2301 * MicroBlaze Function Attributes::
2302 * Microsoft Windows Function Attributes::
2303 * MIPS Function Attributes::
2304 * MSP430 Function Attributes::
2305 * NDS32 Function Attributes::
2306 * Nios II Function Attributes::
2307 * Nvidia PTX Function Attributes::
2308 * PowerPC Function Attributes::
2309 * RL78 Function Attributes::
2310 * RX Function Attributes::
2311 * S/390 Function Attributes::
2312 * SH Function Attributes::
2313 * SPU Function Attributes::
2314 * Symbian OS Function Attributes::
2315 * V850 Function Attributes::
2316 * Visium Function Attributes::
2317 * x86 Function Attributes::
2318 * Xstormy16 Function Attributes::
2319 @end menu
2321 @node Common Function Attributes
2322 @subsection Common Function Attributes
2324 The following attributes are supported on most targets.
2326 @table @code
2327 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2329 @item alias ("@var{target}")
2330 @cindex @code{alias} function attribute
2331 The @code{alias} attribute causes the declaration to be emitted as an
2332 alias for another symbol, which must be specified.  For instance,
2334 @smallexample
2335 void __f () @{ /* @r{Do something.} */; @}
2336 void f () __attribute__ ((weak, alias ("__f")));
2337 @end smallexample
2339 @noindent
2340 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2341 mangled name for the target must be used.  It is an error if @samp{__f}
2342 is not defined in the same translation unit.
2344 This attribute requires assembler and object file support,
2345 and may not be available on all targets.
2347 @item aligned (@var{alignment})
2348 @cindex @code{aligned} function attribute
2349 This attribute specifies a minimum alignment for the function,
2350 measured in bytes.
2352 You cannot use this attribute to decrease the alignment of a function,
2353 only to increase it.  However, when you explicitly specify a function
2354 alignment this overrides the effect of the
2355 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2356 function.
2358 Note that the effectiveness of @code{aligned} attributes may be
2359 limited by inherent limitations in your linker.  On many systems, the
2360 linker is only able to arrange for functions to be aligned up to a
2361 certain maximum alignment.  (For some linkers, the maximum supported
2362 alignment may be very very small.)  See your linker documentation for
2363 further information.
2365 The @code{aligned} attribute can also be used for variables and fields
2366 (@pxref{Variable Attributes}.)
2368 @item alloc_align
2369 @cindex @code{alloc_align} function attribute
2370 The @code{alloc_align} attribute is used to tell the compiler that the
2371 function return value points to memory, where the returned pointer minimum
2372 alignment is given by one of the functions parameters.  GCC uses this
2373 information to improve pointer alignment analysis.
2375 The function parameter denoting the allocated alignment is specified by
2376 one integer argument, whose number is the argument of the attribute.
2377 Argument numbering starts at one.
2379 For instance,
2381 @smallexample
2382 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2383 @end smallexample
2385 @noindent
2386 declares that @code{my_memalign} returns memory with minimum alignment
2387 given by parameter 1.
2389 @item alloc_size
2390 @cindex @code{alloc_size} function attribute
2391 The @code{alloc_size} attribute is used to tell the compiler that the
2392 function return value points to memory, where the size is given by
2393 one or two of the functions parameters.  GCC uses this
2394 information to improve the correctness of @code{__builtin_object_size}.
2396 The function parameter(s) denoting the allocated size are specified by
2397 one or two integer arguments supplied to the attribute.  The allocated size
2398 is either the value of the single function argument specified or the product
2399 of the two function arguments specified.  Argument numbering starts at
2400 one.
2402 For instance,
2404 @smallexample
2405 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2406 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2407 @end smallexample
2409 @noindent
2410 declares that @code{my_calloc} returns memory of the size given by
2411 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2412 of the size given by parameter 2.
2414 @item always_inline
2415 @cindex @code{always_inline} function attribute
2416 Generally, functions are not inlined unless optimization is specified.
2417 For functions declared inline, this attribute inlines the function
2418 independent of any restrictions that otherwise apply to inlining.
2419 Failure to inline such a function is diagnosed as an error.
2420 Note that if such a function is called indirectly the compiler may
2421 or may not inline it depending on optimization level and a failure
2422 to inline an indirect call may or may not be diagnosed.
2424 @item artificial
2425 @cindex @code{artificial} function attribute
2426 This attribute is useful for small inline wrappers that if possible
2427 should appear during debugging as a unit.  Depending on the debug
2428 info format it either means marking the function as artificial
2429 or using the caller location for all instructions within the inlined
2430 body.
2432 @item assume_aligned
2433 @cindex @code{assume_aligned} function attribute
2434 The @code{assume_aligned} attribute is used to tell the compiler that the
2435 function return value points to memory, where the returned pointer minimum
2436 alignment is given by the first argument.
2437 If the attribute has two arguments, the second argument is misalignment offset.
2439 For instance
2441 @smallexample
2442 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2443 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2444 @end smallexample
2446 @noindent
2447 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2448 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2449 to 8.
2451 @item bnd_instrument
2452 @cindex @code{bnd_instrument} function attribute
2453 The @code{bnd_instrument} attribute on functions is used to inform the
2454 compiler that the function should be instrumented when compiled
2455 with the @option{-fchkp-instrument-marked-only} option.
2457 @item bnd_legacy
2458 @cindex @code{bnd_legacy} function attribute
2459 @cindex Pointer Bounds Checker attributes
2460 The @code{bnd_legacy} attribute on functions is used to inform the
2461 compiler that the function should not be instrumented when compiled
2462 with the @option{-fcheck-pointer-bounds} option.
2464 @item cold
2465 @cindex @code{cold} function attribute
2466 The @code{cold} attribute on functions is used to inform the compiler that
2467 the function is unlikely to be executed.  The function is optimized for
2468 size rather than speed and on many targets it is placed into a special
2469 subsection of the text section so all cold functions appear close together,
2470 improving code locality of non-cold parts of program.  The paths leading
2471 to calls of cold functions within code are marked as unlikely by the branch
2472 prediction mechanism.  It is thus useful to mark functions used to handle
2473 unlikely conditions, such as @code{perror}, as cold to improve optimization
2474 of hot functions that do call marked functions in rare occasions.
2476 When profile feedback is available, via @option{-fprofile-use}, cold functions
2477 are automatically detected and this attribute is ignored.
2479 @item const
2480 @cindex @code{const} function attribute
2481 @cindex functions that have no side effects
2482 Many functions do not examine any values except their arguments, and
2483 have no effects except the return value.  Basically this is just slightly
2484 more strict class than the @code{pure} attribute below, since function is not
2485 allowed to read global memory.
2487 @cindex pointer arguments
2488 Note that a function that has pointer arguments and examines the data
2489 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2490 function that calls a non-@code{const} function usually must not be
2491 @code{const}.  It does not make sense for a @code{const} function to
2492 return @code{void}.
2494 @item constructor
2495 @itemx destructor
2496 @itemx constructor (@var{priority})
2497 @itemx destructor (@var{priority})
2498 @cindex @code{constructor} function attribute
2499 @cindex @code{destructor} function attribute
2500 The @code{constructor} attribute causes the function to be called
2501 automatically before execution enters @code{main ()}.  Similarly, the
2502 @code{destructor} attribute causes the function to be called
2503 automatically after @code{main ()} completes or @code{exit ()} is
2504 called.  Functions with these attributes are useful for
2505 initializing data that is used implicitly during the execution of
2506 the program.
2508 You may provide an optional integer priority to control the order in
2509 which constructor and destructor functions are run.  A constructor
2510 with a smaller priority number runs before a constructor with a larger
2511 priority number; the opposite relationship holds for destructors.  So,
2512 if you have a constructor that allocates a resource and a destructor
2513 that deallocates the same resource, both functions typically have the
2514 same priority.  The priorities for constructor and destructor
2515 functions are the same as those specified for namespace-scope C++
2516 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2517 constructors for C++ objects with static storage duration and functions
2518 decorated with attribute @code{constructor} are invoked is unspecified.
2519 In mixed declarations, attribute @code{init_priority} can be used to
2520 impose a specific ordering.
2522 @item deprecated
2523 @itemx deprecated (@var{msg})
2524 @cindex @code{deprecated} function attribute
2525 The @code{deprecated} attribute results in a warning if the function
2526 is used anywhere in the source file.  This is useful when identifying
2527 functions that are expected to be removed in a future version of a
2528 program.  The warning also includes the location of the declaration
2529 of the deprecated function, to enable users to easily find further
2530 information about why the function is deprecated, or what they should
2531 do instead.  Note that the warnings only occurs for uses:
2533 @smallexample
2534 int old_fn () __attribute__ ((deprecated));
2535 int old_fn ();
2536 int (*fn_ptr)() = old_fn;
2537 @end smallexample
2539 @noindent
2540 results in a warning on line 3 but not line 2.  The optional @var{msg}
2541 argument, which must be a string, is printed in the warning if
2542 present.
2544 The @code{deprecated} attribute can also be used for variables and
2545 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2547 @item error ("@var{message}")
2548 @itemx warning ("@var{message}")
2549 @cindex @code{error} function attribute
2550 @cindex @code{warning} function attribute
2551 If the @code{error} or @code{warning} attribute 
2552 is used on a function declaration and a call to such a function
2553 is not eliminated through dead code elimination or other optimizations, 
2554 an error or warning (respectively) that includes @var{message} is diagnosed.  
2555 This is useful
2556 for compile-time checking, especially together with @code{__builtin_constant_p}
2557 and inline functions where checking the inline function arguments is not
2558 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2560 While it is possible to leave the function undefined and thus invoke
2561 a link failure (to define the function with
2562 a message in @code{.gnu.warning*} section),
2563 when using these attributes the problem is diagnosed
2564 earlier and with exact location of the call even in presence of inline
2565 functions or when not emitting debugging information.
2567 @item externally_visible
2568 @cindex @code{externally_visible} function attribute
2569 This attribute, attached to a global variable or function, nullifies
2570 the effect of the @option{-fwhole-program} command-line option, so the
2571 object remains visible outside the current compilation unit.
2573 If @option{-fwhole-program} is used together with @option{-flto} and 
2574 @command{gold} is used as the linker plugin, 
2575 @code{externally_visible} attributes are automatically added to functions 
2576 (not variable yet due to a current @command{gold} issue) 
2577 that are accessed outside of LTO objects according to resolution file
2578 produced by @command{gold}.
2579 For other linkers that cannot generate resolution file,
2580 explicit @code{externally_visible} attributes are still necessary.
2582 @item flatten
2583 @cindex @code{flatten} function attribute
2584 Generally, inlining into a function is limited.  For a function marked with
2585 this attribute, every call inside this function is inlined, if possible.
2586 Whether the function itself is considered for inlining depends on its size and
2587 the current inlining parameters.
2589 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2590 @cindex @code{format} function attribute
2591 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2592 @opindex Wformat
2593 The @code{format} attribute specifies that a function takes @code{printf},
2594 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2595 should be type-checked against a format string.  For example, the
2596 declaration:
2598 @smallexample
2599 extern int
2600 my_printf (void *my_object, const char *my_format, ...)
2601       __attribute__ ((format (printf, 2, 3)));
2602 @end smallexample
2604 @noindent
2605 causes the compiler to check the arguments in calls to @code{my_printf}
2606 for consistency with the @code{printf} style format string argument
2607 @code{my_format}.
2609 The parameter @var{archetype} determines how the format string is
2610 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2611 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2612 @code{strfmon}.  (You can also use @code{__printf__},
2613 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2614 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2615 @code{ms_strftime} are also present.
2616 @var{archetype} values such as @code{printf} refer to the formats accepted
2617 by the system's C runtime library,
2618 while values prefixed with @samp{gnu_} always refer
2619 to the formats accepted by the GNU C Library.  On Microsoft Windows
2620 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2621 @file{msvcrt.dll} library.
2622 The parameter @var{string-index}
2623 specifies which argument is the format string argument (starting
2624 from 1), while @var{first-to-check} is the number of the first
2625 argument to check against the format string.  For functions
2626 where the arguments are not available to be checked (such as
2627 @code{vprintf}), specify the third parameter as zero.  In this case the
2628 compiler only checks the format string for consistency.  For
2629 @code{strftime} formats, the third parameter is required to be zero.
2630 Since non-static C++ methods have an implicit @code{this} argument, the
2631 arguments of such methods should be counted from two, not one, when
2632 giving values for @var{string-index} and @var{first-to-check}.
2634 In the example above, the format string (@code{my_format}) is the second
2635 argument of the function @code{my_print}, and the arguments to check
2636 start with the third argument, so the correct parameters for the format
2637 attribute are 2 and 3.
2639 @opindex ffreestanding
2640 @opindex fno-builtin
2641 The @code{format} attribute allows you to identify your own functions
2642 that take format strings as arguments, so that GCC can check the
2643 calls to these functions for errors.  The compiler always (unless
2644 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2645 for the standard library functions @code{printf}, @code{fprintf},
2646 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2647 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2648 warnings are requested (using @option{-Wformat}), so there is no need to
2649 modify the header file @file{stdio.h}.  In C99 mode, the functions
2650 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2651 @code{vsscanf} are also checked.  Except in strictly conforming C
2652 standard modes, the X/Open function @code{strfmon} is also checked as
2653 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2654 @xref{C Dialect Options,,Options Controlling C Dialect}.
2656 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2657 recognized in the same context.  Declarations including these format attributes
2658 are parsed for correct syntax, however the result of checking of such format
2659 strings is not yet defined, and is not carried out by this version of the
2660 compiler.
2662 The target may also provide additional types of format checks.
2663 @xref{Target Format Checks,,Format Checks Specific to Particular
2664 Target Machines}.
2666 @item format_arg (@var{string-index})
2667 @cindex @code{format_arg} function attribute
2668 @opindex Wformat-nonliteral
2669 The @code{format_arg} attribute specifies that a function takes a format
2670 string for a @code{printf}, @code{scanf}, @code{strftime} or
2671 @code{strfmon} style function and modifies it (for example, to translate
2672 it into another language), so the result can be passed to a
2673 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2674 function (with the remaining arguments to the format function the same
2675 as they would have been for the unmodified string).  For example, the
2676 declaration:
2678 @smallexample
2679 extern char *
2680 my_dgettext (char *my_domain, const char *my_format)
2681       __attribute__ ((format_arg (2)));
2682 @end smallexample
2684 @noindent
2685 causes the compiler to check the arguments in calls to a @code{printf},
2686 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2687 format string argument is a call to the @code{my_dgettext} function, for
2688 consistency with the format string argument @code{my_format}.  If the
2689 @code{format_arg} attribute had not been specified, all the compiler
2690 could tell in such calls to format functions would be that the format
2691 string argument is not constant; this would generate a warning when
2692 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2693 without the attribute.
2695 The parameter @var{string-index} specifies which argument is the format
2696 string argument (starting from one).  Since non-static C++ methods have
2697 an implicit @code{this} argument, the arguments of such methods should
2698 be counted from two.
2700 The @code{format_arg} attribute allows you to identify your own
2701 functions that modify format strings, so that GCC can check the
2702 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2703 type function whose operands are a call to one of your own function.
2704 The compiler always treats @code{gettext}, @code{dgettext}, and
2705 @code{dcgettext} in this manner except when strict ISO C support is
2706 requested by @option{-ansi} or an appropriate @option{-std} option, or
2707 @option{-ffreestanding} or @option{-fno-builtin}
2708 is used.  @xref{C Dialect Options,,Options
2709 Controlling C Dialect}.
2711 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2712 @code{NSString} reference for compatibility with the @code{format} attribute
2713 above.
2715 The target may also allow additional types in @code{format-arg} attributes.
2716 @xref{Target Format Checks,,Format Checks Specific to Particular
2717 Target Machines}.
2719 @item gnu_inline
2720 @cindex @code{gnu_inline} function attribute
2721 This attribute should be used with a function that is also declared
2722 with the @code{inline} keyword.  It directs GCC to treat the function
2723 as if it were defined in gnu90 mode even when compiling in C99 or
2724 gnu99 mode.
2726 If the function is declared @code{extern}, then this definition of the
2727 function is used only for inlining.  In no case is the function
2728 compiled as a standalone function, not even if you take its address
2729 explicitly.  Such an address becomes an external reference, as if you
2730 had only declared the function, and had not defined it.  This has
2731 almost the effect of a macro.  The way to use this is to put a
2732 function definition in a header file with this attribute, and put
2733 another copy of the function, without @code{extern}, in a library
2734 file.  The definition in the header file causes most calls to the
2735 function to be inlined.  If any uses of the function remain, they
2736 refer to the single copy in the library.  Note that the two
2737 definitions of the functions need not be precisely the same, although
2738 if they do not have the same effect your program may behave oddly.
2740 In C, if the function is neither @code{extern} nor @code{static}, then
2741 the function is compiled as a standalone function, as well as being
2742 inlined where possible.
2744 This is how GCC traditionally handled functions declared
2745 @code{inline}.  Since ISO C99 specifies a different semantics for
2746 @code{inline}, this function attribute is provided as a transition
2747 measure and as a useful feature in its own right.  This attribute is
2748 available in GCC 4.1.3 and later.  It is available if either of the
2749 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2750 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2751 Function is As Fast As a Macro}.
2753 In C++, this attribute does not depend on @code{extern} in any way,
2754 but it still requires the @code{inline} keyword to enable its special
2755 behavior.
2757 @item hot
2758 @cindex @code{hot} function attribute
2759 The @code{hot} attribute on a function is used to inform the compiler that
2760 the function is a hot spot of the compiled program.  The function is
2761 optimized more aggressively and on many targets it is placed into a special
2762 subsection of the text section so all hot functions appear close together,
2763 improving locality.
2765 When profile feedback is available, via @option{-fprofile-use}, hot functions
2766 are automatically detected and this attribute is ignored.
2768 @item ifunc ("@var{resolver}")
2769 @cindex @code{ifunc} function attribute
2770 @cindex indirect functions
2771 @cindex functions that are dynamically resolved
2772 The @code{ifunc} attribute is used to mark a function as an indirect
2773 function using the STT_GNU_IFUNC symbol type extension to the ELF
2774 standard.  This allows the resolution of the symbol value to be
2775 determined dynamically at load time, and an optimized version of the
2776 routine can be selected for the particular processor or other system
2777 characteristics determined then.  To use this attribute, first define
2778 the implementation functions available, and a resolver function that
2779 returns a pointer to the selected implementation function.  The
2780 implementation functions' declarations must match the API of the
2781 function being implemented, the resolver's declaration is be a
2782 function returning pointer to void function returning void:
2784 @smallexample
2785 void *my_memcpy (void *dst, const void *src, size_t len)
2787   @dots{}
2790 static void (*resolve_memcpy (void)) (void)
2792   return my_memcpy; // we'll just always select this routine
2794 @end smallexample
2796 @noindent
2797 The exported header file declaring the function the user calls would
2798 contain:
2800 @smallexample
2801 extern void *memcpy (void *, const void *, size_t);
2802 @end smallexample
2804 @noindent
2805 allowing the user to call this as a regular function, unaware of the
2806 implementation.  Finally, the indirect function needs to be defined in
2807 the same translation unit as the resolver function:
2809 @smallexample
2810 void *memcpy (void *, const void *, size_t)
2811      __attribute__ ((ifunc ("resolve_memcpy")));
2812 @end smallexample
2814 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2815 and GNU C Library version 2.11.1 are required to use this feature.
2817 @item interrupt
2818 @itemx interrupt_handler
2819 Many GCC back ends support attributes to indicate that a function is
2820 an interrupt handler, which tells the compiler to generate function
2821 entry and exit sequences that differ from those from regular
2822 functions.  The exact syntax and behavior are target-specific;
2823 refer to the following subsections for details.
2825 @item leaf
2826 @cindex @code{leaf} function attribute
2827 Calls to external functions with this attribute must return to the
2828 current compilation unit only by return or by exception handling.  In
2829 particular, a leaf function is not allowed to invoke callback functions
2830 passed to it from the current compilation unit, directly call functions
2831 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2832 might still call functions from other compilation units and thus they
2833 are not necessarily leaf in the sense that they contain no function
2834 calls at all.
2836 The attribute is intended for library functions to improve dataflow
2837 analysis.  The compiler takes the hint that any data not escaping the
2838 current compilation unit cannot be used or modified by the leaf
2839 function.  For example, the @code{sin} function is a leaf function, but
2840 @code{qsort} is not.
2842 Note that leaf functions might indirectly run a signal handler defined
2843 in the current compilation unit that uses static variables.  Similarly,
2844 when lazy symbol resolution is in effect, leaf functions might invoke
2845 indirect functions whose resolver function or implementation function is
2846 defined in the current compilation unit and uses static variables.  There
2847 is no standard-compliant way to write such a signal handler, resolver
2848 function, or implementation function, and the best that you can do is to
2849 remove the @code{leaf} attribute or mark all such static variables
2850 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2851 interposition, care should be taken that functions defined in the
2852 current compilation unit do not unexpectedly interpose other symbols
2853 based on the defined standards mode and defined feature test macros;
2854 otherwise an inadvertent callback would be added.
2856 The attribute has no effect on functions defined within the current
2857 compilation unit.  This is to allow easy merging of multiple compilation
2858 units into one, for example, by using the link-time optimization.  For
2859 this reason the attribute is not allowed on types to annotate indirect
2860 calls.
2862 @item malloc
2863 @cindex @code{malloc} function attribute
2864 @cindex functions that behave like malloc
2865 This tells the compiler that a function is @code{malloc}-like, i.e.,
2866 that the pointer @var{P} returned by the function cannot alias any
2867 other pointer valid when the function returns, and moreover no
2868 pointers to valid objects occur in any storage addressed by @var{P}.
2870 Using this attribute can improve optimization.  Functions like
2871 @code{malloc} and @code{calloc} have this property because they return
2872 a pointer to uninitialized or zeroed-out storage.  However, functions
2873 like @code{realloc} do not have this property, as they can return a
2874 pointer to storage containing pointers.
2876 @item no_icf
2877 @cindex @code{no_icf} function attribute
2878 This function attribute prevents a functions from being merged with another
2879 semantically equivalent function.
2881 @item no_instrument_function
2882 @cindex @code{no_instrument_function} function attribute
2883 @opindex finstrument-functions
2884 If @option{-finstrument-functions} is given, profiling function calls are
2885 generated at entry and exit of most user-compiled functions.
2886 Functions with this attribute are not so instrumented.
2888 @item no_profile_instrument_function
2889 @cindex @code{no_profile_instrument_function} function attribute
2890 The @code{no_profile_instrument_function} attribute on functions is used
2891 to inform the compiler that it should not process any profile feedback based
2892 optimization code instrumentation.
2894 @item no_reorder
2895 @cindex @code{no_reorder} function attribute
2896 Do not reorder functions or variables marked @code{no_reorder}
2897 against each other or top level assembler statements the executable.
2898 The actual order in the program will depend on the linker command
2899 line. Static variables marked like this are also not removed.
2900 This has a similar effect
2901 as the @option{-fno-toplevel-reorder} option, but only applies to the
2902 marked symbols.
2904 @item no_sanitize_address
2905 @itemx no_address_safety_analysis
2906 @cindex @code{no_sanitize_address} function attribute
2907 The @code{no_sanitize_address} attribute on functions is used
2908 to inform the compiler that it should not instrument memory accesses
2909 in the function when compiling with the @option{-fsanitize=address} option.
2910 The @code{no_address_safety_analysis} is a deprecated alias of the
2911 @code{no_sanitize_address} attribute, new code should use
2912 @code{no_sanitize_address}.
2914 @item no_sanitize_thread
2915 @cindex @code{no_sanitize_thread} function attribute
2916 The @code{no_sanitize_thread} attribute on functions is used
2917 to inform the compiler that it should not instrument memory accesses
2918 in the function when compiling with the @option{-fsanitize=thread} option.
2920 @item no_sanitize_undefined
2921 @cindex @code{no_sanitize_undefined} function attribute
2922 The @code{no_sanitize_undefined} attribute on functions is used
2923 to inform the compiler that it should not check for undefined behavior
2924 in the function when compiling with the @option{-fsanitize=undefined} option.
2926 @item no_split_stack
2927 @cindex @code{no_split_stack} function attribute
2928 @opindex fsplit-stack
2929 If @option{-fsplit-stack} is given, functions have a small
2930 prologue which decides whether to split the stack.  Functions with the
2931 @code{no_split_stack} attribute do not have that prologue, and thus
2932 may run with only a small amount of stack space available.
2934 @item no_stack_limit
2935 @cindex @code{no_stack_limit} function attribute
2936 This attribute locally overrides the @option{-fstack-limit-register}
2937 and @option{-fstack-limit-symbol} command-line options; it has the effect
2938 of disabling stack limit checking in the function it applies to.
2940 @item noclone
2941 @cindex @code{noclone} function attribute
2942 This function attribute prevents a function from being considered for
2943 cloning---a mechanism that produces specialized copies of functions
2944 and which is (currently) performed by interprocedural constant
2945 propagation.
2947 @item noinline
2948 @cindex @code{noinline} function attribute
2949 This function attribute prevents a function from being considered for
2950 inlining.
2951 @c Don't enumerate the optimizations by name here; we try to be
2952 @c future-compatible with this mechanism.
2953 If the function does not have side-effects, there are optimizations
2954 other than inlining that cause function calls to be optimized away,
2955 although the function call is live.  To keep such calls from being
2956 optimized away, put
2957 @smallexample
2958 asm ("");
2959 @end smallexample
2961 @noindent
2962 (@pxref{Extended Asm}) in the called function, to serve as a special
2963 side-effect.
2965 @item nonnull (@var{arg-index}, @dots{})
2966 @cindex @code{nonnull} function attribute
2967 @cindex functions with non-null pointer arguments
2968 The @code{nonnull} attribute specifies that some function parameters should
2969 be non-null pointers.  For instance, the declaration:
2971 @smallexample
2972 extern void *
2973 my_memcpy (void *dest, const void *src, size_t len)
2974         __attribute__((nonnull (1, 2)));
2975 @end smallexample
2977 @noindent
2978 causes the compiler to check that, in calls to @code{my_memcpy},
2979 arguments @var{dest} and @var{src} are non-null.  If the compiler
2980 determines that a null pointer is passed in an argument slot marked
2981 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2982 is issued.  The compiler may also choose to make optimizations based
2983 on the knowledge that certain function arguments will never be null.
2985 If no argument index list is given to the @code{nonnull} attribute,
2986 all pointer arguments are marked as non-null.  To illustrate, the
2987 following declaration is equivalent to the previous example:
2989 @smallexample
2990 extern void *
2991 my_memcpy (void *dest, const void *src, size_t len)
2992         __attribute__((nonnull));
2993 @end smallexample
2995 @item noplt
2996 @cindex @code{noplt} function attribute
2997 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2998 Calls to functions marked with this attribute in position-independent code
2999 do not use the PLT.
3001 @smallexample
3002 @group
3003 /* Externally defined function foo.  */
3004 int foo () __attribute__ ((noplt));
3007 main (/* @r{@dots{}} */)
3009   /* @r{@dots{}} */
3010   foo ();
3011   /* @r{@dots{}} */
3013 @end group
3014 @end smallexample
3016 The @code{noplt} attribute on function @code{foo}
3017 tells the compiler to assume that
3018 the function @code{foo} is externally defined and that the call to
3019 @code{foo} must avoid the PLT
3020 in position-independent code.
3022 In position-dependent code, a few targets also convert calls to
3023 functions that are marked to not use the PLT to use the GOT instead.
3025 @item noreturn
3026 @cindex @code{noreturn} function attribute
3027 @cindex functions that never return
3028 A few standard library functions, such as @code{abort} and @code{exit},
3029 cannot return.  GCC knows this automatically.  Some programs define
3030 their own functions that never return.  You can declare them
3031 @code{noreturn} to tell the compiler this fact.  For example,
3033 @smallexample
3034 @group
3035 void fatal () __attribute__ ((noreturn));
3037 void
3038 fatal (/* @r{@dots{}} */)
3040   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3041   exit (1);
3043 @end group
3044 @end smallexample
3046 The @code{noreturn} keyword tells the compiler to assume that
3047 @code{fatal} cannot return.  It can then optimize without regard to what
3048 would happen if @code{fatal} ever did return.  This makes slightly
3049 better code.  More importantly, it helps avoid spurious warnings of
3050 uninitialized variables.
3052 The @code{noreturn} keyword does not affect the exceptional path when that
3053 applies: a @code{noreturn}-marked function may still return to the caller
3054 by throwing an exception or calling @code{longjmp}.
3056 Do not assume that registers saved by the calling function are
3057 restored before calling the @code{noreturn} function.
3059 It does not make sense for a @code{noreturn} function to have a return
3060 type other than @code{void}.
3062 @item nothrow
3063 @cindex @code{nothrow} function attribute
3064 The @code{nothrow} attribute is used to inform the compiler that a
3065 function cannot throw an exception.  For example, most functions in
3066 the standard C library can be guaranteed not to throw an exception
3067 with the notable exceptions of @code{qsort} and @code{bsearch} that
3068 take function pointer arguments.
3070 @item optimize
3071 @cindex @code{optimize} function attribute
3072 The @code{optimize} attribute is used to specify that a function is to
3073 be compiled with different optimization options than specified on the
3074 command line.  Arguments can either be numbers or strings.  Numbers
3075 are assumed to be an optimization level.  Strings that begin with
3076 @code{O} are assumed to be an optimization option, while other options
3077 are assumed to be used with a @code{-f} prefix.  You can also use the
3078 @samp{#pragma GCC optimize} pragma to set the optimization options
3079 that affect more than one function.
3080 @xref{Function Specific Option Pragmas}, for details about the
3081 @samp{#pragma GCC optimize} pragma.
3083 This attribute should be used for debugging purposes only.  It is not
3084 suitable in production code.
3086 @item pure
3087 @cindex @code{pure} function attribute
3088 @cindex functions that have no side effects
3089 Many functions have no effects except the return value and their
3090 return value depends only on the parameters and/or global variables.
3091 Such a function can be subject
3092 to common subexpression elimination and loop optimization just as an
3093 arithmetic operator would be.  These functions should be declared
3094 with the attribute @code{pure}.  For example,
3096 @smallexample
3097 int square (int) __attribute__ ((pure));
3098 @end smallexample
3100 @noindent
3101 says that the hypothetical function @code{square} is safe to call
3102 fewer times than the program says.
3104 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3105 Interesting non-pure functions are functions with infinite loops or those
3106 depending on volatile memory or other system resource, that may change between
3107 two consecutive calls (such as @code{feof} in a multithreading environment).
3109 @item returns_nonnull
3110 @cindex @code{returns_nonnull} function attribute
3111 The @code{returns_nonnull} attribute specifies that the function
3112 return value should be a non-null pointer.  For instance, the declaration:
3114 @smallexample
3115 extern void *
3116 mymalloc (size_t len) __attribute__((returns_nonnull));
3117 @end smallexample
3119 @noindent
3120 lets the compiler optimize callers based on the knowledge
3121 that the return value will never be null.
3123 @item returns_twice
3124 @cindex @code{returns_twice} function attribute
3125 @cindex functions that return more than once
3126 The @code{returns_twice} attribute tells the compiler that a function may
3127 return more than one time.  The compiler ensures that all registers
3128 are dead before calling such a function and emits a warning about
3129 the variables that may be clobbered after the second return from the
3130 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3131 The @code{longjmp}-like counterpart of such function, if any, might need
3132 to be marked with the @code{noreturn} attribute.
3134 @item section ("@var{section-name}")
3135 @cindex @code{section} function attribute
3136 @cindex functions in arbitrary sections
3137 Normally, the compiler places the code it generates in the @code{text} section.
3138 Sometimes, however, you need additional sections, or you need certain
3139 particular functions to appear in special sections.  The @code{section}
3140 attribute specifies that a function lives in a particular section.
3141 For example, the declaration:
3143 @smallexample
3144 extern void foobar (void) __attribute__ ((section ("bar")));
3145 @end smallexample
3147 @noindent
3148 puts the function @code{foobar} in the @code{bar} section.
3150 Some file formats do not support arbitrary sections so the @code{section}
3151 attribute is not available on all platforms.
3152 If you need to map the entire contents of a module to a particular
3153 section, consider using the facilities of the linker instead.
3155 @item sentinel
3156 @cindex @code{sentinel} function attribute
3157 This function attribute ensures that a parameter in a function call is
3158 an explicit @code{NULL}.  The attribute is only valid on variadic
3159 functions.  By default, the sentinel is located at position zero, the
3160 last parameter of the function call.  If an optional integer position
3161 argument P is supplied to the attribute, the sentinel must be located at
3162 position P counting backwards from the end of the argument list.
3164 @smallexample
3165 __attribute__ ((sentinel))
3166 is equivalent to
3167 __attribute__ ((sentinel(0)))
3168 @end smallexample
3170 The attribute is automatically set with a position of 0 for the built-in
3171 functions @code{execl} and @code{execlp}.  The built-in function
3172 @code{execle} has the attribute set with a position of 1.
3174 A valid @code{NULL} in this context is defined as zero with any pointer
3175 type.  If your system defines the @code{NULL} macro with an integer type
3176 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3177 with a copy that redefines NULL appropriately.
3179 The warnings for missing or incorrect sentinels are enabled with
3180 @option{-Wformat}.
3182 @item simd
3183 @itemx simd("@var{mask}")
3184 @cindex @code{simd} function attribute
3185 This attribute enables creation of one or more function versions that
3186 can process multiple arguments using SIMD instructions from a
3187 single invocation.  Specifying this attribute allows compiler to
3188 assume that such versions are available at link time (provided
3189 in the same or another translation unit).  Generated versions are
3190 target-dependent and described in the corresponding Vector ABI document.  For
3191 x86_64 target this document can be found
3192 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3194 The optional argument @var{mask} may have the value
3195 @code{notinbranch} or @code{inbranch},
3196 and instructs the compiler to generate non-masked or masked
3197 clones correspondingly. By default, all clones are generated.
3199 The attribute should not be used together with Cilk Plus @code{vector}
3200 attribute on the same function.
3202 If the attribute is specified and @code{#pragma omp declare simd} is
3203 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3204 switch is specified, then the attribute is ignored.
3206 @item stack_protect
3207 @cindex @code{stack_protect} function attribute
3208 This attribute adds stack protection code to the function if 
3209 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3210 or @option{-fstack-protector-explicit} are set.
3212 @item target (@var{options})
3213 @cindex @code{target} function attribute
3214 Multiple target back ends implement the @code{target} attribute
3215 to specify that a function is to
3216 be compiled with different target options than specified on the
3217 command line.  This can be used for instance to have functions
3218 compiled with a different ISA (instruction set architecture) than the
3219 default.  You can also use the @samp{#pragma GCC target} pragma to set
3220 more than one function to be compiled with specific target options.
3221 @xref{Function Specific Option Pragmas}, for details about the
3222 @samp{#pragma GCC target} pragma.
3224 For instance, on an x86, you could declare one function with the
3225 @code{target("sse4.1,arch=core2")} attribute and another with
3226 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3227 compiling the first function with @option{-msse4.1} and
3228 @option{-march=core2} options, and the second function with
3229 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3230 to make sure that a function is only invoked on a machine that
3231 supports the particular ISA it is compiled for (for example by using
3232 @code{cpuid} on x86 to determine what feature bits and architecture
3233 family are used).
3235 @smallexample
3236 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3237 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3238 @end smallexample
3240 You can either use multiple
3241 strings separated by commas to specify multiple options,
3242 or separate the options with a comma (@samp{,}) within a single string.
3244 The options supported are specific to each target; refer to @ref{x86
3245 Function Attributes}, @ref{PowerPC Function Attributes},
3246 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3247 for details.
3249 @item target_clones (@var{options})
3250 @cindex @code{target_clones} function attribute
3251 The @code{target_clones} attribute is used to specify that a function
3252 be cloned into multiple versions compiled with different target options
3253 than specified on the command line.  The supported options and restrictions
3254 are the same as for @code{target} attribute.
3256 For instance, on an x86, you could compile a function with
3257 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3258 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3259 It also creates a resolver function (see the @code{ifunc} attribute
3260 above) that dynamically selects a clone suitable for current
3261 architecture.
3263 On a PowerPC, you can compile a function with
3264 @code{target_clones("cpu=power9,default")}.  GCC will create two
3265 function clones, one compiled with @option{-mcpu=power9} and another
3266 with the default options.  It also creates a resolver function (see
3267 the @code{ifunc} attribute above) that dynamically selects a clone
3268 suitable for current architecture.
3270 @item unused
3271 @cindex @code{unused} function attribute
3272 This attribute, attached to a function, means that the function is meant
3273 to be possibly unused.  GCC does not produce a warning for this
3274 function.
3276 @item used
3277 @cindex @code{used} function attribute
3278 This attribute, attached to a function, means that code must be emitted
3279 for the function even if it appears that the function is not referenced.
3280 This is useful, for example, when the function is referenced only in
3281 inline assembly.
3283 When applied to a member function of a C++ class template, the
3284 attribute also means that the function is instantiated if the
3285 class itself is instantiated.
3287 @item visibility ("@var{visibility_type}")
3288 @cindex @code{visibility} function attribute
3289 This attribute affects the linkage of the declaration to which it is attached.
3290 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3291 (@pxref{Common Type Attributes}) as well as functions.
3293 There are four supported @var{visibility_type} values: default,
3294 hidden, protected or internal visibility.
3296 @smallexample
3297 void __attribute__ ((visibility ("protected")))
3298 f () @{ /* @r{Do something.} */; @}
3299 int i __attribute__ ((visibility ("hidden")));
3300 @end smallexample
3302 The possible values of @var{visibility_type} correspond to the
3303 visibility settings in the ELF gABI.
3305 @table @code
3306 @c keep this list of visibilities in alphabetical order.
3308 @item default
3309 Default visibility is the normal case for the object file format.
3310 This value is available for the visibility attribute to override other
3311 options that may change the assumed visibility of entities.
3313 On ELF, default visibility means that the declaration is visible to other
3314 modules and, in shared libraries, means that the declared entity may be
3315 overridden.
3317 On Darwin, default visibility means that the declaration is visible to
3318 other modules.
3320 Default visibility corresponds to ``external linkage'' in the language.
3322 @item hidden
3323 Hidden visibility indicates that the entity declared has a new
3324 form of linkage, which we call ``hidden linkage''.  Two
3325 declarations of an object with hidden linkage refer to the same object
3326 if they are in the same shared object.
3328 @item internal
3329 Internal visibility is like hidden visibility, but with additional
3330 processor specific semantics.  Unless otherwise specified by the
3331 psABI, GCC defines internal visibility to mean that a function is
3332 @emph{never} called from another module.  Compare this with hidden
3333 functions which, while they cannot be referenced directly by other
3334 modules, can be referenced indirectly via function pointers.  By
3335 indicating that a function cannot be called from outside the module,
3336 GCC may for instance omit the load of a PIC register since it is known
3337 that the calling function loaded the correct value.
3339 @item protected
3340 Protected visibility is like default visibility except that it
3341 indicates that references within the defining module bind to the
3342 definition in that module.  That is, the declared entity cannot be
3343 overridden by another module.
3345 @end table
3347 All visibilities are supported on many, but not all, ELF targets
3348 (supported when the assembler supports the @samp{.visibility}
3349 pseudo-op).  Default visibility is supported everywhere.  Hidden
3350 visibility is supported on Darwin targets.
3352 The visibility attribute should be applied only to declarations that
3353 would otherwise have external linkage.  The attribute should be applied
3354 consistently, so that the same entity should not be declared with
3355 different settings of the attribute.
3357 In C++, the visibility attribute applies to types as well as functions
3358 and objects, because in C++ types have linkage.  A class must not have
3359 greater visibility than its non-static data member types and bases,
3360 and class members default to the visibility of their class.  Also, a
3361 declaration without explicit visibility is limited to the visibility
3362 of its type.
3364 In C++, you can mark member functions and static member variables of a
3365 class with the visibility attribute.  This is useful if you know a
3366 particular method or static member variable should only be used from
3367 one shared object; then you can mark it hidden while the rest of the
3368 class has default visibility.  Care must be taken to avoid breaking
3369 the One Definition Rule; for example, it is usually not useful to mark
3370 an inline method as hidden without marking the whole class as hidden.
3372 A C++ namespace declaration can also have the visibility attribute.
3374 @smallexample
3375 namespace nspace1 __attribute__ ((visibility ("protected")))
3376 @{ /* @r{Do something.} */; @}
3377 @end smallexample
3379 This attribute applies only to the particular namespace body, not to
3380 other definitions of the same namespace; it is equivalent to using
3381 @samp{#pragma GCC visibility} before and after the namespace
3382 definition (@pxref{Visibility Pragmas}).
3384 In C++, if a template argument has limited visibility, this
3385 restriction is implicitly propagated to the template instantiation.
3386 Otherwise, template instantiations and specializations default to the
3387 visibility of their template.
3389 If both the template and enclosing class have explicit visibility, the
3390 visibility from the template is used.
3392 @item warn_unused_result
3393 @cindex @code{warn_unused_result} function attribute
3394 The @code{warn_unused_result} attribute causes a warning to be emitted
3395 if a caller of the function with this attribute does not use its
3396 return value.  This is useful for functions where not checking
3397 the result is either a security problem or always a bug, such as
3398 @code{realloc}.
3400 @smallexample
3401 int fn () __attribute__ ((warn_unused_result));
3402 int foo ()
3404   if (fn () < 0) return -1;
3405   fn ();
3406   return 0;
3408 @end smallexample
3410 @noindent
3411 results in warning on line 5.
3413 @item weak
3414 @cindex @code{weak} function attribute
3415 The @code{weak} attribute causes the declaration to be emitted as a weak
3416 symbol rather than a global.  This is primarily useful in defining
3417 library functions that can be overridden in user code, though it can
3418 also be used with non-function declarations.  Weak symbols are supported
3419 for ELF targets, and also for a.out targets when using the GNU assembler
3420 and linker.
3422 @item weakref
3423 @itemx weakref ("@var{target}")
3424 @cindex @code{weakref} function attribute
3425 The @code{weakref} attribute marks a declaration as a weak reference.
3426 Without arguments, it should be accompanied by an @code{alias} attribute
3427 naming the target symbol.  Optionally, the @var{target} may be given as
3428 an argument to @code{weakref} itself.  In either case, @code{weakref}
3429 implicitly marks the declaration as @code{weak}.  Without a
3430 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3431 @code{weakref} is equivalent to @code{weak}.
3433 @smallexample
3434 static int x() __attribute__ ((weakref ("y")));
3435 /* is equivalent to... */
3436 static int x() __attribute__ ((weak, weakref, alias ("y")));
3437 /* and to... */
3438 static int x() __attribute__ ((weakref));
3439 static int x() __attribute__ ((alias ("y")));
3440 @end smallexample
3442 A weak reference is an alias that does not by itself require a
3443 definition to be given for the target symbol.  If the target symbol is
3444 only referenced through weak references, then it becomes a @code{weak}
3445 undefined symbol.  If it is directly referenced, however, then such
3446 strong references prevail, and a definition is required for the
3447 symbol, not necessarily in the same translation unit.
3449 The effect is equivalent to moving all references to the alias to a
3450 separate translation unit, renaming the alias to the aliased symbol,
3451 declaring it as weak, compiling the two separate translation units and
3452 performing a reloadable link on them.
3454 At present, a declaration to which @code{weakref} is attached can
3455 only be @code{static}.
3458 @end table
3460 @c This is the end of the target-independent attribute table
3462 @node AArch64 Function Attributes
3463 @subsection AArch64 Function Attributes
3465 The following target-specific function attributes are available for the
3466 AArch64 target.  For the most part, these options mirror the behavior of
3467 similar command-line options (@pxref{AArch64 Options}), but on a
3468 per-function basis.
3470 @table @code
3471 @item general-regs-only
3472 @cindex @code{general-regs-only} function attribute, AArch64
3473 Indicates that no floating-point or Advanced SIMD registers should be
3474 used when generating code for this function.  If the function explicitly
3475 uses floating-point code, then the compiler gives an error.  This is
3476 the same behavior as that of the command-line option
3477 @option{-mgeneral-regs-only}.
3479 @item fix-cortex-a53-835769
3480 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3481 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3482 applied to this function.  To explicitly disable the workaround for this
3483 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3484 This corresponds to the behavior of the command line options
3485 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3487 @item cmodel=
3488 @cindex @code{cmodel=} function attribute, AArch64
3489 Indicates that code should be generated for a particular code model for
3490 this function.  The behavior and permissible arguments are the same as
3491 for the command line option @option{-mcmodel=}.
3493 @item strict-align
3494 @cindex @code{strict-align} function attribute, AArch64
3495 Indicates that the compiler should not assume that unaligned memory references
3496 are handled by the system.  The behavior is the same as for the command-line
3497 option @option{-mstrict-align}.
3499 @item omit-leaf-frame-pointer
3500 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3501 Indicates that the frame pointer should be omitted for a leaf function call.
3502 To keep the frame pointer, the inverse attribute
3503 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3504 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3505 and @option{-mno-omit-leaf-frame-pointer}.
3507 @item tls-dialect=
3508 @cindex @code{tls-dialect=} function attribute, AArch64
3509 Specifies the TLS dialect to use for this function.  The behavior and
3510 permissible arguments are the same as for the command-line option
3511 @option{-mtls-dialect=}.
3513 @item arch=
3514 @cindex @code{arch=} function attribute, AArch64
3515 Specifies the architecture version and architectural extensions to use
3516 for this function.  The behavior and permissible arguments are the same as
3517 for the @option{-march=} command-line option.
3519 @item tune=
3520 @cindex @code{tune=} function attribute, AArch64
3521 Specifies the core for which to tune the performance of this function.
3522 The behavior and permissible arguments are the same as for the @option{-mtune=}
3523 command-line option.
3525 @item cpu=
3526 @cindex @code{cpu=} function attribute, AArch64
3527 Specifies the core for which to tune the performance of this function and also
3528 whose architectural features to use.  The behavior and valid arguments are the
3529 same as for the @option{-mcpu=} command-line option.
3531 @item sign-return-address
3532 @cindex @code{sign-return-address} function attribute, AArch64
3533 Select the function scope on which return address signing will be applied.  The
3534 behavior and permissible arguments are the same as for the command-line option
3535 @option{-msign-return-address=}.  The default value is @code{none}.
3537 @end table
3539 The above target attributes can be specified as follows:
3541 @smallexample
3542 __attribute__((target("@var{attr-string}")))
3544 f (int a)
3546   return a + 5;
3548 @end smallexample
3550 where @code{@var{attr-string}} is one of the attribute strings specified above.
3552 Additionally, the architectural extension string may be specified on its
3553 own.  This can be used to turn on and off particular architectural extensions
3554 without having to specify a particular architecture version or core.  Example:
3556 @smallexample
3557 __attribute__((target("+crc+nocrypto")))
3559 foo (int a)
3561   return a + 5;
3563 @end smallexample
3565 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3566 extension and disables the @code{crypto} extension for the function @code{foo}
3567 without modifying an existing @option{-march=} or @option{-mcpu} option.
3569 Multiple target function attributes can be specified by separating them with
3570 a comma.  For example:
3571 @smallexample
3572 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3574 foo (int a)
3576   return a + 5;
3578 @end smallexample
3580 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3581 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3583 @subsubsection Inlining rules
3584 Specifying target attributes on individual functions or performing link-time
3585 optimization across translation units compiled with different target options
3586 can affect function inlining rules:
3588 In particular, a caller function can inline a callee function only if the
3589 architectural features available to the callee are a subset of the features
3590 available to the caller.
3591 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3592 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3593 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3594 because the all the architectural features that function @code{bar} requires
3595 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3596 inline function @code{foo}.
3598 Additionally inlining a function compiled with @option{-mstrict-align} into a
3599 function compiled without @code{-mstrict-align} is not allowed.
3600 However, inlining a function compiled without @option{-mstrict-align} into a
3601 function compiled with @option{-mstrict-align} is allowed.
3603 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3604 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3605 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3606 architectural feature rules specified above.
3608 @node ARC Function Attributes
3609 @subsection ARC Function Attributes
3611 These function attributes are supported by the ARC back end:
3613 @table @code
3614 @item interrupt
3615 @cindex @code{interrupt} function attribute, ARC
3616 Use this attribute to indicate
3617 that the specified function is an interrupt handler.  The compiler generates
3618 function entry and exit sequences suitable for use in an interrupt handler
3619 when this attribute is present.
3621 On the ARC, you must specify the kind of interrupt to be handled
3622 in a parameter to the interrupt attribute like this:
3624 @smallexample
3625 void f () __attribute__ ((interrupt ("ilink1")));
3626 @end smallexample
3628 Permissible values for this parameter are: @w{@code{ilink1}} and
3629 @w{@code{ilink2}}.
3631 @item long_call
3632 @itemx medium_call
3633 @itemx short_call
3634 @cindex @code{long_call} function attribute, ARC
3635 @cindex @code{medium_call} function attribute, ARC
3636 @cindex @code{short_call} function attribute, ARC
3637 @cindex indirect calls, ARC
3638 These attributes specify how a particular function is called.
3639 These attributes override the
3640 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3641 command-line switches and @code{#pragma long_calls} settings.
3643 For ARC, a function marked with the @code{long_call} attribute is
3644 always called using register-indirect jump-and-link instructions,
3645 thereby enabling the called function to be placed anywhere within the
3646 32-bit address space.  A function marked with the @code{medium_call}
3647 attribute will always be close enough to be called with an unconditional
3648 branch-and-link instruction, which has a 25-bit offset from
3649 the call site.  A function marked with the @code{short_call}
3650 attribute will always be close enough to be called with a conditional
3651 branch-and-link instruction, which has a 21-bit offset from
3652 the call site.
3653 @end table
3655 @node ARM Function Attributes
3656 @subsection ARM Function Attributes
3658 These function attributes are supported for ARM targets:
3660 @table @code
3661 @item interrupt
3662 @cindex @code{interrupt} function attribute, ARM
3663 Use this attribute to indicate
3664 that the specified function is an interrupt handler.  The compiler generates
3665 function entry and exit sequences suitable for use in an interrupt handler
3666 when this attribute is present.
3668 You can specify the kind of interrupt to be handled by
3669 adding an optional parameter to the interrupt attribute like this:
3671 @smallexample
3672 void f () __attribute__ ((interrupt ("IRQ")));
3673 @end smallexample
3675 @noindent
3676 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3677 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3679 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3680 may be called with a word-aligned stack pointer.
3682 @item isr
3683 @cindex @code{isr} function attribute, ARM
3684 Use this attribute on ARM to write Interrupt Service Routines. This is an
3685 alias to the @code{interrupt} attribute above.
3687 @item long_call
3688 @itemx short_call
3689 @cindex @code{long_call} function attribute, ARM
3690 @cindex @code{short_call} function attribute, ARM
3691 @cindex indirect calls, ARM
3692 These attributes specify how a particular function is called.
3693 These attributes override the
3694 @option{-mlong-calls} (@pxref{ARM Options})
3695 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3696 @code{long_call} attribute indicates that the function might be far
3697 away from the call site and require a different (more expensive)
3698 calling sequence.   The @code{short_call} attribute always places
3699 the offset to the function from the call site into the @samp{BL}
3700 instruction directly.
3702 @item naked
3703 @cindex @code{naked} function attribute, ARM
3704 This attribute allows the compiler to construct the
3705 requisite function declaration, while allowing the body of the
3706 function to be assembly code. The specified function will not have
3707 prologue/epilogue sequences generated by the compiler. Only basic
3708 @code{asm} statements can safely be included in naked functions
3709 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3710 basic @code{asm} and C code may appear to work, they cannot be
3711 depended upon to work reliably and are not supported.
3713 @item pcs
3714 @cindex @code{pcs} function attribute, ARM
3716 The @code{pcs} attribute can be used to control the calling convention
3717 used for a function on ARM.  The attribute takes an argument that specifies
3718 the calling convention to use.
3720 When compiling using the AAPCS ABI (or a variant of it) then valid
3721 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3722 order to use a variant other than @code{"aapcs"} then the compiler must
3723 be permitted to use the appropriate co-processor registers (i.e., the
3724 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3725 For example,
3727 @smallexample
3728 /* Argument passed in r0, and result returned in r0+r1.  */
3729 double f2d (float) __attribute__((pcs("aapcs")));
3730 @end smallexample
3732 Variadic functions always use the @code{"aapcs"} calling convention and
3733 the compiler rejects attempts to specify an alternative.
3735 @item target (@var{options})
3736 @cindex @code{target} function attribute
3737 As discussed in @ref{Common Function Attributes}, this attribute 
3738 allows specification of target-specific compilation options.
3740 On ARM, the following options are allowed:
3742 @table @samp
3743 @item thumb
3744 @cindex @code{target("thumb")} function attribute, ARM
3745 Force code generation in the Thumb (T16/T32) ISA, depending on the
3746 architecture level.
3748 @item arm
3749 @cindex @code{target("arm")} function attribute, ARM
3750 Force code generation in the ARM (A32) ISA.
3752 Functions from different modes can be inlined in the caller's mode.
3754 @item fpu=
3755 @cindex @code{target("fpu=")} function attribute, ARM
3756 Specifies the fpu for which to tune the performance of this function.
3757 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3758 command-line option.
3760 @end table
3762 @end table
3764 @node AVR Function Attributes
3765 @subsection AVR Function Attributes
3767 These function attributes are supported by the AVR back end:
3769 @table @code
3770 @item interrupt
3771 @cindex @code{interrupt} function attribute, AVR
3772 Use this attribute to indicate
3773 that the specified function is an interrupt handler.  The compiler generates
3774 function entry and exit sequences suitable for use in an interrupt handler
3775 when this attribute is present.
3777 On the AVR, the hardware globally disables interrupts when an
3778 interrupt is executed.  The first instruction of an interrupt handler
3779 declared with this attribute is a @code{SEI} instruction to
3780 re-enable interrupts.  See also the @code{signal} function attribute
3781 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3782 @code{interrupt} are specified for the same function, @code{signal}
3783 is silently ignored.
3785 @item naked
3786 @cindex @code{naked} function attribute, AVR
3787 This attribute allows the compiler to construct the
3788 requisite function declaration, while allowing the body of the
3789 function to be assembly code. The specified function will not have
3790 prologue/epilogue sequences generated by the compiler. Only basic
3791 @code{asm} statements can safely be included in naked functions
3792 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3793 basic @code{asm} and C code may appear to work, they cannot be
3794 depended upon to work reliably and are not supported.
3796 @item OS_main
3797 @itemx OS_task
3798 @cindex @code{OS_main} function attribute, AVR
3799 @cindex @code{OS_task} function attribute, AVR
3800 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3801 do not save/restore any call-saved register in their prologue/epilogue.
3803 The @code{OS_main} attribute can be used when there @emph{is
3804 guarantee} that interrupts are disabled at the time when the function
3805 is entered.  This saves resources when the stack pointer has to be
3806 changed to set up a frame for local variables.
3808 The @code{OS_task} attribute can be used when there is @emph{no
3809 guarantee} that interrupts are disabled at that time when the function
3810 is entered like for, e@.g@. task functions in a multi-threading operating
3811 system. In that case, changing the stack pointer register is
3812 guarded by save/clear/restore of the global interrupt enable flag.
3814 The differences to the @code{naked} function attribute are:
3815 @itemize @bullet
3816 @item @code{naked} functions do not have a return instruction whereas 
3817 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3818 @code{RETI} return instruction.
3819 @item @code{naked} functions do not set up a frame for local variables
3820 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3821 as needed.
3822 @end itemize
3824 @item signal
3825 @cindex @code{signal} function attribute, AVR
3826 Use this attribute on the AVR to indicate that the specified
3827 function is an interrupt handler.  The compiler generates function
3828 entry and exit sequences suitable for use in an interrupt handler when this
3829 attribute is present.
3831 See also the @code{interrupt} function attribute. 
3833 The AVR hardware globally disables interrupts when an interrupt is executed.
3834 Interrupt handler functions defined with the @code{signal} attribute
3835 do not re-enable interrupts.  It is save to enable interrupts in a
3836 @code{signal} handler.  This ``save'' only applies to the code
3837 generated by the compiler and not to the IRQ layout of the
3838 application which is responsibility of the application.
3840 If both @code{signal} and @code{interrupt} are specified for the same
3841 function, @code{signal} is silently ignored.
3842 @end table
3844 @node Blackfin Function Attributes
3845 @subsection Blackfin Function Attributes
3847 These function attributes are supported by the Blackfin back end:
3849 @table @code
3851 @item exception_handler
3852 @cindex @code{exception_handler} function attribute
3853 @cindex exception handler functions, Blackfin
3854 Use this attribute on the Blackfin to indicate that the specified function
3855 is an exception handler.  The compiler generates function entry and
3856 exit sequences suitable for use in an exception handler when this
3857 attribute is present.
3859 @item interrupt_handler
3860 @cindex @code{interrupt_handler} function attribute, Blackfin
3861 Use this attribute to
3862 indicate that the specified function is an interrupt handler.  The compiler
3863 generates function entry and exit sequences suitable for use in an
3864 interrupt handler when this attribute is present.
3866 @item kspisusp
3867 @cindex @code{kspisusp} function attribute, Blackfin
3868 @cindex User stack pointer in interrupts on the Blackfin
3869 When used together with @code{interrupt_handler}, @code{exception_handler}
3870 or @code{nmi_handler}, code is generated to load the stack pointer
3871 from the USP register in the function prologue.
3873 @item l1_text
3874 @cindex @code{l1_text} function attribute, Blackfin
3875 This attribute specifies a function to be placed into L1 Instruction
3876 SRAM@. The function is put into a specific section named @code{.l1.text}.
3877 With @option{-mfdpic}, function calls with a such function as the callee
3878 or caller uses inlined PLT.
3880 @item l2
3881 @cindex @code{l2} function attribute, Blackfin
3882 This attribute specifies a function to be placed into L2
3883 SRAM. The function is put into a specific section named
3884 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3885 an inlined PLT.
3887 @item longcall
3888 @itemx shortcall
3889 @cindex indirect calls, Blackfin
3890 @cindex @code{longcall} function attribute, Blackfin
3891 @cindex @code{shortcall} function attribute, Blackfin
3892 The @code{longcall} attribute
3893 indicates that the function might be far away from the call site and
3894 require a different (more expensive) calling sequence.  The
3895 @code{shortcall} attribute indicates that the function is always close
3896 enough for the shorter calling sequence to be used.  These attributes
3897 override the @option{-mlongcall} switch.
3899 @item nesting
3900 @cindex @code{nesting} function attribute, Blackfin
3901 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3902 Use this attribute together with @code{interrupt_handler},
3903 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3904 entry code should enable nested interrupts or exceptions.
3906 @item nmi_handler
3907 @cindex @code{nmi_handler} function attribute, Blackfin
3908 @cindex NMI handler functions on the Blackfin processor
3909 Use this attribute on the Blackfin to indicate that the specified function
3910 is an NMI handler.  The compiler generates function entry and
3911 exit sequences suitable for use in an NMI handler when this
3912 attribute is present.
3914 @item saveall
3915 @cindex @code{saveall} function attribute, Blackfin
3916 @cindex save all registers on the Blackfin
3917 Use this attribute to indicate that
3918 all registers except the stack pointer should be saved in the prologue
3919 regardless of whether they are used or not.
3920 @end table
3922 @node CR16 Function Attributes
3923 @subsection CR16 Function Attributes
3925 These function attributes are supported by the CR16 back end:
3927 @table @code
3928 @item interrupt
3929 @cindex @code{interrupt} function attribute, CR16
3930 Use this attribute to indicate
3931 that the specified function is an interrupt handler.  The compiler generates
3932 function entry and exit sequences suitable for use in an interrupt handler
3933 when this attribute is present.
3934 @end table
3936 @node Epiphany Function Attributes
3937 @subsection Epiphany Function Attributes
3939 These function attributes are supported by the Epiphany back end:
3941 @table @code
3942 @item disinterrupt
3943 @cindex @code{disinterrupt} function attribute, Epiphany
3944 This attribute causes the compiler to emit
3945 instructions to disable interrupts for the duration of the given
3946 function.
3948 @item forwarder_section
3949 @cindex @code{forwarder_section} function attribute, Epiphany
3950 This attribute modifies the behavior of an interrupt handler.
3951 The interrupt handler may be in external memory which cannot be
3952 reached by a branch instruction, so generate a local memory trampoline
3953 to transfer control.  The single parameter identifies the section where
3954 the trampoline is placed.
3956 @item interrupt
3957 @cindex @code{interrupt} function attribute, Epiphany
3958 Use this attribute to indicate
3959 that the specified function is an interrupt handler.  The compiler generates
3960 function entry and exit sequences suitable for use in an interrupt handler
3961 when this attribute is present.  It may also generate
3962 a special section with code to initialize the interrupt vector table.
3964 On Epiphany targets one or more optional parameters can be added like this:
3966 @smallexample
3967 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3968 @end smallexample
3970 Permissible values for these parameters are: @w{@code{reset}},
3971 @w{@code{software_exception}}, @w{@code{page_miss}},
3972 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3973 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3974 Multiple parameters indicate that multiple entries in the interrupt
3975 vector table should be initialized for this function, i.e.@: for each
3976 parameter @w{@var{name}}, a jump to the function is emitted in
3977 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3978 entirely, in which case no interrupt vector table entry is provided.
3980 Note that interrupts are enabled inside the function
3981 unless the @code{disinterrupt} attribute is also specified.
3983 The following examples are all valid uses of these attributes on
3984 Epiphany targets:
3985 @smallexample
3986 void __attribute__ ((interrupt)) universal_handler ();
3987 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3988 void __attribute__ ((interrupt ("dma0, dma1"))) 
3989   universal_dma_handler ();
3990 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3991   fast_timer_handler ();
3992 void __attribute__ ((interrupt ("dma0, dma1"), 
3993                      forwarder_section ("tramp")))
3994   external_dma_handler ();
3995 @end smallexample
3997 @item long_call
3998 @itemx short_call
3999 @cindex @code{long_call} function attribute, Epiphany
4000 @cindex @code{short_call} function attribute, Epiphany
4001 @cindex indirect calls, Epiphany
4002 These attributes specify how a particular function is called.
4003 These attributes override the
4004 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4005 command-line switch and @code{#pragma long_calls} settings.
4006 @end table
4009 @node H8/300 Function Attributes
4010 @subsection H8/300 Function Attributes
4012 These function attributes are available for H8/300 targets:
4014 @table @code
4015 @item function_vector
4016 @cindex @code{function_vector} function attribute, H8/300
4017 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4018 that the specified function should be called through the function vector.
4019 Calling a function through the function vector reduces code size; however,
4020 the function vector has a limited size (maximum 128 entries on the H8/300
4021 and 64 entries on the H8/300H and H8S)
4022 and shares space with the interrupt vector.
4024 @item interrupt_handler
4025 @cindex @code{interrupt_handler} function attribute, H8/300
4026 Use this attribute on the H8/300, H8/300H, and H8S to
4027 indicate that the specified function is an interrupt handler.  The compiler
4028 generates function entry and exit sequences suitable for use in an
4029 interrupt handler when this attribute is present.
4031 @item saveall
4032 @cindex @code{saveall} function attribute, H8/300
4033 @cindex save all registers on the H8/300, H8/300H, and H8S
4034 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4035 all registers except the stack pointer should be saved in the prologue
4036 regardless of whether they are used or not.
4037 @end table
4039 @node IA-64 Function Attributes
4040 @subsection IA-64 Function Attributes
4042 These function attributes are supported on IA-64 targets:
4044 @table @code
4045 @item syscall_linkage
4046 @cindex @code{syscall_linkage} function attribute, IA-64
4047 This attribute is used to modify the IA-64 calling convention by marking
4048 all input registers as live at all function exits.  This makes it possible
4049 to restart a system call after an interrupt without having to save/restore
4050 the input registers.  This also prevents kernel data from leaking into
4051 application code.
4053 @item version_id
4054 @cindex @code{version_id} function attribute, IA-64
4055 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4056 symbol to contain a version string, thus allowing for function level
4057 versioning.  HP-UX system header files may use function level versioning
4058 for some system calls.
4060 @smallexample
4061 extern int foo () __attribute__((version_id ("20040821")));
4062 @end smallexample
4064 @noindent
4065 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4066 @end table
4068 @node M32C Function Attributes
4069 @subsection M32C Function Attributes
4071 These function attributes are supported by the M32C back end:
4073 @table @code
4074 @item bank_switch
4075 @cindex @code{bank_switch} function attribute, M32C
4076 When added to an interrupt handler with the M32C port, causes the
4077 prologue and epilogue to use bank switching to preserve the registers
4078 rather than saving them on the stack.
4080 @item fast_interrupt
4081 @cindex @code{fast_interrupt} function attribute, M32C
4082 Use this attribute on the M32C port to indicate that the specified
4083 function is a fast interrupt handler.  This is just like the
4084 @code{interrupt} attribute, except that @code{freit} is used to return
4085 instead of @code{reit}.
4087 @item function_vector
4088 @cindex @code{function_vector} function attribute, M16C/M32C
4089 On M16C/M32C targets, the @code{function_vector} attribute declares a
4090 special page subroutine call function. Use of this attribute reduces
4091 the code size by 2 bytes for each call generated to the
4092 subroutine. The argument to the attribute is the vector number entry
4093 from the special page vector table which contains the 16 low-order
4094 bits of the subroutine's entry address. Each vector table has special
4095 page number (18 to 255) that is used in @code{jsrs} instructions.
4096 Jump addresses of the routines are generated by adding 0x0F0000 (in
4097 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4098 2-byte addresses set in the vector table. Therefore you need to ensure
4099 that all the special page vector routines should get mapped within the
4100 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4101 (for M32C).
4103 In the following example 2 bytes are saved for each call to
4104 function @code{foo}.
4106 @smallexample
4107 void foo (void) __attribute__((function_vector(0x18)));
4108 void foo (void)
4112 void bar (void)
4114     foo();
4116 @end smallexample
4118 If functions are defined in one file and are called in another file,
4119 then be sure to write this declaration in both files.
4121 This attribute is ignored for R8C target.
4123 @item interrupt
4124 @cindex @code{interrupt} function attribute, M32C
4125 Use this attribute to indicate
4126 that the specified function is an interrupt handler.  The compiler generates
4127 function entry and exit sequences suitable for use in an interrupt handler
4128 when this attribute is present.
4129 @end table
4131 @node M32R/D Function Attributes
4132 @subsection M32R/D Function Attributes
4134 These function attributes are supported by the M32R/D back end:
4136 @table @code
4137 @item interrupt
4138 @cindex @code{interrupt} function attribute, M32R/D
4139 Use this attribute to indicate
4140 that the specified function is an interrupt handler.  The compiler generates
4141 function entry and exit sequences suitable for use in an interrupt handler
4142 when this attribute is present.
4144 @item model (@var{model-name})
4145 @cindex @code{model} function attribute, M32R/D
4146 @cindex function addressability on the M32R/D
4148 On the M32R/D, use this attribute to set the addressability of an
4149 object, and of the code generated for a function.  The identifier
4150 @var{model-name} is one of @code{small}, @code{medium}, or
4151 @code{large}, representing each of the code models.
4153 Small model objects live in the lower 16MB of memory (so that their
4154 addresses can be loaded with the @code{ld24} instruction), and are
4155 callable with the @code{bl} instruction.
4157 Medium model objects may live anywhere in the 32-bit address space (the
4158 compiler generates @code{seth/add3} instructions to load their addresses),
4159 and are callable with the @code{bl} instruction.
4161 Large model objects may live anywhere in the 32-bit address space (the
4162 compiler generates @code{seth/add3} instructions to load their addresses),
4163 and may not be reachable with the @code{bl} instruction (the compiler
4164 generates the much slower @code{seth/add3/jl} instruction sequence).
4165 @end table
4167 @node m68k Function Attributes
4168 @subsection m68k Function Attributes
4170 These function attributes are supported by the m68k back end:
4172 @table @code
4173 @item interrupt
4174 @itemx interrupt_handler
4175 @cindex @code{interrupt} function attribute, m68k
4176 @cindex @code{interrupt_handler} function attribute, m68k
4177 Use this attribute to
4178 indicate that the specified function is an interrupt handler.  The compiler
4179 generates function entry and exit sequences suitable for use in an
4180 interrupt handler when this attribute is present.  Either name may be used.
4182 @item interrupt_thread
4183 @cindex @code{interrupt_thread} function attribute, fido
4184 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4185 that the specified function is an interrupt handler that is designed
4186 to run as a thread.  The compiler omits generate prologue/epilogue
4187 sequences and replaces the return instruction with a @code{sleep}
4188 instruction.  This attribute is available only on fido.
4189 @end table
4191 @node MCORE Function Attributes
4192 @subsection MCORE Function Attributes
4194 These function attributes are supported by the MCORE back end:
4196 @table @code
4197 @item naked
4198 @cindex @code{naked} function attribute, MCORE
4199 This attribute allows the compiler to construct the
4200 requisite function declaration, while allowing the body of the
4201 function to be assembly code. The specified function will not have
4202 prologue/epilogue sequences generated by the compiler. Only basic
4203 @code{asm} statements can safely be included in naked functions
4204 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4205 basic @code{asm} and C code may appear to work, they cannot be
4206 depended upon to work reliably and are not supported.
4207 @end table
4209 @node MeP Function Attributes
4210 @subsection MeP Function Attributes
4212 These function attributes are supported by the MeP back end:
4214 @table @code
4215 @item disinterrupt
4216 @cindex @code{disinterrupt} function attribute, MeP
4217 On MeP targets, this attribute causes the compiler to emit
4218 instructions to disable interrupts for the duration of the given
4219 function.
4221 @item interrupt
4222 @cindex @code{interrupt} function attribute, MeP
4223 Use this attribute to indicate
4224 that the specified function is an interrupt handler.  The compiler generates
4225 function entry and exit sequences suitable for use in an interrupt handler
4226 when this attribute is present.
4228 @item near
4229 @cindex @code{near} function attribute, MeP
4230 This attribute causes the compiler to assume the called
4231 function is close enough to use the normal calling convention,
4232 overriding the @option{-mtf} command-line option.
4234 @item far
4235 @cindex @code{far} function attribute, MeP
4236 On MeP targets this causes the compiler to use a calling convention
4237 that assumes the called function is too far away for the built-in
4238 addressing modes.
4240 @item vliw
4241 @cindex @code{vliw} function attribute, MeP
4242 The @code{vliw} attribute tells the compiler to emit
4243 instructions in VLIW mode instead of core mode.  Note that this
4244 attribute is not allowed unless a VLIW coprocessor has been configured
4245 and enabled through command-line options.
4246 @end table
4248 @node MicroBlaze Function Attributes
4249 @subsection MicroBlaze Function Attributes
4251 These function attributes are supported on MicroBlaze targets:
4253 @table @code
4254 @item save_volatiles
4255 @cindex @code{save_volatiles} function attribute, MicroBlaze
4256 Use this attribute to indicate that the function is
4257 an interrupt handler.  All volatile registers (in addition to non-volatile
4258 registers) are saved in the function prologue.  If the function is a leaf
4259 function, only volatiles used by the function are saved.  A normal function
4260 return is generated instead of a return from interrupt.
4262 @item break_handler
4263 @cindex @code{break_handler} function attribute, MicroBlaze
4264 @cindex break handler functions
4265 Use this attribute to indicate that
4266 the specified function is a break handler.  The compiler generates function
4267 entry and exit sequences suitable for use in an break handler when this
4268 attribute is present. The return from @code{break_handler} is done through
4269 the @code{rtbd} instead of @code{rtsd}.
4271 @smallexample
4272 void f () __attribute__ ((break_handler));
4273 @end smallexample
4275 @item interrupt_handler
4276 @itemx fast_interrupt 
4277 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4278 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4279 These attributes indicate that the specified function is an interrupt
4280 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4281 used in low-latency interrupt mode, and @code{interrupt_handler} for
4282 interrupts that do not use low-latency handlers.  In both cases, GCC
4283 emits appropriate prologue code and generates a return from the handler
4284 using @code{rtid} instead of @code{rtsd}.
4285 @end table
4287 @node Microsoft Windows Function Attributes
4288 @subsection Microsoft Windows Function Attributes
4290 The following attributes are available on Microsoft Windows and Symbian OS
4291 targets.
4293 @table @code
4294 @item dllexport
4295 @cindex @code{dllexport} function attribute
4296 @cindex @code{__declspec(dllexport)}
4297 On Microsoft Windows targets and Symbian OS targets the
4298 @code{dllexport} attribute causes the compiler to provide a global
4299 pointer to a pointer in a DLL, so that it can be referenced with the
4300 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4301 name is formed by combining @code{_imp__} and the function or variable
4302 name.
4304 You can use @code{__declspec(dllexport)} as a synonym for
4305 @code{__attribute__ ((dllexport))} for compatibility with other
4306 compilers.
4308 On systems that support the @code{visibility} attribute, this
4309 attribute also implies ``default'' visibility.  It is an error to
4310 explicitly specify any other visibility.
4312 GCC's default behavior is to emit all inline functions with the
4313 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4314 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4315 ignore the attribute for inlined functions unless the 
4316 @option{-fkeep-inline-functions} flag is used instead.
4318 The attribute is ignored for undefined symbols.
4320 When applied to C++ classes, the attribute marks defined non-inlined
4321 member functions and static data members as exports.  Static consts
4322 initialized in-class are not marked unless they are also defined
4323 out-of-class.
4325 For Microsoft Windows targets there are alternative methods for
4326 including the symbol in the DLL's export table such as using a
4327 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4328 the @option{--export-all} linker flag.
4330 @item dllimport
4331 @cindex @code{dllimport} function attribute
4332 @cindex @code{__declspec(dllimport)}
4333 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4334 attribute causes the compiler to reference a function or variable via
4335 a global pointer to a pointer that is set up by the DLL exporting the
4336 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4337 targets, the pointer name is formed by combining @code{_imp__} and the
4338 function or variable name.
4340 You can use @code{__declspec(dllimport)} as a synonym for
4341 @code{__attribute__ ((dllimport))} for compatibility with other
4342 compilers.
4344 On systems that support the @code{visibility} attribute, this
4345 attribute also implies ``default'' visibility.  It is an error to
4346 explicitly specify any other visibility.
4348 Currently, the attribute is ignored for inlined functions.  If the
4349 attribute is applied to a symbol @emph{definition}, an error is reported.
4350 If a symbol previously declared @code{dllimport} is later defined, the
4351 attribute is ignored in subsequent references, and a warning is emitted.
4352 The attribute is also overridden by a subsequent declaration as
4353 @code{dllexport}.
4355 When applied to C++ classes, the attribute marks non-inlined
4356 member functions and static data members as imports.  However, the
4357 attribute is ignored for virtual methods to allow creation of vtables
4358 using thunks.
4360 On the SH Symbian OS target the @code{dllimport} attribute also has
4361 another affect---it can cause the vtable and run-time type information
4362 for a class to be exported.  This happens when the class has a
4363 dllimported constructor or a non-inline, non-pure virtual function
4364 and, for either of those two conditions, the class also has an inline
4365 constructor or destructor and has a key function that is defined in
4366 the current translation unit.
4368 For Microsoft Windows targets the use of the @code{dllimport}
4369 attribute on functions is not necessary, but provides a small
4370 performance benefit by eliminating a thunk in the DLL@.  The use of the
4371 @code{dllimport} attribute on imported variables can be avoided by passing the
4372 @option{--enable-auto-import} switch to the GNU linker.  As with
4373 functions, using the attribute for a variable eliminates a thunk in
4374 the DLL@.
4376 One drawback to using this attribute is that a pointer to a
4377 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4378 address. However, a pointer to a @emph{function} with the
4379 @code{dllimport} attribute can be used as a constant initializer; in
4380 this case, the address of a stub function in the import lib is
4381 referenced.  On Microsoft Windows targets, the attribute can be disabled
4382 for functions by setting the @option{-mnop-fun-dllimport} flag.
4383 @end table
4385 @node MIPS Function Attributes
4386 @subsection MIPS Function Attributes
4388 These function attributes are supported by the MIPS back end:
4390 @table @code
4391 @item interrupt
4392 @cindex @code{interrupt} function attribute, MIPS
4393 Use this attribute to indicate that the specified function is an interrupt
4394 handler.  The compiler generates function entry and exit sequences suitable
4395 for use in an interrupt handler when this attribute is present.
4396 An optional argument is supported for the interrupt attribute which allows
4397 the interrupt mode to be described.  By default GCC assumes the external
4398 interrupt controller (EIC) mode is in use, this can be explicitly set using
4399 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4400 Priority Level (IPL) is copied to the current IPL which has the effect of only
4401 enabling higher priority interrupts.  To use vectored interrupt mode use
4402 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4403 the behavior of the non-masked interrupt support and GCC will arrange to mask
4404 all interrupts from sw0 up to and including the specified interrupt vector.
4406 You can use the following attributes to modify the behavior
4407 of an interrupt handler:
4408 @table @code
4409 @item use_shadow_register_set
4410 @cindex @code{use_shadow_register_set} function attribute, MIPS
4411 Assume that the handler uses a shadow register set, instead of
4412 the main general-purpose registers.  An optional argument @code{intstack} is
4413 supported to indicate that the shadow register set contains a valid stack
4414 pointer.
4416 @item keep_interrupts_masked
4417 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4418 Keep interrupts masked for the whole function.  Without this attribute,
4419 GCC tries to reenable interrupts for as much of the function as it can.
4421 @item use_debug_exception_return
4422 @cindex @code{use_debug_exception_return} function attribute, MIPS
4423 Return using the @code{deret} instruction.  Interrupt handlers that don't
4424 have this attribute return using @code{eret} instead.
4425 @end table
4427 You can use any combination of these attributes, as shown below:
4428 @smallexample
4429 void __attribute__ ((interrupt)) v0 ();
4430 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4431 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4432 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4433 void __attribute__ ((interrupt, use_shadow_register_set,
4434                      keep_interrupts_masked)) v4 ();
4435 void __attribute__ ((interrupt, use_shadow_register_set,
4436                      use_debug_exception_return)) v5 ();
4437 void __attribute__ ((interrupt, keep_interrupts_masked,
4438                      use_debug_exception_return)) v6 ();
4439 void __attribute__ ((interrupt, use_shadow_register_set,
4440                      keep_interrupts_masked,
4441                      use_debug_exception_return)) v7 ();
4442 void __attribute__ ((interrupt("eic"))) v8 ();
4443 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4444 @end smallexample
4446 @item long_call
4447 @itemx near
4448 @itemx far
4449 @cindex indirect calls, MIPS
4450 @cindex @code{long_call} function attribute, MIPS
4451 @cindex @code{near} function attribute, MIPS
4452 @cindex @code{far} function attribute, MIPS
4453 These attributes specify how a particular function is called on MIPS@.
4454 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4455 command-line switch.  The @code{long_call} and @code{far} attributes are
4456 synonyms, and cause the compiler to always call
4457 the function by first loading its address into a register, and then using
4458 the contents of that register.  The @code{near} attribute has the opposite
4459 effect; it specifies that non-PIC calls should be made using the more
4460 efficient @code{jal} instruction.
4462 @item mips16
4463 @itemx nomips16
4464 @cindex @code{mips16} function attribute, MIPS
4465 @cindex @code{nomips16} function attribute, MIPS
4467 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4468 function attributes to locally select or turn off MIPS16 code generation.
4469 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4470 while MIPS16 code generation is disabled for functions with the
4471 @code{nomips16} attribute.  These attributes override the
4472 @option{-mips16} and @option{-mno-mips16} options on the command line
4473 (@pxref{MIPS Options}).
4475 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4476 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4477 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4478 may interact badly with some GCC extensions such as @code{__builtin_apply}
4479 (@pxref{Constructing Calls}).
4481 @item micromips, MIPS
4482 @itemx nomicromips, MIPS
4483 @cindex @code{micromips} function attribute
4484 @cindex @code{nomicromips} function attribute
4486 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4487 function attributes to locally select or turn off microMIPS code generation.
4488 A function with the @code{micromips} attribute is emitted as microMIPS code,
4489 while microMIPS code generation is disabled for functions with the
4490 @code{nomicromips} attribute.  These attributes override the
4491 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4492 (@pxref{MIPS Options}).
4494 When compiling files containing mixed microMIPS and non-microMIPS code, the
4495 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4496 command line,
4497 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4498 may interact badly with some GCC extensions such as @code{__builtin_apply}
4499 (@pxref{Constructing Calls}).
4501 @item nocompression
4502 @cindex @code{nocompression} function attribute, MIPS
4503 On MIPS targets, you can use the @code{nocompression} function attribute
4504 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4505 overrides the @option{-mips16} and @option{-mmicromips} options on the
4506 command line (@pxref{MIPS Options}).
4507 @end table
4509 @node MSP430 Function Attributes
4510 @subsection MSP430 Function Attributes
4512 These function attributes are supported by the MSP430 back end:
4514 @table @code
4515 @item critical
4516 @cindex @code{critical} function attribute, MSP430
4517 Critical functions disable interrupts upon entry and restore the
4518 previous interrupt state upon exit.  Critical functions cannot also
4519 have the @code{naked} or @code{reentrant} attributes.  They can have
4520 the @code{interrupt} attribute.
4522 @item interrupt
4523 @cindex @code{interrupt} function attribute, MSP430
4524 Use this attribute to indicate
4525 that the specified function is an interrupt handler.  The compiler generates
4526 function entry and exit sequences suitable for use in an interrupt handler
4527 when this attribute is present.
4529 You can provide an argument to the interrupt
4530 attribute which specifies a name or number.  If the argument is a
4531 number it indicates the slot in the interrupt vector table (0 - 31) to
4532 which this handler should be assigned.  If the argument is a name it
4533 is treated as a symbolic name for the vector slot.  These names should
4534 match up with appropriate entries in the linker script.  By default
4535 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4536 @code{reset} for vector 31 are recognized.
4538 @item naked
4539 @cindex @code{naked} function attribute, MSP430
4540 This attribute allows the compiler to construct the
4541 requisite function declaration, while allowing the body of the
4542 function to be assembly code. The specified function will not have
4543 prologue/epilogue sequences generated by the compiler. Only basic
4544 @code{asm} statements can safely be included in naked functions
4545 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4546 basic @code{asm} and C code may appear to work, they cannot be
4547 depended upon to work reliably and are not supported.
4549 @item reentrant
4550 @cindex @code{reentrant} function attribute, MSP430
4551 Reentrant functions disable interrupts upon entry and enable them
4552 upon exit.  Reentrant functions cannot also have the @code{naked}
4553 or @code{critical} attributes.  They can have the @code{interrupt}
4554 attribute.
4556 @item wakeup
4557 @cindex @code{wakeup} function attribute, MSP430
4558 This attribute only applies to interrupt functions.  It is silently
4559 ignored if applied to a non-interrupt function.  A wakeup interrupt
4560 function will rouse the processor from any low-power state that it
4561 might be in when the function exits.
4563 @item lower
4564 @itemx upper
4565 @itemx either
4566 @cindex @code{lower} function attribute, MSP430
4567 @cindex @code{upper} function attribute, MSP430
4568 @cindex @code{either} function attribute, MSP430
4569 On the MSP430 target these attributes can be used to specify whether
4570 the function or variable should be placed into low memory, high
4571 memory, or the placement should be left to the linker to decide.  The
4572 attributes are only significant if compiling for the MSP430X
4573 architecture.
4575 The attributes work in conjunction with a linker script that has been
4576 augmented to specify where to place sections with a @code{.lower} and
4577 a @code{.upper} prefix.  So, for example, as well as placing the
4578 @code{.data} section, the script also specifies the placement of a
4579 @code{.lower.data} and a @code{.upper.data} section.  The intention
4580 is that @code{lower} sections are placed into a small but easier to
4581 access memory region and the upper sections are placed into a larger, but
4582 slower to access, region.
4584 The @code{either} attribute is special.  It tells the linker to place
4585 the object into the corresponding @code{lower} section if there is
4586 room for it.  If there is insufficient room then the object is placed
4587 into the corresponding @code{upper} section instead.  Note that the
4588 placement algorithm is not very sophisticated.  It does not attempt to
4589 find an optimal packing of the @code{lower} sections.  It just makes
4590 one pass over the objects and does the best that it can.  Using the
4591 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4592 options can help the packing, however, since they produce smaller,
4593 easier to pack regions.
4594 @end table
4596 @node NDS32 Function Attributes
4597 @subsection NDS32 Function Attributes
4599 These function attributes are supported by the NDS32 back end:
4601 @table @code
4602 @item exception
4603 @cindex @code{exception} function attribute
4604 @cindex exception handler functions, NDS32
4605 Use this attribute on the NDS32 target to indicate that the specified function
4606 is an exception handler.  The compiler will generate corresponding sections
4607 for use in an exception handler.
4609 @item interrupt
4610 @cindex @code{interrupt} function attribute, NDS32
4611 On NDS32 target, this attribute indicates that the specified function
4612 is an interrupt handler.  The compiler generates corresponding sections
4613 for use in an interrupt handler.  You can use the following attributes
4614 to modify the behavior:
4615 @table @code
4616 @item nested
4617 @cindex @code{nested} function attribute, NDS32
4618 This interrupt service routine is interruptible.
4619 @item not_nested
4620 @cindex @code{not_nested} function attribute, NDS32
4621 This interrupt service routine is not interruptible.
4622 @item nested_ready
4623 @cindex @code{nested_ready} function attribute, NDS32
4624 This interrupt service routine is interruptible after @code{PSW.GIE}
4625 (global interrupt enable) is set.  This allows interrupt service routine to
4626 finish some short critical code before enabling interrupts.
4627 @item save_all
4628 @cindex @code{save_all} function attribute, NDS32
4629 The system will help save all registers into stack before entering
4630 interrupt handler.
4631 @item partial_save
4632 @cindex @code{partial_save} function attribute, NDS32
4633 The system will help save caller registers into stack before entering
4634 interrupt handler.
4635 @end table
4637 @item naked
4638 @cindex @code{naked} function attribute, NDS32
4639 This attribute allows the compiler to construct the
4640 requisite function declaration, while allowing the body of the
4641 function to be assembly code. The specified function will not have
4642 prologue/epilogue sequences generated by the compiler. Only basic
4643 @code{asm} statements can safely be included in naked functions
4644 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4645 basic @code{asm} and C code may appear to work, they cannot be
4646 depended upon to work reliably and are not supported.
4648 @item reset
4649 @cindex @code{reset} function attribute, NDS32
4650 @cindex reset handler functions
4651 Use this attribute on the NDS32 target to indicate that the specified function
4652 is a reset handler.  The compiler will generate corresponding sections
4653 for use in a reset handler.  You can use the following attributes
4654 to provide extra exception handling:
4655 @table @code
4656 @item nmi
4657 @cindex @code{nmi} function attribute, NDS32
4658 Provide a user-defined function to handle NMI exception.
4659 @item warm
4660 @cindex @code{warm} function attribute, NDS32
4661 Provide a user-defined function to handle warm reset exception.
4662 @end table
4663 @end table
4665 @node Nios II Function Attributes
4666 @subsection Nios II Function Attributes
4668 These function attributes are supported by the Nios II back end:
4670 @table @code
4671 @item target (@var{options})
4672 @cindex @code{target} function attribute
4673 As discussed in @ref{Common Function Attributes}, this attribute 
4674 allows specification of target-specific compilation options.
4676 When compiling for Nios II, the following options are allowed:
4678 @table @samp
4679 @item custom-@var{insn}=@var{N}
4680 @itemx no-custom-@var{insn}
4681 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4682 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4683 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4684 custom instruction with encoding @var{N} when generating code that uses 
4685 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4686 the custom instruction @var{insn}.
4687 These target attributes correspond to the
4688 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4689 command-line options, and support the same set of @var{insn} keywords.
4690 @xref{Nios II Options}, for more information.
4692 @item custom-fpu-cfg=@var{name}
4693 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4694 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4695 command-line option, to select a predefined set of custom instructions
4696 named @var{name}.
4697 @xref{Nios II Options}, for more information.
4698 @end table
4699 @end table
4701 @node Nvidia PTX Function Attributes
4702 @subsection Nvidia PTX Function Attributes
4704 These function attributes are supported by the Nvidia PTX back end:
4706 @table @code
4707 @item kernel
4708 @cindex @code{kernel} attribute, Nvidia PTX
4709 This attribute indicates that the corresponding function should be compiled
4710 as a kernel function, which can be invoked from the host via the CUDA RT 
4711 library.
4712 By default functions are only callable only from other PTX functions.
4714 Kernel functions must have @code{void} return type.
4715 @end table
4717 @node PowerPC Function Attributes
4718 @subsection PowerPC Function Attributes
4720 These function attributes are supported by the PowerPC back end:
4722 @table @code
4723 @item longcall
4724 @itemx shortcall
4725 @cindex indirect calls, PowerPC
4726 @cindex @code{longcall} function attribute, PowerPC
4727 @cindex @code{shortcall} function attribute, PowerPC
4728 The @code{longcall} attribute
4729 indicates that the function might be far away from the call site and
4730 require a different (more expensive) calling sequence.  The
4731 @code{shortcall} attribute indicates that the function is always close
4732 enough for the shorter calling sequence to be used.  These attributes
4733 override both the @option{-mlongcall} switch and
4734 the @code{#pragma longcall} setting.
4736 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4737 calls are necessary.
4739 @item target (@var{options})
4740 @cindex @code{target} function attribute
4741 As discussed in @ref{Common Function Attributes}, this attribute 
4742 allows specification of target-specific compilation options.
4744 On the PowerPC, the following options are allowed:
4746 @table @samp
4747 @item altivec
4748 @itemx no-altivec
4749 @cindex @code{target("altivec")} function attribute, PowerPC
4750 Generate code that uses (does not use) AltiVec instructions.  In
4751 32-bit code, you cannot enable AltiVec instructions unless
4752 @option{-mabi=altivec} is used on the command line.
4754 @item cmpb
4755 @itemx no-cmpb
4756 @cindex @code{target("cmpb")} function attribute, PowerPC
4757 Generate code that uses (does not use) the compare bytes instruction
4758 implemented on the POWER6 processor and other processors that support
4759 the PowerPC V2.05 architecture.
4761 @item dlmzb
4762 @itemx no-dlmzb
4763 @cindex @code{target("dlmzb")} function attribute, PowerPC
4764 Generate code that uses (does not use) the string-search @samp{dlmzb}
4765 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4766 generated by default when targeting those processors.
4768 @item fprnd
4769 @itemx no-fprnd
4770 @cindex @code{target("fprnd")} function attribute, PowerPC
4771 Generate code that uses (does not use) the FP round to integer
4772 instructions implemented on the POWER5+ processor and other processors
4773 that support the PowerPC V2.03 architecture.
4775 @item hard-dfp
4776 @itemx no-hard-dfp
4777 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4778 Generate code that uses (does not use) the decimal floating-point
4779 instructions implemented on some POWER processors.
4781 @item isel
4782 @itemx no-isel
4783 @cindex @code{target("isel")} function attribute, PowerPC
4784 Generate code that uses (does not use) ISEL instruction.
4786 @item mfcrf
4787 @itemx no-mfcrf
4788 @cindex @code{target("mfcrf")} function attribute, PowerPC
4789 Generate code that uses (does not use) the move from condition
4790 register field instruction implemented on the POWER4 processor and
4791 other processors that support the PowerPC V2.01 architecture.
4793 @item mfpgpr
4794 @itemx no-mfpgpr
4795 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4796 Generate code that uses (does not use) the FP move to/from general
4797 purpose register instructions implemented on the POWER6X processor and
4798 other processors that support the extended PowerPC V2.05 architecture.
4800 @item mulhw
4801 @itemx no-mulhw
4802 @cindex @code{target("mulhw")} function attribute, PowerPC
4803 Generate code that uses (does not use) the half-word multiply and
4804 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4805 These instructions are generated by default when targeting those
4806 processors.
4808 @item multiple
4809 @itemx no-multiple
4810 @cindex @code{target("multiple")} function attribute, PowerPC
4811 Generate code that uses (does not use) the load multiple word
4812 instructions and the store multiple word instructions.
4814 @item update
4815 @itemx no-update
4816 @cindex @code{target("update")} function attribute, PowerPC
4817 Generate code that uses (does not use) the load or store instructions
4818 that update the base register to the address of the calculated memory
4819 location.
4821 @item popcntb
4822 @itemx no-popcntb
4823 @cindex @code{target("popcntb")} function attribute, PowerPC
4824 Generate code that uses (does not use) the popcount and double-precision
4825 FP reciprocal estimate instruction implemented on the POWER5
4826 processor and other processors that support the PowerPC V2.02
4827 architecture.
4829 @item popcntd
4830 @itemx no-popcntd
4831 @cindex @code{target("popcntd")} function attribute, PowerPC
4832 Generate code that uses (does not use) the popcount instruction
4833 implemented on the POWER7 processor and other processors that support
4834 the PowerPC V2.06 architecture.
4836 @item powerpc-gfxopt
4837 @itemx no-powerpc-gfxopt
4838 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4839 Generate code that uses (does not use) the optional PowerPC
4840 architecture instructions in the Graphics group, including
4841 floating-point select.
4843 @item powerpc-gpopt
4844 @itemx no-powerpc-gpopt
4845 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4846 Generate code that uses (does not use) the optional PowerPC
4847 architecture instructions in the General Purpose group, including
4848 floating-point square root.
4850 @item recip-precision
4851 @itemx no-recip-precision
4852 @cindex @code{target("recip-precision")} function attribute, PowerPC
4853 Assume (do not assume) that the reciprocal estimate instructions
4854 provide higher-precision estimates than is mandated by the PowerPC
4855 ABI.
4857 @item string
4858 @itemx no-string
4859 @cindex @code{target("string")} function attribute, PowerPC
4860 Generate code that uses (does not use) the load string instructions
4861 and the store string word instructions to save multiple registers and
4862 do small block moves.
4864 @item vsx
4865 @itemx no-vsx
4866 @cindex @code{target("vsx")} function attribute, PowerPC
4867 Generate code that uses (does not use) vector/scalar (VSX)
4868 instructions, and also enable the use of built-in functions that allow
4869 more direct access to the VSX instruction set.  In 32-bit code, you
4870 cannot enable VSX or AltiVec instructions unless
4871 @option{-mabi=altivec} is used on the command line.
4873 @item friz
4874 @itemx no-friz
4875 @cindex @code{target("friz")} function attribute, PowerPC
4876 Generate (do not generate) the @code{friz} instruction when the
4877 @option{-funsafe-math-optimizations} option is used to optimize
4878 rounding a floating-point value to 64-bit integer and back to floating
4879 point.  The @code{friz} instruction does not return the same value if
4880 the floating-point number is too large to fit in an integer.
4882 @item avoid-indexed-addresses
4883 @itemx no-avoid-indexed-addresses
4884 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4885 Generate code that tries to avoid (not avoid) the use of indexed load
4886 or store instructions.
4888 @item paired
4889 @itemx no-paired
4890 @cindex @code{target("paired")} function attribute, PowerPC
4891 Generate code that uses (does not use) the generation of PAIRED simd
4892 instructions.
4894 @item longcall
4895 @itemx no-longcall
4896 @cindex @code{target("longcall")} function attribute, PowerPC
4897 Generate code that assumes (does not assume) that all calls are far
4898 away so that a longer more expensive calling sequence is required.
4900 @item cpu=@var{CPU}
4901 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4902 Specify the architecture to generate code for when compiling the
4903 function.  If you select the @code{target("cpu=power7")} attribute when
4904 generating 32-bit code, VSX and AltiVec instructions are not generated
4905 unless you use the @option{-mabi=altivec} option on the command line.
4907 @item tune=@var{TUNE}
4908 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4909 Specify the architecture to tune for when compiling the function.  If
4910 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4911 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4912 compilation tunes for the @var{CPU} architecture, and not the
4913 default tuning specified on the command line.
4914 @end table
4916 On the PowerPC, the inliner does not inline a
4917 function that has different target options than the caller, unless the
4918 callee has a subset of the target options of the caller.
4919 @end table
4921 @node RL78 Function Attributes
4922 @subsection RL78 Function Attributes
4924 These function attributes are supported by the RL78 back end:
4926 @table @code
4927 @item interrupt
4928 @itemx brk_interrupt
4929 @cindex @code{interrupt} function attribute, RL78
4930 @cindex @code{brk_interrupt} function attribute, RL78
4931 These attributes indicate
4932 that the specified function is an interrupt handler.  The compiler generates
4933 function entry and exit sequences suitable for use in an interrupt handler
4934 when this attribute is present.
4936 Use @code{brk_interrupt} instead of @code{interrupt} for
4937 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4938 that must end with @code{RETB} instead of @code{RETI}).
4940 @item naked
4941 @cindex @code{naked} function attribute, RL78
4942 This attribute allows the compiler to construct the
4943 requisite function declaration, while allowing the body of the
4944 function to be assembly code. The specified function will not have
4945 prologue/epilogue sequences generated by the compiler. Only basic
4946 @code{asm} statements can safely be included in naked functions
4947 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4948 basic @code{asm} and C code may appear to work, they cannot be
4949 depended upon to work reliably and are not supported.
4950 @end table
4952 @node RX Function Attributes
4953 @subsection RX Function Attributes
4955 These function attributes are supported by the RX back end:
4957 @table @code
4958 @item fast_interrupt
4959 @cindex @code{fast_interrupt} function attribute, RX
4960 Use this attribute on the RX port to indicate that the specified
4961 function is a fast interrupt handler.  This is just like the
4962 @code{interrupt} attribute, except that @code{freit} is used to return
4963 instead of @code{reit}.
4965 @item interrupt
4966 @cindex @code{interrupt} function attribute, RX
4967 Use this attribute to indicate
4968 that the specified function is an interrupt handler.  The compiler generates
4969 function entry and exit sequences suitable for use in an interrupt handler
4970 when this attribute is present.
4972 On RX targets, you may specify one or more vector numbers as arguments
4973 to the attribute, as well as naming an alternate table name.
4974 Parameters are handled sequentially, so one handler can be assigned to
4975 multiple entries in multiple tables.  One may also pass the magic
4976 string @code{"$default"} which causes the function to be used for any
4977 unfilled slots in the current table.
4979 This example shows a simple assignment of a function to one vector in
4980 the default table (note that preprocessor macros may be used for
4981 chip-specific symbolic vector names):
4982 @smallexample
4983 void __attribute__ ((interrupt (5))) txd1_handler ();
4984 @end smallexample
4986 This example assigns a function to two slots in the default table
4987 (using preprocessor macros defined elsewhere) and makes it the default
4988 for the @code{dct} table:
4989 @smallexample
4990 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4991         txd1_handler ();
4992 @end smallexample
4994 @item naked
4995 @cindex @code{naked} function attribute, RX
4996 This attribute allows the compiler to construct the
4997 requisite function declaration, while allowing the body of the
4998 function to be assembly code. The specified function will not have
4999 prologue/epilogue sequences generated by the compiler. Only basic
5000 @code{asm} statements can safely be included in naked functions
5001 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5002 basic @code{asm} and C code may appear to work, they cannot be
5003 depended upon to work reliably and are not supported.
5005 @item vector
5006 @cindex @code{vector} function attribute, RX
5007 This RX attribute is similar to the @code{interrupt} attribute, including its
5008 parameters, but does not make the function an interrupt-handler type
5009 function (i.e. it retains the normal C function calling ABI).  See the
5010 @code{interrupt} attribute for a description of its arguments.
5011 @end table
5013 @node S/390 Function Attributes
5014 @subsection S/390 Function Attributes
5016 These function attributes are supported on the S/390:
5018 @table @code
5019 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5020 @cindex @code{hotpatch} function attribute, S/390
5022 On S/390 System z targets, you can use this function attribute to
5023 make GCC generate a ``hot-patching'' function prologue.  If the
5024 @option{-mhotpatch=} command-line option is used at the same time,
5025 the @code{hotpatch} attribute takes precedence.  The first of the
5026 two arguments specifies the number of halfwords to be added before
5027 the function label.  A second argument can be used to specify the
5028 number of halfwords to be added after the function label.  For
5029 both arguments the maximum allowed value is 1000000.
5031 If both arguments are zero, hotpatching is disabled.
5033 @item target (@var{options})
5034 @cindex @code{target} function attribute
5035 As discussed in @ref{Common Function Attributes}, this attribute
5036 allows specification of target-specific compilation options.
5038 On S/390, the following options are supported:
5040 @table @samp
5041 @item arch=
5042 @item tune=
5043 @item stack-guard=
5044 @item stack-size=
5045 @item branch-cost=
5046 @item warn-framesize=
5047 @item backchain
5048 @itemx no-backchain
5049 @item hard-dfp
5050 @itemx no-hard-dfp
5051 @item hard-float
5052 @itemx soft-float
5053 @item htm
5054 @itemx no-htm
5055 @item vx
5056 @itemx no-vx
5057 @item packed-stack
5058 @itemx no-packed-stack
5059 @item small-exec
5060 @itemx no-small-exec
5061 @item mvcle
5062 @itemx no-mvcle
5063 @item warn-dynamicstack
5064 @itemx no-warn-dynamicstack
5065 @end table
5067 The options work exactly like the S/390 specific command line
5068 options (without the prefix @option{-m}) except that they do not
5069 change any feature macros.  For example,
5071 @smallexample
5072 @code{target("no-vx")}
5073 @end smallexample
5075 does not undefine the @code{__VEC__} macro.
5076 @end table
5078 @node SH Function Attributes
5079 @subsection SH Function Attributes
5081 These function attributes are supported on the SH family of processors:
5083 @table @code
5084 @item function_vector
5085 @cindex @code{function_vector} function attribute, SH
5086 @cindex calling functions through the function vector on SH2A
5087 On SH2A targets, this attribute declares a function to be called using the
5088 TBR relative addressing mode.  The argument to this attribute is the entry
5089 number of the same function in a vector table containing all the TBR
5090 relative addressable functions.  For correct operation the TBR must be setup
5091 accordingly to point to the start of the vector table before any functions with
5092 this attribute are invoked.  Usually a good place to do the initialization is
5093 the startup routine.  The TBR relative vector table can have at max 256 function
5094 entries.  The jumps to these functions are generated using a SH2A specific,
5095 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5096 from GNU binutils version 2.7 or later for this attribute to work correctly.
5098 In an application, for a function being called once, this attribute
5099 saves at least 8 bytes of code; and if other successive calls are being
5100 made to the same function, it saves 2 bytes of code per each of these
5101 calls.
5103 @item interrupt_handler
5104 @cindex @code{interrupt_handler} function attribute, SH
5105 Use this attribute to
5106 indicate that the specified function is an interrupt handler.  The compiler
5107 generates function entry and exit sequences suitable for use in an
5108 interrupt handler when this attribute is present.
5110 @item nosave_low_regs
5111 @cindex @code{nosave_low_regs} function attribute, SH
5112 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5113 function should not save and restore registers R0..R7.  This can be used on SH3*
5114 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5115 interrupt handlers.
5117 @item renesas
5118 @cindex @code{renesas} function attribute, SH
5119 On SH targets this attribute specifies that the function or struct follows the
5120 Renesas ABI.
5122 @item resbank
5123 @cindex @code{resbank} function attribute, SH
5124 On the SH2A target, this attribute enables the high-speed register
5125 saving and restoration using a register bank for @code{interrupt_handler}
5126 routines.  Saving to the bank is performed automatically after the CPU
5127 accepts an interrupt that uses a register bank.
5129 The nineteen 32-bit registers comprising general register R0 to R14,
5130 control register GBR, and system registers MACH, MACL, and PR and the
5131 vector table address offset are saved into a register bank.  Register
5132 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5133 from the bank is executed by issuing a RESBANK instruction.
5135 @item sp_switch
5136 @cindex @code{sp_switch} function attribute, SH
5137 Use this attribute on the SH to indicate an @code{interrupt_handler}
5138 function should switch to an alternate stack.  It expects a string
5139 argument that names a global variable holding the address of the
5140 alternate stack.
5142 @smallexample
5143 void *alt_stack;
5144 void f () __attribute__ ((interrupt_handler,
5145                           sp_switch ("alt_stack")));
5146 @end smallexample
5148 @item trap_exit
5149 @cindex @code{trap_exit} function attribute, SH
5150 Use this attribute on the SH for an @code{interrupt_handler} to return using
5151 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5152 argument specifying the trap number to be used.
5154 @item trapa_handler
5155 @cindex @code{trapa_handler} function attribute, SH
5156 On SH targets this function attribute is similar to @code{interrupt_handler}
5157 but it does not save and restore all registers.
5158 @end table
5160 @node SPU Function Attributes
5161 @subsection SPU Function Attributes
5163 These function attributes are supported by the SPU back end:
5165 @table @code
5166 @item naked
5167 @cindex @code{naked} function attribute, SPU
5168 This attribute allows the compiler to construct the
5169 requisite function declaration, while allowing the body of the
5170 function to be assembly code. The specified function will not have
5171 prologue/epilogue sequences generated by the compiler. Only basic
5172 @code{asm} statements can safely be included in naked functions
5173 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5174 basic @code{asm} and C code may appear to work, they cannot be
5175 depended upon to work reliably and are not supported.
5176 @end table
5178 @node Symbian OS Function Attributes
5179 @subsection Symbian OS Function Attributes
5181 @xref{Microsoft Windows Function Attributes}, for discussion of the
5182 @code{dllexport} and @code{dllimport} attributes.
5184 @node V850 Function Attributes
5185 @subsection V850 Function Attributes
5187 The V850 back end supports these function attributes:
5189 @table @code
5190 @item interrupt
5191 @itemx interrupt_handler
5192 @cindex @code{interrupt} function attribute, V850
5193 @cindex @code{interrupt_handler} function attribute, V850
5194 Use these attributes to indicate
5195 that the specified function is an interrupt handler.  The compiler generates
5196 function entry and exit sequences suitable for use in an interrupt handler
5197 when either attribute is present.
5198 @end table
5200 @node Visium Function Attributes
5201 @subsection Visium Function Attributes
5203 These function attributes are supported by the Visium back end:
5205 @table @code
5206 @item interrupt
5207 @cindex @code{interrupt} function attribute, Visium
5208 Use this attribute to indicate
5209 that the specified function is an interrupt handler.  The compiler generates
5210 function entry and exit sequences suitable for use in an interrupt handler
5211 when this attribute is present.
5212 @end table
5214 @node x86 Function Attributes
5215 @subsection x86 Function Attributes
5217 These function attributes are supported by the x86 back end:
5219 @table @code
5220 @item cdecl
5221 @cindex @code{cdecl} function attribute, x86-32
5222 @cindex functions that pop the argument stack on x86-32
5223 @opindex mrtd
5224 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5225 assume that the calling function pops off the stack space used to
5226 pass arguments.  This is
5227 useful to override the effects of the @option{-mrtd} switch.
5229 @item fastcall
5230 @cindex @code{fastcall} function attribute, x86-32
5231 @cindex functions that pop the argument stack on x86-32
5232 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5233 pass the first argument (if of integral type) in the register ECX and
5234 the second argument (if of integral type) in the register EDX@.  Subsequent
5235 and other typed arguments are passed on the stack.  The called function
5236 pops the arguments off the stack.  If the number of arguments is variable all
5237 arguments are pushed on the stack.
5239 @item thiscall
5240 @cindex @code{thiscall} function attribute, x86-32
5241 @cindex functions that pop the argument stack on x86-32
5242 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5243 pass the first argument (if of integral type) in the register ECX.
5244 Subsequent and other typed arguments are passed on the stack. The called
5245 function pops the arguments off the stack.
5246 If the number of arguments is variable all arguments are pushed on the
5247 stack.
5248 The @code{thiscall} attribute is intended for C++ non-static member functions.
5249 As a GCC extension, this calling convention can be used for C functions
5250 and for static member methods.
5252 @item ms_abi
5253 @itemx sysv_abi
5254 @cindex @code{ms_abi} function attribute, x86
5255 @cindex @code{sysv_abi} function attribute, x86
5257 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5258 to indicate which calling convention should be used for a function.  The
5259 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5260 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5261 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5262 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5264 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5265 requires the @option{-maccumulate-outgoing-args} option.
5267 @item callee_pop_aggregate_return (@var{number})
5268 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5270 On x86-32 targets, you can use this attribute to control how
5271 aggregates are returned in memory.  If the caller is responsible for
5272 popping the hidden pointer together with the rest of the arguments, specify
5273 @var{number} equal to zero.  If callee is responsible for popping the
5274 hidden pointer, specify @var{number} equal to one.  
5276 The default x86-32 ABI assumes that the callee pops the
5277 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5278 the compiler assumes that the
5279 caller pops the stack for hidden pointer.
5281 @item ms_hook_prologue
5282 @cindex @code{ms_hook_prologue} function attribute, x86
5284 On 32-bit and 64-bit x86 targets, you can use
5285 this function attribute to make GCC generate the ``hot-patching'' function
5286 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5287 and newer.
5289 @item regparm (@var{number})
5290 @cindex @code{regparm} function attribute, x86
5291 @cindex functions that are passed arguments in registers on x86-32
5292 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5293 pass arguments number one to @var{number} if they are of integral type
5294 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5295 take a variable number of arguments continue to be passed all of their
5296 arguments on the stack.
5298 Beware that on some ELF systems this attribute is unsuitable for
5299 global functions in shared libraries with lazy binding (which is the
5300 default).  Lazy binding sends the first call via resolving code in
5301 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5302 per the standard calling conventions.  Solaris 8 is affected by this.
5303 Systems with the GNU C Library version 2.1 or higher
5304 and FreeBSD are believed to be
5305 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5306 disabled with the linker or the loader if desired, to avoid the
5307 problem.)
5309 @item sseregparm
5310 @cindex @code{sseregparm} function attribute, x86
5311 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5312 causes the compiler to pass up to 3 floating-point arguments in
5313 SSE registers instead of on the stack.  Functions that take a
5314 variable number of arguments continue to pass all of their
5315 floating-point arguments on the stack.
5317 @item force_align_arg_pointer
5318 @cindex @code{force_align_arg_pointer} function attribute, x86
5319 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5320 applied to individual function definitions, generating an alternate
5321 prologue and epilogue that realigns the run-time stack if necessary.
5322 This supports mixing legacy codes that run with a 4-byte aligned stack
5323 with modern codes that keep a 16-byte stack for SSE compatibility.
5325 @item stdcall
5326 @cindex @code{stdcall} function attribute, x86-32
5327 @cindex functions that pop the argument stack on x86-32
5328 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5329 assume that the called function pops off the stack space used to
5330 pass arguments, unless it takes a variable number of arguments.
5332 @item no_caller_saved_registers
5333 @cindex @code{no_caller_saved_registers} function attribute, x86
5334 Use this attribute to indicate that the specified function has no
5335 caller-saved registers. That is, all registers are callee-saved. For
5336 example, this attribute can be used for a function called from an
5337 interrupt handler. The compiler generates proper function entry and
5338 exit sequences to save and restore any modified registers, except for
5339 the EFLAGS register.  Since GCC doesn't preserve MPX, SSE, MMX nor x87
5340 states, the GCC option @option{-mgeneral-regs-only} should be used to
5341 compile functions with @code{no_caller_saved_registers} attribute.
5343 @item interrupt
5344 @cindex @code{interrupt} function attribute, x86
5345 Use this attribute to indicate that the specified function is an
5346 interrupt handler or an exception handler (depending on parameters passed
5347 to the function, explained further).  The compiler generates function
5348 entry and exit sequences suitable for use in an interrupt handler when
5349 this attribute is present.  The @code{IRET} instruction, instead of the
5350 @code{RET} instruction, is used to return from interrupt handlers.  All
5351 registers, except for the EFLAGS register which is restored by the
5352 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5353 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5354 @option{-mgeneral-regs-only} should be used to compile interrupt and
5355 exception handlers.
5357 Any interruptible-without-stack-switch code must be compiled with
5358 @option{-mno-red-zone} since interrupt handlers can and will, because
5359 of the hardware design, touch the red zone.
5361 An interrupt handler must be declared with a mandatory pointer
5362 argument:
5364 @smallexample
5365 struct interrupt_frame;
5367 __attribute__ ((interrupt))
5368 void
5369 f (struct interrupt_frame *frame)
5372 @end smallexample
5374 @noindent
5375 and you must define @code{struct interrupt_frame} as described in the
5376 processor's manual.
5378 Exception handlers differ from interrupt handlers because the system
5379 pushes an error code on the stack.  An exception handler declaration is
5380 similar to that for an interrupt handler, but with a different mandatory
5381 function signature.  The compiler arranges to pop the error code off the
5382 stack before the @code{IRET} instruction.
5384 @smallexample
5385 #ifdef __x86_64__
5386 typedef unsigned long long int uword_t;
5387 #else
5388 typedef unsigned int uword_t;
5389 #endif
5391 struct interrupt_frame;
5393 __attribute__ ((interrupt))
5394 void
5395 f (struct interrupt_frame *frame, uword_t error_code)
5397   ...
5399 @end smallexample
5401 Exception handlers should only be used for exceptions that push an error
5402 code; you should use an interrupt handler in other cases.  The system
5403 will crash if the wrong kind of handler is used.
5405 @item target (@var{options})
5406 @cindex @code{target} function attribute
5407 As discussed in @ref{Common Function Attributes}, this attribute 
5408 allows specification of target-specific compilation options.
5410 On the x86, the following options are allowed:
5411 @table @samp
5412 @item abm
5413 @itemx no-abm
5414 @cindex @code{target("abm")} function attribute, x86
5415 Enable/disable the generation of the advanced bit instructions.
5417 @item aes
5418 @itemx no-aes
5419 @cindex @code{target("aes")} function attribute, x86
5420 Enable/disable the generation of the AES instructions.
5422 @item default
5423 @cindex @code{target("default")} function attribute, x86
5424 @xref{Function Multiversioning}, where it is used to specify the
5425 default function version.
5427 @item mmx
5428 @itemx no-mmx
5429 @cindex @code{target("mmx")} function attribute, x86
5430 Enable/disable the generation of the MMX instructions.
5432 @item pclmul
5433 @itemx no-pclmul
5434 @cindex @code{target("pclmul")} function attribute, x86
5435 Enable/disable the generation of the PCLMUL instructions.
5437 @item popcnt
5438 @itemx no-popcnt
5439 @cindex @code{target("popcnt")} function attribute, x86
5440 Enable/disable the generation of the POPCNT instruction.
5442 @item sse
5443 @itemx no-sse
5444 @cindex @code{target("sse")} function attribute, x86
5445 Enable/disable the generation of the SSE instructions.
5447 @item sse2
5448 @itemx no-sse2
5449 @cindex @code{target("sse2")} function attribute, x86
5450 Enable/disable the generation of the SSE2 instructions.
5452 @item sse3
5453 @itemx no-sse3
5454 @cindex @code{target("sse3")} function attribute, x86
5455 Enable/disable the generation of the SSE3 instructions.
5457 @item sse4
5458 @itemx no-sse4
5459 @cindex @code{target("sse4")} function attribute, x86
5460 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5461 and SSE4.2).
5463 @item sse4.1
5464 @itemx no-sse4.1
5465 @cindex @code{target("sse4.1")} function attribute, x86
5466 Enable/disable the generation of the sse4.1 instructions.
5468 @item sse4.2
5469 @itemx no-sse4.2
5470 @cindex @code{target("sse4.2")} function attribute, x86
5471 Enable/disable the generation of the sse4.2 instructions.
5473 @item sse4a
5474 @itemx no-sse4a
5475 @cindex @code{target("sse4a")} function attribute, x86
5476 Enable/disable the generation of the SSE4A instructions.
5478 @item fma4
5479 @itemx no-fma4
5480 @cindex @code{target("fma4")} function attribute, x86
5481 Enable/disable the generation of the FMA4 instructions.
5483 @item xop
5484 @itemx no-xop
5485 @cindex @code{target("xop")} function attribute, x86
5486 Enable/disable the generation of the XOP instructions.
5488 @item lwp
5489 @itemx no-lwp
5490 @cindex @code{target("lwp")} function attribute, x86
5491 Enable/disable the generation of the LWP instructions.
5493 @item ssse3
5494 @itemx no-ssse3
5495 @cindex @code{target("ssse3")} function attribute, x86
5496 Enable/disable the generation of the SSSE3 instructions.
5498 @item cld
5499 @itemx no-cld
5500 @cindex @code{target("cld")} function attribute, x86
5501 Enable/disable the generation of the CLD before string moves.
5503 @item fancy-math-387
5504 @itemx no-fancy-math-387
5505 @cindex @code{target("fancy-math-387")} function attribute, x86
5506 Enable/disable the generation of the @code{sin}, @code{cos}, and
5507 @code{sqrt} instructions on the 387 floating-point unit.
5509 @item ieee-fp
5510 @itemx no-ieee-fp
5511 @cindex @code{target("ieee-fp")} function attribute, x86
5512 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5514 @item inline-all-stringops
5515 @itemx no-inline-all-stringops
5516 @cindex @code{target("inline-all-stringops")} function attribute, x86
5517 Enable/disable inlining of string operations.
5519 @item inline-stringops-dynamically
5520 @itemx no-inline-stringops-dynamically
5521 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5522 Enable/disable the generation of the inline code to do small string
5523 operations and calling the library routines for large operations.
5525 @item align-stringops
5526 @itemx no-align-stringops
5527 @cindex @code{target("align-stringops")} function attribute, x86
5528 Do/do not align destination of inlined string operations.
5530 @item recip
5531 @itemx no-recip
5532 @cindex @code{target("recip")} function attribute, x86
5533 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5534 instructions followed an additional Newton-Raphson step instead of
5535 doing a floating-point division.
5537 @item arch=@var{ARCH}
5538 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5539 Specify the architecture to generate code for in compiling the function.
5541 @item tune=@var{TUNE}
5542 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5543 Specify the architecture to tune for in compiling the function.
5545 @item fpmath=@var{FPMATH}
5546 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5547 Specify which floating-point unit to use.  You must specify the
5548 @code{target("fpmath=sse,387")} option as
5549 @code{target("fpmath=sse+387")} because the comma would separate
5550 different options.
5551 @end table
5553 On the x86, the inliner does not inline a
5554 function that has different target options than the caller, unless the
5555 callee has a subset of the target options of the caller.  For example
5556 a function declared with @code{target("sse3")} can inline a function
5557 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5558 @end table
5560 @node Xstormy16 Function Attributes
5561 @subsection Xstormy16 Function Attributes
5563 These function attributes are supported by the Xstormy16 back end:
5565 @table @code
5566 @item interrupt
5567 @cindex @code{interrupt} function attribute, Xstormy16
5568 Use this attribute to indicate
5569 that the specified function is an interrupt handler.  The compiler generates
5570 function entry and exit sequences suitable for use in an interrupt handler
5571 when this attribute is present.
5572 @end table
5574 @node Variable Attributes
5575 @section Specifying Attributes of Variables
5576 @cindex attribute of variables
5577 @cindex variable attributes
5579 The keyword @code{__attribute__} allows you to specify special
5580 attributes of variables or structure fields.  This keyword is followed
5581 by an attribute specification inside double parentheses.  Some
5582 attributes are currently defined generically for variables.
5583 Other attributes are defined for variables on particular target
5584 systems.  Other attributes are available for functions
5585 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5586 enumerators (@pxref{Enumerator Attributes}), statements
5587 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5588 Other front ends might define more attributes
5589 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5591 @xref{Attribute Syntax}, for details of the exact syntax for using
5592 attributes.
5594 @menu
5595 * Common Variable Attributes::
5596 * AVR Variable Attributes::
5597 * Blackfin Variable Attributes::
5598 * H8/300 Variable Attributes::
5599 * IA-64 Variable Attributes::
5600 * M32R/D Variable Attributes::
5601 * MeP Variable Attributes::
5602 * Microsoft Windows Variable Attributes::
5603 * MSP430 Variable Attributes::
5604 * Nvidia PTX Variable Attributes::
5605 * PowerPC Variable Attributes::
5606 * RL78 Variable Attributes::
5607 * SPU Variable Attributes::
5608 * V850 Variable Attributes::
5609 * x86 Variable Attributes::
5610 * Xstormy16 Variable Attributes::
5611 @end menu
5613 @node Common Variable Attributes
5614 @subsection Common Variable Attributes
5616 The following attributes are supported on most targets.
5618 @table @code
5619 @cindex @code{aligned} variable attribute
5620 @item aligned (@var{alignment})
5621 This attribute specifies a minimum alignment for the variable or
5622 structure field, measured in bytes.  For example, the declaration:
5624 @smallexample
5625 int x __attribute__ ((aligned (16))) = 0;
5626 @end smallexample
5628 @noindent
5629 causes the compiler to allocate the global variable @code{x} on a
5630 16-byte boundary.  On a 68040, this could be used in conjunction with
5631 an @code{asm} expression to access the @code{move16} instruction which
5632 requires 16-byte aligned operands.
5634 You can also specify the alignment of structure fields.  For example, to
5635 create a double-word aligned @code{int} pair, you could write:
5637 @smallexample
5638 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5639 @end smallexample
5641 @noindent
5642 This is an alternative to creating a union with a @code{double} member,
5643 which forces the union to be double-word aligned.
5645 As in the preceding examples, you can explicitly specify the alignment
5646 (in bytes) that you wish the compiler to use for a given variable or
5647 structure field.  Alternatively, you can leave out the alignment factor
5648 and just ask the compiler to align a variable or field to the
5649 default alignment for the target architecture you are compiling for.
5650 The default alignment is sufficient for all scalar types, but may not be
5651 enough for all vector types on a target that supports vector operations.
5652 The default alignment is fixed for a particular target ABI.
5654 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5655 which is the largest alignment ever used for any data type on the
5656 target machine you are compiling for.  For example, you could write:
5658 @smallexample
5659 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5660 @end smallexample
5662 The compiler automatically sets the alignment for the declared
5663 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5664 often make copy operations more efficient, because the compiler can
5665 use whatever instructions copy the biggest chunks of memory when
5666 performing copies to or from the variables or fields that you have
5667 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5668 may change depending on command-line options.
5670 When used on a struct, or struct member, the @code{aligned} attribute can
5671 only increase the alignment; in order to decrease it, the @code{packed}
5672 attribute must be specified as well.  When used as part of a typedef, the
5673 @code{aligned} attribute can both increase and decrease alignment, and
5674 specifying the @code{packed} attribute generates a warning.
5676 Note that the effectiveness of @code{aligned} attributes may be limited
5677 by inherent limitations in your linker.  On many systems, the linker is
5678 only able to arrange for variables to be aligned up to a certain maximum
5679 alignment.  (For some linkers, the maximum supported alignment may
5680 be very very small.)  If your linker is only able to align variables
5681 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5682 in an @code{__attribute__} still only provides you with 8-byte
5683 alignment.  See your linker documentation for further information.
5685 The @code{aligned} attribute can also be used for functions
5686 (@pxref{Common Function Attributes}.)
5688 @item cleanup (@var{cleanup_function})
5689 @cindex @code{cleanup} variable attribute
5690 The @code{cleanup} attribute runs a function when the variable goes
5691 out of scope.  This attribute can only be applied to auto function
5692 scope variables; it may not be applied to parameters or variables
5693 with static storage duration.  The function must take one parameter,
5694 a pointer to a type compatible with the variable.  The return value
5695 of the function (if any) is ignored.
5697 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5698 is run during the stack unwinding that happens during the
5699 processing of the exception.  Note that the @code{cleanup} attribute
5700 does not allow the exception to be caught, only to perform an action.
5701 It is undefined what happens if @var{cleanup_function} does not
5702 return normally.
5704 @item common
5705 @itemx nocommon
5706 @cindex @code{common} variable attribute
5707 @cindex @code{nocommon} variable attribute
5708 @opindex fcommon
5709 @opindex fno-common
5710 The @code{common} attribute requests GCC to place a variable in
5711 ``common'' storage.  The @code{nocommon} attribute requests the
5712 opposite---to allocate space for it directly.
5714 These attributes override the default chosen by the
5715 @option{-fno-common} and @option{-fcommon} flags respectively.
5717 @item deprecated
5718 @itemx deprecated (@var{msg})
5719 @cindex @code{deprecated} variable attribute
5720 The @code{deprecated} attribute results in a warning if the variable
5721 is used anywhere in the source file.  This is useful when identifying
5722 variables that are expected to be removed in a future version of a
5723 program.  The warning also includes the location of the declaration
5724 of the deprecated variable, to enable users to easily find further
5725 information about why the variable is deprecated, or what they should
5726 do instead.  Note that the warning only occurs for uses:
5728 @smallexample
5729 extern int old_var __attribute__ ((deprecated));
5730 extern int old_var;
5731 int new_fn () @{ return old_var; @}
5732 @end smallexample
5734 @noindent
5735 results in a warning on line 3 but not line 2.  The optional @var{msg}
5736 argument, which must be a string, is printed in the warning if
5737 present.
5739 The @code{deprecated} attribute can also be used for functions and
5740 types (@pxref{Common Function Attributes},
5741 @pxref{Common Type Attributes}).
5743 @item mode (@var{mode})
5744 @cindex @code{mode} variable attribute
5745 This attribute specifies the data type for the declaration---whichever
5746 type corresponds to the mode @var{mode}.  This in effect lets you
5747 request an integer or floating-point type according to its width.
5749 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
5750 for a list of the possible keywords for @var{mode}.
5751 You may also specify a mode of @code{byte} or @code{__byte__} to
5752 indicate the mode corresponding to a one-byte integer, @code{word} or
5753 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5754 or @code{__pointer__} for the mode used to represent pointers.
5756 @item packed
5757 @cindex @code{packed} variable attribute
5758 The @code{packed} attribute specifies that a variable or structure field
5759 should have the smallest possible alignment---one byte for a variable,
5760 and one bit for a field, unless you specify a larger value with the
5761 @code{aligned} attribute.
5763 Here is a structure in which the field @code{x} is packed, so that it
5764 immediately follows @code{a}:
5766 @smallexample
5767 struct foo
5769   char a;
5770   int x[2] __attribute__ ((packed));
5772 @end smallexample
5774 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5775 @code{packed} attribute on bit-fields of type @code{char}.  This has
5776 been fixed in GCC 4.4 but the change can lead to differences in the
5777 structure layout.  See the documentation of
5778 @option{-Wpacked-bitfield-compat} for more information.
5780 @item section ("@var{section-name}")
5781 @cindex @code{section} variable attribute
5782 Normally, the compiler places the objects it generates in sections like
5783 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5784 or you need certain particular variables to appear in special sections,
5785 for example to map to special hardware.  The @code{section}
5786 attribute specifies that a variable (or function) lives in a particular
5787 section.  For example, this small program uses several specific section names:
5789 @smallexample
5790 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5791 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5792 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5793 int init_data __attribute__ ((section ("INITDATA")));
5795 main()
5797   /* @r{Initialize stack pointer} */
5798   init_sp (stack + sizeof (stack));
5800   /* @r{Initialize initialized data} */
5801   memcpy (&init_data, &data, &edata - &data);
5803   /* @r{Turn on the serial ports} */
5804   init_duart (&a);
5805   init_duart (&b);
5807 @end smallexample
5809 @noindent
5810 Use the @code{section} attribute with
5811 @emph{global} variables and not @emph{local} variables,
5812 as shown in the example.
5814 You may use the @code{section} attribute with initialized or
5815 uninitialized global variables but the linker requires
5816 each object be defined once, with the exception that uninitialized
5817 variables tentatively go in the @code{common} (or @code{bss}) section
5818 and can be multiply ``defined''.  Using the @code{section} attribute
5819 changes what section the variable goes into and may cause the
5820 linker to issue an error if an uninitialized variable has multiple
5821 definitions.  You can force a variable to be initialized with the
5822 @option{-fno-common} flag or the @code{nocommon} attribute.
5824 Some file formats do not support arbitrary sections so the @code{section}
5825 attribute is not available on all platforms.
5826 If you need to map the entire contents of a module to a particular
5827 section, consider using the facilities of the linker instead.
5829 @item tls_model ("@var{tls_model}")
5830 @cindex @code{tls_model} variable attribute
5831 The @code{tls_model} attribute sets thread-local storage model
5832 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5833 overriding @option{-ftls-model=} command-line switch on a per-variable
5834 basis.
5835 The @var{tls_model} argument should be one of @code{global-dynamic},
5836 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5838 Not all targets support this attribute.
5840 @item unused
5841 @cindex @code{unused} variable attribute
5842 This attribute, attached to a variable, means that the variable is meant
5843 to be possibly unused.  GCC does not produce a warning for this
5844 variable.
5846 @item used
5847 @cindex @code{used} variable attribute
5848 This attribute, attached to a variable with static storage, means that
5849 the variable must be emitted even if it appears that the variable is not
5850 referenced.
5852 When applied to a static data member of a C++ class template, the
5853 attribute also means that the member is instantiated if the
5854 class itself is instantiated.
5856 @item vector_size (@var{bytes})
5857 @cindex @code{vector_size} variable attribute
5858 This attribute specifies the vector size for the variable, measured in
5859 bytes.  For example, the declaration:
5861 @smallexample
5862 int foo __attribute__ ((vector_size (16)));
5863 @end smallexample
5865 @noindent
5866 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5867 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5868 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5870 This attribute is only applicable to integral and float scalars,
5871 although arrays, pointers, and function return values are allowed in
5872 conjunction with this construct.
5874 Aggregates with this attribute are invalid, even if they are of the same
5875 size as a corresponding scalar.  For example, the declaration:
5877 @smallexample
5878 struct S @{ int a; @};
5879 struct S  __attribute__ ((vector_size (16))) foo;
5880 @end smallexample
5882 @noindent
5883 is invalid even if the size of the structure is the same as the size of
5884 the @code{int}.
5886 @item visibility ("@var{visibility_type}")
5887 @cindex @code{visibility} variable attribute
5888 This attribute affects the linkage of the declaration to which it is attached.
5889 The @code{visibility} attribute is described in
5890 @ref{Common Function Attributes}.
5892 @item weak
5893 @cindex @code{weak} variable attribute
5894 The @code{weak} attribute is described in
5895 @ref{Common Function Attributes}.
5897 @end table
5899 @node AVR Variable Attributes
5900 @subsection AVR Variable Attributes
5902 @table @code
5903 @item progmem
5904 @cindex @code{progmem} variable attribute, AVR
5905 The @code{progmem} attribute is used on the AVR to place read-only
5906 data in the non-volatile program memory (flash). The @code{progmem}
5907 attribute accomplishes this by putting respective variables into a
5908 section whose name starts with @code{.progmem}.
5910 This attribute works similar to the @code{section} attribute
5911 but adds additional checking.
5913 @table @asis
5914 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5915 @code{progmem} affects the location
5916 of the data but not how this data is accessed.
5917 In order to read data located with the @code{progmem} attribute
5918 (inline) assembler must be used.
5919 @smallexample
5920 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5921 #include <avr/pgmspace.h> 
5923 /* Locate var in flash memory */
5924 const int var[2] PROGMEM = @{ 1, 2 @};
5926 int read_var (int i)
5928     /* Access var[] by accessor macro from avr/pgmspace.h */
5929     return (int) pgm_read_word (& var[i]);
5931 @end smallexample
5933 AVR is a Harvard architecture processor and data and read-only data
5934 normally resides in the data memory (RAM).
5936 See also the @ref{AVR Named Address Spaces} section for
5937 an alternate way to locate and access data in flash memory.
5939 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5940 The compiler adds @code{0x4000}
5941 to the addresses of objects and declarations in @code{progmem} and locates
5942 the objects in flash memory, namely in section @code{.progmem.data}.
5943 The offset is needed because the flash memory is visible in the RAM
5944 address space starting at address @code{0x4000}.
5946 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5947 no special functions or macros are needed.
5949 @smallexample
5950 /* var is located in flash memory */
5951 extern const int var[2] __attribute__((progmem));
5953 int read_var (int i)
5955     return var[i];
5957 @end smallexample
5959 Please notice that on these devices, there is no need for @code{progmem}
5960 at all.  Just use an appropriate linker description file like outlined below.
5962 @smallexample
5963   .text :
5964   @{ ...
5965   @} > text
5966   /* Leave .rodata in flash and add an offset of 0x4000 to all
5967      addresses so that respective objects can be accessed by
5968      LD instructions and open coded C/C++.  This means there
5969      is no need for progmem in the source and no overhead by
5970      read-only data in RAM.  */
5971   .rodata ADDR(.text) + SIZEOF (.text) + 0x4000 :
5972   @{
5973     *(.rodata)
5974     *(.rodata*)
5975     *(.gnu.linkonce.r*)
5976   @} AT> text
5977   /* No more need to put .rodata into .data:
5978      Removed all .rodata entries from .data.  */
5979   .data :
5980   @{ ...
5981 @end smallexample
5983 @end table
5985 @item io
5986 @itemx io (@var{addr})
5987 @cindex @code{io} variable attribute, AVR
5988 Variables with the @code{io} attribute are used to address
5989 memory-mapped peripherals in the io address range.
5990 If an address is specified, the variable
5991 is assigned that address, and the value is interpreted as an
5992 address in the data address space.
5993 Example:
5995 @smallexample
5996 volatile int porta __attribute__((io (0x22)));
5997 @end smallexample
5999 The address specified in the address in the data address range.
6001 Otherwise, the variable it is not assigned an address, but the
6002 compiler will still use in/out instructions where applicable,
6003 assuming some other module assigns an address in the io address range.
6004 Example:
6006 @smallexample
6007 extern volatile int porta __attribute__((io));
6008 @end smallexample
6010 @item io_low
6011 @itemx io_low (@var{addr})
6012 @cindex @code{io_low} variable attribute, AVR
6013 This is like the @code{io} attribute, but additionally it informs the
6014 compiler that the object lies in the lower half of the I/O area,
6015 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6016 instructions.
6018 @item address
6019 @itemx address (@var{addr})
6020 @cindex @code{address} variable attribute, AVR
6021 Variables with the @code{address} attribute are used to address
6022 memory-mapped peripherals that may lie outside the io address range.
6024 @smallexample
6025 volatile int porta __attribute__((address (0x600)));
6026 @end smallexample
6028 @item absdata
6029 @cindex @code{absdata} variable attribute, AVR
6030 Variables in static storage and with the @code{absdata} attribute can
6031 be accessed by the @code{LDS} and @code{STS} instructions which take
6032 absolute addresses.
6034 @itemize @bullet
6035 @item
6036 This attribute is only supported for the reduced AVR Tiny core
6037 like ATtiny40.
6039 @item
6040 You must make sure that respective data is located in the
6041 address range @code{0x40}@dots{}@code{0xbf} accessible by
6042 @code{LDS} and @code{STS}.  One way to achieve this as an
6043 appropriate linker description file.
6045 @item
6046 If the location does not fit the address range of @code{LDS}
6047 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6048 warning like
6049 @quotation
6050 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6051 @end quotation
6053 @end itemize
6055 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6057 @end table
6059 @node Blackfin Variable Attributes
6060 @subsection Blackfin Variable Attributes
6062 Three attributes are currently defined for the Blackfin.
6064 @table @code
6065 @item l1_data
6066 @itemx l1_data_A
6067 @itemx l1_data_B
6068 @cindex @code{l1_data} variable attribute, Blackfin
6069 @cindex @code{l1_data_A} variable attribute, Blackfin
6070 @cindex @code{l1_data_B} variable attribute, Blackfin
6071 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6072 Variables with @code{l1_data} attribute are put into the specific section
6073 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6074 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6075 attribute are put into the specific section named @code{.l1.data.B}.
6077 @item l2
6078 @cindex @code{l2} variable attribute, Blackfin
6079 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6080 Variables with @code{l2} attribute are put into the specific section
6081 named @code{.l2.data}.
6082 @end table
6084 @node H8/300 Variable Attributes
6085 @subsection H8/300 Variable Attributes
6087 These variable attributes are available for H8/300 targets:
6089 @table @code
6090 @item eightbit_data
6091 @cindex @code{eightbit_data} variable attribute, H8/300
6092 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6093 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6094 variable should be placed into the eight-bit data section.
6095 The compiler generates more efficient code for certain operations
6096 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6097 256 bytes of data.
6099 You must use GAS and GLD from GNU binutils version 2.7 or later for
6100 this attribute to work correctly.
6102 @item tiny_data
6103 @cindex @code{tiny_data} variable attribute, H8/300
6104 @cindex tiny data section on the H8/300H and H8S
6105 Use this attribute on the H8/300H and H8S to indicate that the specified
6106 variable should be placed into the tiny data section.
6107 The compiler generates more efficient code for loads and stores
6108 on data in the tiny data section.  Note the tiny data area is limited to
6109 slightly under 32KB of data.
6111 @end table
6113 @node IA-64 Variable Attributes
6114 @subsection IA-64 Variable Attributes
6116 The IA-64 back end supports the following variable attribute:
6118 @table @code
6119 @item model (@var{model-name})
6120 @cindex @code{model} variable attribute, IA-64
6122 On IA-64, use this attribute to set the addressability of an object.
6123 At present, the only supported identifier for @var{model-name} is
6124 @code{small}, indicating addressability via ``small'' (22-bit)
6125 addresses (so that their addresses can be loaded with the @code{addl}
6126 instruction).  Caveat: such addressing is by definition not position
6127 independent and hence this attribute must not be used for objects
6128 defined by shared libraries.
6130 @end table
6132 @node M32R/D Variable Attributes
6133 @subsection M32R/D Variable Attributes
6135 One attribute is currently defined for the M32R/D@.
6137 @table @code
6138 @item model (@var{model-name})
6139 @cindex @code{model-name} variable attribute, M32R/D
6140 @cindex variable addressability on the M32R/D
6141 Use this attribute on the M32R/D to set the addressability of an object.
6142 The identifier @var{model-name} is one of @code{small}, @code{medium},
6143 or @code{large}, representing each of the code models.
6145 Small model objects live in the lower 16MB of memory (so that their
6146 addresses can be loaded with the @code{ld24} instruction).
6148 Medium and large model objects may live anywhere in the 32-bit address space
6149 (the compiler generates @code{seth/add3} instructions to load their
6150 addresses).
6151 @end table
6153 @node MeP Variable Attributes
6154 @subsection MeP Variable Attributes
6156 The MeP target has a number of addressing modes and busses.  The
6157 @code{near} space spans the standard memory space's first 16 megabytes
6158 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6159 The @code{based} space is a 128-byte region in the memory space that
6160 is addressed relative to the @code{$tp} register.  The @code{tiny}
6161 space is a 65536-byte region relative to the @code{$gp} register.  In
6162 addition to these memory regions, the MeP target has a separate 16-bit
6163 control bus which is specified with @code{cb} attributes.
6165 @table @code
6167 @item based
6168 @cindex @code{based} variable attribute, MeP
6169 Any variable with the @code{based} attribute is assigned to the
6170 @code{.based} section, and is accessed with relative to the
6171 @code{$tp} register.
6173 @item tiny
6174 @cindex @code{tiny} variable attribute, MeP
6175 Likewise, the @code{tiny} attribute assigned variables to the
6176 @code{.tiny} section, relative to the @code{$gp} register.
6178 @item near
6179 @cindex @code{near} variable attribute, MeP
6180 Variables with the @code{near} attribute are assumed to have addresses
6181 that fit in a 24-bit addressing mode.  This is the default for large
6182 variables (@code{-mtiny=4} is the default) but this attribute can
6183 override @code{-mtiny=} for small variables, or override @code{-ml}.
6185 @item far
6186 @cindex @code{far} variable attribute, MeP
6187 Variables with the @code{far} attribute are addressed using a full
6188 32-bit address.  Since this covers the entire memory space, this
6189 allows modules to make no assumptions about where variables might be
6190 stored.
6192 @item io
6193 @cindex @code{io} variable attribute, MeP
6194 @itemx io (@var{addr})
6195 Variables with the @code{io} attribute are used to address
6196 memory-mapped peripherals.  If an address is specified, the variable
6197 is assigned that address, else it is not assigned an address (it is
6198 assumed some other module assigns an address).  Example:
6200 @smallexample
6201 int timer_count __attribute__((io(0x123)));
6202 @end smallexample
6204 @item cb
6205 @itemx cb (@var{addr})
6206 @cindex @code{cb} variable attribute, MeP
6207 Variables with the @code{cb} attribute are used to access the control
6208 bus, using special instructions.  @code{addr} indicates the control bus
6209 address.  Example:
6211 @smallexample
6212 int cpu_clock __attribute__((cb(0x123)));
6213 @end smallexample
6215 @end table
6217 @node Microsoft Windows Variable Attributes
6218 @subsection Microsoft Windows Variable Attributes
6220 You can use these attributes on Microsoft Windows targets.
6221 @ref{x86 Variable Attributes} for additional Windows compatibility
6222 attributes available on all x86 targets.
6224 @table @code
6225 @item dllimport
6226 @itemx dllexport
6227 @cindex @code{dllimport} variable attribute
6228 @cindex @code{dllexport} variable attribute
6229 The @code{dllimport} and @code{dllexport} attributes are described in
6230 @ref{Microsoft Windows Function Attributes}.
6232 @item selectany
6233 @cindex @code{selectany} variable attribute
6234 The @code{selectany} attribute causes an initialized global variable to
6235 have link-once semantics.  When multiple definitions of the variable are
6236 encountered by the linker, the first is selected and the remainder are
6237 discarded.  Following usage by the Microsoft compiler, the linker is told
6238 @emph{not} to warn about size or content differences of the multiple
6239 definitions.
6241 Although the primary usage of this attribute is for POD types, the
6242 attribute can also be applied to global C++ objects that are initialized
6243 by a constructor.  In this case, the static initialization and destruction
6244 code for the object is emitted in each translation defining the object,
6245 but the calls to the constructor and destructor are protected by a
6246 link-once guard variable.
6248 The @code{selectany} attribute is only available on Microsoft Windows
6249 targets.  You can use @code{__declspec (selectany)} as a synonym for
6250 @code{__attribute__ ((selectany))} for compatibility with other
6251 compilers.
6253 @item shared
6254 @cindex @code{shared} variable attribute
6255 On Microsoft Windows, in addition to putting variable definitions in a named
6256 section, the section can also be shared among all running copies of an
6257 executable or DLL@.  For example, this small program defines shared data
6258 by putting it in a named section @code{shared} and marking the section
6259 shareable:
6261 @smallexample
6262 int foo __attribute__((section ("shared"), shared)) = 0;
6265 main()
6267   /* @r{Read and write foo.  All running
6268      copies see the same value.}  */
6269   return 0;
6271 @end smallexample
6273 @noindent
6274 You may only use the @code{shared} attribute along with @code{section}
6275 attribute with a fully-initialized global definition because of the way
6276 linkers work.  See @code{section} attribute for more information.
6278 The @code{shared} attribute is only available on Microsoft Windows@.
6280 @end table
6282 @node MSP430 Variable Attributes
6283 @subsection MSP430 Variable Attributes
6285 @table @code
6286 @item noinit
6287 @cindex @code{noinit} variable attribute, MSP430 
6288 Any data with the @code{noinit} attribute will not be initialised by
6289 the C runtime startup code, or the program loader.  Not initialising
6290 data in this way can reduce program startup times.
6292 @item persistent
6293 @cindex @code{persistent} variable attribute, MSP430 
6294 Any variable with the @code{persistent} attribute will not be
6295 initialised by the C runtime startup code.  Instead its value will be
6296 set once, when the application is loaded, and then never initialised
6297 again, even if the processor is reset or the program restarts.
6298 Persistent data is intended to be placed into FLASH RAM, where its
6299 value will be retained across resets.  The linker script being used to
6300 create the application should ensure that persistent data is correctly
6301 placed.
6303 @item lower
6304 @itemx upper
6305 @itemx either
6306 @cindex @code{lower} variable attribute, MSP430 
6307 @cindex @code{upper} variable attribute, MSP430 
6308 @cindex @code{either} variable attribute, MSP430 
6309 These attributes are the same as the MSP430 function attributes of the
6310 same name (@pxref{MSP430 Function Attributes}).  
6311 These attributes can be applied to both functions and variables.
6312 @end table
6314 @node Nvidia PTX Variable Attributes
6315 @subsection Nvidia PTX Variable Attributes
6317 These variable attributes are supported by the Nvidia PTX back end:
6319 @table @code
6320 @item shared
6321 @cindex @code{shared} attribute, Nvidia PTX
6322 Use this attribute to place a variable in the @code{.shared} memory space.
6323 This memory space is private to each cooperative thread array; only threads
6324 within one thread block refer to the same instance of the variable.
6325 The runtime does not initialize variables in this memory space.
6326 @end table
6328 @node PowerPC Variable Attributes
6329 @subsection PowerPC Variable Attributes
6331 Three attributes currently are defined for PowerPC configurations:
6332 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6334 @cindex @code{ms_struct} variable attribute, PowerPC
6335 @cindex @code{gcc_struct} variable attribute, PowerPC
6336 For full documentation of the struct attributes please see the
6337 documentation in @ref{x86 Variable Attributes}.
6339 @cindex @code{altivec} variable attribute, PowerPC
6340 For documentation of @code{altivec} attribute please see the
6341 documentation in @ref{PowerPC Type Attributes}.
6343 @node RL78 Variable Attributes
6344 @subsection RL78 Variable Attributes
6346 @cindex @code{saddr} variable attribute, RL78
6347 The RL78 back end supports the @code{saddr} variable attribute.  This
6348 specifies placement of the corresponding variable in the SADDR area,
6349 which can be accessed more efficiently than the default memory region.
6351 @node SPU Variable Attributes
6352 @subsection SPU Variable Attributes
6354 @cindex @code{spu_vector} variable attribute, SPU
6355 The SPU supports the @code{spu_vector} attribute for variables.  For
6356 documentation of this attribute please see the documentation in
6357 @ref{SPU Type Attributes}.
6359 @node V850 Variable Attributes
6360 @subsection V850 Variable Attributes
6362 These variable attributes are supported by the V850 back end:
6364 @table @code
6366 @item sda
6367 @cindex @code{sda} variable attribute, V850
6368 Use this attribute to explicitly place a variable in the small data area,
6369 which can hold up to 64 kilobytes.
6371 @item tda
6372 @cindex @code{tda} variable attribute, V850
6373 Use this attribute to explicitly place a variable in the tiny data area,
6374 which can hold up to 256 bytes in total.
6376 @item zda
6377 @cindex @code{zda} variable attribute, V850
6378 Use this attribute to explicitly place a variable in the first 32 kilobytes
6379 of memory.
6380 @end table
6382 @node x86 Variable Attributes
6383 @subsection x86 Variable Attributes
6385 Two attributes are currently defined for x86 configurations:
6386 @code{ms_struct} and @code{gcc_struct}.
6388 @table @code
6389 @item ms_struct
6390 @itemx gcc_struct
6391 @cindex @code{ms_struct} variable attribute, x86
6392 @cindex @code{gcc_struct} variable attribute, x86
6394 If @code{packed} is used on a structure, or if bit-fields are used,
6395 it may be that the Microsoft ABI lays out the structure differently
6396 than the way GCC normally does.  Particularly when moving packed
6397 data between functions compiled with GCC and the native Microsoft compiler
6398 (either via function call or as data in a file), it may be necessary to access
6399 either format.
6401 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6402 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6403 command-line options, respectively;
6404 see @ref{x86 Options}, for details of how structure layout is affected.
6405 @xref{x86 Type Attributes}, for information about the corresponding
6406 attributes on types.
6408 @end table
6410 @node Xstormy16 Variable Attributes
6411 @subsection Xstormy16 Variable Attributes
6413 One attribute is currently defined for xstormy16 configurations:
6414 @code{below100}.
6416 @table @code
6417 @item below100
6418 @cindex @code{below100} variable attribute, Xstormy16
6420 If a variable has the @code{below100} attribute (@code{BELOW100} is
6421 allowed also), GCC places the variable in the first 0x100 bytes of
6422 memory and use special opcodes to access it.  Such variables are
6423 placed in either the @code{.bss_below100} section or the
6424 @code{.data_below100} section.
6426 @end table
6428 @node Type Attributes
6429 @section Specifying Attributes of Types
6430 @cindex attribute of types
6431 @cindex type attributes
6433 The keyword @code{__attribute__} allows you to specify special
6434 attributes of types.  Some type attributes apply only to @code{struct}
6435 and @code{union} types, while others can apply to any type defined
6436 via a @code{typedef} declaration.  Other attributes are defined for
6437 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6438 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6439 statements (@pxref{Statement Attributes}), and for
6440 variables (@pxref{Variable Attributes}).
6442 The @code{__attribute__} keyword is followed by an attribute specification
6443 inside double parentheses.  
6445 You may specify type attributes in an enum, struct or union type
6446 declaration or definition by placing them immediately after the
6447 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6448 syntax is to place them just past the closing curly brace of the
6449 definition.
6451 You can also include type attributes in a @code{typedef} declaration.
6452 @xref{Attribute Syntax}, for details of the exact syntax for using
6453 attributes.
6455 @menu
6456 * Common Type Attributes::
6457 * ARM Type Attributes::
6458 * MeP Type Attributes::
6459 * PowerPC Type Attributes::
6460 * SPU Type Attributes::
6461 * x86 Type Attributes::
6462 @end menu
6464 @node Common Type Attributes
6465 @subsection Common Type Attributes
6467 The following type attributes are supported on most targets.
6469 @table @code
6470 @cindex @code{aligned} type attribute
6471 @item aligned (@var{alignment})
6472 This attribute specifies a minimum alignment (in bytes) for variables
6473 of the specified type.  For example, the declarations:
6475 @smallexample
6476 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6477 typedef int more_aligned_int __attribute__ ((aligned (8)));
6478 @end smallexample
6480 @noindent
6481 force the compiler to ensure (as far as it can) that each variable whose
6482 type is @code{struct S} or @code{more_aligned_int} is allocated and
6483 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6484 variables of type @code{struct S} aligned to 8-byte boundaries allows
6485 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6486 store) instructions when copying one variable of type @code{struct S} to
6487 another, thus improving run-time efficiency.
6489 Note that the alignment of any given @code{struct} or @code{union} type
6490 is required by the ISO C standard to be at least a perfect multiple of
6491 the lowest common multiple of the alignments of all of the members of
6492 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6493 effectively adjust the alignment of a @code{struct} or @code{union}
6494 type by attaching an @code{aligned} attribute to any one of the members
6495 of such a type, but the notation illustrated in the example above is a
6496 more obvious, intuitive, and readable way to request the compiler to
6497 adjust the alignment of an entire @code{struct} or @code{union} type.
6499 As in the preceding example, you can explicitly specify the alignment
6500 (in bytes) that you wish the compiler to use for a given @code{struct}
6501 or @code{union} type.  Alternatively, you can leave out the alignment factor
6502 and just ask the compiler to align a type to the maximum
6503 useful alignment for the target machine you are compiling for.  For
6504 example, you could write:
6506 @smallexample
6507 struct S @{ short f[3]; @} __attribute__ ((aligned));
6508 @end smallexample
6510 Whenever you leave out the alignment factor in an @code{aligned}
6511 attribute specification, the compiler automatically sets the alignment
6512 for the type to the largest alignment that is ever used for any data
6513 type on the target machine you are compiling for.  Doing this can often
6514 make copy operations more efficient, because the compiler can use
6515 whatever instructions copy the biggest chunks of memory when performing
6516 copies to or from the variables that have types that you have aligned
6517 this way.
6519 In the example above, if the size of each @code{short} is 2 bytes, then
6520 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6521 power of two that is greater than or equal to that is 8, so the
6522 compiler sets the alignment for the entire @code{struct S} type to 8
6523 bytes.
6525 Note that although you can ask the compiler to select a time-efficient
6526 alignment for a given type and then declare only individual stand-alone
6527 objects of that type, the compiler's ability to select a time-efficient
6528 alignment is primarily useful only when you plan to create arrays of
6529 variables having the relevant (efficiently aligned) type.  If you
6530 declare or use arrays of variables of an efficiently-aligned type, then
6531 it is likely that your program also does pointer arithmetic (or
6532 subscripting, which amounts to the same thing) on pointers to the
6533 relevant type, and the code that the compiler generates for these
6534 pointer arithmetic operations is often more efficient for
6535 efficiently-aligned types than for other types.
6537 Note that the effectiveness of @code{aligned} attributes may be limited
6538 by inherent limitations in your linker.  On many systems, the linker is
6539 only able to arrange for variables to be aligned up to a certain maximum
6540 alignment.  (For some linkers, the maximum supported alignment may
6541 be very very small.)  If your linker is only able to align variables
6542 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6543 in an @code{__attribute__} still only provides you with 8-byte
6544 alignment.  See your linker documentation for further information.
6546 The @code{aligned} attribute can only increase alignment.  Alignment
6547 can be decreased by specifying the @code{packed} attribute.  See below.
6549 @item bnd_variable_size
6550 @cindex @code{bnd_variable_size} type attribute
6551 @cindex Pointer Bounds Checker attributes
6552 When applied to a structure field, this attribute tells Pointer
6553 Bounds Checker that the size of this field should not be computed
6554 using static type information.  It may be used to mark variably-sized
6555 static array fields placed at the end of a structure.
6557 @smallexample
6558 struct S
6560   int size;
6561   char data[1];
6563 S *p = (S *)malloc (sizeof(S) + 100);
6564 p->data[10] = 0; //Bounds violation
6565 @end smallexample
6567 @noindent
6568 By using an attribute for the field we may avoid unwanted bound
6569 violation checks:
6571 @smallexample
6572 struct S
6574   int size;
6575   char data[1] __attribute__((bnd_variable_size));
6577 S *p = (S *)malloc (sizeof(S) + 100);
6578 p->data[10] = 0; //OK
6579 @end smallexample
6581 @item deprecated
6582 @itemx deprecated (@var{msg})
6583 @cindex @code{deprecated} type attribute
6584 The @code{deprecated} attribute results in a warning if the type
6585 is used anywhere in the source file.  This is useful when identifying
6586 types that are expected to be removed in a future version of a program.
6587 If possible, the warning also includes the location of the declaration
6588 of the deprecated type, to enable users to easily find further
6589 information about why the type is deprecated, or what they should do
6590 instead.  Note that the warnings only occur for uses and then only
6591 if the type is being applied to an identifier that itself is not being
6592 declared as deprecated.
6594 @smallexample
6595 typedef int T1 __attribute__ ((deprecated));
6596 T1 x;
6597 typedef T1 T2;
6598 T2 y;
6599 typedef T1 T3 __attribute__ ((deprecated));
6600 T3 z __attribute__ ((deprecated));
6601 @end smallexample
6603 @noindent
6604 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6605 warning is issued for line 4 because T2 is not explicitly
6606 deprecated.  Line 5 has no warning because T3 is explicitly
6607 deprecated.  Similarly for line 6.  The optional @var{msg}
6608 argument, which must be a string, is printed in the warning if
6609 present.
6611 The @code{deprecated} attribute can also be used for functions and
6612 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6614 @item designated_init
6615 @cindex @code{designated_init} type attribute
6616 This attribute may only be applied to structure types.  It indicates
6617 that any initialization of an object of this type must use designated
6618 initializers rather than positional initializers.  The intent of this
6619 attribute is to allow the programmer to indicate that a structure's
6620 layout may change, and that therefore relying on positional
6621 initialization will result in future breakage.
6623 GCC emits warnings based on this attribute by default; use
6624 @option{-Wno-designated-init} to suppress them.
6626 @item may_alias
6627 @cindex @code{may_alias} type attribute
6628 Accesses through pointers to types with this attribute are not subject
6629 to type-based alias analysis, but are instead assumed to be able to alias
6630 any other type of objects.
6631 In the context of section 6.5 paragraph 7 of the C99 standard,
6632 an lvalue expression
6633 dereferencing such a pointer is treated like having a character type.
6634 See @option{-fstrict-aliasing} for more information on aliasing issues.
6635 This extension exists to support some vector APIs, in which pointers to
6636 one vector type are permitted to alias pointers to a different vector type.
6638 Note that an object of a type with this attribute does not have any
6639 special semantics.
6641 Example of use:
6643 @smallexample
6644 typedef short __attribute__((__may_alias__)) short_a;
6647 main (void)
6649   int a = 0x12345678;
6650   short_a *b = (short_a *) &a;
6652   b[1] = 0;
6654   if (a == 0x12345678)
6655     abort();
6657   exit(0);
6659 @end smallexample
6661 @noindent
6662 If you replaced @code{short_a} with @code{short} in the variable
6663 declaration, the above program would abort when compiled with
6664 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6665 above.
6667 @item packed
6668 @cindex @code{packed} type attribute
6669 This attribute, attached to @code{struct} or @code{union} type
6670 definition, specifies that each member (other than zero-width bit-fields)
6671 of the structure or union is placed to minimize the memory required.  When
6672 attached to an @code{enum} definition, it indicates that the smallest
6673 integral type should be used.
6675 @opindex fshort-enums
6676 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6677 types is equivalent to specifying the @code{packed} attribute on each
6678 of the structure or union members.  Specifying the @option{-fshort-enums}
6679 flag on the command line is equivalent to specifying the @code{packed}
6680 attribute on all @code{enum} definitions.
6682 In the following example @code{struct my_packed_struct}'s members are
6683 packed closely together, but the internal layout of its @code{s} member
6684 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6685 be packed too.
6687 @smallexample
6688 struct my_unpacked_struct
6689  @{
6690     char c;
6691     int i;
6692  @};
6694 struct __attribute__ ((__packed__)) my_packed_struct
6695   @{
6696      char c;
6697      int  i;
6698      struct my_unpacked_struct s;
6699   @};
6700 @end smallexample
6702 You may only specify the @code{packed} attribute attribute on the definition
6703 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6704 that does not also define the enumerated type, structure or union.
6706 @item scalar_storage_order ("@var{endianness}")
6707 @cindex @code{scalar_storage_order} type attribute
6708 When attached to a @code{union} or a @code{struct}, this attribute sets
6709 the storage order, aka endianness, of the scalar fields of the type, as
6710 well as the array fields whose component is scalar.  The supported
6711 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
6712 has no effects on fields which are themselves a @code{union}, a @code{struct}
6713 or an array whose component is a @code{union} or a @code{struct}, and it is
6714 possible for these fields to have a different scalar storage order than the
6715 enclosing type.
6717 This attribute is supported only for targets that use a uniform default
6718 scalar storage order (fortunately, most of them), i.e. targets that store
6719 the scalars either all in big-endian or all in little-endian.
6721 Additional restrictions are enforced for types with the reverse scalar
6722 storage order with regard to the scalar storage order of the target:
6724 @itemize
6725 @item Taking the address of a scalar field of a @code{union} or a
6726 @code{struct} with reverse scalar storage order is not permitted and yields
6727 an error.
6728 @item Taking the address of an array field, whose component is scalar, of
6729 a @code{union} or a @code{struct} with reverse scalar storage order is
6730 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6731 is specified.
6732 @item Taking the address of a @code{union} or a @code{struct} with reverse
6733 scalar storage order is permitted.
6734 @end itemize
6736 These restrictions exist because the storage order attribute is lost when
6737 the address of a scalar or the address of an array with scalar component is
6738 taken, so storing indirectly through this address generally does not work.
6739 The second case is nevertheless allowed to be able to perform a block copy
6740 from or to the array.
6742 Moreover, the use of type punning or aliasing to toggle the storage order
6743 is not supported; that is to say, a given scalar object cannot be accessed
6744 through distinct types that assign a different storage order to it.
6746 @item transparent_union
6747 @cindex @code{transparent_union} type attribute
6749 This attribute, attached to a @code{union} type definition, indicates
6750 that any function parameter having that union type causes calls to that
6751 function to be treated in a special way.
6753 First, the argument corresponding to a transparent union type can be of
6754 any type in the union; no cast is required.  Also, if the union contains
6755 a pointer type, the corresponding argument can be a null pointer
6756 constant or a void pointer expression; and if the union contains a void
6757 pointer type, the corresponding argument can be any pointer expression.
6758 If the union member type is a pointer, qualifiers like @code{const} on
6759 the referenced type must be respected, just as with normal pointer
6760 conversions.
6762 Second, the argument is passed to the function using the calling
6763 conventions of the first member of the transparent union, not the calling
6764 conventions of the union itself.  All members of the union must have the
6765 same machine representation; this is necessary for this argument passing
6766 to work properly.
6768 Transparent unions are designed for library functions that have multiple
6769 interfaces for compatibility reasons.  For example, suppose the
6770 @code{wait} function must accept either a value of type @code{int *} to
6771 comply with POSIX, or a value of type @code{union wait *} to comply with
6772 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6773 @code{wait} would accept both kinds of arguments, but it would also
6774 accept any other pointer type and this would make argument type checking
6775 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6776 as follows:
6778 @smallexample
6779 typedef union __attribute__ ((__transparent_union__))
6780   @{
6781     int *__ip;
6782     union wait *__up;
6783   @} wait_status_ptr_t;
6785 pid_t wait (wait_status_ptr_t);
6786 @end smallexample
6788 @noindent
6789 This interface allows either @code{int *} or @code{union wait *}
6790 arguments to be passed, using the @code{int *} calling convention.
6791 The program can call @code{wait} with arguments of either type:
6793 @smallexample
6794 int w1 () @{ int w; return wait (&w); @}
6795 int w2 () @{ union wait w; return wait (&w); @}
6796 @end smallexample
6798 @noindent
6799 With this interface, @code{wait}'s implementation might look like this:
6801 @smallexample
6802 pid_t wait (wait_status_ptr_t p)
6804   return waitpid (-1, p.__ip, 0);
6806 @end smallexample
6808 @item unused
6809 @cindex @code{unused} type attribute
6810 When attached to a type (including a @code{union} or a @code{struct}),
6811 this attribute means that variables of that type are meant to appear
6812 possibly unused.  GCC does not produce a warning for any variables of
6813 that type, even if the variable appears to do nothing.  This is often
6814 the case with lock or thread classes, which are usually defined and then
6815 not referenced, but contain constructors and destructors that have
6816 nontrivial bookkeeping functions.
6818 @item visibility
6819 @cindex @code{visibility} type attribute
6820 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6821 applied to class, struct, union and enum types.  Unlike other type
6822 attributes, the attribute must appear between the initial keyword and
6823 the name of the type; it cannot appear after the body of the type.
6825 Note that the type visibility is applied to vague linkage entities
6826 associated with the class (vtable, typeinfo node, etc.).  In
6827 particular, if a class is thrown as an exception in one shared object
6828 and caught in another, the class must have default visibility.
6829 Otherwise the two shared objects are unable to use the same
6830 typeinfo node and exception handling will break.
6832 @end table
6834 To specify multiple attributes, separate them by commas within the
6835 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6836 packed))}.
6838 @node ARM Type Attributes
6839 @subsection ARM Type Attributes
6841 @cindex @code{notshared} type attribute, ARM
6842 On those ARM targets that support @code{dllimport} (such as Symbian
6843 OS), you can use the @code{notshared} attribute to indicate that the
6844 virtual table and other similar data for a class should not be
6845 exported from a DLL@.  For example:
6847 @smallexample
6848 class __declspec(notshared) C @{
6849 public:
6850   __declspec(dllimport) C();
6851   virtual void f();
6854 __declspec(dllexport)
6855 C::C() @{@}
6856 @end smallexample
6858 @noindent
6859 In this code, @code{C::C} is exported from the current DLL, but the
6860 virtual table for @code{C} is not exported.  (You can use
6861 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6862 most Symbian OS code uses @code{__declspec}.)
6864 @node MeP Type Attributes
6865 @subsection MeP Type Attributes
6867 @cindex @code{based} type attribute, MeP
6868 @cindex @code{tiny} type attribute, MeP
6869 @cindex @code{near} type attribute, MeP
6870 @cindex @code{far} type attribute, MeP
6871 Many of the MeP variable attributes may be applied to types as well.
6872 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6873 @code{far} attributes may be applied to either.  The @code{io} and
6874 @code{cb} attributes may not be applied to types.
6876 @node PowerPC Type Attributes
6877 @subsection PowerPC Type Attributes
6879 Three attributes currently are defined for PowerPC configurations:
6880 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6882 @cindex @code{ms_struct} type attribute, PowerPC
6883 @cindex @code{gcc_struct} type attribute, PowerPC
6884 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6885 attributes please see the documentation in @ref{x86 Type Attributes}.
6887 @cindex @code{altivec} type attribute, PowerPC
6888 The @code{altivec} attribute allows one to declare AltiVec vector data
6889 types supported by the AltiVec Programming Interface Manual.  The
6890 attribute requires an argument to specify one of three vector types:
6891 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6892 and @code{bool__} (always followed by unsigned).
6894 @smallexample
6895 __attribute__((altivec(vector__)))
6896 __attribute__((altivec(pixel__))) unsigned short
6897 __attribute__((altivec(bool__))) unsigned
6898 @end smallexample
6900 These attributes mainly are intended to support the @code{__vector},
6901 @code{__pixel}, and @code{__bool} AltiVec keywords.
6903 @node SPU Type Attributes
6904 @subsection SPU Type Attributes
6906 @cindex @code{spu_vector} type attribute, SPU
6907 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6908 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6909 Language Extensions Specification.  It is intended to support the
6910 @code{__vector} keyword.
6912 @node x86 Type Attributes
6913 @subsection x86 Type Attributes
6915 Two attributes are currently defined for x86 configurations:
6916 @code{ms_struct} and @code{gcc_struct}.
6918 @table @code
6920 @item ms_struct
6921 @itemx gcc_struct
6922 @cindex @code{ms_struct} type attribute, x86
6923 @cindex @code{gcc_struct} type attribute, x86
6925 If @code{packed} is used on a structure, or if bit-fields are used
6926 it may be that the Microsoft ABI packs them differently
6927 than GCC normally packs them.  Particularly when moving packed
6928 data between functions compiled with GCC and the native Microsoft compiler
6929 (either via function call or as data in a file), it may be necessary to access
6930 either format.
6932 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6933 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6934 command-line options, respectively;
6935 see @ref{x86 Options}, for details of how structure layout is affected.
6936 @xref{x86 Variable Attributes}, for information about the corresponding
6937 attributes on variables.
6939 @end table
6941 @node Label Attributes
6942 @section Label Attributes
6943 @cindex Label Attributes
6945 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
6946 details of the exact syntax for using attributes.  Other attributes are 
6947 available for functions (@pxref{Function Attributes}), variables 
6948 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6949 statements (@pxref{Statement Attributes}), and for types
6950 (@pxref{Type Attributes}).
6952 This example uses the @code{cold} label attribute to indicate the 
6953 @code{ErrorHandling} branch is unlikely to be taken and that the
6954 @code{ErrorHandling} label is unused:
6956 @smallexample
6958    asm goto ("some asm" : : : : NoError);
6960 /* This branch (the fall-through from the asm) is less commonly used */
6961 ErrorHandling: 
6962    __attribute__((cold, unused)); /* Semi-colon is required here */
6963    printf("error\n");
6964    return 0;
6966 NoError:
6967    printf("no error\n");
6968    return 1;
6969 @end smallexample
6971 @table @code
6972 @item unused
6973 @cindex @code{unused} label attribute
6974 This feature is intended for program-generated code that may contain 
6975 unused labels, but which is compiled with @option{-Wall}.  It is
6976 not normally appropriate to use in it human-written code, though it
6977 could be useful in cases where the code that jumps to the label is
6978 contained within an @code{#ifdef} conditional.
6980 @item hot
6981 @cindex @code{hot} label attribute
6982 The @code{hot} attribute on a label is used to inform the compiler that
6983 the path following the label is more likely than paths that are not so
6984 annotated.  This attribute is used in cases where @code{__builtin_expect}
6985 cannot be used, for instance with computed goto or @code{asm goto}.
6987 @item cold
6988 @cindex @code{cold} label attribute
6989 The @code{cold} attribute on labels is used to inform the compiler that
6990 the path following the label is unlikely to be executed.  This attribute
6991 is used in cases where @code{__builtin_expect} cannot be used, for instance
6992 with computed goto or @code{asm goto}.
6994 @end table
6996 @node Enumerator Attributes
6997 @section Enumerator Attributes
6998 @cindex Enumerator Attributes
7000 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7001 details of the exact syntax for using attributes.  Other attributes are
7002 available for functions (@pxref{Function Attributes}), variables
7003 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7004 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7006 This example uses the @code{deprecated} enumerator attribute to indicate the
7007 @code{oldval} enumerator is deprecated:
7009 @smallexample
7010 enum E @{
7011   oldval __attribute__((deprecated)),
7012   newval
7016 fn (void)
7018   return oldval;
7020 @end smallexample
7022 @table @code
7023 @item deprecated
7024 @cindex @code{deprecated} enumerator attribute
7025 The @code{deprecated} attribute results in a warning if the enumerator
7026 is used anywhere in the source file.  This is useful when identifying
7027 enumerators that are expected to be removed in a future version of a
7028 program.  The warning also includes the location of the declaration
7029 of the deprecated enumerator, to enable users to easily find further
7030 information about why the enumerator is deprecated, or what they should
7031 do instead.  Note that the warnings only occurs for uses.
7033 @end table
7035 @node Statement Attributes
7036 @section Statement Attributes
7037 @cindex Statement Attributes
7039 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7040 for details of the exact syntax for using attributes.  Other attributes are
7041 available for functions (@pxref{Function Attributes}), variables
7042 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7043 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7045 This example uses the @code{fallthrough} statement attribute to indicate that
7046 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7048 @smallexample
7049 switch (cond)
7050   @{
7051   case 1:
7052     bar (1);
7053     __attribute__((fallthrough));
7054   case 2:
7055     @dots{}
7056   @}
7057 @end smallexample
7059 @table @code
7060 @item fallthrough
7061 @cindex @code{fallthrough} statement attribute
7062 The @code{fallthrough} attribute with a null statement serves as a
7063 fallthrough statement.  It hints to the compiler that a statement
7064 that falls through to another case label, or user-defined label
7065 in a switch statement is intentional and thus the
7066 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7067 fallthrough attribute may appear at most once in each attribute
7068 list, and may not be mixed with other attributes.  It can only
7069 be used in a switch statement (the compiler will issue an error
7070 otherwise), after a preceding statement and before a logically
7071 succeeding case label, or user-defined label.
7073 @end table
7075 @node Attribute Syntax
7076 @section Attribute Syntax
7077 @cindex attribute syntax
7079 This section describes the syntax with which @code{__attribute__} may be
7080 used, and the constructs to which attribute specifiers bind, for the C
7081 language.  Some details may vary for C++ and Objective-C@.  Because of
7082 infelicities in the grammar for attributes, some forms described here
7083 may not be successfully parsed in all cases.
7085 There are some problems with the semantics of attributes in C++.  For
7086 example, there are no manglings for attributes, although they may affect
7087 code generation, so problems may arise when attributed types are used in
7088 conjunction with templates or overloading.  Similarly, @code{typeid}
7089 does not distinguish between types with different attributes.  Support
7090 for attributes in C++ may be restricted in future to attributes on
7091 declarations only, but not on nested declarators.
7093 @xref{Function Attributes}, for details of the semantics of attributes
7094 applying to functions.  @xref{Variable Attributes}, for details of the
7095 semantics of attributes applying to variables.  @xref{Type Attributes},
7096 for details of the semantics of attributes applying to structure, union
7097 and enumerated types.
7098 @xref{Label Attributes}, for details of the semantics of attributes 
7099 applying to labels.
7100 @xref{Enumerator Attributes}, for details of the semantics of attributes
7101 applying to enumerators.
7102 @xref{Statement Attributes}, for details of the semantics of attributes
7103 applying to statements.
7105 An @dfn{attribute specifier} is of the form
7106 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7107 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7108 each attribute is one of the following:
7110 @itemize @bullet
7111 @item
7112 Empty.  Empty attributes are ignored.
7114 @item
7115 An attribute name
7116 (which may be an identifier such as @code{unused}, or a reserved
7117 word such as @code{const}).
7119 @item
7120 An attribute name followed by a parenthesized list of
7121 parameters for the attribute.
7122 These parameters take one of the following forms:
7124 @itemize @bullet
7125 @item
7126 An identifier.  For example, @code{mode} attributes use this form.
7128 @item
7129 An identifier followed by a comma and a non-empty comma-separated list
7130 of expressions.  For example, @code{format} attributes use this form.
7132 @item
7133 A possibly empty comma-separated list of expressions.  For example,
7134 @code{format_arg} attributes use this form with the list being a single
7135 integer constant expression, and @code{alias} attributes use this form
7136 with the list being a single string constant.
7137 @end itemize
7138 @end itemize
7140 An @dfn{attribute specifier list} is a sequence of one or more attribute
7141 specifiers, not separated by any other tokens.
7143 You may optionally specify attribute names with @samp{__}
7144 preceding and following the name.
7145 This allows you to use them in header files without
7146 being concerned about a possible macro of the same name.  For example,
7147 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7150 @subsubheading Label Attributes
7152 In GNU C, an attribute specifier list may appear after the colon following a
7153 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7154 attributes on labels if the attribute specifier is immediately
7155 followed by a semicolon (i.e., the label applies to an empty
7156 statement).  If the semicolon is missing, C++ label attributes are
7157 ambiguous, as it is permissible for a declaration, which could begin
7158 with an attribute list, to be labelled in C++.  Declarations cannot be
7159 labelled in C90 or C99, so the ambiguity does not arise there.
7161 @subsubheading Enumerator Attributes
7163 In GNU C, an attribute specifier list may appear as part of an enumerator.
7164 The attribute goes after the enumeration constant, before @code{=}, if
7165 present.  The optional attribute in the enumerator appertains to the
7166 enumeration constant.  It is not possible to place the attribute after
7167 the constant expression, if present.
7169 @subsubheading Statement Attributes
7170 In GNU C, an attribute specifier list may appear as part of a null
7171 statement.  The attribute goes before the semicolon.
7173 @subsubheading Type Attributes
7175 An attribute specifier list may appear as part of a @code{struct},
7176 @code{union} or @code{enum} specifier.  It may go either immediately
7177 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7178 the closing brace.  The former syntax is preferred.
7179 Where attribute specifiers follow the closing brace, they are considered
7180 to relate to the structure, union or enumerated type defined, not to any
7181 enclosing declaration the type specifier appears in, and the type
7182 defined is not complete until after the attribute specifiers.
7183 @c Otherwise, there would be the following problems: a shift/reduce
7184 @c conflict between attributes binding the struct/union/enum and
7185 @c binding to the list of specifiers/qualifiers; and "aligned"
7186 @c attributes could use sizeof for the structure, but the size could be
7187 @c changed later by "packed" attributes.
7190 @subsubheading All other attributes
7192 Otherwise, an attribute specifier appears as part of a declaration,
7193 counting declarations of unnamed parameters and type names, and relates
7194 to that declaration (which may be nested in another declaration, for
7195 example in the case of a parameter declaration), or to a particular declarator
7196 within a declaration.  Where an
7197 attribute specifier is applied to a parameter declared as a function or
7198 an array, it should apply to the function or array rather than the
7199 pointer to which the parameter is implicitly converted, but this is not
7200 yet correctly implemented.
7202 Any list of specifiers and qualifiers at the start of a declaration may
7203 contain attribute specifiers, whether or not such a list may in that
7204 context contain storage class specifiers.  (Some attributes, however,
7205 are essentially in the nature of storage class specifiers, and only make
7206 sense where storage class specifiers may be used; for example,
7207 @code{section}.)  There is one necessary limitation to this syntax: the
7208 first old-style parameter declaration in a function definition cannot
7209 begin with an attribute specifier, because such an attribute applies to
7210 the function instead by syntax described below (which, however, is not
7211 yet implemented in this case).  In some other cases, attribute
7212 specifiers are permitted by this grammar but not yet supported by the
7213 compiler.  All attribute specifiers in this place relate to the
7214 declaration as a whole.  In the obsolescent usage where a type of
7215 @code{int} is implied by the absence of type specifiers, such a list of
7216 specifiers and qualifiers may be an attribute specifier list with no
7217 other specifiers or qualifiers.
7219 At present, the first parameter in a function prototype must have some
7220 type specifier that is not an attribute specifier; this resolves an
7221 ambiguity in the interpretation of @code{void f(int
7222 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7223 the parentheses of a function declarator contain only attributes then
7224 those attributes are ignored, rather than yielding an error or warning
7225 or implying a single parameter of type int, but this is subject to
7226 change.
7228 An attribute specifier list may appear immediately before a declarator
7229 (other than the first) in a comma-separated list of declarators in a
7230 declaration of more than one identifier using a single list of
7231 specifiers and qualifiers.  Such attribute specifiers apply
7232 only to the identifier before whose declarator they appear.  For
7233 example, in
7235 @smallexample
7236 __attribute__((noreturn)) void d0 (void),
7237     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7238      d2 (void);
7239 @end smallexample
7241 @noindent
7242 the @code{noreturn} attribute applies to all the functions
7243 declared; the @code{format} attribute only applies to @code{d1}.
7245 An attribute specifier list may appear immediately before the comma,
7246 @code{=} or semicolon terminating the declaration of an identifier other
7247 than a function definition.  Such attribute specifiers apply
7248 to the declared object or function.  Where an
7249 assembler name for an object or function is specified (@pxref{Asm
7250 Labels}), the attribute must follow the @code{asm}
7251 specification.
7253 An attribute specifier list may, in future, be permitted to appear after
7254 the declarator in a function definition (before any old-style parameter
7255 declarations or the function body).
7257 Attribute specifiers may be mixed with type qualifiers appearing inside
7258 the @code{[]} of a parameter array declarator, in the C99 construct by
7259 which such qualifiers are applied to the pointer to which the array is
7260 implicitly converted.  Such attribute specifiers apply to the pointer,
7261 not to the array, but at present this is not implemented and they are
7262 ignored.
7264 An attribute specifier list may appear at the start of a nested
7265 declarator.  At present, there are some limitations in this usage: the
7266 attributes correctly apply to the declarator, but for most individual
7267 attributes the semantics this implies are not implemented.
7268 When attribute specifiers follow the @code{*} of a pointer
7269 declarator, they may be mixed with any type qualifiers present.
7270 The following describes the formal semantics of this syntax.  It makes the
7271 most sense if you are familiar with the formal specification of
7272 declarators in the ISO C standard.
7274 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7275 D1}, where @code{T} contains declaration specifiers that specify a type
7276 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7277 contains an identifier @var{ident}.  The type specified for @var{ident}
7278 for derived declarators whose type does not include an attribute
7279 specifier is as in the ISO C standard.
7281 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7282 and the declaration @code{T D} specifies the type
7283 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7284 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7285 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7287 If @code{D1} has the form @code{*
7288 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7289 declaration @code{T D} specifies the type
7290 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7291 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7292 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7293 @var{ident}.
7295 For example,
7297 @smallexample
7298 void (__attribute__((noreturn)) ****f) (void);
7299 @end smallexample
7301 @noindent
7302 specifies the type ``pointer to pointer to pointer to pointer to
7303 non-returning function returning @code{void}''.  As another example,
7305 @smallexample
7306 char *__attribute__((aligned(8))) *f;
7307 @end smallexample
7309 @noindent
7310 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7311 Note again that this does not work with most attributes; for example,
7312 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7313 is not yet supported.
7315 For compatibility with existing code written for compiler versions that
7316 did not implement attributes on nested declarators, some laxity is
7317 allowed in the placing of attributes.  If an attribute that only applies
7318 to types is applied to a declaration, it is treated as applying to
7319 the type of that declaration.  If an attribute that only applies to
7320 declarations is applied to the type of a declaration, it is treated
7321 as applying to that declaration; and, for compatibility with code
7322 placing the attributes immediately before the identifier declared, such
7323 an attribute applied to a function return type is treated as
7324 applying to the function type, and such an attribute applied to an array
7325 element type is treated as applying to the array type.  If an
7326 attribute that only applies to function types is applied to a
7327 pointer-to-function type, it is treated as applying to the pointer
7328 target type; if such an attribute is applied to a function return type
7329 that is not a pointer-to-function type, it is treated as applying
7330 to the function type.
7332 @node Function Prototypes
7333 @section Prototypes and Old-Style Function Definitions
7334 @cindex function prototype declarations
7335 @cindex old-style function definitions
7336 @cindex promotion of formal parameters
7338 GNU C extends ISO C to allow a function prototype to override a later
7339 old-style non-prototype definition.  Consider the following example:
7341 @smallexample
7342 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7343 #ifdef __STDC__
7344 #define P(x) x
7345 #else
7346 #define P(x) ()
7347 #endif
7349 /* @r{Prototype function declaration.}  */
7350 int isroot P((uid_t));
7352 /* @r{Old-style function definition.}  */
7354 isroot (x)   /* @r{??? lossage here ???} */
7355      uid_t x;
7357   return x == 0;
7359 @end smallexample
7361 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7362 not allow this example, because subword arguments in old-style
7363 non-prototype definitions are promoted.  Therefore in this example the
7364 function definition's argument is really an @code{int}, which does not
7365 match the prototype argument type of @code{short}.
7367 This restriction of ISO C makes it hard to write code that is portable
7368 to traditional C compilers, because the programmer does not know
7369 whether the @code{uid_t} type is @code{short}, @code{int}, or
7370 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7371 to override a later old-style definition.  More precisely, in GNU C, a
7372 function prototype argument type overrides the argument type specified
7373 by a later old-style definition if the former type is the same as the
7374 latter type before promotion.  Thus in GNU C the above example is
7375 equivalent to the following:
7377 @smallexample
7378 int isroot (uid_t);
7381 isroot (uid_t x)
7383   return x == 0;
7385 @end smallexample
7387 @noindent
7388 GNU C++ does not support old-style function definitions, so this
7389 extension is irrelevant.
7391 @node C++ Comments
7392 @section C++ Style Comments
7393 @cindex @code{//}
7394 @cindex C++ comments
7395 @cindex comments, C++ style
7397 In GNU C, you may use C++ style comments, which start with @samp{//} and
7398 continue until the end of the line.  Many other C implementations allow
7399 such comments, and they are included in the 1999 C standard.  However,
7400 C++ style comments are not recognized if you specify an @option{-std}
7401 option specifying a version of ISO C before C99, or @option{-ansi}
7402 (equivalent to @option{-std=c90}).
7404 @node Dollar Signs
7405 @section Dollar Signs in Identifier Names
7406 @cindex $
7407 @cindex dollar signs in identifier names
7408 @cindex identifier names, dollar signs in
7410 In GNU C, you may normally use dollar signs in identifier names.
7411 This is because many traditional C implementations allow such identifiers.
7412 However, dollar signs in identifiers are not supported on a few target
7413 machines, typically because the target assembler does not allow them.
7415 @node Character Escapes
7416 @section The Character @key{ESC} in Constants
7418 You can use the sequence @samp{\e} in a string or character constant to
7419 stand for the ASCII character @key{ESC}.
7421 @node Alignment
7422 @section Inquiring on Alignment of Types or Variables
7423 @cindex alignment
7424 @cindex type alignment
7425 @cindex variable alignment
7427 The keyword @code{__alignof__} allows you to inquire about how an object
7428 is aligned, or the minimum alignment usually required by a type.  Its
7429 syntax is just like @code{sizeof}.
7431 For example, if the target machine requires a @code{double} value to be
7432 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7433 This is true on many RISC machines.  On more traditional machine
7434 designs, @code{__alignof__ (double)} is 4 or even 2.
7436 Some machines never actually require alignment; they allow reference to any
7437 data type even at an odd address.  For these machines, @code{__alignof__}
7438 reports the smallest alignment that GCC gives the data type, usually as
7439 mandated by the target ABI.
7441 If the operand of @code{__alignof__} is an lvalue rather than a type,
7442 its value is the required alignment for its type, taking into account
7443 any minimum alignment specified with GCC's @code{__attribute__}
7444 extension (@pxref{Variable Attributes}).  For example, after this
7445 declaration:
7447 @smallexample
7448 struct foo @{ int x; char y; @} foo1;
7449 @end smallexample
7451 @noindent
7452 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7453 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7455 It is an error to ask for the alignment of an incomplete type.
7458 @node Inline
7459 @section An Inline Function is As Fast As a Macro
7460 @cindex inline functions
7461 @cindex integrating function code
7462 @cindex open coding
7463 @cindex macros, inline alternative
7465 By declaring a function inline, you can direct GCC to make
7466 calls to that function faster.  One way GCC can achieve this is to
7467 integrate that function's code into the code for its callers.  This
7468 makes execution faster by eliminating the function-call overhead; in
7469 addition, if any of the actual argument values are constant, their
7470 known values may permit simplifications at compile time so that not
7471 all of the inline function's code needs to be included.  The effect on
7472 code size is less predictable; object code may be larger or smaller
7473 with function inlining, depending on the particular case.  You can
7474 also direct GCC to try to integrate all ``simple enough'' functions
7475 into their callers with the option @option{-finline-functions}.
7477 GCC implements three different semantics of declaring a function
7478 inline.  One is available with @option{-std=gnu89} or
7479 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7480 on all inline declarations, another when
7481 @option{-std=c99}, @option{-std=c11},
7482 @option{-std=gnu99} or @option{-std=gnu11}
7483 (without @option{-fgnu89-inline}), and the third
7484 is used when compiling C++.
7486 To declare a function inline, use the @code{inline} keyword in its
7487 declaration, like this:
7489 @smallexample
7490 static inline int
7491 inc (int *a)
7493   return (*a)++;
7495 @end smallexample
7497 If you are writing a header file to be included in ISO C90 programs, write
7498 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7500 The three types of inlining behave similarly in two important cases:
7501 when the @code{inline} keyword is used on a @code{static} function,
7502 like the example above, and when a function is first declared without
7503 using the @code{inline} keyword and then is defined with
7504 @code{inline}, like this:
7506 @smallexample
7507 extern int inc (int *a);
7508 inline int
7509 inc (int *a)
7511   return (*a)++;
7513 @end smallexample
7515 In both of these common cases, the program behaves the same as if you
7516 had not used the @code{inline} keyword, except for its speed.
7518 @cindex inline functions, omission of
7519 @opindex fkeep-inline-functions
7520 When a function is both inline and @code{static}, if all calls to the
7521 function are integrated into the caller, and the function's address is
7522 never used, then the function's own assembler code is never referenced.
7523 In this case, GCC does not actually output assembler code for the
7524 function, unless you specify the option @option{-fkeep-inline-functions}.
7525 If there is a nonintegrated call, then the function is compiled to
7526 assembler code as usual.  The function must also be compiled as usual if
7527 the program refers to its address, because that cannot be inlined.
7529 @opindex Winline
7530 Note that certain usages in a function definition can make it unsuitable
7531 for inline substitution.  Among these usages are: variadic functions,
7532 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7533 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7534 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7535 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7536 function marked @code{inline} could not be substituted, and gives the
7537 reason for the failure.
7539 @cindex automatic @code{inline} for C++ member fns
7540 @cindex @code{inline} automatic for C++ member fns
7541 @cindex member fns, automatically @code{inline}
7542 @cindex C++ member fns, automatically @code{inline}
7543 @opindex fno-default-inline
7544 As required by ISO C++, GCC considers member functions defined within
7545 the body of a class to be marked inline even if they are
7546 not explicitly declared with the @code{inline} keyword.  You can
7547 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7548 Options,,Options Controlling C++ Dialect}.
7550 GCC does not inline any functions when not optimizing unless you specify
7551 the @samp{always_inline} attribute for the function, like this:
7553 @smallexample
7554 /* @r{Prototype.}  */
7555 inline void foo (const char) __attribute__((always_inline));
7556 @end smallexample
7558 The remainder of this section is specific to GNU C90 inlining.
7560 @cindex non-static inline function
7561 When an inline function is not @code{static}, then the compiler must assume
7562 that there may be calls from other source files; since a global symbol can
7563 be defined only once in any program, the function must not be defined in
7564 the other source files, so the calls therein cannot be integrated.
7565 Therefore, a non-@code{static} inline function is always compiled on its
7566 own in the usual fashion.
7568 If you specify both @code{inline} and @code{extern} in the function
7569 definition, then the definition is used only for inlining.  In no case
7570 is the function compiled on its own, not even if you refer to its
7571 address explicitly.  Such an address becomes an external reference, as
7572 if you had only declared the function, and had not defined it.
7574 This combination of @code{inline} and @code{extern} has almost the
7575 effect of a macro.  The way to use it is to put a function definition in
7576 a header file with these keywords, and put another copy of the
7577 definition (lacking @code{inline} and @code{extern}) in a library file.
7578 The definition in the header file causes most calls to the function
7579 to be inlined.  If any uses of the function remain, they refer to
7580 the single copy in the library.
7582 @node Volatiles
7583 @section When is a Volatile Object Accessed?
7584 @cindex accessing volatiles
7585 @cindex volatile read
7586 @cindex volatile write
7587 @cindex volatile access
7589 C has the concept of volatile objects.  These are normally accessed by
7590 pointers and used for accessing hardware or inter-thread
7591 communication.  The standard encourages compilers to refrain from
7592 optimizations concerning accesses to volatile objects, but leaves it
7593 implementation defined as to what constitutes a volatile access.  The
7594 minimum requirement is that at a sequence point all previous accesses
7595 to volatile objects have stabilized and no subsequent accesses have
7596 occurred.  Thus an implementation is free to reorder and combine
7597 volatile accesses that occur between sequence points, but cannot do
7598 so for accesses across a sequence point.  The use of volatile does
7599 not allow you to violate the restriction on updating objects multiple
7600 times between two sequence points.
7602 Accesses to non-volatile objects are not ordered with respect to
7603 volatile accesses.  You cannot use a volatile object as a memory
7604 barrier to order a sequence of writes to non-volatile memory.  For
7605 instance:
7607 @smallexample
7608 int *ptr = @var{something};
7609 volatile int vobj;
7610 *ptr = @var{something};
7611 vobj = 1;
7612 @end smallexample
7614 @noindent
7615 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7616 that the write to @var{*ptr} occurs by the time the update
7617 of @var{vobj} happens.  If you need this guarantee, you must use
7618 a stronger memory barrier such as:
7620 @smallexample
7621 int *ptr = @var{something};
7622 volatile int vobj;
7623 *ptr = @var{something};
7624 asm volatile ("" : : : "memory");
7625 vobj = 1;
7626 @end smallexample
7628 A scalar volatile object is read when it is accessed in a void context:
7630 @smallexample
7631 volatile int *src = @var{somevalue};
7632 *src;
7633 @end smallexample
7635 Such expressions are rvalues, and GCC implements this as a
7636 read of the volatile object being pointed to.
7638 Assignments are also expressions and have an rvalue.  However when
7639 assigning to a scalar volatile, the volatile object is not reread,
7640 regardless of whether the assignment expression's rvalue is used or
7641 not.  If the assignment's rvalue is used, the value is that assigned
7642 to the volatile object.  For instance, there is no read of @var{vobj}
7643 in all the following cases:
7645 @smallexample
7646 int obj;
7647 volatile int vobj;
7648 vobj = @var{something};
7649 obj = vobj = @var{something};
7650 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7651 obj = (@var{something}, vobj = @var{anotherthing});
7652 @end smallexample
7654 If you need to read the volatile object after an assignment has
7655 occurred, you must use a separate expression with an intervening
7656 sequence point.
7658 As bit-fields are not individually addressable, volatile bit-fields may
7659 be implicitly read when written to, or when adjacent bit-fields are
7660 accessed.  Bit-field operations may be optimized such that adjacent
7661 bit-fields are only partially accessed, if they straddle a storage unit
7662 boundary.  For these reasons it is unwise to use volatile bit-fields to
7663 access hardware.
7665 @node Using Assembly Language with C
7666 @section How to Use Inline Assembly Language in C Code
7667 @cindex @code{asm} keyword
7668 @cindex assembly language in C
7669 @cindex inline assembly language
7670 @cindex mixing assembly language and C
7672 The @code{asm} keyword allows you to embed assembler instructions
7673 within C code.  GCC provides two forms of inline @code{asm}
7674 statements.  A @dfn{basic @code{asm}} statement is one with no
7675 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7676 statement (@pxref{Extended Asm}) includes one or more operands.  
7677 The extended form is preferred for mixing C and assembly language
7678 within a function, but to include assembly language at
7679 top level you must use basic @code{asm}.
7681 You can also use the @code{asm} keyword to override the assembler name
7682 for a C symbol, or to place a C variable in a specific register.
7684 @menu
7685 * Basic Asm::          Inline assembler without operands.
7686 * Extended Asm::       Inline assembler with operands.
7687 * Constraints::        Constraints for @code{asm} operands
7688 * Asm Labels::         Specifying the assembler name to use for a C symbol.
7689 * Explicit Register Variables::  Defining variables residing in specified 
7690                        registers.
7691 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
7692 @end menu
7694 @node Basic Asm
7695 @subsection Basic Asm --- Assembler Instructions Without Operands
7696 @cindex basic @code{asm}
7697 @cindex assembly language in C, basic
7699 A basic @code{asm} statement has the following syntax:
7701 @example
7702 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7703 @end example
7705 The @code{asm} keyword is a GNU extension.
7706 When writing code that can be compiled with @option{-ansi} and the
7707 various @option{-std} options, use @code{__asm__} instead of 
7708 @code{asm} (@pxref{Alternate Keywords}).
7710 @subsubheading Qualifiers
7711 @table @code
7712 @item volatile
7713 The optional @code{volatile} qualifier has no effect. 
7714 All basic @code{asm} blocks are implicitly volatile.
7715 @end table
7717 @subsubheading Parameters
7718 @table @var
7720 @item AssemblerInstructions
7721 This is a literal string that specifies the assembler code. The string can 
7722 contain any instructions recognized by the assembler, including directives. 
7723 GCC does not parse the assembler instructions themselves and 
7724 does not know what they mean or even whether they are valid assembler input. 
7726 You may place multiple assembler instructions together in a single @code{asm} 
7727 string, separated by the characters normally used in assembly code for the 
7728 system. A combination that works in most places is a newline to break the 
7729 line, plus a tab character (written as @samp{\n\t}).
7730 Some assemblers allow semicolons as a line separator. However, 
7731 note that some assembler dialects use semicolons to start a comment. 
7732 @end table
7734 @subsubheading Remarks
7735 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7736 smaller, safer, and more efficient code, and in most cases it is a
7737 better solution than basic @code{asm}.  However, there are two
7738 situations where only basic @code{asm} can be used:
7740 @itemize @bullet
7741 @item
7742 Extended @code{asm} statements have to be inside a C
7743 function, so to write inline assembly language at file scope (``top-level''),
7744 outside of C functions, you must use basic @code{asm}.
7745 You can use this technique to emit assembler directives,
7746 define assembly language macros that can be invoked elsewhere in the file,
7747 or write entire functions in assembly language.
7749 @item
7750 Functions declared
7751 with the @code{naked} attribute also require basic @code{asm}
7752 (@pxref{Function Attributes}).
7753 @end itemize
7755 Safely accessing C data and calling functions from basic @code{asm} is more 
7756 complex than it may appear. To access C data, it is better to use extended 
7757 @code{asm}.
7759 Do not expect a sequence of @code{asm} statements to remain perfectly 
7760 consecutive after compilation. If certain instructions need to remain 
7761 consecutive in the output, put them in a single multi-instruction @code{asm}
7762 statement. Note that GCC's optimizers can move @code{asm} statements 
7763 relative to other code, including across jumps.
7765 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7766 GCC does not know about these jumps, and therefore cannot take 
7767 account of them when deciding how to optimize. Jumps from @code{asm} to C 
7768 labels are only supported in extended @code{asm}.
7770 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7771 assembly code when optimizing. This can lead to unexpected duplicate 
7772 symbol errors during compilation if your assembly code defines symbols or 
7773 labels.
7775 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7776 making it a potential source of incompatibilities between compilers.  These
7777 incompatibilities may not produce compiler warnings/errors.
7779 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7780 means there is no way to communicate to the compiler what is happening
7781 inside them.  GCC has no visibility of symbols in the @code{asm} and may
7782 discard them as unreferenced.  It also does not know about side effects of
7783 the assembler code, such as modifications to memory or registers.  Unlike
7784 some compilers, GCC assumes that no changes to general purpose registers
7785 occur.  This assumption may change in a future release.
7787 To avoid complications from future changes to the semantics and the
7788 compatibility issues between compilers, consider replacing basic @code{asm}
7789 with extended @code{asm}.  See
7790 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7791 from basic asm to extended asm} for information about how to perform this
7792 conversion.
7794 The compiler copies the assembler instructions in a basic @code{asm} 
7795 verbatim to the assembly language output file, without 
7796 processing dialects or any of the @samp{%} operators that are available with
7797 extended @code{asm}. This results in minor differences between basic 
7798 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7799 registers you might use @samp{%eax} in basic @code{asm} and
7800 @samp{%%eax} in extended @code{asm}.
7802 On targets such as x86 that support multiple assembler dialects,
7803 all basic @code{asm} blocks use the assembler dialect specified by the 
7804 @option{-masm} command-line option (@pxref{x86 Options}).  
7805 Basic @code{asm} provides no
7806 mechanism to provide different assembler strings for different dialects.
7808 For basic @code{asm} with non-empty assembler string GCC assumes
7809 the assembler block does not change any general purpose registers,
7810 but it may read or write any globally accessible variable.
7812 Here is an example of basic @code{asm} for i386:
7814 @example
7815 /* Note that this code will not compile with -masm=intel */
7816 #define DebugBreak() asm("int $3")
7817 @end example
7819 @node Extended Asm
7820 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7821 @cindex extended @code{asm}
7822 @cindex assembly language in C, extended
7824 With extended @code{asm} you can read and write C variables from 
7825 assembler and perform jumps from assembler code to C labels.  
7826 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7827 the operand parameters after the assembler template:
7829 @example
7830 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7831                  : @var{OutputOperands} 
7832                  @r{[} : @var{InputOperands}
7833                  @r{[} : @var{Clobbers} @r{]} @r{]})
7835 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7836                       : 
7837                       : @var{InputOperands}
7838                       : @var{Clobbers}
7839                       : @var{GotoLabels})
7840 @end example
7842 The @code{asm} keyword is a GNU extension.
7843 When writing code that can be compiled with @option{-ansi} and the
7844 various @option{-std} options, use @code{__asm__} instead of 
7845 @code{asm} (@pxref{Alternate Keywords}).
7847 @subsubheading Qualifiers
7848 @table @code
7850 @item volatile
7851 The typical use of extended @code{asm} statements is to manipulate input 
7852 values to produce output values. However, your @code{asm} statements may 
7853 also produce side effects. If so, you may need to use the @code{volatile} 
7854 qualifier to disable certain optimizations. @xref{Volatile}.
7856 @item goto
7857 This qualifier informs the compiler that the @code{asm} statement may 
7858 perform a jump to one of the labels listed in the @var{GotoLabels}.
7859 @xref{GotoLabels}.
7860 @end table
7862 @subsubheading Parameters
7863 @table @var
7864 @item AssemblerTemplate
7865 This is a literal string that is the template for the assembler code. It is a 
7866 combination of fixed text and tokens that refer to the input, output, 
7867 and goto parameters. @xref{AssemblerTemplate}.
7869 @item OutputOperands
7870 A comma-separated list of the C variables modified by the instructions in the 
7871 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7873 @item InputOperands
7874 A comma-separated list of C expressions read by the instructions in the 
7875 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7877 @item Clobbers
7878 A comma-separated list of registers or other values changed by the 
7879 @var{AssemblerTemplate}, beyond those listed as outputs.
7880 An empty list is permitted.  @xref{Clobbers}.
7882 @item GotoLabels
7883 When you are using the @code{goto} form of @code{asm}, this section contains 
7884 the list of all C labels to which the code in the 
7885 @var{AssemblerTemplate} may jump. 
7886 @xref{GotoLabels}.
7888 @code{asm} statements may not perform jumps into other @code{asm} statements,
7889 only to the listed @var{GotoLabels}.
7890 GCC's optimizers do not know about other jumps; therefore they cannot take 
7891 account of them when deciding how to optimize.
7892 @end table
7894 The total number of input + output + goto operands is limited to 30.
7896 @subsubheading Remarks
7897 The @code{asm} statement allows you to include assembly instructions directly 
7898 within C code. This may help you to maximize performance in time-sensitive 
7899 code or to access assembly instructions that are not readily available to C 
7900 programs.
7902 Note that extended @code{asm} statements must be inside a function. Only 
7903 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7904 Functions declared with the @code{naked} attribute also require basic 
7905 @code{asm} (@pxref{Function Attributes}).
7907 While the uses of @code{asm} are many and varied, it may help to think of an 
7908 @code{asm} statement as a series of low-level instructions that convert input 
7909 parameters to output parameters. So a simple (if not particularly useful) 
7910 example for i386 using @code{asm} might look like this:
7912 @example
7913 int src = 1;
7914 int dst;   
7916 asm ("mov %1, %0\n\t"
7917     "add $1, %0"
7918     : "=r" (dst) 
7919     : "r" (src));
7921 printf("%d\n", dst);
7922 @end example
7924 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7926 @anchor{Volatile}
7927 @subsubsection Volatile
7928 @cindex volatile @code{asm}
7929 @cindex @code{asm} volatile
7931 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7932 there is no need for the output variables. Also, the optimizers may move 
7933 code out of loops if they believe that the code will always return the same 
7934 result (i.e. none of its input values change between calls). Using the 
7935 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7936 that have no output operands, including @code{asm goto} statements, 
7937 are implicitly volatile.
7939 This i386 code demonstrates a case that does not use (or require) the 
7940 @code{volatile} qualifier. If it is performing assertion checking, this code 
7941 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7942 unreferenced by any code. As a result, the optimizers can discard the 
7943 @code{asm} statement, which in turn removes the need for the entire 
7944 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7945 isn't needed you allow the optimizers to produce the most efficient code 
7946 possible.
7948 @example
7949 void DoCheck(uint32_t dwSomeValue)
7951    uint32_t dwRes;
7953    // Assumes dwSomeValue is not zero.
7954    asm ("bsfl %1,%0"
7955      : "=r" (dwRes)
7956      : "r" (dwSomeValue)
7957      : "cc");
7959    assert(dwRes > 3);
7961 @end example
7963 The next example shows a case where the optimizers can recognize that the input 
7964 (@code{dwSomeValue}) never changes during the execution of the function and can 
7965 therefore move the @code{asm} outside the loop to produce more efficient code. 
7966 Again, using @code{volatile} disables this type of optimization.
7968 @example
7969 void do_print(uint32_t dwSomeValue)
7971    uint32_t dwRes;
7973    for (uint32_t x=0; x < 5; x++)
7974    @{
7975       // Assumes dwSomeValue is not zero.
7976       asm ("bsfl %1,%0"
7977         : "=r" (dwRes)
7978         : "r" (dwSomeValue)
7979         : "cc");
7981       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7982    @}
7984 @end example
7986 The following example demonstrates a case where you need to use the 
7987 @code{volatile} qualifier. 
7988 It uses the x86 @code{rdtsc} instruction, which reads 
7989 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
7990 the optimizers might assume that the @code{asm} block will always return the 
7991 same value and therefore optimize away the second call.
7993 @example
7994 uint64_t msr;
7996 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7997         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7998         "or %%rdx, %0"        // 'Or' in the lower bits.
7999         : "=a" (msr)
8000         : 
8001         : "rdx");
8003 printf("msr: %llx\n", msr);
8005 // Do other work...
8007 // Reprint the timestamp
8008 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8009         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8010         "or %%rdx, %0"        // 'Or' in the lower bits.
8011         : "=a" (msr)
8012         : 
8013         : "rdx");
8015 printf("msr: %llx\n", msr);
8016 @end example
8018 GCC's optimizers do not treat this code like the non-volatile code in the 
8019 earlier examples. They do not move it out of loops or omit it on the 
8020 assumption that the result from a previous call is still valid.
8022 Note that the compiler can move even volatile @code{asm} instructions relative 
8023 to other code, including across jump instructions. For example, on many 
8024 targets there is a system register that controls the rounding mode of 
8025 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8026 following PowerPC example, does not work reliably.
8028 @example
8029 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8030 sum = x + y;
8031 @end example
8033 The compiler may move the addition back before the volatile @code{asm}. To 
8034 make it work as expected, add an artificial dependency to the @code{asm} by 
8035 referencing a variable in the subsequent code, for example: 
8037 @example
8038 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8039 sum = x + y;
8040 @end example
8042 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8043 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8044 errors during compilation if your asm code defines symbols or labels. 
8045 Using @samp{%=} 
8046 (@pxref{AssemblerTemplate}) may help resolve this problem.
8048 @anchor{AssemblerTemplate}
8049 @subsubsection Assembler Template
8050 @cindex @code{asm} assembler template
8052 An assembler template is a literal string containing assembler instructions.
8053 The compiler replaces tokens in the template that refer 
8054 to inputs, outputs, and goto labels,
8055 and then outputs the resulting string to the assembler. The 
8056 string can contain any instructions recognized by the assembler, including 
8057 directives. GCC does not parse the assembler instructions 
8058 themselves and does not know what they mean or even whether they are valid 
8059 assembler input. However, it does count the statements 
8060 (@pxref{Size of an asm}).
8062 You may place multiple assembler instructions together in a single @code{asm} 
8063 string, separated by the characters normally used in assembly code for the 
8064 system. A combination that works in most places is a newline to break the 
8065 line, plus a tab character to move to the instruction field (written as 
8066 @samp{\n\t}). 
8067 Some assemblers allow semicolons as a line separator. However, note 
8068 that some assembler dialects use semicolons to start a comment. 
8070 Do not expect a sequence of @code{asm} statements to remain perfectly 
8071 consecutive after compilation, even when you are using the @code{volatile} 
8072 qualifier. If certain instructions need to remain consecutive in the output, 
8073 put them in a single multi-instruction asm statement.
8075 Accessing data from C programs without using input/output operands (such as 
8076 by using global symbols directly from the assembler template) may not work as 
8077 expected. Similarly, calling functions directly from an assembler template 
8078 requires a detailed understanding of the target assembler and ABI.
8080 Since GCC does not parse the assembler template,
8081 it has no visibility of any 
8082 symbols it references. This may result in GCC discarding those symbols as 
8083 unreferenced unless they are also listed as input, output, or goto operands.
8085 @subsubheading Special format strings
8087 In addition to the tokens described by the input, output, and goto operands, 
8088 these tokens have special meanings in the assembler template:
8090 @table @samp
8091 @item %% 
8092 Outputs a single @samp{%} into the assembler code.
8094 @item %= 
8095 Outputs a number that is unique to each instance of the @code{asm} 
8096 statement in the entire compilation. This option is useful when creating local 
8097 labels and referring to them multiple times in a single template that 
8098 generates multiple assembler instructions. 
8100 @item %@{
8101 @itemx %|
8102 @itemx %@}
8103 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8104 into the assembler code.  When unescaped, these characters have special
8105 meaning to indicate multiple assembler dialects, as described below.
8106 @end table
8108 @subsubheading Multiple assembler dialects in @code{asm} templates
8110 On targets such as x86, GCC supports multiple assembler dialects.
8111 The @option{-masm} option controls which dialect GCC uses as its 
8112 default for inline assembler. The target-specific documentation for the 
8113 @option{-masm} option contains the list of supported dialects, as well as the 
8114 default dialect if the option is not specified. This information may be 
8115 important to understand, since assembler code that works correctly when 
8116 compiled using one dialect will likely fail if compiled using another.
8117 @xref{x86 Options}.
8119 If your code needs to support multiple assembler dialects (for example, if 
8120 you are writing public headers that need to support a variety of compilation 
8121 options), use constructs of this form:
8123 @example
8124 @{ dialect0 | dialect1 | dialect2... @}
8125 @end example
8127 This construct outputs @code{dialect0} 
8128 when using dialect #0 to compile the code, 
8129 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8130 braces than the number of dialects the compiler supports, the construct 
8131 outputs nothing.
8133 For example, if an x86 compiler supports two dialects
8134 (@samp{att}, @samp{intel}), an 
8135 assembler template such as this:
8137 @example
8138 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8139 @end example
8141 @noindent
8142 is equivalent to one of
8144 @example
8145 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8146 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8147 @end example
8149 Using that same compiler, this code:
8151 @example
8152 "xchg@{l@}\t@{%%@}ebx, %1"
8153 @end example
8155 @noindent
8156 corresponds to either
8158 @example
8159 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8160 "xchg\tebx, %1"                    @r{/* intel dialect */}
8161 @end example
8163 There is no support for nesting dialect alternatives.
8165 @anchor{OutputOperands}
8166 @subsubsection Output Operands
8167 @cindex @code{asm} output operands
8169 An @code{asm} statement has zero or more output operands indicating the names
8170 of C variables modified by the assembler code.
8172 In this i386 example, @code{old} (referred to in the template string as 
8173 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8174 (@code{%2}) is an input:
8176 @example
8177 bool old;
8179 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8180          "sbb %0,%0"      // Use the CF to calculate old.
8181    : "=r" (old), "+rm" (*Base)
8182    : "Ir" (Offset)
8183    : "cc");
8185 return old;
8186 @end example
8188 Operands are separated by commas.  Each operand has this format:
8190 @example
8191 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8192 @end example
8194 @table @var
8195 @item asmSymbolicName
8196 Specifies a symbolic name for the operand.
8197 Reference the name in the assembler template 
8198 by enclosing it in square brackets 
8199 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8200 that contains the definition. Any valid C variable name is acceptable, 
8201 including names already defined in the surrounding code. No two operands 
8202 within the same @code{asm} statement can use the same symbolic name.
8204 When not using an @var{asmSymbolicName}, use the (zero-based) position
8205 of the operand 
8206 in the list of operands in the assembler template. For example if there are 
8207 three output operands, use @samp{%0} in the template to refer to the first, 
8208 @samp{%1} for the second, and @samp{%2} for the third. 
8210 @item constraint
8211 A string constant specifying constraints on the placement of the operand; 
8212 @xref{Constraints}, for details.
8214 Output constraints must begin with either @samp{=} (a variable overwriting an 
8215 existing value) or @samp{+} (when reading and writing). When using 
8216 @samp{=}, do not assume the location contains the existing value
8217 on entry to the @code{asm}, except 
8218 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8220 After the prefix, there must be one or more additional constraints 
8221 (@pxref{Constraints}) that describe where the value resides. Common 
8222 constraints include @samp{r} for register and @samp{m} for memory. 
8223 When you list more than one possible location (for example, @code{"=rm"}),
8224 the compiler chooses the most efficient one based on the current context. 
8225 If you list as many alternates as the @code{asm} statement allows, you permit 
8226 the optimizers to produce the best possible code. 
8227 If you must use a specific register, but your Machine Constraints do not
8228 provide sufficient control to select the specific register you want, 
8229 local register variables may provide a solution (@pxref{Local Register 
8230 Variables}).
8232 @item cvariablename
8233 Specifies a C lvalue expression to hold the output, typically a variable name.
8234 The enclosing parentheses are a required part of the syntax.
8236 @end table
8238 When the compiler selects the registers to use to 
8239 represent the output operands, it does not use any of the clobbered registers 
8240 (@pxref{Clobbers}).
8242 Output operand expressions must be lvalues. The compiler cannot check whether 
8243 the operands have data types that are reasonable for the instruction being 
8244 executed. For output expressions that are not directly addressable (for 
8245 example a bit-field), the constraint must allow a register. In that case, GCC 
8246 uses the register as the output of the @code{asm}, and then stores that 
8247 register into the output. 
8249 Operands using the @samp{+} constraint modifier count as two operands 
8250 (that is, both as input and output) towards the total maximum of 30 operands
8251 per @code{asm} statement.
8253 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8254 operands that must not overlap an input.  Otherwise, 
8255 GCC may allocate the output operand in the same register as an unrelated 
8256 input operand, on the assumption that the assembler code consumes its 
8257 inputs before producing outputs. This assumption may be false if the assembler 
8258 code actually consists of more than one instruction.
8260 The same problem can occur if one output parameter (@var{a}) allows a register 
8261 constraint and another output parameter (@var{b}) allows a memory constraint.
8262 The code generated by GCC to access the memory address in @var{b} can contain
8263 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8264 registers to be inputs to the asm. As above, GCC assumes that such input
8265 registers are consumed before any outputs are written. This assumption may 
8266 result in incorrect behavior if the asm writes to @var{a} before using 
8267 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8268 ensures that modifying @var{a} does not affect the address referenced by 
8269 @var{b}. Otherwise, the location of @var{b} 
8270 is undefined if @var{a} is modified before using @var{b}.
8272 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8273 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8274 dependent. The list of supported modifiers for x86 is found at 
8275 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8277 If the C code that follows the @code{asm} makes no use of any of the output 
8278 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8279 optimizers from discarding the @code{asm} statement as unneeded 
8280 (see @ref{Volatile}).
8282 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8283 references the first output operand as @code{%0} (were there a second, it 
8284 would be @code{%1}, etc). The number of the first input operand is one greater 
8285 than that of the last output operand. In this i386 example, that makes 
8286 @code{Mask} referenced as @code{%1}:
8288 @example
8289 uint32_t Mask = 1234;
8290 uint32_t Index;
8292   asm ("bsfl %1, %0"
8293      : "=r" (Index)
8294      : "r" (Mask)
8295      : "cc");
8296 @end example
8298 That code overwrites the variable @code{Index} (@samp{=}),
8299 placing the value in a register (@samp{r}).
8300 Using the generic @samp{r} constraint instead of a constraint for a specific 
8301 register allows the compiler to pick the register to use, which can result 
8302 in more efficient code. This may not be possible if an assembler instruction 
8303 requires a specific register.
8305 The following i386 example uses the @var{asmSymbolicName} syntax.
8306 It produces the 
8307 same result as the code above, but some may consider it more readable or more 
8308 maintainable since reordering index numbers is not necessary when adding or 
8309 removing operands. The names @code{aIndex} and @code{aMask}
8310 are only used in this example to emphasize which 
8311 names get used where.
8312 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8314 @example
8315 uint32_t Mask = 1234;
8316 uint32_t Index;
8318   asm ("bsfl %[aMask], %[aIndex]"
8319      : [aIndex] "=r" (Index)
8320      : [aMask] "r" (Mask)
8321      : "cc");
8322 @end example
8324 Here are some more examples of output operands.
8326 @example
8327 uint32_t c = 1;
8328 uint32_t d;
8329 uint32_t *e = &c;
8331 asm ("mov %[e], %[d]"
8332    : [d] "=rm" (d)
8333    : [e] "rm" (*e));
8334 @end example
8336 Here, @code{d} may either be in a register or in memory. Since the compiler 
8337 might already have the current value of the @code{uint32_t} location
8338 pointed to by @code{e}
8339 in a register, you can enable it to choose the best location
8340 for @code{d} by specifying both constraints.
8342 @anchor{FlagOutputOperands}
8343 @subsubsection Flag Output Operands
8344 @cindex @code{asm} flag output operands
8346 Some targets have a special register that holds the ``flags'' for the
8347 result of an operation or comparison.  Normally, the contents of that
8348 register are either unmodifed by the asm, or the asm is considered to
8349 clobber the contents.
8351 On some targets, a special form of output operand exists by which
8352 conditions in the flags register may be outputs of the asm.  The set of
8353 conditions supported are target specific, but the general rule is that
8354 the output variable must be a scalar integer, and the value is boolean.
8355 When supported, the target defines the preprocessor symbol
8356 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8358 Because of the special nature of the flag output operands, the constraint
8359 may not include alternatives.
8361 Most often, the target has only one flags register, and thus is an implied
8362 operand of many instructions.  In this case, the operand should not be
8363 referenced within the assembler template via @code{%0} etc, as there's
8364 no corresponding text in the assembly language.
8366 @table @asis
8367 @item x86 family
8368 The flag output constraints for the x86 family are of the form
8369 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8370 conditions defined in the ISA manual for @code{j@var{cc}} or
8371 @code{set@var{cc}}.
8373 @table @code
8374 @item a
8375 ``above'' or unsigned greater than
8376 @item ae
8377 ``above or equal'' or unsigned greater than or equal
8378 @item b
8379 ``below'' or unsigned less than
8380 @item be
8381 ``below or equal'' or unsigned less than or equal
8382 @item c
8383 carry flag set
8384 @item e
8385 @itemx z
8386 ``equal'' or zero flag set
8387 @item g
8388 signed greater than
8389 @item ge
8390 signed greater than or equal
8391 @item l
8392 signed less than
8393 @item le
8394 signed less than or equal
8395 @item o
8396 overflow flag set
8397 @item p
8398 parity flag set
8399 @item s
8400 sign flag set
8401 @item na
8402 @itemx nae
8403 @itemx nb
8404 @itemx nbe
8405 @itemx nc
8406 @itemx ne
8407 @itemx ng
8408 @itemx nge
8409 @itemx nl
8410 @itemx nle
8411 @itemx no
8412 @itemx np
8413 @itemx ns
8414 @itemx nz
8415 ``not'' @var{flag}, or inverted versions of those above
8416 @end table
8418 @end table
8420 @anchor{InputOperands}
8421 @subsubsection Input Operands
8422 @cindex @code{asm} input operands
8423 @cindex @code{asm} expressions
8425 Input operands make values from C variables and expressions available to the 
8426 assembly code.
8428 Operands are separated by commas.  Each operand has this format:
8430 @example
8431 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8432 @end example
8434 @table @var
8435 @item asmSymbolicName
8436 Specifies a symbolic name for the operand.
8437 Reference the name in the assembler template 
8438 by enclosing it in square brackets 
8439 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8440 that contains the definition. Any valid C variable name is acceptable, 
8441 including names already defined in the surrounding code. No two operands 
8442 within the same @code{asm} statement can use the same symbolic name.
8444 When not using an @var{asmSymbolicName}, use the (zero-based) position
8445 of the operand 
8446 in the list of operands in the assembler template. For example if there are
8447 two output operands and three inputs,
8448 use @samp{%2} in the template to refer to the first input operand,
8449 @samp{%3} for the second, and @samp{%4} for the third. 
8451 @item constraint
8452 A string constant specifying constraints on the placement of the operand; 
8453 @xref{Constraints}, for details.
8455 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8456 When you list more than one possible location (for example, @samp{"irm"}), 
8457 the compiler chooses the most efficient one based on the current context.
8458 If you must use a specific register, but your Machine Constraints do not
8459 provide sufficient control to select the specific register you want, 
8460 local register variables may provide a solution (@pxref{Local Register 
8461 Variables}).
8463 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8464 that the specified input must be in the same place as the output constraint 
8465 at the (zero-based) index in the output constraint list. 
8466 When using @var{asmSymbolicName} syntax for the output operands,
8467 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8469 @item cexpression
8470 This is the C variable or expression being passed to the @code{asm} statement 
8471 as input.  The enclosing parentheses are a required part of the syntax.
8473 @end table
8475 When the compiler selects the registers to use to represent the input 
8476 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8478 If there are no output operands but there are input operands, place two 
8479 consecutive colons where the output operands would go:
8481 @example
8482 __asm__ ("some instructions"
8483    : /* No outputs. */
8484    : "r" (Offset / 8));
8485 @end example
8487 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8488 (except for inputs tied to outputs). The compiler assumes that on exit from 
8489 the @code{asm} statement these operands contain the same values as they 
8490 had before executing the statement. 
8491 It is @emph{not} possible to use clobbers
8492 to inform the compiler that the values in these inputs are changing. One 
8493 common work-around is to tie the changing input variable to an output variable 
8494 that never gets used. Note, however, that if the code that follows the 
8495 @code{asm} statement makes no use of any of the output operands, the GCC 
8496 optimizers may discard the @code{asm} statement as unneeded 
8497 (see @ref{Volatile}).
8499 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8500 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8501 dependent. The list of supported modifiers for x86 is found at 
8502 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8504 In this example using the fictitious @code{combine} instruction, the 
8505 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8506 location as output operand 0. Only input operands may use numbers in 
8507 constraints, and they must each refer to an output operand. Only a number (or 
8508 the symbolic assembler name) in the constraint can guarantee that one operand 
8509 is in the same place as another. The mere fact that @code{foo} is the value of 
8510 both operands is not enough to guarantee that they are in the same place in 
8511 the generated assembler code.
8513 @example
8514 asm ("combine %2, %0" 
8515    : "=r" (foo) 
8516    : "0" (foo), "g" (bar));
8517 @end example
8519 Here is an example using symbolic names.
8521 @example
8522 asm ("cmoveq %1, %2, %[result]" 
8523    : [result] "=r"(result) 
8524    : "r" (test), "r" (new), "[result]" (old));
8525 @end example
8527 @anchor{Clobbers}
8528 @subsubsection Clobbers
8529 @cindex @code{asm} clobbers
8531 While the compiler is aware of changes to entries listed in the output 
8532 operands, the inline @code{asm} code may modify more than just the outputs. For 
8533 example, calculations may require additional registers, or the processor may 
8534 overwrite a register as a side effect of a particular assembler instruction. 
8535 In order to inform the compiler of these changes, list them in the clobber 
8536 list. Clobber list items are either register names or the special clobbers 
8537 (listed below). Each clobber list item is a string constant 
8538 enclosed in double quotes and separated by commas.
8540 Clobber descriptions may not in any way overlap with an input or output 
8541 operand. For example, you may not have an operand describing a register class 
8542 with one member when listing that register in the clobber list. Variables 
8543 declared to live in specific registers (@pxref{Explicit Register 
8544 Variables}) and used 
8545 as @code{asm} input or output operands must have no part mentioned in the 
8546 clobber description. In particular, there is no way to specify that input 
8547 operands get modified without also specifying them as output operands.
8549 When the compiler selects which registers to use to represent input and output 
8550 operands, it does not use any of the clobbered registers. As a result, 
8551 clobbered registers are available for any use in the assembler code.
8553 Here is a realistic example for the VAX showing the use of clobbered 
8554 registers: 
8556 @example
8557 asm volatile ("movc3 %0, %1, %2"
8558                    : /* No outputs. */
8559                    : "g" (from), "g" (to), "g" (count)
8560                    : "r0", "r1", "r2", "r3", "r4", "r5");
8561 @end example
8563 Also, there are two special clobber arguments:
8565 @table @code
8566 @item "cc"
8567 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
8568 register. On some machines, GCC represents the condition codes as a specific 
8569 hardware register; @code{"cc"} serves to name this register.
8570 On other machines, condition code handling is different, 
8571 and specifying @code{"cc"} has no effect. But 
8572 it is valid no matter what the target.
8574 @item "memory"
8575 The @code{"memory"} clobber tells the compiler that the assembly code
8576 performs memory 
8577 reads or writes to items other than those listed in the input and output 
8578 operands (for example, accessing the memory pointed to by one of the input 
8579 parameters). To ensure memory contains correct values, GCC may need to flush 
8580 specific register values to memory before executing the @code{asm}. Further, 
8581 the compiler does not assume that any values read from memory before an 
8582 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
8583 needed.  
8584 Using the @code{"memory"} clobber effectively forms a read/write
8585 memory barrier for the compiler.
8587 Note that this clobber does not prevent the @emph{processor} from doing 
8588 speculative reads past the @code{asm} statement. To prevent that, you need 
8589 processor-specific fence instructions.
8591 Flushing registers to memory has performance implications and may be an issue 
8592 for time-sensitive code.  You can use a trick to avoid this if the size of 
8593 the memory being accessed is known at compile time. For example, if accessing 
8594 ten bytes of a string, use a memory input like: 
8596 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8598 @end table
8600 @anchor{GotoLabels}
8601 @subsubsection Goto Labels
8602 @cindex @code{asm} goto labels
8604 @code{asm goto} allows assembly code to jump to one or more C labels.  The
8605 @var{GotoLabels} section in an @code{asm goto} statement contains 
8606 a comma-separated 
8607 list of all C labels to which the assembler code may jump. GCC assumes that 
8608 @code{asm} execution falls through to the next statement (if this is not the 
8609 case, consider using the @code{__builtin_unreachable} intrinsic after the 
8610 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
8611 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
8612 Attributes}).
8614 An @code{asm goto} statement cannot have outputs.
8615 This is due to an internal restriction of 
8616 the compiler: control transfer instructions cannot have outputs. 
8617 If the assembler code does modify anything, use the @code{"memory"} clobber 
8618 to force the 
8619 optimizers to flush all register values to memory and reload them if 
8620 necessary after the @code{asm} statement.
8622 Also note that an @code{asm goto} statement is always implicitly
8623 considered volatile.
8625 To reference a label in the assembler template,
8626 prefix it with @samp{%l} (lowercase @samp{L}) followed 
8627 by its (zero-based) position in @var{GotoLabels} plus the number of input 
8628 operands.  For example, if the @code{asm} has three inputs and references two 
8629 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8631 Alternately, you can reference labels using the actual C label name enclosed
8632 in brackets.  For example, to reference a label named @code{carry}, you can
8633 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
8634 section when using this approach.
8636 Here is an example of @code{asm goto} for i386:
8638 @example
8639 asm goto (
8640     "btl %1, %0\n\t"
8641     "jc %l2"
8642     : /* No outputs. */
8643     : "r" (p1), "r" (p2) 
8644     : "cc" 
8645     : carry);
8647 return 0;
8649 carry:
8650 return 1;
8651 @end example
8653 The following example shows an @code{asm goto} that uses a memory clobber.
8655 @example
8656 int frob(int x)
8658   int y;
8659   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8660             : /* No outputs. */
8661             : "r"(x), "r"(&y)
8662             : "r5", "memory" 
8663             : error);
8664   return y;
8665 error:
8666   return -1;
8668 @end example
8670 @anchor{x86Operandmodifiers}
8671 @subsubsection x86 Operand Modifiers
8673 References to input, output, and goto operands in the assembler template
8674 of extended @code{asm} statements can use 
8675 modifiers to affect the way the operands are formatted in 
8676 the code output to the assembler. For example, the 
8677 following code uses the @samp{h} and @samp{b} modifiers for x86:
8679 @example
8680 uint16_t  num;
8681 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8682 @end example
8684 @noindent
8685 These modifiers generate this assembler code:
8687 @example
8688 xchg %ah, %al
8689 @end example
8691 The rest of this discussion uses the following code for illustrative purposes.
8693 @example
8694 int main()
8696    int iInt = 1;
8698 top:
8700    asm volatile goto ("some assembler instructions here"
8701    : /* No outputs. */
8702    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8703    : /* No clobbers. */
8704    : top);
8706 @end example
8708 With no modifiers, this is what the output from the operands would be for the 
8709 @samp{att} and @samp{intel} dialects of assembler:
8711 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
8712 @headitem Operand @tab @samp{att} @tab @samp{intel}
8713 @item @code{%0}
8714 @tab @code{%eax}
8715 @tab @code{eax}
8716 @item @code{%1}
8717 @tab @code{$2}
8718 @tab @code{2}
8719 @item @code{%2}
8720 @tab @code{$.L2}
8721 @tab @code{OFFSET FLAT:.L2}
8722 @end multitable
8724 The table below shows the list of supported modifiers and their effects.
8726 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
8727 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
8728 @item @code{z}
8729 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8730 @tab @code{%z0}
8731 @tab @code{l}
8732 @tab 
8733 @item @code{b}
8734 @tab Print the QImode name of the register.
8735 @tab @code{%b0}
8736 @tab @code{%al}
8737 @tab @code{al}
8738 @item @code{h}
8739 @tab Print the QImode name for a ``high'' register.
8740 @tab @code{%h0}
8741 @tab @code{%ah}
8742 @tab @code{ah}
8743 @item @code{w}
8744 @tab Print the HImode name of the register.
8745 @tab @code{%w0}
8746 @tab @code{%ax}
8747 @tab @code{ax}
8748 @item @code{k}
8749 @tab Print the SImode name of the register.
8750 @tab @code{%k0}
8751 @tab @code{%eax}
8752 @tab @code{eax}
8753 @item @code{q}
8754 @tab Print the DImode name of the register.
8755 @tab @code{%q0}
8756 @tab @code{%rax}
8757 @tab @code{rax}
8758 @item @code{l}
8759 @tab Print the label name with no punctuation.
8760 @tab @code{%l2}
8761 @tab @code{.L2}
8762 @tab @code{.L2}
8763 @item @code{c}
8764 @tab Require a constant operand and print the constant expression with no punctuation.
8765 @tab @code{%c1}
8766 @tab @code{2}
8767 @tab @code{2}
8768 @end multitable
8770 @anchor{x86floatingpointasmoperands}
8771 @subsubsection x86 Floating-Point @code{asm} Operands
8773 On x86 targets, there are several rules on the usage of stack-like registers
8774 in the operands of an @code{asm}.  These rules apply only to the operands
8775 that are stack-like registers:
8777 @enumerate
8778 @item
8779 Given a set of input registers that die in an @code{asm}, it is
8780 necessary to know which are implicitly popped by the @code{asm}, and
8781 which must be explicitly popped by GCC@.
8783 An input register that is implicitly popped by the @code{asm} must be
8784 explicitly clobbered, unless it is constrained to match an
8785 output operand.
8787 @item
8788 For any input register that is implicitly popped by an @code{asm}, it is
8789 necessary to know how to adjust the stack to compensate for the pop.
8790 If any non-popped input is closer to the top of the reg-stack than
8791 the implicitly popped register, it would not be possible to know what the
8792 stack looked like---it's not clear how the rest of the stack ``slides
8793 up''.
8795 All implicitly popped input registers must be closer to the top of
8796 the reg-stack than any input that is not implicitly popped.
8798 It is possible that if an input dies in an @code{asm}, the compiler might
8799 use the input register for an output reload.  Consider this example:
8801 @smallexample
8802 asm ("foo" : "=t" (a) : "f" (b));
8803 @end smallexample
8805 @noindent
8806 This code says that input @code{b} is not popped by the @code{asm}, and that
8807 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8808 deeper after the @code{asm} than it was before.  But, it is possible that
8809 reload may think that it can use the same register for both the input and
8810 the output.
8812 To prevent this from happening,
8813 if any input operand uses the @samp{f} constraint, all output register
8814 constraints must use the @samp{&} early-clobber modifier.
8816 The example above is correctly written as:
8818 @smallexample
8819 asm ("foo" : "=&t" (a) : "f" (b));
8820 @end smallexample
8822 @item
8823 Some operands need to be in particular places on the stack.  All
8824 output operands fall in this category---GCC has no other way to
8825 know which registers the outputs appear in unless you indicate
8826 this in the constraints.
8828 Output operands must specifically indicate which register an output
8829 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
8830 constraints must select a class with a single register.
8832 @item
8833 Output operands may not be ``inserted'' between existing stack registers.
8834 Since no 387 opcode uses a read/write operand, all output operands
8835 are dead before the @code{asm}, and are pushed by the @code{asm}.
8836 It makes no sense to push anywhere but the top of the reg-stack.
8838 Output operands must start at the top of the reg-stack: output
8839 operands may not ``skip'' a register.
8841 @item
8842 Some @code{asm} statements may need extra stack space for internal
8843 calculations.  This can be guaranteed by clobbering stack registers
8844 unrelated to the inputs and outputs.
8846 @end enumerate
8848 This @code{asm}
8849 takes one input, which is internally popped, and produces two outputs.
8851 @smallexample
8852 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8853 @end smallexample
8855 @noindent
8856 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8857 and replaces them with one output.  The @code{st(1)} clobber is necessary 
8858 for the compiler to know that @code{fyl2xp1} pops both inputs.
8860 @smallexample
8861 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8862 @end smallexample
8864 @lowersections
8865 @include md.texi
8866 @raisesections
8868 @node Asm Labels
8869 @subsection Controlling Names Used in Assembler Code
8870 @cindex assembler names for identifiers
8871 @cindex names used in assembler code
8872 @cindex identifiers, names in assembler code
8874 You can specify the name to be used in the assembler code for a C
8875 function or variable by writing the @code{asm} (or @code{__asm__})
8876 keyword after the declarator.
8877 It is up to you to make sure that the assembler names you choose do not
8878 conflict with any other assembler symbols, or reference registers.
8880 @subsubheading Assembler names for data:
8882 This sample shows how to specify the assembler name for data:
8884 @smallexample
8885 int foo asm ("myfoo") = 2;
8886 @end smallexample
8888 @noindent
8889 This specifies that the name to be used for the variable @code{foo} in
8890 the assembler code should be @samp{myfoo} rather than the usual
8891 @samp{_foo}.
8893 On systems where an underscore is normally prepended to the name of a C
8894 variable, this feature allows you to define names for the
8895 linker that do not start with an underscore.
8897 GCC does not support using this feature with a non-static local variable 
8898 since such variables do not have assembler names.  If you are
8899 trying to put the variable in a particular register, see 
8900 @ref{Explicit Register Variables}.
8902 @subsubheading Assembler names for functions:
8904 To specify the assembler name for functions, write a declaration for the 
8905 function before its definition and put @code{asm} there, like this:
8907 @smallexample
8908 int func (int x, int y) asm ("MYFUNC");
8909      
8910 int func (int x, int y)
8912    /* @r{@dots{}} */
8913 @end smallexample
8915 @noindent
8916 This specifies that the name to be used for the function @code{func} in
8917 the assembler code should be @code{MYFUNC}.
8919 @node Explicit Register Variables
8920 @subsection Variables in Specified Registers
8921 @anchor{Explicit Reg Vars}
8922 @cindex explicit register variables
8923 @cindex variables in specified registers
8924 @cindex specified registers
8926 GNU C allows you to associate specific hardware registers with C 
8927 variables.  In almost all cases, allowing the compiler to assign
8928 registers produces the best code.  However under certain unusual
8929 circumstances, more precise control over the variable storage is 
8930 required.
8932 Both global and local variables can be associated with a register.  The
8933 consequences of performing this association are very different between
8934 the two, as explained in the sections below.
8936 @menu
8937 * Global Register Variables::   Variables declared at global scope.
8938 * Local Register Variables::    Variables declared within a function.
8939 @end menu
8941 @node Global Register Variables
8942 @subsubsection Defining Global Register Variables
8943 @anchor{Global Reg Vars}
8944 @cindex global register variables
8945 @cindex registers, global variables in
8946 @cindex registers, global allocation
8948 You can define a global register variable and associate it with a specified 
8949 register like this:
8951 @smallexample
8952 register int *foo asm ("r12");
8953 @end smallexample
8955 @noindent
8956 Here @code{r12} is the name of the register that should be used. Note that 
8957 this is the same syntax used for defining local register variables, but for 
8958 a global variable the declaration appears outside a function. The 
8959 @code{register} keyword is required, and cannot be combined with 
8960 @code{static}. The register name must be a valid register name for the
8961 target platform.
8963 Registers are a scarce resource on most systems and allowing the 
8964 compiler to manage their usage usually results in the best code. However, 
8965 under special circumstances it can make sense to reserve some globally.
8966 For example this may be useful in programs such as programming language 
8967 interpreters that have a couple of global variables that are accessed 
8968 very often.
8970 After defining a global register variable, for the current compilation
8971 unit:
8973 @itemize @bullet
8974 @item The register is reserved entirely for this use, and will not be 
8975 allocated for any other purpose.
8976 @item The register is not saved and restored by any functions.
8977 @item Stores into this register are never deleted even if they appear to be 
8978 dead, but references may be deleted, moved or simplified.
8979 @end itemize
8981 Note that these points @emph{only} apply to code that is compiled with the
8982 definition. The behavior of code that is merely linked in (for example 
8983 code from libraries) is not affected.
8985 If you want to recompile source files that do not actually use your global 
8986 register variable so they do not use the specified register for any other 
8987 purpose, you need not actually add the global register declaration to 
8988 their source code. It suffices to specify the compiler option 
8989 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
8990 register.
8992 @subsubheading Declaring the variable
8994 Global register variables can not have initial values, because an
8995 executable file has no means to supply initial contents for a register.
8997 When selecting a register, choose one that is normally saved and 
8998 restored by function calls on your machine. This ensures that code
8999 which is unaware of this reservation (such as library routines) will 
9000 restore it before returning.
9002 On machines with register windows, be sure to choose a global
9003 register that is not affected magically by the function call mechanism.
9005 @subsubheading Using the variable
9007 @cindex @code{qsort}, and global register variables
9008 When calling routines that are not aware of the reservation, be 
9009 cautious if those routines call back into code which uses them. As an 
9010 example, if you call the system library version of @code{qsort}, it may 
9011 clobber your registers during execution, but (if you have selected 
9012 appropriate registers) it will restore them before returning. However 
9013 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9014 function. As a result, global values will not reliably be available to 
9015 the comparison function unless the @code{qsort} function itself is rebuilt.
9017 Similarly, it is not safe to access the global register variables from signal
9018 handlers or from more than one thread of control. Unless you recompile 
9019 them specially for the task at hand, the system library routines may 
9020 temporarily use the register for other things.
9022 @cindex register variable after @code{longjmp}
9023 @cindex global register after @code{longjmp}
9024 @cindex value after @code{longjmp}
9025 @findex longjmp
9026 @findex setjmp
9027 On most machines, @code{longjmp} restores to each global register
9028 variable the value it had at the time of the @code{setjmp}. On some
9029 machines, however, @code{longjmp} does not change the value of global
9030 register variables. To be portable, the function that called @code{setjmp}
9031 should make other arrangements to save the values of the global register
9032 variables, and to restore them in a @code{longjmp}. This way, the same
9033 thing happens regardless of what @code{longjmp} does.
9035 Eventually there may be a way of asking the compiler to choose a register 
9036 automatically, but first we need to figure out how it should choose and 
9037 how to enable you to guide the choice.  No solution is evident.
9039 @node Local Register Variables
9040 @subsubsection Specifying Registers for Local Variables
9041 @anchor{Local Reg Vars}
9042 @cindex local variables, specifying registers
9043 @cindex specifying registers for local variables
9044 @cindex registers for local variables
9046 You can define a local register variable and associate it with a specified 
9047 register like this:
9049 @smallexample
9050 register int *foo asm ("r12");
9051 @end smallexample
9053 @noindent
9054 Here @code{r12} is the name of the register that should be used.  Note
9055 that this is the same syntax used for defining global register variables, 
9056 but for a local variable the declaration appears within a function.  The 
9057 @code{register} keyword is required, and cannot be combined with 
9058 @code{static}.  The register name must be a valid register name for the
9059 target platform.
9061 As with global register variables, it is recommended that you choose 
9062 a register that is normally saved and restored by function calls on your 
9063 machine, so that calls to library routines will not clobber it.
9065 The only supported use for this feature is to specify registers
9066 for input and output operands when calling Extended @code{asm} 
9067 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9068 particular machine don't provide sufficient control to select the desired 
9069 register.  To force an operand into a register, create a local variable 
9070 and specify the register name after the variable's declaration.  Then use 
9071 the local variable for the @code{asm} operand and specify any constraint 
9072 letter that matches the register:
9074 @smallexample
9075 register int *p1 asm ("r0") = @dots{};
9076 register int *p2 asm ("r1") = @dots{};
9077 register int *result asm ("r0");
9078 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9079 @end smallexample
9081 @emph{Warning:} In the above example, be aware that a register (for example 
9082 @code{r0}) can be call-clobbered by subsequent code, including function 
9083 calls and library calls for arithmetic operators on other variables (for 
9084 example the initialization of @code{p2}).  In this case, use temporary 
9085 variables for expressions between the register assignments:
9087 @smallexample
9088 int t1 = @dots{};
9089 register int *p1 asm ("r0") = @dots{};
9090 register int *p2 asm ("r1") = t1;
9091 register int *result asm ("r0");
9092 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9093 @end smallexample
9095 Defining a register variable does not reserve the register.  Other than
9096 when invoking the Extended @code{asm}, the contents of the specified 
9097 register are not guaranteed.  For this reason, the following uses 
9098 are explicitly @emph{not} supported.  If they appear to work, it is only 
9099 happenstance, and may stop working as intended due to (seemingly) 
9100 unrelated changes in surrounding code, or even minor changes in the 
9101 optimization of a future version of gcc:
9103 @itemize @bullet
9104 @item Passing parameters to or from Basic @code{asm}
9105 @item Passing parameters to or from Extended @code{asm} without using input 
9106 or output operands.
9107 @item Passing parameters to or from routines written in assembler (or
9108 other languages) using non-standard calling conventions.
9109 @end itemize
9111 Some developers use Local Register Variables in an attempt to improve 
9112 gcc's allocation of registers, especially in large functions.  In this 
9113 case the register name is essentially a hint to the register allocator.
9114 While in some instances this can generate better code, improvements are
9115 subject to the whims of the allocator/optimizers.  Since there are no
9116 guarantees that your improvements won't be lost, this usage of Local
9117 Register Variables is discouraged.
9119 On the MIPS platform, there is related use for local register variables 
9120 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9121 Defining coprocessor specifics for MIPS targets, gccint, 
9122 GNU Compiler Collection (GCC) Internals}).
9124 @node Size of an asm
9125 @subsection Size of an @code{asm}
9127 Some targets require that GCC track the size of each instruction used
9128 in order to generate correct code.  Because the final length of the
9129 code produced by an @code{asm} statement is only known by the
9130 assembler, GCC must make an estimate as to how big it will be.  It
9131 does this by counting the number of instructions in the pattern of the
9132 @code{asm} and multiplying that by the length of the longest
9133 instruction supported by that processor.  (When working out the number
9134 of instructions, it assumes that any occurrence of a newline or of
9135 whatever statement separator character is supported by the assembler --
9136 typically @samp{;} --- indicates the end of an instruction.)
9138 Normally, GCC's estimate is adequate to ensure that correct
9139 code is generated, but it is possible to confuse the compiler if you use
9140 pseudo instructions or assembler macros that expand into multiple real
9141 instructions, or if you use assembler directives that expand to more
9142 space in the object file than is needed for a single instruction.
9143 If this happens then the assembler may produce a diagnostic saying that
9144 a label is unreachable.
9146 @node Alternate Keywords
9147 @section Alternate Keywords
9148 @cindex alternate keywords
9149 @cindex keywords, alternate
9151 @option{-ansi} and the various @option{-std} options disable certain
9152 keywords.  This causes trouble when you want to use GNU C extensions, or
9153 a general-purpose header file that should be usable by all programs,
9154 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9155 @code{inline} are not available in programs compiled with
9156 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9157 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9158 ISO C99 keyword
9159 @code{restrict} is only available when @option{-std=gnu99} (which will
9160 eventually be the default) or @option{-std=c99} (or the equivalent
9161 @option{-std=iso9899:1999}), or an option for a later standard
9162 version, is used.
9164 The way to solve these problems is to put @samp{__} at the beginning and
9165 end of each problematical keyword.  For example, use @code{__asm__}
9166 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9168 Other C compilers won't accept these alternative keywords; if you want to
9169 compile with another compiler, you can define the alternate keywords as
9170 macros to replace them with the customary keywords.  It looks like this:
9172 @smallexample
9173 #ifndef __GNUC__
9174 #define __asm__ asm
9175 #endif
9176 @end smallexample
9178 @findex __extension__
9179 @opindex pedantic
9180 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9181 You can
9182 prevent such warnings within one expression by writing
9183 @code{__extension__} before the expression.  @code{__extension__} has no
9184 effect aside from this.
9186 @node Incomplete Enums
9187 @section Incomplete @code{enum} Types
9189 You can define an @code{enum} tag without specifying its possible values.
9190 This results in an incomplete type, much like what you get if you write
9191 @code{struct foo} without describing the elements.  A later declaration
9192 that does specify the possible values completes the type.
9194 You cannot allocate variables or storage using the type while it is
9195 incomplete.  However, you can work with pointers to that type.
9197 This extension may not be very useful, but it makes the handling of
9198 @code{enum} more consistent with the way @code{struct} and @code{union}
9199 are handled.
9201 This extension is not supported by GNU C++.
9203 @node Function Names
9204 @section Function Names as Strings
9205 @cindex @code{__func__} identifier
9206 @cindex @code{__FUNCTION__} identifier
9207 @cindex @code{__PRETTY_FUNCTION__} identifier
9209 GCC provides three magic constants that hold the name of the current
9210 function as a string.  In C++11 and later modes, all three are treated
9211 as constant expressions and can be used in @code{constexpr} constexts.
9212 The first of these constants is @code{__func__}, which is part of
9213 the C99 standard:
9215 The identifier @code{__func__} is implicitly declared by the translator
9216 as if, immediately following the opening brace of each function
9217 definition, the declaration
9219 @smallexample
9220 static const char __func__[] = "function-name";
9221 @end smallexample
9223 @noindent
9224 appeared, where function-name is the name of the lexically-enclosing
9225 function.  This name is the unadorned name of the function.  As an
9226 extension, at file (or, in C++, namespace scope), @code{__func__}
9227 evaluates to the empty string.
9229 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9230 backward compatibility with old versions of GCC.
9232 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9233 @code{__func__}, except that at file (or, in C++, namespace scope),
9234 it evaluates to the string @code{"top level"}.  In addition, in C++,
9235 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9236 well as its bare name.  For example, this program:
9238 @smallexample
9239 extern "C" int printf (const char *, ...);
9241 class a @{
9242  public:
9243   void sub (int i)
9244     @{
9245       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9246       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9247     @}
9251 main (void)
9253   a ax;
9254   ax.sub (0);
9255   return 0;
9257 @end smallexample
9259 @noindent
9260 gives this output:
9262 @smallexample
9263 __FUNCTION__ = sub
9264 __PRETTY_FUNCTION__ = void a::sub(int)
9265 @end smallexample
9267 These identifiers are variables, not preprocessor macros, and may not
9268 be used to initialize @code{char} arrays or be concatenated with string
9269 literals.
9271 @node Return Address
9272 @section Getting the Return or Frame Address of a Function
9274 These functions may be used to get information about the callers of a
9275 function.
9277 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9278 This function returns the return address of the current function, or of
9279 one of its callers.  The @var{level} argument is number of frames to
9280 scan up the call stack.  A value of @code{0} yields the return address
9281 of the current function, a value of @code{1} yields the return address
9282 of the caller of the current function, and so forth.  When inlining
9283 the expected behavior is that the function returns the address of
9284 the function that is returned to.  To work around this behavior use
9285 the @code{noinline} function attribute.
9287 The @var{level} argument must be a constant integer.
9289 On some machines it may be impossible to determine the return address of
9290 any function other than the current one; in such cases, or when the top
9291 of the stack has been reached, this function returns @code{0} or a
9292 random value.  In addition, @code{__builtin_frame_address} may be used
9293 to determine if the top of the stack has been reached.
9295 Additional post-processing of the returned value may be needed, see
9296 @code{__builtin_extract_return_addr}.
9298 Calling this function with a nonzero argument can have unpredictable
9299 effects, including crashing the calling program.  As a result, calls
9300 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9301 option is in effect.  Such calls should only be made in debugging
9302 situations.
9303 @end deftypefn
9305 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9306 The address as returned by @code{__builtin_return_address} may have to be fed
9307 through this function to get the actual encoded address.  For example, on the
9308 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9309 platforms an offset has to be added for the true next instruction to be
9310 executed.
9312 If no fixup is needed, this function simply passes through @var{addr}.
9313 @end deftypefn
9315 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9316 This function does the reverse of @code{__builtin_extract_return_addr}.
9317 @end deftypefn
9319 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9320 This function is similar to @code{__builtin_return_address}, but it
9321 returns the address of the function frame rather than the return address
9322 of the function.  Calling @code{__builtin_frame_address} with a value of
9323 @code{0} yields the frame address of the current function, a value of
9324 @code{1} yields the frame address of the caller of the current function,
9325 and so forth.
9327 The frame is the area on the stack that holds local variables and saved
9328 registers.  The frame address is normally the address of the first word
9329 pushed on to the stack by the function.  However, the exact definition
9330 depends upon the processor and the calling convention.  If the processor
9331 has a dedicated frame pointer register, and the function has a frame,
9332 then @code{__builtin_frame_address} returns the value of the frame
9333 pointer register.
9335 On some machines it may be impossible to determine the frame address of
9336 any function other than the current one; in such cases, or when the top
9337 of the stack has been reached, this function returns @code{0} if
9338 the first frame pointer is properly initialized by the startup code.
9340 Calling this function with a nonzero argument can have unpredictable
9341 effects, including crashing the calling program.  As a result, calls
9342 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9343 option is in effect.  Such calls should only be made in debugging
9344 situations.
9345 @end deftypefn
9347 @node Vector Extensions
9348 @section Using Vector Instructions through Built-in Functions
9350 On some targets, the instruction set contains SIMD vector instructions which
9351 operate on multiple values contained in one large register at the same time.
9352 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9353 this way.
9355 The first step in using these extensions is to provide the necessary data
9356 types.  This should be done using an appropriate @code{typedef}:
9358 @smallexample
9359 typedef int v4si __attribute__ ((vector_size (16)));
9360 @end smallexample
9362 @noindent
9363 The @code{int} type specifies the base type, while the attribute specifies
9364 the vector size for the variable, measured in bytes.  For example, the
9365 declaration above causes the compiler to set the mode for the @code{v4si}
9366 type to be 16 bytes wide and divided into @code{int} sized units.  For
9367 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9368 corresponding mode of @code{foo} is @acronym{V4SI}.
9370 The @code{vector_size} attribute is only applicable to integral and
9371 float scalars, although arrays, pointers, and function return values
9372 are allowed in conjunction with this construct. Only sizes that are
9373 a power of two are currently allowed.
9375 All the basic integer types can be used as base types, both as signed
9376 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9377 @code{long long}.  In addition, @code{float} and @code{double} can be
9378 used to build floating-point vector types.
9380 Specifying a combination that is not valid for the current architecture
9381 causes GCC to synthesize the instructions using a narrower mode.
9382 For example, if you specify a variable of type @code{V4SI} and your
9383 architecture does not allow for this specific SIMD type, GCC
9384 produces code that uses 4 @code{SIs}.
9386 The types defined in this manner can be used with a subset of normal C
9387 operations.  Currently, GCC allows using the following operators
9388 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9390 The operations behave like C++ @code{valarrays}.  Addition is defined as
9391 the addition of the corresponding elements of the operands.  For
9392 example, in the code below, each of the 4 elements in @var{a} is
9393 added to the corresponding 4 elements in @var{b} and the resulting
9394 vector is stored in @var{c}.
9396 @smallexample
9397 typedef int v4si __attribute__ ((vector_size (16)));
9399 v4si a, b, c;
9401 c = a + b;
9402 @end smallexample
9404 Subtraction, multiplication, division, and the logical operations
9405 operate in a similar manner.  Likewise, the result of using the unary
9406 minus or complement operators on a vector type is a vector whose
9407 elements are the negative or complemented values of the corresponding
9408 elements in the operand.
9410 It is possible to use shifting operators @code{<<}, @code{>>} on
9411 integer-type vectors. The operation is defined as following: @code{@{a0,
9412 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9413 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9414 elements. 
9416 For convenience, it is allowed to use a binary vector operation
9417 where one operand is a scalar. In that case the compiler transforms
9418 the scalar operand into a vector where each element is the scalar from
9419 the operation. The transformation happens only if the scalar could be
9420 safely converted to the vector-element type.
9421 Consider the following code.
9423 @smallexample
9424 typedef int v4si __attribute__ ((vector_size (16)));
9426 v4si a, b, c;
9427 long l;
9429 a = b + 1;    /* a = b + @{1,1,1,1@}; */
9430 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
9432 a = l + a;    /* Error, cannot convert long to int. */
9433 @end smallexample
9435 Vectors can be subscripted as if the vector were an array with
9436 the same number of elements and base type.  Out of bound accesses
9437 invoke undefined behavior at run time.  Warnings for out of bound
9438 accesses for vector subscription can be enabled with
9439 @option{-Warray-bounds}.
9441 Vector comparison is supported with standard comparison
9442 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9443 vector expressions of integer-type or real-type. Comparison between
9444 integer-type vectors and real-type vectors are not supported.  The
9445 result of the comparison is a vector of the same width and number of
9446 elements as the comparison operands with a signed integral element
9447 type.
9449 Vectors are compared element-wise producing 0 when comparison is false
9450 and -1 (constant of the appropriate type where all bits are set)
9451 otherwise. Consider the following example.
9453 @smallexample
9454 typedef int v4si __attribute__ ((vector_size (16)));
9456 v4si a = @{1,2,3,4@};
9457 v4si b = @{3,2,1,4@};
9458 v4si c;
9460 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
9461 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
9462 @end smallexample
9464 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9465 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9466 integer vector with the same number of elements of the same size as @code{b}
9467 and @code{c}, computes all three arguments and creates a vector
9468 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
9469 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9470 As in the case of binary operations, this syntax is also accepted when
9471 one of @code{b} or @code{c} is a scalar that is then transformed into a
9472 vector. If both @code{b} and @code{c} are scalars and the type of
9473 @code{true?b:c} has the same size as the element type of @code{a}, then
9474 @code{b} and @code{c} are converted to a vector type whose elements have
9475 this type and with the same number of elements as @code{a}.
9477 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9478 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9479 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9480 For mixed operations between a scalar @code{s} and a vector @code{v},
9481 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9482 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9484 Vector shuffling is available using functions
9485 @code{__builtin_shuffle (vec, mask)} and
9486 @code{__builtin_shuffle (vec0, vec1, mask)}.
9487 Both functions construct a permutation of elements from one or two
9488 vectors and return a vector of the same type as the input vector(s).
9489 The @var{mask} is an integral vector with the same width (@var{W})
9490 and element count (@var{N}) as the output vector.
9492 The elements of the input vectors are numbered in memory ordering of
9493 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
9494 elements of @var{mask} are considered modulo @var{N} in the single-operand
9495 case and modulo @math{2*@var{N}} in the two-operand case.
9497 Consider the following example,
9499 @smallexample
9500 typedef int v4si __attribute__ ((vector_size (16)));
9502 v4si a = @{1,2,3,4@};
9503 v4si b = @{5,6,7,8@};
9504 v4si mask1 = @{0,1,1,3@};
9505 v4si mask2 = @{0,4,2,5@};
9506 v4si res;
9508 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
9509 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
9510 @end smallexample
9512 Note that @code{__builtin_shuffle} is intentionally semantically
9513 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9515 You can declare variables and use them in function calls and returns, as
9516 well as in assignments and some casts.  You can specify a vector type as
9517 a return type for a function.  Vector types can also be used as function
9518 arguments.  It is possible to cast from one vector type to another,
9519 provided they are of the same size (in fact, you can also cast vectors
9520 to and from other datatypes of the same size).
9522 You cannot operate between vectors of different lengths or different
9523 signedness without a cast.
9525 @node Offsetof
9526 @section Support for @code{offsetof}
9527 @findex __builtin_offsetof
9529 GCC implements for both C and C++ a syntactic extension to implement
9530 the @code{offsetof} macro.
9532 @smallexample
9533 primary:
9534         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9536 offsetof_member_designator:
9537           @code{identifier}
9538         | offsetof_member_designator "." @code{identifier}
9539         | offsetof_member_designator "[" @code{expr} "]"
9540 @end smallexample
9542 This extension is sufficient such that
9544 @smallexample
9545 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
9546 @end smallexample
9548 @noindent
9549 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
9550 may be dependent.  In either case, @var{member} may consist of a single
9551 identifier, or a sequence of member accesses and array references.
9553 @node __sync Builtins
9554 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9556 The following built-in functions
9557 are intended to be compatible with those described
9558 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9559 section 7.4.  As such, they depart from normal GCC practice by not using
9560 the @samp{__builtin_} prefix and also by being overloaded so that they
9561 work on multiple types.
9563 The definition given in the Intel documentation allows only for the use of
9564 the types @code{int}, @code{long}, @code{long long} or their unsigned
9565 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9566 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9567 Operations on pointer arguments are performed as if the operands were
9568 of the @code{uintptr_t} type.  That is, they are not scaled by the size
9569 of the type to which the pointer points.
9571 These functions are implemented in terms of the @samp{__atomic}
9572 builtins (@pxref{__atomic Builtins}).  They should not be used for new
9573 code which should use the @samp{__atomic} builtins instead.
9575 Not all operations are supported by all target processors.  If a particular
9576 operation cannot be implemented on the target processor, a warning is
9577 generated and a call to an external function is generated.  The external
9578 function carries the same name as the built-in version,
9579 with an additional suffix
9580 @samp{_@var{n}} where @var{n} is the size of the data type.
9582 @c ??? Should we have a mechanism to suppress this warning?  This is almost
9583 @c useful for implementing the operation under the control of an external
9584 @c mutex.
9586 In most cases, these built-in functions are considered a @dfn{full barrier}.
9587 That is,
9588 no memory operand is moved across the operation, either forward or
9589 backward.  Further, instructions are issued as necessary to prevent the
9590 processor from speculating loads across the operation and from queuing stores
9591 after the operation.
9593 All of the routines are described in the Intel documentation to take
9594 ``an optional list of variables protected by the memory barrier''.  It's
9595 not clear what is meant by that; it could mean that @emph{only} the
9596 listed variables are protected, or it could mean a list of additional
9597 variables to be protected.  The list is ignored by GCC which treats it as
9598 empty.  GCC interprets an empty list as meaning that all globally
9599 accessible variables should be protected.
9601 @table @code
9602 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9603 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9604 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9605 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9606 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9607 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9608 @findex __sync_fetch_and_add
9609 @findex __sync_fetch_and_sub
9610 @findex __sync_fetch_and_or
9611 @findex __sync_fetch_and_and
9612 @findex __sync_fetch_and_xor
9613 @findex __sync_fetch_and_nand
9614 These built-in functions perform the operation suggested by the name, and
9615 returns the value that had previously been in memory.  That is, operations
9616 on integer operands have the following semantics.  Operations on pointer
9617 arguments are performed as if the operands were of the @code{uintptr_t}
9618 type.  That is, they are not scaled by the size of the type to which
9619 the pointer points.
9621 @smallexample
9622 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9623 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
9624 @end smallexample
9626 The object pointed to by the first argument must be of integer or pointer
9627 type.  It must not be a boolean type.
9629 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9630 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9632 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9633 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9634 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9635 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9636 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9637 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9638 @findex __sync_add_and_fetch
9639 @findex __sync_sub_and_fetch
9640 @findex __sync_or_and_fetch
9641 @findex __sync_and_and_fetch
9642 @findex __sync_xor_and_fetch
9643 @findex __sync_nand_and_fetch
9644 These built-in functions perform the operation suggested by the name, and
9645 return the new value.  That is, operations on integer operands have
9646 the following semantics.  Operations on pointer operands are performed as
9647 if the operand's type were @code{uintptr_t}.
9649 @smallexample
9650 @{ *ptr @var{op}= value; return *ptr; @}
9651 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
9652 @end smallexample
9654 The same constraints on arguments apply as for the corresponding
9655 @code{__sync_op_and_fetch} built-in functions.
9657 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9658 as @code{*ptr = ~(*ptr & value)} instead of
9659 @code{*ptr = ~*ptr & value}.
9661 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9662 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9663 @findex __sync_bool_compare_and_swap
9664 @findex __sync_val_compare_and_swap
9665 These built-in functions perform an atomic compare and swap.
9666 That is, if the current
9667 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9668 @code{*@var{ptr}}.
9670 The ``bool'' version returns true if the comparison is successful and
9671 @var{newval} is written.  The ``val'' version returns the contents
9672 of @code{*@var{ptr}} before the operation.
9674 @item __sync_synchronize (...)
9675 @findex __sync_synchronize
9676 This built-in function issues a full memory barrier.
9678 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9679 @findex __sync_lock_test_and_set
9680 This built-in function, as described by Intel, is not a traditional test-and-set
9681 operation, but rather an atomic exchange operation.  It writes @var{value}
9682 into @code{*@var{ptr}}, and returns the previous contents of
9683 @code{*@var{ptr}}.
9685 Many targets have only minimal support for such locks, and do not support
9686 a full exchange operation.  In this case, a target may support reduced
9687 functionality here by which the @emph{only} valid value to store is the
9688 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
9689 is implementation defined.
9691 This built-in function is not a full barrier,
9692 but rather an @dfn{acquire barrier}.
9693 This means that references after the operation cannot move to (or be
9694 speculated to) before the operation, but previous memory stores may not
9695 be globally visible yet, and previous memory loads may not yet be
9696 satisfied.
9698 @item void __sync_lock_release (@var{type} *ptr, ...)
9699 @findex __sync_lock_release
9700 This built-in function releases the lock acquired by
9701 @code{__sync_lock_test_and_set}.
9702 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9704 This built-in function is not a full barrier,
9705 but rather a @dfn{release barrier}.
9706 This means that all previous memory stores are globally visible, and all
9707 previous memory loads have been satisfied, but following memory reads
9708 are not prevented from being speculated to before the barrier.
9709 @end table
9711 @node __atomic Builtins
9712 @section Built-in Functions for Memory Model Aware Atomic Operations
9714 The following built-in functions approximately match the requirements
9715 for the C++11 memory model.  They are all
9716 identified by being prefixed with @samp{__atomic} and most are
9717 overloaded so that they work with multiple types.
9719 These functions are intended to replace the legacy @samp{__sync}
9720 builtins.  The main difference is that the memory order that is requested
9721 is a parameter to the functions.  New code should always use the
9722 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9724 Note that the @samp{__atomic} builtins assume that programs will
9725 conform to the C++11 memory model.  In particular, they assume
9726 that programs are free of data races.  See the C++11 standard for
9727 detailed requirements.
9729 The @samp{__atomic} builtins can be used with any integral scalar or
9730 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
9731 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9732 supported by the architecture.
9734 The four non-arithmetic functions (load, store, exchange, and 
9735 compare_exchange) all have a generic version as well.  This generic
9736 version works on any data type.  It uses the lock-free built-in function
9737 if the specific data type size makes that possible; otherwise, an
9738 external call is left to be resolved at run time.  This external call is
9739 the same format with the addition of a @samp{size_t} parameter inserted
9740 as the first parameter indicating the size of the object being pointed to.
9741 All objects must be the same size.
9743 There are 6 different memory orders that can be specified.  These map
9744 to the C++11 memory orders with the same names, see the C++11 standard
9745 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9746 on atomic synchronization} for detailed definitions.  Individual
9747 targets may also support additional memory orders for use on specific
9748 architectures.  Refer to the target documentation for details of
9749 these.
9751 An atomic operation can both constrain code motion and
9752 be mapped to hardware instructions for synchronization between threads
9753 (e.g., a fence).  To which extent this happens is controlled by the
9754 memory orders, which are listed here in approximately ascending order of
9755 strength.  The description of each memory order is only meant to roughly
9756 illustrate the effects and is not a specification; see the C++11
9757 memory model for precise semantics.
9759 @table  @code
9760 @item __ATOMIC_RELAXED
9761 Implies no inter-thread ordering constraints.
9762 @item __ATOMIC_CONSUME
9763 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9764 memory order because of a deficiency in C++11's semantics for
9765 @code{memory_order_consume}.
9766 @item __ATOMIC_ACQUIRE
9767 Creates an inter-thread happens-before constraint from the release (or
9768 stronger) semantic store to this acquire load.  Can prevent hoisting
9769 of code to before the operation.
9770 @item __ATOMIC_RELEASE
9771 Creates an inter-thread happens-before constraint to acquire (or stronger)
9772 semantic loads that read from this release store.  Can prevent sinking
9773 of code to after the operation.
9774 @item __ATOMIC_ACQ_REL
9775 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9776 @code{__ATOMIC_RELEASE}.
9777 @item __ATOMIC_SEQ_CST
9778 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9779 @end table
9781 Note that in the C++11 memory model, @emph{fences} (e.g.,
9782 @samp{__atomic_thread_fence}) take effect in combination with other
9783 atomic operations on specific memory locations (e.g., atomic loads);
9784 operations on specific memory locations do not necessarily affect other
9785 operations in the same way.
9787 Target architectures are encouraged to provide their own patterns for
9788 each of the atomic built-in functions.  If no target is provided, the original
9789 non-memory model set of @samp{__sync} atomic built-in functions are
9790 used, along with any required synchronization fences surrounding it in
9791 order to achieve the proper behavior.  Execution in this case is subject
9792 to the same restrictions as those built-in functions.
9794 If there is no pattern or mechanism to provide a lock-free instruction
9795 sequence, a call is made to an external routine with the same parameters
9796 to be resolved at run time.
9798 When implementing patterns for these built-in functions, the memory order
9799 parameter can be ignored as long as the pattern implements the most
9800 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
9801 orders execute correctly with this memory order but they may not execute as
9802 efficiently as they could with a more appropriate implementation of the
9803 relaxed requirements.
9805 Note that the C++11 standard allows for the memory order parameter to be
9806 determined at run time rather than at compile time.  These built-in
9807 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9808 than invoke a runtime library call or inline a switch statement.  This is
9809 standard compliant, safe, and the simplest approach for now.
9811 The memory order parameter is a signed int, but only the lower 16 bits are
9812 reserved for the memory order.  The remainder of the signed int is reserved
9813 for target use and should be 0.  Use of the predefined atomic values
9814 ensures proper usage.
9816 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9817 This built-in function implements an atomic load operation.  It returns the
9818 contents of @code{*@var{ptr}}.
9820 The valid memory order variants are
9821 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9822 and @code{__ATOMIC_CONSUME}.
9824 @end deftypefn
9826 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9827 This is the generic version of an atomic load.  It returns the
9828 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9830 @end deftypefn
9832 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9833 This built-in function implements an atomic store operation.  It writes 
9834 @code{@var{val}} into @code{*@var{ptr}}.  
9836 The valid memory order variants are
9837 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9839 @end deftypefn
9841 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9842 This is the generic version of an atomic store.  It stores the value
9843 of @code{*@var{val}} into @code{*@var{ptr}}.
9845 @end deftypefn
9847 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9848 This built-in function implements an atomic exchange operation.  It writes
9849 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9850 @code{*@var{ptr}}.
9852 The valid memory order variants are
9853 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9854 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9856 @end deftypefn
9858 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9859 This is the generic version of an atomic exchange.  It stores the
9860 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9861 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9863 @end deftypefn
9865 @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)
9866 This built-in function implements an atomic compare and exchange operation.
9867 This compares the contents of @code{*@var{ptr}} with the contents of
9868 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9869 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
9870 equal, the operation is a @emph{read} and the current contents of
9871 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
9872 for weak compare_exchange, which may fail spuriously, and false for
9873 the strong variation, which never fails spuriously.  Many targets
9874 only offer the strong variation and ignore the parameter.  When in doubt, use
9875 the strong variation.
9877 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9878 and memory is affected according to the
9879 memory order specified by @var{success_memorder}.  There are no
9880 restrictions on what memory order can be used here.
9882 Otherwise, false is returned and memory is affected according
9883 to @var{failure_memorder}. This memory order cannot be
9884 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
9885 stronger order than that specified by @var{success_memorder}.
9887 @end deftypefn
9889 @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)
9890 This built-in function implements the generic version of
9891 @code{__atomic_compare_exchange}.  The function is virtually identical to
9892 @code{__atomic_compare_exchange_n}, except the desired value is also a
9893 pointer.
9895 @end deftypefn
9897 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9898 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9899 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9900 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9901 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9902 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9903 These built-in functions perform the operation suggested by the name, and
9904 return the result of the operation.  Operations on pointer arguments are
9905 performed as if the operands were of the @code{uintptr_t} type.  That is,
9906 they are not scaled by the size of the type to which the pointer points.
9908 @smallexample
9909 @{ *ptr @var{op}= val; return *ptr; @}
9910 @end smallexample
9912 The object pointed to by the first argument must be of integer or pointer
9913 type.  It must not be a boolean type.  All memory orders are valid.
9915 @end deftypefn
9917 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9918 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9919 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9920 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9921 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9922 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9923 These built-in functions perform the operation suggested by the name, and
9924 return the value that had previously been in @code{*@var{ptr}}.  Operations
9925 on pointer arguments are performed as if the operands were of
9926 the @code{uintptr_t} type.  That is, they are not scaled by the size of
9927 the type to which the pointer points.
9929 @smallexample
9930 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9931 @end smallexample
9933 The same constraints on arguments apply as for the corresponding
9934 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
9936 @end deftypefn
9938 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9940 This built-in function performs an atomic test-and-set operation on
9941 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9942 defined nonzero ``set'' value and the return value is @code{true} if and only
9943 if the previous contents were ``set''.
9944 It should be only used for operands of type @code{bool} or @code{char}. For 
9945 other types only part of the value may be set.
9947 All memory orders are valid.
9949 @end deftypefn
9951 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9953 This built-in function performs an atomic clear operation on
9954 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9955 It should be only used for operands of type @code{bool} or @code{char} and 
9956 in conjunction with @code{__atomic_test_and_set}.
9957 For other types it may only clear partially. If the type is not @code{bool}
9958 prefer using @code{__atomic_store}.
9960 The valid memory order variants are
9961 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9962 @code{__ATOMIC_RELEASE}.
9964 @end deftypefn
9966 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9968 This built-in function acts as a synchronization fence between threads
9969 based on the specified memory order.
9971 All memory orders are valid.
9973 @end deftypefn
9975 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9977 This built-in function acts as a synchronization fence between a thread
9978 and signal handlers based in the same thread.
9980 All memory orders are valid.
9982 @end deftypefn
9984 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
9986 This built-in function returns true if objects of @var{size} bytes always
9987 generate lock-free atomic instructions for the target architecture.
9988 @var{size} must resolve to a compile-time constant and the result also
9989 resolves to a compile-time constant.
9991 @var{ptr} is an optional pointer to the object that may be used to determine
9992 alignment.  A value of 0 indicates typical alignment should be used.  The 
9993 compiler may also ignore this parameter.
9995 @smallexample
9996 if (__atomic_always_lock_free (sizeof (long long), 0))
9997 @end smallexample
9999 @end deftypefn
10001 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10003 This built-in function returns true if objects of @var{size} bytes always
10004 generate lock-free atomic instructions for the target architecture.  If
10005 the built-in function is not known to be lock-free, a call is made to a
10006 runtime routine named @code{__atomic_is_lock_free}.
10008 @var{ptr} is an optional pointer to the object that may be used to determine
10009 alignment.  A value of 0 indicates typical alignment should be used.  The 
10010 compiler may also ignore this parameter.
10011 @end deftypefn
10013 @node Integer Overflow Builtins
10014 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10016 The following built-in functions allow performing simple arithmetic operations
10017 together with checking whether the operations overflowed.
10019 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10020 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10021 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10022 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10023 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10024 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10025 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10027 These built-in functions promote the first two operands into infinite precision signed
10028 type and perform addition on those promoted operands.  The result is then
10029 cast to the type the third pointer argument points to and stored there.
10030 If the stored result is equal to the infinite precision result, the built-in
10031 functions return false, otherwise they return true.  As the addition is
10032 performed in infinite signed precision, these built-in functions have fully defined
10033 behavior for all argument values.
10035 The first built-in function allows arbitrary integral types for operands and
10036 the result type must be pointer to some integral type other than enumerated or
10037 boolean type, the rest of the built-in functions have explicit integer types.
10039 The compiler will attempt to use hardware instructions to implement
10040 these built-in functions where possible, like conditional jump on overflow
10041 after addition, conditional jump on carry etc.
10043 @end deftypefn
10045 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10046 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10047 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10048 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10049 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10050 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10051 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10053 These built-in functions are similar to the add overflow checking built-in
10054 functions above, except they perform subtraction, subtract the second argument
10055 from the first one, instead of addition.
10057 @end deftypefn
10059 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10060 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10061 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10062 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10063 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10064 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10065 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10067 These built-in functions are similar to the add overflow checking built-in
10068 functions above, except they perform multiplication, instead of addition.
10070 @end deftypefn
10072 The following built-in functions allow checking if simple arithmetic operation
10073 would overflow.
10075 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10076 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10077 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10079 These built-in functions are similar to @code{__builtin_add_overflow},
10080 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10081 they don't store the result of the arithmetic operation anywhere and the
10082 last argument is not a pointer, but some expression with integral type other
10083 than enumerated or boolean type.
10085 The built-in functions promote the first two operands into infinite precision signed type
10086 and perform addition on those promoted operands. The result is then
10087 cast to the type of the third argument.  If the cast result is equal to the infinite
10088 precision result, the built-in functions return false, otherwise they return true.
10089 The value of the third argument is ignored, just the side-effects in the third argument
10090 are evaluated, and no integral argument promotions are performed on the last argument.
10091 If the third argument is a bit-field, the type used for the result cast has the
10092 precision and signedness of the given bit-field, rather than precision and signedness
10093 of the underlying type.
10095 For example, the following macro can be used to portably check, at
10096 compile-time, whether or not adding two constant integers will overflow,
10097 and perform the addition only when it is known to be safe and not to trigger
10098 a @option{-Woverflow} warning.
10100 @smallexample
10101 #define INT_ADD_OVERFLOW_P(a, b) \
10102    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10104 enum @{
10105     A = INT_MAX, B = 3,
10106     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10107     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10109 @end smallexample
10111 The compiler will attempt to use hardware instructions to implement
10112 these built-in functions where possible, like conditional jump on overflow
10113 after addition, conditional jump on carry etc.
10115 @end deftypefn
10117 @node x86 specific memory model extensions for transactional memory
10118 @section x86-Specific Memory Model Extensions for Transactional Memory
10120 The x86 architecture supports additional memory ordering flags
10121 to mark critical sections for hardware lock elision. 
10122 These must be specified in addition to an existing memory order to
10123 atomic intrinsics.
10125 @table @code
10126 @item __ATOMIC_HLE_ACQUIRE
10127 Start lock elision on a lock variable.
10128 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10129 @item __ATOMIC_HLE_RELEASE
10130 End lock elision on a lock variable.
10131 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10132 @end table
10134 When a lock acquire fails, it is required for good performance to abort
10135 the transaction quickly. This can be done with a @code{_mm_pause}.
10137 @smallexample
10138 #include <immintrin.h> // For _mm_pause
10140 int lockvar;
10142 /* Acquire lock with lock elision */
10143 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10144     _mm_pause(); /* Abort failed transaction */
10146 /* Free lock with lock elision */
10147 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10148 @end smallexample
10150 @node Object Size Checking
10151 @section Object Size Checking Built-in Functions
10152 @findex __builtin_object_size
10153 @findex __builtin___memcpy_chk
10154 @findex __builtin___mempcpy_chk
10155 @findex __builtin___memmove_chk
10156 @findex __builtin___memset_chk
10157 @findex __builtin___strcpy_chk
10158 @findex __builtin___stpcpy_chk
10159 @findex __builtin___strncpy_chk
10160 @findex __builtin___strcat_chk
10161 @findex __builtin___strncat_chk
10162 @findex __builtin___sprintf_chk
10163 @findex __builtin___snprintf_chk
10164 @findex __builtin___vsprintf_chk
10165 @findex __builtin___vsnprintf_chk
10166 @findex __builtin___printf_chk
10167 @findex __builtin___vprintf_chk
10168 @findex __builtin___fprintf_chk
10169 @findex __builtin___vfprintf_chk
10171 GCC implements a limited buffer overflow protection mechanism that can
10172 prevent some buffer overflow attacks by determining the sizes of objects
10173 into which data is about to be written and preventing the writes when
10174 the size isn't sufficient.  The built-in functions described below yield
10175 the best results when used together and when optimization is enabled.
10176 For example, to detect object sizes across function boundaries or to
10177 follow pointer assignments through non-trivial control flow they rely
10178 on various optimization passes enabled with @option{-O2}.  However, to
10179 a limited extent, they can be used without optimization as well.
10181 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10182 is a built-in construct that returns a constant number of bytes from
10183 @var{ptr} to the end of the object @var{ptr} pointer points to
10184 (if known at compile time).  @code{__builtin_object_size} never evaluates
10185 its arguments for side-effects.  If there are any side-effects in them, it
10186 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10187 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10188 point to and all of them are known at compile time, the returned number
10189 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10190 0 and minimum if nonzero.  If it is not possible to determine which objects
10191 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10192 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10193 for @var{type} 2 or 3.
10195 @var{type} is an integer constant from 0 to 3.  If the least significant
10196 bit is clear, objects are whole variables, if it is set, a closest
10197 surrounding subobject is considered the object a pointer points to.
10198 The second bit determines if maximum or minimum of remaining bytes
10199 is computed.
10201 @smallexample
10202 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10203 char *p = &var.buf1[1], *q = &var.b;
10205 /* Here the object p points to is var.  */
10206 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10207 /* The subobject p points to is var.buf1.  */
10208 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10209 /* The object q points to is var.  */
10210 assert (__builtin_object_size (q, 0)
10211         == (char *) (&var + 1) - (char *) &var.b);
10212 /* The subobject q points to is var.b.  */
10213 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10214 @end smallexample
10215 @end deftypefn
10217 There are built-in functions added for many common string operation
10218 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10219 built-in is provided.  This built-in has an additional last argument,
10220 which is the number of bytes remaining in the object the @var{dest}
10221 argument points to or @code{(size_t) -1} if the size is not known.
10223 The built-in functions are optimized into the normal string functions
10224 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10225 it is known at compile time that the destination object will not
10226 be overflowed.  If the compiler can determine at compile time that the
10227 object will always be overflowed, it issues a warning.
10229 The intended use can be e.g.@:
10231 @smallexample
10232 #undef memcpy
10233 #define bos0(dest) __builtin_object_size (dest, 0)
10234 #define memcpy(dest, src, n) \
10235   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10237 char *volatile p;
10238 char buf[10];
10239 /* It is unknown what object p points to, so this is optimized
10240    into plain memcpy - no checking is possible.  */
10241 memcpy (p, "abcde", n);
10242 /* Destination is known and length too.  It is known at compile
10243    time there will be no overflow.  */
10244 memcpy (&buf[5], "abcde", 5);
10245 /* Destination is known, but the length is not known at compile time.
10246    This will result in __memcpy_chk call that can check for overflow
10247    at run time.  */
10248 memcpy (&buf[5], "abcde", n);
10249 /* Destination is known and it is known at compile time there will
10250    be overflow.  There will be a warning and __memcpy_chk call that
10251    will abort the program at run time.  */
10252 memcpy (&buf[6], "abcde", 5);
10253 @end smallexample
10255 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10256 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10257 @code{strcat} and @code{strncat}.
10259 There are also checking built-in functions for formatted output functions.
10260 @smallexample
10261 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10262 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10263                               const char *fmt, ...);
10264 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10265                               va_list ap);
10266 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10267                                const char *fmt, va_list ap);
10268 @end smallexample
10270 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10271 etc.@: functions and can contain implementation specific flags on what
10272 additional security measures the checking function might take, such as
10273 handling @code{%n} differently.
10275 The @var{os} argument is the object size @var{s} points to, like in the
10276 other built-in functions.  There is a small difference in the behavior
10277 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10278 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10279 the checking function is called with @var{os} argument set to
10280 @code{(size_t) -1}.
10282 In addition to this, there are checking built-in functions
10283 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10284 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10285 These have just one additional argument, @var{flag}, right before
10286 format string @var{fmt}.  If the compiler is able to optimize them to
10287 @code{fputc} etc.@: functions, it does, otherwise the checking function
10288 is called and the @var{flag} argument passed to it.
10290 @node Pointer Bounds Checker builtins
10291 @section Pointer Bounds Checker Built-in Functions
10292 @cindex Pointer Bounds Checker builtins
10293 @findex __builtin___bnd_set_ptr_bounds
10294 @findex __builtin___bnd_narrow_ptr_bounds
10295 @findex __builtin___bnd_copy_ptr_bounds
10296 @findex __builtin___bnd_init_ptr_bounds
10297 @findex __builtin___bnd_null_ptr_bounds
10298 @findex __builtin___bnd_store_ptr_bounds
10299 @findex __builtin___bnd_chk_ptr_lbounds
10300 @findex __builtin___bnd_chk_ptr_ubounds
10301 @findex __builtin___bnd_chk_ptr_bounds
10302 @findex __builtin___bnd_get_ptr_lbound
10303 @findex __builtin___bnd_get_ptr_ubound
10305 GCC provides a set of built-in functions to control Pointer Bounds Checker
10306 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
10307 even if you compile with Pointer Bounds Checker off
10308 (@option{-fno-check-pointer-bounds}).
10309 The behavior may differ in such case as documented below.
10311 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10313 This built-in function returns a new pointer with the value of @var{q}, and
10314 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
10315 Bounds Checker off, the built-in function just returns the first argument.
10317 @smallexample
10318 extern void *__wrap_malloc (size_t n)
10320   void *p = (void *)__real_malloc (n);
10321   if (!p) return __builtin___bnd_null_ptr_bounds (p);
10322   return __builtin___bnd_set_ptr_bounds (p, n);
10324 @end smallexample
10326 @end deftypefn
10328 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
10330 This built-in function returns a new pointer with the value of @var{p}
10331 and associates it with the narrowed bounds formed by the intersection
10332 of bounds associated with @var{q} and the bounds
10333 [@var{p}, @var{p} + @var{size} - 1].
10334 With Pointer Bounds Checker off, the built-in function just returns the first
10335 argument.
10337 @smallexample
10338 void init_objects (object *objs, size_t size)
10340   size_t i;
10341   /* Initialize objects one-by-one passing pointers with bounds of 
10342      an object, not the full array of objects.  */
10343   for (i = 0; i < size; i++)
10344     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10345                                                     sizeof(object)));
10347 @end smallexample
10349 @end deftypefn
10351 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10353 This built-in function returns a new pointer with the value of @var{q},
10354 and associates it with the bounds already associated with pointer @var{r}.
10355 With Pointer Bounds Checker off, the built-in function just returns the first
10356 argument.
10358 @smallexample
10359 /* Here is a way to get pointer to object's field but
10360    still with the full object's bounds.  */
10361 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
10362                                                   objptr);
10363 @end smallexample
10365 @end deftypefn
10367 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10369 This built-in function returns a new pointer with the value of @var{q}, and
10370 associates it with INIT (allowing full memory access) bounds. With Pointer
10371 Bounds Checker off, the built-in function just returns the first argument.
10373 @end deftypefn
10375 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10377 This built-in function returns a new pointer with the value of @var{q}, and
10378 associates it with NULL (allowing no memory access) bounds. With Pointer
10379 Bounds Checker off, the built-in function just returns the first argument.
10381 @end deftypefn
10383 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10385 This built-in function stores the bounds associated with pointer @var{ptr_val}
10386 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
10387 bounds from legacy code without touching the associated pointer's memory when
10388 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
10389 function call is ignored.
10391 @end deftypefn
10393 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10395 This built-in function checks if the pointer @var{q} is within the lower
10396 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10397 function call is ignored.
10399 @smallexample
10400 extern void *__wrap_memset (void *dst, int c, size_t len)
10402   if (len > 0)
10403     @{
10404       __builtin___bnd_chk_ptr_lbounds (dst);
10405       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10406       __real_memset (dst, c, len);
10407     @}
10408   return dst;
10410 @end smallexample
10412 @end deftypefn
10414 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10416 This built-in function checks if the pointer @var{q} is within the upper
10417 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10418 function call is ignored.
10420 @end deftypefn
10422 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10424 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10425 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
10426 off, the built-in function call is ignored.
10428 @smallexample
10429 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10431   if (n > 0)
10432     @{
10433       __bnd_chk_ptr_bounds (dst, n);
10434       __bnd_chk_ptr_bounds (src, n);
10435       __real_memcpy (dst, src, n);
10436     @}
10437   return dst;
10439 @end smallexample
10441 @end deftypefn
10443 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10445 This built-in function returns the lower bound associated
10446 with the pointer @var{q}, as a pointer value.  
10447 This is useful for debugging using @code{printf}.
10448 With Pointer Bounds Checker off, the built-in function returns 0.
10450 @smallexample
10451 void *lb = __builtin___bnd_get_ptr_lbound (q);
10452 void *ub = __builtin___bnd_get_ptr_ubound (q);
10453 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
10454 @end smallexample
10456 @end deftypefn
10458 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10460 This built-in function returns the upper bound (which is a pointer) associated
10461 with the pointer @var{q}.  With Pointer Bounds Checker off,
10462 the built-in function returns -1.
10464 @end deftypefn
10466 @node Cilk Plus Builtins
10467 @section Cilk Plus C/C++ Language Extension Built-in Functions
10469 GCC provides support for the following built-in reduction functions if Cilk Plus
10470 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10472 @itemize @bullet
10473 @item @code{__sec_implicit_index}
10474 @item @code{__sec_reduce}
10475 @item @code{__sec_reduce_add}
10476 @item @code{__sec_reduce_all_nonzero}
10477 @item @code{__sec_reduce_all_zero}
10478 @item @code{__sec_reduce_any_nonzero}
10479 @item @code{__sec_reduce_any_zero}
10480 @item @code{__sec_reduce_max}
10481 @item @code{__sec_reduce_min}
10482 @item @code{__sec_reduce_max_ind}
10483 @item @code{__sec_reduce_min_ind}
10484 @item @code{__sec_reduce_mul}
10485 @item @code{__sec_reduce_mutating}
10486 @end itemize
10488 Further details and examples about these built-in functions are described 
10489 in the Cilk Plus language manual which can be found at 
10490 @uref{https://www.cilkplus.org}.
10492 @node Other Builtins
10493 @section Other Built-in Functions Provided by GCC
10494 @cindex built-in functions
10495 @findex __builtin_alloca
10496 @findex __builtin_alloca_with_align
10497 @findex __builtin_call_with_static_chain
10498 @findex __builtin_fpclassify
10499 @findex __builtin_isfinite
10500 @findex __builtin_isnormal
10501 @findex __builtin_isgreater
10502 @findex __builtin_isgreaterequal
10503 @findex __builtin_isinf_sign
10504 @findex __builtin_isless
10505 @findex __builtin_islessequal
10506 @findex __builtin_islessgreater
10507 @findex __builtin_isunordered
10508 @findex __builtin_powi
10509 @findex __builtin_powif
10510 @findex __builtin_powil
10511 @findex _Exit
10512 @findex _exit
10513 @findex abort
10514 @findex abs
10515 @findex acos
10516 @findex acosf
10517 @findex acosh
10518 @findex acoshf
10519 @findex acoshl
10520 @findex acosl
10521 @findex alloca
10522 @findex asin
10523 @findex asinf
10524 @findex asinh
10525 @findex asinhf
10526 @findex asinhl
10527 @findex asinl
10528 @findex atan
10529 @findex atan2
10530 @findex atan2f
10531 @findex atan2l
10532 @findex atanf
10533 @findex atanh
10534 @findex atanhf
10535 @findex atanhl
10536 @findex atanl
10537 @findex bcmp
10538 @findex bzero
10539 @findex cabs
10540 @findex cabsf
10541 @findex cabsl
10542 @findex cacos
10543 @findex cacosf
10544 @findex cacosh
10545 @findex cacoshf
10546 @findex cacoshl
10547 @findex cacosl
10548 @findex calloc
10549 @findex carg
10550 @findex cargf
10551 @findex cargl
10552 @findex casin
10553 @findex casinf
10554 @findex casinh
10555 @findex casinhf
10556 @findex casinhl
10557 @findex casinl
10558 @findex catan
10559 @findex catanf
10560 @findex catanh
10561 @findex catanhf
10562 @findex catanhl
10563 @findex catanl
10564 @findex cbrt
10565 @findex cbrtf
10566 @findex cbrtl
10567 @findex ccos
10568 @findex ccosf
10569 @findex ccosh
10570 @findex ccoshf
10571 @findex ccoshl
10572 @findex ccosl
10573 @findex ceil
10574 @findex ceilf
10575 @findex ceill
10576 @findex cexp
10577 @findex cexpf
10578 @findex cexpl
10579 @findex cimag
10580 @findex cimagf
10581 @findex cimagl
10582 @findex clog
10583 @findex clogf
10584 @findex clogl
10585 @findex clog10
10586 @findex clog10f
10587 @findex clog10l
10588 @findex conj
10589 @findex conjf
10590 @findex conjl
10591 @findex copysign
10592 @findex copysignf
10593 @findex copysignl
10594 @findex cos
10595 @findex cosf
10596 @findex cosh
10597 @findex coshf
10598 @findex coshl
10599 @findex cosl
10600 @findex cpow
10601 @findex cpowf
10602 @findex cpowl
10603 @findex cproj
10604 @findex cprojf
10605 @findex cprojl
10606 @findex creal
10607 @findex crealf
10608 @findex creall
10609 @findex csin
10610 @findex csinf
10611 @findex csinh
10612 @findex csinhf
10613 @findex csinhl
10614 @findex csinl
10615 @findex csqrt
10616 @findex csqrtf
10617 @findex csqrtl
10618 @findex ctan
10619 @findex ctanf
10620 @findex ctanh
10621 @findex ctanhf
10622 @findex ctanhl
10623 @findex ctanl
10624 @findex dcgettext
10625 @findex dgettext
10626 @findex drem
10627 @findex dremf
10628 @findex dreml
10629 @findex erf
10630 @findex erfc
10631 @findex erfcf
10632 @findex erfcl
10633 @findex erff
10634 @findex erfl
10635 @findex exit
10636 @findex exp
10637 @findex exp10
10638 @findex exp10f
10639 @findex exp10l
10640 @findex exp2
10641 @findex exp2f
10642 @findex exp2l
10643 @findex expf
10644 @findex expl
10645 @findex expm1
10646 @findex expm1f
10647 @findex expm1l
10648 @findex fabs
10649 @findex fabsf
10650 @findex fabsl
10651 @findex fdim
10652 @findex fdimf
10653 @findex fdiml
10654 @findex ffs
10655 @findex floor
10656 @findex floorf
10657 @findex floorl
10658 @findex fma
10659 @findex fmaf
10660 @findex fmal
10661 @findex fmax
10662 @findex fmaxf
10663 @findex fmaxl
10664 @findex fmin
10665 @findex fminf
10666 @findex fminl
10667 @findex fmod
10668 @findex fmodf
10669 @findex fmodl
10670 @findex fprintf
10671 @findex fprintf_unlocked
10672 @findex fputs
10673 @findex fputs_unlocked
10674 @findex frexp
10675 @findex frexpf
10676 @findex frexpl
10677 @findex fscanf
10678 @findex gamma
10679 @findex gammaf
10680 @findex gammal
10681 @findex gamma_r
10682 @findex gammaf_r
10683 @findex gammal_r
10684 @findex gettext
10685 @findex hypot
10686 @findex hypotf
10687 @findex hypotl
10688 @findex ilogb
10689 @findex ilogbf
10690 @findex ilogbl
10691 @findex imaxabs
10692 @findex index
10693 @findex isalnum
10694 @findex isalpha
10695 @findex isascii
10696 @findex isblank
10697 @findex iscntrl
10698 @findex isdigit
10699 @findex isgraph
10700 @findex islower
10701 @findex isprint
10702 @findex ispunct
10703 @findex isspace
10704 @findex isupper
10705 @findex iswalnum
10706 @findex iswalpha
10707 @findex iswblank
10708 @findex iswcntrl
10709 @findex iswdigit
10710 @findex iswgraph
10711 @findex iswlower
10712 @findex iswprint
10713 @findex iswpunct
10714 @findex iswspace
10715 @findex iswupper
10716 @findex iswxdigit
10717 @findex isxdigit
10718 @findex j0
10719 @findex j0f
10720 @findex j0l
10721 @findex j1
10722 @findex j1f
10723 @findex j1l
10724 @findex jn
10725 @findex jnf
10726 @findex jnl
10727 @findex labs
10728 @findex ldexp
10729 @findex ldexpf
10730 @findex ldexpl
10731 @findex lgamma
10732 @findex lgammaf
10733 @findex lgammal
10734 @findex lgamma_r
10735 @findex lgammaf_r
10736 @findex lgammal_r
10737 @findex llabs
10738 @findex llrint
10739 @findex llrintf
10740 @findex llrintl
10741 @findex llround
10742 @findex llroundf
10743 @findex llroundl
10744 @findex log
10745 @findex log10
10746 @findex log10f
10747 @findex log10l
10748 @findex log1p
10749 @findex log1pf
10750 @findex log1pl
10751 @findex log2
10752 @findex log2f
10753 @findex log2l
10754 @findex logb
10755 @findex logbf
10756 @findex logbl
10757 @findex logf
10758 @findex logl
10759 @findex lrint
10760 @findex lrintf
10761 @findex lrintl
10762 @findex lround
10763 @findex lroundf
10764 @findex lroundl
10765 @findex malloc
10766 @findex memchr
10767 @findex memcmp
10768 @findex memcpy
10769 @findex mempcpy
10770 @findex memset
10771 @findex modf
10772 @findex modff
10773 @findex modfl
10774 @findex nearbyint
10775 @findex nearbyintf
10776 @findex nearbyintl
10777 @findex nextafter
10778 @findex nextafterf
10779 @findex nextafterl
10780 @findex nexttoward
10781 @findex nexttowardf
10782 @findex nexttowardl
10783 @findex pow
10784 @findex pow10
10785 @findex pow10f
10786 @findex pow10l
10787 @findex powf
10788 @findex powl
10789 @findex printf
10790 @findex printf_unlocked
10791 @findex putchar
10792 @findex puts
10793 @findex remainder
10794 @findex remainderf
10795 @findex remainderl
10796 @findex remquo
10797 @findex remquof
10798 @findex remquol
10799 @findex rindex
10800 @findex rint
10801 @findex rintf
10802 @findex rintl
10803 @findex round
10804 @findex roundf
10805 @findex roundl
10806 @findex scalb
10807 @findex scalbf
10808 @findex scalbl
10809 @findex scalbln
10810 @findex scalblnf
10811 @findex scalblnf
10812 @findex scalbn
10813 @findex scalbnf
10814 @findex scanfnl
10815 @findex signbit
10816 @findex signbitf
10817 @findex signbitl
10818 @findex signbitd32
10819 @findex signbitd64
10820 @findex signbitd128
10821 @findex significand
10822 @findex significandf
10823 @findex significandl
10824 @findex sin
10825 @findex sincos
10826 @findex sincosf
10827 @findex sincosl
10828 @findex sinf
10829 @findex sinh
10830 @findex sinhf
10831 @findex sinhl
10832 @findex sinl
10833 @findex snprintf
10834 @findex sprintf
10835 @findex sqrt
10836 @findex sqrtf
10837 @findex sqrtl
10838 @findex sscanf
10839 @findex stpcpy
10840 @findex stpncpy
10841 @findex strcasecmp
10842 @findex strcat
10843 @findex strchr
10844 @findex strcmp
10845 @findex strcpy
10846 @findex strcspn
10847 @findex strdup
10848 @findex strfmon
10849 @findex strftime
10850 @findex strlen
10851 @findex strncasecmp
10852 @findex strncat
10853 @findex strncmp
10854 @findex strncpy
10855 @findex strndup
10856 @findex strpbrk
10857 @findex strrchr
10858 @findex strspn
10859 @findex strstr
10860 @findex tan
10861 @findex tanf
10862 @findex tanh
10863 @findex tanhf
10864 @findex tanhl
10865 @findex tanl
10866 @findex tgamma
10867 @findex tgammaf
10868 @findex tgammal
10869 @findex toascii
10870 @findex tolower
10871 @findex toupper
10872 @findex towlower
10873 @findex towupper
10874 @findex trunc
10875 @findex truncf
10876 @findex truncl
10877 @findex vfprintf
10878 @findex vfscanf
10879 @findex vprintf
10880 @findex vscanf
10881 @findex vsnprintf
10882 @findex vsprintf
10883 @findex vsscanf
10884 @findex y0
10885 @findex y0f
10886 @findex y0l
10887 @findex y1
10888 @findex y1f
10889 @findex y1l
10890 @findex yn
10891 @findex ynf
10892 @findex ynl
10894 GCC provides a large number of built-in functions other than the ones
10895 mentioned above.  Some of these are for internal use in the processing
10896 of exceptions or variable-length argument lists and are not
10897 documented here because they may change from time to time; we do not
10898 recommend general use of these functions.
10900 The remaining functions are provided for optimization purposes.
10902 With the exception of built-ins that have library equivalents such as
10903 the standard C library functions discussed below, or that expand to
10904 library calls, GCC built-in functions are always expanded inline and
10905 thus do not have corresponding entry points and their address cannot
10906 be obtained.  Attempting to use them in an expression other than
10907 a function call results in a compile-time error.
10909 @opindex fno-builtin
10910 GCC includes built-in versions of many of the functions in the standard
10911 C library.  These functions come in two forms: one whose names start with
10912 the @code{__builtin_} prefix, and the other without.  Both forms have the
10913 same type (including prototype), the same address (when their address is
10914 taken), and the same meaning as the C library functions even if you specify
10915 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
10916 functions are only optimized in certain cases; if they are not optimized in
10917 a particular case, a call to the library function is emitted.
10919 @opindex ansi
10920 @opindex std
10921 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10922 @option{-std=c99} or @option{-std=c11}), the functions
10923 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10924 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10925 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10926 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10927 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10928 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10929 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10930 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10931 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10932 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10933 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10934 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10935 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10936 @code{significandl}, @code{significand}, @code{sincosf},
10937 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10938 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10939 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10940 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10941 @code{yn}
10942 may be handled as built-in functions.
10943 All these functions have corresponding versions
10944 prefixed with @code{__builtin_}, which may be used even in strict C90
10945 mode.
10947 The ISO C99 functions
10948 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10949 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10950 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10951 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10952 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10953 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10954 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10955 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10956 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10957 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10958 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10959 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10960 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10961 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10962 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10963 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10964 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10965 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10966 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10967 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10968 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10969 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10970 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10971 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10972 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10973 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10974 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10975 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10976 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10977 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10978 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10979 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10980 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10981 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10982 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10983 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10984 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10985 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10986 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10987 are handled as built-in functions
10988 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10990 There are also built-in versions of the ISO C99 functions
10991 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10992 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10993 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10994 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10995 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10996 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10997 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10998 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10999 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11000 that are recognized in any mode since ISO C90 reserves these names for
11001 the purpose to which ISO C99 puts them.  All these functions have
11002 corresponding versions prefixed with @code{__builtin_}.
11004 There are also built-in functions @code{__builtin_fabsf@var{n}},
11005 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11006 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11007 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11008 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11009 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11011 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11012 @code{clog10l} which names are reserved by ISO C99 for future use.
11013 All these functions have versions prefixed with @code{__builtin_}.
11015 The ISO C94 functions
11016 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11017 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11018 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11019 @code{towupper}
11020 are handled as built-in functions
11021 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11023 The ISO C90 functions
11024 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11025 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11026 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11027 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11028 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11029 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11030 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11031 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11032 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11033 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11034 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11035 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11036 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11037 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11038 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11039 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11040 are all recognized as built-in functions unless
11041 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11042 is specified for an individual function).  All of these functions have
11043 corresponding versions prefixed with @code{__builtin_}.
11045 GCC provides built-in versions of the ISO C99 floating-point comparison
11046 macros that avoid raising exceptions for unordered operands.  They have
11047 the same names as the standard macros ( @code{isgreater},
11048 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11049 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11050 prefixed.  We intend for a library implementor to be able to simply
11051 @code{#define} each standard macro to its built-in equivalent.
11052 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11053 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11054 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11055 built-in functions appear both with and without the @code{__builtin_} prefix.
11057 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11058 The @code{__builtin_alloca} function must be called at block scope.
11059 The function allocates an object @var{size} bytes large on the stack
11060 of the calling function.  The object is aligned on the default stack
11061 alignment boundary for the target determined by the
11062 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11063 function returns a pointer to the first byte of the allocated object.
11064 The lifetime of the allocated object ends just before the calling
11065 function returns to its caller.   This is so even when
11066 @code{__builtin_alloca} is called within a nested block.
11068 For example, the following function allocates eight objects of @code{n}
11069 bytes each on the stack, storing a pointer to each in consecutive elements
11070 of the array @code{a}.  It then passes the array to function @code{g}
11071 which can safely use the storage pointed to by each of the array elements.
11073 @smallexample
11074 void f (unsigned n)
11076   void *a [8];
11077   for (int i = 0; i != 8; ++i)
11078     a [i] = __builtin_alloca (n);
11080   g (a, n);   // @r{safe}
11082 @end smallexample
11084 Since the @code{__builtin_alloca} function doesn't validate its argument
11085 it is the responsibility of its caller to make sure the argument doesn't
11086 cause it to exceed the stack size limit.
11087 The @code{__builtin_alloca} function is provided to make it possible to
11088 allocate on the stack arrays of bytes with an upper bound that may be
11089 computed at run time.  Since C99 Variable Length Arrays offer
11090 similar functionality under a portable, more convenient, and safer
11091 interface they are recommended instead, in both C99 and C++ programs
11092 where GCC provides them as an extension.
11093 @xref{Variable Length}, for details.
11095 @end deftypefn
11097 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11098 The @code{__builtin_alloca_with_align} function must be called at block
11099 scope.  The function allocates an object @var{size} bytes large on
11100 the stack of the calling function.  The allocated object is aligned on
11101 the boundary specified by the argument @var{alignment} whose unit is given
11102 in bits (not bytes).  The @var{size} argument must be positive and not
11103 exceed the stack size limit.  The @var{alignment} argument must be a constant
11104 integer expression that evaluates to a power of 2 greater than or equal to
11105 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11106 with other values are rejected with an error indicating the valid bounds.
11107 The function returns a pointer to the first byte of the allocated object.
11108 The lifetime of the allocated object ends at the end of the block in which
11109 the function was called.  The allocated storage is released no later than
11110 just before the calling function returns to its caller, but may be released
11111 at the end of the block in which the function was called.
11113 For example, in the following function the call to @code{g} is unsafe
11114 because when @code{overalign} is non-zero, the space allocated by
11115 @code{__builtin_alloca_with_align} may have been released at the end
11116 of the @code{if} statement in which it was called.
11118 @smallexample
11119 void f (unsigned n, bool overalign)
11121   void *p;
11122   if (overalign)
11123     p = __builtin_alloca_with_align (n, 64 /* bits */);
11124   else
11125     p = __builtin_alloc (n);
11127   g (p, n);   // @r{unsafe}
11129 @end smallexample
11131 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11132 @var{size} argument it is the responsibility of its caller to make sure
11133 the argument doesn't cause it to exceed the stack size limit.
11134 The @code{__builtin_alloca_with_align} function is provided to make
11135 it possible to allocate on the stack overaligned arrays of bytes with
11136 an upper bound that may be computed at run time.  Since C99
11137 Variable Length Arrays offer the same functionality under
11138 a portable, more convenient, and safer interface they are recommended
11139 instead, in both C99 and C++ programs where GCC provides them as
11140 an extension.  @xref{Variable Length}, for details.
11142 @end deftypefn
11144 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11146 You can use the built-in function @code{__builtin_types_compatible_p} to
11147 determine whether two types are the same.
11149 This built-in function returns 1 if the unqualified versions of the
11150 types @var{type1} and @var{type2} (which are types, not expressions) are
11151 compatible, 0 otherwise.  The result of this built-in function can be
11152 used in integer constant expressions.
11154 This built-in function ignores top level qualifiers (e.g., @code{const},
11155 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11156 int}.
11158 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11159 hand, @code{int} and @code{char *} are not compatible, even if the size
11160 of their types, on the particular architecture are the same.  Also, the
11161 amount of pointer indirection is taken into account when determining
11162 similarity.  Consequently, @code{short *} is not similar to
11163 @code{short **}.  Furthermore, two types that are typedefed are
11164 considered compatible if their underlying types are compatible.
11166 An @code{enum} type is not considered to be compatible with another
11167 @code{enum} type even if both are compatible with the same integer
11168 type; this is what the C standard specifies.
11169 For example, @code{enum @{foo, bar@}} is not similar to
11170 @code{enum @{hot, dog@}}.
11172 You typically use this function in code whose execution varies
11173 depending on the arguments' types.  For example:
11175 @smallexample
11176 #define foo(x)                                                  \
11177   (@{                                                           \
11178     typeof (x) tmp = (x);                                       \
11179     if (__builtin_types_compatible_p (typeof (x), long double)) \
11180       tmp = foo_long_double (tmp);                              \
11181     else if (__builtin_types_compatible_p (typeof (x), double)) \
11182       tmp = foo_double (tmp);                                   \
11183     else if (__builtin_types_compatible_p (typeof (x), float))  \
11184       tmp = foo_float (tmp);                                    \
11185     else                                                        \
11186       abort ();                                                 \
11187     tmp;                                                        \
11188   @})
11189 @end smallexample
11191 @emph{Note:} This construct is only available for C@.
11193 @end deftypefn
11195 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11197 The @var{call_exp} expression must be a function call, and the
11198 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11199 is passed to the function call in the target's static chain location.
11200 The result of builtin is the result of the function call.
11202 @emph{Note:} This builtin is only available for C@.
11203 This builtin can be used to call Go closures from C.
11205 @end deftypefn
11207 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11209 You can use the built-in function @code{__builtin_choose_expr} to
11210 evaluate code depending on the value of a constant expression.  This
11211 built-in function returns @var{exp1} if @var{const_exp}, which is an
11212 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11214 This built-in function is analogous to the @samp{? :} operator in C,
11215 except that the expression returned has its type unaltered by promotion
11216 rules.  Also, the built-in function does not evaluate the expression
11217 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11218 @var{exp2} is not evaluated even if it has side-effects.
11220 This built-in function can return an lvalue if the chosen argument is an
11221 lvalue.
11223 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11224 type.  Similarly, if @var{exp2} is returned, its return type is the same
11225 as @var{exp2}.
11227 Example:
11229 @smallexample
11230 #define foo(x)                                                    \
11231   __builtin_choose_expr (                                         \
11232     __builtin_types_compatible_p (typeof (x), double),            \
11233     foo_double (x),                                               \
11234     __builtin_choose_expr (                                       \
11235       __builtin_types_compatible_p (typeof (x), float),           \
11236       foo_float (x),                                              \
11237       /* @r{The void expression results in a compile-time error}  \
11238          @r{when assigning the result to something.}  */          \
11239       (void)0))
11240 @end smallexample
11242 @emph{Note:} This construct is only available for C@.  Furthermore, the
11243 unused expression (@var{exp1} or @var{exp2} depending on the value of
11244 @var{const_exp}) may still generate syntax errors.  This may change in
11245 future revisions.
11247 @end deftypefn
11249 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11251 The built-in function @code{__builtin_complex} is provided for use in
11252 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11253 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11254 real binary floating-point type, and the result has the corresponding
11255 complex type with real and imaginary parts @var{real} and @var{imag}.
11256 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11257 infinities, NaNs and negative zeros are involved.
11259 @end deftypefn
11261 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11262 You can use the built-in function @code{__builtin_constant_p} to
11263 determine if a value is known to be constant at compile time and hence
11264 that GCC can perform constant-folding on expressions involving that
11265 value.  The argument of the function is the value to test.  The function
11266 returns the integer 1 if the argument is known to be a compile-time
11267 constant and 0 if it is not known to be a compile-time constant.  A
11268 return of 0 does not indicate that the value is @emph{not} a constant,
11269 but merely that GCC cannot prove it is a constant with the specified
11270 value of the @option{-O} option.
11272 You typically use this function in an embedded application where
11273 memory is a critical resource.  If you have some complex calculation,
11274 you may want it to be folded if it involves constants, but need to call
11275 a function if it does not.  For example:
11277 @smallexample
11278 #define Scale_Value(X)      \
11279   (__builtin_constant_p (X) \
11280   ? ((X) * SCALE + OFFSET) : Scale (X))
11281 @end smallexample
11283 You may use this built-in function in either a macro or an inline
11284 function.  However, if you use it in an inlined function and pass an
11285 argument of the function as the argument to the built-in, GCC 
11286 never returns 1 when you call the inline function with a string constant
11287 or compound literal (@pxref{Compound Literals}) and does not return 1
11288 when you pass a constant numeric value to the inline function unless you
11289 specify the @option{-O} option.
11291 You may also use @code{__builtin_constant_p} in initializers for static
11292 data.  For instance, you can write
11294 @smallexample
11295 static const int table[] = @{
11296    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11297    /* @r{@dots{}} */
11299 @end smallexample
11301 @noindent
11302 This is an acceptable initializer even if @var{EXPRESSION} is not a
11303 constant expression, including the case where
11304 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11305 folded to a constant but @var{EXPRESSION} contains operands that are
11306 not otherwise permitted in a static initializer (for example,
11307 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11308 built-in in this case, because it has no opportunity to perform
11309 optimization.
11310 @end deftypefn
11312 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11313 @opindex fprofile-arcs
11314 You may use @code{__builtin_expect} to provide the compiler with
11315 branch prediction information.  In general, you should prefer to
11316 use actual profile feedback for this (@option{-fprofile-arcs}), as
11317 programmers are notoriously bad at predicting how their programs
11318 actually perform.  However, there are applications in which this
11319 data is hard to collect.
11321 The return value is the value of @var{exp}, which should be an integral
11322 expression.  The semantics of the built-in are that it is expected that
11323 @var{exp} == @var{c}.  For example:
11325 @smallexample
11326 if (__builtin_expect (x, 0))
11327   foo ();
11328 @end smallexample
11330 @noindent
11331 indicates that we do not expect to call @code{foo}, since
11332 we expect @code{x} to be zero.  Since you are limited to integral
11333 expressions for @var{exp}, you should use constructions such as
11335 @smallexample
11336 if (__builtin_expect (ptr != NULL, 1))
11337   foo (*ptr);
11338 @end smallexample
11340 @noindent
11341 when testing pointer or floating-point values.
11342 @end deftypefn
11344 @deftypefn {Built-in Function} void __builtin_trap (void)
11345 This function causes the program to exit abnormally.  GCC implements
11346 this function by using a target-dependent mechanism (such as
11347 intentionally executing an illegal instruction) or by calling
11348 @code{abort}.  The mechanism used may vary from release to release so
11349 you should not rely on any particular implementation.
11350 @end deftypefn
11352 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11353 If control flow reaches the point of the @code{__builtin_unreachable},
11354 the program is undefined.  It is useful in situations where the
11355 compiler cannot deduce the unreachability of the code.
11357 One such case is immediately following an @code{asm} statement that
11358 either never terminates, or one that transfers control elsewhere
11359 and never returns.  In this example, without the
11360 @code{__builtin_unreachable}, GCC issues a warning that control
11361 reaches the end of a non-void function.  It also generates code
11362 to return after the @code{asm}.
11364 @smallexample
11365 int f (int c, int v)
11367   if (c)
11368     @{
11369       return v;
11370     @}
11371   else
11372     @{
11373       asm("jmp error_handler");
11374       __builtin_unreachable ();
11375     @}
11377 @end smallexample
11379 @noindent
11380 Because the @code{asm} statement unconditionally transfers control out
11381 of the function, control never reaches the end of the function
11382 body.  The @code{__builtin_unreachable} is in fact unreachable and
11383 communicates this fact to the compiler.
11385 Another use for @code{__builtin_unreachable} is following a call a
11386 function that never returns but that is not declared
11387 @code{__attribute__((noreturn))}, as in this example:
11389 @smallexample
11390 void function_that_never_returns (void);
11392 int g (int c)
11394   if (c)
11395     @{
11396       return 1;
11397     @}
11398   else
11399     @{
11400       function_that_never_returns ();
11401       __builtin_unreachable ();
11402     @}
11404 @end smallexample
11406 @end deftypefn
11408 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11409 This function returns its first argument, and allows the compiler
11410 to assume that the returned pointer is at least @var{align} bytes
11411 aligned.  This built-in can have either two or three arguments,
11412 if it has three, the third argument should have integer type, and
11413 if it is nonzero means misalignment offset.  For example:
11415 @smallexample
11416 void *x = __builtin_assume_aligned (arg, 16);
11417 @end smallexample
11419 @noindent
11420 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11421 16-byte aligned, while:
11423 @smallexample
11424 void *x = __builtin_assume_aligned (arg, 32, 8);
11425 @end smallexample
11427 @noindent
11428 means that the compiler can assume for @code{x}, set to @code{arg}, that
11429 @code{(char *) x - 8} is 32-byte aligned.
11430 @end deftypefn
11432 @deftypefn {Built-in Function} int __builtin_LINE ()
11433 This function is the equivalent of the preprocessor @code{__LINE__}
11434 macro and returns a constant integer expression that evaluates to
11435 the line number of the invocation of the built-in.  When used as a C++
11436 default argument for a function @var{F}, it returns the line number
11437 of the call to @var{F}.
11438 @end deftypefn
11440 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11441 This function is the equivalent of the @code{__FUNCTION__} symbol
11442 and returns an address constant pointing to the name of the function
11443 from which the built-in was invoked, or the empty string if
11444 the invocation is not at function scope.  When used as a C++ default
11445 argument for a function @var{F}, it returns the name of @var{F}'s
11446 caller or the empty string if the call was not made at function
11447 scope.
11448 @end deftypefn
11450 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11451 This function is the equivalent of the preprocessor @code{__FILE__}
11452 macro and returns an address constant pointing to the file name
11453 containing the invocation of the built-in, or the empty string if
11454 the invocation is not at function scope.  When used as a C++ default
11455 argument for a function @var{F}, it returns the file name of the call
11456 to @var{F} or the empty string if the call was not made at function
11457 scope.
11459 For example, in the following, each call to function @code{foo} will
11460 print a line similar to @code{"file.c:123: foo: message"} with the name
11461 of the file and the line number of the @code{printf} call, the name of
11462 the function @code{foo}, followed by the word @code{message}.
11464 @smallexample
11465 const char*
11466 function (const char *func = __builtin_FUNCTION ())
11468   return func;
11471 void foo (void)
11473   printf ("%s:%i: %s: message\n", file (), line (), function ());
11475 @end smallexample
11477 @end deftypefn
11479 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11480 This function is used to flush the processor's instruction cache for
11481 the region of memory between @var{begin} inclusive and @var{end}
11482 exclusive.  Some targets require that the instruction cache be
11483 flushed, after modifying memory containing code, in order to obtain
11484 deterministic behavior.
11486 If the target does not require instruction cache flushes,
11487 @code{__builtin___clear_cache} has no effect.  Otherwise either
11488 instructions are emitted in-line to clear the instruction cache or a
11489 call to the @code{__clear_cache} function in libgcc is made.
11490 @end deftypefn
11492 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11493 This function is used to minimize cache-miss latency by moving data into
11494 a cache before it is accessed.
11495 You can insert calls to @code{__builtin_prefetch} into code for which
11496 you know addresses of data in memory that is likely to be accessed soon.
11497 If the target supports them, data prefetch instructions are generated.
11498 If the prefetch is done early enough before the access then the data will
11499 be in the cache by the time it is accessed.
11501 The value of @var{addr} is the address of the memory to prefetch.
11502 There are two optional arguments, @var{rw} and @var{locality}.
11503 The value of @var{rw} is a compile-time constant one or zero; one
11504 means that the prefetch is preparing for a write to the memory address
11505 and zero, the default, means that the prefetch is preparing for a read.
11506 The value @var{locality} must be a compile-time constant integer between
11507 zero and three.  A value of zero means that the data has no temporal
11508 locality, so it need not be left in the cache after the access.  A value
11509 of three means that the data has a high degree of temporal locality and
11510 should be left in all levels of cache possible.  Values of one and two
11511 mean, respectively, a low or moderate degree of temporal locality.  The
11512 default is three.
11514 @smallexample
11515 for (i = 0; i < n; i++)
11516   @{
11517     a[i] = a[i] + b[i];
11518     __builtin_prefetch (&a[i+j], 1, 1);
11519     __builtin_prefetch (&b[i+j], 0, 1);
11520     /* @r{@dots{}} */
11521   @}
11522 @end smallexample
11524 Data prefetch does not generate faults if @var{addr} is invalid, but
11525 the address expression itself must be valid.  For example, a prefetch
11526 of @code{p->next} does not fault if @code{p->next} is not a valid
11527 address, but evaluation faults if @code{p} is not a valid address.
11529 If the target does not support data prefetch, the address expression
11530 is evaluated if it includes side effects but no other code is generated
11531 and GCC does not issue a warning.
11532 @end deftypefn
11534 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11535 Returns a positive infinity, if supported by the floating-point format,
11536 else @code{DBL_MAX}.  This function is suitable for implementing the
11537 ISO C macro @code{HUGE_VAL}.
11538 @end deftypefn
11540 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11541 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11542 @end deftypefn
11544 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11545 Similar to @code{__builtin_huge_val}, except the return
11546 type is @code{long double}.
11547 @end deftypefn
11549 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11550 Similar to @code{__builtin_huge_val}, except the return type is
11551 @code{_Float@var{n}}.
11552 @end deftypefn
11554 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11555 Similar to @code{__builtin_huge_val}, except the return type is
11556 @code{_Float@var{n}x}.
11557 @end deftypefn
11559 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11560 This built-in implements the C99 fpclassify functionality.  The first
11561 five int arguments should be the target library's notion of the
11562 possible FP classes and are used for return values.  They must be
11563 constant values and they must appear in this order: @code{FP_NAN},
11564 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11565 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
11566 to classify.  GCC treats the last argument as type-generic, which
11567 means it does not do default promotion from float to double.
11568 @end deftypefn
11570 @deftypefn {Built-in Function} double __builtin_inf (void)
11571 Similar to @code{__builtin_huge_val}, except a warning is generated
11572 if the target floating-point format does not support infinities.
11573 @end deftypefn
11575 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11576 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11577 @end deftypefn
11579 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11580 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11581 @end deftypefn
11583 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11584 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11585 @end deftypefn
11587 @deftypefn {Built-in Function} float __builtin_inff (void)
11588 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11589 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11590 @end deftypefn
11592 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11593 Similar to @code{__builtin_inf}, except the return
11594 type is @code{long double}.
11595 @end deftypefn
11597 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11598 Similar to @code{__builtin_inf}, except the return
11599 type is @code{_Float@var{n}}.
11600 @end deftypefn
11602 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11603 Similar to @code{__builtin_inf}, except the return
11604 type is @code{_Float@var{n}x}.
11605 @end deftypefn
11607 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11608 Similar to @code{isinf}, except the return value is -1 for
11609 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11610 Note while the parameter list is an
11611 ellipsis, this function only accepts exactly one floating-point
11612 argument.  GCC treats this parameter as type-generic, which means it
11613 does not do default promotion from float to double.
11614 @end deftypefn
11616 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11617 This is an implementation of the ISO C99 function @code{nan}.
11619 Since ISO C99 defines this function in terms of @code{strtod}, which we
11620 do not implement, a description of the parsing is in order.  The string
11621 is parsed as by @code{strtol}; that is, the base is recognized by
11622 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
11623 in the significand such that the least significant bit of the number
11624 is at the least significant bit of the significand.  The number is
11625 truncated to fit the significand field provided.  The significand is
11626 forced to be a quiet NaN@.
11628 This function, if given a string literal all of which would have been
11629 consumed by @code{strtol}, is evaluated early enough that it is considered a
11630 compile-time constant.
11631 @end deftypefn
11633 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11634 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11635 @end deftypefn
11637 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11638 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11639 @end deftypefn
11641 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11642 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11643 @end deftypefn
11645 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11646 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11647 @end deftypefn
11649 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11650 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11651 @end deftypefn
11653 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11654 Similar to @code{__builtin_nan}, except the return type is
11655 @code{_Float@var{n}}.
11656 @end deftypefn
11658 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11659 Similar to @code{__builtin_nan}, except the return type is
11660 @code{_Float@var{n}x}.
11661 @end deftypefn
11663 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11664 Similar to @code{__builtin_nan}, except the significand is forced
11665 to be a signaling NaN@.  The @code{nans} function is proposed by
11666 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11667 @end deftypefn
11669 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11670 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11671 @end deftypefn
11673 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11674 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11675 @end deftypefn
11677 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11678 Similar to @code{__builtin_nans}, except the return type is
11679 @code{_Float@var{n}}.
11680 @end deftypefn
11682 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11683 Similar to @code{__builtin_nans}, except the return type is
11684 @code{_Float@var{n}x}.
11685 @end deftypefn
11687 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11688 Returns one plus the index of the least significant 1-bit of @var{x}, or
11689 if @var{x} is zero, returns zero.
11690 @end deftypefn
11692 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11693 Returns the number of leading 0-bits in @var{x}, starting at the most
11694 significant bit position.  If @var{x} is 0, the result is undefined.
11695 @end deftypefn
11697 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11698 Returns the number of trailing 0-bits in @var{x}, starting at the least
11699 significant bit position.  If @var{x} is 0, the result is undefined.
11700 @end deftypefn
11702 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11703 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11704 number of bits following the most significant bit that are identical
11705 to it.  There are no special cases for 0 or other values. 
11706 @end deftypefn
11708 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11709 Returns the number of 1-bits in @var{x}.
11710 @end deftypefn
11712 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11713 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11714 modulo 2.
11715 @end deftypefn
11717 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11718 Similar to @code{__builtin_ffs}, except the argument type is
11719 @code{long}.
11720 @end deftypefn
11722 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11723 Similar to @code{__builtin_clz}, except the argument type is
11724 @code{unsigned long}.
11725 @end deftypefn
11727 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11728 Similar to @code{__builtin_ctz}, except the argument type is
11729 @code{unsigned long}.
11730 @end deftypefn
11732 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11733 Similar to @code{__builtin_clrsb}, except the argument type is
11734 @code{long}.
11735 @end deftypefn
11737 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11738 Similar to @code{__builtin_popcount}, except the argument type is
11739 @code{unsigned long}.
11740 @end deftypefn
11742 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11743 Similar to @code{__builtin_parity}, except the argument type is
11744 @code{unsigned long}.
11745 @end deftypefn
11747 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11748 Similar to @code{__builtin_ffs}, except the argument type is
11749 @code{long long}.
11750 @end deftypefn
11752 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11753 Similar to @code{__builtin_clz}, except the argument type is
11754 @code{unsigned long long}.
11755 @end deftypefn
11757 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11758 Similar to @code{__builtin_ctz}, except the argument type is
11759 @code{unsigned long long}.
11760 @end deftypefn
11762 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11763 Similar to @code{__builtin_clrsb}, except the argument type is
11764 @code{long long}.
11765 @end deftypefn
11767 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11768 Similar to @code{__builtin_popcount}, except the argument type is
11769 @code{unsigned long long}.
11770 @end deftypefn
11772 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11773 Similar to @code{__builtin_parity}, except the argument type is
11774 @code{unsigned long long}.
11775 @end deftypefn
11777 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11778 Returns the first argument raised to the power of the second.  Unlike the
11779 @code{pow} function no guarantees about precision and rounding are made.
11780 @end deftypefn
11782 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11783 Similar to @code{__builtin_powi}, except the argument and return types
11784 are @code{float}.
11785 @end deftypefn
11787 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11788 Similar to @code{__builtin_powi}, except the argument and return types
11789 are @code{long double}.
11790 @end deftypefn
11792 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11793 Returns @var{x} with the order of the bytes reversed; for example,
11794 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
11795 exactly 8 bits.
11796 @end deftypefn
11798 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11799 Similar to @code{__builtin_bswap16}, except the argument and return types
11800 are 32 bit.
11801 @end deftypefn
11803 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11804 Similar to @code{__builtin_bswap32}, except the argument and return types
11805 are 64 bit.
11806 @end deftypefn
11808 @node Target Builtins
11809 @section Built-in Functions Specific to Particular Target Machines
11811 On some target machines, GCC supports many built-in functions specific
11812 to those machines.  Generally these generate calls to specific machine
11813 instructions, but allow the compiler to schedule those calls.
11815 @menu
11816 * AArch64 Built-in Functions::
11817 * Alpha Built-in Functions::
11818 * Altera Nios II Built-in Functions::
11819 * ARC Built-in Functions::
11820 * ARC SIMD Built-in Functions::
11821 * ARM iWMMXt Built-in Functions::
11822 * ARM C Language Extensions (ACLE)::
11823 * ARM Floating Point Status and Control Intrinsics::
11824 * ARM ARMv8-M Security Extensions::
11825 * AVR Built-in Functions::
11826 * Blackfin Built-in Functions::
11827 * FR-V Built-in Functions::
11828 * MIPS DSP Built-in Functions::
11829 * MIPS Paired-Single Support::
11830 * MIPS Loongson Built-in Functions::
11831 * MIPS SIMD Architecture (MSA) Support::
11832 * Other MIPS Built-in Functions::
11833 * MSP430 Built-in Functions::
11834 * NDS32 Built-in Functions::
11835 * picoChip Built-in Functions::
11836 * PowerPC Built-in Functions::
11837 * PowerPC AltiVec/VSX Built-in Functions::
11838 * PowerPC Hardware Transactional Memory Built-in Functions::
11839 * RX Built-in Functions::
11840 * S/390 System z Built-in Functions::
11841 * SH Built-in Functions::
11842 * SPARC VIS Built-in Functions::
11843 * SPU Built-in Functions::
11844 * TI C6X Built-in Functions::
11845 * TILE-Gx Built-in Functions::
11846 * TILEPro Built-in Functions::
11847 * x86 Built-in Functions::
11848 * x86 transactional memory intrinsics::
11849 @end menu
11851 @node AArch64 Built-in Functions
11852 @subsection AArch64 Built-in Functions
11854 These built-in functions are available for the AArch64 family of
11855 processors.
11856 @smallexample
11857 unsigned int __builtin_aarch64_get_fpcr ()
11858 void __builtin_aarch64_set_fpcr (unsigned int)
11859 unsigned int __builtin_aarch64_get_fpsr ()
11860 void __builtin_aarch64_set_fpsr (unsigned int)
11861 @end smallexample
11863 @node Alpha Built-in Functions
11864 @subsection Alpha Built-in Functions
11866 These built-in functions are available for the Alpha family of
11867 processors, depending on the command-line switches used.
11869 The following built-in functions are always available.  They
11870 all generate the machine instruction that is part of the name.
11872 @smallexample
11873 long __builtin_alpha_implver (void)
11874 long __builtin_alpha_rpcc (void)
11875 long __builtin_alpha_amask (long)
11876 long __builtin_alpha_cmpbge (long, long)
11877 long __builtin_alpha_extbl (long, long)
11878 long __builtin_alpha_extwl (long, long)
11879 long __builtin_alpha_extll (long, long)
11880 long __builtin_alpha_extql (long, long)
11881 long __builtin_alpha_extwh (long, long)
11882 long __builtin_alpha_extlh (long, long)
11883 long __builtin_alpha_extqh (long, long)
11884 long __builtin_alpha_insbl (long, long)
11885 long __builtin_alpha_inswl (long, long)
11886 long __builtin_alpha_insll (long, long)
11887 long __builtin_alpha_insql (long, long)
11888 long __builtin_alpha_inswh (long, long)
11889 long __builtin_alpha_inslh (long, long)
11890 long __builtin_alpha_insqh (long, long)
11891 long __builtin_alpha_mskbl (long, long)
11892 long __builtin_alpha_mskwl (long, long)
11893 long __builtin_alpha_mskll (long, long)
11894 long __builtin_alpha_mskql (long, long)
11895 long __builtin_alpha_mskwh (long, long)
11896 long __builtin_alpha_msklh (long, long)
11897 long __builtin_alpha_mskqh (long, long)
11898 long __builtin_alpha_umulh (long, long)
11899 long __builtin_alpha_zap (long, long)
11900 long __builtin_alpha_zapnot (long, long)
11901 @end smallexample
11903 The following built-in functions are always with @option{-mmax}
11904 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11905 later.  They all generate the machine instruction that is part
11906 of the name.
11908 @smallexample
11909 long __builtin_alpha_pklb (long)
11910 long __builtin_alpha_pkwb (long)
11911 long __builtin_alpha_unpkbl (long)
11912 long __builtin_alpha_unpkbw (long)
11913 long __builtin_alpha_minub8 (long, long)
11914 long __builtin_alpha_minsb8 (long, long)
11915 long __builtin_alpha_minuw4 (long, long)
11916 long __builtin_alpha_minsw4 (long, long)
11917 long __builtin_alpha_maxub8 (long, long)
11918 long __builtin_alpha_maxsb8 (long, long)
11919 long __builtin_alpha_maxuw4 (long, long)
11920 long __builtin_alpha_maxsw4 (long, long)
11921 long __builtin_alpha_perr (long, long)
11922 @end smallexample
11924 The following built-in functions are always with @option{-mcix}
11925 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11926 later.  They all generate the machine instruction that is part
11927 of the name.
11929 @smallexample
11930 long __builtin_alpha_cttz (long)
11931 long __builtin_alpha_ctlz (long)
11932 long __builtin_alpha_ctpop (long)
11933 @end smallexample
11935 The following built-in functions are available on systems that use the OSF/1
11936 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
11937 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11938 @code{rdval} and @code{wrval}.
11940 @smallexample
11941 void *__builtin_thread_pointer (void)
11942 void __builtin_set_thread_pointer (void *)
11943 @end smallexample
11945 @node Altera Nios II Built-in Functions
11946 @subsection Altera Nios II Built-in Functions
11948 These built-in functions are available for the Altera Nios II
11949 family of processors.
11951 The following built-in functions are always available.  They
11952 all generate the machine instruction that is part of the name.
11954 @example
11955 int __builtin_ldbio (volatile const void *)
11956 int __builtin_ldbuio (volatile const void *)
11957 int __builtin_ldhio (volatile const void *)
11958 int __builtin_ldhuio (volatile const void *)
11959 int __builtin_ldwio (volatile const void *)
11960 void __builtin_stbio (volatile void *, int)
11961 void __builtin_sthio (volatile void *, int)
11962 void __builtin_stwio (volatile void *, int)
11963 void __builtin_sync (void)
11964 int __builtin_rdctl (int) 
11965 int __builtin_rdprs (int, int)
11966 void __builtin_wrctl (int, int)
11967 void __builtin_flushd (volatile void *)
11968 void __builtin_flushda (volatile void *)
11969 int __builtin_wrpie (int);
11970 void __builtin_eni (int);
11971 int __builtin_ldex (volatile const void *)
11972 int __builtin_stex (volatile void *, int)
11973 int __builtin_ldsex (volatile const void *)
11974 int __builtin_stsex (volatile void *, int)
11975 @end example
11977 The following built-in functions are always available.  They
11978 all generate a Nios II Custom Instruction. The name of the
11979 function represents the types that the function takes and
11980 returns. The letter before the @code{n} is the return type
11981 or void if absent. The @code{n} represents the first parameter
11982 to all the custom instructions, the custom instruction number.
11983 The two letters after the @code{n} represent the up to two
11984 parameters to the function.
11986 The letters represent the following data types:
11987 @table @code
11988 @item <no letter>
11989 @code{void} for return type and no parameter for parameter types.
11991 @item i
11992 @code{int} for return type and parameter type
11994 @item f
11995 @code{float} for return type and parameter type
11997 @item p
11998 @code{void *} for return type and parameter type
12000 @end table
12002 And the function names are:
12003 @example
12004 void __builtin_custom_n (void)
12005 void __builtin_custom_ni (int)
12006 void __builtin_custom_nf (float)
12007 void __builtin_custom_np (void *)
12008 void __builtin_custom_nii (int, int)
12009 void __builtin_custom_nif (int, float)
12010 void __builtin_custom_nip (int, void *)
12011 void __builtin_custom_nfi (float, int)
12012 void __builtin_custom_nff (float, float)
12013 void __builtin_custom_nfp (float, void *)
12014 void __builtin_custom_npi (void *, int)
12015 void __builtin_custom_npf (void *, float)
12016 void __builtin_custom_npp (void *, void *)
12017 int __builtin_custom_in (void)
12018 int __builtin_custom_ini (int)
12019 int __builtin_custom_inf (float)
12020 int __builtin_custom_inp (void *)
12021 int __builtin_custom_inii (int, int)
12022 int __builtin_custom_inif (int, float)
12023 int __builtin_custom_inip (int, void *)
12024 int __builtin_custom_infi (float, int)
12025 int __builtin_custom_inff (float, float)
12026 int __builtin_custom_infp (float, void *)
12027 int __builtin_custom_inpi (void *, int)
12028 int __builtin_custom_inpf (void *, float)
12029 int __builtin_custom_inpp (void *, void *)
12030 float __builtin_custom_fn (void)
12031 float __builtin_custom_fni (int)
12032 float __builtin_custom_fnf (float)
12033 float __builtin_custom_fnp (void *)
12034 float __builtin_custom_fnii (int, int)
12035 float __builtin_custom_fnif (int, float)
12036 float __builtin_custom_fnip (int, void *)
12037 float __builtin_custom_fnfi (float, int)
12038 float __builtin_custom_fnff (float, float)
12039 float __builtin_custom_fnfp (float, void *)
12040 float __builtin_custom_fnpi (void *, int)
12041 float __builtin_custom_fnpf (void *, float)
12042 float __builtin_custom_fnpp (void *, void *)
12043 void * __builtin_custom_pn (void)
12044 void * __builtin_custom_pni (int)
12045 void * __builtin_custom_pnf (float)
12046 void * __builtin_custom_pnp (void *)
12047 void * __builtin_custom_pnii (int, int)
12048 void * __builtin_custom_pnif (int, float)
12049 void * __builtin_custom_pnip (int, void *)
12050 void * __builtin_custom_pnfi (float, int)
12051 void * __builtin_custom_pnff (float, float)
12052 void * __builtin_custom_pnfp (float, void *)
12053 void * __builtin_custom_pnpi (void *, int)
12054 void * __builtin_custom_pnpf (void *, float)
12055 void * __builtin_custom_pnpp (void *, void *)
12056 @end example
12058 @node ARC Built-in Functions
12059 @subsection ARC Built-in Functions
12061 The following built-in functions are provided for ARC targets.  The
12062 built-ins generate the corresponding assembly instructions.  In the
12063 examples given below, the generated code often requires an operand or
12064 result to be in a register.  Where necessary further code will be
12065 generated to ensure this is true, but for brevity this is not
12066 described in each case.
12068 @emph{Note:} Using a built-in to generate an instruction not supported
12069 by a target may cause problems. At present the compiler is not
12070 guaranteed to detect such misuse, and as a result an internal compiler
12071 error may be generated.
12073 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12074 Return 1 if @var{val} is known to have the byte alignment given
12075 by @var{alignval}, otherwise return 0.
12076 Note that this is different from
12077 @smallexample
12078 __alignof__(*(char *)@var{val}) >= alignval
12079 @end smallexample
12080 because __alignof__ sees only the type of the dereference, whereas
12081 __builtin_arc_align uses alignment information from the pointer
12082 as well as from the pointed-to type.
12083 The information available will depend on optimization level.
12084 @end deftypefn
12086 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12087 Generates
12088 @example
12090 @end example
12091 @end deftypefn
12093 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12094 The operand is the number of a register to be read.  Generates:
12095 @example
12096 mov  @var{dest}, r@var{regno}
12097 @end example
12098 where the value in @var{dest} will be the result returned from the
12099 built-in.
12100 @end deftypefn
12102 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12103 The first operand is the number of a register to be written, the
12104 second operand is a compile time constant to write into that
12105 register.  Generates:
12106 @example
12107 mov  r@var{regno}, @var{val}
12108 @end example
12109 @end deftypefn
12111 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12112 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12113 Generates:
12114 @example
12115 divaw  @var{dest}, @var{a}, @var{b}
12116 @end example
12117 where the value in @var{dest} will be the result returned from the
12118 built-in.
12119 @end deftypefn
12121 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12122 Generates
12123 @example
12124 flag  @var{a}
12125 @end example
12126 @end deftypefn
12128 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12129 The operand, @var{auxv}, is the address of an auxiliary register and
12130 must be a compile time constant.  Generates:
12131 @example
12132 lr  @var{dest}, [@var{auxr}]
12133 @end example
12134 Where the value in @var{dest} will be the result returned from the
12135 built-in.
12136 @end deftypefn
12138 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12139 Only available with @option{-mmul64}.  Generates:
12140 @example
12141 mul64  @var{a}, @var{b}
12142 @end example
12143 @end deftypefn
12145 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12146 Only available with @option{-mmul64}.  Generates:
12147 @example
12148 mulu64  @var{a}, @var{b}
12149 @end example
12150 @end deftypefn
12152 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12153 Generates:
12154 @example
12156 @end example
12157 @end deftypefn
12159 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12160 Only valid if the @samp{norm} instruction is available through the
12161 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12162 Generates:
12163 @example
12164 norm  @var{dest}, @var{src}
12165 @end example
12166 Where the value in @var{dest} will be the result returned from the
12167 built-in.
12168 @end deftypefn
12170 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12171 Only valid if the @samp{normw} instruction is available through the
12172 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12173 Generates:
12174 @example
12175 normw  @var{dest}, @var{src}
12176 @end example
12177 Where the value in @var{dest} will be the result returned from the
12178 built-in.
12179 @end deftypefn
12181 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12182 Generates:
12183 @example
12184 rtie
12185 @end example
12186 @end deftypefn
12188 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12189 Generates:
12190 @example
12191 sleep  @var{a}
12192 @end example
12193 @end deftypefn
12195 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12196 The first argument, @var{auxv}, is the address of an auxiliary
12197 register, the second argument, @var{val}, is a compile time constant
12198 to be written to the register.  Generates:
12199 @example
12200 sr  @var{auxr}, [@var{val}]
12201 @end example
12202 @end deftypefn
12204 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12205 Only valid with @option{-mswap}.  Generates:
12206 @example
12207 swap  @var{dest}, @var{src}
12208 @end example
12209 Where the value in @var{dest} will be the result returned from the
12210 built-in.
12211 @end deftypefn
12213 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12214 Generates:
12215 @example
12217 @end example
12218 @end deftypefn
12220 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12221 Only available with @option{-mcpu=ARC700}.  Generates:
12222 @example
12223 sync
12224 @end example
12225 @end deftypefn
12227 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12228 Only available with @option{-mcpu=ARC700}.  Generates:
12229 @example
12230 trap_s  @var{c}
12231 @end example
12232 @end deftypefn
12234 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12235 Only available with @option{-mcpu=ARC700}.  Generates:
12236 @example
12237 unimp_s
12238 @end example
12239 @end deftypefn
12241 The instructions generated by the following builtins are not
12242 considered as candidates for scheduling.  They are not moved around by
12243 the compiler during scheduling, and thus can be expected to appear
12244 where they are put in the C code:
12245 @example
12246 __builtin_arc_brk()
12247 __builtin_arc_core_read()
12248 __builtin_arc_core_write()
12249 __builtin_arc_flag()
12250 __builtin_arc_lr()
12251 __builtin_arc_sleep()
12252 __builtin_arc_sr()
12253 __builtin_arc_swi()
12254 @end example
12256 @node ARC SIMD Built-in Functions
12257 @subsection ARC SIMD Built-in Functions
12259 SIMD builtins provided by the compiler can be used to generate the
12260 vector instructions.  This section describes the available builtins
12261 and their usage in programs.  With the @option{-msimd} option, the
12262 compiler provides 128-bit vector types, which can be specified using
12263 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12264 can be included to use the following predefined types:
12265 @example
12266 typedef int __v4si   __attribute__((vector_size(16)));
12267 typedef short __v8hi __attribute__((vector_size(16)));
12268 @end example
12270 These types can be used to define 128-bit variables.  The built-in
12271 functions listed in the following section can be used on these
12272 variables to generate the vector operations.
12274 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12275 @file{arc-simd.h} also provides equivalent macros called
12276 @code{_@var{someinsn}} that can be used for programming ease and
12277 improved readability.  The following macros for DMA control are also
12278 provided:
12279 @example
12280 #define _setup_dma_in_channel_reg _vdiwr
12281 #define _setup_dma_out_channel_reg _vdowr
12282 @end example
12284 The following is a complete list of all the SIMD built-ins provided
12285 for ARC, grouped by calling signature.
12287 The following take two @code{__v8hi} arguments and return a
12288 @code{__v8hi} result:
12289 @example
12290 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12291 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12292 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12293 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12294 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12295 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12296 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12297 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12298 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12299 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12300 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12301 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12302 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12303 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12304 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12305 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12306 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12307 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12308 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12309 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12310 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12311 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12312 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12313 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12314 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12315 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12316 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12317 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12318 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12319 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12320 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12321 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12322 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12323 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12324 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12325 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12326 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12327 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12328 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12329 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12330 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12331 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12332 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12333 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12334 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12335 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12336 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12337 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12338 @end example
12340 The following take one @code{__v8hi} and one @code{int} argument and return a
12341 @code{__v8hi} result:
12343 @example
12344 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12345 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12346 __v8hi __builtin_arc_vbminw (__v8hi, int)
12347 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12348 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12349 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12350 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12351 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12352 @end example
12354 The following take one @code{__v8hi} argument and one @code{int} argument which
12355 must be a 3-bit compile time constant indicating a register number
12356 I0-I7.  They return a @code{__v8hi} result.
12357 @example
12358 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12359 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12360 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12361 @end example
12363 The following take one @code{__v8hi} argument and one @code{int}
12364 argument which must be a 6-bit compile time constant.  They return a
12365 @code{__v8hi} result.
12366 @example
12367 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12368 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12369 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12370 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12371 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12372 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12373 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12374 @end example
12376 The following take one @code{__v8hi} argument and one @code{int} argument which
12377 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12378 result.
12379 @example
12380 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12381 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12382 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12383 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12384 @end example
12386 The following take two @code{int} arguments, the second of which which
12387 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12388 result:
12389 @example
12390 __v8hi __builtin_arc_vmovaw (int, const int)
12391 __v8hi __builtin_arc_vmovw (int, const int)
12392 __v8hi __builtin_arc_vmovzw (int, const int)
12393 @end example
12395 The following take a single @code{__v8hi} argument and return a
12396 @code{__v8hi} result:
12397 @example
12398 __v8hi __builtin_arc_vabsaw (__v8hi)
12399 __v8hi __builtin_arc_vabsw (__v8hi)
12400 __v8hi __builtin_arc_vaddsuw (__v8hi)
12401 __v8hi __builtin_arc_vexch1 (__v8hi)
12402 __v8hi __builtin_arc_vexch2 (__v8hi)
12403 __v8hi __builtin_arc_vexch4 (__v8hi)
12404 __v8hi __builtin_arc_vsignw (__v8hi)
12405 __v8hi __builtin_arc_vupbaw (__v8hi)
12406 __v8hi __builtin_arc_vupbw (__v8hi)
12407 __v8hi __builtin_arc_vupsbaw (__v8hi)
12408 __v8hi __builtin_arc_vupsbw (__v8hi)
12409 @end example
12411 The following take two @code{int} arguments and return no result:
12412 @example
12413 void __builtin_arc_vdirun (int, int)
12414 void __builtin_arc_vdorun (int, int)
12415 @end example
12417 The following take two @code{int} arguments and return no result.  The
12418 first argument must a 3-bit compile time constant indicating one of
12419 the DR0-DR7 DMA setup channels:
12420 @example
12421 void __builtin_arc_vdiwr (const int, int)
12422 void __builtin_arc_vdowr (const int, int)
12423 @end example
12425 The following take an @code{int} argument and return no result:
12426 @example
12427 void __builtin_arc_vendrec (int)
12428 void __builtin_arc_vrec (int)
12429 void __builtin_arc_vrecrun (int)
12430 void __builtin_arc_vrun (int)
12431 @end example
12433 The following take a @code{__v8hi} argument and two @code{int}
12434 arguments and return a @code{__v8hi} result.  The second argument must
12435 be a 3-bit compile time constants, indicating one the registers I0-I7,
12436 and the third argument must be an 8-bit compile time constant.
12438 @emph{Note:} Although the equivalent hardware instructions do not take
12439 an SIMD register as an operand, these builtins overwrite the relevant
12440 bits of the @code{__v8hi} register provided as the first argument with
12441 the value loaded from the @code{[Ib, u8]} location in the SDM.
12443 @example
12444 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12445 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12446 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12447 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12448 @end example
12450 The following take two @code{int} arguments and return a @code{__v8hi}
12451 result.  The first argument must be a 3-bit compile time constants,
12452 indicating one the registers I0-I7, and the second argument must be an
12453 8-bit compile time constant.
12455 @example
12456 __v8hi __builtin_arc_vld128 (const int, const int)
12457 __v8hi __builtin_arc_vld64w (const int, const int)
12458 @end example
12460 The following take a @code{__v8hi} argument and two @code{int}
12461 arguments and return no result.  The second argument must be a 3-bit
12462 compile time constants, indicating one the registers I0-I7, and the
12463 third argument must be an 8-bit compile time constant.
12465 @example
12466 void __builtin_arc_vst128 (__v8hi, const int, const int)
12467 void __builtin_arc_vst64 (__v8hi, const int, const int)
12468 @end example
12470 The following take a @code{__v8hi} argument and three @code{int}
12471 arguments and return no result.  The second argument must be a 3-bit
12472 compile-time constant, identifying the 16-bit sub-register to be
12473 stored, the third argument must be a 3-bit compile time constants,
12474 indicating one the registers I0-I7, and the fourth argument must be an
12475 8-bit compile time constant.
12477 @example
12478 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12479 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12480 @end example
12482 @node ARM iWMMXt Built-in Functions
12483 @subsection ARM iWMMXt Built-in Functions
12485 These built-in functions are available for the ARM family of
12486 processors when the @option{-mcpu=iwmmxt} switch is used:
12488 @smallexample
12489 typedef int v2si __attribute__ ((vector_size (8)));
12490 typedef short v4hi __attribute__ ((vector_size (8)));
12491 typedef char v8qi __attribute__ ((vector_size (8)));
12493 int __builtin_arm_getwcgr0 (void)
12494 void __builtin_arm_setwcgr0 (int)
12495 int __builtin_arm_getwcgr1 (void)
12496 void __builtin_arm_setwcgr1 (int)
12497 int __builtin_arm_getwcgr2 (void)
12498 void __builtin_arm_setwcgr2 (int)
12499 int __builtin_arm_getwcgr3 (void)
12500 void __builtin_arm_setwcgr3 (int)
12501 int __builtin_arm_textrmsb (v8qi, int)
12502 int __builtin_arm_textrmsh (v4hi, int)
12503 int __builtin_arm_textrmsw (v2si, int)
12504 int __builtin_arm_textrmub (v8qi, int)
12505 int __builtin_arm_textrmuh (v4hi, int)
12506 int __builtin_arm_textrmuw (v2si, int)
12507 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12508 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12509 v2si __builtin_arm_tinsrw (v2si, int, int)
12510 long long __builtin_arm_tmia (long long, int, int)
12511 long long __builtin_arm_tmiabb (long long, int, int)
12512 long long __builtin_arm_tmiabt (long long, int, int)
12513 long long __builtin_arm_tmiaph (long long, int, int)
12514 long long __builtin_arm_tmiatb (long long, int, int)
12515 long long __builtin_arm_tmiatt (long long, int, int)
12516 int __builtin_arm_tmovmskb (v8qi)
12517 int __builtin_arm_tmovmskh (v4hi)
12518 int __builtin_arm_tmovmskw (v2si)
12519 long long __builtin_arm_waccb (v8qi)
12520 long long __builtin_arm_wacch (v4hi)
12521 long long __builtin_arm_waccw (v2si)
12522 v8qi __builtin_arm_waddb (v8qi, v8qi)
12523 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12524 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12525 v4hi __builtin_arm_waddh (v4hi, v4hi)
12526 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12527 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12528 v2si __builtin_arm_waddw (v2si, v2si)
12529 v2si __builtin_arm_waddwss (v2si, v2si)
12530 v2si __builtin_arm_waddwus (v2si, v2si)
12531 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12532 long long __builtin_arm_wand(long long, long long)
12533 long long __builtin_arm_wandn (long long, long long)
12534 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12535 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12536 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12537 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12538 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12539 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12540 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12541 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12542 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12543 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12544 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12545 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12546 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12547 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12548 long long __builtin_arm_wmacsz (v4hi, v4hi)
12549 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12550 long long __builtin_arm_wmacuz (v4hi, v4hi)
12551 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12552 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12553 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12554 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12555 v2si __builtin_arm_wmaxsw (v2si, v2si)
12556 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12557 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12558 v2si __builtin_arm_wmaxuw (v2si, v2si)
12559 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12560 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12561 v2si __builtin_arm_wminsw (v2si, v2si)
12562 v8qi __builtin_arm_wminub (v8qi, v8qi)
12563 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12564 v2si __builtin_arm_wminuw (v2si, v2si)
12565 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12566 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12567 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12568 long long __builtin_arm_wor (long long, long long)
12569 v2si __builtin_arm_wpackdss (long long, long long)
12570 v2si __builtin_arm_wpackdus (long long, long long)
12571 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12572 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12573 v4hi __builtin_arm_wpackwss (v2si, v2si)
12574 v4hi __builtin_arm_wpackwus (v2si, v2si)
12575 long long __builtin_arm_wrord (long long, long long)
12576 long long __builtin_arm_wrordi (long long, int)
12577 v4hi __builtin_arm_wrorh (v4hi, long long)
12578 v4hi __builtin_arm_wrorhi (v4hi, int)
12579 v2si __builtin_arm_wrorw (v2si, long long)
12580 v2si __builtin_arm_wrorwi (v2si, int)
12581 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12582 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12583 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12584 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12585 v4hi __builtin_arm_wshufh (v4hi, int)
12586 long long __builtin_arm_wslld (long long, long long)
12587 long long __builtin_arm_wslldi (long long, int)
12588 v4hi __builtin_arm_wsllh (v4hi, long long)
12589 v4hi __builtin_arm_wsllhi (v4hi, int)
12590 v2si __builtin_arm_wsllw (v2si, long long)
12591 v2si __builtin_arm_wsllwi (v2si, int)
12592 long long __builtin_arm_wsrad (long long, long long)
12593 long long __builtin_arm_wsradi (long long, int)
12594 v4hi __builtin_arm_wsrah (v4hi, long long)
12595 v4hi __builtin_arm_wsrahi (v4hi, int)
12596 v2si __builtin_arm_wsraw (v2si, long long)
12597 v2si __builtin_arm_wsrawi (v2si, int)
12598 long long __builtin_arm_wsrld (long long, long long)
12599 long long __builtin_arm_wsrldi (long long, int)
12600 v4hi __builtin_arm_wsrlh (v4hi, long long)
12601 v4hi __builtin_arm_wsrlhi (v4hi, int)
12602 v2si __builtin_arm_wsrlw (v2si, long long)
12603 v2si __builtin_arm_wsrlwi (v2si, int)
12604 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12605 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12606 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12607 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12608 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12609 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12610 v2si __builtin_arm_wsubw (v2si, v2si)
12611 v2si __builtin_arm_wsubwss (v2si, v2si)
12612 v2si __builtin_arm_wsubwus (v2si, v2si)
12613 v4hi __builtin_arm_wunpckehsb (v8qi)
12614 v2si __builtin_arm_wunpckehsh (v4hi)
12615 long long __builtin_arm_wunpckehsw (v2si)
12616 v4hi __builtin_arm_wunpckehub (v8qi)
12617 v2si __builtin_arm_wunpckehuh (v4hi)
12618 long long __builtin_arm_wunpckehuw (v2si)
12619 v4hi __builtin_arm_wunpckelsb (v8qi)
12620 v2si __builtin_arm_wunpckelsh (v4hi)
12621 long long __builtin_arm_wunpckelsw (v2si)
12622 v4hi __builtin_arm_wunpckelub (v8qi)
12623 v2si __builtin_arm_wunpckeluh (v4hi)
12624 long long __builtin_arm_wunpckeluw (v2si)
12625 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12626 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12627 v2si __builtin_arm_wunpckihw (v2si, v2si)
12628 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12629 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12630 v2si __builtin_arm_wunpckilw (v2si, v2si)
12631 long long __builtin_arm_wxor (long long, long long)
12632 long long __builtin_arm_wzero ()
12633 @end smallexample
12636 @node ARM C Language Extensions (ACLE)
12637 @subsection ARM C Language Extensions (ACLE)
12639 GCC implements extensions for C as described in the ARM C Language
12640 Extensions (ACLE) specification, which can be found at
12641 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12643 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12644 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
12645 intrinsics can be found at
12646 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12647 The built-in intrinsics for the Advanced SIMD extension are available when
12648 NEON is enabled.
12650 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
12651 back ends support CRC32 intrinsics and the ARM back end supports the
12652 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
12653 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12654 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12655 intrinsics yet.
12657 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12658 availability of extensions.
12660 @node ARM Floating Point Status and Control Intrinsics
12661 @subsection ARM Floating Point Status and Control Intrinsics
12663 These built-in functions are available for the ARM family of
12664 processors with floating-point unit.
12666 @smallexample
12667 unsigned int __builtin_arm_get_fpscr ()
12668 void __builtin_arm_set_fpscr (unsigned int)
12669 @end smallexample
12671 @node ARM ARMv8-M Security Extensions
12672 @subsection ARM ARMv8-M Security Extensions
12674 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
12675 Security Extensions: Requirements on Development Tools Engineering
12676 Specification, which can be found at
12677 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
12679 As part of the Security Extensions GCC implements two new function attributes:
12680 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
12682 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
12683 is used here to mean any function pointer type.
12685 @smallexample
12686 cmse_address_info_t cmse_TT (void *)
12687 cmse_address_info_t cmse_TT_fptr (FPTR)
12688 cmse_address_info_t cmse_TTT (void *)
12689 cmse_address_info_t cmse_TTT_fptr (FPTR)
12690 cmse_address_info_t cmse_TTA (void *)
12691 cmse_address_info_t cmse_TTA_fptr (FPTR)
12692 cmse_address_info_t cmse_TTAT (void *)
12693 cmse_address_info_t cmse_TTAT_fptr (FPTR)
12694 void * cmse_check_address_range (void *, size_t, int)
12695 typeof(p) cmse_nsfptr_create (FPTR p)
12696 intptr_t cmse_is_nsfptr (FPTR)
12697 int cmse_nonsecure_caller (void)
12698 @end smallexample
12700 @node AVR Built-in Functions
12701 @subsection AVR Built-in Functions
12703 For each built-in function for AVR, there is an equally named,
12704 uppercase built-in macro defined. That way users can easily query if
12705 or if not a specific built-in is implemented or not. For example, if
12706 @code{__builtin_avr_nop} is available the macro
12707 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12709 The following built-in functions map to the respective machine
12710 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12711 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12712 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12713 as library call if no hardware multiplier is available.
12715 @smallexample
12716 void __builtin_avr_nop (void)
12717 void __builtin_avr_sei (void)
12718 void __builtin_avr_cli (void)
12719 void __builtin_avr_sleep (void)
12720 void __builtin_avr_wdr (void)
12721 unsigned char __builtin_avr_swap (unsigned char)
12722 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12723 int __builtin_avr_fmuls (char, char)
12724 int __builtin_avr_fmulsu (char, unsigned char)
12725 @end smallexample
12727 In order to delay execution for a specific number of cycles, GCC
12728 implements
12729 @smallexample
12730 void __builtin_avr_delay_cycles (unsigned long ticks)
12731 @end smallexample
12733 @noindent
12734 @code{ticks} is the number of ticks to delay execution. Note that this
12735 built-in does not take into account the effect of interrupts that
12736 might increase delay time. @code{ticks} must be a compile-time
12737 integer constant; delays with a variable number of cycles are not supported.
12739 @smallexample
12740 char __builtin_avr_flash_segment (const __memx void*)
12741 @end smallexample
12743 @noindent
12744 This built-in takes a byte address to the 24-bit
12745 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12746 the number of the flash segment (the 64 KiB chunk) where the address
12747 points to.  Counting starts at @code{0}.
12748 If the address does not point to flash memory, return @code{-1}.
12750 @smallexample
12751 unsigned char __builtin_avr_insert_bits (unsigned long map,
12752                                          unsigned char bits,
12753                                          unsigned char val)
12754 @end smallexample
12756 @noindent
12757 Insert bits from @var{bits} into @var{val} and return the resulting
12758 value. The nibbles of @var{map} determine how the insertion is
12759 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12760 @enumerate
12761 @item If @var{X} is @code{0xf},
12762 then the @var{n}-th bit of @var{val} is returned unaltered.
12764 @item If X is in the range 0@dots{}7,
12765 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12767 @item If X is in the range 8@dots{}@code{0xe},
12768 then the @var{n}-th result bit is undefined.
12769 @end enumerate
12771 @noindent
12772 One typical use case for this built-in is adjusting input and
12773 output values to non-contiguous port layouts. Some examples:
12775 @smallexample
12776 // same as val, bits is unused
12777 __builtin_avr_insert_bits (0xffffffff, bits, val)
12778 @end smallexample
12780 @smallexample
12781 // same as bits, val is unused
12782 __builtin_avr_insert_bits (0x76543210, bits, val)
12783 @end smallexample
12785 @smallexample
12786 // same as rotating bits by 4
12787 __builtin_avr_insert_bits (0x32107654, bits, 0)
12788 @end smallexample
12790 @smallexample
12791 // high nibble of result is the high nibble of val
12792 // low nibble of result is the low nibble of bits
12793 __builtin_avr_insert_bits (0xffff3210, bits, val)
12794 @end smallexample
12796 @smallexample
12797 // reverse the bit order of bits
12798 __builtin_avr_insert_bits (0x01234567, bits, 0)
12799 @end smallexample
12801 @smallexample
12802 void __builtin_avr_nops (unsigned count)
12803 @end smallexample
12805 @noindent
12806 Insert @code{count} @code{NOP} instructions.
12807 The number of instructions must be a compile-time integer constant.
12809 @node Blackfin Built-in Functions
12810 @subsection Blackfin Built-in Functions
12812 Currently, there are two Blackfin-specific built-in functions.  These are
12813 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12814 using inline assembly; by using these built-in functions the compiler can
12815 automatically add workarounds for hardware errata involving these
12816 instructions.  These functions are named as follows:
12818 @smallexample
12819 void __builtin_bfin_csync (void)
12820 void __builtin_bfin_ssync (void)
12821 @end smallexample
12823 @node FR-V Built-in Functions
12824 @subsection FR-V Built-in Functions
12826 GCC provides many FR-V-specific built-in functions.  In general,
12827 these functions are intended to be compatible with those described
12828 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12829 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
12830 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12831 pointer rather than by value.
12833 Most of the functions are named after specific FR-V instructions.
12834 Such functions are said to be ``directly mapped'' and are summarized
12835 here in tabular form.
12837 @menu
12838 * Argument Types::
12839 * Directly-mapped Integer Functions::
12840 * Directly-mapped Media Functions::
12841 * Raw read/write Functions::
12842 * Other Built-in Functions::
12843 @end menu
12845 @node Argument Types
12846 @subsubsection Argument Types
12848 The arguments to the built-in functions can be divided into three groups:
12849 register numbers, compile-time constants and run-time values.  In order
12850 to make this classification clear at a glance, the arguments and return
12851 values are given the following pseudo types:
12853 @multitable @columnfractions .20 .30 .15 .35
12854 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12855 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12856 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12857 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12858 @item @code{uw2} @tab @code{unsigned long long} @tab No
12859 @tab an unsigned doubleword
12860 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12861 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12862 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12863 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12864 @end multitable
12866 These pseudo types are not defined by GCC, they are simply a notational
12867 convenience used in this manual.
12869 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12870 and @code{sw2} are evaluated at run time.  They correspond to
12871 register operands in the underlying FR-V instructions.
12873 @code{const} arguments represent immediate operands in the underlying
12874 FR-V instructions.  They must be compile-time constants.
12876 @code{acc} arguments are evaluated at compile time and specify the number
12877 of an accumulator register.  For example, an @code{acc} argument of 2
12878 selects the ACC2 register.
12880 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12881 number of an IACC register.  See @pxref{Other Built-in Functions}
12882 for more details.
12884 @node Directly-mapped Integer Functions
12885 @subsubsection Directly-Mapped Integer Functions
12887 The functions listed below map directly to FR-V I-type instructions.
12889 @multitable @columnfractions .45 .32 .23
12890 @item Function prototype @tab Example usage @tab Assembly output
12891 @item @code{sw1 __ADDSS (sw1, sw1)}
12892 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12893 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12894 @item @code{sw1 __SCAN (sw1, sw1)}
12895 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12896 @tab @code{SCAN @var{a},@var{b},@var{c}}
12897 @item @code{sw1 __SCUTSS (sw1)}
12898 @tab @code{@var{b} = __SCUTSS (@var{a})}
12899 @tab @code{SCUTSS @var{a},@var{b}}
12900 @item @code{sw1 __SLASS (sw1, sw1)}
12901 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12902 @tab @code{SLASS @var{a},@var{b},@var{c}}
12903 @item @code{void __SMASS (sw1, sw1)}
12904 @tab @code{__SMASS (@var{a}, @var{b})}
12905 @tab @code{SMASS @var{a},@var{b}}
12906 @item @code{void __SMSSS (sw1, sw1)}
12907 @tab @code{__SMSSS (@var{a}, @var{b})}
12908 @tab @code{SMSSS @var{a},@var{b}}
12909 @item @code{void __SMU (sw1, sw1)}
12910 @tab @code{__SMU (@var{a}, @var{b})}
12911 @tab @code{SMU @var{a},@var{b}}
12912 @item @code{sw2 __SMUL (sw1, sw1)}
12913 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12914 @tab @code{SMUL @var{a},@var{b},@var{c}}
12915 @item @code{sw1 __SUBSS (sw1, sw1)}
12916 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12917 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12918 @item @code{uw2 __UMUL (uw1, uw1)}
12919 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12920 @tab @code{UMUL @var{a},@var{b},@var{c}}
12921 @end multitable
12923 @node Directly-mapped Media Functions
12924 @subsubsection Directly-Mapped Media Functions
12926 The functions listed below map directly to FR-V M-type instructions.
12928 @multitable @columnfractions .45 .32 .23
12929 @item Function prototype @tab Example usage @tab Assembly output
12930 @item @code{uw1 __MABSHS (sw1)}
12931 @tab @code{@var{b} = __MABSHS (@var{a})}
12932 @tab @code{MABSHS @var{a},@var{b}}
12933 @item @code{void __MADDACCS (acc, acc)}
12934 @tab @code{__MADDACCS (@var{b}, @var{a})}
12935 @tab @code{MADDACCS @var{a},@var{b}}
12936 @item @code{sw1 __MADDHSS (sw1, sw1)}
12937 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12938 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12939 @item @code{uw1 __MADDHUS (uw1, uw1)}
12940 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12941 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12942 @item @code{uw1 __MAND (uw1, uw1)}
12943 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12944 @tab @code{MAND @var{a},@var{b},@var{c}}
12945 @item @code{void __MASACCS (acc, acc)}
12946 @tab @code{__MASACCS (@var{b}, @var{a})}
12947 @tab @code{MASACCS @var{a},@var{b}}
12948 @item @code{uw1 __MAVEH (uw1, uw1)}
12949 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12950 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12951 @item @code{uw2 __MBTOH (uw1)}
12952 @tab @code{@var{b} = __MBTOH (@var{a})}
12953 @tab @code{MBTOH @var{a},@var{b}}
12954 @item @code{void __MBTOHE (uw1 *, uw1)}
12955 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12956 @tab @code{MBTOHE @var{a},@var{b}}
12957 @item @code{void __MCLRACC (acc)}
12958 @tab @code{__MCLRACC (@var{a})}
12959 @tab @code{MCLRACC @var{a}}
12960 @item @code{void __MCLRACCA (void)}
12961 @tab @code{__MCLRACCA ()}
12962 @tab @code{MCLRACCA}
12963 @item @code{uw1 __Mcop1 (uw1, uw1)}
12964 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12965 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12966 @item @code{uw1 __Mcop2 (uw1, uw1)}
12967 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12968 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12969 @item @code{uw1 __MCPLHI (uw2, const)}
12970 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12971 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12972 @item @code{uw1 __MCPLI (uw2, const)}
12973 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12974 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12975 @item @code{void __MCPXIS (acc, sw1, sw1)}
12976 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12977 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12978 @item @code{void __MCPXIU (acc, uw1, uw1)}
12979 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12980 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12981 @item @code{void __MCPXRS (acc, sw1, sw1)}
12982 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12983 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12984 @item @code{void __MCPXRU (acc, uw1, uw1)}
12985 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12986 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12987 @item @code{uw1 __MCUT (acc, uw1)}
12988 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12989 @tab @code{MCUT @var{a},@var{b},@var{c}}
12990 @item @code{uw1 __MCUTSS (acc, sw1)}
12991 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12992 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12993 @item @code{void __MDADDACCS (acc, acc)}
12994 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12995 @tab @code{MDADDACCS @var{a},@var{b}}
12996 @item @code{void __MDASACCS (acc, acc)}
12997 @tab @code{__MDASACCS (@var{b}, @var{a})}
12998 @tab @code{MDASACCS @var{a},@var{b}}
12999 @item @code{uw2 __MDCUTSSI (acc, const)}
13000 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13001 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13002 @item @code{uw2 __MDPACKH (uw2, uw2)}
13003 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13004 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13005 @item @code{uw2 __MDROTLI (uw2, const)}
13006 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13007 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13008 @item @code{void __MDSUBACCS (acc, acc)}
13009 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13010 @tab @code{MDSUBACCS @var{a},@var{b}}
13011 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13012 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13013 @tab @code{MDUNPACKH @var{a},@var{b}}
13014 @item @code{uw2 __MEXPDHD (uw1, const)}
13015 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13016 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13017 @item @code{uw1 __MEXPDHW (uw1, const)}
13018 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13019 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13020 @item @code{uw1 __MHDSETH (uw1, const)}
13021 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13022 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13023 @item @code{sw1 __MHDSETS (const)}
13024 @tab @code{@var{b} = __MHDSETS (@var{a})}
13025 @tab @code{MHDSETS #@var{a},@var{b}}
13026 @item @code{uw1 __MHSETHIH (uw1, const)}
13027 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13028 @tab @code{MHSETHIH #@var{a},@var{b}}
13029 @item @code{sw1 __MHSETHIS (sw1, const)}
13030 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13031 @tab @code{MHSETHIS #@var{a},@var{b}}
13032 @item @code{uw1 __MHSETLOH (uw1, const)}
13033 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13034 @tab @code{MHSETLOH #@var{a},@var{b}}
13035 @item @code{sw1 __MHSETLOS (sw1, const)}
13036 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13037 @tab @code{MHSETLOS #@var{a},@var{b}}
13038 @item @code{uw1 __MHTOB (uw2)}
13039 @tab @code{@var{b} = __MHTOB (@var{a})}
13040 @tab @code{MHTOB @var{a},@var{b}}
13041 @item @code{void __MMACHS (acc, sw1, sw1)}
13042 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13043 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13044 @item @code{void __MMACHU (acc, uw1, uw1)}
13045 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13046 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13047 @item @code{void __MMRDHS (acc, sw1, sw1)}
13048 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13049 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13050 @item @code{void __MMRDHU (acc, uw1, uw1)}
13051 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13052 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13053 @item @code{void __MMULHS (acc, sw1, sw1)}
13054 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13055 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13056 @item @code{void __MMULHU (acc, uw1, uw1)}
13057 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13058 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13059 @item @code{void __MMULXHS (acc, sw1, sw1)}
13060 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13061 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13062 @item @code{void __MMULXHU (acc, uw1, uw1)}
13063 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13064 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13065 @item @code{uw1 __MNOT (uw1)}
13066 @tab @code{@var{b} = __MNOT (@var{a})}
13067 @tab @code{MNOT @var{a},@var{b}}
13068 @item @code{uw1 __MOR (uw1, uw1)}
13069 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13070 @tab @code{MOR @var{a},@var{b},@var{c}}
13071 @item @code{uw1 __MPACKH (uh, uh)}
13072 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13073 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13074 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13075 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13076 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13077 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13078 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13079 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13080 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13081 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13082 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13083 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13084 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13085 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13086 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13087 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13088 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13089 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13090 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13091 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13092 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13093 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13094 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13095 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13096 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13097 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13098 @item @code{void __MQMACHS (acc, sw2, sw2)}
13099 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13100 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13101 @item @code{void __MQMACHU (acc, uw2, uw2)}
13102 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13103 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13104 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13105 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13106 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13107 @item @code{void __MQMULHS (acc, sw2, sw2)}
13108 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13109 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13110 @item @code{void __MQMULHU (acc, uw2, uw2)}
13111 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13112 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13113 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13114 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13115 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13116 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13117 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13118 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13119 @item @code{sw2 __MQSATHS (sw2, sw2)}
13120 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13121 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13122 @item @code{uw2 __MQSLLHI (uw2, int)}
13123 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13124 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13125 @item @code{sw2 __MQSRAHI (sw2, int)}
13126 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13127 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13128 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13129 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13130 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13131 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13132 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13133 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13134 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13135 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13136 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13137 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13138 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13139 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13140 @item @code{uw1 __MRDACC (acc)}
13141 @tab @code{@var{b} = __MRDACC (@var{a})}
13142 @tab @code{MRDACC @var{a},@var{b}}
13143 @item @code{uw1 __MRDACCG (acc)}
13144 @tab @code{@var{b} = __MRDACCG (@var{a})}
13145 @tab @code{MRDACCG @var{a},@var{b}}
13146 @item @code{uw1 __MROTLI (uw1, const)}
13147 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13148 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13149 @item @code{uw1 __MROTRI (uw1, const)}
13150 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13151 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13152 @item @code{sw1 __MSATHS (sw1, sw1)}
13153 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13154 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13155 @item @code{uw1 __MSATHU (uw1, uw1)}
13156 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13157 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13158 @item @code{uw1 __MSLLHI (uw1, const)}
13159 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13160 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13161 @item @code{sw1 __MSRAHI (sw1, const)}
13162 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13163 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13164 @item @code{uw1 __MSRLHI (uw1, const)}
13165 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13166 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13167 @item @code{void __MSUBACCS (acc, acc)}
13168 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13169 @tab @code{MSUBACCS @var{a},@var{b}}
13170 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13171 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13172 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13173 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13174 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13175 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13176 @item @code{void __MTRAP (void)}
13177 @tab @code{__MTRAP ()}
13178 @tab @code{MTRAP}
13179 @item @code{uw2 __MUNPACKH (uw1)}
13180 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13181 @tab @code{MUNPACKH @var{a},@var{b}}
13182 @item @code{uw1 __MWCUT (uw2, uw1)}
13183 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13184 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13185 @item @code{void __MWTACC (acc, uw1)}
13186 @tab @code{__MWTACC (@var{b}, @var{a})}
13187 @tab @code{MWTACC @var{a},@var{b}}
13188 @item @code{void __MWTACCG (acc, uw1)}
13189 @tab @code{__MWTACCG (@var{b}, @var{a})}
13190 @tab @code{MWTACCG @var{a},@var{b}}
13191 @item @code{uw1 __MXOR (uw1, uw1)}
13192 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13193 @tab @code{MXOR @var{a},@var{b},@var{c}}
13194 @end multitable
13196 @node Raw read/write Functions
13197 @subsubsection Raw Read/Write Functions
13199 This sections describes built-in functions related to read and write
13200 instructions to access memory.  These functions generate
13201 @code{membar} instructions to flush the I/O load and stores where
13202 appropriate, as described in Fujitsu's manual described above.
13204 @table @code
13206 @item unsigned char __builtin_read8 (void *@var{data})
13207 @item unsigned short __builtin_read16 (void *@var{data})
13208 @item unsigned long __builtin_read32 (void *@var{data})
13209 @item unsigned long long __builtin_read64 (void *@var{data})
13211 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13212 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13213 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13214 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13215 @end table
13217 @node Other Built-in Functions
13218 @subsubsection Other Built-in Functions
13220 This section describes built-in functions that are not named after
13221 a specific FR-V instruction.
13223 @table @code
13224 @item sw2 __IACCreadll (iacc @var{reg})
13225 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13226 for future expansion and must be 0.
13228 @item sw1 __IACCreadl (iacc @var{reg})
13229 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13230 Other values of @var{reg} are rejected as invalid.
13232 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13233 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13234 is reserved for future expansion and must be 0.
13236 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13237 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13238 is 1.  Other values of @var{reg} are rejected as invalid.
13240 @item void __data_prefetch0 (const void *@var{x})
13241 Use the @code{dcpl} instruction to load the contents of address @var{x}
13242 into the data cache.
13244 @item void __data_prefetch (const void *@var{x})
13245 Use the @code{nldub} instruction to load the contents of address @var{x}
13246 into the data cache.  The instruction is issued in slot I1@.
13247 @end table
13249 @node MIPS DSP Built-in Functions
13250 @subsection MIPS DSP Built-in Functions
13252 The MIPS DSP Application-Specific Extension (ASE) includes new
13253 instructions that are designed to improve the performance of DSP and
13254 media applications.  It provides instructions that operate on packed
13255 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13257 GCC supports MIPS DSP operations using both the generic
13258 vector extensions (@pxref{Vector Extensions}) and a collection of
13259 MIPS-specific built-in functions.  Both kinds of support are
13260 enabled by the @option{-mdsp} command-line option.
13262 Revision 2 of the ASE was introduced in the second half of 2006.
13263 This revision adds extra instructions to the original ASE, but is
13264 otherwise backwards-compatible with it.  You can select revision 2
13265 using the command-line option @option{-mdspr2}; this option implies
13266 @option{-mdsp}.
13268 The SCOUNT and POS bits of the DSP control register are global.  The
13269 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13270 POS bits.  During optimization, the compiler does not delete these
13271 instructions and it does not delete calls to functions containing
13272 these instructions.
13274 At present, GCC only provides support for operations on 32-bit
13275 vectors.  The vector type associated with 8-bit integer data is
13276 usually called @code{v4i8}, the vector type associated with Q7
13277 is usually called @code{v4q7}, the vector type associated with 16-bit
13278 integer data is usually called @code{v2i16}, and the vector type
13279 associated with Q15 is usually called @code{v2q15}.  They can be
13280 defined in C as follows:
13282 @smallexample
13283 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13284 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13285 typedef short v2i16 __attribute__ ((vector_size(4)));
13286 typedef short v2q15 __attribute__ ((vector_size(4)));
13287 @end smallexample
13289 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13290 initialized in the same way as aggregates.  For example:
13292 @smallexample
13293 v4i8 a = @{1, 2, 3, 4@};
13294 v4i8 b;
13295 b = (v4i8) @{5, 6, 7, 8@};
13297 v2q15 c = @{0x0fcb, 0x3a75@};
13298 v2q15 d;
13299 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13300 @end smallexample
13302 @emph{Note:} The CPU's endianness determines the order in which values
13303 are packed.  On little-endian targets, the first value is the least
13304 significant and the last value is the most significant.  The opposite
13305 order applies to big-endian targets.  For example, the code above
13306 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13307 and @code{4} on big-endian targets.
13309 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13310 representation.  As shown in this example, the integer representation
13311 of a Q7 value can be obtained by multiplying the fractional value by
13312 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13313 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13314 @code{0x1.0p31}.
13316 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13317 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13318 and @code{c} and @code{d} are @code{v2q15} values.
13320 @multitable @columnfractions .50 .50
13321 @item C code @tab MIPS instruction
13322 @item @code{a + b} @tab @code{addu.qb}
13323 @item @code{c + d} @tab @code{addq.ph}
13324 @item @code{a - b} @tab @code{subu.qb}
13325 @item @code{c - d} @tab @code{subq.ph}
13326 @end multitable
13328 The table below lists the @code{v2i16} operation for which
13329 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13330 @code{v2i16} values.
13332 @multitable @columnfractions .50 .50
13333 @item C code @tab MIPS instruction
13334 @item @code{e * f} @tab @code{mul.ph}
13335 @end multitable
13337 It is easier to describe the DSP built-in functions if we first define
13338 the following types:
13340 @smallexample
13341 typedef int q31;
13342 typedef int i32;
13343 typedef unsigned int ui32;
13344 typedef long long a64;
13345 @end smallexample
13347 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13348 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13349 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13350 @code{long long}, but we use @code{a64} to indicate values that are
13351 placed in one of the four DSP accumulators (@code{$ac0},
13352 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13354 Also, some built-in functions prefer or require immediate numbers as
13355 parameters, because the corresponding DSP instructions accept both immediate
13356 numbers and register operands, or accept immediate numbers only.  The
13357 immediate parameters are listed as follows.
13359 @smallexample
13360 imm0_3: 0 to 3.
13361 imm0_7: 0 to 7.
13362 imm0_15: 0 to 15.
13363 imm0_31: 0 to 31.
13364 imm0_63: 0 to 63.
13365 imm0_255: 0 to 255.
13366 imm_n32_31: -32 to 31.
13367 imm_n512_511: -512 to 511.
13368 @end smallexample
13370 The following built-in functions map directly to a particular MIPS DSP
13371 instruction.  Please refer to the architecture specification
13372 for details on what each instruction does.
13374 @smallexample
13375 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13376 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13377 q31 __builtin_mips_addq_s_w (q31, q31)
13378 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13379 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13380 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13381 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13382 q31 __builtin_mips_subq_s_w (q31, q31)
13383 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13384 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13385 i32 __builtin_mips_addsc (i32, i32)
13386 i32 __builtin_mips_addwc (i32, i32)
13387 i32 __builtin_mips_modsub (i32, i32)
13388 i32 __builtin_mips_raddu_w_qb (v4i8)
13389 v2q15 __builtin_mips_absq_s_ph (v2q15)
13390 q31 __builtin_mips_absq_s_w (q31)
13391 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13392 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13393 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13394 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13395 q31 __builtin_mips_preceq_w_phl (v2q15)
13396 q31 __builtin_mips_preceq_w_phr (v2q15)
13397 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13398 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13399 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13400 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13401 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13402 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13403 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13404 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13405 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13406 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13407 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13408 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13409 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13410 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13411 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13412 q31 __builtin_mips_shll_s_w (q31, i32)
13413 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13414 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13415 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13416 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13417 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13418 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13419 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13420 q31 __builtin_mips_shra_r_w (q31, i32)
13421 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13422 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13423 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13424 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13425 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13426 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13427 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13428 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13429 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13430 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13431 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13432 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13433 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13434 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13435 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13436 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13437 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13438 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13439 i32 __builtin_mips_bitrev (i32)
13440 i32 __builtin_mips_insv (i32, i32)
13441 v4i8 __builtin_mips_repl_qb (imm0_255)
13442 v4i8 __builtin_mips_repl_qb (i32)
13443 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13444 v2q15 __builtin_mips_repl_ph (i32)
13445 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13446 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13447 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13448 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13449 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13450 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13451 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13452 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13453 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13454 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13455 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13456 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13457 i32 __builtin_mips_extr_w (a64, imm0_31)
13458 i32 __builtin_mips_extr_w (a64, i32)
13459 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13460 i32 __builtin_mips_extr_s_h (a64, i32)
13461 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13462 i32 __builtin_mips_extr_rs_w (a64, i32)
13463 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13464 i32 __builtin_mips_extr_r_w (a64, i32)
13465 i32 __builtin_mips_extp (a64, imm0_31)
13466 i32 __builtin_mips_extp (a64, i32)
13467 i32 __builtin_mips_extpdp (a64, imm0_31)
13468 i32 __builtin_mips_extpdp (a64, i32)
13469 a64 __builtin_mips_shilo (a64, imm_n32_31)
13470 a64 __builtin_mips_shilo (a64, i32)
13471 a64 __builtin_mips_mthlip (a64, i32)
13472 void __builtin_mips_wrdsp (i32, imm0_63)
13473 i32 __builtin_mips_rddsp (imm0_63)
13474 i32 __builtin_mips_lbux (void *, i32)
13475 i32 __builtin_mips_lhx (void *, i32)
13476 i32 __builtin_mips_lwx (void *, i32)
13477 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13478 i32 __builtin_mips_bposge32 (void)
13479 a64 __builtin_mips_madd (a64, i32, i32);
13480 a64 __builtin_mips_maddu (a64, ui32, ui32);
13481 a64 __builtin_mips_msub (a64, i32, i32);
13482 a64 __builtin_mips_msubu (a64, ui32, ui32);
13483 a64 __builtin_mips_mult (i32, i32);
13484 a64 __builtin_mips_multu (ui32, ui32);
13485 @end smallexample
13487 The following built-in functions map directly to a particular MIPS DSP REV 2
13488 instruction.  Please refer to the architecture specification
13489 for details on what each instruction does.
13491 @smallexample
13492 v4q7 __builtin_mips_absq_s_qb (v4q7);
13493 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13494 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13495 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13496 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13497 i32 __builtin_mips_append (i32, i32, imm0_31);
13498 i32 __builtin_mips_balign (i32, i32, imm0_3);
13499 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13500 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13501 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13502 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13503 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13504 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13505 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13506 q31 __builtin_mips_mulq_rs_w (q31, q31);
13507 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13508 q31 __builtin_mips_mulq_s_w (q31, q31);
13509 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13510 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13511 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13512 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13513 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13514 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13515 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13516 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13517 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13518 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13519 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13520 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13521 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13522 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13523 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13524 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13525 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13526 q31 __builtin_mips_addqh_w (q31, q31);
13527 q31 __builtin_mips_addqh_r_w (q31, q31);
13528 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13529 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13530 q31 __builtin_mips_subqh_w (q31, q31);
13531 q31 __builtin_mips_subqh_r_w (q31, q31);
13532 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13533 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13534 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13535 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13536 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13537 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13538 @end smallexample
13541 @node MIPS Paired-Single Support
13542 @subsection MIPS Paired-Single Support
13544 The MIPS64 architecture includes a number of instructions that
13545 operate on pairs of single-precision floating-point values.
13546 Each pair is packed into a 64-bit floating-point register,
13547 with one element being designated the ``upper half'' and
13548 the other being designated the ``lower half''.
13550 GCC supports paired-single operations using both the generic
13551 vector extensions (@pxref{Vector Extensions}) and a collection of
13552 MIPS-specific built-in functions.  Both kinds of support are
13553 enabled by the @option{-mpaired-single} command-line option.
13555 The vector type associated with paired-single values is usually
13556 called @code{v2sf}.  It can be defined in C as follows:
13558 @smallexample
13559 typedef float v2sf __attribute__ ((vector_size (8)));
13560 @end smallexample
13562 @code{v2sf} values are initialized in the same way as aggregates.
13563 For example:
13565 @smallexample
13566 v2sf a = @{1.5, 9.1@};
13567 v2sf b;
13568 float e, f;
13569 b = (v2sf) @{e, f@};
13570 @end smallexample
13572 @emph{Note:} The CPU's endianness determines which value is stored in
13573 the upper half of a register and which value is stored in the lower half.
13574 On little-endian targets, the first value is the lower one and the second
13575 value is the upper one.  The opposite order applies to big-endian targets.
13576 For example, the code above sets the lower half of @code{a} to
13577 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13579 @node MIPS Loongson Built-in Functions
13580 @subsection MIPS Loongson Built-in Functions
13582 GCC provides intrinsics to access the SIMD instructions provided by the
13583 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13584 available after inclusion of the @code{loongson.h} header file,
13585 operate on the following 64-bit vector types:
13587 @itemize
13588 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13589 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13590 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13591 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13592 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13593 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13594 @end itemize
13596 The intrinsics provided are listed below; each is named after the
13597 machine instruction to which it corresponds, with suffixes added as
13598 appropriate to distinguish intrinsics that expand to the same machine
13599 instruction yet have different argument types.  Refer to the architecture
13600 documentation for a description of the functionality of each
13601 instruction.
13603 @smallexample
13604 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13605 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13606 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13607 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13608 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13609 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13610 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13611 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13612 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13613 uint64_t paddd_u (uint64_t s, uint64_t t);
13614 int64_t paddd_s (int64_t s, int64_t t);
13615 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13616 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13617 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13618 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13619 uint64_t pandn_ud (uint64_t s, uint64_t t);
13620 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13621 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13622 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13623 int64_t pandn_sd (int64_t s, int64_t t);
13624 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13625 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13626 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13627 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13628 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13629 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13630 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13631 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13632 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13633 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13634 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13635 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13636 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13637 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13638 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13639 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13640 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13641 uint16x4_t pextrh_u (uint16x4_t s, int field);
13642 int16x4_t pextrh_s (int16x4_t s, int field);
13643 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13644 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13645 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13646 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13647 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13648 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13649 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13650 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13651 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13652 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13653 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13654 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13655 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13656 uint8x8_t pmovmskb_u (uint8x8_t s);
13657 int8x8_t pmovmskb_s (int8x8_t s);
13658 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13659 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13660 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13661 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13662 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13663 uint16x4_t biadd (uint8x8_t s);
13664 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13665 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13666 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13667 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13668 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13669 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13670 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13671 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13672 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13673 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13674 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13675 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13676 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13677 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13678 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13679 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13680 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13681 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13682 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13683 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13684 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13685 uint64_t psubd_u (uint64_t s, uint64_t t);
13686 int64_t psubd_s (int64_t s, int64_t t);
13687 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13688 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13689 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13690 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13691 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13692 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13693 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13694 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13695 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13696 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13697 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13698 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13699 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13700 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13701 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13702 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13703 @end smallexample
13705 @menu
13706 * Paired-Single Arithmetic::
13707 * Paired-Single Built-in Functions::
13708 * MIPS-3D Built-in Functions::
13709 @end menu
13711 @node Paired-Single Arithmetic
13712 @subsubsection Paired-Single Arithmetic
13714 The table below lists the @code{v2sf} operations for which hardware
13715 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13716 values and @code{x} is an integral value.
13718 @multitable @columnfractions .50 .50
13719 @item C code @tab MIPS instruction
13720 @item @code{a + b} @tab @code{add.ps}
13721 @item @code{a - b} @tab @code{sub.ps}
13722 @item @code{-a} @tab @code{neg.ps}
13723 @item @code{a * b} @tab @code{mul.ps}
13724 @item @code{a * b + c} @tab @code{madd.ps}
13725 @item @code{a * b - c} @tab @code{msub.ps}
13726 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13727 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13728 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13729 @end multitable
13731 Note that the multiply-accumulate instructions can be disabled
13732 using the command-line option @code{-mno-fused-madd}.
13734 @node Paired-Single Built-in Functions
13735 @subsubsection Paired-Single Built-in Functions
13737 The following paired-single functions map directly to a particular
13738 MIPS instruction.  Please refer to the architecture specification
13739 for details on what each instruction does.
13741 @table @code
13742 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13743 Pair lower lower (@code{pll.ps}).
13745 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13746 Pair upper lower (@code{pul.ps}).
13748 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13749 Pair lower upper (@code{plu.ps}).
13751 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13752 Pair upper upper (@code{puu.ps}).
13754 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13755 Convert pair to paired single (@code{cvt.ps.s}).
13757 @item float __builtin_mips_cvt_s_pl (v2sf)
13758 Convert pair lower to single (@code{cvt.s.pl}).
13760 @item float __builtin_mips_cvt_s_pu (v2sf)
13761 Convert pair upper to single (@code{cvt.s.pu}).
13763 @item v2sf __builtin_mips_abs_ps (v2sf)
13764 Absolute value (@code{abs.ps}).
13766 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13767 Align variable (@code{alnv.ps}).
13769 @emph{Note:} The value of the third parameter must be 0 or 4
13770 modulo 8, otherwise the result is unpredictable.  Please read the
13771 instruction description for details.
13772 @end table
13774 The following multi-instruction functions are also available.
13775 In each case, @var{cond} can be any of the 16 floating-point conditions:
13776 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13777 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13778 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13780 @table @code
13781 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13782 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13783 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13784 @code{movt.ps}/@code{movf.ps}).
13786 The @code{movt} functions return the value @var{x} computed by:
13788 @smallexample
13789 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13790 mov.ps @var{x},@var{c}
13791 movt.ps @var{x},@var{d},@var{cc}
13792 @end smallexample
13794 The @code{movf} functions are similar but use @code{movf.ps} instead
13795 of @code{movt.ps}.
13797 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13798 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13799 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13800 @code{bc1t}/@code{bc1f}).
13802 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13803 and return either the upper or lower half of the result.  For example:
13805 @smallexample
13806 v2sf a, b;
13807 if (__builtin_mips_upper_c_eq_ps (a, b))
13808   upper_halves_are_equal ();
13809 else
13810   upper_halves_are_unequal ();
13812 if (__builtin_mips_lower_c_eq_ps (a, b))
13813   lower_halves_are_equal ();
13814 else
13815   lower_halves_are_unequal ();
13816 @end smallexample
13817 @end table
13819 @node MIPS-3D Built-in Functions
13820 @subsubsection MIPS-3D Built-in Functions
13822 The MIPS-3D Application-Specific Extension (ASE) includes additional
13823 paired-single instructions that are designed to improve the performance
13824 of 3D graphics operations.  Support for these instructions is controlled
13825 by the @option{-mips3d} command-line option.
13827 The functions listed below map directly to a particular MIPS-3D
13828 instruction.  Please refer to the architecture specification for
13829 more details on what each instruction does.
13831 @table @code
13832 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13833 Reduction add (@code{addr.ps}).
13835 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13836 Reduction multiply (@code{mulr.ps}).
13838 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13839 Convert paired single to paired word (@code{cvt.pw.ps}).
13841 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13842 Convert paired word to paired single (@code{cvt.ps.pw}).
13844 @item float __builtin_mips_recip1_s (float)
13845 @itemx double __builtin_mips_recip1_d (double)
13846 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13847 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13849 @item float __builtin_mips_recip2_s (float, float)
13850 @itemx double __builtin_mips_recip2_d (double, double)
13851 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13852 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13854 @item float __builtin_mips_rsqrt1_s (float)
13855 @itemx double __builtin_mips_rsqrt1_d (double)
13856 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13857 Reduced-precision reciprocal square root (sequence step 1)
13858 (@code{rsqrt1.@var{fmt}}).
13860 @item float __builtin_mips_rsqrt2_s (float, float)
13861 @itemx double __builtin_mips_rsqrt2_d (double, double)
13862 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13863 Reduced-precision reciprocal square root (sequence step 2)
13864 (@code{rsqrt2.@var{fmt}}).
13865 @end table
13867 The following multi-instruction functions are also available.
13868 In each case, @var{cond} can be any of the 16 floating-point conditions:
13869 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13870 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13871 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13873 @table @code
13874 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13875 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13876 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13877 @code{bc1t}/@code{bc1f}).
13879 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13880 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13881 For example:
13883 @smallexample
13884 float a, b;
13885 if (__builtin_mips_cabs_eq_s (a, b))
13886   true ();
13887 else
13888   false ();
13889 @end smallexample
13891 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13892 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13893 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13894 @code{bc1t}/@code{bc1f}).
13896 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13897 and return either the upper or lower half of the result.  For example:
13899 @smallexample
13900 v2sf a, b;
13901 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13902   upper_halves_are_equal ();
13903 else
13904   upper_halves_are_unequal ();
13906 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13907   lower_halves_are_equal ();
13908 else
13909   lower_halves_are_unequal ();
13910 @end smallexample
13912 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13913 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13914 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13915 @code{movt.ps}/@code{movf.ps}).
13917 The @code{movt} functions return the value @var{x} computed by:
13919 @smallexample
13920 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13921 mov.ps @var{x},@var{c}
13922 movt.ps @var{x},@var{d},@var{cc}
13923 @end smallexample
13925 The @code{movf} functions are similar but use @code{movf.ps} instead
13926 of @code{movt.ps}.
13928 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13929 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13930 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13931 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13932 Comparison of two paired-single values
13933 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13934 @code{bc1any2t}/@code{bc1any2f}).
13936 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13937 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13938 result is true and the @code{all} forms return true if both results are true.
13939 For example:
13941 @smallexample
13942 v2sf a, b;
13943 if (__builtin_mips_any_c_eq_ps (a, b))
13944   one_is_true ();
13945 else
13946   both_are_false ();
13948 if (__builtin_mips_all_c_eq_ps (a, b))
13949   both_are_true ();
13950 else
13951   one_is_false ();
13952 @end smallexample
13954 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13955 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13956 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13957 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13958 Comparison of four paired-single values
13959 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13960 @code{bc1any4t}/@code{bc1any4f}).
13962 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13963 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13964 The @code{any} forms return true if any of the four results are true
13965 and the @code{all} forms return true if all four results are true.
13966 For example:
13968 @smallexample
13969 v2sf a, b, c, d;
13970 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13971   some_are_true ();
13972 else
13973   all_are_false ();
13975 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13976   all_are_true ();
13977 else
13978   some_are_false ();
13979 @end smallexample
13980 @end table
13982 @node MIPS SIMD Architecture (MSA) Support
13983 @subsection MIPS SIMD Architecture (MSA) Support
13985 @menu
13986 * MIPS SIMD Architecture Built-in Functions::
13987 @end menu
13989 GCC provides intrinsics to access the SIMD instructions provided by the
13990 MSA MIPS SIMD Architecture.  The interface is made available by including
13991 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13992 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13993 @code{__msa_*}.
13995 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13996 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13997 data elements.  The following vectors typedefs are included in @code{msa.h}:
13998 @itemize
13999 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14000 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14001 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14002 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14003 @item @code{v4i32}, a vector of four signed 32-bit integers;
14004 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14005 @item @code{v2i64}, a vector of two signed 64-bit integers;
14006 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14007 @item @code{v4f32}, a vector of four 32-bit floats;
14008 @item @code{v2f64}, a vector of two 64-bit doubles.
14009 @end itemize
14011 Instructions and corresponding built-ins may have additional restrictions and/or
14012 input/output values manipulated:
14013 @itemize
14014 @item @code{imm0_1}, an integer literal in range 0 to 1;
14015 @item @code{imm0_3}, an integer literal in range 0 to 3;
14016 @item @code{imm0_7}, an integer literal in range 0 to 7;
14017 @item @code{imm0_15}, an integer literal in range 0 to 15;
14018 @item @code{imm0_31}, an integer literal in range 0 to 31;
14019 @item @code{imm0_63}, an integer literal in range 0 to 63;
14020 @item @code{imm0_255}, an integer literal in range 0 to 255;
14021 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14022 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14023 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14024 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14025 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14026 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14027 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14028 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14029 @item @code{imm1_4}, an integer literal in range 1 to 4;
14030 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14031 @end itemize
14033 @smallexample
14035 typedef int i32;
14036 #if __LONG_MAX__ == __LONG_LONG_MAX__
14037 typedef long i64;
14038 #else
14039 typedef long long i64;
14040 #endif
14042 typedef unsigned int u32;
14043 #if __LONG_MAX__ == __LONG_LONG_MAX__
14044 typedef unsigned long u64;
14045 #else
14046 typedef unsigned long long u64;
14047 #endif
14049 typedef double f64;
14050 typedef float f32;
14052 @end smallexample
14054 @node MIPS SIMD Architecture Built-in Functions
14055 @subsubsection MIPS SIMD Architecture Built-in Functions
14057 The intrinsics provided are listed below; each is named after the
14058 machine instruction.
14060 @smallexample
14061 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14062 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14063 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14064 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14066 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14067 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14068 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14069 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14071 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14072 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14073 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14074 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14076 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14077 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14078 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14079 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14081 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14082 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14083 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14084 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14086 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14087 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14088 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14089 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14091 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14093 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14095 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14096 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14097 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14098 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14100 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14101 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14102 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14103 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14105 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14106 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14107 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14108 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14110 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14111 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14112 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14113 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14115 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14116 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14117 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14118 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14120 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14121 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14122 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14123 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14125 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14126 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14127 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14128 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14130 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14131 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14132 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14133 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14135 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14136 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14137 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14138 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14140 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14141 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14142 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14143 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14145 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14146 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14147 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14148 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14150 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14151 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14152 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14153 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14155 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14157 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14159 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14161 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14163 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14164 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14165 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14166 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14168 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14169 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14170 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14171 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14173 i32 __builtin_msa_bnz_b (v16u8);
14174 i32 __builtin_msa_bnz_h (v8u16);
14175 i32 __builtin_msa_bnz_w (v4u32);
14176 i32 __builtin_msa_bnz_d (v2u64);
14178 i32 __builtin_msa_bnz_v (v16u8);
14180 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14182 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14184 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14185 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14186 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14187 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14189 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14190 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14191 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14192 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14194 i32 __builtin_msa_bz_b (v16u8);
14195 i32 __builtin_msa_bz_h (v8u16);
14196 i32 __builtin_msa_bz_w (v4u32);
14197 i32 __builtin_msa_bz_d (v2u64);
14199 i32 __builtin_msa_bz_v (v16u8);
14201 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14202 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14203 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14204 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14206 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14207 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14208 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14209 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14211 i32 __builtin_msa_cfcmsa (imm0_31);
14213 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14214 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14215 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14216 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14218 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14219 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14220 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14221 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14223 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14224 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14225 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14226 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14228 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14229 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14230 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14231 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14233 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14234 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14235 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14236 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14238 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14239 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14240 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14241 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14243 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14244 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14245 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14246 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14248 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14249 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14250 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14251 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14253 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14254 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14255 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14256 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14258 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14259 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14260 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14261 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14263 void __builtin_msa_ctcmsa (imm0_31, i32);
14265 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14266 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14267 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14268 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14270 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14271 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14272 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14273 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14275 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14276 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14277 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14279 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14280 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14281 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14283 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14284 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14285 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14287 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14288 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14289 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14291 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14292 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14293 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14295 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14296 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14297 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14299 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14300 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14302 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14303 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14305 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14306 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14308 v4i32 __builtin_msa_fclass_w (v4f32);
14309 v2i64 __builtin_msa_fclass_d (v2f64);
14311 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14312 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14314 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14315 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14317 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14318 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14320 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14321 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14323 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14324 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14326 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14327 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14329 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14330 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14332 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14333 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14335 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14336 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14338 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14339 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14341 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14342 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14344 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14345 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14347 v4f32 __builtin_msa_fexupl_w (v8i16);
14348 v2f64 __builtin_msa_fexupl_d (v4f32);
14350 v4f32 __builtin_msa_fexupr_w (v8i16);
14351 v2f64 __builtin_msa_fexupr_d (v4f32);
14353 v4f32 __builtin_msa_ffint_s_w (v4i32);
14354 v2f64 __builtin_msa_ffint_s_d (v2i64);
14356 v4f32 __builtin_msa_ffint_u_w (v4u32);
14357 v2f64 __builtin_msa_ffint_u_d (v2u64);
14359 v4f32 __builtin_msa_ffql_w (v8i16);
14360 v2f64 __builtin_msa_ffql_d (v4i32);
14362 v4f32 __builtin_msa_ffqr_w (v8i16);
14363 v2f64 __builtin_msa_ffqr_d (v4i32);
14365 v16i8 __builtin_msa_fill_b (i32);
14366 v8i16 __builtin_msa_fill_h (i32);
14367 v4i32 __builtin_msa_fill_w (i32);
14368 v2i64 __builtin_msa_fill_d (i64);
14370 v4f32 __builtin_msa_flog2_w (v4f32);
14371 v2f64 __builtin_msa_flog2_d (v2f64);
14373 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14374 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14376 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14377 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14379 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14380 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14382 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14383 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14385 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14386 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14388 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14389 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14391 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14392 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14394 v4f32 __builtin_msa_frint_w (v4f32);
14395 v2f64 __builtin_msa_frint_d (v2f64);
14397 v4f32 __builtin_msa_frcp_w (v4f32);
14398 v2f64 __builtin_msa_frcp_d (v2f64);
14400 v4f32 __builtin_msa_frsqrt_w (v4f32);
14401 v2f64 __builtin_msa_frsqrt_d (v2f64);
14403 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14404 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14406 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14407 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14409 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14410 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14412 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14413 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14415 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14416 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14418 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14419 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14421 v4f32 __builtin_msa_fsqrt_w (v4f32);
14422 v2f64 __builtin_msa_fsqrt_d (v2f64);
14424 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14425 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14427 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14428 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14430 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14431 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14433 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14434 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14436 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14437 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14439 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14440 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14442 v4i32 __builtin_msa_ftint_s_w (v4f32);
14443 v2i64 __builtin_msa_ftint_s_d (v2f64);
14445 v4u32 __builtin_msa_ftint_u_w (v4f32);
14446 v2u64 __builtin_msa_ftint_u_d (v2f64);
14448 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14449 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14451 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14452 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14454 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14455 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14457 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14458 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14459 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14461 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14462 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14463 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14465 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14466 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14467 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14469 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14470 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14471 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14473 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14474 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14475 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14476 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14478 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14479 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14480 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14481 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14483 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14484 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14485 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14486 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14488 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14489 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14490 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14491 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14493 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14494 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14495 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14496 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14498 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14499 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14500 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14501 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14503 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14504 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14505 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14506 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14508 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14509 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14510 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14511 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14513 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14514 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14516 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14517 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14519 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14520 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14521 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14522 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14524 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14525 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14526 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14527 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14529 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14530 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14531 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14532 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14534 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14535 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14536 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14537 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14539 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14540 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14541 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14542 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14544 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14545 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14546 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14547 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14549 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14550 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14551 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14552 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14554 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14555 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14556 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14557 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14559 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14560 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14561 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14562 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14564 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14565 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14566 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14567 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14569 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14570 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14571 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14572 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14574 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14575 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14576 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14577 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14579 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14580 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14581 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14582 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14584 v16i8 __builtin_msa_move_v (v16i8);
14586 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14587 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14589 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14590 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14592 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14593 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14594 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14595 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14597 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14598 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14600 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14601 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14603 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14604 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14605 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14606 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14608 v16i8 __builtin_msa_nloc_b (v16i8);
14609 v8i16 __builtin_msa_nloc_h (v8i16);
14610 v4i32 __builtin_msa_nloc_w (v4i32);
14611 v2i64 __builtin_msa_nloc_d (v2i64);
14613 v16i8 __builtin_msa_nlzc_b (v16i8);
14614 v8i16 __builtin_msa_nlzc_h (v8i16);
14615 v4i32 __builtin_msa_nlzc_w (v4i32);
14616 v2i64 __builtin_msa_nlzc_d (v2i64);
14618 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14620 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14622 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14624 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14626 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14627 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14628 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14629 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14631 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14632 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14633 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14634 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14636 v16i8 __builtin_msa_pcnt_b (v16i8);
14637 v8i16 __builtin_msa_pcnt_h (v8i16);
14638 v4i32 __builtin_msa_pcnt_w (v4i32);
14639 v2i64 __builtin_msa_pcnt_d (v2i64);
14641 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14642 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14643 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14644 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14646 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14647 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14648 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14649 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14651 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14652 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14653 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14655 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14656 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14657 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14658 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14660 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14661 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14662 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14663 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14665 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14666 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14667 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14668 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14670 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14671 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14672 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14673 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14675 v16i8 __builtin_msa_splat_b (v16i8, i32);
14676 v8i16 __builtin_msa_splat_h (v8i16, i32);
14677 v4i32 __builtin_msa_splat_w (v4i32, i32);
14678 v2i64 __builtin_msa_splat_d (v2i64, i32);
14680 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14681 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14682 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14683 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14685 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14686 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14687 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14688 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14690 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14691 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14692 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14693 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14695 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14696 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14697 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14698 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14700 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14701 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14702 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14703 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14705 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14706 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14707 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14708 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14710 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14711 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14712 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14713 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14715 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14716 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14717 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14718 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14720 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14721 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14722 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14723 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14725 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14726 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14727 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14728 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14730 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14731 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14732 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14733 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14735 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14736 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14737 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14738 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14740 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14741 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14742 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14743 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14745 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14746 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14747 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14748 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14750 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14751 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14752 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14753 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14755 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14756 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14757 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14758 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14760 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14761 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14762 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14763 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14765 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14767 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14768 @end smallexample
14770 @node Other MIPS Built-in Functions
14771 @subsection Other MIPS Built-in Functions
14773 GCC provides other MIPS-specific built-in functions:
14775 @table @code
14776 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14777 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14778 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14779 when this function is available.
14781 @item unsigned int __builtin_mips_get_fcsr (void)
14782 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14783 Get and set the contents of the floating-point control and status register
14784 (FPU control register 31).  These functions are only available in hard-float
14785 code but can be called in both MIPS16 and non-MIPS16 contexts.
14787 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14788 register except the condition codes, which GCC assumes are preserved.
14789 @end table
14791 @node MSP430 Built-in Functions
14792 @subsection MSP430 Built-in Functions
14794 GCC provides a couple of special builtin functions to aid in the
14795 writing of interrupt handlers in C.
14797 @table @code
14798 @item __bic_SR_register_on_exit (int @var{mask})
14799 This clears the indicated bits in the saved copy of the status register
14800 currently residing on the stack.  This only works inside interrupt
14801 handlers and the changes to the status register will only take affect
14802 once the handler returns.
14804 @item __bis_SR_register_on_exit (int @var{mask})
14805 This sets the indicated bits in the saved copy of the status register
14806 currently residing on the stack.  This only works inside interrupt
14807 handlers and the changes to the status register will only take affect
14808 once the handler returns.
14810 @item __delay_cycles (long long @var{cycles})
14811 This inserts an instruction sequence that takes exactly @var{cycles}
14812 cycles (between 0 and about 17E9) to complete.  The inserted sequence
14813 may use jumps, loops, or no-ops, and does not interfere with any other
14814 instructions.  Note that @var{cycles} must be a compile-time constant
14815 integer - that is, you must pass a number, not a variable that may be
14816 optimized to a constant later.  The number of cycles delayed by this
14817 builtin is exact.
14818 @end table
14820 @node NDS32 Built-in Functions
14821 @subsection NDS32 Built-in Functions
14823 These built-in functions are available for the NDS32 target:
14825 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14826 Insert an ISYNC instruction into the instruction stream where
14827 @var{addr} is an instruction address for serialization.
14828 @end deftypefn
14830 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14831 Insert an ISB instruction into the instruction stream.
14832 @end deftypefn
14834 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14835 Return the content of a system register which is mapped by @var{sr}.
14836 @end deftypefn
14838 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14839 Return the content of a user space register which is mapped by @var{usr}.
14840 @end deftypefn
14842 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14843 Move the @var{value} to a system register which is mapped by @var{sr}.
14844 @end deftypefn
14846 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14847 Move the @var{value} to a user space register which is mapped by @var{usr}.
14848 @end deftypefn
14850 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14851 Enable global interrupt.
14852 @end deftypefn
14854 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14855 Disable global interrupt.
14856 @end deftypefn
14858 @node picoChip Built-in Functions
14859 @subsection picoChip Built-in Functions
14861 GCC provides an interface to selected machine instructions from the
14862 picoChip instruction set.
14864 @table @code
14865 @item int __builtin_sbc (int @var{value})
14866 Sign bit count.  Return the number of consecutive bits in @var{value}
14867 that have the same value as the sign bit.  The result is the number of
14868 leading sign bits minus one, giving the number of redundant sign bits in
14869 @var{value}.
14871 @item int __builtin_byteswap (int @var{value})
14872 Byte swap.  Return the result of swapping the upper and lower bytes of
14873 @var{value}.
14875 @item int __builtin_brev (int @var{value})
14876 Bit reversal.  Return the result of reversing the bits in
14877 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14878 and so on.
14880 @item int __builtin_adds (int @var{x}, int @var{y})
14881 Saturating addition.  Return the result of adding @var{x} and @var{y},
14882 storing the value 32767 if the result overflows.
14884 @item int __builtin_subs (int @var{x}, int @var{y})
14885 Saturating subtraction.  Return the result of subtracting @var{y} from
14886 @var{x}, storing the value @minus{}32768 if the result overflows.
14888 @item void __builtin_halt (void)
14889 Halt.  The processor stops execution.  This built-in is useful for
14890 implementing assertions.
14892 @end table
14894 @node PowerPC Built-in Functions
14895 @subsection PowerPC Built-in Functions
14897 The following built-in functions are always available and can be used to
14898 check the PowerPC target platform type:
14900 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14901 This function is a @code{nop} on the PowerPC platform and is included solely
14902 to maintain API compatibility with the x86 builtins.
14903 @end deftypefn
14905 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14906 This function returns a value of @code{1} if the run-time CPU is of type
14907 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14908 detected:
14910 @table @samp
14911 @item power9
14912 IBM POWER9 Server CPU.
14913 @item power8
14914 IBM POWER8 Server CPU.
14915 @item power7
14916 IBM POWER7 Server CPU.
14917 @item power6x
14918 IBM POWER6 Server CPU (RAW mode).
14919 @item power6
14920 IBM POWER6 Server CPU (Architected mode).
14921 @item power5+
14922 IBM POWER5+ Server CPU.
14923 @item power5
14924 IBM POWER5 Server CPU.
14925 @item ppc970
14926 IBM 970 Server CPU (ie, Apple G5).
14927 @item power4
14928 IBM POWER4 Server CPU.
14929 @item ppca2
14930 IBM A2 64-bit Embedded CPU
14931 @item ppc476
14932 IBM PowerPC 476FP 32-bit Embedded CPU.
14933 @item ppc464
14934 IBM PowerPC 464 32-bit Embedded CPU.
14935 @item ppc440
14936 PowerPC 440 32-bit Embedded CPU.
14937 @item ppc405
14938 PowerPC 405 32-bit Embedded CPU.
14939 @item ppc-cell-be
14940 IBM PowerPC Cell Broadband Engine Architecture CPU.
14941 @end table
14943 Here is an example:
14944 @smallexample
14945 if (__builtin_cpu_is ("power8"))
14946   @{
14947      do_power8 (); // POWER8 specific implementation.
14948   @}
14949 else
14950   @{
14951      do_generic (); // Generic implementation.
14952   @}
14953 @end smallexample
14954 @end deftypefn
14956 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14957 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14958 feature @var{feature} and returns @code{0} otherwise. The following features can be
14959 detected:
14961 @table @samp
14962 @item 4xxmac
14963 4xx CPU has a Multiply Accumulator.
14964 @item altivec
14965 CPU has a SIMD/Vector Unit.
14966 @item arch_2_05
14967 CPU supports ISA 2.05 (eg, POWER6)
14968 @item arch_2_06
14969 CPU supports ISA 2.06 (eg, POWER7)
14970 @item arch_2_07
14971 CPU supports ISA 2.07 (eg, POWER8)
14972 @item arch_3_00
14973 CPU supports ISA 3.0 (eg, POWER9)
14974 @item archpmu
14975 CPU supports the set of compatible performance monitoring events.
14976 @item booke
14977 CPU supports the Embedded ISA category.
14978 @item cellbe
14979 CPU has a CELL broadband engine.
14980 @item dfp
14981 CPU has a decimal floating point unit.
14982 @item dscr
14983 CPU supports the data stream control register.
14984 @item ebb
14985 CPU supports event base branching.
14986 @item efpdouble
14987 CPU has a SPE double precision floating point unit.
14988 @item efpsingle
14989 CPU has a SPE single precision floating point unit.
14990 @item fpu
14991 CPU has a floating point unit.
14992 @item htm
14993 CPU has hardware transaction memory instructions.
14994 @item htm-nosc
14995 Kernel aborts hardware transactions when a syscall is made.
14996 @item ic_snoop
14997 CPU supports icache snooping capabilities.
14998 @item ieee128
14999 CPU supports 128-bit IEEE binary floating point instructions.
15000 @item isel
15001 CPU supports the integer select instruction.
15002 @item mmu
15003 CPU has a memory management unit.
15004 @item notb
15005 CPU does not have a timebase (eg, 601 and 403gx).
15006 @item pa6t
15007 CPU supports the PA Semi 6T CORE ISA.
15008 @item power4
15009 CPU supports ISA 2.00 (eg, POWER4)
15010 @item power5
15011 CPU supports ISA 2.02 (eg, POWER5)
15012 @item power5+
15013 CPU supports ISA 2.03 (eg, POWER5+)
15014 @item power6x
15015 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15016 @item ppc32
15017 CPU supports 32-bit mode execution.
15018 @item ppc601
15019 CPU supports the old POWER ISA (eg, 601)
15020 @item ppc64
15021 CPU supports 64-bit mode execution.
15022 @item ppcle
15023 CPU supports a little-endian mode that uses address swizzling.
15024 @item smt
15025 CPU support simultaneous multi-threading.
15026 @item spe
15027 CPU has a signal processing extension unit.
15028 @item tar
15029 CPU supports the target address register.
15030 @item true_le
15031 CPU supports true little-endian mode.
15032 @item ucache
15033 CPU has unified I/D cache.
15034 @item vcrypto
15035 CPU supports the vector cryptography instructions.
15036 @item vsx
15037 CPU supports the vector-scalar extension.
15038 @end table
15040 Here is an example:
15041 @smallexample
15042 if (__builtin_cpu_supports ("fpu"))
15043   @{
15044      asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15045   @}
15046 else
15047   @{
15048      dst = __fadd (src1, src2); // Software FP addition function.
15049   @}
15050 @end smallexample
15051 @end deftypefn
15053 These built-in functions are available for the PowerPC family of
15054 processors:
15055 @smallexample
15056 float __builtin_recipdivf (float, float);
15057 float __builtin_rsqrtf (float);
15058 double __builtin_recipdiv (double, double);
15059 double __builtin_rsqrt (double);
15060 uint64_t __builtin_ppc_get_timebase ();
15061 unsigned long __builtin_ppc_mftb ();
15062 double __builtin_unpack_longdouble (long double, int);
15063 long double __builtin_pack_longdouble (double, double);
15064 @end smallexample
15066 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15067 @code{__builtin_rsqrtf} functions generate multiple instructions to
15068 implement the reciprocal sqrt functionality using reciprocal sqrt
15069 estimate instructions.
15071 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15072 functions generate multiple instructions to implement division using
15073 the reciprocal estimate instructions.
15075 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15076 functions generate instructions to read the Time Base Register.  The
15077 @code{__builtin_ppc_get_timebase} function may generate multiple
15078 instructions and always returns the 64 bits of the Time Base Register.
15079 The @code{__builtin_ppc_mftb} function always generates one instruction and
15080 returns the Time Base Register value as an unsigned long, throwing away
15081 the most significant word on 32-bit environments.
15083 Additional built-in functions are available for the 64-bit PowerPC
15084 family of processors, for efficient use of 128-bit floating point
15085 (@code{__float128}) values.
15087 The following floating-point built-in functions are available with
15088 @code{-mfloat128} and Altivec support.  All of them implement the
15089 function that is part of the name.
15091 @smallexample
15092 __float128 __builtin_fabsq (__float128)
15093 __float128 __builtin_copysignq (__float128, __float128)
15094 @end smallexample
15096 The following built-in functions are available with @code{-mfloat128}
15097 and Altivec support.
15099 @table @code
15100 @item __float128 __builtin_infq (void)
15101 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15102 @findex __builtin_infq
15104 @item __float128 __builtin_huge_valq (void)
15105 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15106 @findex __builtin_huge_valq
15108 @item __float128 __builtin_nanq (void)
15109 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
15110 @findex __builtin_nanq
15112 @item __float128 __builtin_nansq (void)
15113 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
15114 @findex __builtin_nansq
15115 @end table
15117 The following built-in functions are available for the PowerPC family
15118 of processors, starting with ISA 2.05 or later (@option{-mcpu=power6}
15119 or @option{-mcmpb}):
15120 @smallexample
15121 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15122 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15123 @end smallexample
15125 The @code{__builtin_cmpb} function
15126 performs a byte-wise compare on the contents of its two arguments,
15127 returning the result of the byte-wise comparison as the returned
15128 value.  For each byte comparison, the corresponding byte of the return
15129 value holds 0xff if the input bytes are equal and 0 if the input bytes
15130 are not equal.  If either of the arguments to this built-in function
15131 is wider than 32 bits, the function call expands into the form that
15132 expects @code{unsigned long long int} arguments
15133 which is only available on 64-bit targets.
15135 The following built-in functions are available for the PowerPC family
15136 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15137 or @option{-mpopcntd}):
15138 @smallexample
15139 long __builtin_bpermd (long, long);
15140 int __builtin_divwe (int, int);
15141 int __builtin_divweo (int, int);
15142 unsigned int __builtin_divweu (unsigned int, unsigned int);
15143 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15144 long __builtin_divde (long, long);
15145 long __builtin_divdeo (long, long);
15146 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15147 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15148 unsigned int cdtbcd (unsigned int);
15149 unsigned int cbcdtd (unsigned int);
15150 unsigned int addg6s (unsigned int, unsigned int);
15151 @end smallexample
15153 The @code{__builtin_divde}, @code{__builtin_divdeo},
15154 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15155 64-bit environment support ISA 2.06 or later.
15157 The following built-in functions are available for the PowerPC family
15158 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15159 @smallexample
15160 long long __builtin_darn (void);
15161 long long __builtin_darn_raw (void);
15162 int __builtin_darn_32 (void);
15164 unsigned int scalar_extract_exp (double source);
15165 unsigned long long int scalar_extract_sig (double source);
15167 double
15168 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15169 double
15170 scalar_insert_exp (double significand, unsigned long long int exponent);
15172 int scalar_cmp_exp_gt (double arg1, double arg2);
15173 int scalar_cmp_exp_lt (double arg1, double arg2);
15174 int scalar_cmp_exp_eq (double arg1, double arg2);
15175 int scalar_cmp_exp_unordered (double arg1, double arg2);
15177 bool scalar_test_data_class (float source, const int condition);
15178 bool scalar_test_data_class (double source, const int condition);
15180 bool scalar_test_neg (float source);
15181 bool scalar_test_neg (double source);
15183 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15184 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15185 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15187 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15188 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15189 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15190 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15192 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15193 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15194 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15195 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15197 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15198 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15199 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15200 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15202 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15203 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15204 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15205 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15206 @end smallexample
15208 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15209 functions require a
15210 64-bit environment supporting ISA 3.0 or later.
15211 The @code{__builtin_darn} function provides a 64-bit conditioned
15212 random number.  The @code{__builtin_darn_raw} function provides a
15213 64-bit raw random number.  The @code{__builtin_darn_32} function
15214 provides a 32-bit random number.
15216 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
15217 functions require a 64-bit environment supporting ISA 3.0 or later.
15218 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
15219 functions return the significand and the biased exponent value
15220 respectively of their @code{source} arguments.
15221 Within the result returned by @code{scalar_extract_sig},
15222 the @code{0x10000000000000} bit is set if the
15223 function's @code{source} argument is in normalized form.
15224 Otherwise, this bit is set to 0.
15225 Note that the sign of the significand is not represented in the result
15226 returned from the @code{scalar_extract_sig} function.  Use the
15227 @code{scalar_test_neg} function to test the sign of its @code{double}
15228 argument.
15230 The @code{scalar_insert_exp} 
15231 function requires a 64-bit environment supporting ISA 3.0 or later.
15232 The @code{scalar_insert_exp} built-in function returns a double-precision
15233 floating point value that is constructed by assembling the values of its
15234 @code{significand} and @code{exponent} arguments.  The sign of the
15235 result is copied from the most significant bit of the
15236 @code{significand} argument.  The significand and exponent components
15237 of the result are composed of the least significant 11 bits of the
15238 @code{exponent} argument and the least significant 52 bits of the
15239 @code{significand} argument.
15241 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15242 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15243 functions return a non-zero value if @code{arg1} is greater than, less
15244 than, equal to, or not comparable to @code{arg2} respectively.  The
15245 arguments are not comparable if one or the other equals NaN (not a
15246 number). 
15248 The @code{scalar_test_data_class} built-in function returns 1
15249 if any of the condition tests enabled by the value of the
15250 @code{condition} variable are true, and 0 otherwise.  The
15251 @code{condition} argument must be a compile-time constant integer with
15252 value not exceeding 127.  The
15253 @code{condition} argument is encoded as a bitmask with each bit
15254 enabling the testing of a different condition, as characterized by the
15255 following:
15256 @smallexample
15257 0x40    Test for NaN
15258 0x20    Test for +Infinity
15259 0x10    Test for -Infinity
15260 0x08    Test for +Zero
15261 0x04    Test for -Zero
15262 0x02    Test for +Denormal
15263 0x01    Test for -Denormal
15264 @end smallexample
15266 The @code{scalar_test_neg} built-in function returns 1 if its
15267 @code{source} argument holds a negative value, 0 otherwise.
15269 The @code{__builtin_byte_in_set} function requires a
15270 64-bit environment supporting ISA 3.0 or later.  This function returns
15271 a non-zero value if and only if its @code{u} argument exactly equals one of
15272 the eight bytes contained within its 64-bit @code{set} argument.
15274 The @code{__builtin_byte_in_range} and
15275 @code{__builtin_byte_in_either_range} require an environment
15276 supporting ISA 3.0 or later.  For these two functions, the
15277 @code{range} argument is encoded as 4 bytes, organized as
15278 @code{hi_1:lo_1:hi_2:lo_2}.
15279 The @code{__builtin_byte_in_range} function returns a
15280 non-zero value if and only if its @code{u} argument is within the
15281 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15282 The @code{__builtin_byte_in_either_range} function returns non-zero if
15283 and only if its @code{u} argument is within either the range bounded
15284 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15285 between @code{lo_2} and @code{hi_2} inclusive.
15287 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15288 if and only if the number of signficant digits of its @code{value} argument
15289 is less than its @code{comparison} argument.  The
15290 @code{__builtin_dfp_dtstsfi_lt_dd} and
15291 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15292 require that the type of the @code{value} argument be
15293 @code{__Decimal64} and @code{__Decimal128} respectively.
15295 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15296 if and only if the number of signficant digits of its @code{value} argument
15297 is greater than its @code{comparison} argument.  The
15298 @code{__builtin_dfp_dtstsfi_gt_dd} and
15299 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15300 require that the type of the @code{value} argument be
15301 @code{__Decimal64} and @code{__Decimal128} respectively.
15303 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15304 if and only if the number of signficant digits of its @code{value} argument
15305 equals its @code{comparison} argument.  The
15306 @code{__builtin_dfp_dtstsfi_eq_dd} and
15307 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15308 require that the type of the @code{value} argument be
15309 @code{__Decimal64} and @code{__Decimal128} respectively.
15311 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15312 if and only if its @code{value} argument has an undefined number of
15313 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15314 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15315 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15316 require that the type of the @code{value} argument be
15317 @code{__Decimal64} and @code{__Decimal128} respectively.
15319 The following built-in functions are also available for the PowerPC family
15320 of processors, starting with ISA 3.0 or later
15321 (@option{-mcpu=power9}).  These string functions are described
15322 separately in order to group the descriptions closer to the function
15323 prototypes:
15324 @smallexample
15325 int vec_all_nez (vector signed char, vector signed char);
15326 int vec_all_nez (vector unsigned char, vector unsigned char);
15327 int vec_all_nez (vector signed short, vector signed short);
15328 int vec_all_nez (vector unsigned short, vector unsigned short);
15329 int vec_all_nez (vector signed int, vector signed int);
15330 int vec_all_nez (vector unsigned int, vector unsigned int);
15332 int vec_any_eqz (vector signed char, vector signed char);
15333 int vec_any_eqz (vector unsigned char, vector unsigned char);
15334 int vec_any_eqz (vector signed short, vector signed short);
15335 int vec_any_eqz (vector unsigned short, vector unsigned short);
15336 int vec_any_eqz (vector signed int, vector signed int);
15337 int vec_any_eqz (vector unsigned int, vector unsigned int);
15339 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15340 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15341 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15342 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15343 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15344 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15346 signed int vec_cntlz_lsbb (vector signed char);
15347 signed int vec_cntlz_lsbb (vector unsigned char);
15349 signed int vec_cnttz_lsbb (vector signed char);
15350 signed int vec_cnttz_lsbb (vector unsigned char);
15352 vector signed char vec_xl_len (signed char *addr, size_t len);
15353 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
15354 vector signed int vec_xl_len (signed int *addr, size_t len);
15355 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
15356 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
15357 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
15358 vector signed long long vec_xl_len (signed long long *addr, size_t len);
15359 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
15360 vector signed short vec_xl_len (signed short *addr, size_t len);
15361 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
15362 vector double vec_xl_len (double *addr, size_t len);
15363 vector float vec_xl_len (float *addr, size_t len);
15365 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
15366 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
15367 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
15368 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
15369 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
15370 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
15371 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
15372 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
15373 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
15374 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
15375 void vec_xst_len (vector double data, double *addr, size_t len);
15376 void vec_xst_len (vector float data, float *addr, size_t len);
15378 signed char vec_xlx (unsigned int index, vector signed char data);
15379 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
15380 signed short vec_xlx (unsigned int index, vector signed short data);
15381 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
15382 signed int vec_xlx (unsigned int index, vector signed int data);
15383 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
15384 float vec_xlx (unsigned int index, vector float data);
15386 signed char vec_xrx (unsigned int index, vector signed char data);
15387 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
15388 signed short vec_xrx (unsigned int index, vector signed short data);
15389 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
15390 signed int vec_xrx (unsigned int index, vector signed int data);
15391 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
15392 float vec_xrx (unsigned int index, vector float data);
15393 @end smallexample
15395 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
15396 perform pairwise comparisons between the elements at the same
15397 positions within their two vector arguments.
15398 The @code{vec_all_nez} function returns a
15399 non-zero value if and only if all pairwise comparisons are not
15400 equal and no element of either vector argument contains a zero.
15401 The @code{vec_any_eqz} function returns a
15402 non-zero value if and only if at least one pairwise comparison is equal
15403 or if at least one element of either vector argument contains a zero.
15404 The @code{vec_cmpnez} function returns a vector of the same type as
15405 its two arguments, within which each element consists of all ones to
15406 denote that either the corresponding elements of the incoming arguments are
15407 not equal or that at least one of the corresponding elements contains
15408 zero.  Otherwise, the element of the returned vector contains all zeros.
15410 The @code{vec_cntlz_lsbb} function returns the count of the number of
15411 consecutive leading byte elements (starting from position 0 within the
15412 supplied vector argument) for which the least-significant bit
15413 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
15414 the number of consecutive trailing byte elements (starting from
15415 position 15 and counting backwards within the supplied vector
15416 argument) for which the least-significant bit equals zero.
15418 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
15419 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
15420 function loads a variable length vector from memory.  The
15421 @code{vec_xst_len} function stores a variable length vector to memory.
15422 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
15423 @code{addr} argument represents the memory address to or from which
15424 data will be transferred, and the
15425 @code{len} argument represents the number of bytes to be
15426 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
15427 If this expression's value is not a multiple of the vector element's
15428 size, the behavior of this function is undefined.
15429 In the case that the underlying computer is configured to run in
15430 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
15431 the corresponding vector.  In little-endian mode, the data transfer
15432 moves bytes @code{(16 - len)} to @code{15} of the corresponding
15433 vector.  For the load function, any bytes of the result vector that
15434 are not loaded from memory are set to zero.
15435 The value of the @code{addr} argument need not be aligned on a
15436 multiple of the vector's element size.
15438 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
15439 element selected by the @code{index} argument from the vector
15440 represented by the @code{data} argument.  The @code{index} argument
15441 always specifies a byte offset, regardless of the size of the vector
15442 element.  With @code{vec_xlx}, @code{index} is the offset of the first
15443 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
15444 represents the last byte of the element to be extracted, measured
15445 from the right end of the vector.  In other words, the last byte of
15446 the element to be extracted is found at position @code{(15 - index)}.
15447 There is no requirement that @code{index} be a multiple of the vector
15448 element size.  However, if the size of the vector element added to
15449 @code{index} is greater than 15, the content of the returned value is
15450 undefined.
15452 The following built-in functions are available for the PowerPC family
15453 of processors when hardware decimal floating point
15454 (@option{-mhard-dfp}) is available:
15455 @smallexample
15456 long long __builtin_dxex (_Decimal64);
15457 long long __builtin_dxexq (_Decimal128);
15458 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15459 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15460 _Decimal64 __builtin_denbcd (int, _Decimal64);
15461 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15462 _Decimal64 __builtin_diex (long long, _Decimal64);
15463 _Decimal128 _builtin_diexq (long long, _Decimal128);
15464 _Decimal64 __builtin_dscli (_Decimal64, int);
15465 _Decimal128 __builtin_dscliq (_Decimal128, int);
15466 _Decimal64 __builtin_dscri (_Decimal64, int);
15467 _Decimal128 __builtin_dscriq (_Decimal128, int);
15468 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15469 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15470 @end smallexample
15472 The following built-in functions are available for the PowerPC family
15473 of processors when the Vector Scalar (vsx) instruction set is
15474 available:
15475 @smallexample
15476 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15477 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15478                                                 unsigned long long);
15479 @end smallexample
15481 @node PowerPC AltiVec/VSX Built-in Functions
15482 @subsection PowerPC AltiVec Built-in Functions
15484 GCC provides an interface for the PowerPC family of processors to access
15485 the AltiVec operations described in Motorola's AltiVec Programming
15486 Interface Manual.  The interface is made available by including
15487 @code{<altivec.h>} and using @option{-maltivec} and
15488 @option{-mabi=altivec}.  The interface supports the following vector
15489 types.
15491 @smallexample
15492 vector unsigned char
15493 vector signed char
15494 vector bool char
15496 vector unsigned short
15497 vector signed short
15498 vector bool short
15499 vector pixel
15501 vector unsigned int
15502 vector signed int
15503 vector bool int
15504 vector float
15505 @end smallexample
15507 If @option{-mvsx} is used the following additional vector types are
15508 implemented.
15510 @smallexample
15511 vector unsigned long
15512 vector signed long
15513 vector double
15514 @end smallexample
15516 The long types are only implemented for 64-bit code generation, and
15517 the long type is only used in the floating point/integer conversion
15518 instructions.
15520 GCC's implementation of the high-level language interface available from
15521 C and C++ code differs from Motorola's documentation in several ways.
15523 @itemize @bullet
15525 @item
15526 A vector constant is a list of constant expressions within curly braces.
15528 @item
15529 A vector initializer requires no cast if the vector constant is of the
15530 same type as the variable it is initializing.
15532 @item
15533 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15534 vector type is the default signedness of the base type.  The default
15535 varies depending on the operating system, so a portable program should
15536 always specify the signedness.
15538 @item
15539 Compiling with @option{-maltivec} adds keywords @code{__vector},
15540 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15541 @code{bool}.  When compiling ISO C, the context-sensitive substitution
15542 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15543 disabled.  To use them, you must include @code{<altivec.h>} instead.
15545 @item
15546 GCC allows using a @code{typedef} name as the type specifier for a
15547 vector type.
15549 @item
15550 For C, overloaded functions are implemented with macros so the following
15551 does not work:
15553 @smallexample
15554   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15555 @end smallexample
15557 @noindent
15558 Since @code{vec_add} is a macro, the vector constant in the example
15559 is treated as four separate arguments.  Wrap the entire argument in
15560 parentheses for this to work.
15561 @end itemize
15563 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15564 Internally, GCC uses built-in functions to achieve the functionality in
15565 the aforementioned header file, but they are not supported and are
15566 subject to change without notice.
15568 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
15569 which may be found at
15570 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
15571 Appendix A of this document lists the vector API interfaces that must be
15572 provided by compliant compilers.  Programmers should preferentially use
15573 the interfaces described therein.  However, historically GCC has provided
15574 additional interfaces for access to vector instructions.  These are
15575 briefly described below.
15577 The following interfaces are supported for the generic and specific
15578 AltiVec operations and the AltiVec predicates.  In cases where there
15579 is a direct mapping between generic and specific operations, only the
15580 generic names are shown here, although the specific operations can also
15581 be used.
15583 Arguments that are documented as @code{const int} require literal
15584 integral values within the range required for that operation.
15586 @smallexample
15587 vector signed char vec_abs (vector signed char);
15588 vector signed short vec_abs (vector signed short);
15589 vector signed int vec_abs (vector signed int);
15590 vector float vec_abs (vector float);
15592 vector signed char vec_abss (vector signed char);
15593 vector signed short vec_abss (vector signed short);
15594 vector signed int vec_abss (vector signed int);
15596 vector signed char vec_add (vector bool char, vector signed char);
15597 vector signed char vec_add (vector signed char, vector bool char);
15598 vector signed char vec_add (vector signed char, vector signed char);
15599 vector unsigned char vec_add (vector bool char, vector unsigned char);
15600 vector unsigned char vec_add (vector unsigned char, vector bool char);
15601 vector unsigned char vec_add (vector unsigned char,
15602                               vector unsigned char);
15603 vector signed short vec_add (vector bool short, vector signed short);
15604 vector signed short vec_add (vector signed short, vector bool short);
15605 vector signed short vec_add (vector signed short, vector signed short);
15606 vector unsigned short vec_add (vector bool short,
15607                                vector unsigned short);
15608 vector unsigned short vec_add (vector unsigned short,
15609                                vector bool short);
15610 vector unsigned short vec_add (vector unsigned short,
15611                                vector unsigned short);
15612 vector signed int vec_add (vector bool int, vector signed int);
15613 vector signed int vec_add (vector signed int, vector bool int);
15614 vector signed int vec_add (vector signed int, vector signed int);
15615 vector unsigned int vec_add (vector bool int, vector unsigned int);
15616 vector unsigned int vec_add (vector unsigned int, vector bool int);
15617 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15618 vector float vec_add (vector float, vector float);
15620 vector float vec_vaddfp (vector float, vector float);
15622 vector signed int vec_vadduwm (vector bool int, vector signed int);
15623 vector signed int vec_vadduwm (vector signed int, vector bool int);
15624 vector signed int vec_vadduwm (vector signed int, vector signed int);
15625 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15626 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15627 vector unsigned int vec_vadduwm (vector unsigned int,
15628                                  vector unsigned int);
15630 vector signed short vec_vadduhm (vector bool short,
15631                                  vector signed short);
15632 vector signed short vec_vadduhm (vector signed short,
15633                                  vector bool short);
15634 vector signed short vec_vadduhm (vector signed short,
15635                                  vector signed short);
15636 vector unsigned short vec_vadduhm (vector bool short,
15637                                    vector unsigned short);
15638 vector unsigned short vec_vadduhm (vector unsigned short,
15639                                    vector bool short);
15640 vector unsigned short vec_vadduhm (vector unsigned short,
15641                                    vector unsigned short);
15643 vector signed char vec_vaddubm (vector bool char, vector signed char);
15644 vector signed char vec_vaddubm (vector signed char, vector bool char);
15645 vector signed char vec_vaddubm (vector signed char, vector signed char);
15646 vector unsigned char vec_vaddubm (vector bool char,
15647                                   vector unsigned char);
15648 vector unsigned char vec_vaddubm (vector unsigned char,
15649                                   vector bool char);
15650 vector unsigned char vec_vaddubm (vector unsigned char,
15651                                   vector unsigned char);
15653 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15655 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15656 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15657 vector unsigned char vec_adds (vector unsigned char,
15658                                vector unsigned char);
15659 vector signed char vec_adds (vector bool char, vector signed char);
15660 vector signed char vec_adds (vector signed char, vector bool char);
15661 vector signed char vec_adds (vector signed char, vector signed char);
15662 vector unsigned short vec_adds (vector bool short,
15663                                 vector unsigned short);
15664 vector unsigned short vec_adds (vector unsigned short,
15665                                 vector bool short);
15666 vector unsigned short vec_adds (vector unsigned short,
15667                                 vector unsigned short);
15668 vector signed short vec_adds (vector bool short, vector signed short);
15669 vector signed short vec_adds (vector signed short, vector bool short);
15670 vector signed short vec_adds (vector signed short, vector signed short);
15671 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15672 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15673 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15674 vector signed int vec_adds (vector bool int, vector signed int);
15675 vector signed int vec_adds (vector signed int, vector bool int);
15676 vector signed int vec_adds (vector signed int, vector signed int);
15678 vector signed int vec_vaddsws (vector bool int, vector signed int);
15679 vector signed int vec_vaddsws (vector signed int, vector bool int);
15680 vector signed int vec_vaddsws (vector signed int, vector signed int);
15682 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15683 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15684 vector unsigned int vec_vadduws (vector unsigned int,
15685                                  vector unsigned int);
15687 vector signed short vec_vaddshs (vector bool short,
15688                                  vector signed short);
15689 vector signed short vec_vaddshs (vector signed short,
15690                                  vector bool short);
15691 vector signed short vec_vaddshs (vector signed short,
15692                                  vector signed short);
15694 vector unsigned short vec_vadduhs (vector bool short,
15695                                    vector unsigned short);
15696 vector unsigned short vec_vadduhs (vector unsigned short,
15697                                    vector bool short);
15698 vector unsigned short vec_vadduhs (vector unsigned short,
15699                                    vector unsigned short);
15701 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15702 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15703 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15705 vector unsigned char vec_vaddubs (vector bool char,
15706                                   vector unsigned char);
15707 vector unsigned char vec_vaddubs (vector unsigned char,
15708                                   vector bool char);
15709 vector unsigned char vec_vaddubs (vector unsigned char,
15710                                   vector unsigned char);
15712 vector float vec_and (vector float, vector float);
15713 vector float vec_and (vector float, vector bool int);
15714 vector float vec_and (vector bool int, vector float);
15715 vector bool int vec_and (vector bool int, vector bool int);
15716 vector signed int vec_and (vector bool int, vector signed int);
15717 vector signed int vec_and (vector signed int, vector bool int);
15718 vector signed int vec_and (vector signed int, vector signed int);
15719 vector unsigned int vec_and (vector bool int, vector unsigned int);
15720 vector unsigned int vec_and (vector unsigned int, vector bool int);
15721 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15722 vector bool short vec_and (vector bool short, vector bool short);
15723 vector signed short vec_and (vector bool short, vector signed short);
15724 vector signed short vec_and (vector signed short, vector bool short);
15725 vector signed short vec_and (vector signed short, vector signed short);
15726 vector unsigned short vec_and (vector bool short,
15727                                vector unsigned short);
15728 vector unsigned short vec_and (vector unsigned short,
15729                                vector bool short);
15730 vector unsigned short vec_and (vector unsigned short,
15731                                vector unsigned short);
15732 vector signed char vec_and (vector bool char, vector signed char);
15733 vector bool char vec_and (vector bool char, vector bool char);
15734 vector signed char vec_and (vector signed char, vector bool char);
15735 vector signed char vec_and (vector signed char, vector signed char);
15736 vector unsigned char vec_and (vector bool char, vector unsigned char);
15737 vector unsigned char vec_and (vector unsigned char, vector bool char);
15738 vector unsigned char vec_and (vector unsigned char,
15739                               vector unsigned char);
15741 vector float vec_andc (vector float, vector float);
15742 vector float vec_andc (vector float, vector bool int);
15743 vector float vec_andc (vector bool int, vector float);
15744 vector bool int vec_andc (vector bool int, vector bool int);
15745 vector signed int vec_andc (vector bool int, vector signed int);
15746 vector signed int vec_andc (vector signed int, vector bool int);
15747 vector signed int vec_andc (vector signed int, vector signed int);
15748 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15749 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15750 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15751 vector bool short vec_andc (vector bool short, vector bool short);
15752 vector signed short vec_andc (vector bool short, vector signed short);
15753 vector signed short vec_andc (vector signed short, vector bool short);
15754 vector signed short vec_andc (vector signed short, vector signed short);
15755 vector unsigned short vec_andc (vector bool short,
15756                                 vector unsigned short);
15757 vector unsigned short vec_andc (vector unsigned short,
15758                                 vector bool short);
15759 vector unsigned short vec_andc (vector unsigned short,
15760                                 vector unsigned short);
15761 vector signed char vec_andc (vector bool char, vector signed char);
15762 vector bool char vec_andc (vector bool char, vector bool char);
15763 vector signed char vec_andc (vector signed char, vector bool char);
15764 vector signed char vec_andc (vector signed char, vector signed char);
15765 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15766 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15767 vector unsigned char vec_andc (vector unsigned char,
15768                                vector unsigned char);
15770 vector unsigned char vec_avg (vector unsigned char,
15771                               vector unsigned char);
15772 vector signed char vec_avg (vector signed char, vector signed char);
15773 vector unsigned short vec_avg (vector unsigned short,
15774                                vector unsigned short);
15775 vector signed short vec_avg (vector signed short, vector signed short);
15776 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15777 vector signed int vec_avg (vector signed int, vector signed int);
15779 vector signed int vec_vavgsw (vector signed int, vector signed int);
15781 vector unsigned int vec_vavguw (vector unsigned int,
15782                                 vector unsigned int);
15784 vector signed short vec_vavgsh (vector signed short,
15785                                 vector signed short);
15787 vector unsigned short vec_vavguh (vector unsigned short,
15788                                   vector unsigned short);
15790 vector signed char vec_vavgsb (vector signed char, vector signed char);
15792 vector unsigned char vec_vavgub (vector unsigned char,
15793                                  vector unsigned char);
15795 vector float vec_copysign (vector float);
15797 vector float vec_ceil (vector float);
15799 vector signed int vec_cmpb (vector float, vector float);
15801 vector bool char vec_cmpeq (vector bool char, vector bool char);
15802 vector bool short vec_cmpeq (vector bool short, vector bool short);
15803 vector bool int vec_cmpeq (vector bool int, vector bool int);
15804 vector bool char vec_cmpeq (vector signed char, vector signed char);
15805 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15806 vector bool short vec_cmpeq (vector signed short, vector signed short);
15807 vector bool short vec_cmpeq (vector unsigned short,
15808                              vector unsigned short);
15809 vector bool int vec_cmpeq (vector signed int, vector signed int);
15810 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15811 vector bool int vec_cmpeq (vector float, vector float);
15813 vector bool int vec_vcmpeqfp (vector float, vector float);
15815 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15816 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15818 vector bool short vec_vcmpequh (vector signed short,
15819                                 vector signed short);
15820 vector bool short vec_vcmpequh (vector unsigned short,
15821                                 vector unsigned short);
15823 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15824 vector bool char vec_vcmpequb (vector unsigned char,
15825                                vector unsigned char);
15827 vector bool int vec_cmpge (vector float, vector float);
15829 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15830 vector bool char vec_cmpgt (vector signed char, vector signed char);
15831 vector bool short vec_cmpgt (vector unsigned short,
15832                              vector unsigned short);
15833 vector bool short vec_cmpgt (vector signed short, vector signed short);
15834 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15835 vector bool int vec_cmpgt (vector signed int, vector signed int);
15836 vector bool int vec_cmpgt (vector float, vector float);
15838 vector bool int vec_vcmpgtfp (vector float, vector float);
15840 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15842 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15844 vector bool short vec_vcmpgtsh (vector signed short,
15845                                 vector signed short);
15847 vector bool short vec_vcmpgtuh (vector unsigned short,
15848                                 vector unsigned short);
15850 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15852 vector bool char vec_vcmpgtub (vector unsigned char,
15853                                vector unsigned char);
15855 vector bool int vec_cmple (vector float, vector float);
15857 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15858 vector bool char vec_cmplt (vector signed char, vector signed char);
15859 vector bool short vec_cmplt (vector unsigned short,
15860                              vector unsigned short);
15861 vector bool short vec_cmplt (vector signed short, vector signed short);
15862 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15863 vector bool int vec_cmplt (vector signed int, vector signed int);
15864 vector bool int vec_cmplt (vector float, vector float);
15866 vector float vec_cpsgn (vector float, vector float);
15868 vector float vec_ctf (vector unsigned int, const int);
15869 vector float vec_ctf (vector signed int, const int);
15870 vector double vec_ctf (vector unsigned long, const int);
15871 vector double vec_ctf (vector signed long, const int);
15873 vector float vec_vcfsx (vector signed int, const int);
15875 vector float vec_vcfux (vector unsigned int, const int);
15877 vector signed int vec_cts (vector float, const int);
15878 vector signed long vec_cts (vector double, const int);
15880 vector unsigned int vec_ctu (vector float, const int);
15881 vector unsigned long vec_ctu (vector double, const int);
15883 vector double vec_doublee (vector float);
15884 vector double vec_doublee (vector signed int);
15885 vector double vec_doublee (vector unsigned int);
15887 vector double vec_doubleo (vector float);
15888 vector double vec_doubleo (vector signed int);
15889 vector double vec_doubleo (vector unsigned int);
15891 vector double vec_doubleh (vector float);
15892 vector double vec_doubleh (vector signed int);
15893 vector double vec_doubleh (vector unsigned int);
15895 vector double vec_doublel (vector float);
15896 vector double vec_doublel (vector signed int);
15897 vector double vec_doublel (vector unsigned int);
15899 void vec_dss (const int);
15901 void vec_dssall (void);
15903 void vec_dst (const vector unsigned char *, int, const int);
15904 void vec_dst (const vector signed char *, int, const int);
15905 void vec_dst (const vector bool char *, int, const int);
15906 void vec_dst (const vector unsigned short *, int, const int);
15907 void vec_dst (const vector signed short *, int, const int);
15908 void vec_dst (const vector bool short *, int, const int);
15909 void vec_dst (const vector pixel *, int, const int);
15910 void vec_dst (const vector unsigned int *, int, const int);
15911 void vec_dst (const vector signed int *, int, const int);
15912 void vec_dst (const vector bool int *, int, const int);
15913 void vec_dst (const vector float *, int, const int);
15914 void vec_dst (const unsigned char *, int, const int);
15915 void vec_dst (const signed char *, int, const int);
15916 void vec_dst (const unsigned short *, int, const int);
15917 void vec_dst (const short *, int, const int);
15918 void vec_dst (const unsigned int *, int, const int);
15919 void vec_dst (const int *, int, const int);
15920 void vec_dst (const unsigned long *, int, const int);
15921 void vec_dst (const long *, int, const int);
15922 void vec_dst (const float *, int, const int);
15924 void vec_dstst (const vector unsigned char *, int, const int);
15925 void vec_dstst (const vector signed char *, int, const int);
15926 void vec_dstst (const vector bool char *, int, const int);
15927 void vec_dstst (const vector unsigned short *, int, const int);
15928 void vec_dstst (const vector signed short *, int, const int);
15929 void vec_dstst (const vector bool short *, int, const int);
15930 void vec_dstst (const vector pixel *, int, const int);
15931 void vec_dstst (const vector unsigned int *, int, const int);
15932 void vec_dstst (const vector signed int *, int, const int);
15933 void vec_dstst (const vector bool int *, int, const int);
15934 void vec_dstst (const vector float *, int, const int);
15935 void vec_dstst (const unsigned char *, int, const int);
15936 void vec_dstst (const signed char *, int, const int);
15937 void vec_dstst (const unsigned short *, int, const int);
15938 void vec_dstst (const short *, int, const int);
15939 void vec_dstst (const unsigned int *, int, const int);
15940 void vec_dstst (const int *, int, const int);
15941 void vec_dstst (const unsigned long *, int, const int);
15942 void vec_dstst (const long *, int, const int);
15943 void vec_dstst (const float *, int, const int);
15945 void vec_dststt (const vector unsigned char *, int, const int);
15946 void vec_dststt (const vector signed char *, int, const int);
15947 void vec_dststt (const vector bool char *, int, const int);
15948 void vec_dststt (const vector unsigned short *, int, const int);
15949 void vec_dststt (const vector signed short *, int, const int);
15950 void vec_dststt (const vector bool short *, int, const int);
15951 void vec_dststt (const vector pixel *, int, const int);
15952 void vec_dststt (const vector unsigned int *, int, const int);
15953 void vec_dststt (const vector signed int *, int, const int);
15954 void vec_dststt (const vector bool int *, int, const int);
15955 void vec_dststt (const vector float *, int, const int);
15956 void vec_dststt (const unsigned char *, int, const int);
15957 void vec_dststt (const signed char *, int, const int);
15958 void vec_dststt (const unsigned short *, int, const int);
15959 void vec_dststt (const short *, int, const int);
15960 void vec_dststt (const unsigned int *, int, const int);
15961 void vec_dststt (const int *, int, const int);
15962 void vec_dststt (const unsigned long *, int, const int);
15963 void vec_dststt (const long *, int, const int);
15964 void vec_dststt (const float *, int, const int);
15966 void vec_dstt (const vector unsigned char *, int, const int);
15967 void vec_dstt (const vector signed char *, int, const int);
15968 void vec_dstt (const vector bool char *, int, const int);
15969 void vec_dstt (const vector unsigned short *, int, const int);
15970 void vec_dstt (const vector signed short *, int, const int);
15971 void vec_dstt (const vector bool short *, int, const int);
15972 void vec_dstt (const vector pixel *, int, const int);
15973 void vec_dstt (const vector unsigned int *, int, const int);
15974 void vec_dstt (const vector signed int *, int, const int);
15975 void vec_dstt (const vector bool int *, int, const int);
15976 void vec_dstt (const vector float *, int, const int);
15977 void vec_dstt (const unsigned char *, int, const int);
15978 void vec_dstt (const signed char *, int, const int);
15979 void vec_dstt (const unsigned short *, int, const int);
15980 void vec_dstt (const short *, int, const int);
15981 void vec_dstt (const unsigned int *, int, const int);
15982 void vec_dstt (const int *, int, const int);
15983 void vec_dstt (const unsigned long *, int, const int);
15984 void vec_dstt (const long *, int, const int);
15985 void vec_dstt (const float *, int, const int);
15987 vector float vec_expte (vector float);
15989 vector float vec_floor (vector float);
15991 vector float vec_ld (int, const vector float *);
15992 vector float vec_ld (int, const float *);
15993 vector bool int vec_ld (int, const vector bool int *);
15994 vector signed int vec_ld (int, const vector signed int *);
15995 vector signed int vec_ld (int, const int *);
15996 vector signed int vec_ld (int, const long *);
15997 vector unsigned int vec_ld (int, const vector unsigned int *);
15998 vector unsigned int vec_ld (int, const unsigned int *);
15999 vector unsigned int vec_ld (int, const unsigned long *);
16000 vector bool short vec_ld (int, const vector bool short *);
16001 vector pixel vec_ld (int, const vector pixel *);
16002 vector signed short vec_ld (int, const vector signed short *);
16003 vector signed short vec_ld (int, const short *);
16004 vector unsigned short vec_ld (int, const vector unsigned short *);
16005 vector unsigned short vec_ld (int, const unsigned short *);
16006 vector bool char vec_ld (int, const vector bool char *);
16007 vector signed char vec_ld (int, const vector signed char *);
16008 vector signed char vec_ld (int, const signed char *);
16009 vector unsigned char vec_ld (int, const vector unsigned char *);
16010 vector unsigned char vec_ld (int, const unsigned char *);
16012 vector signed char vec_lde (int, const signed char *);
16013 vector unsigned char vec_lde (int, const unsigned char *);
16014 vector signed short vec_lde (int, const short *);
16015 vector unsigned short vec_lde (int, const unsigned short *);
16016 vector float vec_lde (int, const float *);
16017 vector signed int vec_lde (int, const int *);
16018 vector unsigned int vec_lde (int, const unsigned int *);
16019 vector signed int vec_lde (int, const long *);
16020 vector unsigned int vec_lde (int, const unsigned long *);
16022 vector float vec_lvewx (int, float *);
16023 vector signed int vec_lvewx (int, int *);
16024 vector unsigned int vec_lvewx (int, unsigned int *);
16025 vector signed int vec_lvewx (int, long *);
16026 vector unsigned int vec_lvewx (int, unsigned long *);
16028 vector signed short vec_lvehx (int, short *);
16029 vector unsigned short vec_lvehx (int, unsigned short *);
16031 vector signed char vec_lvebx (int, char *);
16032 vector unsigned char vec_lvebx (int, unsigned char *);
16034 vector float vec_ldl (int, const vector float *);
16035 vector float vec_ldl (int, const float *);
16036 vector bool int vec_ldl (int, const vector bool int *);
16037 vector signed int vec_ldl (int, const vector signed int *);
16038 vector signed int vec_ldl (int, const int *);
16039 vector signed int vec_ldl (int, const long *);
16040 vector unsigned int vec_ldl (int, const vector unsigned int *);
16041 vector unsigned int vec_ldl (int, const unsigned int *);
16042 vector unsigned int vec_ldl (int, const unsigned long *);
16043 vector bool short vec_ldl (int, const vector bool short *);
16044 vector pixel vec_ldl (int, const vector pixel *);
16045 vector signed short vec_ldl (int, const vector signed short *);
16046 vector signed short vec_ldl (int, const short *);
16047 vector unsigned short vec_ldl (int, const vector unsigned short *);
16048 vector unsigned short vec_ldl (int, const unsigned short *);
16049 vector bool char vec_ldl (int, const vector bool char *);
16050 vector signed char vec_ldl (int, const vector signed char *);
16051 vector signed char vec_ldl (int, const signed char *);
16052 vector unsigned char vec_ldl (int, const vector unsigned char *);
16053 vector unsigned char vec_ldl (int, const unsigned char *);
16055 vector float vec_loge (vector float);
16057 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16058 vector unsigned char vec_lvsl (int, const volatile signed char *);
16059 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16060 vector unsigned char vec_lvsl (int, const volatile short *);
16061 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16062 vector unsigned char vec_lvsl (int, const volatile int *);
16063 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16064 vector unsigned char vec_lvsl (int, const volatile long *);
16065 vector unsigned char vec_lvsl (int, const volatile float *);
16067 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16068 vector unsigned char vec_lvsr (int, const volatile signed char *);
16069 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16070 vector unsigned char vec_lvsr (int, const volatile short *);
16071 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16072 vector unsigned char vec_lvsr (int, const volatile int *);
16073 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16074 vector unsigned char vec_lvsr (int, const volatile long *);
16075 vector unsigned char vec_lvsr (int, const volatile float *);
16077 vector float vec_madd (vector float, vector float, vector float);
16079 vector signed short vec_madds (vector signed short,
16080                                vector signed short,
16081                                vector signed short);
16083 vector unsigned char vec_max (vector bool char, vector unsigned char);
16084 vector unsigned char vec_max (vector unsigned char, vector bool char);
16085 vector unsigned char vec_max (vector unsigned char,
16086                               vector unsigned char);
16087 vector signed char vec_max (vector bool char, vector signed char);
16088 vector signed char vec_max (vector signed char, vector bool char);
16089 vector signed char vec_max (vector signed char, vector signed char);
16090 vector unsigned short vec_max (vector bool short,
16091                                vector unsigned short);
16092 vector unsigned short vec_max (vector unsigned short,
16093                                vector bool short);
16094 vector unsigned short vec_max (vector unsigned short,
16095                                vector unsigned short);
16096 vector signed short vec_max (vector bool short, vector signed short);
16097 vector signed short vec_max (vector signed short, vector bool short);
16098 vector signed short vec_max (vector signed short, vector signed short);
16099 vector unsigned int vec_max (vector bool int, vector unsigned int);
16100 vector unsigned int vec_max (vector unsigned int, vector bool int);
16101 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16102 vector signed int vec_max (vector bool int, vector signed int);
16103 vector signed int vec_max (vector signed int, vector bool int);
16104 vector signed int vec_max (vector signed int, vector signed int);
16105 vector float vec_max (vector float, vector float);
16107 vector float vec_vmaxfp (vector float, vector float);
16109 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16110 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16111 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16113 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16114 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16115 vector unsigned int vec_vmaxuw (vector unsigned int,
16116                                 vector unsigned int);
16118 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16119 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16120 vector signed short vec_vmaxsh (vector signed short,
16121                                 vector signed short);
16123 vector unsigned short vec_vmaxuh (vector bool short,
16124                                   vector unsigned short);
16125 vector unsigned short vec_vmaxuh (vector unsigned short,
16126                                   vector bool short);
16127 vector unsigned short vec_vmaxuh (vector unsigned short,
16128                                   vector unsigned short);
16130 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16131 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16132 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16134 vector unsigned char vec_vmaxub (vector bool char,
16135                                  vector unsigned char);
16136 vector unsigned char vec_vmaxub (vector unsigned char,
16137                                  vector bool char);
16138 vector unsigned char vec_vmaxub (vector unsigned char,
16139                                  vector unsigned char);
16141 vector bool char vec_mergeh (vector bool char, vector bool char);
16142 vector signed char vec_mergeh (vector signed char, vector signed char);
16143 vector unsigned char vec_mergeh (vector unsigned char,
16144                                  vector unsigned char);
16145 vector bool short vec_mergeh (vector bool short, vector bool short);
16146 vector pixel vec_mergeh (vector pixel, vector pixel);
16147 vector signed short vec_mergeh (vector signed short,
16148                                 vector signed short);
16149 vector unsigned short vec_mergeh (vector unsigned short,
16150                                   vector unsigned short);
16151 vector float vec_mergeh (vector float, vector float);
16152 vector bool int vec_mergeh (vector bool int, vector bool int);
16153 vector signed int vec_mergeh (vector signed int, vector signed int);
16154 vector unsigned int vec_mergeh (vector unsigned int,
16155                                 vector unsigned int);
16157 vector float vec_vmrghw (vector float, vector float);
16158 vector bool int vec_vmrghw (vector bool int, vector bool int);
16159 vector signed int vec_vmrghw (vector signed int, vector signed int);
16160 vector unsigned int vec_vmrghw (vector unsigned int,
16161                                 vector unsigned int);
16163 vector bool short vec_vmrghh (vector bool short, vector bool short);
16164 vector signed short vec_vmrghh (vector signed short,
16165                                 vector signed short);
16166 vector unsigned short vec_vmrghh (vector unsigned short,
16167                                   vector unsigned short);
16168 vector pixel vec_vmrghh (vector pixel, vector pixel);
16170 vector bool char vec_vmrghb (vector bool char, vector bool char);
16171 vector signed char vec_vmrghb (vector signed char, vector signed char);
16172 vector unsigned char vec_vmrghb (vector unsigned char,
16173                                  vector unsigned char);
16175 vector bool char vec_mergel (vector bool char, vector bool char);
16176 vector signed char vec_mergel (vector signed char, vector signed char);
16177 vector unsigned char vec_mergel (vector unsigned char,
16178                                  vector unsigned char);
16179 vector bool short vec_mergel (vector bool short, vector bool short);
16180 vector pixel vec_mergel (vector pixel, vector pixel);
16181 vector signed short vec_mergel (vector signed short,
16182                                 vector signed short);
16183 vector unsigned short vec_mergel (vector unsigned short,
16184                                   vector unsigned short);
16185 vector float vec_mergel (vector float, vector float);
16186 vector bool int vec_mergel (vector bool int, vector bool int);
16187 vector signed int vec_mergel (vector signed int, vector signed int);
16188 vector unsigned int vec_mergel (vector unsigned int,
16189                                 vector unsigned int);
16191 vector float vec_vmrglw (vector float, vector float);
16192 vector signed int vec_vmrglw (vector signed int, vector signed int);
16193 vector unsigned int vec_vmrglw (vector unsigned int,
16194                                 vector unsigned int);
16195 vector bool int vec_vmrglw (vector bool int, vector bool int);
16197 vector bool short vec_vmrglh (vector bool short, vector bool short);
16198 vector signed short vec_vmrglh (vector signed short,
16199                                 vector signed short);
16200 vector unsigned short vec_vmrglh (vector unsigned short,
16201                                   vector unsigned short);
16202 vector pixel vec_vmrglh (vector pixel, vector pixel);
16204 vector bool char vec_vmrglb (vector bool char, vector bool char);
16205 vector signed char vec_vmrglb (vector signed char, vector signed char);
16206 vector unsigned char vec_vmrglb (vector unsigned char,
16207                                  vector unsigned char);
16209 vector unsigned short vec_mfvscr (void);
16211 vector unsigned char vec_min (vector bool char, vector unsigned char);
16212 vector unsigned char vec_min (vector unsigned char, vector bool char);
16213 vector unsigned char vec_min (vector unsigned char,
16214                               vector unsigned char);
16215 vector signed char vec_min (vector bool char, vector signed char);
16216 vector signed char vec_min (vector signed char, vector bool char);
16217 vector signed char vec_min (vector signed char, vector signed char);
16218 vector unsigned short vec_min (vector bool short,
16219                                vector unsigned short);
16220 vector unsigned short vec_min (vector unsigned short,
16221                                vector bool short);
16222 vector unsigned short vec_min (vector unsigned short,
16223                                vector unsigned short);
16224 vector signed short vec_min (vector bool short, vector signed short);
16225 vector signed short vec_min (vector signed short, vector bool short);
16226 vector signed short vec_min (vector signed short, vector signed short);
16227 vector unsigned int vec_min (vector bool int, vector unsigned int);
16228 vector unsigned int vec_min (vector unsigned int, vector bool int);
16229 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16230 vector signed int vec_min (vector bool int, vector signed int);
16231 vector signed int vec_min (vector signed int, vector bool int);
16232 vector signed int vec_min (vector signed int, vector signed int);
16233 vector float vec_min (vector float, vector float);
16235 vector float vec_vminfp (vector float, vector float);
16237 vector signed int vec_vminsw (vector bool int, vector signed int);
16238 vector signed int vec_vminsw (vector signed int, vector bool int);
16239 vector signed int vec_vminsw (vector signed int, vector signed int);
16241 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16242 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16243 vector unsigned int vec_vminuw (vector unsigned int,
16244                                 vector unsigned int);
16246 vector signed short vec_vminsh (vector bool short, vector signed short);
16247 vector signed short vec_vminsh (vector signed short, vector bool short);
16248 vector signed short vec_vminsh (vector signed short,
16249                                 vector signed short);
16251 vector unsigned short vec_vminuh (vector bool short,
16252                                   vector unsigned short);
16253 vector unsigned short vec_vminuh (vector unsigned short,
16254                                   vector bool short);
16255 vector unsigned short vec_vminuh (vector unsigned short,
16256                                   vector unsigned short);
16258 vector signed char vec_vminsb (vector bool char, vector signed char);
16259 vector signed char vec_vminsb (vector signed char, vector bool char);
16260 vector signed char vec_vminsb (vector signed char, vector signed char);
16262 vector unsigned char vec_vminub (vector bool char,
16263                                  vector unsigned char);
16264 vector unsigned char vec_vminub (vector unsigned char,
16265                                  vector bool char);
16266 vector unsigned char vec_vminub (vector unsigned char,
16267                                  vector unsigned char);
16269 vector signed short vec_mladd (vector signed short,
16270                                vector signed short,
16271                                vector signed short);
16272 vector signed short vec_mladd (vector signed short,
16273                                vector unsigned short,
16274                                vector unsigned short);
16275 vector signed short vec_mladd (vector unsigned short,
16276                                vector signed short,
16277                                vector signed short);
16278 vector unsigned short vec_mladd (vector unsigned short,
16279                                  vector unsigned short,
16280                                  vector unsigned short);
16282 vector signed short vec_mradds (vector signed short,
16283                                 vector signed short,
16284                                 vector signed short);
16286 vector unsigned int vec_msum (vector unsigned char,
16287                               vector unsigned char,
16288                               vector unsigned int);
16289 vector signed int vec_msum (vector signed char,
16290                             vector unsigned char,
16291                             vector signed int);
16292 vector unsigned int vec_msum (vector unsigned short,
16293                               vector unsigned short,
16294                               vector unsigned int);
16295 vector signed int vec_msum (vector signed short,
16296                             vector signed short,
16297                             vector signed int);
16299 vector signed int vec_vmsumshm (vector signed short,
16300                                 vector signed short,
16301                                 vector signed int);
16303 vector unsigned int vec_vmsumuhm (vector unsigned short,
16304                                   vector unsigned short,
16305                                   vector unsigned int);
16307 vector signed int vec_vmsummbm (vector signed char,
16308                                 vector unsigned char,
16309                                 vector signed int);
16311 vector unsigned int vec_vmsumubm (vector unsigned char,
16312                                   vector unsigned char,
16313                                   vector unsigned int);
16315 vector unsigned int vec_msums (vector unsigned short,
16316                                vector unsigned short,
16317                                vector unsigned int);
16318 vector signed int vec_msums (vector signed short,
16319                              vector signed short,
16320                              vector signed int);
16322 vector signed int vec_vmsumshs (vector signed short,
16323                                 vector signed short,
16324                                 vector signed int);
16326 vector unsigned int vec_vmsumuhs (vector unsigned short,
16327                                   vector unsigned short,
16328                                   vector unsigned int);
16330 void vec_mtvscr (vector signed int);
16331 void vec_mtvscr (vector unsigned int);
16332 void vec_mtvscr (vector bool int);
16333 void vec_mtvscr (vector signed short);
16334 void vec_mtvscr (vector unsigned short);
16335 void vec_mtvscr (vector bool short);
16336 void vec_mtvscr (vector pixel);
16337 void vec_mtvscr (vector signed char);
16338 void vec_mtvscr (vector unsigned char);
16339 void vec_mtvscr (vector bool char);
16341 vector unsigned short vec_mule (vector unsigned char,
16342                                 vector unsigned char);
16343 vector signed short vec_mule (vector signed char,
16344                               vector signed char);
16345 vector unsigned int vec_mule (vector unsigned short,
16346                               vector unsigned short);
16347 vector signed int vec_mule (vector signed short, vector signed short);
16348 vector unsigned long long vec_mule (vector unsigned int,
16349                                     vector unsigned int);
16350 vector signed long long vec_mule (vector signed int,
16351                                   vector signed int);
16353 vector signed int vec_vmulesh (vector signed short,
16354                                vector signed short);
16356 vector unsigned int vec_vmuleuh (vector unsigned short,
16357                                  vector unsigned short);
16359 vector signed short vec_vmulesb (vector signed char,
16360                                  vector signed char);
16362 vector unsigned short vec_vmuleub (vector unsigned char,
16363                                   vector unsigned char);
16365 vector unsigned short vec_mulo (vector unsigned char,
16366                                 vector unsigned char);
16367 vector signed short vec_mulo (vector signed char, vector signed char);
16368 vector unsigned int vec_mulo (vector unsigned short,
16369                               vector unsigned short);
16370 vector signed int vec_mulo (vector signed short, vector signed short);
16371 vector unsigned long long vec_mulo (vector unsigned int,
16372                                     vector unsigned int);
16373 vector signed long long vec_mulo (vector signed int,
16374                                   vector signed int);
16376 vector signed int vec_vmulosh (vector signed short,
16377                                vector signed short);
16379 vector unsigned int vec_vmulouh (vector unsigned short,
16380                                  vector unsigned short);
16382 vector signed short vec_vmulosb (vector signed char,
16383                                  vector signed char);
16385 vector unsigned short vec_vmuloub (vector unsigned char,
16386                                    vector unsigned char);
16388 vector float vec_nmsub (vector float, vector float, vector float);
16390 vector signed char vec_nabs (vector signed char);
16391 vector signed short vec_nabs (vector signed short);
16392 vector signed int vec_nabs (vector signed int);
16393 vector float vec_nabs (vector float);
16394 vector double vec_nabs (vector double);
16396 vector signed char vec_neg (vector signed char);
16397 vector signed short vec_neg (vector signed short);
16398 vector signed int vec_neg (vector signed int);
16399 vector signed long long vec_neg (vector signed long long);
16400 vector float  char vec_neg (vector float);
16401 vector double vec_neg (vector double);
16403 vector float vec_nor (vector float, vector float);
16404 vector signed int vec_nor (vector signed int, vector signed int);
16405 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16406 vector bool int vec_nor (vector bool int, vector bool int);
16407 vector signed short vec_nor (vector signed short, vector signed short);
16408 vector unsigned short vec_nor (vector unsigned short,
16409                                vector unsigned short);
16410 vector bool short vec_nor (vector bool short, vector bool short);
16411 vector signed char vec_nor (vector signed char, vector signed char);
16412 vector unsigned char vec_nor (vector unsigned char,
16413                               vector unsigned char);
16414 vector bool char vec_nor (vector bool char, vector bool char);
16416 vector float vec_or (vector float, vector float);
16417 vector float vec_or (vector float, vector bool int);
16418 vector float vec_or (vector bool int, vector float);
16419 vector bool int vec_or (vector bool int, vector bool int);
16420 vector signed int vec_or (vector bool int, vector signed int);
16421 vector signed int vec_or (vector signed int, vector bool int);
16422 vector signed int vec_or (vector signed int, vector signed int);
16423 vector unsigned int vec_or (vector bool int, vector unsigned int);
16424 vector unsigned int vec_or (vector unsigned int, vector bool int);
16425 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16426 vector bool short vec_or (vector bool short, vector bool short);
16427 vector signed short vec_or (vector bool short, vector signed short);
16428 vector signed short vec_or (vector signed short, vector bool short);
16429 vector signed short vec_or (vector signed short, vector signed short);
16430 vector unsigned short vec_or (vector bool short, vector unsigned short);
16431 vector unsigned short vec_or (vector unsigned short, vector bool short);
16432 vector unsigned short vec_or (vector unsigned short,
16433                               vector unsigned short);
16434 vector signed char vec_or (vector bool char, vector signed char);
16435 vector bool char vec_or (vector bool char, vector bool char);
16436 vector signed char vec_or (vector signed char, vector bool char);
16437 vector signed char vec_or (vector signed char, vector signed char);
16438 vector unsigned char vec_or (vector bool char, vector unsigned char);
16439 vector unsigned char vec_or (vector unsigned char, vector bool char);
16440 vector unsigned char vec_or (vector unsigned char,
16441                              vector unsigned char);
16443 vector signed char vec_pack (vector signed short, vector signed short);
16444 vector unsigned char vec_pack (vector unsigned short,
16445                                vector unsigned short);
16446 vector bool char vec_pack (vector bool short, vector bool short);
16447 vector signed short vec_pack (vector signed int, vector signed int);
16448 vector unsigned short vec_pack (vector unsigned int,
16449                                 vector unsigned int);
16450 vector bool short vec_pack (vector bool int, vector bool int);
16452 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16453 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16454 vector unsigned short vec_vpkuwum (vector unsigned int,
16455                                    vector unsigned int);
16457 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16458 vector signed char vec_vpkuhum (vector signed short,
16459                                 vector signed short);
16460 vector unsigned char vec_vpkuhum (vector unsigned short,
16461                                   vector unsigned short);
16463 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16465 vector unsigned char vec_packs (vector unsigned short,
16466                                 vector unsigned short);
16467 vector signed char vec_packs (vector signed short, vector signed short);
16468 vector unsigned short vec_packs (vector unsigned int,
16469                                  vector unsigned int);
16470 vector signed short vec_packs (vector signed int, vector signed int);
16472 vector signed short vec_vpkswss (vector signed int, vector signed int);
16474 vector unsigned short vec_vpkuwus (vector unsigned int,
16475                                    vector unsigned int);
16477 vector signed char vec_vpkshss (vector signed short,
16478                                 vector signed short);
16480 vector unsigned char vec_vpkuhus (vector unsigned short,
16481                                   vector unsigned short);
16483 vector unsigned char vec_packsu (vector unsigned short,
16484                                  vector unsigned short);
16485 vector unsigned char vec_packsu (vector signed short,
16486                                  vector signed short);
16487 vector unsigned short vec_packsu (vector unsigned int,
16488                                   vector unsigned int);
16489 vector unsigned short vec_packsu (vector signed int, vector signed int);
16491 vector unsigned short vec_vpkswus (vector signed int,
16492                                    vector signed int);
16494 vector unsigned char vec_vpkshus (vector signed short,
16495                                   vector signed short);
16497 vector float vec_perm (vector float,
16498                        vector float,
16499                        vector unsigned char);
16500 vector signed int vec_perm (vector signed int,
16501                             vector signed int,
16502                             vector unsigned char);
16503 vector unsigned int vec_perm (vector unsigned int,
16504                               vector unsigned int,
16505                               vector unsigned char);
16506 vector bool int vec_perm (vector bool int,
16507                           vector bool int,
16508                           vector unsigned char);
16509 vector signed short vec_perm (vector signed short,
16510                               vector signed short,
16511                               vector unsigned char);
16512 vector unsigned short vec_perm (vector unsigned short,
16513                                 vector unsigned short,
16514                                 vector unsigned char);
16515 vector bool short vec_perm (vector bool short,
16516                             vector bool short,
16517                             vector unsigned char);
16518 vector pixel vec_perm (vector pixel,
16519                        vector pixel,
16520                        vector unsigned char);
16521 vector signed char vec_perm (vector signed char,
16522                              vector signed char,
16523                              vector unsigned char);
16524 vector unsigned char vec_perm (vector unsigned char,
16525                                vector unsigned char,
16526                                vector unsigned char);
16527 vector bool char vec_perm (vector bool char,
16528                            vector bool char,
16529                            vector unsigned char);
16531 vector float vec_re (vector float);
16533 vector signed char vec_rl (vector signed char,
16534                            vector unsigned char);
16535 vector unsigned char vec_rl (vector unsigned char,
16536                              vector unsigned char);
16537 vector signed short vec_rl (vector signed short, vector unsigned short);
16538 vector unsigned short vec_rl (vector unsigned short,
16539                               vector unsigned short);
16540 vector signed int vec_rl (vector signed int, vector unsigned int);
16541 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16543 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16544 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16546 vector signed short vec_vrlh (vector signed short,
16547                               vector unsigned short);
16548 vector unsigned short vec_vrlh (vector unsigned short,
16549                                 vector unsigned short);
16551 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16552 vector unsigned char vec_vrlb (vector unsigned char,
16553                                vector unsigned char);
16555 vector float vec_round (vector float);
16557 vector float vec_recip (vector float, vector float);
16559 vector float vec_rsqrt (vector float);
16561 vector float vec_rsqrte (vector float);
16563 vector float vec_sel (vector float, vector float, vector bool int);
16564 vector float vec_sel (vector float, vector float, vector unsigned int);
16565 vector signed int vec_sel (vector signed int,
16566                            vector signed int,
16567                            vector bool int);
16568 vector signed int vec_sel (vector signed int,
16569                            vector signed int,
16570                            vector unsigned int);
16571 vector unsigned int vec_sel (vector unsigned int,
16572                              vector unsigned int,
16573                              vector bool int);
16574 vector unsigned int vec_sel (vector unsigned int,
16575                              vector unsigned int,
16576                              vector unsigned int);
16577 vector bool int vec_sel (vector bool int,
16578                          vector bool int,
16579                          vector bool int);
16580 vector bool int vec_sel (vector bool int,
16581                          vector bool int,
16582                          vector unsigned int);
16583 vector signed short vec_sel (vector signed short,
16584                              vector signed short,
16585                              vector bool short);
16586 vector signed short vec_sel (vector signed short,
16587                              vector signed short,
16588                              vector unsigned short);
16589 vector unsigned short vec_sel (vector unsigned short,
16590                                vector unsigned short,
16591                                vector bool short);
16592 vector unsigned short vec_sel (vector unsigned short,
16593                                vector unsigned short,
16594                                vector unsigned short);
16595 vector bool short vec_sel (vector bool short,
16596                            vector bool short,
16597                            vector bool short);
16598 vector bool short vec_sel (vector bool short,
16599                            vector bool short,
16600                            vector unsigned short);
16601 vector signed char vec_sel (vector signed char,
16602                             vector signed char,
16603                             vector bool char);
16604 vector signed char vec_sel (vector signed char,
16605                             vector signed char,
16606                             vector unsigned char);
16607 vector unsigned char vec_sel (vector unsigned char,
16608                               vector unsigned char,
16609                               vector bool char);
16610 vector unsigned char vec_sel (vector unsigned char,
16611                               vector unsigned char,
16612                               vector unsigned char);
16613 vector bool char vec_sel (vector bool char,
16614                           vector bool char,
16615                           vector bool char);
16616 vector bool char vec_sel (vector bool char,
16617                           vector bool char,
16618                           vector unsigned char);
16620 vector signed char vec_sl (vector signed char,
16621                            vector unsigned char);
16622 vector unsigned char vec_sl (vector unsigned char,
16623                              vector unsigned char);
16624 vector signed short vec_sl (vector signed short, vector unsigned short);
16625 vector unsigned short vec_sl (vector unsigned short,
16626                               vector unsigned short);
16627 vector signed int vec_sl (vector signed int, vector unsigned int);
16628 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16630 vector signed int vec_vslw (vector signed int, vector unsigned int);
16631 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16633 vector signed short vec_vslh (vector signed short,
16634                               vector unsigned short);
16635 vector unsigned short vec_vslh (vector unsigned short,
16636                                 vector unsigned short);
16638 vector signed char vec_vslb (vector signed char, vector unsigned char);
16639 vector unsigned char vec_vslb (vector unsigned char,
16640                                vector unsigned char);
16642 vector float vec_sld (vector float, vector float, const int);
16643 vector double vec_sld (vector double, vector double, const int);
16645 vector signed int vec_sld (vector signed int,
16646                            vector signed int,
16647                            const int);
16648 vector unsigned int vec_sld (vector unsigned int,
16649                              vector unsigned int,
16650                              const int);
16651 vector bool int vec_sld (vector bool int,
16652                          vector bool int,
16653                          const int);
16654 vector signed short vec_sld (vector signed short,
16655                              vector signed short,
16656                              const int);
16657 vector unsigned short vec_sld (vector unsigned short,
16658                                vector unsigned short,
16659                                const int);
16660 vector bool short vec_sld (vector bool short,
16661                            vector bool short,
16662                            const int);
16663 vector pixel vec_sld (vector pixel,
16664                       vector pixel,
16665                       const int);
16666 vector signed char vec_sld (vector signed char,
16667                             vector signed char,
16668                             const int);
16669 vector unsigned char vec_sld (vector unsigned char,
16670                               vector unsigned char,
16671                               const int);
16672 vector bool char vec_sld (vector bool char,
16673                           vector bool char,
16674                           const int);
16676 vector signed char vec_sldw (vector signed char,
16677                              vector signed char,
16678                              const int);
16679 vector unsigned char vec_sldw (vector unsigned char,
16680                                vector unsigned char,
16681                                const int);
16682 vector signed short vec_sldw (vector signed short,
16683                               vector signed short,
16684                               const int);
16685 vector unsigned short vec_sldw (vector unsigned short,
16686                                 vector unsigned short,
16687                                 const int);
16688 vector signed int vec_sldw (vector signed int,
16689                             vector signed int,
16690                             const int);
16691 vector unsigned int vec_sldw (vector unsigned int,
16692                               vector unsigned int,
16693                               const int);
16694 vector signed long long vec_sldw (vector signed long long,
16695                                   vector signed long long,
16696                                   const int);
16697 vector unsigned long long vec_sldw (vector unsigned long long,
16698                                     vector unsigned long long,
16699                                     const int);
16701 vector signed int vec_sll (vector signed int,
16702                            vector unsigned int);
16703 vector signed int vec_sll (vector signed int,
16704                            vector unsigned short);
16705 vector signed int vec_sll (vector signed int,
16706                            vector unsigned char);
16707 vector unsigned int vec_sll (vector unsigned int,
16708                              vector unsigned int);
16709 vector unsigned int vec_sll (vector unsigned int,
16710                              vector unsigned short);
16711 vector unsigned int vec_sll (vector unsigned int,
16712                              vector unsigned char);
16713 vector bool int vec_sll (vector bool int,
16714                          vector unsigned int);
16715 vector bool int vec_sll (vector bool int,
16716                          vector unsigned short);
16717 vector bool int vec_sll (vector bool int,
16718                          vector unsigned char);
16719 vector signed short vec_sll (vector signed short,
16720                              vector unsigned int);
16721 vector signed short vec_sll (vector signed short,
16722                              vector unsigned short);
16723 vector signed short vec_sll (vector signed short,
16724                              vector unsigned char);
16725 vector unsigned short vec_sll (vector unsigned short,
16726                                vector unsigned int);
16727 vector unsigned short vec_sll (vector unsigned short,
16728                                vector unsigned short);
16729 vector unsigned short vec_sll (vector unsigned short,
16730                                vector unsigned char);
16731 vector bool short vec_sll (vector bool short, vector unsigned int);
16732 vector bool short vec_sll (vector bool short, vector unsigned short);
16733 vector bool short vec_sll (vector bool short, vector unsigned char);
16734 vector pixel vec_sll (vector pixel, vector unsigned int);
16735 vector pixel vec_sll (vector pixel, vector unsigned short);
16736 vector pixel vec_sll (vector pixel, vector unsigned char);
16737 vector signed char vec_sll (vector signed char, vector unsigned int);
16738 vector signed char vec_sll (vector signed char, vector unsigned short);
16739 vector signed char vec_sll (vector signed char, vector unsigned char);
16740 vector unsigned char vec_sll (vector unsigned char,
16741                               vector unsigned int);
16742 vector unsigned char vec_sll (vector unsigned char,
16743                               vector unsigned short);
16744 vector unsigned char vec_sll (vector unsigned char,
16745                               vector unsigned char);
16746 vector bool char vec_sll (vector bool char, vector unsigned int);
16747 vector bool char vec_sll (vector bool char, vector unsigned short);
16748 vector bool char vec_sll (vector bool char, vector unsigned char);
16750 vector float vec_slo (vector float, vector signed char);
16751 vector float vec_slo (vector float, vector unsigned char);
16752 vector signed int vec_slo (vector signed int, vector signed char);
16753 vector signed int vec_slo (vector signed int, vector unsigned char);
16754 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16755 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16756 vector signed short vec_slo (vector signed short, vector signed char);
16757 vector signed short vec_slo (vector signed short, vector unsigned char);
16758 vector unsigned short vec_slo (vector unsigned short,
16759                                vector signed char);
16760 vector unsigned short vec_slo (vector unsigned short,
16761                                vector unsigned char);
16762 vector pixel vec_slo (vector pixel, vector signed char);
16763 vector pixel vec_slo (vector pixel, vector unsigned char);
16764 vector signed char vec_slo (vector signed char, vector signed char);
16765 vector signed char vec_slo (vector signed char, vector unsigned char);
16766 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16767 vector unsigned char vec_slo (vector unsigned char,
16768                               vector unsigned char);
16769 vector signed long long vec_slo (vector signed long long, vector signed char);
16770 vector signed long long vec_slo (vector signed long long, vector unsigned char);
16771 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
16772 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
16774 vector signed char vec_splat (vector signed char, const int);
16775 vector unsigned char vec_splat (vector unsigned char, const int);
16776 vector bool char vec_splat (vector bool char, const int);
16777 vector signed short vec_splat (vector signed short, const int);
16778 vector unsigned short vec_splat (vector unsigned short, const int);
16779 vector bool short vec_splat (vector bool short, const int);
16780 vector pixel vec_splat (vector pixel, const int);
16781 vector float vec_splat (vector float, const int);
16782 vector signed int vec_splat (vector signed int, const int);
16783 vector unsigned int vec_splat (vector unsigned int, const int);
16784 vector bool int vec_splat (vector bool int, const int);
16785 vector signed long vec_splat (vector signed long, const int);
16786 vector unsigned long vec_splat (vector unsigned long, const int);
16788 vector signed char vec_splats (signed char);
16789 vector unsigned char vec_splats (unsigned char);
16790 vector signed short vec_splats (signed short);
16791 vector unsigned short vec_splats (unsigned short);
16792 vector signed int vec_splats (signed int);
16793 vector unsigned int vec_splats (unsigned int);
16794 vector float vec_splats (float);
16796 vector float vec_vspltw (vector float, const int);
16797 vector signed int vec_vspltw (vector signed int, const int);
16798 vector unsigned int vec_vspltw (vector unsigned int, const int);
16799 vector bool int vec_vspltw (vector bool int, const int);
16801 vector bool short vec_vsplth (vector bool short, const int);
16802 vector signed short vec_vsplth (vector signed short, const int);
16803 vector unsigned short vec_vsplth (vector unsigned short, const int);
16804 vector pixel vec_vsplth (vector pixel, const int);
16806 vector signed char vec_vspltb (vector signed char, const int);
16807 vector unsigned char vec_vspltb (vector unsigned char, const int);
16808 vector bool char vec_vspltb (vector bool char, const int);
16810 vector signed char vec_splat_s8 (const int);
16812 vector signed short vec_splat_s16 (const int);
16814 vector signed int vec_splat_s32 (const int);
16816 vector unsigned char vec_splat_u8 (const int);
16818 vector unsigned short vec_splat_u16 (const int);
16820 vector unsigned int vec_splat_u32 (const int);
16822 vector signed char vec_sr (vector signed char, vector unsigned char);
16823 vector unsigned char vec_sr (vector unsigned char,
16824                              vector unsigned char);
16825 vector signed short vec_sr (vector signed short,
16826                             vector unsigned short);
16827 vector unsigned short vec_sr (vector unsigned short,
16828                               vector unsigned short);
16829 vector signed int vec_sr (vector signed int, vector unsigned int);
16830 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16832 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16833 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16835 vector signed short vec_vsrh (vector signed short,
16836                               vector unsigned short);
16837 vector unsigned short vec_vsrh (vector unsigned short,
16838                                 vector unsigned short);
16840 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16841 vector unsigned char vec_vsrb (vector unsigned char,
16842                                vector unsigned char);
16844 vector signed char vec_sra (vector signed char, vector unsigned char);
16845 vector unsigned char vec_sra (vector unsigned char,
16846                               vector unsigned char);
16847 vector signed short vec_sra (vector signed short,
16848                              vector unsigned short);
16849 vector unsigned short vec_sra (vector unsigned short,
16850                                vector unsigned short);
16851 vector signed int vec_sra (vector signed int, vector unsigned int);
16852 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16854 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16855 vector unsigned int vec_vsraw (vector unsigned int,
16856                                vector unsigned int);
16858 vector signed short vec_vsrah (vector signed short,
16859                                vector unsigned short);
16860 vector unsigned short vec_vsrah (vector unsigned short,
16861                                  vector unsigned short);
16863 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16864 vector unsigned char vec_vsrab (vector unsigned char,
16865                                 vector unsigned char);
16867 vector signed int vec_srl (vector signed int, vector unsigned int);
16868 vector signed int vec_srl (vector signed int, vector unsigned short);
16869 vector signed int vec_srl (vector signed int, vector unsigned char);
16870 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16871 vector unsigned int vec_srl (vector unsigned int,
16872                              vector unsigned short);
16873 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16874 vector bool int vec_srl (vector bool int, vector unsigned int);
16875 vector bool int vec_srl (vector bool int, vector unsigned short);
16876 vector bool int vec_srl (vector bool int, vector unsigned char);
16877 vector signed short vec_srl (vector signed short, vector unsigned int);
16878 vector signed short vec_srl (vector signed short,
16879                              vector unsigned short);
16880 vector signed short vec_srl (vector signed short, vector unsigned char);
16881 vector unsigned short vec_srl (vector unsigned short,
16882                                vector unsigned int);
16883 vector unsigned short vec_srl (vector unsigned short,
16884                                vector unsigned short);
16885 vector unsigned short vec_srl (vector unsigned short,
16886                                vector unsigned char);
16887 vector bool short vec_srl (vector bool short, vector unsigned int);
16888 vector bool short vec_srl (vector bool short, vector unsigned short);
16889 vector bool short vec_srl (vector bool short, vector unsigned char);
16890 vector pixel vec_srl (vector pixel, vector unsigned int);
16891 vector pixel vec_srl (vector pixel, vector unsigned short);
16892 vector pixel vec_srl (vector pixel, vector unsigned char);
16893 vector signed char vec_srl (vector signed char, vector unsigned int);
16894 vector signed char vec_srl (vector signed char, vector unsigned short);
16895 vector signed char vec_srl (vector signed char, vector unsigned char);
16896 vector unsigned char vec_srl (vector unsigned char,
16897                               vector unsigned int);
16898 vector unsigned char vec_srl (vector unsigned char,
16899                               vector unsigned short);
16900 vector unsigned char vec_srl (vector unsigned char,
16901                               vector unsigned char);
16902 vector bool char vec_srl (vector bool char, vector unsigned int);
16903 vector bool char vec_srl (vector bool char, vector unsigned short);
16904 vector bool char vec_srl (vector bool char, vector unsigned char);
16906 vector float vec_sro (vector float, vector signed char);
16907 vector float vec_sro (vector float, vector unsigned char);
16908 vector signed int vec_sro (vector signed int, vector signed char);
16909 vector signed int vec_sro (vector signed int, vector unsigned char);
16910 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16911 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16912 vector signed short vec_sro (vector signed short, vector signed char);
16913 vector signed short vec_sro (vector signed short, vector unsigned char);
16914 vector unsigned short vec_sro (vector unsigned short,
16915                                vector signed char);
16916 vector unsigned short vec_sro (vector unsigned short,
16917                                vector unsigned char);
16918 vector pixel vec_sro (vector pixel, vector signed char);
16919 vector pixel vec_sro (vector pixel, vector unsigned char);
16920 vector signed char vec_sro (vector signed char, vector signed char);
16921 vector signed char vec_sro (vector signed char, vector unsigned char);
16922 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16923 vector unsigned char vec_sro (vector unsigned char,
16924                               vector unsigned char);
16926 void vec_st (vector float, int, vector float *);
16927 void vec_st (vector float, int, float *);
16928 void vec_st (vector signed int, int, vector signed int *);
16929 void vec_st (vector signed int, int, int *);
16930 void vec_st (vector unsigned int, int, vector unsigned int *);
16931 void vec_st (vector unsigned int, int, unsigned int *);
16932 void vec_st (vector bool int, int, vector bool int *);
16933 void vec_st (vector bool int, int, unsigned int *);
16934 void vec_st (vector bool int, int, int *);
16935 void vec_st (vector signed short, int, vector signed short *);
16936 void vec_st (vector signed short, int, short *);
16937 void vec_st (vector unsigned short, int, vector unsigned short *);
16938 void vec_st (vector unsigned short, int, unsigned short *);
16939 void vec_st (vector bool short, int, vector bool short *);
16940 void vec_st (vector bool short, int, unsigned short *);
16941 void vec_st (vector pixel, int, vector pixel *);
16942 void vec_st (vector pixel, int, unsigned short *);
16943 void vec_st (vector pixel, int, short *);
16944 void vec_st (vector bool short, int, short *);
16945 void vec_st (vector signed char, int, vector signed char *);
16946 void vec_st (vector signed char, int, signed char *);
16947 void vec_st (vector unsigned char, int, vector unsigned char *);
16948 void vec_st (vector unsigned char, int, unsigned char *);
16949 void vec_st (vector bool char, int, vector bool char *);
16950 void vec_st (vector bool char, int, unsigned char *);
16951 void vec_st (vector bool char, int, signed char *);
16953 void vec_ste (vector signed char, int, signed char *);
16954 void vec_ste (vector unsigned char, int, unsigned char *);
16955 void vec_ste (vector bool char, int, signed char *);
16956 void vec_ste (vector bool char, int, unsigned char *);
16957 void vec_ste (vector signed short, int, short *);
16958 void vec_ste (vector unsigned short, int, unsigned short *);
16959 void vec_ste (vector bool short, int, short *);
16960 void vec_ste (vector bool short, int, unsigned short *);
16961 void vec_ste (vector pixel, int, short *);
16962 void vec_ste (vector pixel, int, unsigned short *);
16963 void vec_ste (vector float, int, float *);
16964 void vec_ste (vector signed int, int, int *);
16965 void vec_ste (vector unsigned int, int, unsigned int *);
16966 void vec_ste (vector bool int, int, int *);
16967 void vec_ste (vector bool int, int, unsigned int *);
16969 void vec_stvewx (vector float, int, float *);
16970 void vec_stvewx (vector signed int, int, int *);
16971 void vec_stvewx (vector unsigned int, int, unsigned int *);
16972 void vec_stvewx (vector bool int, int, int *);
16973 void vec_stvewx (vector bool int, int, unsigned int *);
16975 void vec_stvehx (vector signed short, int, short *);
16976 void vec_stvehx (vector unsigned short, int, unsigned short *);
16977 void vec_stvehx (vector bool short, int, short *);
16978 void vec_stvehx (vector bool short, int, unsigned short *);
16979 void vec_stvehx (vector pixel, int, short *);
16980 void vec_stvehx (vector pixel, int, unsigned short *);
16982 void vec_stvebx (vector signed char, int, signed char *);
16983 void vec_stvebx (vector unsigned char, int, unsigned char *);
16984 void vec_stvebx (vector bool char, int, signed char *);
16985 void vec_stvebx (vector bool char, int, unsigned char *);
16987 void vec_stl (vector float, int, vector float *);
16988 void vec_stl (vector float, int, float *);
16989 void vec_stl (vector signed int, int, vector signed int *);
16990 void vec_stl (vector signed int, int, int *);
16991 void vec_stl (vector unsigned int, int, vector unsigned int *);
16992 void vec_stl (vector unsigned int, int, unsigned int *);
16993 void vec_stl (vector bool int, int, vector bool int *);
16994 void vec_stl (vector bool int, int, unsigned int *);
16995 void vec_stl (vector bool int, int, int *);
16996 void vec_stl (vector signed short, int, vector signed short *);
16997 void vec_stl (vector signed short, int, short *);
16998 void vec_stl (vector unsigned short, int, vector unsigned short *);
16999 void vec_stl (vector unsigned short, int, unsigned short *);
17000 void vec_stl (vector bool short, int, vector bool short *);
17001 void vec_stl (vector bool short, int, unsigned short *);
17002 void vec_stl (vector bool short, int, short *);
17003 void vec_stl (vector pixel, int, vector pixel *);
17004 void vec_stl (vector pixel, int, unsigned short *);
17005 void vec_stl (vector pixel, int, short *);
17006 void vec_stl (vector signed char, int, vector signed char *);
17007 void vec_stl (vector signed char, int, signed char *);
17008 void vec_stl (vector unsigned char, int, vector unsigned char *);
17009 void vec_stl (vector unsigned char, int, unsigned char *);
17010 void vec_stl (vector bool char, int, vector bool char *);
17011 void vec_stl (vector bool char, int, unsigned char *);
17012 void vec_stl (vector bool char, int, signed char *);
17014 vector signed char vec_sub (vector bool char, vector signed char);
17015 vector signed char vec_sub (vector signed char, vector bool char);
17016 vector signed char vec_sub (vector signed char, vector signed char);
17017 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17018 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17019 vector unsigned char vec_sub (vector unsigned char,
17020                               vector unsigned char);
17021 vector signed short vec_sub (vector bool short, vector signed short);
17022 vector signed short vec_sub (vector signed short, vector bool short);
17023 vector signed short vec_sub (vector signed short, vector signed short);
17024 vector unsigned short vec_sub (vector bool short,
17025                                vector unsigned short);
17026 vector unsigned short vec_sub (vector unsigned short,
17027                                vector bool short);
17028 vector unsigned short vec_sub (vector unsigned short,
17029                                vector unsigned short);
17030 vector signed int vec_sub (vector bool int, vector signed int);
17031 vector signed int vec_sub (vector signed int, vector bool int);
17032 vector signed int vec_sub (vector signed int, vector signed int);
17033 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17034 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17035 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17036 vector float vec_sub (vector float, vector float);
17038 vector float vec_vsubfp (vector float, vector float);
17040 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17041 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17042 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17043 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17044 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17045 vector unsigned int vec_vsubuwm (vector unsigned int,
17046                                  vector unsigned int);
17048 vector signed short vec_vsubuhm (vector bool short,
17049                                  vector signed short);
17050 vector signed short vec_vsubuhm (vector signed short,
17051                                  vector bool short);
17052 vector signed short vec_vsubuhm (vector signed short,
17053                                  vector signed short);
17054 vector unsigned short vec_vsubuhm (vector bool short,
17055                                    vector unsigned short);
17056 vector unsigned short vec_vsubuhm (vector unsigned short,
17057                                    vector bool short);
17058 vector unsigned short vec_vsubuhm (vector unsigned short,
17059                                    vector unsigned short);
17061 vector signed char vec_vsububm (vector bool char, vector signed char);
17062 vector signed char vec_vsububm (vector signed char, vector bool char);
17063 vector signed char vec_vsububm (vector signed char, vector signed char);
17064 vector unsigned char vec_vsububm (vector bool char,
17065                                   vector unsigned char);
17066 vector unsigned char vec_vsububm (vector unsigned char,
17067                                   vector bool char);
17068 vector unsigned char vec_vsububm (vector unsigned char,
17069                                   vector unsigned char);
17071 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17073 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17074 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17075 vector unsigned char vec_subs (vector unsigned char,
17076                                vector unsigned char);
17077 vector signed char vec_subs (vector bool char, vector signed char);
17078 vector signed char vec_subs (vector signed char, vector bool char);
17079 vector signed char vec_subs (vector signed char, vector signed char);
17080 vector unsigned short vec_subs (vector bool short,
17081                                 vector unsigned short);
17082 vector unsigned short vec_subs (vector unsigned short,
17083                                 vector bool short);
17084 vector unsigned short vec_subs (vector unsigned short,
17085                                 vector unsigned short);
17086 vector signed short vec_subs (vector bool short, vector signed short);
17087 vector signed short vec_subs (vector signed short, vector bool short);
17088 vector signed short vec_subs (vector signed short, vector signed short);
17089 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17090 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17091 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17092 vector signed int vec_subs (vector bool int, vector signed int);
17093 vector signed int vec_subs (vector signed int, vector bool int);
17094 vector signed int vec_subs (vector signed int, vector signed int);
17096 vector signed int vec_vsubsws (vector bool int, vector signed int);
17097 vector signed int vec_vsubsws (vector signed int, vector bool int);
17098 vector signed int vec_vsubsws (vector signed int, vector signed int);
17100 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17101 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17102 vector unsigned int vec_vsubuws (vector unsigned int,
17103                                  vector unsigned int);
17105 vector signed short vec_vsubshs (vector bool short,
17106                                  vector signed short);
17107 vector signed short vec_vsubshs (vector signed short,
17108                                  vector bool short);
17109 vector signed short vec_vsubshs (vector signed short,
17110                                  vector signed short);
17112 vector unsigned short vec_vsubuhs (vector bool short,
17113                                    vector unsigned short);
17114 vector unsigned short vec_vsubuhs (vector unsigned short,
17115                                    vector bool short);
17116 vector unsigned short vec_vsubuhs (vector unsigned short,
17117                                    vector unsigned short);
17119 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17120 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17121 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17123 vector unsigned char vec_vsububs (vector bool char,
17124                                   vector unsigned char);
17125 vector unsigned char vec_vsububs (vector unsigned char,
17126                                   vector bool char);
17127 vector unsigned char vec_vsububs (vector unsigned char,
17128                                   vector unsigned char);
17130 vector unsigned int vec_sum4s (vector unsigned char,
17131                                vector unsigned int);
17132 vector signed int vec_sum4s (vector signed char, vector signed int);
17133 vector signed int vec_sum4s (vector signed short, vector signed int);
17135 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17137 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17139 vector unsigned int vec_vsum4ubs (vector unsigned char,
17140                                   vector unsigned int);
17142 vector signed int vec_sum2s (vector signed int, vector signed int);
17144 vector signed int vec_sums (vector signed int, vector signed int);
17146 vector float vec_trunc (vector float);
17148 vector signed short vec_unpackh (vector signed char);
17149 vector bool short vec_unpackh (vector bool char);
17150 vector signed int vec_unpackh (vector signed short);
17151 vector bool int vec_unpackh (vector bool short);
17152 vector unsigned int vec_unpackh (vector pixel);
17154 vector bool int vec_vupkhsh (vector bool short);
17155 vector signed int vec_vupkhsh (vector signed short);
17157 vector unsigned int vec_vupkhpx (vector pixel);
17159 vector bool short vec_vupkhsb (vector bool char);
17160 vector signed short vec_vupkhsb (vector signed char);
17162 vector signed short vec_unpackl (vector signed char);
17163 vector bool short vec_unpackl (vector bool char);
17164 vector unsigned int vec_unpackl (vector pixel);
17165 vector signed int vec_unpackl (vector signed short);
17166 vector bool int vec_unpackl (vector bool short);
17168 vector unsigned int vec_vupklpx (vector pixel);
17170 vector bool int vec_vupklsh (vector bool short);
17171 vector signed int vec_vupklsh (vector signed short);
17173 vector bool short vec_vupklsb (vector bool char);
17174 vector signed short vec_vupklsb (vector signed char);
17176 vector float vec_xor (vector float, vector float);
17177 vector float vec_xor (vector float, vector bool int);
17178 vector float vec_xor (vector bool int, vector float);
17179 vector bool int vec_xor (vector bool int, vector bool int);
17180 vector signed int vec_xor (vector bool int, vector signed int);
17181 vector signed int vec_xor (vector signed int, vector bool int);
17182 vector signed int vec_xor (vector signed int, vector signed int);
17183 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17184 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17185 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17186 vector bool short vec_xor (vector bool short, vector bool short);
17187 vector signed short vec_xor (vector bool short, vector signed short);
17188 vector signed short vec_xor (vector signed short, vector bool short);
17189 vector signed short vec_xor (vector signed short, vector signed short);
17190 vector unsigned short vec_xor (vector bool short,
17191                                vector unsigned short);
17192 vector unsigned short vec_xor (vector unsigned short,
17193                                vector bool short);
17194 vector unsigned short vec_xor (vector unsigned short,
17195                                vector unsigned short);
17196 vector signed char vec_xor (vector bool char, vector signed char);
17197 vector bool char vec_xor (vector bool char, vector bool char);
17198 vector signed char vec_xor (vector signed char, vector bool char);
17199 vector signed char vec_xor (vector signed char, vector signed char);
17200 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17201 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17202 vector unsigned char vec_xor (vector unsigned char,
17203                               vector unsigned char);
17205 int vec_all_eq (vector signed char, vector bool char);
17206 int vec_all_eq (vector signed char, vector signed char);
17207 int vec_all_eq (vector unsigned char, vector bool char);
17208 int vec_all_eq (vector unsigned char, vector unsigned char);
17209 int vec_all_eq (vector bool char, vector bool char);
17210 int vec_all_eq (vector bool char, vector unsigned char);
17211 int vec_all_eq (vector bool char, vector signed char);
17212 int vec_all_eq (vector signed short, vector bool short);
17213 int vec_all_eq (vector signed short, vector signed short);
17214 int vec_all_eq (vector unsigned short, vector bool short);
17215 int vec_all_eq (vector unsigned short, vector unsigned short);
17216 int vec_all_eq (vector bool short, vector bool short);
17217 int vec_all_eq (vector bool short, vector unsigned short);
17218 int vec_all_eq (vector bool short, vector signed short);
17219 int vec_all_eq (vector pixel, vector pixel);
17220 int vec_all_eq (vector signed int, vector bool int);
17221 int vec_all_eq (vector signed int, vector signed int);
17222 int vec_all_eq (vector unsigned int, vector bool int);
17223 int vec_all_eq (vector unsigned int, vector unsigned int);
17224 int vec_all_eq (vector bool int, vector bool int);
17225 int vec_all_eq (vector bool int, vector unsigned int);
17226 int vec_all_eq (vector bool int, vector signed int);
17227 int vec_all_eq (vector float, vector float);
17229 int vec_all_ge (vector bool char, vector unsigned char);
17230 int vec_all_ge (vector unsigned char, vector bool char);
17231 int vec_all_ge (vector unsigned char, vector unsigned char);
17232 int vec_all_ge (vector bool char, vector signed char);
17233 int vec_all_ge (vector signed char, vector bool char);
17234 int vec_all_ge (vector signed char, vector signed char);
17235 int vec_all_ge (vector bool short, vector unsigned short);
17236 int vec_all_ge (vector unsigned short, vector bool short);
17237 int vec_all_ge (vector unsigned short, vector unsigned short);
17238 int vec_all_ge (vector signed short, vector signed short);
17239 int vec_all_ge (vector bool short, vector signed short);
17240 int vec_all_ge (vector signed short, vector bool short);
17241 int vec_all_ge (vector bool int, vector unsigned int);
17242 int vec_all_ge (vector unsigned int, vector bool int);
17243 int vec_all_ge (vector unsigned int, vector unsigned int);
17244 int vec_all_ge (vector bool int, vector signed int);
17245 int vec_all_ge (vector signed int, vector bool int);
17246 int vec_all_ge (vector signed int, vector signed int);
17247 int vec_all_ge (vector float, vector float);
17249 int vec_all_gt (vector bool char, vector unsigned char);
17250 int vec_all_gt (vector unsigned char, vector bool char);
17251 int vec_all_gt (vector unsigned char, vector unsigned char);
17252 int vec_all_gt (vector bool char, vector signed char);
17253 int vec_all_gt (vector signed char, vector bool char);
17254 int vec_all_gt (vector signed char, vector signed char);
17255 int vec_all_gt (vector bool short, vector unsigned short);
17256 int vec_all_gt (vector unsigned short, vector bool short);
17257 int vec_all_gt (vector unsigned short, vector unsigned short);
17258 int vec_all_gt (vector bool short, vector signed short);
17259 int vec_all_gt (vector signed short, vector bool short);
17260 int vec_all_gt (vector signed short, vector signed short);
17261 int vec_all_gt (vector bool int, vector unsigned int);
17262 int vec_all_gt (vector unsigned int, vector bool int);
17263 int vec_all_gt (vector unsigned int, vector unsigned int);
17264 int vec_all_gt (vector bool int, vector signed int);
17265 int vec_all_gt (vector signed int, vector bool int);
17266 int vec_all_gt (vector signed int, vector signed int);
17267 int vec_all_gt (vector float, vector float);
17269 int vec_all_in (vector float, vector float);
17271 int vec_all_le (vector bool char, vector unsigned char);
17272 int vec_all_le (vector unsigned char, vector bool char);
17273 int vec_all_le (vector unsigned char, vector unsigned char);
17274 int vec_all_le (vector bool char, vector signed char);
17275 int vec_all_le (vector signed char, vector bool char);
17276 int vec_all_le (vector signed char, vector signed char);
17277 int vec_all_le (vector bool short, vector unsigned short);
17278 int vec_all_le (vector unsigned short, vector bool short);
17279 int vec_all_le (vector unsigned short, vector unsigned short);
17280 int vec_all_le (vector bool short, vector signed short);
17281 int vec_all_le (vector signed short, vector bool short);
17282 int vec_all_le (vector signed short, vector signed short);
17283 int vec_all_le (vector bool int, vector unsigned int);
17284 int vec_all_le (vector unsigned int, vector bool int);
17285 int vec_all_le (vector unsigned int, vector unsigned int);
17286 int vec_all_le (vector bool int, vector signed int);
17287 int vec_all_le (vector signed int, vector bool int);
17288 int vec_all_le (vector signed int, vector signed int);
17289 int vec_all_le (vector float, vector float);
17291 int vec_all_lt (vector bool char, vector unsigned char);
17292 int vec_all_lt (vector unsigned char, vector bool char);
17293 int vec_all_lt (vector unsigned char, vector unsigned char);
17294 int vec_all_lt (vector bool char, vector signed char);
17295 int vec_all_lt (vector signed char, vector bool char);
17296 int vec_all_lt (vector signed char, vector signed char);
17297 int vec_all_lt (vector bool short, vector unsigned short);
17298 int vec_all_lt (vector unsigned short, vector bool short);
17299 int vec_all_lt (vector unsigned short, vector unsigned short);
17300 int vec_all_lt (vector bool short, vector signed short);
17301 int vec_all_lt (vector signed short, vector bool short);
17302 int vec_all_lt (vector signed short, vector signed short);
17303 int vec_all_lt (vector bool int, vector unsigned int);
17304 int vec_all_lt (vector unsigned int, vector bool int);
17305 int vec_all_lt (vector unsigned int, vector unsigned int);
17306 int vec_all_lt (vector bool int, vector signed int);
17307 int vec_all_lt (vector signed int, vector bool int);
17308 int vec_all_lt (vector signed int, vector signed int);
17309 int vec_all_lt (vector float, vector float);
17311 int vec_all_nan (vector float);
17313 int vec_all_ne (vector signed char, vector bool char);
17314 int vec_all_ne (vector signed char, vector signed char);
17315 int vec_all_ne (vector unsigned char, vector bool char);
17316 int vec_all_ne (vector unsigned char, vector unsigned char);
17317 int vec_all_ne (vector bool char, vector bool char);
17318 int vec_all_ne (vector bool char, vector unsigned char);
17319 int vec_all_ne (vector bool char, vector signed char);
17320 int vec_all_ne (vector signed short, vector bool short);
17321 int vec_all_ne (vector signed short, vector signed short);
17322 int vec_all_ne (vector unsigned short, vector bool short);
17323 int vec_all_ne (vector unsigned short, vector unsigned short);
17324 int vec_all_ne (vector bool short, vector bool short);
17325 int vec_all_ne (vector bool short, vector unsigned short);
17326 int vec_all_ne (vector bool short, vector signed short);
17327 int vec_all_ne (vector pixel, vector pixel);
17328 int vec_all_ne (vector signed int, vector bool int);
17329 int vec_all_ne (vector signed int, vector signed int);
17330 int vec_all_ne (vector unsigned int, vector bool int);
17331 int vec_all_ne (vector unsigned int, vector unsigned int);
17332 int vec_all_ne (vector bool int, vector bool int);
17333 int vec_all_ne (vector bool int, vector unsigned int);
17334 int vec_all_ne (vector bool int, vector signed int);
17335 int vec_all_ne (vector float, vector float);
17337 int vec_all_nge (vector float, vector float);
17339 int vec_all_ngt (vector float, vector float);
17341 int vec_all_nle (vector float, vector float);
17343 int vec_all_nlt (vector float, vector float);
17345 int vec_all_numeric (vector float);
17347 int vec_any_eq (vector signed char, vector bool char);
17348 int vec_any_eq (vector signed char, vector signed char);
17349 int vec_any_eq (vector unsigned char, vector bool char);
17350 int vec_any_eq (vector unsigned char, vector unsigned char);
17351 int vec_any_eq (vector bool char, vector bool char);
17352 int vec_any_eq (vector bool char, vector unsigned char);
17353 int vec_any_eq (vector bool char, vector signed char);
17354 int vec_any_eq (vector signed short, vector bool short);
17355 int vec_any_eq (vector signed short, vector signed short);
17356 int vec_any_eq (vector unsigned short, vector bool short);
17357 int vec_any_eq (vector unsigned short, vector unsigned short);
17358 int vec_any_eq (vector bool short, vector bool short);
17359 int vec_any_eq (vector bool short, vector unsigned short);
17360 int vec_any_eq (vector bool short, vector signed short);
17361 int vec_any_eq (vector pixel, vector pixel);
17362 int vec_any_eq (vector signed int, vector bool int);
17363 int vec_any_eq (vector signed int, vector signed int);
17364 int vec_any_eq (vector unsigned int, vector bool int);
17365 int vec_any_eq (vector unsigned int, vector unsigned int);
17366 int vec_any_eq (vector bool int, vector bool int);
17367 int vec_any_eq (vector bool int, vector unsigned int);
17368 int vec_any_eq (vector bool int, vector signed int);
17369 int vec_any_eq (vector float, vector float);
17371 int vec_any_ge (vector signed char, vector bool char);
17372 int vec_any_ge (vector unsigned char, vector bool char);
17373 int vec_any_ge (vector unsigned char, vector unsigned char);
17374 int vec_any_ge (vector signed char, vector signed char);
17375 int vec_any_ge (vector bool char, vector unsigned char);
17376 int vec_any_ge (vector bool char, vector signed char);
17377 int vec_any_ge (vector unsigned short, vector bool short);
17378 int vec_any_ge (vector unsigned short, vector unsigned short);
17379 int vec_any_ge (vector signed short, vector signed short);
17380 int vec_any_ge (vector signed short, vector bool short);
17381 int vec_any_ge (vector bool short, vector unsigned short);
17382 int vec_any_ge (vector bool short, vector signed short);
17383 int vec_any_ge (vector signed int, vector bool int);
17384 int vec_any_ge (vector unsigned int, vector bool int);
17385 int vec_any_ge (vector unsigned int, vector unsigned int);
17386 int vec_any_ge (vector signed int, vector signed int);
17387 int vec_any_ge (vector bool int, vector unsigned int);
17388 int vec_any_ge (vector bool int, vector signed int);
17389 int vec_any_ge (vector float, vector float);
17391 int vec_any_gt (vector bool char, vector unsigned char);
17392 int vec_any_gt (vector unsigned char, vector bool char);
17393 int vec_any_gt (vector unsigned char, vector unsigned char);
17394 int vec_any_gt (vector bool char, vector signed char);
17395 int vec_any_gt (vector signed char, vector bool char);
17396 int vec_any_gt (vector signed char, vector signed char);
17397 int vec_any_gt (vector bool short, vector unsigned short);
17398 int vec_any_gt (vector unsigned short, vector bool short);
17399 int vec_any_gt (vector unsigned short, vector unsigned short);
17400 int vec_any_gt (vector bool short, vector signed short);
17401 int vec_any_gt (vector signed short, vector bool short);
17402 int vec_any_gt (vector signed short, vector signed short);
17403 int vec_any_gt (vector bool int, vector unsigned int);
17404 int vec_any_gt (vector unsigned int, vector bool int);
17405 int vec_any_gt (vector unsigned int, vector unsigned int);
17406 int vec_any_gt (vector bool int, vector signed int);
17407 int vec_any_gt (vector signed int, vector bool int);
17408 int vec_any_gt (vector signed int, vector signed int);
17409 int vec_any_gt (vector float, vector float);
17411 int vec_any_le (vector bool char, vector unsigned char);
17412 int vec_any_le (vector unsigned char, vector bool char);
17413 int vec_any_le (vector unsigned char, vector unsigned char);
17414 int vec_any_le (vector bool char, vector signed char);
17415 int vec_any_le (vector signed char, vector bool char);
17416 int vec_any_le (vector signed char, vector signed char);
17417 int vec_any_le (vector bool short, vector unsigned short);
17418 int vec_any_le (vector unsigned short, vector bool short);
17419 int vec_any_le (vector unsigned short, vector unsigned short);
17420 int vec_any_le (vector bool short, vector signed short);
17421 int vec_any_le (vector signed short, vector bool short);
17422 int vec_any_le (vector signed short, vector signed short);
17423 int vec_any_le (vector bool int, vector unsigned int);
17424 int vec_any_le (vector unsigned int, vector bool int);
17425 int vec_any_le (vector unsigned int, vector unsigned int);
17426 int vec_any_le (vector bool int, vector signed int);
17427 int vec_any_le (vector signed int, vector bool int);
17428 int vec_any_le (vector signed int, vector signed int);
17429 int vec_any_le (vector float, vector float);
17431 int vec_any_lt (vector bool char, vector unsigned char);
17432 int vec_any_lt (vector unsigned char, vector bool char);
17433 int vec_any_lt (vector unsigned char, vector unsigned char);
17434 int vec_any_lt (vector bool char, vector signed char);
17435 int vec_any_lt (vector signed char, vector bool char);
17436 int vec_any_lt (vector signed char, vector signed char);
17437 int vec_any_lt (vector bool short, vector unsigned short);
17438 int vec_any_lt (vector unsigned short, vector bool short);
17439 int vec_any_lt (vector unsigned short, vector unsigned short);
17440 int vec_any_lt (vector bool short, vector signed short);
17441 int vec_any_lt (vector signed short, vector bool short);
17442 int vec_any_lt (vector signed short, vector signed short);
17443 int vec_any_lt (vector bool int, vector unsigned int);
17444 int vec_any_lt (vector unsigned int, vector bool int);
17445 int vec_any_lt (vector unsigned int, vector unsigned int);
17446 int vec_any_lt (vector bool int, vector signed int);
17447 int vec_any_lt (vector signed int, vector bool int);
17448 int vec_any_lt (vector signed int, vector signed int);
17449 int vec_any_lt (vector float, vector float);
17451 int vec_any_nan (vector float);
17453 int vec_any_ne (vector signed char, vector bool char);
17454 int vec_any_ne (vector signed char, vector signed char);
17455 int vec_any_ne (vector unsigned char, vector bool char);
17456 int vec_any_ne (vector unsigned char, vector unsigned char);
17457 int vec_any_ne (vector bool char, vector bool char);
17458 int vec_any_ne (vector bool char, vector unsigned char);
17459 int vec_any_ne (vector bool char, vector signed char);
17460 int vec_any_ne (vector signed short, vector bool short);
17461 int vec_any_ne (vector signed short, vector signed short);
17462 int vec_any_ne (vector unsigned short, vector bool short);
17463 int vec_any_ne (vector unsigned short, vector unsigned short);
17464 int vec_any_ne (vector bool short, vector bool short);
17465 int vec_any_ne (vector bool short, vector unsigned short);
17466 int vec_any_ne (vector bool short, vector signed short);
17467 int vec_any_ne (vector pixel, vector pixel);
17468 int vec_any_ne (vector signed int, vector bool int);
17469 int vec_any_ne (vector signed int, vector signed int);
17470 int vec_any_ne (vector unsigned int, vector bool int);
17471 int vec_any_ne (vector unsigned int, vector unsigned int);
17472 int vec_any_ne (vector bool int, vector bool int);
17473 int vec_any_ne (vector bool int, vector unsigned int);
17474 int vec_any_ne (vector bool int, vector signed int);
17475 int vec_any_ne (vector float, vector float);
17477 int vec_any_nge (vector float, vector float);
17479 int vec_any_ngt (vector float, vector float);
17481 int vec_any_nle (vector float, vector float);
17483 int vec_any_nlt (vector float, vector float);
17485 int vec_any_numeric (vector float);
17487 int vec_any_out (vector float, vector float);
17488 @end smallexample
17490 If the vector/scalar (VSX) instruction set is available, the following
17491 additional functions are available:
17493 @smallexample
17494 vector double vec_abs (vector double);
17495 vector double vec_add (vector double, vector double);
17496 vector double vec_and (vector double, vector double);
17497 vector double vec_and (vector double, vector bool long);
17498 vector double vec_and (vector bool long, vector double);
17499 vector long vec_and (vector long, vector long);
17500 vector long vec_and (vector long, vector bool long);
17501 vector long vec_and (vector bool long, vector long);
17502 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17503 vector unsigned long vec_and (vector unsigned long, vector bool long);
17504 vector unsigned long vec_and (vector bool long, vector unsigned long);
17505 vector double vec_andc (vector double, vector double);
17506 vector double vec_andc (vector double, vector bool long);
17507 vector double vec_andc (vector bool long, vector double);
17508 vector long vec_andc (vector long, vector long);
17509 vector long vec_andc (vector long, vector bool long);
17510 vector long vec_andc (vector bool long, vector long);
17511 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17512 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17513 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17514 vector double vec_ceil (vector double);
17515 vector bool long vec_cmpeq (vector double, vector double);
17516 vector bool long vec_cmpge (vector double, vector double);
17517 vector bool long vec_cmpgt (vector double, vector double);
17518 vector bool long vec_cmple (vector double, vector double);
17519 vector bool long vec_cmplt (vector double, vector double);
17520 vector double vec_cpsgn (vector double, vector double);
17521 vector float vec_div (vector float, vector float);
17522 vector double vec_div (vector double, vector double);
17523 vector long vec_div (vector long, vector long);
17524 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17525 vector double vec_floor (vector double);
17526 vector double vec_ld (int, const vector double *);
17527 vector double vec_ld (int, const double *);
17528 vector double vec_ldl (int, const vector double *);
17529 vector double vec_ldl (int, const double *);
17530 vector unsigned char vec_lvsl (int, const volatile double *);
17531 vector unsigned char vec_lvsr (int, const volatile double *);
17532 vector double vec_madd (vector double, vector double, vector double);
17533 vector double vec_max (vector double, vector double);
17534 vector signed long vec_mergeh (vector signed long, vector signed long);
17535 vector signed long vec_mergeh (vector signed long, vector bool long);
17536 vector signed long vec_mergeh (vector bool long, vector signed long);
17537 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17538 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17539 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17540 vector signed long vec_mergel (vector signed long, vector signed long);
17541 vector signed long vec_mergel (vector signed long, vector bool long);
17542 vector signed long vec_mergel (vector bool long, vector signed long);
17543 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17544 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17545 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17546 vector double vec_min (vector double, vector double);
17547 vector float vec_msub (vector float, vector float, vector float);
17548 vector double vec_msub (vector double, vector double, vector double);
17549 vector float vec_mul (vector float, vector float);
17550 vector double vec_mul (vector double, vector double);
17551 vector long vec_mul (vector long, vector long);
17552 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17553 vector float vec_nearbyint (vector float);
17554 vector double vec_nearbyint (vector double);
17555 vector float vec_nmadd (vector float, vector float, vector float);
17556 vector double vec_nmadd (vector double, vector double, vector double);
17557 vector double vec_nmsub (vector double, vector double, vector double);
17558 vector double vec_nor (vector double, vector double);
17559 vector long vec_nor (vector long, vector long);
17560 vector long vec_nor (vector long, vector bool long);
17561 vector long vec_nor (vector bool long, vector long);
17562 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17563 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17564 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17565 vector double vec_or (vector double, vector double);
17566 vector double vec_or (vector double, vector bool long);
17567 vector double vec_or (vector bool long, vector double);
17568 vector long vec_or (vector long, vector long);
17569 vector long vec_or (vector long, vector bool long);
17570 vector long vec_or (vector bool long, vector long);
17571 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17572 vector unsigned long vec_or (vector unsigned long, vector bool long);
17573 vector unsigned long vec_or (vector bool long, vector unsigned long);
17574 vector double vec_perm (vector double, vector double, vector unsigned char);
17575 vector long vec_perm (vector long, vector long, vector unsigned char);
17576 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17577                                vector unsigned char);
17578 vector double vec_rint (vector double);
17579 vector double vec_recip (vector double, vector double);
17580 vector double vec_rsqrt (vector double);
17581 vector double vec_rsqrte (vector double);
17582 vector double vec_sel (vector double, vector double, vector bool long);
17583 vector double vec_sel (vector double, vector double, vector unsigned long);
17584 vector long vec_sel (vector long, vector long, vector long);
17585 vector long vec_sel (vector long, vector long, vector unsigned long);
17586 vector long vec_sel (vector long, vector long, vector bool long);
17587 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17588                               vector long);
17589 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17590                               vector unsigned long);
17591 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17592                               vector bool long);
17593 vector double vec_splats (double);
17594 vector signed long vec_splats (signed long);
17595 vector unsigned long vec_splats (unsigned long);
17596 vector float vec_sqrt (vector float);
17597 vector double vec_sqrt (vector double);
17598 void vec_st (vector double, int, vector double *);
17599 void vec_st (vector double, int, double *);
17600 vector double vec_sub (vector double, vector double);
17601 vector double vec_trunc (vector double);
17602 vector double vec_xl (int, vector double *);
17603 vector double vec_xl (int, double *);
17604 vector long long vec_xl (int, vector long long *);
17605 vector long long vec_xl (int, long long *);
17606 vector unsigned long long vec_xl (int, vector unsigned long long *);
17607 vector unsigned long long vec_xl (int, unsigned long long *);
17608 vector float vec_xl (int, vector float *);
17609 vector float vec_xl (int, float *);
17610 vector int vec_xl (int, vector int *);
17611 vector int vec_xl (int, int *);
17612 vector unsigned int vec_xl (int, vector unsigned int *);
17613 vector unsigned int vec_xl (int, unsigned int *);
17614 vector double vec_xor (vector double, vector double);
17615 vector double vec_xor (vector double, vector bool long);
17616 vector double vec_xor (vector bool long, vector double);
17617 vector long vec_xor (vector long, vector long);
17618 vector long vec_xor (vector long, vector bool long);
17619 vector long vec_xor (vector bool long, vector long);
17620 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17621 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17622 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17623 void vec_xst (vector double, int, vector double *);
17624 void vec_xst (vector double, int, double *);
17625 void vec_xst (vector long long, int, vector long long *);
17626 void vec_xst (vector long long, int, long long *);
17627 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17628 void vec_xst (vector unsigned long long, int, unsigned long long *);
17629 void vec_xst (vector float, int, vector float *);
17630 void vec_xst (vector float, int, float *);
17631 void vec_xst (vector int, int, vector int *);
17632 void vec_xst (vector int, int, int *);
17633 void vec_xst (vector unsigned int, int, vector unsigned int *);
17634 void vec_xst (vector unsigned int, int, unsigned int *);
17635 int vec_all_eq (vector double, vector double);
17636 int vec_all_ge (vector double, vector double);
17637 int vec_all_gt (vector double, vector double);
17638 int vec_all_le (vector double, vector double);
17639 int vec_all_lt (vector double, vector double);
17640 int vec_all_nan (vector double);
17641 int vec_all_ne (vector double, vector double);
17642 int vec_all_nge (vector double, vector double);
17643 int vec_all_ngt (vector double, vector double);
17644 int vec_all_nle (vector double, vector double);
17645 int vec_all_nlt (vector double, vector double);
17646 int vec_all_numeric (vector double);
17647 int vec_any_eq (vector double, vector double);
17648 int vec_any_ge (vector double, vector double);
17649 int vec_any_gt (vector double, vector double);
17650 int vec_any_le (vector double, vector double);
17651 int vec_any_lt (vector double, vector double);
17652 int vec_any_nan (vector double);
17653 int vec_any_ne (vector double, vector double);
17654 int vec_any_nge (vector double, vector double);
17655 int vec_any_ngt (vector double, vector double);
17656 int vec_any_nle (vector double, vector double);
17657 int vec_any_nlt (vector double, vector double);
17658 int vec_any_numeric (vector double);
17660 vector double vec_vsx_ld (int, const vector double *);
17661 vector double vec_vsx_ld (int, const double *);
17662 vector float vec_vsx_ld (int, const vector float *);
17663 vector float vec_vsx_ld (int, const float *);
17664 vector bool int vec_vsx_ld (int, const vector bool int *);
17665 vector signed int vec_vsx_ld (int, const vector signed int *);
17666 vector signed int vec_vsx_ld (int, const int *);
17667 vector signed int vec_vsx_ld (int, const long *);
17668 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17669 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17670 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17671 vector bool short vec_vsx_ld (int, const vector bool short *);
17672 vector pixel vec_vsx_ld (int, const vector pixel *);
17673 vector signed short vec_vsx_ld (int, const vector signed short *);
17674 vector signed short vec_vsx_ld (int, const short *);
17675 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17676 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17677 vector bool char vec_vsx_ld (int, const vector bool char *);
17678 vector signed char vec_vsx_ld (int, const vector signed char *);
17679 vector signed char vec_vsx_ld (int, const signed char *);
17680 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17681 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17683 void vec_vsx_st (vector double, int, vector double *);
17684 void vec_vsx_st (vector double, int, double *);
17685 void vec_vsx_st (vector float, int, vector float *);
17686 void vec_vsx_st (vector float, int, float *);
17687 void vec_vsx_st (vector signed int, int, vector signed int *);
17688 void vec_vsx_st (vector signed int, int, int *);
17689 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17690 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17691 void vec_vsx_st (vector bool int, int, vector bool int *);
17692 void vec_vsx_st (vector bool int, int, unsigned int *);
17693 void vec_vsx_st (vector bool int, int, int *);
17694 void vec_vsx_st (vector signed short, int, vector signed short *);
17695 void vec_vsx_st (vector signed short, int, short *);
17696 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17697 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17698 void vec_vsx_st (vector bool short, int, vector bool short *);
17699 void vec_vsx_st (vector bool short, int, unsigned short *);
17700 void vec_vsx_st (vector pixel, int, vector pixel *);
17701 void vec_vsx_st (vector pixel, int, unsigned short *);
17702 void vec_vsx_st (vector pixel, int, short *);
17703 void vec_vsx_st (vector bool short, int, short *);
17704 void vec_vsx_st (vector signed char, int, vector signed char *);
17705 void vec_vsx_st (vector signed char, int, signed char *);
17706 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17707 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17708 void vec_vsx_st (vector bool char, int, vector bool char *);
17709 void vec_vsx_st (vector bool char, int, unsigned char *);
17710 void vec_vsx_st (vector bool char, int, signed char *);
17712 vector double vec_xxpermdi (vector double, vector double, const int);
17713 vector float vec_xxpermdi (vector float, vector float, const int);
17714 vector long long vec_xxpermdi (vector long long, vector long long, const int);
17715 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17716                                         vector unsigned long long, const int);
17717 vector int vec_xxpermdi (vector int, vector int, const int);
17718 vector unsigned int vec_xxpermdi (vector unsigned int,
17719                                   vector unsigned int, const int);
17720 vector short vec_xxpermdi (vector short, vector short, const int);
17721 vector unsigned short vec_xxpermdi (vector unsigned short,
17722                                     vector unsigned short, const int);
17723 vector signed char vec_xxpermdi (vector signed char, vector signed char,
17724                                  const int);
17725 vector unsigned char vec_xxpermdi (vector unsigned char,
17726                                    vector unsigned char, const int);
17728 vector double vec_xxsldi (vector double, vector double, int);
17729 vector float vec_xxsldi (vector float, vector float, int);
17730 vector long long vec_xxsldi (vector long long, vector long long, int);
17731 vector unsigned long long vec_xxsldi (vector unsigned long long,
17732                                       vector unsigned long long, int);
17733 vector int vec_xxsldi (vector int, vector int, int);
17734 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17735 vector short vec_xxsldi (vector short, vector short, int);
17736 vector unsigned short vec_xxsldi (vector unsigned short,
17737                                   vector unsigned short, int);
17738 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17739 vector unsigned char vec_xxsldi (vector unsigned char,
17740                                  vector unsigned char, int);
17741 @end smallexample
17743 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17744 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17745 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
17746 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17747 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17749 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17750 instruction set are available, the following additional functions are
17751 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
17752 can use @var{vector long} instead of @var{vector long long},
17753 @var{vector bool long} instead of @var{vector bool long long}, and
17754 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17756 @smallexample
17757 vector long long vec_abs (vector long long);
17759 vector long long vec_add (vector long long, vector long long);
17760 vector unsigned long long vec_add (vector unsigned long long,
17761                                    vector unsigned long long);
17763 int vec_all_eq (vector long long, vector long long);
17764 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17765 int vec_all_ge (vector long long, vector long long);
17766 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17767 int vec_all_gt (vector long long, vector long long);
17768 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17769 int vec_all_le (vector long long, vector long long);
17770 int vec_all_le (vector unsigned long long, vector unsigned long long);
17771 int vec_all_lt (vector long long, vector long long);
17772 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17773 int vec_all_ne (vector long long, vector long long);
17774 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17776 int vec_any_eq (vector long long, vector long long);
17777 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17778 int vec_any_ge (vector long long, vector long long);
17779 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17780 int vec_any_gt (vector long long, vector long long);
17781 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17782 int vec_any_le (vector long long, vector long long);
17783 int vec_any_le (vector unsigned long long, vector unsigned long long);
17784 int vec_any_lt (vector long long, vector long long);
17785 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17786 int vec_any_ne (vector long long, vector long long);
17787 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17789 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
17791 vector long long vec_eqv (vector long long, vector long long);
17792 vector long long vec_eqv (vector bool long long, vector long long);
17793 vector long long vec_eqv (vector long long, vector bool long long);
17794 vector unsigned long long vec_eqv (vector unsigned long long,
17795                                    vector unsigned long long);
17796 vector unsigned long long vec_eqv (vector bool long long,
17797                                    vector unsigned long long);
17798 vector unsigned long long vec_eqv (vector unsigned long long,
17799                                    vector bool long long);
17800 vector int vec_eqv (vector int, vector int);
17801 vector int vec_eqv (vector bool int, vector int);
17802 vector int vec_eqv (vector int, vector bool int);
17803 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17804 vector unsigned int vec_eqv (vector bool unsigned int,
17805                              vector unsigned int);
17806 vector unsigned int vec_eqv (vector unsigned int,
17807                              vector bool unsigned int);
17808 vector short vec_eqv (vector short, vector short);
17809 vector short vec_eqv (vector bool short, vector short);
17810 vector short vec_eqv (vector short, vector bool short);
17811 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17812 vector unsigned short vec_eqv (vector bool unsigned short,
17813                                vector unsigned short);
17814 vector unsigned short vec_eqv (vector unsigned short,
17815                                vector bool unsigned short);
17816 vector signed char vec_eqv (vector signed char, vector signed char);
17817 vector signed char vec_eqv (vector bool signed char, vector signed char);
17818 vector signed char vec_eqv (vector signed char, vector bool signed char);
17819 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17820 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17821 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17823 vector long long vec_max (vector long long, vector long long);
17824 vector unsigned long long vec_max (vector unsigned long long,
17825                                    vector unsigned long long);
17827 vector signed int vec_mergee (vector signed int, vector signed int);
17828 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17829 vector bool int vec_mergee (vector bool int, vector bool int);
17831 vector signed int vec_mergeo (vector signed int, vector signed int);
17832 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17833 vector bool int vec_mergeo (vector bool int, vector bool int);
17835 vector long long vec_min (vector long long, vector long long);
17836 vector unsigned long long vec_min (vector unsigned long long,
17837                                    vector unsigned long long);
17839 vector signed long long vec_nabs (vector signed long long);
17841 vector long long vec_nand (vector long long, vector long long);
17842 vector long long vec_nand (vector bool long long, vector long long);
17843 vector long long vec_nand (vector long long, vector bool long long);
17844 vector unsigned long long vec_nand (vector unsigned long long,
17845                                     vector unsigned long long);
17846 vector unsigned long long vec_nand (vector bool long long,
17847                                    vector unsigned long long);
17848 vector unsigned long long vec_nand (vector unsigned long long,
17849                                     vector bool long long);
17850 vector int vec_nand (vector int, vector int);
17851 vector int vec_nand (vector bool int, vector int);
17852 vector int vec_nand (vector int, vector bool int);
17853 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17854 vector unsigned int vec_nand (vector bool unsigned int,
17855                               vector unsigned int);
17856 vector unsigned int vec_nand (vector unsigned int,
17857                               vector bool unsigned int);
17858 vector short vec_nand (vector short, vector short);
17859 vector short vec_nand (vector bool short, vector short);
17860 vector short vec_nand (vector short, vector bool short);
17861 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17862 vector unsigned short vec_nand (vector bool unsigned short,
17863                                 vector unsigned short);
17864 vector unsigned short vec_nand (vector unsigned short,
17865                                 vector bool unsigned short);
17866 vector signed char vec_nand (vector signed char, vector signed char);
17867 vector signed char vec_nand (vector bool signed char, vector signed char);
17868 vector signed char vec_nand (vector signed char, vector bool signed char);
17869 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17870 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17871 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17873 vector long long vec_orc (vector long long, vector long long);
17874 vector long long vec_orc (vector bool long long, vector long long);
17875 vector long long vec_orc (vector long long, vector bool long long);
17876 vector unsigned long long vec_orc (vector unsigned long long,
17877                                    vector unsigned long long);
17878 vector unsigned long long vec_orc (vector bool long long,
17879                                    vector unsigned long long);
17880 vector unsigned long long vec_orc (vector unsigned long long,
17881                                    vector bool long long);
17882 vector int vec_orc (vector int, vector int);
17883 vector int vec_orc (vector bool int, vector int);
17884 vector int vec_orc (vector int, vector bool int);
17885 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17886 vector unsigned int vec_orc (vector bool unsigned int,
17887                              vector unsigned int);
17888 vector unsigned int vec_orc (vector unsigned int,
17889                              vector bool unsigned int);
17890 vector short vec_orc (vector short, vector short);
17891 vector short vec_orc (vector bool short, vector short);
17892 vector short vec_orc (vector short, vector bool short);
17893 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17894 vector unsigned short vec_orc (vector bool unsigned short,
17895                                vector unsigned short);
17896 vector unsigned short vec_orc (vector unsigned short,
17897                                vector bool unsigned short);
17898 vector signed char vec_orc (vector signed char, vector signed char);
17899 vector signed char vec_orc (vector bool signed char, vector signed char);
17900 vector signed char vec_orc (vector signed char, vector bool signed char);
17901 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17902 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17903 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17905 vector int vec_pack (vector long long, vector long long);
17906 vector unsigned int vec_pack (vector unsigned long long,
17907                               vector unsigned long long);
17908 vector bool int vec_pack (vector bool long long, vector bool long long);
17909 vector float vec_pack (vector double, vector double);
17911 vector int vec_packs (vector long long, vector long long);
17912 vector unsigned int vec_packs (vector unsigned long long,
17913                                vector unsigned long long);
17915 vector unsigned int vec_packsu (vector long long, vector long long);
17916 vector unsigned int vec_packsu (vector unsigned long long,
17917                                 vector unsigned long long);
17919 vector unsigned char vec_popcnt (vector signed char);
17920 vector unsigned char vec_popcnt (vector unsigned char);
17921 vector unsigned short vec_popcnt (vector signed short);
17922 vector unsigned short vec_popcnt (vector unsigned short);
17923 vector unsigned int vec_popcnt (vector signed int);
17924 vector unsigned int vec_popcnt (vector unsigned int);
17925 vector unsigned long long vec_popcnt (vector signed long long);
17926 vector unsigned long long vec_popcnt (vector unsigned long long);
17928 vector long long vec_rl (vector long long,
17929                          vector unsigned long long);
17930 vector long long vec_rl (vector unsigned long long,
17931                          vector unsigned long long);
17933 vector long long vec_sl (vector long long, vector unsigned long long);
17934 vector long long vec_sl (vector unsigned long long,
17935                          vector unsigned long long);
17937 vector long long vec_sr (vector long long, vector unsigned long long);
17938 vector unsigned long long char vec_sr (vector unsigned long long,
17939                                        vector unsigned long long);
17941 vector long long vec_sra (vector long long, vector unsigned long long);
17942 vector unsigned long long vec_sra (vector unsigned long long,
17943                                    vector unsigned long long);
17945 vector long long vec_sub (vector long long, vector long long);
17946 vector unsigned long long vec_sub (vector unsigned long long,
17947                                    vector unsigned long long);
17949 vector long long vec_unpackh (vector int);
17950 vector unsigned long long vec_unpackh (vector unsigned int);
17952 vector long long vec_unpackl (vector int);
17953 vector unsigned long long vec_unpackl (vector unsigned int);
17955 vector long long vec_vaddudm (vector long long, vector long long);
17956 vector long long vec_vaddudm (vector bool long long, vector long long);
17957 vector long long vec_vaddudm (vector long long, vector bool long long);
17958 vector unsigned long long vec_vaddudm (vector unsigned long long,
17959                                        vector unsigned long long);
17960 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17961                                        vector unsigned long long);
17962 vector unsigned long long vec_vaddudm (vector unsigned long long,
17963                                        vector bool unsigned long long);
17965 vector long long vec_vbpermq (vector signed char, vector signed char);
17966 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17968 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
17969 vector unsigned char vec_bperm (vector unsigned long long,
17970                                 vector unsigned char);
17971 vector unsigned long long vec_bperm (vector unsigned __int128,
17972                                      vector unsigned char);
17974 vector long long vec_cntlz (vector long long);
17975 vector unsigned long long vec_cntlz (vector unsigned long long);
17976 vector int vec_cntlz (vector int);
17977 vector unsigned int vec_cntlz (vector int);
17978 vector short vec_cntlz (vector short);
17979 vector unsigned short vec_cntlz (vector unsigned short);
17980 vector signed char vec_cntlz (vector signed char);
17981 vector unsigned char vec_cntlz (vector unsigned char);
17983 vector long long vec_vclz (vector long long);
17984 vector unsigned long long vec_vclz (vector unsigned long long);
17985 vector int vec_vclz (vector int);
17986 vector unsigned int vec_vclz (vector int);
17987 vector short vec_vclz (vector short);
17988 vector unsigned short vec_vclz (vector unsigned short);
17989 vector signed char vec_vclz (vector signed char);
17990 vector unsigned char vec_vclz (vector unsigned char);
17992 vector signed char vec_vclzb (vector signed char);
17993 vector unsigned char vec_vclzb (vector unsigned char);
17995 vector long long vec_vclzd (vector long long);
17996 vector unsigned long long vec_vclzd (vector unsigned long long);
17998 vector short vec_vclzh (vector short);
17999 vector unsigned short vec_vclzh (vector unsigned short);
18001 vector int vec_vclzw (vector int);
18002 vector unsigned int vec_vclzw (vector int);
18004 vector signed char vec_vgbbd (vector signed char);
18005 vector unsigned char vec_vgbbd (vector unsigned char);
18007 vector long long vec_vmaxsd (vector long long, vector long long);
18009 vector unsigned long long vec_vmaxud (vector unsigned long long,
18010                                       unsigned vector long long);
18012 vector long long vec_vminsd (vector long long, vector long long);
18014 vector unsigned long long vec_vminud (vector long long,
18015                                       vector long long);
18017 vector int vec_vpksdss (vector long long, vector long long);
18018 vector unsigned int vec_vpksdss (vector long long, vector long long);
18020 vector unsigned int vec_vpkudus (vector unsigned long long,
18021                                  vector unsigned long long);
18023 vector int vec_vpkudum (vector long long, vector long long);
18024 vector unsigned int vec_vpkudum (vector unsigned long long,
18025                                  vector unsigned long long);
18026 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18028 vector long long vec_vpopcnt (vector long long);
18029 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18030 vector int vec_vpopcnt (vector int);
18031 vector unsigned int vec_vpopcnt (vector int);
18032 vector short vec_vpopcnt (vector short);
18033 vector unsigned short vec_vpopcnt (vector unsigned short);
18034 vector signed char vec_vpopcnt (vector signed char);
18035 vector unsigned char vec_vpopcnt (vector unsigned char);
18037 vector signed char vec_vpopcntb (vector signed char);
18038 vector unsigned char vec_vpopcntb (vector unsigned char);
18040 vector long long vec_vpopcntd (vector long long);
18041 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18043 vector short vec_vpopcnth (vector short);
18044 vector unsigned short vec_vpopcnth (vector unsigned short);
18046 vector int vec_vpopcntw (vector int);
18047 vector unsigned int vec_vpopcntw (vector int);
18049 vector long long vec_vrld (vector long long, vector unsigned long long);
18050 vector unsigned long long vec_vrld (vector unsigned long long,
18051                                     vector unsigned long long);
18053 vector long long vec_vsld (vector long long, vector unsigned long long);
18054 vector long long vec_vsld (vector unsigned long long,
18055                            vector unsigned long long);
18057 vector long long vec_vsrad (vector long long, vector unsigned long long);
18058 vector unsigned long long vec_vsrad (vector unsigned long long,
18059                                      vector unsigned long long);
18061 vector long long vec_vsrd (vector long long, vector unsigned long long);
18062 vector unsigned long long char vec_vsrd (vector unsigned long long,
18063                                          vector unsigned long long);
18065 vector long long vec_vsubudm (vector long long, vector long long);
18066 vector long long vec_vsubudm (vector bool long long, vector long long);
18067 vector long long vec_vsubudm (vector long long, vector bool long long);
18068 vector unsigned long long vec_vsubudm (vector unsigned long long,
18069                                        vector unsigned long long);
18070 vector unsigned long long vec_vsubudm (vector bool long long,
18071                                        vector unsigned long long);
18072 vector unsigned long long vec_vsubudm (vector unsigned long long,
18073                                        vector bool long long);
18075 vector long long vec_vupkhsw (vector int);
18076 vector unsigned long long vec_vupkhsw (vector unsigned int);
18078 vector long long vec_vupklsw (vector int);
18079 vector unsigned long long vec_vupklsw (vector int);
18080 @end smallexample
18082 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18083 instruction set are available, the following additional functions are
18084 available for 64-bit targets.  New vector types
18085 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18086 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18087 builtins.
18089 The normal vector extract, and set operations work on
18090 @var{vector __int128_t} and @var{vector __uint128_t} types,
18091 but the index value must be 0.
18093 @smallexample
18094 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18095 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18097 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18098 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18100 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18101                                 vector __int128_t);
18102 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18103                                  vector __uint128_t);
18105 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18106                                 vector __int128_t);
18107 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18108                                  vector __uint128_t);
18110 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18111                                 vector __int128_t);
18112 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18113                                  vector __uint128_t);
18115 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18116                                 vector __int128_t);
18117 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18118                                  vector __uint128_t);
18120 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18121 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18123 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18124 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18126 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
18127 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
18128 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
18129 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
18130 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
18131 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
18132 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
18133 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
18134 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
18135 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
18136 @end smallexample
18138 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18139 are available:
18141 @smallexample
18142 vector unsigned long long vec_bperm (vector unsigned long long,
18143                                      vector unsigned char);
18145 vector bool char vec_cmpne (vector bool char, vector bool char);
18146 vector bool short vec_cmpne (vector bool short, vector bool short);
18147 vector bool int vec_cmpne (vector bool int, vector bool int);
18148 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18150 vector long long vec_vctz (vector long long);
18151 vector unsigned long long vec_vctz (vector unsigned long long);
18152 vector int vec_vctz (vector int);
18153 vector unsigned int vec_vctz (vector int);
18154 vector short vec_vctz (vector short);
18155 vector unsigned short vec_vctz (vector unsigned short);
18156 vector signed char vec_vctz (vector signed char);
18157 vector unsigned char vec_vctz (vector unsigned char);
18159 vector signed char vec_vctzb (vector signed char);
18160 vector unsigned char vec_vctzb (vector unsigned char);
18162 vector long long vec_vctzd (vector long long);
18163 vector unsigned long long vec_vctzd (vector unsigned long long);
18165 vector short vec_vctzh (vector short);
18166 vector unsigned short vec_vctzh (vector unsigned short);
18168 vector int vec_vctzw (vector int);
18169 vector unsigned int vec_vctzw (vector int);
18171 long long vec_vextract4b (const vector signed char, const int);
18172 long long vec_vextract4b (const vector unsigned char, const int);
18174 vector signed char vec_insert4b (vector int, vector signed char, const int);
18175 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18176                                    const int);
18177 vector signed char vec_insert4b (long long, vector signed char, const int);
18178 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
18180 vector int vec_vprtyb (vector int);
18181 vector unsigned int vec_vprtyb (vector unsigned int);
18182 vector long long vec_vprtyb (vector long long);
18183 vector unsigned long long vec_vprtyb (vector unsigned long long);
18185 vector int vec_vprtybw (vector int);
18186 vector unsigned int vec_vprtybw (vector unsigned int);
18188 vector long long vec_vprtybd (vector long long);
18189 vector unsigned long long vec_vprtybd (vector unsigned long long);
18190 @end smallexample
18192 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18193 are available:
18195 @smallexample
18196 vector long vec_vprtyb (vector long);
18197 vector unsigned long vec_vprtyb (vector unsigned long);
18198 vector __int128_t vec_vprtyb (vector __int128_t);
18199 vector __uint128_t vec_vprtyb (vector __uint128_t);
18201 vector long vec_vprtybd (vector long);
18202 vector unsigned long vec_vprtybd (vector unsigned long);
18204 vector __int128_t vec_vprtybq (vector __int128_t);
18205 vector __uint128_t vec_vprtybd (vector __uint128_t);
18206 @end smallexample
18208 The following built-in vector functions are available for the PowerPC family
18209 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18210 @smallexample
18211 __vector unsigned char
18212 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18213 __vector unsigned char
18214 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18215 @end smallexample
18217 The @code{vec_slv} and @code{vec_srv} functions operate on
18218 all of the bytes of their @code{src} and @code{shift_distance}
18219 arguments in parallel.  The behavior of the @code{vec_slv} is as if
18220 there existed a temporary array of 17 unsigned characters
18221 @code{slv_array} within which elements 0 through 15 are the same as
18222 the entries in the @code{src} array and element 16 equals 0.  The
18223 result returned from the @code{vec_slv} function is a
18224 @code{__vector} of 16 unsigned characters within which element
18225 @code{i} is computed using the C expression
18226 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18227 shift_distance[i]))},
18228 with this resulting value coerced to the @code{unsigned char} type.
18229 The behavior of the @code{vec_srv} is as if
18230 there existed a temporary array of 17 unsigned characters
18231 @code{srv_array} within which element 0 equals zero and
18232 elements 1 through 16 equal the elements 0 through 15 of
18233 the @code{src} array.  The
18234 result returned from the @code{vec_srv} function is a
18235 @code{__vector} of 16 unsigned characters within which element
18236 @code{i} is computed using the C expression
18237 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18238 (0x07 & shift_distance[i]))},
18239 with this resulting value coerced to the @code{unsigned char} type.
18241 The following built-in functions are available for the PowerPC family
18242 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18243 @smallexample
18244 __vector unsigned char
18245 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18246 __vector unsigned short
18247 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18248 __vector unsigned int
18249 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18251 __vector unsigned char
18252 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18253 __vector unsigned short
18254 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18255 __vector unsigned int
18256 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18257 @end smallexample
18259 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18260 @code{vec_absdw} built-in functions each computes the absolute
18261 differences of the pairs of vector elements supplied in its two vector
18262 arguments, placing the absolute differences into the corresponding
18263 elements of the vector result.
18265 The following built-in functions are available for the PowerPC family
18266 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18267 @smallexample
18268 __vector unsigned int
18269 vec_extract_exp (__vector float source);
18270 __vector unsigned long long int
18271 vec_extract_exp (__vector double source);
18273 __vector unsigned int
18274 vec_extract_sig (__vector float source);
18275 __vector unsigned long long int
18276 vec_extract_sig (__vector double source);
18278 __vector float
18279 vec_insert_exp (__vector unsigned int significands,
18280                 __vector unsigned int exponents);
18281 __vector float
18282 vec_insert_exp (__vector unsigned float significands,
18283                 __vector unsigned int exponents);
18284 __vector double
18285 vec_insert_exp (__vector unsigned long long int significands,
18286                 __vector unsigned long long int exponents);
18287 __vector double
18288 vec_insert_exp (__vector unsigned double significands,
18289                 __vector unsigned long long int exponents);
18291 __vector bool int vec_test_data_class (__vector float source,
18292                                        const int condition);
18293 __vector bool long long int vec_test_data_class (__vector double source,
18294                                                  const int condition);
18295 @end smallexample
18297 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18298 functions return vectors representing the significands and biased
18299 exponent values of their @code{source} arguments respectively.
18300 Within the result vector returned by @code{vec_extract_sig}, the
18301 @code{0x800000} bit of each vector element returned when the
18302 function's @code{source} argument is of type @code{float} is set to 1
18303 if the corresponding floating point value is in normalized form.
18304 Otherwise, this bit is set to 0.  When the @code{source} argument is
18305 of type @code{double}, the @code{0x10000000000000} bit within each of
18306 the result vector's elements is set according to the same rules.
18307 Note that the sign of the significand is not represented in the result
18308 returned from the @code{vec_extract_sig} function.  To extract the
18309 sign bits, use the
18310 @code{vec_cpsgn} function, which returns a new vector within which all
18311 of the sign bits of its second argument vector are overwritten with the
18312 sign bits copied from the coresponding elements of its first argument
18313 vector, and all other (non-sign) bits of the second argument vector
18314 are copied unchanged into the result vector.
18316 The @code{vec_insert_exp} built-in functions return a vector of
18317 single- or double-precision floating
18318 point values constructed by assembling the values of their
18319 @code{significands} and @code{exponents} arguments into the
18320 corresponding elements of the returned vector.
18321 The sign of each
18322 element of the result is copied from the most significant bit of the
18323 corresponding entry within the @code{significands} argument.
18324 Note that the relevant
18325 bits of the @code{significands} argument are the same, for both integer
18326 and floating point types.
18328 significand and exponent components of each element of the result are
18329 composed of the least significant bits of the corresponding
18330 @code{significands} element and the least significant bits of the
18331 corresponding @code{exponents} element.
18333 The @code{vec_test_data_class} built-in function returns a vector
18334 representing the results of testing the @code{source} vector for the
18335 condition selected by the @code{condition} argument.  The
18336 @code{condition} argument must be a compile-time constant integer with
18337 value not exceeding 127.  The
18338 @code{condition} argument is encoded as a bitmask with each bit
18339 enabling the testing of a different condition, as characterized by the
18340 following:
18341 @smallexample
18342 0x40    Test for NaN
18343 0x20    Test for +Infinity
18344 0x10    Test for -Infinity
18345 0x08    Test for +Zero
18346 0x04    Test for -Zero
18347 0x02    Test for +Denormal
18348 0x01    Test for -Denormal
18349 @end smallexample
18351 If any of the enabled test conditions is true, the corresponding entry
18352 in the result vector is -1.  Otherwise (all of the enabled test
18353 conditions are false), the corresponding entry of the result vector is 0.
18355 The following built-in functions are available for the PowerPC family
18356 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18357 @smallexample
18358 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
18359                               vector unsigned int);
18360 vector unsigned long long vec_rlmi (vector unsigned long long,
18361                                     vector unsigned long long,
18362                                     vector unsigned long long);
18363 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
18364                               vector unsigned int);
18365 vector unsigned long long vec_rlnm (vector unsigned long long,
18366                                     vector unsigned long long,
18367                                     vector unsigned long long);
18368 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
18369 vector unsigned long long vec_vrlnm (vector unsigned long long,
18370                                      vector unsigned long long);
18371 @end smallexample
18373 The result of @code{vec_rlmi} is obtained by rotating each element of
18374 the first argument vector left and inserting it under mask into the
18375 second argument vector.  The third argument vector contains the mask
18376 beginning in bits 11:15, the mask end in bits 19:23, and the shift
18377 count in bits 27:31, of each element.
18379 The result of @code{vec_rlnm} is obtained by rotating each element of
18380 the first argument vector left and ANDing it with a mask specified by
18381 the second and third argument vectors.  The second argument vector
18382 contains the shift count for each element in the low-order byte.  The
18383 third argument vector contains the mask end for each element in the
18384 low-order byte, with the mask begin in the next higher byte.
18386 The result of @code{vec_vrlnm} is obtained by rotating each element
18387 of the first argument vector left and ANDing it with a mask.  The
18388 second argument vector contains the mask  beginning in bits 11:15,
18389 the mask end in bits 19:23, and the shift count in bits 27:31,
18390 of each element.
18392 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18393 are available:
18394 @smallexample
18395 vector signed char vec_revb (vector signed char);
18396 vector unsigned char vec_revb (vector unsigned char);
18397 vector short vec_revb (vector short);
18398 vector unsigned short vec_revb (vector unsigned short);
18399 vector int vec_revb (vector int);
18400 vector unsigned int vec_revb (vector unsigned int);
18401 vector float vec_revb (vector float);
18402 vector long long vec_revb (vector long long);
18403 vector unsigned long long vec_revb (vector unsigned long long);
18404 vector double vec_revb (vector double);
18405 @end smallexample
18407 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18408 are available:
18409 @smallexample
18410 vector long vec_revb (vector long);
18411 vector unsigned long vec_revb (vector unsigned long);
18412 vector __int128_t vec_revb (vector __int128_t);
18413 vector __uint128_t vec_revb (vector __uint128_t);
18414 @end smallexample
18416 The @code{vec_revb} built-in function reverses the bytes on an element
18417 by element basis.  A vector of @code{vector unsigned char} or
18418 @code{vector signed char} reverses the bytes in the whole word.
18420 If the cryptographic instructions are enabled (@option{-mcrypto} or
18421 @option{-mcpu=power8}), the following builtins are enabled.
18423 @smallexample
18424 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
18426 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
18427                                                     vector unsigned long long);
18429 vector unsigned long long __builtin_crypto_vcipherlast
18430                                      (vector unsigned long long,
18431                                       vector unsigned long long);
18433 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
18434                                                      vector unsigned long long);
18436 vector unsigned long long __builtin_crypto_vncipherlast
18437                                      (vector unsigned long long,
18438                                       vector unsigned long long);
18440 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
18441                                                 vector unsigned char,
18442                                                 vector unsigned char);
18444 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
18445                                                  vector unsigned short,
18446                                                  vector unsigned short);
18448 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
18449                                                vector unsigned int,
18450                                                vector unsigned int);
18452 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
18453                                                      vector unsigned long long,
18454                                                      vector unsigned long long);
18456 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
18457                                                vector unsigned char);
18459 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
18460                                                 vector unsigned short);
18462 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
18463                                               vector unsigned int);
18465 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
18466                                                     vector unsigned long long);
18468 vector unsigned long long __builtin_crypto_vshasigmad
18469                                (vector unsigned long long, int, int);
18471 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
18472                                                  int, int);
18473 @end smallexample
18475 The second argument to @var{__builtin_crypto_vshasigmad} and
18476 @var{__builtin_crypto_vshasigmaw} must be a constant
18477 integer that is 0 or 1.  The third argument to these built-in functions
18478 must be a constant integer in the range of 0 to 15.
18480 If the ISA 3.0 instruction set additions 
18481 are enabled (@option{-mcpu=power9}), the following additional
18482 functions are available for both 32-bit and 64-bit targets.
18484 vector short vec_xl (int, vector short *);
18485 vector short vec_xl (int, short *);
18486 vector unsigned short vec_xl (int, vector unsigned short *);
18487 vector unsigned short vec_xl (int, unsigned short *);
18488 vector char vec_xl (int, vector char *);
18489 vector char vec_xl (int, char *);
18490 vector unsigned char vec_xl (int, vector unsigned char *);
18491 vector unsigned char vec_xl (int, unsigned char *);
18493 void vec_xst (vector short, int, vector short *);
18494 void vec_xst (vector short, int, short *);
18495 void vec_xst (vector unsigned short, int, vector unsigned short *);
18496 void vec_xst (vector unsigned short, int, unsigned short *);
18497 void vec_xst (vector char, int, vector char *);
18498 void vec_xst (vector char, int, char *);
18499 void vec_xst (vector unsigned char, int, vector unsigned char *);
18500 void vec_xst (vector unsigned char, int, unsigned char *);
18502 @node PowerPC Hardware Transactional Memory Built-in Functions
18503 @subsection PowerPC Hardware Transactional Memory Built-in Functions
18504 GCC provides two interfaces for accessing the Hardware Transactional
18505 Memory (HTM) instructions available on some of the PowerPC family
18506 of processors (eg, POWER8).  The two interfaces come in a low level
18507 interface, consisting of built-in functions specific to PowerPC and a
18508 higher level interface consisting of inline functions that are common
18509 between PowerPC and S/390.
18511 @subsubsection PowerPC HTM Low Level Built-in Functions
18513 The following low level built-in functions are available with
18514 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
18515 They all generate the machine instruction that is part of the name.
18517 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
18518 the full 4-bit condition register value set by their associated hardware
18519 instruction.  The header file @code{htmintrin.h} defines some macros that can
18520 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
18521 returns a simple true or false value depending on whether a transaction was
18522 successfully started or not.  The arguments of the builtins match exactly the
18523 type and order of the associated hardware instruction's operands, except for
18524 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18525 Refer to the ISA manual for a description of each instruction's operands.
18527 @smallexample
18528 unsigned int __builtin_tbegin (unsigned int)
18529 unsigned int __builtin_tend (unsigned int)
18531 unsigned int __builtin_tabort (unsigned int)
18532 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18533 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18534 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18535 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18537 unsigned int __builtin_tcheck (void)
18538 unsigned int __builtin_treclaim (unsigned int)
18539 unsigned int __builtin_trechkpt (void)
18540 unsigned int __builtin_tsr (unsigned int)
18541 @end smallexample
18543 In addition to the above HTM built-ins, we have added built-ins for
18544 some common extended mnemonics of the HTM instructions:
18546 @smallexample
18547 unsigned int __builtin_tendall (void)
18548 unsigned int __builtin_tresume (void)
18549 unsigned int __builtin_tsuspend (void)
18550 @end smallexample
18552 Note that the semantics of the above HTM builtins are required to mimic
18553 the locking semantics used for critical sections.  Builtins that are used
18554 to create a new transaction or restart a suspended transaction must have
18555 lock acquisition like semantics while those builtins that end or suspend a
18556 transaction must have lock release like semantics.  Specifically, this must
18557 mimic lock semantics as specified by C++11, for example: Lock acquisition is
18558 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
18559 that returns 0, and lock release is as-if an execution of
18560 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
18561 implicit implementation-defined lock used for all transactions.  The HTM
18562 instructions associated with with the builtins inherently provide the
18563 correct acquisition and release hardware barriers required.  However,
18564 the compiler must also be prohibited from moving loads and stores across
18565 the builtins in a way that would violate their semantics.  This has been
18566 accomplished by adding memory barriers to the associated HTM instructions
18567 (which is a conservative approach to provide acquire and release semantics).
18568 Earlier versions of the compiler did not treat the HTM instructions as
18569 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
18570 be used to determine whether the current compiler treats HTM instructions
18571 as memory barriers or not.  This allows the user to explicitly add memory
18572 barriers to their code when using an older version of the compiler.
18574 The following set of built-in functions are available to gain access
18575 to the HTM specific special purpose registers.
18577 @smallexample
18578 unsigned long __builtin_get_texasr (void)
18579 unsigned long __builtin_get_texasru (void)
18580 unsigned long __builtin_get_tfhar (void)
18581 unsigned long __builtin_get_tfiar (void)
18583 void __builtin_set_texasr (unsigned long);
18584 void __builtin_set_texasru (unsigned long);
18585 void __builtin_set_tfhar (unsigned long);
18586 void __builtin_set_tfiar (unsigned long);
18587 @end smallexample
18589 Example usage of these low level built-in functions may look like:
18591 @smallexample
18592 #include <htmintrin.h>
18594 int num_retries = 10;
18596 while (1)
18597   @{
18598     if (__builtin_tbegin (0))
18599       @{
18600         /* Transaction State Initiated.  */
18601         if (is_locked (lock))
18602           __builtin_tabort (0);
18603         ... transaction code...
18604         __builtin_tend (0);
18605         break;
18606       @}
18607     else
18608       @{
18609         /* Transaction State Failed.  Use locks if the transaction
18610            failure is "persistent" or we've tried too many times.  */
18611         if (num_retries-- <= 0
18612             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18613           @{
18614             acquire_lock (lock);
18615             ... non transactional fallback path...
18616             release_lock (lock);
18617             break;
18618           @}
18619       @}
18620   @}
18621 @end smallexample
18623 One final built-in function has been added that returns the value of
18624 the 2-bit Transaction State field of the Machine Status Register (MSR)
18625 as stored in @code{CR0}.
18627 @smallexample
18628 unsigned long __builtin_ttest (void)
18629 @end smallexample
18631 This built-in can be used to determine the current transaction state
18632 using the following code example:
18634 @smallexample
18635 #include <htmintrin.h>
18637 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
18639 if (tx_state == _HTM_TRANSACTIONAL)
18640   @{
18641     /* Code to use in transactional state.  */
18642   @}
18643 else if (tx_state == _HTM_NONTRANSACTIONAL)
18644   @{
18645     /* Code to use in non-transactional state.  */
18646   @}
18647 else if (tx_state == _HTM_SUSPENDED)
18648   @{
18649     /* Code to use in transaction suspended state.  */
18650   @}
18651 @end smallexample
18653 @subsubsection PowerPC HTM High Level Inline Functions
18655 The following high level HTM interface is made available by including
18656 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18657 where CPU is `power8' or later.  This interface is common between PowerPC
18658 and S/390, allowing users to write one HTM source implementation that
18659 can be compiled and executed on either system.
18661 @smallexample
18662 long __TM_simple_begin (void)
18663 long __TM_begin (void* const TM_buff)
18664 long __TM_end (void)
18665 void __TM_abort (void)
18666 void __TM_named_abort (unsigned char const code)
18667 void __TM_resume (void)
18668 void __TM_suspend (void)
18670 long __TM_is_user_abort (void* const TM_buff)
18671 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18672 long __TM_is_illegal (void* const TM_buff)
18673 long __TM_is_footprint_exceeded (void* const TM_buff)
18674 long __TM_nesting_depth (void* const TM_buff)
18675 long __TM_is_nested_too_deep(void* const TM_buff)
18676 long __TM_is_conflict(void* const TM_buff)
18677 long __TM_is_failure_persistent(void* const TM_buff)
18678 long __TM_failure_address(void* const TM_buff)
18679 long long __TM_failure_code(void* const TM_buff)
18680 @end smallexample
18682 Using these common set of HTM inline functions, we can create
18683 a more portable version of the HTM example in the previous
18684 section that will work on either PowerPC or S/390:
18686 @smallexample
18687 #include <htmxlintrin.h>
18689 int num_retries = 10;
18690 TM_buff_type TM_buff;
18692 while (1)
18693   @{
18694     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18695       @{
18696         /* Transaction State Initiated.  */
18697         if (is_locked (lock))
18698           __TM_abort ();
18699         ... transaction code...
18700         __TM_end ();
18701         break;
18702       @}
18703     else
18704       @{
18705         /* Transaction State Failed.  Use locks if the transaction
18706            failure is "persistent" or we've tried too many times.  */
18707         if (num_retries-- <= 0
18708             || __TM_is_failure_persistent (TM_buff))
18709           @{
18710             acquire_lock (lock);
18711             ... non transactional fallback path...
18712             release_lock (lock);
18713             break;
18714           @}
18715       @}
18716   @}
18717 @end smallexample
18719 @node RX Built-in Functions
18720 @subsection RX Built-in Functions
18721 GCC supports some of the RX instructions which cannot be expressed in
18722 the C programming language via the use of built-in functions.  The
18723 following functions are supported:
18725 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
18726 Generates the @code{brk} machine instruction.
18727 @end deftypefn
18729 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
18730 Generates the @code{clrpsw} machine instruction to clear the specified
18731 bit in the processor status word.
18732 @end deftypefn
18734 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
18735 Generates the @code{int} machine instruction to generate an interrupt
18736 with the specified value.
18737 @end deftypefn
18739 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
18740 Generates the @code{machi} machine instruction to add the result of
18741 multiplying the top 16 bits of the two arguments into the
18742 accumulator.
18743 @end deftypefn
18745 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
18746 Generates the @code{maclo} machine instruction to add the result of
18747 multiplying the bottom 16 bits of the two arguments into the
18748 accumulator.
18749 @end deftypefn
18751 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
18752 Generates the @code{mulhi} machine instruction to place the result of
18753 multiplying the top 16 bits of the two arguments into the
18754 accumulator.
18755 @end deftypefn
18757 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
18758 Generates the @code{mullo} machine instruction to place the result of
18759 multiplying the bottom 16 bits of the two arguments into the
18760 accumulator.
18761 @end deftypefn
18763 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
18764 Generates the @code{mvfachi} machine instruction to read the top
18765 32 bits of the accumulator.
18766 @end deftypefn
18768 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
18769 Generates the @code{mvfacmi} machine instruction to read the middle
18770 32 bits of the accumulator.
18771 @end deftypefn
18773 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
18774 Generates the @code{mvfc} machine instruction which reads the control
18775 register specified in its argument and returns its value.
18776 @end deftypefn
18778 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
18779 Generates the @code{mvtachi} machine instruction to set the top
18780 32 bits of the accumulator.
18781 @end deftypefn
18783 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
18784 Generates the @code{mvtaclo} machine instruction to set the bottom
18785 32 bits of the accumulator.
18786 @end deftypefn
18788 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
18789 Generates the @code{mvtc} machine instruction which sets control
18790 register number @code{reg} to @code{val}.
18791 @end deftypefn
18793 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
18794 Generates the @code{mvtipl} machine instruction set the interrupt
18795 priority level.
18796 @end deftypefn
18798 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
18799 Generates the @code{racw} machine instruction to round the accumulator
18800 according to the specified mode.
18801 @end deftypefn
18803 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
18804 Generates the @code{revw} machine instruction which swaps the bytes in
18805 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18806 and also bits 16--23 occupy bits 24--31 and vice versa.
18807 @end deftypefn
18809 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
18810 Generates the @code{rmpa} machine instruction which initiates a
18811 repeated multiply and accumulate sequence.
18812 @end deftypefn
18814 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
18815 Generates the @code{round} machine instruction which returns the
18816 floating-point argument rounded according to the current rounding mode
18817 set in the floating-point status word register.
18818 @end deftypefn
18820 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
18821 Generates the @code{sat} machine instruction which returns the
18822 saturated value of the argument.
18823 @end deftypefn
18825 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
18826 Generates the @code{setpsw} machine instruction to set the specified
18827 bit in the processor status word.
18828 @end deftypefn
18830 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
18831 Generates the @code{wait} machine instruction.
18832 @end deftypefn
18834 @node S/390 System z Built-in Functions
18835 @subsection S/390 System z Built-in Functions
18836 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18837 Generates the @code{tbegin} machine instruction starting a
18838 non-constrained hardware transaction.  If the parameter is non-NULL the
18839 memory area is used to store the transaction diagnostic buffer and
18840 will be passed as first operand to @code{tbegin}.  This buffer can be
18841 defined using the @code{struct __htm_tdb} C struct defined in
18842 @code{htmintrin.h} and must reside on a double-word boundary.  The
18843 second tbegin operand is set to @code{0xff0c}. This enables
18844 save/restore of all GPRs and disables aborts for FPR and AR
18845 manipulations inside the transaction body.  The condition code set by
18846 the tbegin instruction is returned as integer value.  The tbegin
18847 instruction by definition overwrites the content of all FPRs.  The
18848 compiler will generate code which saves and restores the FPRs.  For
18849 soft-float code it is recommended to used the @code{*_nofloat}
18850 variant.  In order to prevent a TDB from being written it is required
18851 to pass a constant zero value as parameter.  Passing a zero value
18852 through a variable is not sufficient.  Although modifications of
18853 access registers inside the transaction will not trigger an
18854 transaction abort it is not supported to actually modify them.  Access
18855 registers do not get saved when entering a transaction. They will have
18856 undefined state when reaching the abort code.
18857 @end deftypefn
18859 Macros for the possible return codes of tbegin are defined in the
18860 @code{htmintrin.h} header file:
18862 @table @code
18863 @item _HTM_TBEGIN_STARTED
18864 @code{tbegin} has been executed as part of normal processing.  The
18865 transaction body is supposed to be executed.
18866 @item _HTM_TBEGIN_INDETERMINATE
18867 The transaction was aborted due to an indeterminate condition which
18868 might be persistent.
18869 @item _HTM_TBEGIN_TRANSIENT
18870 The transaction aborted due to a transient failure.  The transaction
18871 should be re-executed in that case.
18872 @item _HTM_TBEGIN_PERSISTENT
18873 The transaction aborted due to a persistent failure.  Re-execution
18874 under same circumstances will not be productive.
18875 @end table
18877 @defmac _HTM_FIRST_USER_ABORT_CODE
18878 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18879 specifies the first abort code which can be used for
18880 @code{__builtin_tabort}.  Values below this threshold are reserved for
18881 machine use.
18882 @end defmac
18884 @deftp {Data type} {struct __htm_tdb}
18885 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18886 the structure of the transaction diagnostic block as specified in the
18887 Principles of Operation manual chapter 5-91.
18888 @end deftp
18890 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18891 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18892 Using this variant in code making use of FPRs will leave the FPRs in
18893 undefined state when entering the transaction abort handler code.
18894 @end deftypefn
18896 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18897 In addition to @code{__builtin_tbegin} a loop for transient failures
18898 is generated.  If tbegin returns a condition code of 2 the transaction
18899 will be retried as often as specified in the second argument.  The
18900 perform processor assist instruction is used to tell the CPU about the
18901 number of fails so far.
18902 @end deftypefn
18904 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18905 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18906 restores.  Using this variant in code making use of FPRs will leave
18907 the FPRs in undefined state when entering the transaction abort
18908 handler code.
18909 @end deftypefn
18911 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18912 Generates the @code{tbeginc} machine instruction starting a constrained
18913 hardware transaction.  The second operand is set to @code{0xff08}.
18914 @end deftypefn
18916 @deftypefn {Built-in Function} int __builtin_tend (void)
18917 Generates the @code{tend} machine instruction finishing a transaction
18918 and making the changes visible to other threads.  The condition code
18919 generated by tend is returned as integer value.
18920 @end deftypefn
18922 @deftypefn {Built-in Function} void __builtin_tabort (int)
18923 Generates the @code{tabort} machine instruction with the specified
18924 abort code.  Abort codes from 0 through 255 are reserved and will
18925 result in an error message.
18926 @end deftypefn
18928 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
18929 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
18930 integer parameter is loaded into rX and a value of zero is loaded into
18931 rY.  The integer parameter specifies the number of times the
18932 transaction repeatedly aborted.
18933 @end deftypefn
18935 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
18936 Generates the @code{etnd} machine instruction.  The current nesting
18937 depth is returned as integer value.  For a nesting depth of 0 the code
18938 is not executed as part of an transaction.
18939 @end deftypefn
18941 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
18943 Generates the @code{ntstg} machine instruction.  The second argument
18944 is written to the first arguments location.  The store operation will
18945 not be rolled-back in case of an transaction abort.
18946 @end deftypefn
18948 @node SH Built-in Functions
18949 @subsection SH Built-in Functions
18950 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
18951 families of processors:
18953 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
18954 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
18955 used by system code that manages threads and execution contexts.  The compiler
18956 normally does not generate code that modifies the contents of @samp{GBR} and
18957 thus the value is preserved across function calls.  Changing the @samp{GBR}
18958 value in user code must be done with caution, since the compiler might use
18959 @samp{GBR} in order to access thread local variables.
18961 @end deftypefn
18963 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
18964 Returns the value that is currently set in the @samp{GBR} register.
18965 Memory loads and stores that use the thread pointer as a base address are
18966 turned into @samp{GBR} based displacement loads and stores, if possible.
18967 For example:
18968 @smallexample
18969 struct my_tcb
18971    int a, b, c, d, e;
18974 int get_tcb_value (void)
18976   // Generate @samp{mov.l @@(8,gbr),r0} instruction
18977   return ((my_tcb*)__builtin_thread_pointer ())->c;
18980 @end smallexample
18981 @end deftypefn
18983 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18984 Returns the value that is currently set in the @samp{FPSCR} register.
18985 @end deftypefn
18987 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18988 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18989 preserving the current values of the FR, SZ and PR bits.
18990 @end deftypefn
18992 @node SPARC VIS Built-in Functions
18993 @subsection SPARC VIS Built-in Functions
18995 GCC supports SIMD operations on the SPARC using both the generic vector
18996 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18997 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
18998 switch, the VIS extension is exposed as the following built-in functions:
19000 @smallexample
19001 typedef int v1si __attribute__ ((vector_size (4)));
19002 typedef int v2si __attribute__ ((vector_size (8)));
19003 typedef short v4hi __attribute__ ((vector_size (8)));
19004 typedef short v2hi __attribute__ ((vector_size (4)));
19005 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19006 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19008 void __builtin_vis_write_gsr (int64_t);
19009 int64_t __builtin_vis_read_gsr (void);
19011 void * __builtin_vis_alignaddr (void *, long);
19012 void * __builtin_vis_alignaddrl (void *, long);
19013 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19014 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19015 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19016 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19018 v4hi __builtin_vis_fexpand (v4qi);
19020 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19021 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19022 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19023 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19024 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19025 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19026 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19028 v4qi __builtin_vis_fpack16 (v4hi);
19029 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19030 v2hi __builtin_vis_fpackfix (v2si);
19031 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19033 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19035 long __builtin_vis_edge8 (void *, void *);
19036 long __builtin_vis_edge8l (void *, void *);
19037 long __builtin_vis_edge16 (void *, void *);
19038 long __builtin_vis_edge16l (void *, void *);
19039 long __builtin_vis_edge32 (void *, void *);
19040 long __builtin_vis_edge32l (void *, void *);
19042 long __builtin_vis_fcmple16 (v4hi, v4hi);
19043 long __builtin_vis_fcmple32 (v2si, v2si);
19044 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19045 long __builtin_vis_fcmpne32 (v2si, v2si);
19046 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19047 long __builtin_vis_fcmpgt32 (v2si, v2si);
19048 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19049 long __builtin_vis_fcmpeq32 (v2si, v2si);
19051 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19052 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19053 v2si __builtin_vis_fpadd32 (v2si, v2si);
19054 v1si __builtin_vis_fpadd32s (v1si, v1si);
19055 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19056 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19057 v2si __builtin_vis_fpsub32 (v2si, v2si);
19058 v1si __builtin_vis_fpsub32s (v1si, v1si);
19060 long __builtin_vis_array8 (long, long);
19061 long __builtin_vis_array16 (long, long);
19062 long __builtin_vis_array32 (long, long);
19063 @end smallexample
19065 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19066 functions also become available:
19068 @smallexample
19069 long __builtin_vis_bmask (long, long);
19070 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19071 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19072 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19073 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19075 long __builtin_vis_edge8n (void *, void *);
19076 long __builtin_vis_edge8ln (void *, void *);
19077 long __builtin_vis_edge16n (void *, void *);
19078 long __builtin_vis_edge16ln (void *, void *);
19079 long __builtin_vis_edge32n (void *, void *);
19080 long __builtin_vis_edge32ln (void *, void *);
19081 @end smallexample
19083 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19084 functions also become available:
19086 @smallexample
19087 void __builtin_vis_cmask8 (long);
19088 void __builtin_vis_cmask16 (long);
19089 void __builtin_vis_cmask32 (long);
19091 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19093 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19094 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19095 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19096 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19097 v2si __builtin_vis_fsll16 (v2si, v2si);
19098 v2si __builtin_vis_fslas16 (v2si, v2si);
19099 v2si __builtin_vis_fsrl16 (v2si, v2si);
19100 v2si __builtin_vis_fsra16 (v2si, v2si);
19102 long __builtin_vis_pdistn (v8qi, v8qi);
19104 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19106 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19107 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19109 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19110 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19111 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19112 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19113 v2si __builtin_vis_fpadds32 (v2si, v2si);
19114 v1si __builtin_vis_fpadds32s (v1si, v1si);
19115 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19116 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19118 long __builtin_vis_fucmple8 (v8qi, v8qi);
19119 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19120 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19121 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19123 float __builtin_vis_fhadds (float, float);
19124 double __builtin_vis_fhaddd (double, double);
19125 float __builtin_vis_fhsubs (float, float);
19126 double __builtin_vis_fhsubd (double, double);
19127 float __builtin_vis_fnhadds (float, float);
19128 double __builtin_vis_fnhaddd (double, double);
19130 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19131 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19132 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19133 @end smallexample
19135 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19136 functions also become available:
19138 @smallexample
19139 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19140 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19141 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19142 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19144 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19145 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19146 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19147 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19149 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19150 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19151 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19152 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19153 long __builtin_vis_fpcmpule32 (v2si, v2si);
19154 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19156 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19157 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19158 v2si __builtin_vis_fpmax32 (v2si, v2si);
19160 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19161 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19162 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19165 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19166 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19167 v2si __builtin_vis_fpmin32 (v2si, v2si);
19169 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19170 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19171 v2si __builtin_vis_fpminu32 (v2si, v2si);
19172 @end smallexample
19174 @node SPU Built-in Functions
19175 @subsection SPU Built-in Functions
19177 GCC provides extensions for the SPU processor as described in the
19178 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
19179 implementation differs in several ways.
19181 @itemize @bullet
19183 @item
19184 The optional extension of specifying vector constants in parentheses is
19185 not supported.
19187 @item
19188 A vector initializer requires no cast if the vector constant is of the
19189 same type as the variable it is initializing.
19191 @item
19192 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19193 vector type is the default signedness of the base type.  The default
19194 varies depending on the operating system, so a portable program should
19195 always specify the signedness.
19197 @item
19198 By default, the keyword @code{__vector} is added. The macro
19199 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19200 undefined.
19202 @item
19203 GCC allows using a @code{typedef} name as the type specifier for a
19204 vector type.
19206 @item
19207 For C, overloaded functions are implemented with macros so the following
19208 does not work:
19210 @smallexample
19211   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
19212 @end smallexample
19214 @noindent
19215 Since @code{spu_add} is a macro, the vector constant in the example
19216 is treated as four separate arguments.  Wrap the entire argument in
19217 parentheses for this to work.
19219 @item
19220 The extended version of @code{__builtin_expect} is not supported.
19222 @end itemize
19224 @emph{Note:} Only the interface described in the aforementioned
19225 specification is supported. Internally, GCC uses built-in functions to
19226 implement the required functionality, but these are not supported and
19227 are subject to change without notice.
19229 @node TI C6X Built-in Functions
19230 @subsection TI C6X Built-in Functions
19232 GCC provides intrinsics to access certain instructions of the TI C6X
19233 processors.  These intrinsics, listed below, are available after
19234 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
19235 to C6X instructions.
19237 @smallexample
19239 int _sadd (int, int)
19240 int _ssub (int, int)
19241 int _sadd2 (int, int)
19242 int _ssub2 (int, int)
19243 long long _mpy2 (int, int)
19244 long long _smpy2 (int, int)
19245 int _add4 (int, int)
19246 int _sub4 (int, int)
19247 int _saddu4 (int, int)
19249 int _smpy (int, int)
19250 int _smpyh (int, int)
19251 int _smpyhl (int, int)
19252 int _smpylh (int, int)
19254 int _sshl (int, int)
19255 int _subc (int, int)
19257 int _avg2 (int, int)
19258 int _avgu4 (int, int)
19260 int _clrr (int, int)
19261 int _extr (int, int)
19262 int _extru (int, int)
19263 int _abs (int)
19264 int _abs2 (int)
19266 @end smallexample
19268 @node TILE-Gx Built-in Functions
19269 @subsection TILE-Gx Built-in Functions
19271 GCC provides intrinsics to access every instruction of the TILE-Gx
19272 processor.  The intrinsics are of the form:
19274 @smallexample
19276 unsigned long long __insn_@var{op} (...)
19278 @end smallexample
19280 Where @var{op} is the name of the instruction.  Refer to the ISA manual
19281 for the complete list of instructions.
19283 GCC also provides intrinsics to directly access the network registers.
19284 The intrinsics are:
19286 @smallexample
19288 unsigned long long __tile_idn0_receive (void)
19289 unsigned long long __tile_idn1_receive (void)
19290 unsigned long long __tile_udn0_receive (void)
19291 unsigned long long __tile_udn1_receive (void)
19292 unsigned long long __tile_udn2_receive (void)
19293 unsigned long long __tile_udn3_receive (void)
19294 void __tile_idn_send (unsigned long long)
19295 void __tile_udn_send (unsigned long long)
19297 @end smallexample
19299 The intrinsic @code{void __tile_network_barrier (void)} is used to
19300 guarantee that no network operations before it are reordered with
19301 those after it.
19303 @node TILEPro Built-in Functions
19304 @subsection TILEPro Built-in Functions
19306 GCC provides intrinsics to access every instruction of the TILEPro
19307 processor.  The intrinsics are of the form:
19309 @smallexample
19311 unsigned __insn_@var{op} (...)
19313 @end smallexample
19315 @noindent
19316 where @var{op} is the name of the instruction.  Refer to the ISA manual
19317 for the complete list of instructions.
19319 GCC also provides intrinsics to directly access the network registers.
19320 The intrinsics are:
19322 @smallexample
19324 unsigned __tile_idn0_receive (void)
19325 unsigned __tile_idn1_receive (void)
19326 unsigned __tile_sn_receive (void)
19327 unsigned __tile_udn0_receive (void)
19328 unsigned __tile_udn1_receive (void)
19329 unsigned __tile_udn2_receive (void)
19330 unsigned __tile_udn3_receive (void)
19331 void __tile_idn_send (unsigned)
19332 void __tile_sn_send (unsigned)
19333 void __tile_udn_send (unsigned)
19335 @end smallexample
19337 The intrinsic @code{void __tile_network_barrier (void)} is used to
19338 guarantee that no network operations before it are reordered with
19339 those after it.
19341 @node x86 Built-in Functions
19342 @subsection x86 Built-in Functions
19344 These built-in functions are available for the x86-32 and x86-64 family
19345 of computers, depending on the command-line switches used.
19347 If you specify command-line switches such as @option{-msse},
19348 the compiler could use the extended instruction sets even if the built-ins
19349 are not used explicitly in the program.  For this reason, applications
19350 that perform run-time CPU detection must compile separate files for each
19351 supported architecture, using the appropriate flags.  In particular,
19352 the file containing the CPU detection code should be compiled without
19353 these options.
19355 The following machine modes are available for use with MMX built-in functions
19356 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
19357 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
19358 vector of eight 8-bit integers.  Some of the built-in functions operate on
19359 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
19361 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
19362 of two 32-bit floating-point values.
19364 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
19365 floating-point values.  Some instructions use a vector of four 32-bit
19366 integers, these use @code{V4SI}.  Finally, some instructions operate on an
19367 entire vector register, interpreting it as a 128-bit integer, these use mode
19368 @code{TI}.
19370 The x86-32 and x86-64 family of processors use additional built-in
19371 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
19372 floating point and @code{TC} 128-bit complex floating-point values.
19374 The following floating-point built-in functions are always available.  All
19375 of them implement the function that is part of the name.
19377 @smallexample
19378 __float128 __builtin_fabsq (__float128)
19379 __float128 __builtin_copysignq (__float128, __float128)
19380 @end smallexample
19382 The following built-in functions are always available.
19384 @table @code
19385 @item __float128 __builtin_infq (void)
19386 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
19387 @findex __builtin_infq
19389 @item __float128 __builtin_huge_valq (void)
19390 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
19391 @findex __builtin_huge_valq
19393 @item __float128 __builtin_nanq (void)
19394 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
19395 @findex __builtin_nanq
19397 @item __float128 __builtin_nansq (void)
19398 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
19399 @findex __builtin_nansq
19400 @end table
19402 The following built-in function is always available.
19404 @table @code
19405 @item void __builtin_ia32_pause (void)
19406 Generates the @code{pause} machine instruction with a compiler memory
19407 barrier.
19408 @end table
19410 The following built-in functions are always available and can be used to
19411 check the target platform type.
19413 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
19414 This function runs the CPU detection code to check the type of CPU and the
19415 features supported.  This built-in function needs to be invoked along with the built-in functions
19416 to check CPU type and features, @code{__builtin_cpu_is} and
19417 @code{__builtin_cpu_supports}, only when used in a function that is
19418 executed before any constructors are called.  The CPU detection code is
19419 automatically executed in a very high priority constructor.
19421 For example, this function has to be used in @code{ifunc} resolvers that
19422 check for CPU type using the built-in functions @code{__builtin_cpu_is}
19423 and @code{__builtin_cpu_supports}, or in constructors on targets that
19424 don't support constructor priority.
19425 @smallexample
19427 static void (*resolve_memcpy (void)) (void)
19429   // ifunc resolvers fire before constructors, explicitly call the init
19430   // function.
19431   __builtin_cpu_init ();
19432   if (__builtin_cpu_supports ("ssse3"))
19433     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
19434   else
19435     return default_memcpy;
19438 void *memcpy (void *, const void *, size_t)
19439      __attribute__ ((ifunc ("resolve_memcpy")));
19440 @end smallexample
19442 @end deftypefn
19444 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
19445 This function returns a positive integer if the run-time CPU
19446 is of type @var{cpuname}
19447 and returns @code{0} otherwise. The following CPU names can be detected:
19449 @table @samp
19450 @item intel
19451 Intel CPU.
19453 @item atom
19454 Intel Atom CPU.
19456 @item core2
19457 Intel Core 2 CPU.
19459 @item corei7
19460 Intel Core i7 CPU.
19462 @item nehalem
19463 Intel Core i7 Nehalem CPU.
19465 @item westmere
19466 Intel Core i7 Westmere CPU.
19468 @item sandybridge
19469 Intel Core i7 Sandy Bridge CPU.
19471 @item amd
19472 AMD CPU.
19474 @item amdfam10h
19475 AMD Family 10h CPU.
19477 @item barcelona
19478 AMD Family 10h Barcelona CPU.
19480 @item shanghai
19481 AMD Family 10h Shanghai CPU.
19483 @item istanbul
19484 AMD Family 10h Istanbul CPU.
19486 @item btver1
19487 AMD Family 14h CPU.
19489 @item amdfam15h
19490 AMD Family 15h CPU.
19492 @item bdver1
19493 AMD Family 15h Bulldozer version 1.
19495 @item bdver2
19496 AMD Family 15h Bulldozer version 2.
19498 @item bdver3
19499 AMD Family 15h Bulldozer version 3.
19501 @item bdver4
19502 AMD Family 15h Bulldozer version 4.
19504 @item btver2
19505 AMD Family 16h CPU.
19507 @item znver1
19508 AMD Family 17h CPU.
19509 @end table
19511 Here is an example:
19512 @smallexample
19513 if (__builtin_cpu_is ("corei7"))
19514   @{
19515      do_corei7 (); // Core i7 specific implementation.
19516   @}
19517 else
19518   @{
19519      do_generic (); // Generic implementation.
19520   @}
19521 @end smallexample
19522 @end deftypefn
19524 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
19525 This function returns a positive integer if the run-time CPU
19526 supports @var{feature}
19527 and returns @code{0} otherwise. The following features can be detected:
19529 @table @samp
19530 @item cmov
19531 CMOV instruction.
19532 @item mmx
19533 MMX instructions.
19534 @item popcnt
19535 POPCNT instruction.
19536 @item sse
19537 SSE instructions.
19538 @item sse2
19539 SSE2 instructions.
19540 @item sse3
19541 SSE3 instructions.
19542 @item ssse3
19543 SSSE3 instructions.
19544 @item sse4.1
19545 SSE4.1 instructions.
19546 @item sse4.2
19547 SSE4.2 instructions.
19548 @item avx
19549 AVX instructions.
19550 @item avx2
19551 AVX2 instructions.
19552 @item avx512f
19553 AVX512F instructions.
19554 @end table
19556 Here is an example:
19557 @smallexample
19558 if (__builtin_cpu_supports ("popcnt"))
19559   @{
19560      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
19561   @}
19562 else
19563   @{
19564      count = generic_countbits (n); //generic implementation.
19565   @}
19566 @end smallexample
19567 @end deftypefn
19570 The following built-in functions are made available by @option{-mmmx}.
19571 All of them generate the machine instruction that is part of the name.
19573 @smallexample
19574 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19575 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19576 v2si __builtin_ia32_paddd (v2si, v2si)
19577 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19578 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19579 v2si __builtin_ia32_psubd (v2si, v2si)
19580 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19581 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19582 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19583 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19584 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19585 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19586 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19587 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19588 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19589 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19590 di __builtin_ia32_pand (di, di)
19591 di __builtin_ia32_pandn (di,di)
19592 di __builtin_ia32_por (di, di)
19593 di __builtin_ia32_pxor (di, di)
19594 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
19595 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
19596 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
19597 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
19598 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
19599 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
19600 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
19601 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
19602 v2si __builtin_ia32_punpckhdq (v2si, v2si)
19603 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
19604 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
19605 v2si __builtin_ia32_punpckldq (v2si, v2si)
19606 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
19607 v4hi __builtin_ia32_packssdw (v2si, v2si)
19608 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
19610 v4hi __builtin_ia32_psllw (v4hi, v4hi)
19611 v2si __builtin_ia32_pslld (v2si, v2si)
19612 v1di __builtin_ia32_psllq (v1di, v1di)
19613 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
19614 v2si __builtin_ia32_psrld (v2si, v2si)
19615 v1di __builtin_ia32_psrlq (v1di, v1di)
19616 v4hi __builtin_ia32_psraw (v4hi, v4hi)
19617 v2si __builtin_ia32_psrad (v2si, v2si)
19618 v4hi __builtin_ia32_psllwi (v4hi, int)
19619 v2si __builtin_ia32_pslldi (v2si, int)
19620 v1di __builtin_ia32_psllqi (v1di, int)
19621 v4hi __builtin_ia32_psrlwi (v4hi, int)
19622 v2si __builtin_ia32_psrldi (v2si, int)
19623 v1di __builtin_ia32_psrlqi (v1di, int)
19624 v4hi __builtin_ia32_psrawi (v4hi, int)
19625 v2si __builtin_ia32_psradi (v2si, int)
19627 @end smallexample
19629 The following built-in functions are made available either with
19630 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
19631 the machine instruction that is part of the name.
19633 @smallexample
19634 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
19635 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
19636 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
19637 v1di __builtin_ia32_psadbw (v8qi, v8qi)
19638 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
19639 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19640 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19641 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19642 int __builtin_ia32_pmovmskb (v8qi)
19643 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19644 void __builtin_ia32_movntq (di *, di)
19645 void __builtin_ia32_sfence (void)
19646 @end smallexample
19648 The following built-in functions are available when @option{-msse} is used.
19649 All of them generate the machine instruction that is part of the name.
19651 @smallexample
19652 int __builtin_ia32_comieq (v4sf, v4sf)
19653 int __builtin_ia32_comineq (v4sf, v4sf)
19654 int __builtin_ia32_comilt (v4sf, v4sf)
19655 int __builtin_ia32_comile (v4sf, v4sf)
19656 int __builtin_ia32_comigt (v4sf, v4sf)
19657 int __builtin_ia32_comige (v4sf, v4sf)
19658 int __builtin_ia32_ucomieq (v4sf, v4sf)
19659 int __builtin_ia32_ucomineq (v4sf, v4sf)
19660 int __builtin_ia32_ucomilt (v4sf, v4sf)
19661 int __builtin_ia32_ucomile (v4sf, v4sf)
19662 int __builtin_ia32_ucomigt (v4sf, v4sf)
19663 int __builtin_ia32_ucomige (v4sf, v4sf)
19664 v4sf __builtin_ia32_addps (v4sf, v4sf)
19665 v4sf __builtin_ia32_subps (v4sf, v4sf)
19666 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19667 v4sf __builtin_ia32_divps (v4sf, v4sf)
19668 v4sf __builtin_ia32_addss (v4sf, v4sf)
19669 v4sf __builtin_ia32_subss (v4sf, v4sf)
19670 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19671 v4sf __builtin_ia32_divss (v4sf, v4sf)
19672 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19673 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19674 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19675 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19676 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19677 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19678 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19679 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19680 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19681 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19682 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19683 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19684 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19685 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19686 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19687 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19688 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19689 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19690 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19691 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19692 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19693 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19694 v4sf __builtin_ia32_minps (v4sf, v4sf)
19695 v4sf __builtin_ia32_minss (v4sf, v4sf)
19696 v4sf __builtin_ia32_andps (v4sf, v4sf)
19697 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19698 v4sf __builtin_ia32_orps (v4sf, v4sf)
19699 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19700 v4sf __builtin_ia32_movss (v4sf, v4sf)
19701 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19702 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19703 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19704 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19705 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19706 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19707 v2si __builtin_ia32_cvtps2pi (v4sf)
19708 int __builtin_ia32_cvtss2si (v4sf)
19709 v2si __builtin_ia32_cvttps2pi (v4sf)
19710 int __builtin_ia32_cvttss2si (v4sf)
19711 v4sf __builtin_ia32_rcpps (v4sf)
19712 v4sf __builtin_ia32_rsqrtps (v4sf)
19713 v4sf __builtin_ia32_sqrtps (v4sf)
19714 v4sf __builtin_ia32_rcpss (v4sf)
19715 v4sf __builtin_ia32_rsqrtss (v4sf)
19716 v4sf __builtin_ia32_sqrtss (v4sf)
19717 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19718 void __builtin_ia32_movntps (float *, v4sf)
19719 int __builtin_ia32_movmskps (v4sf)
19720 @end smallexample
19722 The following built-in functions are available when @option{-msse} is used.
19724 @table @code
19725 @item v4sf __builtin_ia32_loadups (float *)
19726 Generates the @code{movups} machine instruction as a load from memory.
19727 @item void __builtin_ia32_storeups (float *, v4sf)
19728 Generates the @code{movups} machine instruction as a store to memory.
19729 @item v4sf __builtin_ia32_loadss (float *)
19730 Generates the @code{movss} machine instruction as a load from memory.
19731 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19732 Generates the @code{movhps} machine instruction as a load from memory.
19733 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19734 Generates the @code{movlps} machine instruction as a load from memory
19735 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19736 Generates the @code{movhps} machine instruction as a store to memory.
19737 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19738 Generates the @code{movlps} machine instruction as a store to memory.
19739 @end table
19741 The following built-in functions are available when @option{-msse2} is used.
19742 All of them generate the machine instruction that is part of the name.
19744 @smallexample
19745 int __builtin_ia32_comisdeq (v2df, v2df)
19746 int __builtin_ia32_comisdlt (v2df, v2df)
19747 int __builtin_ia32_comisdle (v2df, v2df)
19748 int __builtin_ia32_comisdgt (v2df, v2df)
19749 int __builtin_ia32_comisdge (v2df, v2df)
19750 int __builtin_ia32_comisdneq (v2df, v2df)
19751 int __builtin_ia32_ucomisdeq (v2df, v2df)
19752 int __builtin_ia32_ucomisdlt (v2df, v2df)
19753 int __builtin_ia32_ucomisdle (v2df, v2df)
19754 int __builtin_ia32_ucomisdgt (v2df, v2df)
19755 int __builtin_ia32_ucomisdge (v2df, v2df)
19756 int __builtin_ia32_ucomisdneq (v2df, v2df)
19757 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19758 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19759 v2df __builtin_ia32_cmplepd (v2df, v2df)
19760 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19761 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19762 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19763 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19764 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19765 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19766 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19767 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19768 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19769 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19770 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19771 v2df __builtin_ia32_cmplesd (v2df, v2df)
19772 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19773 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19774 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19775 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19776 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19777 v2di __builtin_ia32_paddq (v2di, v2di)
19778 v2di __builtin_ia32_psubq (v2di, v2di)
19779 v2df __builtin_ia32_addpd (v2df, v2df)
19780 v2df __builtin_ia32_subpd (v2df, v2df)
19781 v2df __builtin_ia32_mulpd (v2df, v2df)
19782 v2df __builtin_ia32_divpd (v2df, v2df)
19783 v2df __builtin_ia32_addsd (v2df, v2df)
19784 v2df __builtin_ia32_subsd (v2df, v2df)
19785 v2df __builtin_ia32_mulsd (v2df, v2df)
19786 v2df __builtin_ia32_divsd (v2df, v2df)
19787 v2df __builtin_ia32_minpd (v2df, v2df)
19788 v2df __builtin_ia32_maxpd (v2df, v2df)
19789 v2df __builtin_ia32_minsd (v2df, v2df)
19790 v2df __builtin_ia32_maxsd (v2df, v2df)
19791 v2df __builtin_ia32_andpd (v2df, v2df)
19792 v2df __builtin_ia32_andnpd (v2df, v2df)
19793 v2df __builtin_ia32_orpd (v2df, v2df)
19794 v2df __builtin_ia32_xorpd (v2df, v2df)
19795 v2df __builtin_ia32_movsd (v2df, v2df)
19796 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19797 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19798 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19799 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19800 v4si __builtin_ia32_paddd128 (v4si, v4si)
19801 v2di __builtin_ia32_paddq128 (v2di, v2di)
19802 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19803 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19804 v4si __builtin_ia32_psubd128 (v4si, v4si)
19805 v2di __builtin_ia32_psubq128 (v2di, v2di)
19806 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19807 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19808 v2di __builtin_ia32_pand128 (v2di, v2di)
19809 v2di __builtin_ia32_pandn128 (v2di, v2di)
19810 v2di __builtin_ia32_por128 (v2di, v2di)
19811 v2di __builtin_ia32_pxor128 (v2di, v2di)
19812 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19813 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19814 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19815 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19816 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19817 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19818 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19819 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19820 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19821 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19822 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19823 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19824 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19825 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19826 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19827 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19828 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19829 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19830 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19831 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19832 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19833 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19834 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19835 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19836 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19837 v2df __builtin_ia32_loadupd (double *)
19838 void __builtin_ia32_storeupd (double *, v2df)
19839 v2df __builtin_ia32_loadhpd (v2df, double const *)
19840 v2df __builtin_ia32_loadlpd (v2df, double const *)
19841 int __builtin_ia32_movmskpd (v2df)
19842 int __builtin_ia32_pmovmskb128 (v16qi)
19843 void __builtin_ia32_movnti (int *, int)
19844 void __builtin_ia32_movnti64 (long long int *, long long int)
19845 void __builtin_ia32_movntpd (double *, v2df)
19846 void __builtin_ia32_movntdq (v2df *, v2df)
19847 v4si __builtin_ia32_pshufd (v4si, int)
19848 v8hi __builtin_ia32_pshuflw (v8hi, int)
19849 v8hi __builtin_ia32_pshufhw (v8hi, int)
19850 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19851 v2df __builtin_ia32_sqrtpd (v2df)
19852 v2df __builtin_ia32_sqrtsd (v2df)
19853 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19854 v2df __builtin_ia32_cvtdq2pd (v4si)
19855 v4sf __builtin_ia32_cvtdq2ps (v4si)
19856 v4si __builtin_ia32_cvtpd2dq (v2df)
19857 v2si __builtin_ia32_cvtpd2pi (v2df)
19858 v4sf __builtin_ia32_cvtpd2ps (v2df)
19859 v4si __builtin_ia32_cvttpd2dq (v2df)
19860 v2si __builtin_ia32_cvttpd2pi (v2df)
19861 v2df __builtin_ia32_cvtpi2pd (v2si)
19862 int __builtin_ia32_cvtsd2si (v2df)
19863 int __builtin_ia32_cvttsd2si (v2df)
19864 long long __builtin_ia32_cvtsd2si64 (v2df)
19865 long long __builtin_ia32_cvttsd2si64 (v2df)
19866 v4si __builtin_ia32_cvtps2dq (v4sf)
19867 v2df __builtin_ia32_cvtps2pd (v4sf)
19868 v4si __builtin_ia32_cvttps2dq (v4sf)
19869 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19870 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19871 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19872 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19873 void __builtin_ia32_clflush (const void *)
19874 void __builtin_ia32_lfence (void)
19875 void __builtin_ia32_mfence (void)
19876 v16qi __builtin_ia32_loaddqu (const char *)
19877 void __builtin_ia32_storedqu (char *, v16qi)
19878 v1di __builtin_ia32_pmuludq (v2si, v2si)
19879 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19880 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19881 v4si __builtin_ia32_pslld128 (v4si, v4si)
19882 v2di __builtin_ia32_psllq128 (v2di, v2di)
19883 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19884 v4si __builtin_ia32_psrld128 (v4si, v4si)
19885 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19886 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19887 v4si __builtin_ia32_psrad128 (v4si, v4si)
19888 v2di __builtin_ia32_pslldqi128 (v2di, int)
19889 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19890 v4si __builtin_ia32_pslldi128 (v4si, int)
19891 v2di __builtin_ia32_psllqi128 (v2di, int)
19892 v2di __builtin_ia32_psrldqi128 (v2di, int)
19893 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19894 v4si __builtin_ia32_psrldi128 (v4si, int)
19895 v2di __builtin_ia32_psrlqi128 (v2di, int)
19896 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19897 v4si __builtin_ia32_psradi128 (v4si, int)
19898 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19899 v2di __builtin_ia32_movq128 (v2di)
19900 @end smallexample
19902 The following built-in functions are available when @option{-msse3} is used.
19903 All of them generate the machine instruction that is part of the name.
19905 @smallexample
19906 v2df __builtin_ia32_addsubpd (v2df, v2df)
19907 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19908 v2df __builtin_ia32_haddpd (v2df, v2df)
19909 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19910 v2df __builtin_ia32_hsubpd (v2df, v2df)
19911 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19912 v16qi __builtin_ia32_lddqu (char const *)
19913 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19914 v4sf __builtin_ia32_movshdup (v4sf)
19915 v4sf __builtin_ia32_movsldup (v4sf)
19916 void __builtin_ia32_mwait (unsigned int, unsigned int)
19917 @end smallexample
19919 The following built-in functions are available when @option{-mssse3} is used.
19920 All of them generate the machine instruction that is part of the name.
19922 @smallexample
19923 v2si __builtin_ia32_phaddd (v2si, v2si)
19924 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
19925 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
19926 v2si __builtin_ia32_phsubd (v2si, v2si)
19927 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
19928 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
19929 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
19930 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
19931 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
19932 v8qi __builtin_ia32_psignb (v8qi, v8qi)
19933 v2si __builtin_ia32_psignd (v2si, v2si)
19934 v4hi __builtin_ia32_psignw (v4hi, v4hi)
19935 v1di __builtin_ia32_palignr (v1di, v1di, int)
19936 v8qi __builtin_ia32_pabsb (v8qi)
19937 v2si __builtin_ia32_pabsd (v2si)
19938 v4hi __builtin_ia32_pabsw (v4hi)
19939 @end smallexample
19941 The following built-in functions are available when @option{-mssse3} is used.
19942 All of them generate the machine instruction that is part of the name.
19944 @smallexample
19945 v4si __builtin_ia32_phaddd128 (v4si, v4si)
19946 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
19947 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
19948 v4si __builtin_ia32_phsubd128 (v4si, v4si)
19949 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
19950 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
19951 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
19952 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
19953 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
19954 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
19955 v4si __builtin_ia32_psignd128 (v4si, v4si)
19956 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
19957 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
19958 v16qi __builtin_ia32_pabsb128 (v16qi)
19959 v4si __builtin_ia32_pabsd128 (v4si)
19960 v8hi __builtin_ia32_pabsw128 (v8hi)
19961 @end smallexample
19963 The following built-in functions are available when @option{-msse4.1} is
19964 used.  All of them generate the machine instruction that is part of the
19965 name.
19967 @smallexample
19968 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
19969 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
19970 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
19971 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
19972 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19973 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19974 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19975 v2di __builtin_ia32_movntdqa (v2di *);
19976 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19977 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19978 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19979 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19980 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19981 v8hi __builtin_ia32_phminposuw128 (v8hi)
19982 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19983 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19984 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19985 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19986 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19987 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19988 v4si __builtin_ia32_pminud128 (v4si, v4si)
19989 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19990 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19991 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19992 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19993 v2di __builtin_ia32_pmovsxdq128 (v4si)
19994 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19995 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19996 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19997 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19998 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19999 v2di __builtin_ia32_pmovzxdq128 (v4si)
20000 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20001 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20002 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20003 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20004 int __builtin_ia32_ptestc128 (v2di, v2di)
20005 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20006 int __builtin_ia32_ptestz128 (v2di, v2di)
20007 v2df __builtin_ia32_roundpd (v2df, const int)
20008 v4sf __builtin_ia32_roundps (v4sf, const int)
20009 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20010 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20011 @end smallexample
20013 The following built-in functions are available when @option{-msse4.1} is
20014 used.
20016 @table @code
20017 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20018 Generates the @code{insertps} machine instruction.
20019 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20020 Generates the @code{pextrb} machine instruction.
20021 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20022 Generates the @code{pinsrb} machine instruction.
20023 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20024 Generates the @code{pinsrd} machine instruction.
20025 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20026 Generates the @code{pinsrq} machine instruction in 64bit mode.
20027 @end table
20029 The following built-in functions are changed to generate new SSE4.1
20030 instructions when @option{-msse4.1} is used.
20032 @table @code
20033 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20034 Generates the @code{extractps} machine instruction.
20035 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20036 Generates the @code{pextrd} machine instruction.
20037 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20038 Generates the @code{pextrq} machine instruction in 64bit mode.
20039 @end table
20041 The following built-in functions are available when @option{-msse4.2} is
20042 used.  All of them generate the machine instruction that is part of the
20043 name.
20045 @smallexample
20046 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20047 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20048 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20049 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20050 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20051 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20052 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20053 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20054 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20055 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20056 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20057 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20058 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20059 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20060 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20061 @end smallexample
20063 The following built-in functions are available when @option{-msse4.2} is
20064 used.
20066 @table @code
20067 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20068 Generates the @code{crc32b} machine instruction.
20069 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20070 Generates the @code{crc32w} machine instruction.
20071 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20072 Generates the @code{crc32l} machine instruction.
20073 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20074 Generates the @code{crc32q} machine instruction.
20075 @end table
20077 The following built-in functions are changed to generate new SSE4.2
20078 instructions when @option{-msse4.2} is used.
20080 @table @code
20081 @item int __builtin_popcount (unsigned int)
20082 Generates the @code{popcntl} machine instruction.
20083 @item int __builtin_popcountl (unsigned long)
20084 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20085 depending on the size of @code{unsigned long}.
20086 @item int __builtin_popcountll (unsigned long long)
20087 Generates the @code{popcntq} machine instruction.
20088 @end table
20090 The following built-in functions are available when @option{-mavx} is
20091 used. All of them generate the machine instruction that is part of the
20092 name.
20094 @smallexample
20095 v4df __builtin_ia32_addpd256 (v4df,v4df)
20096 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20097 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20098 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20099 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20100 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20101 v4df __builtin_ia32_andpd256 (v4df,v4df)
20102 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20103 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20104 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20105 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20106 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20107 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20108 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20109 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20110 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20111 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20112 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20113 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20114 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20115 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20116 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20117 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20118 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20119 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20120 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20121 v4df __builtin_ia32_divpd256 (v4df,v4df)
20122 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20123 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20124 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20125 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20126 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20127 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20128 v32qi __builtin_ia32_lddqu256 (pcchar)
20129 v32qi __builtin_ia32_loaddqu256 (pcchar)
20130 v4df __builtin_ia32_loadupd256 (pcdouble)
20131 v8sf __builtin_ia32_loadups256 (pcfloat)
20132 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20133 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20134 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20135 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20136 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20137 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20138 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20139 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20140 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20141 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20142 v4df __builtin_ia32_minpd256 (v4df,v4df)
20143 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20144 v4df __builtin_ia32_movddup256 (v4df)
20145 int __builtin_ia32_movmskpd256 (v4df)
20146 int __builtin_ia32_movmskps256 (v8sf)
20147 v8sf __builtin_ia32_movshdup256 (v8sf)
20148 v8sf __builtin_ia32_movsldup256 (v8sf)
20149 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20150 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20151 v4df __builtin_ia32_orpd256 (v4df,v4df)
20152 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20153 v2df __builtin_ia32_pd_pd256 (v4df)
20154 v4df __builtin_ia32_pd256_pd (v2df)
20155 v4sf __builtin_ia32_ps_ps256 (v8sf)
20156 v8sf __builtin_ia32_ps256_ps (v4sf)
20157 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20158 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20159 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20160 v8sf __builtin_ia32_rcpps256 (v8sf)
20161 v4df __builtin_ia32_roundpd256 (v4df,int)
20162 v8sf __builtin_ia32_roundps256 (v8sf,int)
20163 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20164 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20165 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20166 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20167 v4si __builtin_ia32_si_si256 (v8si)
20168 v8si __builtin_ia32_si256_si (v4si)
20169 v4df __builtin_ia32_sqrtpd256 (v4df)
20170 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20171 v8sf __builtin_ia32_sqrtps256 (v8sf)
20172 void __builtin_ia32_storedqu256 (pchar,v32qi)
20173 void __builtin_ia32_storeupd256 (pdouble,v4df)
20174 void __builtin_ia32_storeups256 (pfloat,v8sf)
20175 v4df __builtin_ia32_subpd256 (v4df,v4df)
20176 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20177 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20178 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20179 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20180 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20181 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20182 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20183 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20184 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20185 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20186 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20187 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20188 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20189 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20190 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20191 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20192 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20193 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20194 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20195 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20196 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20197 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20198 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20199 v2df __builtin_ia32_vpermilpd (v2df,int)
20200 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20201 v4sf __builtin_ia32_vpermilps (v4sf,int)
20202 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
20203 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
20204 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
20205 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
20206 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
20207 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
20208 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
20209 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
20210 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
20211 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
20212 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
20213 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
20214 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
20215 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
20216 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
20217 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
20218 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
20219 void __builtin_ia32_vzeroall (void)
20220 void __builtin_ia32_vzeroupper (void)
20221 v4df __builtin_ia32_xorpd256 (v4df,v4df)
20222 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
20223 @end smallexample
20225 The following built-in functions are available when @option{-mavx2} is
20226 used. All of them generate the machine instruction that is part of the
20227 name.
20229 @smallexample
20230 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
20231 v32qi __builtin_ia32_pabsb256 (v32qi)
20232 v16hi __builtin_ia32_pabsw256 (v16hi)
20233 v8si __builtin_ia32_pabsd256 (v8si)
20234 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
20235 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
20236 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
20237 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
20238 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
20239 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
20240 v8si __builtin_ia32_paddd256 (v8si,v8si)
20241 v4di __builtin_ia32_paddq256 (v4di,v4di)
20242 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
20243 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
20244 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20245 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20246 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20247 v4di __builtin_ia32_andsi256 (v4di,v4di)
20248 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20249 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20250 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20251 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20252 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20253 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20254 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20255 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20256 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20257 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20258 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20259 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20260 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20261 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20262 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20263 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20264 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20265 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20266 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20267 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20268 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20269 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20270 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20271 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20272 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20273 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20274 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20275 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20276 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20277 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20278 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20279 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20280 v8si __builtin_ia32_pminud256 (v8si,v8si)
20281 int __builtin_ia32_pmovmskb256 (v32qi)
20282 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20283 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20284 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20285 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20286 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20287 v4di __builtin_ia32_pmovsxdq256 (v4si)
20288 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20289 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20290 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20291 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20292 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20293 v4di __builtin_ia32_pmovzxdq256 (v4si)
20294 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20295 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20296 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20297 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20298 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20299 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20300 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20301 v4di __builtin_ia32_por256 (v4di,v4di)
20302 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20303 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20304 v8si __builtin_ia32_pshufd256 (v8si,int)
20305 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
20306 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
20307 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
20308 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
20309 v8si __builtin_ia32_psignd256 (v8si,v8si)
20310 v4di __builtin_ia32_pslldqi256 (v4di,int)
20311 v16hi __builtin_ia32_psllwi256 (16hi,int)
20312 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
20313 v8si __builtin_ia32_pslldi256 (v8si,int)
20314 v8si __builtin_ia32_pslld256(v8si,v4si)
20315 v4di __builtin_ia32_psllqi256 (v4di,int)
20316 v4di __builtin_ia32_psllq256(v4di,v2di)
20317 v16hi __builtin_ia32_psrawi256 (v16hi,int)
20318 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
20319 v8si __builtin_ia32_psradi256 (v8si,int)
20320 v8si __builtin_ia32_psrad256 (v8si,v4si)
20321 v4di __builtin_ia32_psrldqi256 (v4di, int)
20322 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
20323 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
20324 v8si __builtin_ia32_psrldi256 (v8si,int)
20325 v8si __builtin_ia32_psrld256 (v8si,v4si)
20326 v4di __builtin_ia32_psrlqi256 (v4di,int)
20327 v4di __builtin_ia32_psrlq256(v4di,v2di)
20328 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
20329 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
20330 v8si __builtin_ia32_psubd256 (v8si,v8si)
20331 v4di __builtin_ia32_psubq256 (v4di,v4di)
20332 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
20333 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
20334 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
20335 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
20336 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
20337 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
20338 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
20339 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
20340 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
20341 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
20342 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
20343 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
20344 v4di __builtin_ia32_pxor256 (v4di,v4di)
20345 v4di __builtin_ia32_movntdqa256 (pv4di)
20346 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
20347 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
20348 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
20349 v4di __builtin_ia32_vbroadcastsi256 (v2di)
20350 v4si __builtin_ia32_pblendd128 (v4si,v4si)
20351 v8si __builtin_ia32_pblendd256 (v8si,v8si)
20352 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
20353 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
20354 v8si __builtin_ia32_pbroadcastd256 (v4si)
20355 v4di __builtin_ia32_pbroadcastq256 (v2di)
20356 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
20357 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
20358 v4si __builtin_ia32_pbroadcastd128 (v4si)
20359 v2di __builtin_ia32_pbroadcastq128 (v2di)
20360 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
20361 v4df __builtin_ia32_permdf256 (v4df,int)
20362 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
20363 v4di __builtin_ia32_permdi256 (v4di,int)
20364 v4di __builtin_ia32_permti256 (v4di,v4di,int)
20365 v4di __builtin_ia32_extract128i256 (v4di,int)
20366 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
20367 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
20368 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
20369 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
20370 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
20371 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
20372 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
20373 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
20374 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
20375 v8si __builtin_ia32_psllv8si (v8si,v8si)
20376 v4si __builtin_ia32_psllv4si (v4si,v4si)
20377 v4di __builtin_ia32_psllv4di (v4di,v4di)
20378 v2di __builtin_ia32_psllv2di (v2di,v2di)
20379 v8si __builtin_ia32_psrav8si (v8si,v8si)
20380 v4si __builtin_ia32_psrav4si (v4si,v4si)
20381 v8si __builtin_ia32_psrlv8si (v8si,v8si)
20382 v4si __builtin_ia32_psrlv4si (v4si,v4si)
20383 v4di __builtin_ia32_psrlv4di (v4di,v4di)
20384 v2di __builtin_ia32_psrlv2di (v2di,v2di)
20385 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
20386 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
20387 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
20388 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
20389 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
20390 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
20391 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
20392 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
20393 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
20394 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
20395 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
20396 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
20397 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
20398 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
20399 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
20400 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
20401 @end smallexample
20403 The following built-in functions are available when @option{-maes} is
20404 used.  All of them generate the machine instruction that is part of the
20405 name.
20407 @smallexample
20408 v2di __builtin_ia32_aesenc128 (v2di, v2di)
20409 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
20410 v2di __builtin_ia32_aesdec128 (v2di, v2di)
20411 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
20412 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
20413 v2di __builtin_ia32_aesimc128 (v2di)
20414 @end smallexample
20416 The following built-in function is available when @option{-mpclmul} is
20417 used.
20419 @table @code
20420 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
20421 Generates the @code{pclmulqdq} machine instruction.
20422 @end table
20424 The following built-in function is available when @option{-mfsgsbase} is
20425 used.  All of them generate the machine instruction that is part of the
20426 name.
20428 @smallexample
20429 unsigned int __builtin_ia32_rdfsbase32 (void)
20430 unsigned long long __builtin_ia32_rdfsbase64 (void)
20431 unsigned int __builtin_ia32_rdgsbase32 (void)
20432 unsigned long long __builtin_ia32_rdgsbase64 (void)
20433 void _writefsbase_u32 (unsigned int)
20434 void _writefsbase_u64 (unsigned long long)
20435 void _writegsbase_u32 (unsigned int)
20436 void _writegsbase_u64 (unsigned long long)
20437 @end smallexample
20439 The following built-in function is available when @option{-mrdrnd} is
20440 used.  All of them generate the machine instruction that is part of the
20441 name.
20443 @smallexample
20444 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
20445 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
20446 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
20447 @end smallexample
20449 The following built-in functions are available when @option{-msse4a} is used.
20450 All of them generate the machine instruction that is part of the name.
20452 @smallexample
20453 void __builtin_ia32_movntsd (double *, v2df)
20454 void __builtin_ia32_movntss (float *, v4sf)
20455 v2di __builtin_ia32_extrq  (v2di, v16qi)
20456 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
20457 v2di __builtin_ia32_insertq (v2di, v2di)
20458 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
20459 @end smallexample
20461 The following built-in functions are available when @option{-mxop} is used.
20462 @smallexample
20463 v2df __builtin_ia32_vfrczpd (v2df)
20464 v4sf __builtin_ia32_vfrczps (v4sf)
20465 v2df __builtin_ia32_vfrczsd (v2df)
20466 v4sf __builtin_ia32_vfrczss (v4sf)
20467 v4df __builtin_ia32_vfrczpd256 (v4df)
20468 v8sf __builtin_ia32_vfrczps256 (v8sf)
20469 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
20470 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
20471 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
20472 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
20473 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
20474 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
20475 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
20476 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
20477 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
20478 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
20479 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
20480 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
20481 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
20482 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
20483 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20484 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
20485 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
20486 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
20487 v4si __builtin_ia32_vpcomequd (v4si, v4si)
20488 v2di __builtin_ia32_vpcomequq (v2di, v2di)
20489 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
20490 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20491 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
20492 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
20493 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
20494 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
20495 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
20496 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
20497 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
20498 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
20499 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
20500 v4si __builtin_ia32_vpcomged (v4si, v4si)
20501 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
20502 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
20503 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
20504 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
20505 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
20506 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
20507 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
20508 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
20509 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
20510 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
20511 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
20512 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
20513 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
20514 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
20515 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
20516 v4si __builtin_ia32_vpcomled (v4si, v4si)
20517 v2di __builtin_ia32_vpcomleq (v2di, v2di)
20518 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
20519 v4si __builtin_ia32_vpcomleud (v4si, v4si)
20520 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
20521 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
20522 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
20523 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
20524 v4si __builtin_ia32_vpcomltd (v4si, v4si)
20525 v2di __builtin_ia32_vpcomltq (v2di, v2di)
20526 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
20527 v4si __builtin_ia32_vpcomltud (v4si, v4si)
20528 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
20529 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
20530 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
20531 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
20532 v4si __builtin_ia32_vpcomned (v4si, v4si)
20533 v2di __builtin_ia32_vpcomneq (v2di, v2di)
20534 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
20535 v4si __builtin_ia32_vpcomneud (v4si, v4si)
20536 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
20537 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
20538 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
20539 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
20540 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
20541 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
20542 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
20543 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
20544 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
20545 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
20546 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
20547 v4si __builtin_ia32_vphaddbd (v16qi)
20548 v2di __builtin_ia32_vphaddbq (v16qi)
20549 v8hi __builtin_ia32_vphaddbw (v16qi)
20550 v2di __builtin_ia32_vphadddq (v4si)
20551 v4si __builtin_ia32_vphaddubd (v16qi)
20552 v2di __builtin_ia32_vphaddubq (v16qi)
20553 v8hi __builtin_ia32_vphaddubw (v16qi)
20554 v2di __builtin_ia32_vphaddudq (v4si)
20555 v4si __builtin_ia32_vphadduwd (v8hi)
20556 v2di __builtin_ia32_vphadduwq (v8hi)
20557 v4si __builtin_ia32_vphaddwd (v8hi)
20558 v2di __builtin_ia32_vphaddwq (v8hi)
20559 v8hi __builtin_ia32_vphsubbw (v16qi)
20560 v2di __builtin_ia32_vphsubdq (v4si)
20561 v4si __builtin_ia32_vphsubwd (v8hi)
20562 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
20563 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
20564 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
20565 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
20566 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
20567 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
20568 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
20569 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
20570 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
20571 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
20572 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
20573 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20574 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20575 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20576 v4si __builtin_ia32_vprotd (v4si, v4si)
20577 v2di __builtin_ia32_vprotq (v2di, v2di)
20578 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20579 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20580 v4si __builtin_ia32_vpshad (v4si, v4si)
20581 v2di __builtin_ia32_vpshaq (v2di, v2di)
20582 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20583 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20584 v4si __builtin_ia32_vpshld (v4si, v4si)
20585 v2di __builtin_ia32_vpshlq (v2di, v2di)
20586 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20587 @end smallexample
20589 The following built-in functions are available when @option{-mfma4} is used.
20590 All of them generate the machine instruction that is part of the name.
20592 @smallexample
20593 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
20594 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
20595 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
20596 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
20597 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
20598 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
20599 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
20600 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
20601 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
20602 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
20603 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
20604 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
20605 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
20606 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
20607 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
20608 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
20609 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
20610 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
20611 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
20612 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
20613 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
20614 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
20615 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
20616 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
20617 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
20618 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
20619 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
20620 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
20621 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
20622 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
20623 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
20624 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
20626 @end smallexample
20628 The following built-in functions are available when @option{-mlwp} is used.
20630 @smallexample
20631 void __builtin_ia32_llwpcb16 (void *);
20632 void __builtin_ia32_llwpcb32 (void *);
20633 void __builtin_ia32_llwpcb64 (void *);
20634 void * __builtin_ia32_llwpcb16 (void);
20635 void * __builtin_ia32_llwpcb32 (void);
20636 void * __builtin_ia32_llwpcb64 (void);
20637 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
20638 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
20639 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20640 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20641 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20642 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20643 @end smallexample
20645 The following built-in functions are available when @option{-mbmi} is used.
20646 All of them generate the machine instruction that is part of the name.
20647 @smallexample
20648 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20649 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20650 @end smallexample
20652 The following built-in functions are available when @option{-mbmi2} is used.
20653 All of them generate the machine instruction that is part of the name.
20654 @smallexample
20655 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20656 unsigned int _pdep_u32 (unsigned int, unsigned int)
20657 unsigned int _pext_u32 (unsigned int, unsigned int)
20658 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20659 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20660 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20661 @end smallexample
20663 The following built-in functions are available when @option{-mlzcnt} is used.
20664 All of them generate the machine instruction that is part of the name.
20665 @smallexample
20666 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20667 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20668 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20669 @end smallexample
20671 The following built-in functions are available when @option{-mfxsr} is used.
20672 All of them generate the machine instruction that is part of the name.
20673 @smallexample
20674 void __builtin_ia32_fxsave (void *)
20675 void __builtin_ia32_fxrstor (void *)
20676 void __builtin_ia32_fxsave64 (void *)
20677 void __builtin_ia32_fxrstor64 (void *)
20678 @end smallexample
20680 The following built-in functions are available when @option{-mxsave} is used.
20681 All of them generate the machine instruction that is part of the name.
20682 @smallexample
20683 void __builtin_ia32_xsave (void *, long long)
20684 void __builtin_ia32_xrstor (void *, long long)
20685 void __builtin_ia32_xsave64 (void *, long long)
20686 void __builtin_ia32_xrstor64 (void *, long long)
20687 @end smallexample
20689 The following built-in functions are available when @option{-mxsaveopt} is used.
20690 All of them generate the machine instruction that is part of the name.
20691 @smallexample
20692 void __builtin_ia32_xsaveopt (void *, long long)
20693 void __builtin_ia32_xsaveopt64 (void *, long long)
20694 @end smallexample
20696 The following built-in functions are available when @option{-mtbm} is used.
20697 Both of them generate the immediate form of the bextr machine instruction.
20698 @smallexample
20699 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
20700                                         const unsigned int);
20701 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
20702                                               const unsigned long long);
20703 @end smallexample
20706 The following built-in functions are available when @option{-m3dnow} is used.
20707 All of them generate the machine instruction that is part of the name.
20709 @smallexample
20710 void __builtin_ia32_femms (void)
20711 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20712 v2si __builtin_ia32_pf2id (v2sf)
20713 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20714 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20715 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20716 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20717 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20718 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20719 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20720 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20721 v2sf __builtin_ia32_pfrcp (v2sf)
20722 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20723 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20724 v2sf __builtin_ia32_pfrsqrt (v2sf)
20725 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20726 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20727 v2sf __builtin_ia32_pi2fd (v2si)
20728 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20729 @end smallexample
20731 The following built-in functions are available when @option{-m3dnowa} is used.
20732 All of them generate the machine instruction that is part of the name.
20734 @smallexample
20735 v2si __builtin_ia32_pf2iw (v2sf)
20736 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20737 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20738 v2sf __builtin_ia32_pi2fw (v2si)
20739 v2sf __builtin_ia32_pswapdsf (v2sf)
20740 v2si __builtin_ia32_pswapdsi (v2si)
20741 @end smallexample
20743 The following built-in functions are available when @option{-mrtm} is used
20744 They are used for restricted transactional memory. These are the internal
20745 low level functions. Normally the functions in 
20746 @ref{x86 transactional memory intrinsics} should be used instead.
20748 @smallexample
20749 int __builtin_ia32_xbegin ()
20750 void __builtin_ia32_xend ()
20751 void __builtin_ia32_xabort (status)
20752 int __builtin_ia32_xtest ()
20753 @end smallexample
20755 The following built-in functions are available when @option{-mmwaitx} is used.
20756 All of them generate the machine instruction that is part of the name.
20757 @smallexample
20758 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20759 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20760 @end smallexample
20762 The following built-in functions are available when @option{-mclzero} is used.
20763 All of them generate the machine instruction that is part of the name.
20764 @smallexample
20765 void __builtin_i32_clzero (void *)
20766 @end smallexample
20768 The following built-in functions are available when @option{-mpku} is used.
20769 They generate reads and writes to PKRU.
20770 @smallexample
20771 void __builtin_ia32_wrpkru (unsigned int)
20772 unsigned int __builtin_ia32_rdpkru ()
20773 @end smallexample
20775 @node x86 transactional memory intrinsics
20776 @subsection x86 Transactional Memory Intrinsics
20778 These hardware transactional memory intrinsics for x86 allow you to use
20779 memory transactions with RTM (Restricted Transactional Memory).
20780 This support is enabled with the @option{-mrtm} option.
20781 For using HLE (Hardware Lock Elision) see 
20782 @ref{x86 specific memory model extensions for transactional memory} instead.
20784 A memory transaction commits all changes to memory in an atomic way,
20785 as visible to other threads. If the transaction fails it is rolled back
20786 and all side effects discarded.
20788 Generally there is no guarantee that a memory transaction ever succeeds
20789 and suitable fallback code always needs to be supplied.
20791 @deftypefn {RTM Function} {unsigned} _xbegin ()
20792 Start a RTM (Restricted Transactional Memory) transaction. 
20793 Returns @code{_XBEGIN_STARTED} when the transaction
20794 started successfully (note this is not 0, so the constant has to be 
20795 explicitly tested).  
20797 If the transaction aborts, all side-effects 
20798 are undone and an abort code encoded as a bit mask is returned.
20799 The following macros are defined:
20801 @table @code
20802 @item _XABORT_EXPLICIT
20803 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
20804 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20805 @item _XABORT_RETRY
20806 Transaction retry is possible.
20807 @item _XABORT_CONFLICT
20808 Transaction abort due to a memory conflict with another thread.
20809 @item _XABORT_CAPACITY
20810 Transaction abort due to the transaction using too much memory.
20811 @item _XABORT_DEBUG
20812 Transaction abort due to a debug trap.
20813 @item _XABORT_NESTED
20814 Transaction abort in an inner nested transaction.
20815 @end table
20817 There is no guarantee
20818 any transaction ever succeeds, so there always needs to be a valid
20819 fallback path.
20820 @end deftypefn
20822 @deftypefn {RTM Function} {void} _xend ()
20823 Commit the current transaction. When no transaction is active this faults.
20824 All memory side-effects of the transaction become visible
20825 to other threads in an atomic manner.
20826 @end deftypefn
20828 @deftypefn {RTM Function} {int} _xtest ()
20829 Return a nonzero value if a transaction is currently active, otherwise 0.
20830 @end deftypefn
20832 @deftypefn {RTM Function} {void} _xabort (status)
20833 Abort the current transaction. When no transaction is active this is a no-op.
20834 The @var{status} is an 8-bit constant; its value is encoded in the return 
20835 value from @code{_xbegin}.
20836 @end deftypefn
20838 Here is an example showing handling for @code{_XABORT_RETRY}
20839 and a fallback path for other failures:
20841 @smallexample
20842 #include <immintrin.h>
20844 int n_tries, max_tries;
20845 unsigned status = _XABORT_EXPLICIT;
20848 for (n_tries = 0; n_tries < max_tries; n_tries++) 
20849   @{
20850     status = _xbegin ();
20851     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20852       break;
20853   @}
20854 if (status == _XBEGIN_STARTED) 
20855   @{
20856     ... transaction code...
20857     _xend ();
20858   @} 
20859 else 
20860   @{
20861     ... non-transactional fallback path...
20862   @}
20863 @end smallexample
20865 @noindent
20866 Note that, in most cases, the transactional and non-transactional code
20867 must synchronize together to ensure consistency.
20869 @node Target Format Checks
20870 @section Format Checks Specific to Particular Target Machines
20872 For some target machines, GCC supports additional options to the
20873 format attribute
20874 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20876 @menu
20877 * Solaris Format Checks::
20878 * Darwin Format Checks::
20879 @end menu
20881 @node Solaris Format Checks
20882 @subsection Solaris Format Checks
20884 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20885 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
20886 conversions, and the two-argument @code{%b} conversion for displaying
20887 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
20889 @node Darwin Format Checks
20890 @subsection Darwin Format Checks
20892 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20893 attribute context.  Declarations made with such attribution are parsed for correct syntax
20894 and format argument types.  However, parsing of the format string itself is currently undefined
20895 and is not carried out by this version of the compiler.
20897 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20898 also be used as format arguments.  Note that the relevant headers are only likely to be
20899 available on Darwin (OSX) installations.  On such installations, the XCode and system
20900 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20901 associated functions.
20903 @node Pragmas
20904 @section Pragmas Accepted by GCC
20905 @cindex pragmas
20906 @cindex @code{#pragma}
20908 GCC supports several types of pragmas, primarily in order to compile
20909 code originally written for other compilers.  Note that in general
20910 we do not recommend the use of pragmas; @xref{Function Attributes},
20911 for further explanation.
20913 @menu
20914 * AArch64 Pragmas::
20915 * ARM Pragmas::
20916 * M32C Pragmas::
20917 * MeP Pragmas::
20918 * RS/6000 and PowerPC Pragmas::
20919 * S/390 Pragmas::
20920 * Darwin Pragmas::
20921 * Solaris Pragmas::
20922 * Symbol-Renaming Pragmas::
20923 * Structure-Layout Pragmas::
20924 * Weak Pragmas::
20925 * Diagnostic Pragmas::
20926 * Visibility Pragmas::
20927 * Push/Pop Macro Pragmas::
20928 * Function Specific Option Pragmas::
20929 * Loop-Specific Pragmas::
20930 @end menu
20932 @node AArch64 Pragmas
20933 @subsection AArch64 Pragmas
20935 The pragmas defined by the AArch64 target correspond to the AArch64
20936 target function attributes.  They can be specified as below:
20937 @smallexample
20938 #pragma GCC target("string")
20939 @end smallexample
20941 where @code{@var{string}} can be any string accepted as an AArch64 target
20942 attribute.  @xref{AArch64 Function Attributes}, for more details
20943 on the permissible values of @code{string}.
20945 @node ARM Pragmas
20946 @subsection ARM Pragmas
20948 The ARM target defines pragmas for controlling the default addition of
20949 @code{long_call} and @code{short_call} attributes to functions.
20950 @xref{Function Attributes}, for information about the effects of these
20951 attributes.
20953 @table @code
20954 @item long_calls
20955 @cindex pragma, long_calls
20956 Set all subsequent functions to have the @code{long_call} attribute.
20958 @item no_long_calls
20959 @cindex pragma, no_long_calls
20960 Set all subsequent functions to have the @code{short_call} attribute.
20962 @item long_calls_off
20963 @cindex pragma, long_calls_off
20964 Do not affect the @code{long_call} or @code{short_call} attributes of
20965 subsequent functions.
20966 @end table
20968 @node M32C Pragmas
20969 @subsection M32C Pragmas
20971 @table @code
20972 @item GCC memregs @var{number}
20973 @cindex pragma, memregs
20974 Overrides the command-line option @code{-memregs=} for the current
20975 file.  Use with care!  This pragma must be before any function in the
20976 file, and mixing different memregs values in different objects may
20977 make them incompatible.  This pragma is useful when a
20978 performance-critical function uses a memreg for temporary values,
20979 as it may allow you to reduce the number of memregs used.
20981 @item ADDRESS @var{name} @var{address}
20982 @cindex pragma, address
20983 For any declared symbols matching @var{name}, this does three things
20984 to that symbol: it forces the symbol to be located at the given
20985 address (a number), it forces the symbol to be volatile, and it
20986 changes the symbol's scope to be static.  This pragma exists for
20987 compatibility with other compilers, but note that the common
20988 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20989 instead).  Example:
20991 @smallexample
20992 #pragma ADDRESS port3 0x103
20993 char port3;
20994 @end smallexample
20996 @end table
20998 @node MeP Pragmas
20999 @subsection MeP Pragmas
21001 @table @code
21003 @item custom io_volatile (on|off)
21004 @cindex pragma, custom io_volatile
21005 Overrides the command-line option @code{-mio-volatile} for the current
21006 file.  Note that for compatibility with future GCC releases, this
21007 option should only be used once before any @code{io} variables in each
21008 file.
21010 @item GCC coprocessor available @var{registers}
21011 @cindex pragma, coprocessor available
21012 Specifies which coprocessor registers are available to the register
21013 allocator.  @var{registers} may be a single register, register range
21014 separated by ellipses, or comma-separated list of those.  Example:
21016 @smallexample
21017 #pragma GCC coprocessor available $c0...$c10, $c28
21018 @end smallexample
21020 @item GCC coprocessor call_saved @var{registers}
21021 @cindex pragma, coprocessor call_saved
21022 Specifies which coprocessor registers are to be saved and restored by
21023 any function using them.  @var{registers} may be a single register,
21024 register range separated by ellipses, or comma-separated list of
21025 those.  Example:
21027 @smallexample
21028 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21029 @end smallexample
21031 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21032 @cindex pragma, coprocessor subclass
21033 Creates and defines a register class.  These register classes can be
21034 used by inline @code{asm} constructs.  @var{registers} may be a single
21035 register, register range separated by ellipses, or comma-separated
21036 list of those.  Example:
21038 @smallexample
21039 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21041 asm ("cpfoo %0" : "=B" (x));
21042 @end smallexample
21044 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21045 @cindex pragma, disinterrupt
21046 For the named functions, the compiler adds code to disable interrupts
21047 for the duration of those functions.  If any functions so named 
21048 are not encountered in the source, a warning is emitted that the pragma is
21049 not used.  Examples:
21051 @smallexample
21052 #pragma disinterrupt foo
21053 #pragma disinterrupt bar, grill
21054 int foo () @{ @dots{} @}
21055 @end smallexample
21057 @item GCC call @var{name} , @var{name} @dots{}
21058 @cindex pragma, call
21059 For the named functions, the compiler always uses a register-indirect
21060 call model when calling the named functions.  Examples:
21062 @smallexample
21063 extern int foo ();
21064 #pragma call foo
21065 @end smallexample
21067 @end table
21069 @node RS/6000 and PowerPC Pragmas
21070 @subsection RS/6000 and PowerPC Pragmas
21072 The RS/6000 and PowerPC targets define one pragma for controlling
21073 whether or not the @code{longcall} attribute is added to function
21074 declarations by default.  This pragma overrides the @option{-mlongcall}
21075 option, but not the @code{longcall} and @code{shortcall} attributes.
21076 @xref{RS/6000 and PowerPC Options}, for more information about when long
21077 calls are and are not necessary.
21079 @table @code
21080 @item longcall (1)
21081 @cindex pragma, longcall
21082 Apply the @code{longcall} attribute to all subsequent function
21083 declarations.
21085 @item longcall (0)
21086 Do not apply the @code{longcall} attribute to subsequent function
21087 declarations.
21088 @end table
21090 @c Describe h8300 pragmas here.
21091 @c Describe sh pragmas here.
21092 @c Describe v850 pragmas here.
21094 @node S/390 Pragmas
21095 @subsection S/390 Pragmas
21097 The pragmas defined by the S/390 target correspond to the S/390
21098 target function attributes and some the additional options:
21100 @table @samp
21101 @item zvector
21102 @itemx no-zvector
21103 @end table
21105 Note that options of the pragma, unlike options of the target
21106 attribute, do change the value of preprocessor macros like
21107 @code{__VEC__}.  They can be specified as below:
21109 @smallexample
21110 #pragma GCC target("string[,string]...")
21111 #pragma GCC target("string"[,"string"]...)
21112 @end smallexample
21114 @node Darwin Pragmas
21115 @subsection Darwin Pragmas
21117 The following pragmas are available for all architectures running the
21118 Darwin operating system.  These are useful for compatibility with other
21119 Mac OS compilers.
21121 @table @code
21122 @item mark @var{tokens}@dots{}
21123 @cindex pragma, mark
21124 This pragma is accepted, but has no effect.
21126 @item options align=@var{alignment}
21127 @cindex pragma, options align
21128 This pragma sets the alignment of fields in structures.  The values of
21129 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21130 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
21131 properly; to restore the previous setting, use @code{reset} for the
21132 @var{alignment}.
21134 @item segment @var{tokens}@dots{}
21135 @cindex pragma, segment
21136 This pragma is accepted, but has no effect.
21138 @item unused (@var{var} [, @var{var}]@dots{})
21139 @cindex pragma, unused
21140 This pragma declares variables to be possibly unused.  GCC does not
21141 produce warnings for the listed variables.  The effect is similar to
21142 that of the @code{unused} attribute, except that this pragma may appear
21143 anywhere within the variables' scopes.
21144 @end table
21146 @node Solaris Pragmas
21147 @subsection Solaris Pragmas
21149 The Solaris target supports @code{#pragma redefine_extname}
21150 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
21151 @code{#pragma} directives for compatibility with the system compiler.
21153 @table @code
21154 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
21155 @cindex pragma, align
21157 Increase the minimum alignment of each @var{variable} to @var{alignment}.
21158 This is the same as GCC's @code{aligned} attribute @pxref{Variable
21159 Attributes}).  Macro expansion occurs on the arguments to this pragma
21160 when compiling C and Objective-C@.  It does not currently occur when
21161 compiling C++, but this is a bug which may be fixed in a future
21162 release.
21164 @item fini (@var{function} [, @var{function}]...)
21165 @cindex pragma, fini
21167 This pragma causes each listed @var{function} to be called after
21168 main, or during shared module unloading, by adding a call to the
21169 @code{.fini} section.
21171 @item init (@var{function} [, @var{function}]...)
21172 @cindex pragma, init
21174 This pragma causes each listed @var{function} to be called during
21175 initialization (before @code{main}) or during shared module loading, by
21176 adding a call to the @code{.init} section.
21178 @end table
21180 @node Symbol-Renaming Pragmas
21181 @subsection Symbol-Renaming Pragmas
21183 GCC supports a @code{#pragma} directive that changes the name used in
21184 assembly for a given declaration. While this pragma is supported on all
21185 platforms, it is intended primarily to provide compatibility with the
21186 Solaris system headers. This effect can also be achieved using the asm
21187 labels extension (@pxref{Asm Labels}).
21189 @table @code
21190 @item redefine_extname @var{oldname} @var{newname}
21191 @cindex pragma, redefine_extname
21193 This pragma gives the C function @var{oldname} the assembly symbol
21194 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
21195 is defined if this pragma is available (currently on all platforms).
21196 @end table
21198 This pragma and the asm labels extension interact in a complicated
21199 manner.  Here are some corner cases you may want to be aware of:
21201 @enumerate
21202 @item This pragma silently applies only to declarations with external
21203 linkage.  Asm labels do not have this restriction.
21205 @item In C++, this pragma silently applies only to declarations with
21206 ``C'' linkage.  Again, asm labels do not have this restriction.
21208 @item If either of the ways of changing the assembly name of a
21209 declaration are applied to a declaration whose assembly name has
21210 already been determined (either by a previous use of one of these
21211 features, or because the compiler needed the assembly name in order to
21212 generate code), and the new name is different, a warning issues and
21213 the name does not change.
21215 @item The @var{oldname} used by @code{#pragma redefine_extname} is
21216 always the C-language name.
21217 @end enumerate
21219 @node Structure-Layout Pragmas
21220 @subsection Structure-Layout Pragmas
21222 For compatibility with Microsoft Windows compilers, GCC supports a
21223 set of @code{#pragma} directives that change the maximum alignment of
21224 members of structures (other than zero-width bit-fields), unions, and
21225 classes subsequently defined. The @var{n} value below always is required
21226 to be a small power of two and specifies the new alignment in bytes.
21228 @enumerate
21229 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
21230 @item @code{#pragma pack()} sets the alignment to the one that was in
21231 effect when compilation started (see also command-line option
21232 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
21233 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
21234 setting on an internal stack and then optionally sets the new alignment.
21235 @item @code{#pragma pack(pop)} restores the alignment setting to the one
21236 saved at the top of the internal stack (and removes that stack entry).
21237 Note that @code{#pragma pack([@var{n}])} does not influence this internal
21238 stack; thus it is possible to have @code{#pragma pack(push)} followed by
21239 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
21240 @code{#pragma pack(pop)}.
21241 @end enumerate
21243 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
21244 directive which lays out structures and unions subsequently defined as the
21245 documented @code{__attribute__ ((ms_struct))}.
21247 @enumerate
21248 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21249 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21250 @item @code{#pragma ms_struct reset} goes back to the default layout.
21251 @end enumerate
21253 Most targets also support the @code{#pragma scalar_storage_order} directive
21254 which lays out structures and unions subsequently defined as the documented
21255 @code{__attribute__ ((scalar_storage_order))}.
21257 @enumerate
21258 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21259 of the scalar fields to big-endian.
21260 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21261 of the scalar fields to little-endian.
21262 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21263 that was in effect when compilation started (see also command-line option
21264 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21265 @end enumerate
21267 @node Weak Pragmas
21268 @subsection Weak Pragmas
21270 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21271 directives for declaring symbols to be weak, and defining weak
21272 aliases.
21274 @table @code
21275 @item #pragma weak @var{symbol}
21276 @cindex pragma, weak
21277 This pragma declares @var{symbol} to be weak, as if the declaration
21278 had the attribute of the same name.  The pragma may appear before
21279 or after the declaration of @var{symbol}.  It is not an error for
21280 @var{symbol} to never be defined at all.
21282 @item #pragma weak @var{symbol1} = @var{symbol2}
21283 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21284 It is an error if @var{symbol2} is not defined in the current
21285 translation unit.
21286 @end table
21288 @node Diagnostic Pragmas
21289 @subsection Diagnostic Pragmas
21291 GCC allows the user to selectively enable or disable certain types of
21292 diagnostics, and change the kind of the diagnostic.  For example, a
21293 project's policy might require that all sources compile with
21294 @option{-Werror} but certain files might have exceptions allowing
21295 specific types of warnings.  Or, a project might selectively enable
21296 diagnostics and treat them as errors depending on which preprocessor
21297 macros are defined.
21299 @table @code
21300 @item #pragma GCC diagnostic @var{kind} @var{option}
21301 @cindex pragma, diagnostic
21303 Modifies the disposition of a diagnostic.  Note that not all
21304 diagnostics are modifiable; at the moment only warnings (normally
21305 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
21306 Use @option{-fdiagnostics-show-option} to determine which diagnostics
21307 are controllable and which option controls them.
21309 @var{kind} is @samp{error} to treat this diagnostic as an error,
21310 @samp{warning} to treat it like a warning (even if @option{-Werror} is
21311 in effect), or @samp{ignored} if the diagnostic is to be ignored.
21312 @var{option} is a double quoted string that matches the command-line
21313 option.
21315 @smallexample
21316 #pragma GCC diagnostic warning "-Wformat"
21317 #pragma GCC diagnostic error "-Wformat"
21318 #pragma GCC diagnostic ignored "-Wformat"
21319 @end smallexample
21321 Note that these pragmas override any command-line options.  GCC keeps
21322 track of the location of each pragma, and issues diagnostics according
21323 to the state as of that point in the source file.  Thus, pragmas occurring
21324 after a line do not affect diagnostics caused by that line.
21326 @item #pragma GCC diagnostic push
21327 @itemx #pragma GCC diagnostic pop
21329 Causes GCC to remember the state of the diagnostics as of each
21330 @code{push}, and restore to that point at each @code{pop}.  If a
21331 @code{pop} has no matching @code{push}, the command-line options are
21332 restored.
21334 @smallexample
21335 #pragma GCC diagnostic error "-Wuninitialized"
21336   foo(a);                       /* error is given for this one */
21337 #pragma GCC diagnostic push
21338 #pragma GCC diagnostic ignored "-Wuninitialized"
21339   foo(b);                       /* no diagnostic for this one */
21340 #pragma GCC diagnostic pop
21341   foo(c);                       /* error is given for this one */
21342 #pragma GCC diagnostic pop
21343   foo(d);                       /* depends on command-line options */
21344 @end smallexample
21346 @end table
21348 GCC also offers a simple mechanism for printing messages during
21349 compilation.
21351 @table @code
21352 @item #pragma message @var{string}
21353 @cindex pragma, diagnostic
21355 Prints @var{string} as a compiler message on compilation.  The message
21356 is informational only, and is neither a compilation warning nor an error.
21358 @smallexample
21359 #pragma message "Compiling " __FILE__ "..."
21360 @end smallexample
21362 @var{string} may be parenthesized, and is printed with location
21363 information.  For example,
21365 @smallexample
21366 #define DO_PRAGMA(x) _Pragma (#x)
21367 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
21369 TODO(Remember to fix this)
21370 @end smallexample
21372 @noindent
21373 prints @samp{/tmp/file.c:4: note: #pragma message:
21374 TODO - Remember to fix this}.
21376 @end table
21378 @node Visibility Pragmas
21379 @subsection Visibility Pragmas
21381 @table @code
21382 @item #pragma GCC visibility push(@var{visibility})
21383 @itemx #pragma GCC visibility pop
21384 @cindex pragma, visibility
21386 This pragma allows the user to set the visibility for multiple
21387 declarations without having to give each a visibility attribute
21388 (@pxref{Function Attributes}).
21390 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
21391 declarations.  Class members and template specializations are not
21392 affected; if you want to override the visibility for a particular
21393 member or instantiation, you must use an attribute.
21395 @end table
21398 @node Push/Pop Macro Pragmas
21399 @subsection Push/Pop Macro Pragmas
21401 For compatibility with Microsoft Windows compilers, GCC supports
21402 @samp{#pragma push_macro(@var{"macro_name"})}
21403 and @samp{#pragma pop_macro(@var{"macro_name"})}.
21405 @table @code
21406 @item #pragma push_macro(@var{"macro_name"})
21407 @cindex pragma, push_macro
21408 This pragma saves the value of the macro named as @var{macro_name} to
21409 the top of the stack for this macro.
21411 @item #pragma pop_macro(@var{"macro_name"})
21412 @cindex pragma, pop_macro
21413 This pragma sets the value of the macro named as @var{macro_name} to
21414 the value on top of the stack for this macro. If the stack for
21415 @var{macro_name} is empty, the value of the macro remains unchanged.
21416 @end table
21418 For example:
21420 @smallexample
21421 #define X  1
21422 #pragma push_macro("X")
21423 #undef X
21424 #define X -1
21425 #pragma pop_macro("X")
21426 int x [X];
21427 @end smallexample
21429 @noindent
21430 In this example, the definition of X as 1 is saved by @code{#pragma
21431 push_macro} and restored by @code{#pragma pop_macro}.
21433 @node Function Specific Option Pragmas
21434 @subsection Function Specific Option Pragmas
21436 @table @code
21437 @item #pragma GCC target (@var{"string"}...)
21438 @cindex pragma GCC target
21440 This pragma allows you to set target specific options for functions
21441 defined later in the source file.  One or more strings can be
21442 specified.  Each function that is defined after this point is as
21443 if @code{attribute((target("STRING")))} was specified for that
21444 function.  The parenthesis around the options is optional.
21445 @xref{Function Attributes}, for more information about the
21446 @code{target} attribute and the attribute syntax.
21448 The @code{#pragma GCC target} pragma is presently implemented for
21449 x86, PowerPC, and Nios II targets only.
21450 @end table
21452 @table @code
21453 @item #pragma GCC optimize (@var{"string"}...)
21454 @cindex pragma GCC optimize
21456 This pragma allows you to set global optimization options for functions
21457 defined later in the source file.  One or more strings can be
21458 specified.  Each function that is defined after this point is as
21459 if @code{attribute((optimize("STRING")))} was specified for that
21460 function.  The parenthesis around the options is optional.
21461 @xref{Function Attributes}, for more information about the
21462 @code{optimize} attribute and the attribute syntax.
21463 @end table
21465 @table @code
21466 @item #pragma GCC push_options
21467 @itemx #pragma GCC pop_options
21468 @cindex pragma GCC push_options
21469 @cindex pragma GCC pop_options
21471 These pragmas maintain a stack of the current target and optimization
21472 options.  It is intended for include files where you temporarily want
21473 to switch to using a different @samp{#pragma GCC target} or
21474 @samp{#pragma GCC optimize} and then to pop back to the previous
21475 options.
21476 @end table
21478 @table @code
21479 @item #pragma GCC reset_options
21480 @cindex pragma GCC reset_options
21482 This pragma clears the current @code{#pragma GCC target} and
21483 @code{#pragma GCC optimize} to use the default switches as specified
21484 on the command line.
21485 @end table
21487 @node Loop-Specific Pragmas
21488 @subsection Loop-Specific Pragmas
21490 @table @code
21491 @item #pragma GCC ivdep
21492 @cindex pragma GCC ivdep
21493 @end table
21495 With this pragma, the programmer asserts that there are no loop-carried
21496 dependencies which would prevent consecutive iterations of
21497 the following loop from executing concurrently with SIMD
21498 (single instruction multiple data) instructions.
21500 For example, the compiler can only unconditionally vectorize the following
21501 loop with the pragma:
21503 @smallexample
21504 void foo (int n, int *a, int *b, int *c)
21506   int i, j;
21507 #pragma GCC ivdep
21508   for (i = 0; i < n; ++i)
21509     a[i] = b[i] + c[i];
21511 @end smallexample
21513 @noindent
21514 In this example, using the @code{restrict} qualifier had the same
21515 effect. In the following example, that would not be possible. Assume
21516 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
21517 that it can unconditionally vectorize the following loop:
21519 @smallexample
21520 void ignore_vec_dep (int *a, int k, int c, int m)
21522 #pragma GCC ivdep
21523   for (int i = 0; i < m; i++)
21524     a[i] = a[i + k] * c;
21526 @end smallexample
21529 @node Unnamed Fields
21530 @section Unnamed Structure and Union Fields
21531 @cindex @code{struct}
21532 @cindex @code{union}
21534 As permitted by ISO C11 and for compatibility with other compilers,
21535 GCC allows you to define
21536 a structure or union that contains, as fields, structures and unions
21537 without names.  For example:
21539 @smallexample
21540 struct @{
21541   int a;
21542   union @{
21543     int b;
21544     float c;
21545   @};
21546   int d;
21547 @} foo;
21548 @end smallexample
21550 @noindent
21551 In this example, you are able to access members of the unnamed
21552 union with code like @samp{foo.b}.  Note that only unnamed structs and
21553 unions are allowed, you may not have, for example, an unnamed
21554 @code{int}.
21556 You must never create such structures that cause ambiguous field definitions.
21557 For example, in this structure:
21559 @smallexample
21560 struct @{
21561   int a;
21562   struct @{
21563     int a;
21564   @};
21565 @} foo;
21566 @end smallexample
21568 @noindent
21569 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
21570 The compiler gives errors for such constructs.
21572 @opindex fms-extensions
21573 Unless @option{-fms-extensions} is used, the unnamed field must be a
21574 structure or union definition without a tag (for example, @samp{struct
21575 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
21576 also be a definition with a tag such as @samp{struct foo @{ int a;
21577 @};}, a reference to a previously defined structure or union such as
21578 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21579 previously defined structure or union type.
21581 @opindex fplan9-extensions
21582 The option @option{-fplan9-extensions} enables
21583 @option{-fms-extensions} as well as two other extensions.  First, a
21584 pointer to a structure is automatically converted to a pointer to an
21585 anonymous field for assignments and function calls.  For example:
21587 @smallexample
21588 struct s1 @{ int a; @};
21589 struct s2 @{ struct s1; @};
21590 extern void f1 (struct s1 *);
21591 void f2 (struct s2 *p) @{ f1 (p); @}
21592 @end smallexample
21594 @noindent
21595 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
21596 converted into a pointer to the anonymous field.
21598 Second, when the type of an anonymous field is a @code{typedef} for a
21599 @code{struct} or @code{union}, code may refer to the field using the
21600 name of the @code{typedef}.
21602 @smallexample
21603 typedef struct @{ int a; @} s1;
21604 struct s2 @{ s1; @};
21605 s1 f1 (struct s2 *p) @{ return p->s1; @}
21606 @end smallexample
21608 These usages are only permitted when they are not ambiguous.
21610 @node Thread-Local
21611 @section Thread-Local Storage
21612 @cindex Thread-Local Storage
21613 @cindex @acronym{TLS}
21614 @cindex @code{__thread}
21616 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
21617 are allocated such that there is one instance of the variable per extant
21618 thread.  The runtime model GCC uses to implement this originates
21619 in the IA-64 processor-specific ABI, but has since been migrated
21620 to other processors as well.  It requires significant support from
21621 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
21622 system libraries (@file{libc.so} and @file{libpthread.so}), so it
21623 is not available everywhere.
21625 At the user level, the extension is visible with a new storage
21626 class keyword: @code{__thread}.  For example:
21628 @smallexample
21629 __thread int i;
21630 extern __thread struct state s;
21631 static __thread char *p;
21632 @end smallexample
21634 The @code{__thread} specifier may be used alone, with the @code{extern}
21635 or @code{static} specifiers, but with no other storage class specifier.
21636 When used with @code{extern} or @code{static}, @code{__thread} must appear
21637 immediately after the other storage class specifier.
21639 The @code{__thread} specifier may be applied to any global, file-scoped
21640 static, function-scoped static, or static data member of a class.  It may
21641 not be applied to block-scoped automatic or non-static data member.
21643 When the address-of operator is applied to a thread-local variable, it is
21644 evaluated at run time and returns the address of the current thread's
21645 instance of that variable.  An address so obtained may be used by any
21646 thread.  When a thread terminates, any pointers to thread-local variables
21647 in that thread become invalid.
21649 No static initialization may refer to the address of a thread-local variable.
21651 In C++, if an initializer is present for a thread-local variable, it must
21652 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21653 standard.
21655 See @uref{https://www.akkadia.org/drepper/tls.pdf,
21656 ELF Handling For Thread-Local Storage} for a detailed explanation of
21657 the four thread-local storage addressing models, and how the runtime
21658 is expected to function.
21660 @menu
21661 * C99 Thread-Local Edits::
21662 * C++98 Thread-Local Edits::
21663 @end menu
21665 @node C99 Thread-Local Edits
21666 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21668 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21669 that document the exact semantics of the language extension.
21671 @itemize @bullet
21672 @item
21673 @cite{5.1.2  Execution environments}
21675 Add new text after paragraph 1
21677 @quotation
21678 Within either execution environment, a @dfn{thread} is a flow of
21679 control within a program.  It is implementation defined whether
21680 or not there may be more than one thread associated with a program.
21681 It is implementation defined how threads beyond the first are
21682 created, the name and type of the function called at thread
21683 startup, and how threads may be terminated.  However, objects
21684 with thread storage duration shall be initialized before thread
21685 startup.
21686 @end quotation
21688 @item
21689 @cite{6.2.4  Storage durations of objects}
21691 Add new text before paragraph 3
21693 @quotation
21694 An object whose identifier is declared with the storage-class
21695 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21696 Its lifetime is the entire execution of the thread, and its
21697 stored value is initialized only once, prior to thread startup.
21698 @end quotation
21700 @item
21701 @cite{6.4.1  Keywords}
21703 Add @code{__thread}.
21705 @item
21706 @cite{6.7.1  Storage-class specifiers}
21708 Add @code{__thread} to the list of storage class specifiers in
21709 paragraph 1.
21711 Change paragraph 2 to
21713 @quotation
21714 With the exception of @code{__thread}, at most one storage-class
21715 specifier may be given [@dots{}].  The @code{__thread} specifier may
21716 be used alone, or immediately following @code{extern} or
21717 @code{static}.
21718 @end quotation
21720 Add new text after paragraph 6
21722 @quotation
21723 The declaration of an identifier for a variable that has
21724 block scope that specifies @code{__thread} shall also
21725 specify either @code{extern} or @code{static}.
21727 The @code{__thread} specifier shall be used only with
21728 variables.
21729 @end quotation
21730 @end itemize
21732 @node C++98 Thread-Local Edits
21733 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21735 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21736 that document the exact semantics of the language extension.
21738 @itemize @bullet
21739 @item
21740 @b{[intro.execution]}
21742 New text after paragraph 4
21744 @quotation
21745 A @dfn{thread} is a flow of control within the abstract machine.
21746 It is implementation defined whether or not there may be more than
21747 one thread.
21748 @end quotation
21750 New text after paragraph 7
21752 @quotation
21753 It is unspecified whether additional action must be taken to
21754 ensure when and whether side effects are visible to other threads.
21755 @end quotation
21757 @item
21758 @b{[lex.key]}
21760 Add @code{__thread}.
21762 @item
21763 @b{[basic.start.main]}
21765 Add after paragraph 5
21767 @quotation
21768 The thread that begins execution at the @code{main} function is called
21769 the @dfn{main thread}.  It is implementation defined how functions
21770 beginning threads other than the main thread are designated or typed.
21771 A function so designated, as well as the @code{main} function, is called
21772 a @dfn{thread startup function}.  It is implementation defined what
21773 happens if a thread startup function returns.  It is implementation
21774 defined what happens to other threads when any thread calls @code{exit}.
21775 @end quotation
21777 @item
21778 @b{[basic.start.init]}
21780 Add after paragraph 4
21782 @quotation
21783 The storage for an object of thread storage duration shall be
21784 statically initialized before the first statement of the thread startup
21785 function.  An object of thread storage duration shall not require
21786 dynamic initialization.
21787 @end quotation
21789 @item
21790 @b{[basic.start.term]}
21792 Add after paragraph 3
21794 @quotation
21795 The type of an object with thread storage duration shall not have a
21796 non-trivial destructor, nor shall it be an array type whose elements
21797 (directly or indirectly) have non-trivial destructors.
21798 @end quotation
21800 @item
21801 @b{[basic.stc]}
21803 Add ``thread storage duration'' to the list in paragraph 1.
21805 Change paragraph 2
21807 @quotation
21808 Thread, static, and automatic storage durations are associated with
21809 objects introduced by declarations [@dots{}].
21810 @end quotation
21812 Add @code{__thread} to the list of specifiers in paragraph 3.
21814 @item
21815 @b{[basic.stc.thread]}
21817 New section before @b{[basic.stc.static]}
21819 @quotation
21820 The keyword @code{__thread} applied to a non-local object gives the
21821 object thread storage duration.
21823 A local variable or class data member declared both @code{static}
21824 and @code{__thread} gives the variable or member thread storage
21825 duration.
21826 @end quotation
21828 @item
21829 @b{[basic.stc.static]}
21831 Change paragraph 1
21833 @quotation
21834 All objects that have neither thread storage duration, dynamic
21835 storage duration nor are local [@dots{}].
21836 @end quotation
21838 @item
21839 @b{[dcl.stc]}
21841 Add @code{__thread} to the list in paragraph 1.
21843 Change paragraph 1
21845 @quotation
21846 With the exception of @code{__thread}, at most one
21847 @var{storage-class-specifier} shall appear in a given
21848 @var{decl-specifier-seq}.  The @code{__thread} specifier may
21849 be used alone, or immediately following the @code{extern} or
21850 @code{static} specifiers.  [@dots{}]
21851 @end quotation
21853 Add after paragraph 5
21855 @quotation
21856 The @code{__thread} specifier can be applied only to the names of objects
21857 and to anonymous unions.
21858 @end quotation
21860 @item
21861 @b{[class.mem]}
21863 Add after paragraph 6
21865 @quotation
21866 Non-@code{static} members shall not be @code{__thread}.
21867 @end quotation
21868 @end itemize
21870 @node Binary constants
21871 @section Binary Constants using the @samp{0b} Prefix
21872 @cindex Binary constants using the @samp{0b} prefix
21874 Integer constants can be written as binary constants, consisting of a
21875 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21876 @samp{0B}.  This is particularly useful in environments that operate a
21877 lot on the bit level (like microcontrollers).
21879 The following statements are identical:
21881 @smallexample
21882 i =       42;
21883 i =     0x2a;
21884 i =      052;
21885 i = 0b101010;
21886 @end smallexample
21888 The type of these constants follows the same rules as for octal or
21889 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21890 can be applied.
21892 @node C++ Extensions
21893 @chapter Extensions to the C++ Language
21894 @cindex extensions, C++ language
21895 @cindex C++ language extensions
21897 The GNU compiler provides these extensions to the C++ language (and you
21898 can also use most of the C language extensions in your C++ programs).  If you
21899 want to write code that checks whether these features are available, you can
21900 test for the GNU compiler the same way as for C programs: check for a
21901 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
21902 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21903 Predefined Macros,cpp,The GNU C Preprocessor}).
21905 @menu
21906 * C++ Volatiles::       What constitutes an access to a volatile object.
21907 * Restricted Pointers:: C99 restricted pointers and references.
21908 * Vague Linkage::       Where G++ puts inlines, vtables and such.
21909 * C++ Interface::       You can use a single C++ header file for both
21910                         declarations and definitions.
21911 * Template Instantiation:: Methods for ensuring that exactly one copy of
21912                         each needed template instantiation is emitted.
21913 * Bound member functions:: You can extract a function pointer to the
21914                         method denoted by a @samp{->*} or @samp{.*} expression.
21915 * C++ Attributes::      Variable, function, and type attributes for C++ only.
21916 * Function Multiversioning::   Declaring multiple function versions.
21917 * Type Traits::         Compiler support for type traits.
21918 * C++ Concepts::        Improved support for generic programming.
21919 * Deprecated Features:: Things will disappear from G++.
21920 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
21921 @end menu
21923 @node C++ Volatiles
21924 @section When is a Volatile C++ Object Accessed?
21925 @cindex accessing volatiles
21926 @cindex volatile read
21927 @cindex volatile write
21928 @cindex volatile access
21930 The C++ standard differs from the C standard in its treatment of
21931 volatile objects.  It fails to specify what constitutes a volatile
21932 access, except to say that C++ should behave in a similar manner to C
21933 with respect to volatiles, where possible.  However, the different
21934 lvalueness of expressions between C and C++ complicate the behavior.
21935 G++ behaves the same as GCC for volatile access, @xref{C
21936 Extensions,,Volatiles}, for a description of GCC's behavior.
21938 The C and C++ language specifications differ when an object is
21939 accessed in a void context:
21941 @smallexample
21942 volatile int *src = @var{somevalue};
21943 *src;
21944 @end smallexample
21946 The C++ standard specifies that such expressions do not undergo lvalue
21947 to rvalue conversion, and that the type of the dereferenced object may
21948 be incomplete.  The C++ standard does not specify explicitly that it
21949 is lvalue to rvalue conversion that is responsible for causing an
21950 access.  There is reason to believe that it is, because otherwise
21951 certain simple expressions become undefined.  However, because it
21952 would surprise most programmers, G++ treats dereferencing a pointer to
21953 volatile object of complete type as GCC would do for an equivalent
21954 type in C@.  When the object has incomplete type, G++ issues a
21955 warning; if you wish to force an error, you must force a conversion to
21956 rvalue with, for instance, a static cast.
21958 When using a reference to volatile, G++ does not treat equivalent
21959 expressions as accesses to volatiles, but instead issues a warning that
21960 no volatile is accessed.  The rationale for this is that otherwise it
21961 becomes difficult to determine where volatile access occur, and not
21962 possible to ignore the return value from functions returning volatile
21963 references.  Again, if you wish to force a read, cast the reference to
21964 an rvalue.
21966 G++ implements the same behavior as GCC does when assigning to a
21967 volatile object---there is no reread of the assigned-to object, the
21968 assigned rvalue is reused.  Note that in C++ assignment expressions
21969 are lvalues, and if used as an lvalue, the volatile object is
21970 referred to.  For instance, @var{vref} refers to @var{vobj}, as
21971 expected, in the following example:
21973 @smallexample
21974 volatile int vobj;
21975 volatile int &vref = vobj = @var{something};
21976 @end smallexample
21978 @node Restricted Pointers
21979 @section Restricting Pointer Aliasing
21980 @cindex restricted pointers
21981 @cindex restricted references
21982 @cindex restricted this pointer
21984 As with the C front end, G++ understands the C99 feature of restricted pointers,
21985 specified with the @code{__restrict__}, or @code{__restrict} type
21986 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
21987 language flag, @code{restrict} is not a keyword in C++.
21989 In addition to allowing restricted pointers, you can specify restricted
21990 references, which indicate that the reference is not aliased in the local
21991 context.
21993 @smallexample
21994 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21996   /* @r{@dots{}} */
21998 @end smallexample
22000 @noindent
22001 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22002 @var{rref} refers to a (different) unaliased integer.
22004 You may also specify whether a member function's @var{this} pointer is
22005 unaliased by using @code{__restrict__} as a member function qualifier.
22007 @smallexample
22008 void T::fn () __restrict__
22010   /* @r{@dots{}} */
22012 @end smallexample
22014 @noindent
22015 Within the body of @code{T::fn}, @var{this} has the effective
22016 definition @code{T *__restrict__ const this}.  Notice that the
22017 interpretation of a @code{__restrict__} member function qualifier is
22018 different to that of @code{const} or @code{volatile} qualifier, in that it
22019 is applied to the pointer rather than the object.  This is consistent with
22020 other compilers that implement restricted pointers.
22022 As with all outermost parameter qualifiers, @code{__restrict__} is
22023 ignored in function definition matching.  This means you only need to
22024 specify @code{__restrict__} in a function definition, rather than
22025 in a function prototype as well.
22027 @node Vague Linkage
22028 @section Vague Linkage
22029 @cindex vague linkage
22031 There are several constructs in C++ that require space in the object
22032 file but are not clearly tied to a single translation unit.  We say that
22033 these constructs have ``vague linkage''.  Typically such constructs are
22034 emitted wherever they are needed, though sometimes we can be more
22035 clever.
22037 @table @asis
22038 @item Inline Functions
22039 Inline functions are typically defined in a header file which can be
22040 included in many different compilations.  Hopefully they can usually be
22041 inlined, but sometimes an out-of-line copy is necessary, if the address
22042 of the function is taken or if inlining fails.  In general, we emit an
22043 out-of-line copy in all translation units where one is needed.  As an
22044 exception, we only emit inline virtual functions with the vtable, since
22045 it always requires a copy.
22047 Local static variables and string constants used in an inline function
22048 are also considered to have vague linkage, since they must be shared
22049 between all inlined and out-of-line instances of the function.
22051 @item VTables
22052 @cindex vtable
22053 C++ virtual functions are implemented in most compilers using a lookup
22054 table, known as a vtable.  The vtable contains pointers to the virtual
22055 functions provided by a class, and each object of the class contains a
22056 pointer to its vtable (or vtables, in some multiple-inheritance
22057 situations).  If the class declares any non-inline, non-pure virtual
22058 functions, the first one is chosen as the ``key method'' for the class,
22059 and the vtable is only emitted in the translation unit where the key
22060 method is defined.
22062 @emph{Note:} If the chosen key method is later defined as inline, the
22063 vtable is still emitted in every translation unit that defines it.
22064 Make sure that any inline virtuals are declared inline in the class
22065 body, even if they are not defined there.
22067 @item @code{type_info} objects
22068 @cindex @code{type_info}
22069 @cindex RTTI
22070 C++ requires information about types to be written out in order to
22071 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
22072 For polymorphic classes (classes with virtual functions), the @samp{type_info}
22073 object is written out along with the vtable so that @samp{dynamic_cast}
22074 can determine the dynamic type of a class object at run time.  For all
22075 other types, we write out the @samp{type_info} object when it is used: when
22076 applying @samp{typeid} to an expression, throwing an object, or
22077 referring to a type in a catch clause or exception specification.
22079 @item Template Instantiations
22080 Most everything in this section also applies to template instantiations,
22081 but there are other options as well.
22082 @xref{Template Instantiation,,Where's the Template?}.
22084 @end table
22086 When used with GNU ld version 2.8 or later on an ELF system such as
22087 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
22088 these constructs will be discarded at link time.  This is known as
22089 COMDAT support.
22091 On targets that don't support COMDAT, but do support weak symbols, GCC
22092 uses them.  This way one copy overrides all the others, but
22093 the unused copies still take up space in the executable.
22095 For targets that do not support either COMDAT or weak symbols,
22096 most entities with vague linkage are emitted as local symbols to
22097 avoid duplicate definition errors from the linker.  This does not happen
22098 for local statics in inlines, however, as having multiple copies
22099 almost certainly breaks things.
22101 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
22102 another way to control placement of these constructs.
22104 @node C++ Interface
22105 @section C++ Interface and Implementation Pragmas
22107 @cindex interface and implementation headers, C++
22108 @cindex C++ interface and implementation headers
22109 @cindex pragmas, interface and implementation
22111 @code{#pragma interface} and @code{#pragma implementation} provide the
22112 user with a way of explicitly directing the compiler to emit entities
22113 with vague linkage (and debugging information) in a particular
22114 translation unit.
22116 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
22117 by COMDAT support and the ``key method'' heuristic
22118 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
22119 program to grow due to unnecessary out-of-line copies of inline
22120 functions.
22122 @table @code
22123 @item #pragma interface
22124 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
22125 @kindex #pragma interface
22126 Use this directive in @emph{header files} that define object classes, to save
22127 space in most of the object files that use those classes.  Normally,
22128 local copies of certain information (backup copies of inline member
22129 functions, debugging information, and the internal tables that implement
22130 virtual functions) must be kept in each object file that includes class
22131 definitions.  You can use this pragma to avoid such duplication.  When a
22132 header file containing @samp{#pragma interface} is included in a
22133 compilation, this auxiliary information is not generated (unless
22134 the main input source file itself uses @samp{#pragma implementation}).
22135 Instead, the object files contain references to be resolved at link
22136 time.
22138 The second form of this directive is useful for the case where you have
22139 multiple headers with the same name in different directories.  If you
22140 use this form, you must specify the same string to @samp{#pragma
22141 implementation}.
22143 @item #pragma implementation
22144 @itemx #pragma implementation "@var{objects}.h"
22145 @kindex #pragma implementation
22146 Use this pragma in a @emph{main input file}, when you want full output from
22147 included header files to be generated (and made globally visible).  The
22148 included header file, in turn, should use @samp{#pragma interface}.
22149 Backup copies of inline member functions, debugging information, and the
22150 internal tables used to implement virtual functions are all generated in
22151 implementation files.
22153 @cindex implied @code{#pragma implementation}
22154 @cindex @code{#pragma implementation}, implied
22155 @cindex naming convention, implementation headers
22156 If you use @samp{#pragma implementation} with no argument, it applies to
22157 an include file with the same basename@footnote{A file's @dfn{basename}
22158 is the name stripped of all leading path information and of trailing
22159 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
22160 file.  For example, in @file{allclass.cc}, giving just
22161 @samp{#pragma implementation}
22162 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
22164 Use the string argument if you want a single implementation file to
22165 include code from multiple header files.  (You must also use
22166 @samp{#include} to include the header file; @samp{#pragma
22167 implementation} only specifies how to use the file---it doesn't actually
22168 include it.)
22170 There is no way to split up the contents of a single header file into
22171 multiple implementation files.
22172 @end table
22174 @cindex inlining and C++ pragmas
22175 @cindex C++ pragmas, effect on inlining
22176 @cindex pragmas in C++, effect on inlining
22177 @samp{#pragma implementation} and @samp{#pragma interface} also have an
22178 effect on function inlining.
22180 If you define a class in a header file marked with @samp{#pragma
22181 interface}, the effect on an inline function defined in that class is
22182 similar to an explicit @code{extern} declaration---the compiler emits
22183 no code at all to define an independent version of the function.  Its
22184 definition is used only for inlining with its callers.
22186 @opindex fno-implement-inlines
22187 Conversely, when you include the same header file in a main source file
22188 that declares it as @samp{#pragma implementation}, the compiler emits
22189 code for the function itself; this defines a version of the function
22190 that can be found via pointers (or by callers compiled without
22191 inlining).  If all calls to the function can be inlined, you can avoid
22192 emitting the function by compiling with @option{-fno-implement-inlines}.
22193 If any calls are not inlined, you will get linker errors.
22195 @node Template Instantiation
22196 @section Where's the Template?
22197 @cindex template instantiation
22199 C++ templates were the first language feature to require more
22200 intelligence from the environment than was traditionally found on a UNIX
22201 system.  Somehow the compiler and linker have to make sure that each
22202 template instance occurs exactly once in the executable if it is needed,
22203 and not at all otherwise.  There are two basic approaches to this
22204 problem, which are referred to as the Borland model and the Cfront model.
22206 @table @asis
22207 @item Borland model
22208 Borland C++ solved the template instantiation problem by adding the code
22209 equivalent of common blocks to their linker; the compiler emits template
22210 instances in each translation unit that uses them, and the linker
22211 collapses them together.  The advantage of this model is that the linker
22212 only has to consider the object files themselves; there is no external
22213 complexity to worry about.  The disadvantage is that compilation time
22214 is increased because the template code is being compiled repeatedly.
22215 Code written for this model tends to include definitions of all
22216 templates in the header file, since they must be seen to be
22217 instantiated.
22219 @item Cfront model
22220 The AT&T C++ translator, Cfront, solved the template instantiation
22221 problem by creating the notion of a template repository, an
22222 automatically maintained place where template instances are stored.  A
22223 more modern version of the repository works as follows: As individual
22224 object files are built, the compiler places any template definitions and
22225 instantiations encountered in the repository.  At link time, the link
22226 wrapper adds in the objects in the repository and compiles any needed
22227 instances that were not previously emitted.  The advantages of this
22228 model are more optimal compilation speed and the ability to use the
22229 system linker; to implement the Borland model a compiler vendor also
22230 needs to replace the linker.  The disadvantages are vastly increased
22231 complexity, and thus potential for error; for some code this can be
22232 just as transparent, but in practice it can been very difficult to build
22233 multiple programs in one directory and one program in multiple
22234 directories.  Code written for this model tends to separate definitions
22235 of non-inline member templates into a separate file, which should be
22236 compiled separately.
22237 @end table
22239 G++ implements the Borland model on targets where the linker supports it,
22240 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
22241 Otherwise G++ implements neither automatic model.
22243 You have the following options for dealing with template instantiations:
22245 @enumerate
22246 @item
22247 Do nothing.  Code written for the Borland model works fine, but
22248 each translation unit contains instances of each of the templates it
22249 uses.  The duplicate instances will be discarded by the linker, but in
22250 a large program, this can lead to an unacceptable amount of code
22251 duplication in object files or shared libraries.
22253 Duplicate instances of a template can be avoided by defining an explicit
22254 instantiation in one object file, and preventing the compiler from doing
22255 implicit instantiations in any other object files by using an explicit
22256 instantiation declaration, using the @code{extern template} syntax:
22258 @smallexample
22259 extern template int max (int, int);
22260 @end smallexample
22262 This syntax is defined in the C++ 2011 standard, but has been supported by
22263 G++ and other compilers since well before 2011.
22265 Explicit instantiations can be used for the largest or most frequently
22266 duplicated instances, without having to know exactly which other instances
22267 are used in the rest of the program.  You can scatter the explicit
22268 instantiations throughout your program, perhaps putting them in the
22269 translation units where the instances are used or the translation units
22270 that define the templates themselves; you can put all of the explicit
22271 instantiations you need into one big file; or you can create small files
22272 like
22274 @smallexample
22275 #include "Foo.h"
22276 #include "Foo.cc"
22278 template class Foo<int>;
22279 template ostream& operator <<
22280                 (ostream&, const Foo<int>&);
22281 @end smallexample
22283 @noindent
22284 for each of the instances you need, and create a template instantiation
22285 library from those.
22287 This is the simplest option, but also offers flexibility and
22288 fine-grained control when necessary. It is also the most portable
22289 alternative and programs using this approach will work with most modern
22290 compilers.
22292 @item
22293 @opindex frepo
22294 Compile your template-using code with @option{-frepo}.  The compiler
22295 generates files with the extension @samp{.rpo} listing all of the
22296 template instantiations used in the corresponding object files that
22297 could be instantiated there; the link wrapper, @samp{collect2},
22298 then updates the @samp{.rpo} files to tell the compiler where to place
22299 those instantiations and rebuild any affected object files.  The
22300 link-time overhead is negligible after the first pass, as the compiler
22301 continues to place the instantiations in the same files.
22303 This can be a suitable option for application code written for the Borland
22304 model, as it usually just works.  Code written for the Cfront model 
22305 needs to be modified so that the template definitions are available at
22306 one or more points of instantiation; usually this is as simple as adding
22307 @code{#include <tmethods.cc>} to the end of each template header.
22309 For library code, if you want the library to provide all of the template
22310 instantiations it needs, just try to link all of its object files
22311 together; the link will fail, but cause the instantiations to be
22312 generated as a side effect.  Be warned, however, that this may cause
22313 conflicts if multiple libraries try to provide the same instantiations.
22314 For greater control, use explicit instantiation as described in the next
22315 option.
22317 @item
22318 @opindex fno-implicit-templates
22319 Compile your code with @option{-fno-implicit-templates} to disable the
22320 implicit generation of template instances, and explicitly instantiate
22321 all the ones you use.  This approach requires more knowledge of exactly
22322 which instances you need than do the others, but it's less
22323 mysterious and allows greater control if you want to ensure that only
22324 the intended instances are used.
22326 If you are using Cfront-model code, you can probably get away with not
22327 using @option{-fno-implicit-templates} when compiling files that don't
22328 @samp{#include} the member template definitions.
22330 If you use one big file to do the instantiations, you may want to
22331 compile it without @option{-fno-implicit-templates} so you get all of the
22332 instances required by your explicit instantiations (but not by any
22333 other files) without having to specify them as well.
22335 In addition to forward declaration of explicit instantiations
22336 (with @code{extern}), G++ has extended the template instantiation
22337 syntax to support instantiation of the compiler support data for a
22338 template class (i.e.@: the vtable) without instantiating any of its
22339 members (with @code{inline}), and instantiation of only the static data
22340 members of a template class, without the support data or member
22341 functions (with @code{static}):
22343 @smallexample
22344 inline template class Foo<int>;
22345 static template class Foo<int>;
22346 @end smallexample
22347 @end enumerate
22349 @node Bound member functions
22350 @section Extracting the Function Pointer from a Bound Pointer to Member Function
22351 @cindex pmf
22352 @cindex pointer to member function
22353 @cindex bound pointer to member function
22355 In C++, pointer to member functions (PMFs) are implemented using a wide
22356 pointer of sorts to handle all the possible call mechanisms; the PMF
22357 needs to store information about how to adjust the @samp{this} pointer,
22358 and if the function pointed to is virtual, where to find the vtable, and
22359 where in the vtable to look for the member function.  If you are using
22360 PMFs in an inner loop, you should really reconsider that decision.  If
22361 that is not an option, you can extract the pointer to the function that
22362 would be called for a given object/PMF pair and call it directly inside
22363 the inner loop, to save a bit of time.
22365 Note that you still pay the penalty for the call through a
22366 function pointer; on most modern architectures, such a call defeats the
22367 branch prediction features of the CPU@.  This is also true of normal
22368 virtual function calls.
22370 The syntax for this extension is
22372 @smallexample
22373 extern A a;
22374 extern int (A::*fp)();
22375 typedef int (*fptr)(A *);
22377 fptr p = (fptr)(a.*fp);
22378 @end smallexample
22380 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
22381 no object is needed to obtain the address of the function.  They can be
22382 converted to function pointers directly:
22384 @smallexample
22385 fptr p1 = (fptr)(&A::foo);
22386 @end smallexample
22388 @opindex Wno-pmf-conversions
22389 You must specify @option{-Wno-pmf-conversions} to use this extension.
22391 @node C++ Attributes
22392 @section C++-Specific Variable, Function, and Type Attributes
22394 Some attributes only make sense for C++ programs.
22396 @table @code
22397 @item abi_tag ("@var{tag}", ...)
22398 @cindex @code{abi_tag} function attribute
22399 @cindex @code{abi_tag} variable attribute
22400 @cindex @code{abi_tag} type attribute
22401 The @code{abi_tag} attribute can be applied to a function, variable, or class
22402 declaration.  It modifies the mangled name of the entity to
22403 incorporate the tag name, in order to distinguish the function or
22404 class from an earlier version with a different ABI; perhaps the class
22405 has changed size, or the function has a different return type that is
22406 not encoded in the mangled name.
22408 The attribute can also be applied to an inline namespace, but does not
22409 affect the mangled name of the namespace; in this case it is only used
22410 for @option{-Wabi-tag} warnings and automatic tagging of functions and
22411 variables.  Tagging inline namespaces is generally preferable to
22412 tagging individual declarations, but the latter is sometimes
22413 necessary, such as when only certain members of a class need to be
22414 tagged.
22416 The argument can be a list of strings of arbitrary length.  The
22417 strings are sorted on output, so the order of the list is
22418 unimportant.
22420 A redeclaration of an entity must not add new ABI tags,
22421 since doing so would change the mangled name.
22423 The ABI tags apply to a name, so all instantiations and
22424 specializations of a template have the same tags.  The attribute will
22425 be ignored if applied to an explicit specialization or instantiation.
22427 The @option{-Wabi-tag} flag enables a warning about a class which does
22428 not have all the ABI tags used by its subobjects and virtual functions; for users with code
22429 that needs to coexist with an earlier ABI, using this option can help
22430 to find all affected types that need to be tagged.
22432 When a type involving an ABI tag is used as the type of a variable or
22433 return type of a function where that tag is not already present in the
22434 signature of the function, the tag is automatically applied to the
22435 variable or function.  @option{-Wabi-tag} also warns about this
22436 situation; this warning can be avoided by explicitly tagging the
22437 variable or function or moving it into a tagged inline namespace.
22439 @item init_priority (@var{priority})
22440 @cindex @code{init_priority} variable attribute
22442 In Standard C++, objects defined at namespace scope are guaranteed to be
22443 initialized in an order in strict accordance with that of their definitions
22444 @emph{in a given translation unit}.  No guarantee is made for initializations
22445 across translation units.  However, GNU C++ allows users to control the
22446 order of initialization of objects defined at namespace scope with the
22447 @code{init_priority} attribute by specifying a relative @var{priority},
22448 a constant integral expression currently bounded between 101 and 65535
22449 inclusive.  Lower numbers indicate a higher priority.
22451 In the following example, @code{A} would normally be created before
22452 @code{B}, but the @code{init_priority} attribute reverses that order:
22454 @smallexample
22455 Some_Class  A  __attribute__ ((init_priority (2000)));
22456 Some_Class  B  __attribute__ ((init_priority (543)));
22457 @end smallexample
22459 @noindent
22460 Note that the particular values of @var{priority} do not matter; only their
22461 relative ordering.
22463 @item warn_unused
22464 @cindex @code{warn_unused} type attribute
22466 For C++ types with non-trivial constructors and/or destructors it is
22467 impossible for the compiler to determine whether a variable of this
22468 type is truly unused if it is not referenced. This type attribute
22469 informs the compiler that variables of this type should be warned
22470 about if they appear to be unused, just like variables of fundamental
22471 types.
22473 This attribute is appropriate for types which just represent a value,
22474 such as @code{std::string}; it is not appropriate for types which
22475 control a resource, such as @code{std::lock_guard}.
22477 This attribute is also accepted in C, but it is unnecessary because C
22478 does not have constructors or destructors.
22480 @end table
22482 @node Function Multiversioning
22483 @section Function Multiversioning
22484 @cindex function versions
22486 With the GNU C++ front end, for x86 targets, you may specify multiple
22487 versions of a function, where each function is specialized for a
22488 specific target feature.  At runtime, the appropriate version of the
22489 function is automatically executed depending on the characteristics of
22490 the execution platform.  Here is an example.
22492 @smallexample
22493 __attribute__ ((target ("default")))
22494 int foo ()
22496   // The default version of foo.
22497   return 0;
22500 __attribute__ ((target ("sse4.2")))
22501 int foo ()
22503   // foo version for SSE4.2
22504   return 1;
22507 __attribute__ ((target ("arch=atom")))
22508 int foo ()
22510   // foo version for the Intel ATOM processor
22511   return 2;
22514 __attribute__ ((target ("arch=amdfam10")))
22515 int foo ()
22517   // foo version for the AMD Family 0x10 processors.
22518   return 3;
22521 int main ()
22523   int (*p)() = &foo;
22524   assert ((*p) () == foo ());
22525   return 0;
22527 @end smallexample
22529 In the above example, four versions of function foo are created. The
22530 first version of foo with the target attribute "default" is the default
22531 version.  This version gets executed when no other target specific
22532 version qualifies for execution on a particular platform. A new version
22533 of foo is created by using the same function signature but with a
22534 different target string.  Function foo is called or a pointer to it is
22535 taken just like a regular function.  GCC takes care of doing the
22536 dispatching to call the right version at runtime.  Refer to the
22537 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
22538 Function Multiversioning} for more details.
22540 @node Type Traits
22541 @section Type Traits
22543 The C++ front end implements syntactic extensions that allow
22544 compile-time determination of 
22545 various characteristics of a type (or of a
22546 pair of types).
22548 @table @code
22549 @item __has_nothrow_assign (type)
22550 If @code{type} is const qualified or is a reference type then the trait is
22551 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22552 is true, else if @code{type} is a cv class or union type with copy assignment
22553 operators that are known not to throw an exception then the trait is true,
22554 else it is false.  Requires: @code{type} shall be a complete type,
22555 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22557 @item __has_nothrow_copy (type)
22558 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22559 @code{type} is a cv class or union type with copy constructors that
22560 are known not to throw an exception then the trait is true, else it is false.
22561 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22562 @code{void}, or an array of unknown bound.
22564 @item __has_nothrow_constructor (type)
22565 If @code{__has_trivial_constructor (type)} is true then the trait is
22566 true, else if @code{type} is a cv class or union type (or array
22567 thereof) with a default constructor that is known not to throw an
22568 exception then the trait is true, else it is false.  Requires:
22569 @code{type} shall be a complete type, (possibly cv-qualified)
22570 @code{void}, or an array of unknown bound.
22572 @item __has_trivial_assign (type)
22573 If @code{type} is const qualified or is a reference type then the trait is
22574 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
22575 true, else if @code{type} is a cv class or union type with a trivial
22576 copy assignment ([class.copy]) then the trait is true, else it is
22577 false.  Requires: @code{type} shall be a complete type, (possibly
22578 cv-qualified) @code{void}, or an array of unknown bound.
22580 @item __has_trivial_copy (type)
22581 If @code{__is_pod (type)} is true or @code{type} is a reference type
22582 then the trait is true, else if @code{type} is a cv class or union type
22583 with a trivial copy constructor ([class.copy]) then the trait
22584 is true, else it is false.  Requires: @code{type} shall be a complete
22585 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22587 @item __has_trivial_constructor (type)
22588 If @code{__is_pod (type)} is true then the trait is true, else if
22589 @code{type} is a cv class or union type (or array thereof) with a
22590 trivial default constructor ([class.ctor]) then the trait is true,
22591 else it is false.  Requires: @code{type} shall be a complete
22592 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22594 @item __has_trivial_destructor (type)
22595 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22596 the trait is true, else if @code{type} is a cv class or union type (or
22597 array thereof) with a trivial destructor ([class.dtor]) then the trait
22598 is true, else it is false.  Requires: @code{type} shall be a complete
22599 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22601 @item __has_virtual_destructor (type)
22602 If @code{type} is a class type with a virtual destructor
22603 ([class.dtor]) then the trait is true, else it is false.  Requires:
22604 @code{type} shall be a complete type, (possibly cv-qualified)
22605 @code{void}, or an array of unknown bound.
22607 @item __is_abstract (type)
22608 If @code{type} is an abstract class ([class.abstract]) then the trait
22609 is true, else it is false.  Requires: @code{type} shall be a complete
22610 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22612 @item __is_base_of (base_type, derived_type)
22613 If @code{base_type} is a base class of @code{derived_type}
22614 ([class.derived]) then the trait is true, otherwise it is false.
22615 Top-level cv qualifications of @code{base_type} and
22616 @code{derived_type} are ignored.  For the purposes of this trait, a
22617 class type is considered is own base.  Requires: if @code{__is_class
22618 (base_type)} and @code{__is_class (derived_type)} are true and
22619 @code{base_type} and @code{derived_type} are not the same type
22620 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22621 type.  A diagnostic is produced if this requirement is not met.
22623 @item __is_class (type)
22624 If @code{type} is a cv class type, and not a union type
22625 ([basic.compound]) the trait is true, else it is false.
22627 @item __is_empty (type)
22628 If @code{__is_class (type)} is false then the trait is false.
22629 Otherwise @code{type} is considered empty if and only if: @code{type}
22630 has no non-static data members, or all non-static data members, if
22631 any, are bit-fields of length 0, and @code{type} has no virtual
22632 members, and @code{type} has no virtual base classes, and @code{type}
22633 has no base classes @code{base_type} for which
22634 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
22635 be a complete type, (possibly cv-qualified) @code{void}, or an array
22636 of unknown bound.
22638 @item __is_enum (type)
22639 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22640 true, else it is false.
22642 @item __is_literal_type (type)
22643 If @code{type} is a literal type ([basic.types]) the trait is
22644 true, else it is false.  Requires: @code{type} shall be a complete type,
22645 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22647 @item __is_pod (type)
22648 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22649 else it is false.  Requires: @code{type} shall be a complete type,
22650 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22652 @item __is_polymorphic (type)
22653 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22654 is true, else it is false.  Requires: @code{type} shall be a complete
22655 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22657 @item __is_standard_layout (type)
22658 If @code{type} is a standard-layout type ([basic.types]) the trait is
22659 true, else it is false.  Requires: @code{type} shall be a complete
22660 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22662 @item __is_trivial (type)
22663 If @code{type} is a trivial type ([basic.types]) the trait is
22664 true, else it is false.  Requires: @code{type} shall be a complete
22665 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22667 @item __is_union (type)
22668 If @code{type} is a cv union type ([basic.compound]) the trait is
22669 true, else it is false.
22671 @item __underlying_type (type)
22672 The underlying type of @code{type}.  Requires: @code{type} shall be
22673 an enumeration type ([dcl.enum]).
22675 @item __integer_pack (length)
22676 When used as the pattern of a pack expansion within a template
22677 definition, expands to a template argument pack containing integers
22678 from @code{0} to @code{length-1}.  This is provided for efficient
22679 implementation of @code{std::make_integer_sequence}.
22681 @end table
22684 @node C++ Concepts
22685 @section C++ Concepts
22687 C++ concepts provide much-improved support for generic programming. In
22688 particular, they allow the specification of constraints on template arguments.
22689 The constraints are used to extend the usual overloading and partial
22690 specialization capabilities of the language, allowing generic data structures
22691 and algorithms to be ``refined'' based on their properties rather than their
22692 type names.
22694 The following keywords are reserved for concepts.
22696 @table @code
22697 @item assumes
22698 States an expression as an assumption, and if possible, verifies that the
22699 assumption is valid. For example, @code{assume(n > 0)}.
22701 @item axiom
22702 Introduces an axiom definition. Axioms introduce requirements on values.
22704 @item forall
22705 Introduces a universally quantified object in an axiom. For example,
22706 @code{forall (int n) n + 0 == n}).
22708 @item concept
22709 Introduces a concept definition. Concepts are sets of syntactic and semantic
22710 requirements on types and their values.
22712 @item requires
22713 Introduces constraints on template arguments or requirements for a member
22714 function of a class template.
22716 @end table
22718 The front end also exposes a number of internal mechanism that can be used
22719 to simplify the writing of type traits. Note that some of these traits are
22720 likely to be removed in the future.
22722 @table @code
22723 @item __is_same (type1, type2)
22724 A binary type trait: true whenever the type arguments are the same.
22726 @end table
22729 @node Deprecated Features
22730 @section Deprecated Features
22732 In the past, the GNU C++ compiler was extended to experiment with new
22733 features, at a time when the C++ language was still evolving.  Now that
22734 the C++ standard is complete, some of those features are superseded by
22735 superior alternatives.  Using the old features might cause a warning in
22736 some cases that the feature will be dropped in the future.  In other
22737 cases, the feature might be gone already.
22739 While the list below is not exhaustive, it documents some of the options
22740 that are now deprecated:
22742 @table @code
22743 @item -fexternal-templates
22744 @itemx -falt-external-templates
22745 These are two of the many ways for G++ to implement template
22746 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
22747 defines how template definitions have to be organized across
22748 implementation units.  G++ has an implicit instantiation mechanism that
22749 should work just fine for standard-conforming code.
22751 @item -fstrict-prototype
22752 @itemx -fno-strict-prototype
22753 Previously it was possible to use an empty prototype parameter list to
22754 indicate an unspecified number of parameters (like C), rather than no
22755 parameters, as C++ demands.  This feature has been removed, except where
22756 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
22757 @end table
22759 G++ allows a virtual function returning @samp{void *} to be overridden
22760 by one returning a different pointer type.  This extension to the
22761 covariant return type rules is now deprecated and will be removed from a
22762 future version.
22764 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22765 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22766 and are now removed from G++.  Code using these operators should be
22767 modified to use @code{std::min} and @code{std::max} instead.
22769 The named return value extension has been deprecated, and is now
22770 removed from G++.
22772 The use of initializer lists with new expressions has been deprecated,
22773 and is now removed from G++.
22775 Floating and complex non-type template parameters have been deprecated,
22776 and are now removed from G++.
22778 The implicit typename extension has been deprecated and is now
22779 removed from G++.
22781 The use of default arguments in function pointers, function typedefs
22782 and other places where they are not permitted by the standard is
22783 deprecated and will be removed from a future version of G++.
22785 G++ allows floating-point literals to appear in integral constant expressions,
22786 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22787 This extension is deprecated and will be removed from a future version.
22789 G++ allows static data members of const floating-point type to be declared
22790 with an initializer in a class definition. The standard only allows
22791 initializers for static members of const integral types and const
22792 enumeration types so this extension has been deprecated and will be removed
22793 from a future version.
22795 @node Backwards Compatibility
22796 @section Backwards Compatibility
22797 @cindex Backwards Compatibility
22798 @cindex ARM [Annotated C++ Reference Manual]
22800 Now that there is a definitive ISO standard C++, G++ has a specification
22801 to adhere to.  The C++ language evolved over time, and features that
22802 used to be acceptable in previous drafts of the standard, such as the ARM
22803 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
22804 compilation of C++ written to such drafts, G++ contains some backwards
22805 compatibilities.  @emph{All such backwards compatibility features are
22806 liable to disappear in future versions of G++.} They should be considered
22807 deprecated.   @xref{Deprecated Features}.
22809 @table @code
22810 @item For scope
22811 If a variable is declared at for scope, it used to remain in scope until
22812 the end of the scope that contained the for statement (rather than just
22813 within the for scope).  G++ retains this, but issues a warning, if such a
22814 variable is accessed outside the for scope.
22816 @item Implicit C language
22817 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22818 scope to set the language.  On such systems, all header files are
22819 implicitly scoped inside a C language scope.  Also, an empty prototype
22820 @code{()} is treated as an unspecified number of arguments, rather
22821 than no arguments, as C++ demands.
22822 @end table
22824 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
22825 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr