gcc/ChangeLog:
[official-gcc.git] / gcc / doc / extend.texi
blob5cb512fe5754402118b895a332161df3bb7c5f9f
1 @c Copyright (C) 1988-2017 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax::    Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments::        C++ comments are recognized.
67 * Dollar Signs::        Dollar sign is allowed in identifiers.
68 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
69 * Alignment::           Inquiring about the alignment of a type or variable.
70 * Inline::              Defining inline functions (as fast as macros).
71 * Volatiles::           What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83                         arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86                         checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
89 * Other Builtins::      Other built-in functions.
90 * Target Builtins::     Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas::             Pragmas accepted by GCC.
93 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
94 * Thread-Local::        Per-thread variables.
95 * Binary constants::    Binary constants using the @samp{0b} prefix.
96 @end menu
98 @node Statement Exprs
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@.  This allows you to use loops, switches, and local variables
109 within an expression.
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces.  For
113 example:
115 @smallexample
116 (@{ int y = foo (); int z;
117    if (y > 0) z = y;
118    else z = - y;
119    z; @})
120 @end smallexample
122 @noindent
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct.  (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once).  For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
135 follows:
137 @smallexample
138 #define max(a,b) ((a) > (b) ? (a) : (b))
139 @end smallexample
141 @noindent
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects.  In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
148 @smallexample
149 #define maxint(a,b) \
150   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 @end smallexample
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression.  For instance, if @code{A} is a class, then
164 @smallexample
165         A a;
167         (@{a;@}).Foo ()
168 @end smallexample
170 @noindent
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 address of @code{a}.
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end.  This makes statement
178 expressions inside macros slightly different from function calls.  In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call.  In the statement expression case they are destroyed during
182 the statement expression.  For instance,
184 @smallexample
185 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
188 void foo ()
190   macro (X ());
191   function (X ());
193 @end smallexample
195 @noindent
196 has different places where temporaries are destroyed.  For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}.  In the @code{function} case that
199 temporary is destroyed when the function returns.
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++.  (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
205 bug.)
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted.  Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression.  In any case, as with a function call, the evaluation of a
218 statement expression is not interleaved with the evaluation of other
219 parts of the containing expression.  For example,
221 @smallexample
222   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
223 @end smallexample
225 @noindent
226 calls @code{foo} and @code{bar1} and does not call @code{baz} but
227 may or may not call @code{bar2}.  If @code{bar2} is called, it is
228 called after @code{foo} and before @code{bar1}.
230 @node Local Labels
231 @section Locally Declared Labels
232 @cindex local labels
233 @cindex macros, local labels
235 GCC allows you to declare @dfn{local labels} in any nested block
236 scope.  A local label is just like an ordinary label, but you can
237 only reference it (with a @code{goto} statement, or by taking its
238 address) within the block in which it is declared.
240 A local label declaration looks like this:
242 @smallexample
243 __label__ @var{label};
244 @end smallexample
246 @noindent
249 @smallexample
250 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 @end smallexample
253 Local label declarations must come at the beginning of the block,
254 before any ordinary declarations or statements.
256 The label declaration defines the label @emph{name}, but does not define
257 the label itself.  You must do this in the usual way, with
258 @code{@var{label}:}, within the statements of the statement expression.
260 The local label feature is useful for complex macros.  If a macro
261 contains nested loops, a @code{goto} can be useful for breaking out of
262 them.  However, an ordinary label whose scope is the whole function
263 cannot be used: if the macro can be expanded several times in one
264 function, the label is multiply defined in that function.  A
265 local label avoids this problem.  For example:
267 @smallexample
268 #define SEARCH(value, array, target)              \
269 do @{                                              \
270   __label__ found;                                \
271   typeof (target) _SEARCH_target = (target);      \
272   typeof (*(array)) *_SEARCH_array = (array);     \
273   int i, j;                                       \
274   int value;                                      \
275   for (i = 0; i < max; i++)                       \
276     for (j = 0; j < max; j++)                     \
277       if (_SEARCH_array[i][j] == _SEARCH_target)  \
278         @{ (value) = i; goto found; @}              \
279   (value) = -1;                                   \
280  found:;                                          \
281 @} while (0)
282 @end smallexample
284 This could also be written using a statement expression:
286 @smallexample
287 #define SEARCH(array, target)                     \
288 (@{                                                \
289   __label__ found;                                \
290   typeof (target) _SEARCH_target = (target);      \
291   typeof (*(array)) *_SEARCH_array = (array);     \
292   int i, j;                                       \
293   int value;                                      \
294   for (i = 0; i < max; i++)                       \
295     for (j = 0; j < max; j++)                     \
296       if (_SEARCH_array[i][j] == _SEARCH_target)  \
297         @{ value = i; goto found; @}                \
298   value = -1;                                     \
299  found:                                           \
300   value;                                          \
302 @end smallexample
304 Local label declarations also make the labels they declare visible to
305 nested functions, if there are any.  @xref{Nested Functions}, for details.
307 @node Labels as Values
308 @section Labels as Values
309 @cindex labels as values
310 @cindex computed gotos
311 @cindex goto with computed label
312 @cindex address of a label
314 You can get the address of a label defined in the current function
315 (or a containing function) with the unary operator @samp{&&}.  The
316 value has type @code{void *}.  This value is a constant and can be used
317 wherever a constant of that type is valid.  For example:
319 @smallexample
320 void *ptr;
321 /* @r{@dots{}} */
322 ptr = &&foo;
323 @end smallexample
325 To use these values, you need to be able to jump to one.  This is done
326 with the computed goto statement@footnote{The analogous feature in
327 Fortran is called an assigned goto, but that name seems inappropriate in
328 C, where one can do more than simply store label addresses in label
329 variables.}, @code{goto *@var{exp};}.  For example,
331 @smallexample
332 goto *ptr;
333 @end smallexample
335 @noindent
336 Any expression of type @code{void *} is allowed.
338 One way of using these constants is in initializing a static array that
339 serves as a jump table:
341 @smallexample
342 static void *array[] = @{ &&foo, &&bar, &&hack @};
343 @end smallexample
345 @noindent
346 Then you can select a label with indexing, like this:
348 @smallexample
349 goto *array[i];
350 @end smallexample
352 @noindent
353 Note that this does not check whether the subscript is in bounds---array
354 indexing in C never does that.
356 Such an array of label values serves a purpose much like that of the
357 @code{switch} statement.  The @code{switch} statement is cleaner, so
358 use that rather than an array unless the problem does not fit a
359 @code{switch} statement very well.
361 Another use of label values is in an interpreter for threaded code.
362 The labels within the interpreter function can be stored in the
363 threaded code for super-fast dispatching.
365 You may not use this mechanism to jump to code in a different function.
366 If you do that, totally unpredictable things happen.  The best way to
367 avoid this is to store the label address only in automatic variables and
368 never pass it as an argument.
370 An alternate way to write the above example is
372 @smallexample
373 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374                              &&hack - &&foo @};
375 goto *(&&foo + array[i]);
376 @end smallexample
378 @noindent
379 This is more friendly to code living in shared libraries, as it reduces
380 the number of dynamic relocations that are needed, and by consequence,
381 allows the data to be read-only.
382 This alternative with label differences is not supported for the AVR target,
383 please use the first approach for AVR programs.
385 The @code{&&foo} expressions for the same label might have different
386 values if the containing function is inlined or cloned.  If a program
387 relies on them being always the same,
388 @code{__attribute__((__noinline__,__noclone__))} should be used to
389 prevent inlining and cloning.  If @code{&&foo} is used in a static
390 variable initializer, inlining and cloning is forbidden.
392 @node Nested Functions
393 @section Nested Functions
394 @cindex nested functions
395 @cindex downward funargs
396 @cindex thunks
398 A @dfn{nested function} is a function defined inside another function.
399 Nested functions are supported as an extension in GNU C, but are not
400 supported by GNU C++.
402 The nested function's name is local to the block where it is defined.
403 For example, here we define a nested function named @code{square}, and
404 call it twice:
406 @smallexample
407 @group
408 foo (double a, double b)
410   double square (double z) @{ return z * z; @}
412   return square (a) + square (b);
414 @end group
415 @end smallexample
417 The nested function can access all the variables of the containing
418 function that are visible at the point of its definition.  This is
419 called @dfn{lexical scoping}.  For example, here we show a nested
420 function which uses an inherited variable named @code{offset}:
422 @smallexample
423 @group
424 bar (int *array, int offset, int size)
426   int access (int *array, int index)
427     @{ return array[index + offset]; @}
428   int i;
429   /* @r{@dots{}} */
430   for (i = 0; i < size; i++)
431     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
433 @end group
434 @end smallexample
436 Nested function definitions are permitted within functions in the places
437 where variable definitions are allowed; that is, in any block, mixed
438 with the other declarations and statements in the block.
440 It is possible to call the nested function from outside the scope of its
441 name by storing its address or passing the address to another function:
443 @smallexample
444 hack (int *array, int size)
446   void store (int index, int value)
447     @{ array[index] = value; @}
449   intermediate (store, size);
451 @end smallexample
453 Here, the function @code{intermediate} receives the address of
454 @code{store} as an argument.  If @code{intermediate} calls @code{store},
455 the arguments given to @code{store} are used to store into @code{array}.
456 But this technique works only so long as the containing function
457 (@code{hack}, in this example) does not exit.
459 If you try to call the nested function through its address after the
460 containing function exits, all hell breaks loose.  If you try
461 to call it after a containing scope level exits, and if it refers
462 to some of the variables that are no longer in scope, you may be lucky,
463 but it's not wise to take the risk.  If, however, the nested function
464 does not refer to anything that has gone out of scope, you should be
465 safe.
467 GCC implements taking the address of a nested function using a technique
468 called @dfn{trampolines}.  This technique was described in
469 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
470 C++ Conference Proceedings, October 17-21, 1988).
472 A nested function can jump to a label inherited from a containing
473 function, provided the label is explicitly declared in the containing
474 function (@pxref{Local Labels}).  Such a jump returns instantly to the
475 containing function, exiting the nested function that did the
476 @code{goto} and any intermediate functions as well.  Here is an example:
478 @smallexample
479 @group
480 bar (int *array, int offset, int size)
482   __label__ failure;
483   int access (int *array, int index)
484     @{
485       if (index > size)
486         goto failure;
487       return array[index + offset];
488     @}
489   int i;
490   /* @r{@dots{}} */
491   for (i = 0; i < size; i++)
492     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
493   /* @r{@dots{}} */
494   return 0;
496  /* @r{Control comes here from @code{access}
497     if it detects an error.}  */
498  failure:
499   return -1;
501 @end group
502 @end smallexample
504 A nested function always has no linkage.  Declaring one with
505 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
506 before its definition, use @code{auto} (which is otherwise meaningless
507 for function declarations).
509 @smallexample
510 bar (int *array, int offset, int size)
512   __label__ failure;
513   auto int access (int *, int);
514   /* @r{@dots{}} */
515   int access (int *array, int index)
516     @{
517       if (index > size)
518         goto failure;
519       return array[index + offset];
520     @}
521   /* @r{@dots{}} */
523 @end smallexample
525 @node Constructing Calls
526 @section Constructing Function Calls
527 @cindex constructing calls
528 @cindex forwarding calls
530 Using the built-in functions described below, you can record
531 the arguments a function received, and call another function
532 with the same arguments, without knowing the number or types
533 of the arguments.
535 You can also record the return value of that function call,
536 and later return that value, without knowing what data type
537 the function tried to return (as long as your caller expects
538 that data type).
540 However, these built-in functions may interact badly with some
541 sophisticated features or other extensions of the language.  It
542 is, therefore, not recommended to use them outside very simple
543 functions acting as mere forwarders for their arguments.
545 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
546 This built-in function returns a pointer to data
547 describing how to perform a call with the same arguments as are passed
548 to the current function.
550 The function saves the arg pointer register, structure value address,
551 and all registers that might be used to pass arguments to a function
552 into a block of memory allocated on the stack.  Then it returns the
553 address of that block.
554 @end deftypefn
556 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
557 This built-in function invokes @var{function}
558 with a copy of the parameters described by @var{arguments}
559 and @var{size}.
561 The value of @var{arguments} should be the value returned by
562 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
563 of the stack argument data, in bytes.
565 This function returns a pointer to data describing
566 how to return whatever value is returned by @var{function}.  The data
567 is saved in a block of memory allocated on the stack.
569 It is not always simple to compute the proper value for @var{size}.  The
570 value is used by @code{__builtin_apply} to compute the amount of data
571 that should be pushed on the stack and copied from the incoming argument
572 area.
573 @end deftypefn
575 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
576 This built-in function returns the value described by @var{result} from
577 the containing function.  You should specify, for @var{result}, a value
578 returned by @code{__builtin_apply}.
579 @end deftypefn
581 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
582 This built-in function represents all anonymous arguments of an inline
583 function.  It can be used only in inline functions that are always
584 inlined, never compiled as a separate function, such as those using
585 @code{__attribute__ ((__always_inline__))} or
586 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
587 It must be only passed as last argument to some other function
588 with variable arguments.  This is useful for writing small wrapper
589 inlines for variable argument functions, when using preprocessor
590 macros is undesirable.  For example:
591 @smallexample
592 extern int myprintf (FILE *f, const char *format, ...);
593 extern inline __attribute__ ((__gnu_inline__)) int
594 myprintf (FILE *f, const char *format, ...)
596   int r = fprintf (f, "myprintf: ");
597   if (r < 0)
598     return r;
599   int s = fprintf (f, format, __builtin_va_arg_pack ());
600   if (s < 0)
601     return s;
602   return r + s;
604 @end smallexample
605 @end deftypefn
607 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
608 This built-in function returns the number of anonymous arguments of
609 an inline function.  It can be used only in inline functions that
610 are always inlined, never compiled as a separate function, such
611 as those using @code{__attribute__ ((__always_inline__))} or
612 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
613 For example following does link- or run-time checking of open
614 arguments for optimized code:
615 @smallexample
616 #ifdef __OPTIMIZE__
617 extern inline __attribute__((__gnu_inline__)) int
618 myopen (const char *path, int oflag, ...)
620   if (__builtin_va_arg_pack_len () > 1)
621     warn_open_too_many_arguments ();
623   if (__builtin_constant_p (oflag))
624     @{
625       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
626         @{
627           warn_open_missing_mode ();
628           return __open_2 (path, oflag);
629         @}
630       return open (path, oflag, __builtin_va_arg_pack ());
631     @}
633   if (__builtin_va_arg_pack_len () < 1)
634     return __open_2 (path, oflag);
636   return open (path, oflag, __builtin_va_arg_pack ());
638 #endif
639 @end smallexample
640 @end deftypefn
642 @node Typeof
643 @section Referring to a Type with @code{typeof}
644 @findex typeof
645 @findex sizeof
646 @cindex macros, types of arguments
648 Another way to refer to the type of an expression is with @code{typeof}.
649 The syntax of using of this keyword looks like @code{sizeof}, but the
650 construct acts semantically like a type name defined with @code{typedef}.
652 There are two ways of writing the argument to @code{typeof}: with an
653 expression or with a type.  Here is an example with an expression:
655 @smallexample
656 typeof (x[0](1))
657 @end smallexample
659 @noindent
660 This assumes that @code{x} is an array of pointers to functions;
661 the type described is that of the values of the functions.
663 Here is an example with a typename as the argument:
665 @smallexample
666 typeof (int *)
667 @end smallexample
669 @noindent
670 Here the type described is that of pointers to @code{int}.
672 If you are writing a header file that must work when included in ISO C
673 programs, write @code{__typeof__} instead of @code{typeof}.
674 @xref{Alternate Keywords}.
676 A @code{typeof} construct can be used anywhere a typedef name can be
677 used.  For example, you can use it in a declaration, in a cast, or inside
678 of @code{sizeof} or @code{typeof}.
680 The operand of @code{typeof} is evaluated for its side effects if and
681 only if it is an expression of variably modified type or the name of
682 such a type.
684 @code{typeof} is often useful in conjunction with
685 statement expressions (@pxref{Statement Exprs}).
686 Here is how the two together can
687 be used to define a safe ``maximum'' macro which operates on any
688 arithmetic type and evaluates each of its arguments exactly once:
690 @smallexample
691 #define max(a,b) \
692   (@{ typeof (a) _a = (a); \
693       typeof (b) _b = (b); \
694     _a > _b ? _a : _b; @})
695 @end smallexample
697 @cindex underscores in variables in macros
698 @cindex @samp{_} in variables in macros
699 @cindex local variables in macros
700 @cindex variables, local, in macros
701 @cindex macros, local variables in
703 The reason for using names that start with underscores for the local
704 variables is to avoid conflicts with variable names that occur within the
705 expressions that are substituted for @code{a} and @code{b}.  Eventually we
706 hope to design a new form of declaration syntax that allows you to declare
707 variables whose scopes start only after their initializers; this will be a
708 more reliable way to prevent such conflicts.
710 @noindent
711 Some more examples of the use of @code{typeof}:
713 @itemize @bullet
714 @item
715 This declares @code{y} with the type of what @code{x} points to.
717 @smallexample
718 typeof (*x) y;
719 @end smallexample
721 @item
722 This declares @code{y} as an array of such values.
724 @smallexample
725 typeof (*x) y[4];
726 @end smallexample
728 @item
729 This declares @code{y} as an array of pointers to characters:
731 @smallexample
732 typeof (typeof (char *)[4]) y;
733 @end smallexample
735 @noindent
736 It is equivalent to the following traditional C declaration:
738 @smallexample
739 char *y[4];
740 @end smallexample
742 To see the meaning of the declaration using @code{typeof}, and why it
743 might be a useful way to write, rewrite it with these macros:
745 @smallexample
746 #define pointer(T)  typeof(T *)
747 #define array(T, N) typeof(T [N])
748 @end smallexample
750 @noindent
751 Now the declaration can be rewritten this way:
753 @smallexample
754 array (pointer (char), 4) y;
755 @end smallexample
757 @noindent
758 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
759 pointers to @code{char}.
760 @end itemize
762 In GNU C, but not GNU C++, you may also declare the type of a variable
763 as @code{__auto_type}.  In that case, the declaration must declare
764 only one variable, whose declarator must just be an identifier, the
765 declaration must be initialized, and the type of the variable is
766 determined by the initializer; the name of the variable is not in
767 scope until after the initializer.  (In C++, you should use C++11
768 @code{auto} for this purpose.)  Using @code{__auto_type}, the
769 ``maximum'' macro above could be written as:
771 @smallexample
772 #define max(a,b) \
773   (@{ __auto_type _a = (a); \
774       __auto_type _b = (b); \
775     _a > _b ? _a : _b; @})
776 @end smallexample
778 Using @code{__auto_type} instead of @code{typeof} has two advantages:
780 @itemize @bullet
781 @item Each argument to the macro appears only once in the expansion of
782 the macro.  This prevents the size of the macro expansion growing
783 exponentially when calls to such macros are nested inside arguments of
784 such macros.
786 @item If the argument to the macro has variably modified type, it is
787 evaluated only once when using @code{__auto_type}, but twice if
788 @code{typeof} is used.
789 @end itemize
791 @node Conditionals
792 @section Conditionals with Omitted Operands
793 @cindex conditional expressions, extensions
794 @cindex omitted middle-operands
795 @cindex middle-operands, omitted
796 @cindex extensions, @code{?:}
797 @cindex @code{?:} extensions
799 The middle operand in a conditional expression may be omitted.  Then
800 if the first operand is nonzero, its value is the value of the conditional
801 expression.
803 Therefore, the expression
805 @smallexample
806 x ? : y
807 @end smallexample
809 @noindent
810 has the value of @code{x} if that is nonzero; otherwise, the value of
811 @code{y}.
813 This example is perfectly equivalent to
815 @smallexample
816 x ? x : y
817 @end smallexample
819 @cindex side effect in @code{?:}
820 @cindex @code{?:} side effect
821 @noindent
822 In this simple case, the ability to omit the middle operand is not
823 especially useful.  When it becomes useful is when the first operand does,
824 or may (if it is a macro argument), contain a side effect.  Then repeating
825 the operand in the middle would perform the side effect twice.  Omitting
826 the middle operand uses the value already computed without the undesirable
827 effects of recomputing it.
829 @node __int128
830 @section 128-bit Integers
831 @cindex @code{__int128} data types
833 As an extension the integer scalar type @code{__int128} is supported for
834 targets which have an integer mode wide enough to hold 128 bits.
835 Simply write @code{__int128} for a signed 128-bit integer, or
836 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
837 support in GCC for expressing an integer constant of type @code{__int128}
838 for targets with @code{long long} integer less than 128 bits wide.
840 @node Long Long
841 @section Double-Word Integers
842 @cindex @code{long long} data types
843 @cindex double-word arithmetic
844 @cindex multiprecision arithmetic
845 @cindex @code{LL} integer suffix
846 @cindex @code{ULL} integer suffix
848 ISO C99 supports data types for integers that are at least 64 bits wide,
849 and as an extension GCC supports them in C90 mode and in C++.
850 Simply write @code{long long int} for a signed integer, or
851 @code{unsigned long long int} for an unsigned integer.  To make an
852 integer constant of type @code{long long int}, add the suffix @samp{LL}
853 to the integer.  To make an integer constant of type @code{unsigned long
854 long int}, add the suffix @samp{ULL} to the integer.
856 You can use these types in arithmetic like any other integer types.
857 Addition, subtraction, and bitwise boolean operations on these types
858 are open-coded on all types of machines.  Multiplication is open-coded
859 if the machine supports a fullword-to-doubleword widening multiply
860 instruction.  Division and shifts are open-coded only on machines that
861 provide special support.  The operations that are not open-coded use
862 special library routines that come with GCC@.
864 There may be pitfalls when you use @code{long long} types for function
865 arguments without function prototypes.  If a function
866 expects type @code{int} for its argument, and you pass a value of type
867 @code{long long int}, confusion results because the caller and the
868 subroutine disagree about the number of bytes for the argument.
869 Likewise, if the function expects @code{long long int} and you pass
870 @code{int}.  The best way to avoid such problems is to use prototypes.
872 @node Complex
873 @section Complex Numbers
874 @cindex complex numbers
875 @cindex @code{_Complex} keyword
876 @cindex @code{__complex__} keyword
878 ISO C99 supports complex floating data types, and as an extension GCC
879 supports them in C90 mode and in C++.  GCC also supports complex integer data
880 types which are not part of ISO C99.  You can declare complex types
881 using the keyword @code{_Complex}.  As an extension, the older GNU
882 keyword @code{__complex__} is also supported.
884 For example, @samp{_Complex double x;} declares @code{x} as a
885 variable whose real part and imaginary part are both of type
886 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
887 have real and imaginary parts of type @code{short int}; this is not
888 likely to be useful, but it shows that the set of complex types is
889 complete.
891 To write a constant with a complex data type, use the suffix @samp{i} or
892 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
893 has type @code{_Complex float} and @code{3i} has type
894 @code{_Complex int}.  Such a constant always has a pure imaginary
895 value, but you can form any complex value you like by adding one to a
896 real constant.  This is a GNU extension; if you have an ISO C99
897 conforming C library (such as the GNU C Library), and want to construct complex
898 constants of floating type, you should include @code{<complex.h>} and
899 use the macros @code{I} or @code{_Complex_I} instead.
901 @cindex @code{__real__} keyword
902 @cindex @code{__imag__} keyword
903 To extract the real part of a complex-valued expression @var{exp}, write
904 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
905 extract the imaginary part.  This is a GNU extension; for values of
906 floating type, you should use the ISO C99 functions @code{crealf},
907 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
908 @code{cimagl}, declared in @code{<complex.h>} and also provided as
909 built-in functions by GCC@.
911 @cindex complex conjugation
912 The operator @samp{~} performs complex conjugation when used on a value
913 with a complex type.  This is a GNU extension; for values of
914 floating type, you should use the ISO C99 functions @code{conjf},
915 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
916 provided as built-in functions by GCC@.
918 GCC can allocate complex automatic variables in a noncontiguous
919 fashion; it's even possible for the real part to be in a register while
920 the imaginary part is on the stack (or vice versa).  Only the DWARF
921 debug info format can represent this, so use of DWARF is recommended.
922 If you are using the stabs debug info format, GCC describes a noncontiguous
923 complex variable as if it were two separate variables of noncomplex type.
924 If the variable's actual name is @code{foo}, the two fictitious
925 variables are named @code{foo$real} and @code{foo$imag}.  You can
926 examine and set these two fictitious variables with your debugger.
928 @node Floating Types
929 @section Additional Floating Types
930 @cindex additional floating types
931 @cindex @code{_Float@var{n}} data types
932 @cindex @code{_Float@var{n}x} data types
933 @cindex @code{__float80} data type
934 @cindex @code{__float128} data type
935 @cindex @code{__ibm128} data type
936 @cindex @code{w} floating point suffix
937 @cindex @code{q} floating point suffix
938 @cindex @code{W} floating point suffix
939 @cindex @code{Q} floating point suffix
941 ISO/IEC TS 18661-3:2015 defines C support for additional floating
942 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
943 these type names; the set of types supported depends on the target
944 architecture.  These types are not supported when compiling C++.
945 Constants with these types use suffixes @code{f@var{n}} or
946 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
947 names can be used together with @code{_Complex} to declare complex
948 types.
950 As an extension, GNU C and GNU C++ support additional floating
951 types, which are not supported by all targets.
952 @itemize @bullet
953 @item @code{__float128} is available on i386, x86_64, IA-64, and
954 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
955 the vector scalar (VSX) instruction set.  @code{__float128} supports
956 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
957 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
958 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
959 double}.
961 @item @code{__float80} is available on the i386, x86_64, and IA-64
962 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
963 an alias for the type name @code{_Float64x} on these targets.
965 @item @code{__ibm128} is available on PowerPC targets, and provides
966 access to the IBM extended double format which is the current format
967 used for @code{long double}.  When @code{long double} transitions to
968 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
969 for use in conversions between the two types.
970 @end itemize
972 Support for these additional types includes the arithmetic operators:
973 add, subtract, multiply, divide; unary arithmetic operators;
974 relational operators; equality operators; and conversions to and from
975 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
976 in a literal constant of type @code{__float80} or type
977 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
979 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
980 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
981 expected in future versions of GCC that @code{_Float128} and @code{__float128}
982 will be enabled automatically.
984 The @code{_Float128} type is supported on all systems where
985 @code{__float128} is supported or where @code{long double} has the
986 IEEE binary128 format.  The @code{_Float64x} type is supported on all
987 systems where @code{__float128} is supported.  The @code{_Float32}
988 type is supported on all systems supporting IEEE binary32; the
989 @code{_Float64} and @code{_Float32x} types are supported on all systems
990 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
991 systems by default, and on ARM systems when the IEEE format for 16-bit
992 floating-point types is selected with @option{-mfp16-format=ieee}.
993 GCC does not currently support @code{_Float128x} on any systems.
995 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
996 types using the corresponding internal complex type, @code{XCmode} for
997 @code{__float80} type and @code{TCmode} for @code{__float128} type:
999 @smallexample
1000 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1001 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1002 @end smallexample
1004 On the PowerPC Linux VSX targets, you can declare complex types using
1005 the corresponding internal complex type, @code{KCmode} for
1006 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1008 @smallexample
1009 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1010 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1011 @end smallexample
1013 @node Half-Precision
1014 @section Half-Precision Floating Point
1015 @cindex half-precision floating point
1016 @cindex @code{__fp16} data type
1018 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1019 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1020 On ARM systems, you must enable this type explicitly with the
1021 @option{-mfp16-format} command-line option in order to use it.
1023 ARM targets support two incompatible representations for half-precision
1024 floating-point values.  You must choose one of the representations and
1025 use it consistently in your program.
1027 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1028 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1029 There are 11 bits of significand precision, approximately 3
1030 decimal digits.
1032 Specifying @option{-mfp16-format=alternative} selects the ARM
1033 alternative format.  This representation is similar to the IEEE
1034 format, but does not support infinities or NaNs.  Instead, the range
1035 of exponents is extended, so that this format can represent normalized
1036 values in the range of @math{2^{-14}} to 131008.
1038 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1039 not require use of the @option{-mfp16-format} command-line option.
1041 The @code{__fp16} type may only be used as an argument to intrinsics defined
1042 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1043 arithmetic and other operations, @code{__fp16} values in C or C++
1044 expressions are automatically promoted to @code{float}.
1046 The ARM target provides hardware support for conversions between
1047 @code{__fp16} and @code{float} values
1048 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8 provides
1049 hardware support for conversions between @code{__fp16} and @code{double}
1050 values.  GCC generates code using these hardware instructions if you
1051 compile with options to select an FPU that provides them;
1052 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1053 in addition to the @option{-mfp16-format} option to select
1054 a half-precision format.
1056 Language-level support for the @code{__fp16} data type is
1057 independent of whether GCC generates code using hardware floating-point
1058 instructions.  In cases where hardware support is not specified, GCC
1059 implements conversions between @code{__fp16} and other types as library
1060 calls.
1062 It is recommended that portable code use the @code{_Float16} type defined
1063 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1065 @node Decimal Float
1066 @section Decimal Floating Types
1067 @cindex decimal floating types
1068 @cindex @code{_Decimal32} data type
1069 @cindex @code{_Decimal64} data type
1070 @cindex @code{_Decimal128} data type
1071 @cindex @code{df} integer suffix
1072 @cindex @code{dd} integer suffix
1073 @cindex @code{dl} integer suffix
1074 @cindex @code{DF} integer suffix
1075 @cindex @code{DD} integer suffix
1076 @cindex @code{DL} integer suffix
1078 As an extension, GNU C supports decimal floating types as
1079 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1080 floating types in GCC will evolve as the draft technical report changes.
1081 Calling conventions for any target might also change.  Not all targets
1082 support decimal floating types.
1084 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1085 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1086 @code{float}, @code{double}, and @code{long double} whose radix is not
1087 specified by the C standard but is usually two.
1089 Support for decimal floating types includes the arithmetic operators
1090 add, subtract, multiply, divide; unary arithmetic operators;
1091 relational operators; equality operators; and conversions to and from
1092 integer and other floating types.  Use a suffix @samp{df} or
1093 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1094 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1095 @code{_Decimal128}.
1097 GCC support of decimal float as specified by the draft technical report
1098 is incomplete:
1100 @itemize @bullet
1101 @item
1102 When the value of a decimal floating type cannot be represented in the
1103 integer type to which it is being converted, the result is undefined
1104 rather than the result value specified by the draft technical report.
1106 @item
1107 GCC does not provide the C library functionality associated with
1108 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1109 @file{wchar.h}, which must come from a separate C library implementation.
1110 Because of this the GNU C compiler does not define macro
1111 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1112 the technical report.
1113 @end itemize
1115 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1116 are supported by the DWARF debug information format.
1118 @node Hex Floats
1119 @section Hex Floats
1120 @cindex hex floats
1122 ISO C99 supports floating-point numbers written not only in the usual
1123 decimal notation, such as @code{1.55e1}, but also numbers such as
1124 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1125 supports this in C90 mode (except in some cases when strictly
1126 conforming) and in C++.  In that format the
1127 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1128 mandatory.  The exponent is a decimal number that indicates the power of
1129 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1130 @tex
1131 $1 {15\over16}$,
1132 @end tex
1133 @ifnottex
1134 1 15/16,
1135 @end ifnottex
1136 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1137 is the same as @code{1.55e1}.
1139 Unlike for floating-point numbers in the decimal notation the exponent
1140 is always required in the hexadecimal notation.  Otherwise the compiler
1141 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1142 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1143 extension for floating-point constants of type @code{float}.
1145 @node Fixed-Point
1146 @section Fixed-Point Types
1147 @cindex fixed-point types
1148 @cindex @code{_Fract} data type
1149 @cindex @code{_Accum} data type
1150 @cindex @code{_Sat} data type
1151 @cindex @code{hr} fixed-suffix
1152 @cindex @code{r} fixed-suffix
1153 @cindex @code{lr} fixed-suffix
1154 @cindex @code{llr} fixed-suffix
1155 @cindex @code{uhr} fixed-suffix
1156 @cindex @code{ur} fixed-suffix
1157 @cindex @code{ulr} fixed-suffix
1158 @cindex @code{ullr} fixed-suffix
1159 @cindex @code{hk} fixed-suffix
1160 @cindex @code{k} fixed-suffix
1161 @cindex @code{lk} fixed-suffix
1162 @cindex @code{llk} fixed-suffix
1163 @cindex @code{uhk} fixed-suffix
1164 @cindex @code{uk} fixed-suffix
1165 @cindex @code{ulk} fixed-suffix
1166 @cindex @code{ullk} fixed-suffix
1167 @cindex @code{HR} fixed-suffix
1168 @cindex @code{R} fixed-suffix
1169 @cindex @code{LR} fixed-suffix
1170 @cindex @code{LLR} fixed-suffix
1171 @cindex @code{UHR} fixed-suffix
1172 @cindex @code{UR} fixed-suffix
1173 @cindex @code{ULR} fixed-suffix
1174 @cindex @code{ULLR} fixed-suffix
1175 @cindex @code{HK} fixed-suffix
1176 @cindex @code{K} fixed-suffix
1177 @cindex @code{LK} fixed-suffix
1178 @cindex @code{LLK} fixed-suffix
1179 @cindex @code{UHK} fixed-suffix
1180 @cindex @code{UK} fixed-suffix
1181 @cindex @code{ULK} fixed-suffix
1182 @cindex @code{ULLK} fixed-suffix
1184 As an extension, GNU C supports fixed-point types as
1185 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1186 types in GCC will evolve as the draft technical report changes.
1187 Calling conventions for any target might also change.  Not all targets
1188 support fixed-point types.
1190 The fixed-point types are
1191 @code{short _Fract},
1192 @code{_Fract},
1193 @code{long _Fract},
1194 @code{long long _Fract},
1195 @code{unsigned short _Fract},
1196 @code{unsigned _Fract},
1197 @code{unsigned long _Fract},
1198 @code{unsigned long long _Fract},
1199 @code{_Sat short _Fract},
1200 @code{_Sat _Fract},
1201 @code{_Sat long _Fract},
1202 @code{_Sat long long _Fract},
1203 @code{_Sat unsigned short _Fract},
1204 @code{_Sat unsigned _Fract},
1205 @code{_Sat unsigned long _Fract},
1206 @code{_Sat unsigned long long _Fract},
1207 @code{short _Accum},
1208 @code{_Accum},
1209 @code{long _Accum},
1210 @code{long long _Accum},
1211 @code{unsigned short _Accum},
1212 @code{unsigned _Accum},
1213 @code{unsigned long _Accum},
1214 @code{unsigned long long _Accum},
1215 @code{_Sat short _Accum},
1216 @code{_Sat _Accum},
1217 @code{_Sat long _Accum},
1218 @code{_Sat long long _Accum},
1219 @code{_Sat unsigned short _Accum},
1220 @code{_Sat unsigned _Accum},
1221 @code{_Sat unsigned long _Accum},
1222 @code{_Sat unsigned long long _Accum}.
1224 Fixed-point data values contain fractional and optional integral parts.
1225 The format of fixed-point data varies and depends on the target machine.
1227 Support for fixed-point types includes:
1228 @itemize @bullet
1229 @item
1230 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1231 @item
1232 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1233 @item
1234 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1235 @item
1236 binary shift operators (@code{<<}, @code{>>})
1237 @item
1238 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1239 @item
1240 equality operators (@code{==}, @code{!=})
1241 @item
1242 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1243 @code{<<=}, @code{>>=})
1244 @item
1245 conversions to and from integer, floating-point, or fixed-point types
1246 @end itemize
1248 Use a suffix in a fixed-point literal constant:
1249 @itemize
1250 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1251 @code{_Sat short _Fract}
1252 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1253 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1254 @code{_Sat long _Fract}
1255 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1256 @code{_Sat long long _Fract}
1257 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1258 @code{_Sat unsigned short _Fract}
1259 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1260 @code{_Sat unsigned _Fract}
1261 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1262 @code{_Sat unsigned long _Fract}
1263 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1264 and @code{_Sat unsigned long long _Fract}
1265 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1266 @code{_Sat short _Accum}
1267 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1268 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1269 @code{_Sat long _Accum}
1270 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1271 @code{_Sat long long _Accum}
1272 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1273 @code{_Sat unsigned short _Accum}
1274 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1275 @code{_Sat unsigned _Accum}
1276 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1277 @code{_Sat unsigned long _Accum}
1278 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1279 and @code{_Sat unsigned long long _Accum}
1280 @end itemize
1282 GCC support of fixed-point types as specified by the draft technical report
1283 is incomplete:
1285 @itemize @bullet
1286 @item
1287 Pragmas to control overflow and rounding behaviors are not implemented.
1288 @end itemize
1290 Fixed-point types are supported by the DWARF debug information format.
1292 @node Named Address Spaces
1293 @section Named Address Spaces
1294 @cindex Named Address Spaces
1296 As an extension, GNU C supports named address spaces as
1297 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1298 address spaces in GCC will evolve as the draft technical report
1299 changes.  Calling conventions for any target might also change.  At
1300 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1301 address spaces other than the generic address space.
1303 Address space identifiers may be used exactly like any other C type
1304 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1305 document for more details.
1307 @anchor{AVR Named Address Spaces}
1308 @subsection AVR Named Address Spaces
1310 On the AVR target, there are several address spaces that can be used
1311 in order to put read-only data into the flash memory and access that
1312 data by means of the special instructions @code{LPM} or @code{ELPM}
1313 needed to read from flash.
1315 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1316 flash memory by means of @code{LD*} instructions because the flash
1317 memory is mapped into the RAM address space.  There is @emph{no need}
1318 for language extensions like @code{__flash} or attribute
1319 @ref{AVR Variable Attributes,,@code{progmem}}.
1320 The default linker description files for these devices cater for that
1321 feature and @code{.rodata} stays in flash: The compiler just generates
1322 @code{LD*} instructions, and the linker script adds core specific
1323 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1324 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1325 See @ref{AVR Options} for a list of respective devices.
1327 For devices not in @code{avrtiny} or @code{avrxmega3},
1328 any data including read-only data is located in RAM (the generic
1329 address space) because flash memory is not visible in the RAM address
1330 space.  In order to locate read-only data in flash memory @emph{and}
1331 to generate the right instructions to access this data without
1332 using (inline) assembler code, special address spaces are needed.
1334 @table @code
1335 @item __flash
1336 @cindex @code{__flash} AVR Named Address Spaces
1337 The @code{__flash} qualifier locates data in the
1338 @code{.progmem.data} section. Data is read using the @code{LPM}
1339 instruction. Pointers to this address space are 16 bits wide.
1341 @item __flash1
1342 @itemx __flash2
1343 @itemx __flash3
1344 @itemx __flash4
1345 @itemx __flash5
1346 @cindex @code{__flash1} AVR Named Address Spaces
1347 @cindex @code{__flash2} AVR Named Address Spaces
1348 @cindex @code{__flash3} AVR Named Address Spaces
1349 @cindex @code{__flash4} AVR Named Address Spaces
1350 @cindex @code{__flash5} AVR Named Address Spaces
1351 These are 16-bit address spaces locating data in section
1352 @code{.progmem@var{N}.data} where @var{N} refers to
1353 address space @code{__flash@var{N}}.
1354 The compiler sets the @code{RAMPZ} segment register appropriately 
1355 before reading data by means of the @code{ELPM} instruction.
1357 @item __memx
1358 @cindex @code{__memx} AVR Named Address Spaces
1359 This is a 24-bit address space that linearizes flash and RAM:
1360 If the high bit of the address is set, data is read from
1361 RAM using the lower two bytes as RAM address.
1362 If the high bit of the address is clear, data is read from flash
1363 with @code{RAMPZ} set according to the high byte of the address.
1364 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1366 Objects in this address space are located in @code{.progmemx.data}.
1367 @end table
1369 @b{Example}
1371 @smallexample
1372 char my_read (const __flash char ** p)
1374     /* p is a pointer to RAM that points to a pointer to flash.
1375        The first indirection of p reads that flash pointer
1376        from RAM and the second indirection reads a char from this
1377        flash address.  */
1379     return **p;
1382 /* Locate array[] in flash memory */
1383 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1385 int i = 1;
1387 int main (void)
1389    /* Return 17 by reading from flash memory */
1390    return array[array[i]];
1392 @end smallexample
1394 @noindent
1395 For each named address space supported by avr-gcc there is an equally
1396 named but uppercase built-in macro defined. 
1397 The purpose is to facilitate testing if respective address space
1398 support is available or not:
1400 @smallexample
1401 #ifdef __FLASH
1402 const __flash int var = 1;
1404 int read_var (void)
1406     return var;
1408 #else
1409 #include <avr/pgmspace.h> /* From AVR-LibC */
1411 const int var PROGMEM = 1;
1413 int read_var (void)
1415     return (int) pgm_read_word (&var);
1417 #endif /* __FLASH */
1418 @end smallexample
1420 @noindent
1421 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1422 locates data in flash but
1423 accesses to these data read from generic address space, i.e.@:
1424 from RAM,
1425 so that you need special accessors like @code{pgm_read_byte}
1426 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1427 together with attribute @code{progmem}.
1429 @noindent
1430 @b{Limitations and caveats}
1432 @itemize
1433 @item
1434 Reading across the 64@tie{}KiB section boundary of
1435 the @code{__flash} or @code{__flash@var{N}} address spaces
1436 shows undefined behavior. The only address space that
1437 supports reading across the 64@tie{}KiB flash segment boundaries is
1438 @code{__memx}.
1440 @item
1441 If you use one of the @code{__flash@var{N}} address spaces
1442 you must arrange your linker script to locate the
1443 @code{.progmem@var{N}.data} sections according to your needs.
1445 @item
1446 Any data or pointers to the non-generic address spaces must
1447 be qualified as @code{const}, i.e.@: as read-only data.
1448 This still applies if the data in one of these address
1449 spaces like software version number or calibration lookup table are intended to
1450 be changed after load time by, say, a boot loader. In this case
1451 the right qualification is @code{const} @code{volatile} so that the compiler
1452 must not optimize away known values or insert them
1453 as immediates into operands of instructions.
1455 @item
1456 The following code initializes a variable @code{pfoo}
1457 located in static storage with a 24-bit address:
1458 @smallexample
1459 extern const __memx char foo;
1460 const __memx void *pfoo = &foo;
1461 @end smallexample
1463 @item
1464 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1465 Just use vanilla C / C++ code without overhead as outlined above.
1466 Attribute @code{progmem} is supported but works differently,
1467 see @ref{AVR Variable Attributes}.
1469 @end itemize
1471 @subsection M32C Named Address Spaces
1472 @cindex @code{__far} M32C Named Address Spaces
1474 On the M32C target, with the R8C and M16C CPU variants, variables
1475 qualified with @code{__far} are accessed using 32-bit addresses in
1476 order to access memory beyond the first 64@tie{}Ki bytes.  If
1477 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1478 effect.
1480 @subsection RL78 Named Address Spaces
1481 @cindex @code{__far} RL78 Named Address Spaces
1483 On the RL78 target, variables qualified with @code{__far} are accessed
1484 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1485 addresses.  Non-far variables are assumed to appear in the topmost
1486 64@tie{}KiB of the address space.
1488 @subsection SPU Named Address Spaces
1489 @cindex @code{__ea} SPU Named Address Spaces
1491 On the SPU target variables may be declared as
1492 belonging to another address space by qualifying the type with the
1493 @code{__ea} address space identifier:
1495 @smallexample
1496 extern int __ea i;
1497 @end smallexample
1499 @noindent 
1500 The compiler generates special code to access the variable @code{i}.
1501 It may use runtime library
1502 support, or generate special machine instructions to access that address
1503 space.
1505 @subsection x86 Named Address Spaces
1506 @cindex x86 named address spaces
1508 On the x86 target, variables may be declared as being relative
1509 to the @code{%fs} or @code{%gs} segments.
1511 @table @code
1512 @item __seg_fs
1513 @itemx __seg_gs
1514 @cindex @code{__seg_fs} x86 named address space
1515 @cindex @code{__seg_gs} x86 named address space
1516 The object is accessed with the respective segment override prefix.
1518 The respective segment base must be set via some method specific to
1519 the operating system.  Rather than require an expensive system call
1520 to retrieve the segment base, these address spaces are not considered
1521 to be subspaces of the generic (flat) address space.  This means that
1522 explicit casts are required to convert pointers between these address
1523 spaces and the generic address space.  In practice the application
1524 should cast to @code{uintptr_t} and apply the segment base offset
1525 that it installed previously.
1527 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1528 defined when these address spaces are supported.
1529 @end table
1531 @node Zero Length
1532 @section Arrays of Length Zero
1533 @cindex arrays of length zero
1534 @cindex zero-length arrays
1535 @cindex length-zero arrays
1536 @cindex flexible array members
1538 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1539 last element of a structure that is really a header for a variable-length
1540 object:
1542 @smallexample
1543 struct line @{
1544   int length;
1545   char contents[0];
1548 struct line *thisline = (struct line *)
1549   malloc (sizeof (struct line) + this_length);
1550 thisline->length = this_length;
1551 @end smallexample
1553 In ISO C90, you would have to give @code{contents} a length of 1, which
1554 means either you waste space or complicate the argument to @code{malloc}.
1556 In ISO C99, you would use a @dfn{flexible array member}, which is
1557 slightly different in syntax and semantics:
1559 @itemize @bullet
1560 @item
1561 Flexible array members are written as @code{contents[]} without
1562 the @code{0}.
1564 @item
1565 Flexible array members have incomplete type, and so the @code{sizeof}
1566 operator may not be applied.  As a quirk of the original implementation
1567 of zero-length arrays, @code{sizeof} evaluates to zero.
1569 @item
1570 Flexible array members may only appear as the last member of a
1571 @code{struct} that is otherwise non-empty.
1573 @item
1574 A structure containing a flexible array member, or a union containing
1575 such a structure (possibly recursively), may not be a member of a
1576 structure or an element of an array.  (However, these uses are
1577 permitted by GCC as extensions.)
1578 @end itemize
1580 Non-empty initialization of zero-length
1581 arrays is treated like any case where there are more initializer
1582 elements than the array holds, in that a suitable warning about ``excess
1583 elements in array'' is given, and the excess elements (all of them, in
1584 this case) are ignored.
1586 GCC allows static initialization of flexible array members.
1587 This is equivalent to defining a new structure containing the original
1588 structure followed by an array of sufficient size to contain the data.
1589 E.g.@: in the following, @code{f1} is constructed as if it were declared
1590 like @code{f2}.
1592 @smallexample
1593 struct f1 @{
1594   int x; int y[];
1595 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1597 struct f2 @{
1598   struct f1 f1; int data[3];
1599 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1600 @end smallexample
1602 @noindent
1603 The convenience of this extension is that @code{f1} has the desired
1604 type, eliminating the need to consistently refer to @code{f2.f1}.
1606 This has symmetry with normal static arrays, in that an array of
1607 unknown size is also written with @code{[]}.
1609 Of course, this extension only makes sense if the extra data comes at
1610 the end of a top-level object, as otherwise we would be overwriting
1611 data at subsequent offsets.  To avoid undue complication and confusion
1612 with initialization of deeply nested arrays, we simply disallow any
1613 non-empty initialization except when the structure is the top-level
1614 object.  For example:
1616 @smallexample
1617 struct foo @{ int x; int y[]; @};
1618 struct bar @{ struct foo z; @};
1620 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1621 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1622 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1623 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1624 @end smallexample
1626 @node Empty Structures
1627 @section Structures with No Members
1628 @cindex empty structures
1629 @cindex zero-size structures
1631 GCC permits a C structure to have no members:
1633 @smallexample
1634 struct empty @{
1636 @end smallexample
1638 The structure has size zero.  In C++, empty structures are part
1639 of the language.  G++ treats empty structures as if they had a single
1640 member of type @code{char}.
1642 @node Variable Length
1643 @section Arrays of Variable Length
1644 @cindex variable-length arrays
1645 @cindex arrays of variable length
1646 @cindex VLAs
1648 Variable-length automatic arrays are allowed in ISO C99, and as an
1649 extension GCC accepts them in C90 mode and in C++.  These arrays are
1650 declared like any other automatic arrays, but with a length that is not
1651 a constant expression.  The storage is allocated at the point of
1652 declaration and deallocated when the block scope containing the declaration
1653 exits.  For
1654 example:
1656 @smallexample
1657 FILE *
1658 concat_fopen (char *s1, char *s2, char *mode)
1660   char str[strlen (s1) + strlen (s2) + 1];
1661   strcpy (str, s1);
1662   strcat (str, s2);
1663   return fopen (str, mode);
1665 @end smallexample
1667 @cindex scope of a variable length array
1668 @cindex variable-length array scope
1669 @cindex deallocating variable length arrays
1670 Jumping or breaking out of the scope of the array name deallocates the
1671 storage.  Jumping into the scope is not allowed; you get an error
1672 message for it.
1674 @cindex variable-length array in a structure
1675 As an extension, GCC accepts variable-length arrays as a member of
1676 a structure or a union.  For example:
1678 @smallexample
1679 void
1680 foo (int n)
1682   struct S @{ int x[n]; @};
1684 @end smallexample
1686 @cindex @code{alloca} vs variable-length arrays
1687 You can use the function @code{alloca} to get an effect much like
1688 variable-length arrays.  The function @code{alloca} is available in
1689 many other C implementations (but not in all).  On the other hand,
1690 variable-length arrays are more elegant.
1692 There are other differences between these two methods.  Space allocated
1693 with @code{alloca} exists until the containing @emph{function} returns.
1694 The space for a variable-length array is deallocated as soon as the array
1695 name's scope ends, unless you also use @code{alloca} in this scope.
1697 You can also use variable-length arrays as arguments to functions:
1699 @smallexample
1700 struct entry
1701 tester (int len, char data[len][len])
1703   /* @r{@dots{}} */
1705 @end smallexample
1707 The length of an array is computed once when the storage is allocated
1708 and is remembered for the scope of the array in case you access it with
1709 @code{sizeof}.
1711 If you want to pass the array first and the length afterward, you can
1712 use a forward declaration in the parameter list---another GNU extension.
1714 @smallexample
1715 struct entry
1716 tester (int len; char data[len][len], int len)
1718   /* @r{@dots{}} */
1720 @end smallexample
1722 @cindex parameter forward declaration
1723 The @samp{int len} before the semicolon is a @dfn{parameter forward
1724 declaration}, and it serves the purpose of making the name @code{len}
1725 known when the declaration of @code{data} is parsed.
1727 You can write any number of such parameter forward declarations in the
1728 parameter list.  They can be separated by commas or semicolons, but the
1729 last one must end with a semicolon, which is followed by the ``real''
1730 parameter declarations.  Each forward declaration must match a ``real''
1731 declaration in parameter name and data type.  ISO C99 does not support
1732 parameter forward declarations.
1734 @node Variadic Macros
1735 @section Macros with a Variable Number of Arguments.
1736 @cindex variable number of arguments
1737 @cindex macro with variable arguments
1738 @cindex rest argument (in macro)
1739 @cindex variadic macros
1741 In the ISO C standard of 1999, a macro can be declared to accept a
1742 variable number of arguments much as a function can.  The syntax for
1743 defining the macro is similar to that of a function.  Here is an
1744 example:
1746 @smallexample
1747 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1748 @end smallexample
1750 @noindent
1751 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1752 such a macro, it represents the zero or more tokens until the closing
1753 parenthesis that ends the invocation, including any commas.  This set of
1754 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1755 wherever it appears.  See the CPP manual for more information.
1757 GCC has long supported variadic macros, and used a different syntax that
1758 allowed you to give a name to the variable arguments just like any other
1759 argument.  Here is an example:
1761 @smallexample
1762 #define debug(format, args...) fprintf (stderr, format, args)
1763 @end smallexample
1765 @noindent
1766 This is in all ways equivalent to the ISO C example above, but arguably
1767 more readable and descriptive.
1769 GNU CPP has two further variadic macro extensions, and permits them to
1770 be used with either of the above forms of macro definition.
1772 In standard C, you are not allowed to leave the variable argument out
1773 entirely; but you are allowed to pass an empty argument.  For example,
1774 this invocation is invalid in ISO C, because there is no comma after
1775 the string:
1777 @smallexample
1778 debug ("A message")
1779 @end smallexample
1781 GNU CPP permits you to completely omit the variable arguments in this
1782 way.  In the above examples, the compiler would complain, though since
1783 the expansion of the macro still has the extra comma after the format
1784 string.
1786 To help solve this problem, CPP behaves specially for variable arguments
1787 used with the token paste operator, @samp{##}.  If instead you write
1789 @smallexample
1790 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1791 @end smallexample
1793 @noindent
1794 and if the variable arguments are omitted or empty, the @samp{##}
1795 operator causes the preprocessor to remove the comma before it.  If you
1796 do provide some variable arguments in your macro invocation, GNU CPP
1797 does not complain about the paste operation and instead places the
1798 variable arguments after the comma.  Just like any other pasted macro
1799 argument, these arguments are not macro expanded.
1801 @node Escaped Newlines
1802 @section Slightly Looser Rules for Escaped Newlines
1803 @cindex escaped newlines
1804 @cindex newlines (escaped)
1806 The preprocessor treatment of escaped newlines is more relaxed 
1807 than that specified by the C90 standard, which requires the newline
1808 to immediately follow a backslash.  
1809 GCC's implementation allows whitespace in the form
1810 of spaces, horizontal and vertical tabs, and form feeds between the
1811 backslash and the subsequent newline.  The preprocessor issues a
1812 warning, but treats it as a valid escaped newline and combines the two
1813 lines to form a single logical line.  This works within comments and
1814 tokens, as well as between tokens.  Comments are @emph{not} treated as
1815 whitespace for the purposes of this relaxation, since they have not
1816 yet been replaced with spaces.
1818 @node Subscripting
1819 @section Non-Lvalue Arrays May Have Subscripts
1820 @cindex subscripting
1821 @cindex arrays, non-lvalue
1823 @cindex subscripting and function values
1824 In ISO C99, arrays that are not lvalues still decay to pointers, and
1825 may be subscripted, although they may not be modified or used after
1826 the next sequence point and the unary @samp{&} operator may not be
1827 applied to them.  As an extension, GNU C allows such arrays to be
1828 subscripted in C90 mode, though otherwise they do not decay to
1829 pointers outside C99 mode.  For example,
1830 this is valid in GNU C though not valid in C90:
1832 @smallexample
1833 @group
1834 struct foo @{int a[4];@};
1836 struct foo f();
1838 bar (int index)
1840   return f().a[index];
1842 @end group
1843 @end smallexample
1845 @node Pointer Arith
1846 @section Arithmetic on @code{void}- and Function-Pointers
1847 @cindex void pointers, arithmetic
1848 @cindex void, size of pointer to
1849 @cindex function pointers, arithmetic
1850 @cindex function, size of pointer to
1852 In GNU C, addition and subtraction operations are supported on pointers to
1853 @code{void} and on pointers to functions.  This is done by treating the
1854 size of a @code{void} or of a function as 1.
1856 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1857 and on function types, and returns 1.
1859 @opindex Wpointer-arith
1860 The option @option{-Wpointer-arith} requests a warning if these extensions
1861 are used.
1863 @node Pointers to Arrays
1864 @section Pointers to Arrays with Qualifiers Work as Expected
1865 @cindex pointers to arrays
1866 @cindex const qualifier
1868 In GNU C, pointers to arrays with qualifiers work similar to pointers
1869 to other qualified types. For example, a value of type @code{int (*)[5]}
1870 can be used to initialize a variable of type @code{const int (*)[5]}.
1871 These types are incompatible in ISO C because the @code{const} qualifier
1872 is formally attached to the element type of the array and not the
1873 array itself.
1875 @smallexample
1876 extern void
1877 transpose (int N, int M, double out[M][N], const double in[N][M]);
1878 double x[3][2];
1879 double y[2][3];
1880 @r{@dots{}}
1881 transpose(3, 2, y, x);
1882 @end smallexample
1884 @node Initializers
1885 @section Non-Constant Initializers
1886 @cindex initializers, non-constant
1887 @cindex non-constant initializers
1889 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1890 automatic variable are not required to be constant expressions in GNU C@.
1891 Here is an example of an initializer with run-time varying elements:
1893 @smallexample
1894 foo (float f, float g)
1896   float beat_freqs[2] = @{ f-g, f+g @};
1897   /* @r{@dots{}} */
1899 @end smallexample
1901 @node Compound Literals
1902 @section Compound Literals
1903 @cindex constructor expressions
1904 @cindex initializations in expressions
1905 @cindex structures, constructor expression
1906 @cindex expressions, constructor
1907 @cindex compound literals
1908 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1910 A compound literal looks like a cast of a brace-enclosed aggregate
1911 initializer list.  Its value is an object of the type specified in
1912 the cast, containing the elements specified in the initializer.
1913 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1914 C99 and later support compound literals.  As an extension, GCC
1915 supports compound literals also in C90 mode and in C++, although
1916 as explained below, the C++ semantics are somewhat different.
1918 Usually, the specified type of a compound literal is a structure.  Assume
1919 that @code{struct foo} and @code{structure} are declared as shown:
1921 @smallexample
1922 struct foo @{int a; char b[2];@} structure;
1923 @end smallexample
1925 @noindent
1926 Here is an example of constructing a @code{struct foo} with a compound literal:
1928 @smallexample
1929 structure = ((struct foo) @{x + y, 'a', 0@});
1930 @end smallexample
1932 @noindent
1933 This is equivalent to writing the following:
1935 @smallexample
1937   struct foo temp = @{x + y, 'a', 0@};
1938   structure = temp;
1940 @end smallexample
1942 You can also construct an array, though this is dangerous in C++, as
1943 explained below.  If all the elements of the compound literal are
1944 (made up of) simple constant expressions suitable for use in
1945 initializers of objects of static storage duration, then the compound
1946 literal can be coerced to a pointer to its first element and used in
1947 such an initializer, as shown here:
1949 @smallexample
1950 char **foo = (char *[]) @{ "x", "y", "z" @};
1951 @end smallexample
1953 Compound literals for scalar types and union types are also allowed.  In
1954 the following example the variable @code{i} is initialized to the value
1955 @code{2}, the result of incrementing the unnamed object created by
1956 the compound literal.
1958 @smallexample
1959 int i = ++(int) @{ 1 @};
1960 @end smallexample
1962 As a GNU extension, GCC allows initialization of objects with static storage
1963 duration by compound literals (which is not possible in ISO C99 because
1964 the initializer is not a constant).
1965 It is handled as if the object were initialized only with the brace-enclosed
1966 list if the types of the compound literal and the object match.
1967 The elements of the compound literal must be constant.
1968 If the object being initialized has array type of unknown size, the size is
1969 determined by the size of the compound literal.
1971 @smallexample
1972 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1973 static int y[] = (int []) @{1, 2, 3@};
1974 static int z[] = (int [3]) @{1@};
1975 @end smallexample
1977 @noindent
1978 The above lines are equivalent to the following:
1979 @smallexample
1980 static struct foo x = @{1, 'a', 'b'@};
1981 static int y[] = @{1, 2, 3@};
1982 static int z[] = @{1, 0, 0@};
1983 @end smallexample
1985 In C, a compound literal designates an unnamed object with static or
1986 automatic storage duration.  In C++, a compound literal designates a
1987 temporary object that only lives until the end of its full-expression.
1988 As a result, well-defined C code that takes the address of a subobject
1989 of a compound literal can be undefined in C++, so G++ rejects
1990 the conversion of a temporary array to a pointer.  For instance, if
1991 the array compound literal example above appeared inside a function,
1992 any subsequent use of @code{foo} in C++ would have undefined behavior
1993 because the lifetime of the array ends after the declaration of @code{foo}.
1995 As an optimization, G++ sometimes gives array compound literals longer
1996 lifetimes: when the array either appears outside a function or has
1997 a @code{const}-qualified type.  If @code{foo} and its initializer had
1998 elements of type @code{char *const} rather than @code{char *}, or if
1999 @code{foo} were a global variable, the array would have static storage
2000 duration.  But it is probably safest just to avoid the use of array
2001 compound literals in C++ code.
2003 @node Designated Inits
2004 @section Designated Initializers
2005 @cindex initializers with labeled elements
2006 @cindex labeled elements in initializers
2007 @cindex case labels in initializers
2008 @cindex designated initializers
2010 Standard C90 requires the elements of an initializer to appear in a fixed
2011 order, the same as the order of the elements in the array or structure
2012 being initialized.
2014 In ISO C99 you can give the elements in any order, specifying the array
2015 indices or structure field names they apply to, and GNU C allows this as
2016 an extension in C90 mode as well.  This extension is not
2017 implemented in GNU C++.
2019 To specify an array index, write
2020 @samp{[@var{index}] =} before the element value.  For example,
2022 @smallexample
2023 int a[6] = @{ [4] = 29, [2] = 15 @};
2024 @end smallexample
2026 @noindent
2027 is equivalent to
2029 @smallexample
2030 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2031 @end smallexample
2033 @noindent
2034 The index values must be constant expressions, even if the array being
2035 initialized is automatic.
2037 An alternative syntax for this that has been obsolete since GCC 2.5 but
2038 GCC still accepts is to write @samp{[@var{index}]} before the element
2039 value, with no @samp{=}.
2041 To initialize a range of elements to the same value, write
2042 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2043 extension.  For example,
2045 @smallexample
2046 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2047 @end smallexample
2049 @noindent
2050 If the value in it has side-effects, the side-effects happen only once,
2051 not for each initialized field by the range initializer.
2053 @noindent
2054 Note that the length of the array is the highest value specified
2055 plus one.
2057 In a structure initializer, specify the name of a field to initialize
2058 with @samp{.@var{fieldname} =} before the element value.  For example,
2059 given the following structure,
2061 @smallexample
2062 struct point @{ int x, y; @};
2063 @end smallexample
2065 @noindent
2066 the following initialization
2068 @smallexample
2069 struct point p = @{ .y = yvalue, .x = xvalue @};
2070 @end smallexample
2072 @noindent
2073 is equivalent to
2075 @smallexample
2076 struct point p = @{ xvalue, yvalue @};
2077 @end smallexample
2079 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2080 @samp{@var{fieldname}:}, as shown here:
2082 @smallexample
2083 struct point p = @{ y: yvalue, x: xvalue @};
2084 @end smallexample
2086 Omitted field members are implicitly initialized the same as objects
2087 that have static storage duration.
2089 @cindex designators
2090 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2091 @dfn{designator}.  You can also use a designator (or the obsolete colon
2092 syntax) when initializing a union, to specify which element of the union
2093 should be used.  For example,
2095 @smallexample
2096 union foo @{ int i; double d; @};
2098 union foo f = @{ .d = 4 @};
2099 @end smallexample
2101 @noindent
2102 converts 4 to a @code{double} to store it in the union using
2103 the second element.  By contrast, casting 4 to type @code{union foo}
2104 stores it into the union as the integer @code{i}, since it is
2105 an integer.  @xref{Cast to Union}.
2107 You can combine this technique of naming elements with ordinary C
2108 initialization of successive elements.  Each initializer element that
2109 does not have a designator applies to the next consecutive element of the
2110 array or structure.  For example,
2112 @smallexample
2113 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2114 @end smallexample
2116 @noindent
2117 is equivalent to
2119 @smallexample
2120 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2121 @end smallexample
2123 Labeling the elements of an array initializer is especially useful
2124 when the indices are characters or belong to an @code{enum} type.
2125 For example:
2127 @smallexample
2128 int whitespace[256]
2129   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2130       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2131 @end smallexample
2133 @cindex designator lists
2134 You can also write a series of @samp{.@var{fieldname}} and
2135 @samp{[@var{index}]} designators before an @samp{=} to specify a
2136 nested subobject to initialize; the list is taken relative to the
2137 subobject corresponding to the closest surrounding brace pair.  For
2138 example, with the @samp{struct point} declaration above:
2140 @smallexample
2141 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2142 @end smallexample
2144 @noindent
2145 If the same field is initialized multiple times, it has the value from
2146 the last initialization.  If any such overridden initialization has
2147 side-effect, it is unspecified whether the side-effect happens or not.
2148 Currently, GCC discards them and issues a warning.
2150 @node Case Ranges
2151 @section Case Ranges
2152 @cindex case ranges
2153 @cindex ranges in case statements
2155 You can specify a range of consecutive values in a single @code{case} label,
2156 like this:
2158 @smallexample
2159 case @var{low} ... @var{high}:
2160 @end smallexample
2162 @noindent
2163 This has the same effect as the proper number of individual @code{case}
2164 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2166 This feature is especially useful for ranges of ASCII character codes:
2168 @smallexample
2169 case 'A' ... 'Z':
2170 @end smallexample
2172 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2173 it may be parsed wrong when you use it with integer values.  For example,
2174 write this:
2176 @smallexample
2177 case 1 ... 5:
2178 @end smallexample
2180 @noindent
2181 rather than this:
2183 @smallexample
2184 case 1...5:
2185 @end smallexample
2187 @node Cast to Union
2188 @section Cast to a Union Type
2189 @cindex cast to a union
2190 @cindex union, casting to a
2192 A cast to union type looks similar to other casts, except that the type
2193 specified is a union type.  You can specify the type either with the
2194 @code{union} keyword or with a @code{typedef} name that refers to
2195 a union.  A cast to a union actually creates a compound literal and
2196 yields an lvalue, not an rvalue like true casts do.
2197 @xref{Compound Literals}.
2199 The types that may be cast to the union type are those of the members
2200 of the union.  Thus, given the following union and variables:
2202 @smallexample
2203 union foo @{ int i; double d; @};
2204 int x;
2205 double y;
2206 @end smallexample
2208 @noindent
2209 both @code{x} and @code{y} can be cast to type @code{union foo}.
2211 Using the cast as the right-hand side of an assignment to a variable of
2212 union type is equivalent to storing in a member of the union:
2214 @smallexample
2215 union foo u;
2216 /* @r{@dots{}} */
2217 u = (union foo) x  @equiv{}  u.i = x
2218 u = (union foo) y  @equiv{}  u.d = y
2219 @end smallexample
2221 You can also use the union cast as a function argument:
2223 @smallexample
2224 void hack (union foo);
2225 /* @r{@dots{}} */
2226 hack ((union foo) x);
2227 @end smallexample
2229 @node Mixed Declarations
2230 @section Mixed Declarations and Code
2231 @cindex mixed declarations and code
2232 @cindex declarations, mixed with code
2233 @cindex code, mixed with declarations
2235 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2236 within compound statements.  As an extension, GNU C also allows this in
2237 C90 mode.  For example, you could do:
2239 @smallexample
2240 int i;
2241 /* @r{@dots{}} */
2242 i++;
2243 int j = i + 2;
2244 @end smallexample
2246 Each identifier is visible from where it is declared until the end of
2247 the enclosing block.
2249 @node Function Attributes
2250 @section Declaring Attributes of Functions
2251 @cindex function attributes
2252 @cindex declaring attributes of functions
2253 @cindex @code{volatile} applied to function
2254 @cindex @code{const} applied to function
2256 In GNU C, you can use function attributes to declare certain things
2257 about functions called in your program which help the compiler
2258 optimize calls and check your code more carefully.  For example, you
2259 can use attributes to declare that a function never returns
2260 (@code{noreturn}), returns a value depending only on its arguments
2261 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2263 You can also use attributes to control memory placement, code
2264 generation options or call/return conventions within the function
2265 being annotated.  Many of these attributes are target-specific.  For
2266 example, many targets support attributes for defining interrupt
2267 handler functions, which typically must follow special register usage
2268 and return conventions.
2270 Function attributes are introduced by the @code{__attribute__} keyword
2271 on a declaration, followed by an attribute specification inside double
2272 parentheses.  You can specify multiple attributes in a declaration by
2273 separating them by commas within the double parentheses or by
2274 immediately following an attribute declaration with another attribute
2275 declaration.  @xref{Attribute Syntax}, for the exact rules on
2276 attribute syntax and placement.
2278 GCC also supports attributes on
2279 variable declarations (@pxref{Variable Attributes}),
2280 labels (@pxref{Label Attributes}),
2281 enumerators (@pxref{Enumerator Attributes}),
2282 statements (@pxref{Statement Attributes}),
2283 and types (@pxref{Type Attributes}).
2285 There is some overlap between the purposes of attributes and pragmas
2286 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2287 found convenient to use @code{__attribute__} to achieve a natural
2288 attachment of attributes to their corresponding declarations, whereas
2289 @code{#pragma} is of use for compatibility with other compilers
2290 or constructs that do not naturally form part of the grammar.
2292 In addition to the attributes documented here,
2293 GCC plugins may provide their own attributes.
2295 @menu
2296 * Common Function Attributes::
2297 * AArch64 Function Attributes::
2298 * ARC Function Attributes::
2299 * ARM Function Attributes::
2300 * AVR Function Attributes::
2301 * Blackfin Function Attributes::
2302 * CR16 Function Attributes::
2303 * Epiphany Function Attributes::
2304 * H8/300 Function Attributes::
2305 * IA-64 Function Attributes::
2306 * M32C Function Attributes::
2307 * M32R/D Function Attributes::
2308 * m68k Function Attributes::
2309 * MCORE Function Attributes::
2310 * MeP Function Attributes::
2311 * MicroBlaze Function Attributes::
2312 * Microsoft Windows Function Attributes::
2313 * MIPS Function Attributes::
2314 * MSP430 Function Attributes::
2315 * NDS32 Function Attributes::
2316 * Nios II Function Attributes::
2317 * Nvidia PTX Function Attributes::
2318 * PowerPC Function Attributes::
2319 * RL78 Function Attributes::
2320 * RX Function Attributes::
2321 * S/390 Function Attributes::
2322 * SH Function Attributes::
2323 * SPU Function Attributes::
2324 * Symbian OS Function Attributes::
2325 * V850 Function Attributes::
2326 * Visium Function Attributes::
2327 * x86 Function Attributes::
2328 * Xstormy16 Function Attributes::
2329 @end menu
2331 @node Common Function Attributes
2332 @subsection Common Function Attributes
2334 The following attributes are supported on most targets.
2336 @table @code
2337 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2339 @item alias ("@var{target}")
2340 @cindex @code{alias} function attribute
2341 The @code{alias} attribute causes the declaration to be emitted as an
2342 alias for another symbol, which must be specified.  For instance,
2344 @smallexample
2345 void __f () @{ /* @r{Do something.} */; @}
2346 void f () __attribute__ ((weak, alias ("__f")));
2347 @end smallexample
2349 @noindent
2350 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2351 mangled name for the target must be used.  It is an error if @samp{__f}
2352 is not defined in the same translation unit.
2354 This attribute requires assembler and object file support,
2355 and may not be available on all targets.
2357 @item aligned (@var{alignment})
2358 @cindex @code{aligned} function attribute
2359 This attribute specifies a minimum alignment for the function,
2360 measured in bytes.
2362 You cannot use this attribute to decrease the alignment of a function,
2363 only to increase it.  However, when you explicitly specify a function
2364 alignment this overrides the effect of the
2365 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2366 function.
2368 Note that the effectiveness of @code{aligned} attributes may be
2369 limited by inherent limitations in your linker.  On many systems, the
2370 linker is only able to arrange for functions to be aligned up to a
2371 certain maximum alignment.  (For some linkers, the maximum supported
2372 alignment may be very very small.)  See your linker documentation for
2373 further information.
2375 The @code{aligned} attribute can also be used for variables and fields
2376 (@pxref{Variable Attributes}.)
2378 @item alloc_align
2379 @cindex @code{alloc_align} function attribute
2380 The @code{alloc_align} attribute is used to tell the compiler that the
2381 function return value points to memory, where the returned pointer minimum
2382 alignment is given by one of the functions parameters.  GCC uses this
2383 information to improve pointer alignment analysis.
2385 The function parameter denoting the allocated alignment is specified by
2386 one integer argument, whose number is the argument of the attribute.
2387 Argument numbering starts at one.
2389 For instance,
2391 @smallexample
2392 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2393 @end smallexample
2395 @noindent
2396 declares that @code{my_memalign} returns memory with minimum alignment
2397 given by parameter 1.
2399 @item alloc_size
2400 @cindex @code{alloc_size} function attribute
2401 The @code{alloc_size} attribute is used to tell the compiler that the
2402 function return value points to memory, where the size is given by
2403 one or two of the functions parameters.  GCC uses this
2404 information to improve the correctness of @code{__builtin_object_size}.
2406 The function parameter(s) denoting the allocated size are specified by
2407 one or two integer arguments supplied to the attribute.  The allocated size
2408 is either the value of the single function argument specified or the product
2409 of the two function arguments specified.  Argument numbering starts at
2410 one.
2412 For instance,
2414 @smallexample
2415 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2416 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2417 @end smallexample
2419 @noindent
2420 declares that @code{my_calloc} returns memory of the size given by
2421 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2422 of the size given by parameter 2.
2424 @item always_inline
2425 @cindex @code{always_inline} function attribute
2426 Generally, functions are not inlined unless optimization is specified.
2427 For functions declared inline, this attribute inlines the function
2428 independent of any restrictions that otherwise apply to inlining.
2429 Failure to inline such a function is diagnosed as an error.
2430 Note that if such a function is called indirectly the compiler may
2431 or may not inline it depending on optimization level and a failure
2432 to inline an indirect call may or may not be diagnosed.
2434 @item artificial
2435 @cindex @code{artificial} function attribute
2436 This attribute is useful for small inline wrappers that if possible
2437 should appear during debugging as a unit.  Depending on the debug
2438 info format it either means marking the function as artificial
2439 or using the caller location for all instructions within the inlined
2440 body.
2442 @item assume_aligned
2443 @cindex @code{assume_aligned} function attribute
2444 The @code{assume_aligned} attribute is used to tell the compiler that the
2445 function return value points to memory, where the returned pointer minimum
2446 alignment is given by the first argument.
2447 If the attribute has two arguments, the second argument is misalignment offset.
2449 For instance
2451 @smallexample
2452 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2453 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2454 @end smallexample
2456 @noindent
2457 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2458 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2459 to 8.
2461 @item bnd_instrument
2462 @cindex @code{bnd_instrument} function attribute
2463 The @code{bnd_instrument} attribute on functions is used to inform the
2464 compiler that the function should be instrumented when compiled
2465 with the @option{-fchkp-instrument-marked-only} option.
2467 @item bnd_legacy
2468 @cindex @code{bnd_legacy} function attribute
2469 @cindex Pointer Bounds Checker attributes
2470 The @code{bnd_legacy} attribute on functions is used to inform the
2471 compiler that the function should not be instrumented when compiled
2472 with the @option{-fcheck-pointer-bounds} option.
2474 @item cold
2475 @cindex @code{cold} function attribute
2476 The @code{cold} attribute on functions is used to inform the compiler that
2477 the function is unlikely to be executed.  The function is optimized for
2478 size rather than speed and on many targets it is placed into a special
2479 subsection of the text section so all cold functions appear close together,
2480 improving code locality of non-cold parts of program.  The paths leading
2481 to calls of cold functions within code are marked as unlikely by the branch
2482 prediction mechanism.  It is thus useful to mark functions used to handle
2483 unlikely conditions, such as @code{perror}, as cold to improve optimization
2484 of hot functions that do call marked functions in rare occasions.
2486 When profile feedback is available, via @option{-fprofile-use}, cold functions
2487 are automatically detected and this attribute is ignored.
2489 @item const
2490 @cindex @code{const} function attribute
2491 @cindex functions that have no side effects
2492 Many functions do not examine any values except their arguments, and
2493 have no effects except the return value.  Basically this is just slightly
2494 more strict class than the @code{pure} attribute below, since function is not
2495 allowed to read global memory.
2497 @cindex pointer arguments
2498 Note that a function that has pointer arguments and examines the data
2499 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2500 function that calls a non-@code{const} function usually must not be
2501 @code{const}.  It does not make sense for a @code{const} function to
2502 return @code{void}.
2504 @item constructor
2505 @itemx destructor
2506 @itemx constructor (@var{priority})
2507 @itemx destructor (@var{priority})
2508 @cindex @code{constructor} function attribute
2509 @cindex @code{destructor} function attribute
2510 The @code{constructor} attribute causes the function to be called
2511 automatically before execution enters @code{main ()}.  Similarly, the
2512 @code{destructor} attribute causes the function to be called
2513 automatically after @code{main ()} completes or @code{exit ()} is
2514 called.  Functions with these attributes are useful for
2515 initializing data that is used implicitly during the execution of
2516 the program.
2518 You may provide an optional integer priority to control the order in
2519 which constructor and destructor functions are run.  A constructor
2520 with a smaller priority number runs before a constructor with a larger
2521 priority number; the opposite relationship holds for destructors.  So,
2522 if you have a constructor that allocates a resource and a destructor
2523 that deallocates the same resource, both functions typically have the
2524 same priority.  The priorities for constructor and destructor
2525 functions are the same as those specified for namespace-scope C++
2526 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2527 constructors for C++ objects with static storage duration and functions
2528 decorated with attribute @code{constructor} are invoked is unspecified.
2529 In mixed declarations, attribute @code{init_priority} can be used to
2530 impose a specific ordering.
2532 @item deprecated
2533 @itemx deprecated (@var{msg})
2534 @cindex @code{deprecated} function attribute
2535 The @code{deprecated} attribute results in a warning if the function
2536 is used anywhere in the source file.  This is useful when identifying
2537 functions that are expected to be removed in a future version of a
2538 program.  The warning also includes the location of the declaration
2539 of the deprecated function, to enable users to easily find further
2540 information about why the function is deprecated, or what they should
2541 do instead.  Note that the warnings only occurs for uses:
2543 @smallexample
2544 int old_fn () __attribute__ ((deprecated));
2545 int old_fn ();
2546 int (*fn_ptr)() = old_fn;
2547 @end smallexample
2549 @noindent
2550 results in a warning on line 3 but not line 2.  The optional @var{msg}
2551 argument, which must be a string, is printed in the warning if
2552 present.
2554 The @code{deprecated} attribute can also be used for variables and
2555 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2557 @item error ("@var{message}")
2558 @itemx warning ("@var{message}")
2559 @cindex @code{error} function attribute
2560 @cindex @code{warning} function attribute
2561 If the @code{error} or @code{warning} attribute 
2562 is used on a function declaration and a call to such a function
2563 is not eliminated through dead code elimination or other optimizations, 
2564 an error or warning (respectively) that includes @var{message} is diagnosed.  
2565 This is useful
2566 for compile-time checking, especially together with @code{__builtin_constant_p}
2567 and inline functions where checking the inline function arguments is not
2568 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2570 While it is possible to leave the function undefined and thus invoke
2571 a link failure (to define the function with
2572 a message in @code{.gnu.warning*} section),
2573 when using these attributes the problem is diagnosed
2574 earlier and with exact location of the call even in presence of inline
2575 functions or when not emitting debugging information.
2577 @item externally_visible
2578 @cindex @code{externally_visible} function attribute
2579 This attribute, attached to a global variable or function, nullifies
2580 the effect of the @option{-fwhole-program} command-line option, so the
2581 object remains visible outside the current compilation unit.
2583 If @option{-fwhole-program} is used together with @option{-flto} and 
2584 @command{gold} is used as the linker plugin, 
2585 @code{externally_visible} attributes are automatically added to functions 
2586 (not variable yet due to a current @command{gold} issue) 
2587 that are accessed outside of LTO objects according to resolution file
2588 produced by @command{gold}.
2589 For other linkers that cannot generate resolution file,
2590 explicit @code{externally_visible} attributes are still necessary.
2592 @item flatten
2593 @cindex @code{flatten} function attribute
2594 Generally, inlining into a function is limited.  For a function marked with
2595 this attribute, every call inside this function is inlined, if possible.
2596 Whether the function itself is considered for inlining depends on its size and
2597 the current inlining parameters.
2599 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2600 @cindex @code{format} function attribute
2601 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2602 @opindex Wformat
2603 The @code{format} attribute specifies that a function takes @code{printf},
2604 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2605 should be type-checked against a format string.  For example, the
2606 declaration:
2608 @smallexample
2609 extern int
2610 my_printf (void *my_object, const char *my_format, ...)
2611       __attribute__ ((format (printf, 2, 3)));
2612 @end smallexample
2614 @noindent
2615 causes the compiler to check the arguments in calls to @code{my_printf}
2616 for consistency with the @code{printf} style format string argument
2617 @code{my_format}.
2619 The parameter @var{archetype} determines how the format string is
2620 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2621 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2622 @code{strfmon}.  (You can also use @code{__printf__},
2623 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2624 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2625 @code{ms_strftime} are also present.
2626 @var{archetype} values such as @code{printf} refer to the formats accepted
2627 by the system's C runtime library,
2628 while values prefixed with @samp{gnu_} always refer
2629 to the formats accepted by the GNU C Library.  On Microsoft Windows
2630 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2631 @file{msvcrt.dll} library.
2632 The parameter @var{string-index}
2633 specifies which argument is the format string argument (starting
2634 from 1), while @var{first-to-check} is the number of the first
2635 argument to check against the format string.  For functions
2636 where the arguments are not available to be checked (such as
2637 @code{vprintf}), specify the third parameter as zero.  In this case the
2638 compiler only checks the format string for consistency.  For
2639 @code{strftime} formats, the third parameter is required to be zero.
2640 Since non-static C++ methods have an implicit @code{this} argument, the
2641 arguments of such methods should be counted from two, not one, when
2642 giving values for @var{string-index} and @var{first-to-check}.
2644 In the example above, the format string (@code{my_format}) is the second
2645 argument of the function @code{my_print}, and the arguments to check
2646 start with the third argument, so the correct parameters for the format
2647 attribute are 2 and 3.
2649 @opindex ffreestanding
2650 @opindex fno-builtin
2651 The @code{format} attribute allows you to identify your own functions
2652 that take format strings as arguments, so that GCC can check the
2653 calls to these functions for errors.  The compiler always (unless
2654 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2655 for the standard library functions @code{printf}, @code{fprintf},
2656 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2657 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2658 warnings are requested (using @option{-Wformat}), so there is no need to
2659 modify the header file @file{stdio.h}.  In C99 mode, the functions
2660 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2661 @code{vsscanf} are also checked.  Except in strictly conforming C
2662 standard modes, the X/Open function @code{strfmon} is also checked as
2663 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2664 @xref{C Dialect Options,,Options Controlling C Dialect}.
2666 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2667 recognized in the same context.  Declarations including these format attributes
2668 are parsed for correct syntax, however the result of checking of such format
2669 strings is not yet defined, and is not carried out by this version of the
2670 compiler.
2672 The target may also provide additional types of format checks.
2673 @xref{Target Format Checks,,Format Checks Specific to Particular
2674 Target Machines}.
2676 @item format_arg (@var{string-index})
2677 @cindex @code{format_arg} function attribute
2678 @opindex Wformat-nonliteral
2679 The @code{format_arg} attribute specifies that a function takes a format
2680 string for a @code{printf}, @code{scanf}, @code{strftime} or
2681 @code{strfmon} style function and modifies it (for example, to translate
2682 it into another language), so the result can be passed to a
2683 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2684 function (with the remaining arguments to the format function the same
2685 as they would have been for the unmodified string).  For example, the
2686 declaration:
2688 @smallexample
2689 extern char *
2690 my_dgettext (char *my_domain, const char *my_format)
2691       __attribute__ ((format_arg (2)));
2692 @end smallexample
2694 @noindent
2695 causes the compiler to check the arguments in calls to a @code{printf},
2696 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2697 format string argument is a call to the @code{my_dgettext} function, for
2698 consistency with the format string argument @code{my_format}.  If the
2699 @code{format_arg} attribute had not been specified, all the compiler
2700 could tell in such calls to format functions would be that the format
2701 string argument is not constant; this would generate a warning when
2702 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2703 without the attribute.
2705 The parameter @var{string-index} specifies which argument is the format
2706 string argument (starting from one).  Since non-static C++ methods have
2707 an implicit @code{this} argument, the arguments of such methods should
2708 be counted from two.
2710 The @code{format_arg} attribute allows you to identify your own
2711 functions that modify format strings, so that GCC can check the
2712 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2713 type function whose operands are a call to one of your own function.
2714 The compiler always treats @code{gettext}, @code{dgettext}, and
2715 @code{dcgettext} in this manner except when strict ISO C support is
2716 requested by @option{-ansi} or an appropriate @option{-std} option, or
2717 @option{-ffreestanding} or @option{-fno-builtin}
2718 is used.  @xref{C Dialect Options,,Options
2719 Controlling C Dialect}.
2721 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2722 @code{NSString} reference for compatibility with the @code{format} attribute
2723 above.
2725 The target may also allow additional types in @code{format-arg} attributes.
2726 @xref{Target Format Checks,,Format Checks Specific to Particular
2727 Target Machines}.
2729 @item gnu_inline
2730 @cindex @code{gnu_inline} function attribute
2731 This attribute should be used with a function that is also declared
2732 with the @code{inline} keyword.  It directs GCC to treat the function
2733 as if it were defined in gnu90 mode even when compiling in C99 or
2734 gnu99 mode.
2736 If the function is declared @code{extern}, then this definition of the
2737 function is used only for inlining.  In no case is the function
2738 compiled as a standalone function, not even if you take its address
2739 explicitly.  Such an address becomes an external reference, as if you
2740 had only declared the function, and had not defined it.  This has
2741 almost the effect of a macro.  The way to use this is to put a
2742 function definition in a header file with this attribute, and put
2743 another copy of the function, without @code{extern}, in a library
2744 file.  The definition in the header file causes most calls to the
2745 function to be inlined.  If any uses of the function remain, they
2746 refer to the single copy in the library.  Note that the two
2747 definitions of the functions need not be precisely the same, although
2748 if they do not have the same effect your program may behave oddly.
2750 In C, if the function is neither @code{extern} nor @code{static}, then
2751 the function is compiled as a standalone function, as well as being
2752 inlined where possible.
2754 This is how GCC traditionally handled functions declared
2755 @code{inline}.  Since ISO C99 specifies a different semantics for
2756 @code{inline}, this function attribute is provided as a transition
2757 measure and as a useful feature in its own right.  This attribute is
2758 available in GCC 4.1.3 and later.  It is available if either of the
2759 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2760 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2761 Function is As Fast As a Macro}.
2763 In C++, this attribute does not depend on @code{extern} in any way,
2764 but it still requires the @code{inline} keyword to enable its special
2765 behavior.
2767 @item hot
2768 @cindex @code{hot} function attribute
2769 The @code{hot} attribute on a function is used to inform the compiler that
2770 the function is a hot spot of the compiled program.  The function is
2771 optimized more aggressively and on many targets it is placed into a special
2772 subsection of the text section so all hot functions appear close together,
2773 improving locality.
2775 When profile feedback is available, via @option{-fprofile-use}, hot functions
2776 are automatically detected and this attribute is ignored.
2778 @item ifunc ("@var{resolver}")
2779 @cindex @code{ifunc} function attribute
2780 @cindex indirect functions
2781 @cindex functions that are dynamically resolved
2782 The @code{ifunc} attribute is used to mark a function as an indirect
2783 function using the STT_GNU_IFUNC symbol type extension to the ELF
2784 standard.  This allows the resolution of the symbol value to be
2785 determined dynamically at load time, and an optimized version of the
2786 routine can be selected for the particular processor or other system
2787 characteristics determined then.  To use this attribute, first define
2788 the implementation functions available, and a resolver function that
2789 returns a pointer to the selected implementation function.  The
2790 implementation functions' declarations must match the API of the
2791 function being implemented, the resolver's declaration is be a
2792 function returning pointer to void function returning void:
2794 @smallexample
2795 void *my_memcpy (void *dst, const void *src, size_t len)
2797   @dots{}
2800 static void (*resolve_memcpy (void)) (void)
2802   return my_memcpy; // we'll just always select this routine
2804 @end smallexample
2806 @noindent
2807 The exported header file declaring the function the user calls would
2808 contain:
2810 @smallexample
2811 extern void *memcpy (void *, const void *, size_t);
2812 @end smallexample
2814 @noindent
2815 allowing the user to call this as a regular function, unaware of the
2816 implementation.  Finally, the indirect function needs to be defined in
2817 the same translation unit as the resolver function:
2819 @smallexample
2820 void *memcpy (void *, const void *, size_t)
2821      __attribute__ ((ifunc ("resolve_memcpy")));
2822 @end smallexample
2824 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2825 and GNU C Library version 2.11.1 are required to use this feature.
2827 @item interrupt
2828 @itemx interrupt_handler
2829 Many GCC back ends support attributes to indicate that a function is
2830 an interrupt handler, which tells the compiler to generate function
2831 entry and exit sequences that differ from those from regular
2832 functions.  The exact syntax and behavior are target-specific;
2833 refer to the following subsections for details.
2835 @item leaf
2836 @cindex @code{leaf} function attribute
2837 Calls to external functions with this attribute must return to the
2838 current compilation unit only by return or by exception handling.  In
2839 particular, a leaf function is not allowed to invoke callback functions
2840 passed to it from the current compilation unit, directly call functions
2841 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2842 might still call functions from other compilation units and thus they
2843 are not necessarily leaf in the sense that they contain no function
2844 calls at all.
2846 The attribute is intended for library functions to improve dataflow
2847 analysis.  The compiler takes the hint that any data not escaping the
2848 current compilation unit cannot be used or modified by the leaf
2849 function.  For example, the @code{sin} function is a leaf function, but
2850 @code{qsort} is not.
2852 Note that leaf functions might indirectly run a signal handler defined
2853 in the current compilation unit that uses static variables.  Similarly,
2854 when lazy symbol resolution is in effect, leaf functions might invoke
2855 indirect functions whose resolver function or implementation function is
2856 defined in the current compilation unit and uses static variables.  There
2857 is no standard-compliant way to write such a signal handler, resolver
2858 function, or implementation function, and the best that you can do is to
2859 remove the @code{leaf} attribute or mark all such static variables
2860 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2861 interposition, care should be taken that functions defined in the
2862 current compilation unit do not unexpectedly interpose other symbols
2863 based on the defined standards mode and defined feature test macros;
2864 otherwise an inadvertent callback would be added.
2866 The attribute has no effect on functions defined within the current
2867 compilation unit.  This is to allow easy merging of multiple compilation
2868 units into one, for example, by using the link-time optimization.  For
2869 this reason the attribute is not allowed on types to annotate indirect
2870 calls.
2872 @item malloc
2873 @cindex @code{malloc} function attribute
2874 @cindex functions that behave like malloc
2875 This tells the compiler that a function is @code{malloc}-like, i.e.,
2876 that the pointer @var{P} returned by the function cannot alias any
2877 other pointer valid when the function returns, and moreover no
2878 pointers to valid objects occur in any storage addressed by @var{P}.
2880 Using this attribute can improve optimization.  Functions like
2881 @code{malloc} and @code{calloc} have this property because they return
2882 a pointer to uninitialized or zeroed-out storage.  However, functions
2883 like @code{realloc} do not have this property, as they can return a
2884 pointer to storage containing pointers.
2886 @item no_icf
2887 @cindex @code{no_icf} function attribute
2888 This function attribute prevents a functions from being merged with another
2889 semantically equivalent function.
2891 @item no_instrument_function
2892 @cindex @code{no_instrument_function} function attribute
2893 @opindex finstrument-functions
2894 If @option{-finstrument-functions} is given, profiling function calls are
2895 generated at entry and exit of most user-compiled functions.
2896 Functions with this attribute are not so instrumented.
2898 @item no_profile_instrument_function
2899 @cindex @code{no_profile_instrument_function} function attribute
2900 The @code{no_profile_instrument_function} attribute on functions is used
2901 to inform the compiler that it should not process any profile feedback based
2902 optimization code instrumentation.
2904 @item no_reorder
2905 @cindex @code{no_reorder} function attribute
2906 Do not reorder functions or variables marked @code{no_reorder}
2907 against each other or top level assembler statements the executable.
2908 The actual order in the program will depend on the linker command
2909 line. Static variables marked like this are also not removed.
2910 This has a similar effect
2911 as the @option{-fno-toplevel-reorder} option, but only applies to the
2912 marked symbols.
2914 @item no_sanitize ("@var{sanitize_option}")
2915 @cindex @code{no_sanitize} function attribute
2916 The @code{no_sanitize} attribute on functions is used
2917 to inform the compiler that it should not do sanitization of all options
2918 mentioned in @var{sanitize_option}.  A list of values acceptable by
2919 @option{-fsanitize} option can be provided.
2921 @smallexample
2922 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2923 f () @{ /* @r{Do something.} */; @}
2924 @end smallexample
2926 @item no_sanitize_address
2927 @itemx no_address_safety_analysis
2928 @cindex @code{no_sanitize_address} function attribute
2929 The @code{no_sanitize_address} attribute on functions is used
2930 to inform the compiler that it should not instrument memory accesses
2931 in the function when compiling with the @option{-fsanitize=address} option.
2932 The @code{no_address_safety_analysis} is a deprecated alias of the
2933 @code{no_sanitize_address} attribute, new code should use
2934 @code{no_sanitize_address}.
2936 @item no_sanitize_thread
2937 @cindex @code{no_sanitize_thread} function attribute
2938 The @code{no_sanitize_thread} attribute on functions is used
2939 to inform the compiler that it should not instrument memory accesses
2940 in the function when compiling with the @option{-fsanitize=thread} option.
2942 @item no_sanitize_undefined
2943 @cindex @code{no_sanitize_undefined} function attribute
2944 The @code{no_sanitize_undefined} attribute on functions is used
2945 to inform the compiler that it should not check for undefined behavior
2946 in the function when compiling with the @option{-fsanitize=undefined} option.
2948 @item no_split_stack
2949 @cindex @code{no_split_stack} function attribute
2950 @opindex fsplit-stack
2951 If @option{-fsplit-stack} is given, functions have a small
2952 prologue which decides whether to split the stack.  Functions with the
2953 @code{no_split_stack} attribute do not have that prologue, and thus
2954 may run with only a small amount of stack space available.
2956 @item no_stack_limit
2957 @cindex @code{no_stack_limit} function attribute
2958 This attribute locally overrides the @option{-fstack-limit-register}
2959 and @option{-fstack-limit-symbol} command-line options; it has the effect
2960 of disabling stack limit checking in the function it applies to.
2962 @item noclone
2963 @cindex @code{noclone} function attribute
2964 This function attribute prevents a function from being considered for
2965 cloning---a mechanism that produces specialized copies of functions
2966 and which is (currently) performed by interprocedural constant
2967 propagation.
2969 @item noinline
2970 @cindex @code{noinline} function attribute
2971 This function attribute prevents a function from being considered for
2972 inlining.
2973 @c Don't enumerate the optimizations by name here; we try to be
2974 @c future-compatible with this mechanism.
2975 If the function does not have side-effects, there are optimizations
2976 other than inlining that cause function calls to be optimized away,
2977 although the function call is live.  To keep such calls from being
2978 optimized away, put
2979 @smallexample
2980 asm ("");
2981 @end smallexample
2983 @noindent
2984 (@pxref{Extended Asm}) in the called function, to serve as a special
2985 side-effect.
2987 @item nonnull (@var{arg-index}, @dots{})
2988 @cindex @code{nonnull} function attribute
2989 @cindex functions with non-null pointer arguments
2990 The @code{nonnull} attribute specifies that some function parameters should
2991 be non-null pointers.  For instance, the declaration:
2993 @smallexample
2994 extern void *
2995 my_memcpy (void *dest, const void *src, size_t len)
2996         __attribute__((nonnull (1, 2)));
2997 @end smallexample
2999 @noindent
3000 causes the compiler to check that, in calls to @code{my_memcpy},
3001 arguments @var{dest} and @var{src} are non-null.  If the compiler
3002 determines that a null pointer is passed in an argument slot marked
3003 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3004 is issued.  The compiler may also choose to make optimizations based
3005 on the knowledge that certain function arguments will never be null.
3007 If no argument index list is given to the @code{nonnull} attribute,
3008 all pointer arguments are marked as non-null.  To illustrate, the
3009 following declaration is equivalent to the previous example:
3011 @smallexample
3012 extern void *
3013 my_memcpy (void *dest, const void *src, size_t len)
3014         __attribute__((nonnull));
3015 @end smallexample
3017 @item noplt
3018 @cindex @code{noplt} function attribute
3019 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3020 Calls to functions marked with this attribute in position-independent code
3021 do not use the PLT.
3023 @smallexample
3024 @group
3025 /* Externally defined function foo.  */
3026 int foo () __attribute__ ((noplt));
3029 main (/* @r{@dots{}} */)
3031   /* @r{@dots{}} */
3032   foo ();
3033   /* @r{@dots{}} */
3035 @end group
3036 @end smallexample
3038 The @code{noplt} attribute on function @code{foo}
3039 tells the compiler to assume that
3040 the function @code{foo} is externally defined and that the call to
3041 @code{foo} must avoid the PLT
3042 in position-independent code.
3044 In position-dependent code, a few targets also convert calls to
3045 functions that are marked to not use the PLT to use the GOT instead.
3047 @item noreturn
3048 @cindex @code{noreturn} function attribute
3049 @cindex functions that never return
3050 A few standard library functions, such as @code{abort} and @code{exit},
3051 cannot return.  GCC knows this automatically.  Some programs define
3052 their own functions that never return.  You can declare them
3053 @code{noreturn} to tell the compiler this fact.  For example,
3055 @smallexample
3056 @group
3057 void fatal () __attribute__ ((noreturn));
3059 void
3060 fatal (/* @r{@dots{}} */)
3062   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3063   exit (1);
3065 @end group
3066 @end smallexample
3068 The @code{noreturn} keyword tells the compiler to assume that
3069 @code{fatal} cannot return.  It can then optimize without regard to what
3070 would happen if @code{fatal} ever did return.  This makes slightly
3071 better code.  More importantly, it helps avoid spurious warnings of
3072 uninitialized variables.
3074 The @code{noreturn} keyword does not affect the exceptional path when that
3075 applies: a @code{noreturn}-marked function may still return to the caller
3076 by throwing an exception or calling @code{longjmp}.
3078 Do not assume that registers saved by the calling function are
3079 restored before calling the @code{noreturn} function.
3081 It does not make sense for a @code{noreturn} function to have a return
3082 type other than @code{void}.
3084 @item nothrow
3085 @cindex @code{nothrow} function attribute
3086 The @code{nothrow} attribute is used to inform the compiler that a
3087 function cannot throw an exception.  For example, most functions in
3088 the standard C library can be guaranteed not to throw an exception
3089 with the notable exceptions of @code{qsort} and @code{bsearch} that
3090 take function pointer arguments.
3092 @item optimize
3093 @cindex @code{optimize} function attribute
3094 The @code{optimize} attribute is used to specify that a function is to
3095 be compiled with different optimization options than specified on the
3096 command line.  Arguments can either be numbers or strings.  Numbers
3097 are assumed to be an optimization level.  Strings that begin with
3098 @code{O} are assumed to be an optimization option, while other options
3099 are assumed to be used with a @code{-f} prefix.  You can also use the
3100 @samp{#pragma GCC optimize} pragma to set the optimization options
3101 that affect more than one function.
3102 @xref{Function Specific Option Pragmas}, for details about the
3103 @samp{#pragma GCC optimize} pragma.
3105 This attribute should be used for debugging purposes only.  It is not
3106 suitable in production code.
3108 @item pure
3109 @cindex @code{pure} function attribute
3110 @cindex functions that have no side effects
3111 Many functions have no effects except the return value and their
3112 return value depends only on the parameters and/or global variables.
3113 Such a function can be subject
3114 to common subexpression elimination and loop optimization just as an
3115 arithmetic operator would be.  These functions should be declared
3116 with the attribute @code{pure}.  For example,
3118 @smallexample
3119 int square (int) __attribute__ ((pure));
3120 @end smallexample
3122 @noindent
3123 says that the hypothetical function @code{square} is safe to call
3124 fewer times than the program says.
3126 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3127 Interesting non-pure functions are functions with infinite loops or those
3128 depending on volatile memory or other system resource, that may change between
3129 two consecutive calls (such as @code{feof} in a multithreading environment).
3131 @item returns_nonnull
3132 @cindex @code{returns_nonnull} function attribute
3133 The @code{returns_nonnull} attribute specifies that the function
3134 return value should be a non-null pointer.  For instance, the declaration:
3136 @smallexample
3137 extern void *
3138 mymalloc (size_t len) __attribute__((returns_nonnull));
3139 @end smallexample
3141 @noindent
3142 lets the compiler optimize callers based on the knowledge
3143 that the return value will never be null.
3145 @item returns_twice
3146 @cindex @code{returns_twice} function attribute
3147 @cindex functions that return more than once
3148 The @code{returns_twice} attribute tells the compiler that a function may
3149 return more than one time.  The compiler ensures that all registers
3150 are dead before calling such a function and emits a warning about
3151 the variables that may be clobbered after the second return from the
3152 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3153 The @code{longjmp}-like counterpart of such function, if any, might need
3154 to be marked with the @code{noreturn} attribute.
3156 @item section ("@var{section-name}")
3157 @cindex @code{section} function attribute
3158 @cindex functions in arbitrary sections
3159 Normally, the compiler places the code it generates in the @code{text} section.
3160 Sometimes, however, you need additional sections, or you need certain
3161 particular functions to appear in special sections.  The @code{section}
3162 attribute specifies that a function lives in a particular section.
3163 For example, the declaration:
3165 @smallexample
3166 extern void foobar (void) __attribute__ ((section ("bar")));
3167 @end smallexample
3169 @noindent
3170 puts the function @code{foobar} in the @code{bar} section.
3172 Some file formats do not support arbitrary sections so the @code{section}
3173 attribute is not available on all platforms.
3174 If you need to map the entire contents of a module to a particular
3175 section, consider using the facilities of the linker instead.
3177 @item sentinel
3178 @cindex @code{sentinel} function attribute
3179 This function attribute ensures that a parameter in a function call is
3180 an explicit @code{NULL}.  The attribute is only valid on variadic
3181 functions.  By default, the sentinel is located at position zero, the
3182 last parameter of the function call.  If an optional integer position
3183 argument P is supplied to the attribute, the sentinel must be located at
3184 position P counting backwards from the end of the argument list.
3186 @smallexample
3187 __attribute__ ((sentinel))
3188 is equivalent to
3189 __attribute__ ((sentinel(0)))
3190 @end smallexample
3192 The attribute is automatically set with a position of 0 for the built-in
3193 functions @code{execl} and @code{execlp}.  The built-in function
3194 @code{execle} has the attribute set with a position of 1.
3196 A valid @code{NULL} in this context is defined as zero with any pointer
3197 type.  If your system defines the @code{NULL} macro with an integer type
3198 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3199 with a copy that redefines NULL appropriately.
3201 The warnings for missing or incorrect sentinels are enabled with
3202 @option{-Wformat}.
3204 @item simd
3205 @itemx simd("@var{mask}")
3206 @cindex @code{simd} function attribute
3207 This attribute enables creation of one or more function versions that
3208 can process multiple arguments using SIMD instructions from a
3209 single invocation.  Specifying this attribute allows compiler to
3210 assume that such versions are available at link time (provided
3211 in the same or another translation unit).  Generated versions are
3212 target-dependent and described in the corresponding Vector ABI document.  For
3213 x86_64 target this document can be found
3214 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3216 The optional argument @var{mask} may have the value
3217 @code{notinbranch} or @code{inbranch},
3218 and instructs the compiler to generate non-masked or masked
3219 clones correspondingly. By default, all clones are generated.
3221 The attribute should not be used together with Cilk Plus @code{vector}
3222 attribute on the same function.
3224 If the attribute is specified and @code{#pragma omp declare simd} is
3225 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3226 switch is specified, then the attribute is ignored.
3228 @item stack_protect
3229 @cindex @code{stack_protect} function attribute
3230 This attribute adds stack protection code to the function if 
3231 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3232 or @option{-fstack-protector-explicit} are set.
3234 @item target (@var{options})
3235 @cindex @code{target} function attribute
3236 Multiple target back ends implement the @code{target} attribute
3237 to specify that a function is to
3238 be compiled with different target options than specified on the
3239 command line.  This can be used for instance to have functions
3240 compiled with a different ISA (instruction set architecture) than the
3241 default.  You can also use the @samp{#pragma GCC target} pragma to set
3242 more than one function to be compiled with specific target options.
3243 @xref{Function Specific Option Pragmas}, for details about the
3244 @samp{#pragma GCC target} pragma.
3246 For instance, on an x86, you could declare one function with the
3247 @code{target("sse4.1,arch=core2")} attribute and another with
3248 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3249 compiling the first function with @option{-msse4.1} and
3250 @option{-march=core2} options, and the second function with
3251 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3252 to make sure that a function is only invoked on a machine that
3253 supports the particular ISA it is compiled for (for example by using
3254 @code{cpuid} on x86 to determine what feature bits and architecture
3255 family are used).
3257 @smallexample
3258 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3259 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3260 @end smallexample
3262 You can either use multiple
3263 strings separated by commas to specify multiple options,
3264 or separate the options with a comma (@samp{,}) within a single string.
3266 The options supported are specific to each target; refer to @ref{x86
3267 Function Attributes}, @ref{PowerPC Function Attributes},
3268 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3269 for details.
3271 @item target_clones (@var{options})
3272 @cindex @code{target_clones} function attribute
3273 The @code{target_clones} attribute is used to specify that a function
3274 be cloned into multiple versions compiled with different target options
3275 than specified on the command line.  The supported options and restrictions
3276 are the same as for @code{target} attribute.
3278 For instance, on an x86, you could compile a function with
3279 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3280 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3282 On a PowerPC, you can compile a function with
3283 @code{target_clones("cpu=power9,default")}.  GCC will create two
3284 function clones, one compiled with @option{-mcpu=power9} and another
3285 with the default options.
3287 It also creates a resolver function (see
3288 the @code{ifunc} attribute above) that dynamically selects a clone
3289 suitable for current architecture.  The resolver is created only if there
3290 is a usage of a function with @code{target_clones} attribute.
3292 @item unused
3293 @cindex @code{unused} function attribute
3294 This attribute, attached to a function, means that the function is meant
3295 to be possibly unused.  GCC does not produce a warning for this
3296 function.
3298 @item used
3299 @cindex @code{used} function attribute
3300 This attribute, attached to a function, means that code must be emitted
3301 for the function even if it appears that the function is not referenced.
3302 This is useful, for example, when the function is referenced only in
3303 inline assembly.
3305 When applied to a member function of a C++ class template, the
3306 attribute also means that the function is instantiated if the
3307 class itself is instantiated.
3309 @item visibility ("@var{visibility_type}")
3310 @cindex @code{visibility} function attribute
3311 This attribute affects the linkage of the declaration to which it is attached.
3312 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3313 (@pxref{Common Type Attributes}) as well as functions.
3315 There are four supported @var{visibility_type} values: default,
3316 hidden, protected or internal visibility.
3318 @smallexample
3319 void __attribute__ ((visibility ("protected")))
3320 f () @{ /* @r{Do something.} */; @}
3321 int i __attribute__ ((visibility ("hidden")));
3322 @end smallexample
3324 The possible values of @var{visibility_type} correspond to the
3325 visibility settings in the ELF gABI.
3327 @table @code
3328 @c keep this list of visibilities in alphabetical order.
3330 @item default
3331 Default visibility is the normal case for the object file format.
3332 This value is available for the visibility attribute to override other
3333 options that may change the assumed visibility of entities.
3335 On ELF, default visibility means that the declaration is visible to other
3336 modules and, in shared libraries, means that the declared entity may be
3337 overridden.
3339 On Darwin, default visibility means that the declaration is visible to
3340 other modules.
3342 Default visibility corresponds to ``external linkage'' in the language.
3344 @item hidden
3345 Hidden visibility indicates that the entity declared has a new
3346 form of linkage, which we call ``hidden linkage''.  Two
3347 declarations of an object with hidden linkage refer to the same object
3348 if they are in the same shared object.
3350 @item internal
3351 Internal visibility is like hidden visibility, but with additional
3352 processor specific semantics.  Unless otherwise specified by the
3353 psABI, GCC defines internal visibility to mean that a function is
3354 @emph{never} called from another module.  Compare this with hidden
3355 functions which, while they cannot be referenced directly by other
3356 modules, can be referenced indirectly via function pointers.  By
3357 indicating that a function cannot be called from outside the module,
3358 GCC may for instance omit the load of a PIC register since it is known
3359 that the calling function loaded the correct value.
3361 @item protected
3362 Protected visibility is like default visibility except that it
3363 indicates that references within the defining module bind to the
3364 definition in that module.  That is, the declared entity cannot be
3365 overridden by another module.
3367 @end table
3369 All visibilities are supported on many, but not all, ELF targets
3370 (supported when the assembler supports the @samp{.visibility}
3371 pseudo-op).  Default visibility is supported everywhere.  Hidden
3372 visibility is supported on Darwin targets.
3374 The visibility attribute should be applied only to declarations that
3375 would otherwise have external linkage.  The attribute should be applied
3376 consistently, so that the same entity should not be declared with
3377 different settings of the attribute.
3379 In C++, the visibility attribute applies to types as well as functions
3380 and objects, because in C++ types have linkage.  A class must not have
3381 greater visibility than its non-static data member types and bases,
3382 and class members default to the visibility of their class.  Also, a
3383 declaration without explicit visibility is limited to the visibility
3384 of its type.
3386 In C++, you can mark member functions and static member variables of a
3387 class with the visibility attribute.  This is useful if you know a
3388 particular method or static member variable should only be used from
3389 one shared object; then you can mark it hidden while the rest of the
3390 class has default visibility.  Care must be taken to avoid breaking
3391 the One Definition Rule; for example, it is usually not useful to mark
3392 an inline method as hidden without marking the whole class as hidden.
3394 A C++ namespace declaration can also have the visibility attribute.
3396 @smallexample
3397 namespace nspace1 __attribute__ ((visibility ("protected")))
3398 @{ /* @r{Do something.} */; @}
3399 @end smallexample
3401 This attribute applies only to the particular namespace body, not to
3402 other definitions of the same namespace; it is equivalent to using
3403 @samp{#pragma GCC visibility} before and after the namespace
3404 definition (@pxref{Visibility Pragmas}).
3406 In C++, if a template argument has limited visibility, this
3407 restriction is implicitly propagated to the template instantiation.
3408 Otherwise, template instantiations and specializations default to the
3409 visibility of their template.
3411 If both the template and enclosing class have explicit visibility, the
3412 visibility from the template is used.
3414 @item warn_unused_result
3415 @cindex @code{warn_unused_result} function attribute
3416 The @code{warn_unused_result} attribute causes a warning to be emitted
3417 if a caller of the function with this attribute does not use its
3418 return value.  This is useful for functions where not checking
3419 the result is either a security problem or always a bug, such as
3420 @code{realloc}.
3422 @smallexample
3423 int fn () __attribute__ ((warn_unused_result));
3424 int foo ()
3426   if (fn () < 0) return -1;
3427   fn ();
3428   return 0;
3430 @end smallexample
3432 @noindent
3433 results in warning on line 5.
3435 @item weak
3436 @cindex @code{weak} function attribute
3437 The @code{weak} attribute causes the declaration to be emitted as a weak
3438 symbol rather than a global.  This is primarily useful in defining
3439 library functions that can be overridden in user code, though it can
3440 also be used with non-function declarations.  Weak symbols are supported
3441 for ELF targets, and also for a.out targets when using the GNU assembler
3442 and linker.
3444 @item weakref
3445 @itemx weakref ("@var{target}")
3446 @cindex @code{weakref} function attribute
3447 The @code{weakref} attribute marks a declaration as a weak reference.
3448 Without arguments, it should be accompanied by an @code{alias} attribute
3449 naming the target symbol.  Optionally, the @var{target} may be given as
3450 an argument to @code{weakref} itself.  In either case, @code{weakref}
3451 implicitly marks the declaration as @code{weak}.  Without a
3452 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3453 @code{weakref} is equivalent to @code{weak}.
3455 @smallexample
3456 static int x() __attribute__ ((weakref ("y")));
3457 /* is equivalent to... */
3458 static int x() __attribute__ ((weak, weakref, alias ("y")));
3459 /* and to... */
3460 static int x() __attribute__ ((weakref));
3461 static int x() __attribute__ ((alias ("y")));
3462 @end smallexample
3464 A weak reference is an alias that does not by itself require a
3465 definition to be given for the target symbol.  If the target symbol is
3466 only referenced through weak references, then it becomes a @code{weak}
3467 undefined symbol.  If it is directly referenced, however, then such
3468 strong references prevail, and a definition is required for the
3469 symbol, not necessarily in the same translation unit.
3471 The effect is equivalent to moving all references to the alias to a
3472 separate translation unit, renaming the alias to the aliased symbol,
3473 declaring it as weak, compiling the two separate translation units and
3474 performing a reloadable link on them.
3476 At present, a declaration to which @code{weakref} is attached can
3477 only be @code{static}.
3480 @end table
3482 @c This is the end of the target-independent attribute table
3484 @node AArch64 Function Attributes
3485 @subsection AArch64 Function Attributes
3487 The following target-specific function attributes are available for the
3488 AArch64 target.  For the most part, these options mirror the behavior of
3489 similar command-line options (@pxref{AArch64 Options}), but on a
3490 per-function basis.
3492 @table @code
3493 @item general-regs-only
3494 @cindex @code{general-regs-only} function attribute, AArch64
3495 Indicates that no floating-point or Advanced SIMD registers should be
3496 used when generating code for this function.  If the function explicitly
3497 uses floating-point code, then the compiler gives an error.  This is
3498 the same behavior as that of the command-line option
3499 @option{-mgeneral-regs-only}.
3501 @item fix-cortex-a53-835769
3502 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3503 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3504 applied to this function.  To explicitly disable the workaround for this
3505 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3506 This corresponds to the behavior of the command line options
3507 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3509 @item cmodel=
3510 @cindex @code{cmodel=} function attribute, AArch64
3511 Indicates that code should be generated for a particular code model for
3512 this function.  The behavior and permissible arguments are the same as
3513 for the command line option @option{-mcmodel=}.
3515 @item strict-align
3516 @cindex @code{strict-align} function attribute, AArch64
3517 Indicates that the compiler should not assume that unaligned memory references
3518 are handled by the system.  The behavior is the same as for the command-line
3519 option @option{-mstrict-align}.
3521 @item omit-leaf-frame-pointer
3522 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3523 Indicates that the frame pointer should be omitted for a leaf function call.
3524 To keep the frame pointer, the inverse attribute
3525 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3526 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3527 and @option{-mno-omit-leaf-frame-pointer}.
3529 @item tls-dialect=
3530 @cindex @code{tls-dialect=} function attribute, AArch64
3531 Specifies the TLS dialect to use for this function.  The behavior and
3532 permissible arguments are the same as for the command-line option
3533 @option{-mtls-dialect=}.
3535 @item arch=
3536 @cindex @code{arch=} function attribute, AArch64
3537 Specifies the architecture version and architectural extensions to use
3538 for this function.  The behavior and permissible arguments are the same as
3539 for the @option{-march=} command-line option.
3541 @item tune=
3542 @cindex @code{tune=} function attribute, AArch64
3543 Specifies the core for which to tune the performance of this function.
3544 The behavior and permissible arguments are the same as for the @option{-mtune=}
3545 command-line option.
3547 @item cpu=
3548 @cindex @code{cpu=} function attribute, AArch64
3549 Specifies the core for which to tune the performance of this function and also
3550 whose architectural features to use.  The behavior and valid arguments are the
3551 same as for the @option{-mcpu=} command-line option.
3553 @item sign-return-address
3554 @cindex @code{sign-return-address} function attribute, AArch64
3555 Select the function scope on which return address signing will be applied.  The
3556 behavior and permissible arguments are the same as for the command-line option
3557 @option{-msign-return-address=}.  The default value is @code{none}.
3559 @end table
3561 The above target attributes can be specified as follows:
3563 @smallexample
3564 __attribute__((target("@var{attr-string}")))
3566 f (int a)
3568   return a + 5;
3570 @end smallexample
3572 where @code{@var{attr-string}} is one of the attribute strings specified above.
3574 Additionally, the architectural extension string may be specified on its
3575 own.  This can be used to turn on and off particular architectural extensions
3576 without having to specify a particular architecture version or core.  Example:
3578 @smallexample
3579 __attribute__((target("+crc+nocrypto")))
3581 foo (int a)
3583   return a + 5;
3585 @end smallexample
3587 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3588 extension and disables the @code{crypto} extension for the function @code{foo}
3589 without modifying an existing @option{-march=} or @option{-mcpu} option.
3591 Multiple target function attributes can be specified by separating them with
3592 a comma.  For example:
3593 @smallexample
3594 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3596 foo (int a)
3598   return a + 5;
3600 @end smallexample
3602 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3603 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3605 @subsubsection Inlining rules
3606 Specifying target attributes on individual functions or performing link-time
3607 optimization across translation units compiled with different target options
3608 can affect function inlining rules:
3610 In particular, a caller function can inline a callee function only if the
3611 architectural features available to the callee are a subset of the features
3612 available to the caller.
3613 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3614 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3615 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3616 because the all the architectural features that function @code{bar} requires
3617 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3618 inline function @code{foo}.
3620 Additionally inlining a function compiled with @option{-mstrict-align} into a
3621 function compiled without @code{-mstrict-align} is not allowed.
3622 However, inlining a function compiled without @option{-mstrict-align} into a
3623 function compiled with @option{-mstrict-align} is allowed.
3625 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3626 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3627 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3628 architectural feature rules specified above.
3630 @node ARC Function Attributes
3631 @subsection ARC Function Attributes
3633 These function attributes are supported by the ARC back end:
3635 @table @code
3636 @item interrupt
3637 @cindex @code{interrupt} function attribute, ARC
3638 Use this attribute to indicate
3639 that the specified function is an interrupt handler.  The compiler generates
3640 function entry and exit sequences suitable for use in an interrupt handler
3641 when this attribute is present.
3643 On the ARC, you must specify the kind of interrupt to be handled
3644 in a parameter to the interrupt attribute like this:
3646 @smallexample
3647 void f () __attribute__ ((interrupt ("ilink1")));
3648 @end smallexample
3650 Permissible values for this parameter are: @w{@code{ilink1}} and
3651 @w{@code{ilink2}}.
3653 @item long_call
3654 @itemx medium_call
3655 @itemx short_call
3656 @cindex @code{long_call} function attribute, ARC
3657 @cindex @code{medium_call} function attribute, ARC
3658 @cindex @code{short_call} function attribute, ARC
3659 @cindex indirect calls, ARC
3660 These attributes specify how a particular function is called.
3661 These attributes override the
3662 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3663 command-line switches and @code{#pragma long_calls} settings.
3665 For ARC, a function marked with the @code{long_call} attribute is
3666 always called using register-indirect jump-and-link instructions,
3667 thereby enabling the called function to be placed anywhere within the
3668 32-bit address space.  A function marked with the @code{medium_call}
3669 attribute will always be close enough to be called with an unconditional
3670 branch-and-link instruction, which has a 25-bit offset from
3671 the call site.  A function marked with the @code{short_call}
3672 attribute will always be close enough to be called with a conditional
3673 branch-and-link instruction, which has a 21-bit offset from
3674 the call site.
3675 @end table
3677 @node ARM Function Attributes
3678 @subsection ARM Function Attributes
3680 These function attributes are supported for ARM targets:
3682 @table @code
3683 @item interrupt
3684 @cindex @code{interrupt} function attribute, ARM
3685 Use this attribute to indicate
3686 that the specified function is an interrupt handler.  The compiler generates
3687 function entry and exit sequences suitable for use in an interrupt handler
3688 when this attribute is present.
3690 You can specify the kind of interrupt to be handled by
3691 adding an optional parameter to the interrupt attribute like this:
3693 @smallexample
3694 void f () __attribute__ ((interrupt ("IRQ")));
3695 @end smallexample
3697 @noindent
3698 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3699 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3701 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3702 may be called with a word-aligned stack pointer.
3704 @item isr
3705 @cindex @code{isr} function attribute, ARM
3706 Use this attribute on ARM to write Interrupt Service Routines. This is an
3707 alias to the @code{interrupt} attribute above.
3709 @item long_call
3710 @itemx short_call
3711 @cindex @code{long_call} function attribute, ARM
3712 @cindex @code{short_call} function attribute, ARM
3713 @cindex indirect calls, ARM
3714 These attributes specify how a particular function is called.
3715 These attributes override the
3716 @option{-mlong-calls} (@pxref{ARM Options})
3717 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3718 @code{long_call} attribute indicates that the function might be far
3719 away from the call site and require a different (more expensive)
3720 calling sequence.   The @code{short_call} attribute always places
3721 the offset to the function from the call site into the @samp{BL}
3722 instruction directly.
3724 @item naked
3725 @cindex @code{naked} function attribute, ARM
3726 This attribute allows the compiler to construct the
3727 requisite function declaration, while allowing the body of the
3728 function to be assembly code. The specified function will not have
3729 prologue/epilogue sequences generated by the compiler. Only basic
3730 @code{asm} statements can safely be included in naked functions
3731 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3732 basic @code{asm} and C code may appear to work, they cannot be
3733 depended upon to work reliably and are not supported.
3735 @item pcs
3736 @cindex @code{pcs} function attribute, ARM
3738 The @code{pcs} attribute can be used to control the calling convention
3739 used for a function on ARM.  The attribute takes an argument that specifies
3740 the calling convention to use.
3742 When compiling using the AAPCS ABI (or a variant of it) then valid
3743 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3744 order to use a variant other than @code{"aapcs"} then the compiler must
3745 be permitted to use the appropriate co-processor registers (i.e., the
3746 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3747 For example,
3749 @smallexample
3750 /* Argument passed in r0, and result returned in r0+r1.  */
3751 double f2d (float) __attribute__((pcs("aapcs")));
3752 @end smallexample
3754 Variadic functions always use the @code{"aapcs"} calling convention and
3755 the compiler rejects attempts to specify an alternative.
3757 @item target (@var{options})
3758 @cindex @code{target} function attribute
3759 As discussed in @ref{Common Function Attributes}, this attribute 
3760 allows specification of target-specific compilation options.
3762 On ARM, the following options are allowed:
3764 @table @samp
3765 @item thumb
3766 @cindex @code{target("thumb")} function attribute, ARM
3767 Force code generation in the Thumb (T16/T32) ISA, depending on the
3768 architecture level.
3770 @item arm
3771 @cindex @code{target("arm")} function attribute, ARM
3772 Force code generation in the ARM (A32) ISA.
3774 Functions from different modes can be inlined in the caller's mode.
3776 @item fpu=
3777 @cindex @code{target("fpu=")} function attribute, ARM
3778 Specifies the fpu for which to tune the performance of this function.
3779 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3780 command-line option.
3782 @end table
3784 @end table
3786 @node AVR Function Attributes
3787 @subsection AVR Function Attributes
3789 These function attributes are supported by the AVR back end:
3791 @table @code
3792 @item interrupt
3793 @cindex @code{interrupt} function attribute, AVR
3794 Use this attribute to indicate
3795 that the specified function is an interrupt handler.  The compiler generates
3796 function entry and exit sequences suitable for use in an interrupt handler
3797 when this attribute is present.
3799 On the AVR, the hardware globally disables interrupts when an
3800 interrupt is executed.  The first instruction of an interrupt handler
3801 declared with this attribute is a @code{SEI} instruction to
3802 re-enable interrupts.  See also the @code{signal} function attribute
3803 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3804 @code{interrupt} are specified for the same function, @code{signal}
3805 is silently ignored.
3807 @item naked
3808 @cindex @code{naked} function attribute, AVR
3809 This attribute allows the compiler to construct the
3810 requisite function declaration, while allowing the body of the
3811 function to be assembly code. The specified function will not have
3812 prologue/epilogue sequences generated by the compiler. Only basic
3813 @code{asm} statements can safely be included in naked functions
3814 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3815 basic @code{asm} and C code may appear to work, they cannot be
3816 depended upon to work reliably and are not supported.
3818 @item OS_main
3819 @itemx OS_task
3820 @cindex @code{OS_main} function attribute, AVR
3821 @cindex @code{OS_task} function attribute, AVR
3822 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3823 do not save/restore any call-saved register in their prologue/epilogue.
3825 The @code{OS_main} attribute can be used when there @emph{is
3826 guarantee} that interrupts are disabled at the time when the function
3827 is entered.  This saves resources when the stack pointer has to be
3828 changed to set up a frame for local variables.
3830 The @code{OS_task} attribute can be used when there is @emph{no
3831 guarantee} that interrupts are disabled at that time when the function
3832 is entered like for, e@.g@. task functions in a multi-threading operating
3833 system. In that case, changing the stack pointer register is
3834 guarded by save/clear/restore of the global interrupt enable flag.
3836 The differences to the @code{naked} function attribute are:
3837 @itemize @bullet
3838 @item @code{naked} functions do not have a return instruction whereas 
3839 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3840 @code{RETI} return instruction.
3841 @item @code{naked} functions do not set up a frame for local variables
3842 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3843 as needed.
3844 @end itemize
3846 @item signal
3847 @cindex @code{signal} function attribute, AVR
3848 Use this attribute on the AVR to indicate that the specified
3849 function is an interrupt handler.  The compiler generates function
3850 entry and exit sequences suitable for use in an interrupt handler when this
3851 attribute is present.
3853 See also the @code{interrupt} function attribute. 
3855 The AVR hardware globally disables interrupts when an interrupt is executed.
3856 Interrupt handler functions defined with the @code{signal} attribute
3857 do not re-enable interrupts.  It is save to enable interrupts in a
3858 @code{signal} handler.  This ``save'' only applies to the code
3859 generated by the compiler and not to the IRQ layout of the
3860 application which is responsibility of the application.
3862 If both @code{signal} and @code{interrupt} are specified for the same
3863 function, @code{signal} is silently ignored.
3864 @end table
3866 @node Blackfin Function Attributes
3867 @subsection Blackfin Function Attributes
3869 These function attributes are supported by the Blackfin back end:
3871 @table @code
3873 @item exception_handler
3874 @cindex @code{exception_handler} function attribute
3875 @cindex exception handler functions, Blackfin
3876 Use this attribute on the Blackfin to indicate that the specified function
3877 is an exception handler.  The compiler generates function entry and
3878 exit sequences suitable for use in an exception handler when this
3879 attribute is present.
3881 @item interrupt_handler
3882 @cindex @code{interrupt_handler} function attribute, Blackfin
3883 Use this attribute to
3884 indicate that the specified function is an interrupt handler.  The compiler
3885 generates function entry and exit sequences suitable for use in an
3886 interrupt handler when this attribute is present.
3888 @item kspisusp
3889 @cindex @code{kspisusp} function attribute, Blackfin
3890 @cindex User stack pointer in interrupts on the Blackfin
3891 When used together with @code{interrupt_handler}, @code{exception_handler}
3892 or @code{nmi_handler}, code is generated to load the stack pointer
3893 from the USP register in the function prologue.
3895 @item l1_text
3896 @cindex @code{l1_text} function attribute, Blackfin
3897 This attribute specifies a function to be placed into L1 Instruction
3898 SRAM@. The function is put into a specific section named @code{.l1.text}.
3899 With @option{-mfdpic}, function calls with a such function as the callee
3900 or caller uses inlined PLT.
3902 @item l2
3903 @cindex @code{l2} function attribute, Blackfin
3904 This attribute specifies a function to be placed into L2
3905 SRAM. The function is put into a specific section named
3906 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3907 an inlined PLT.
3909 @item longcall
3910 @itemx shortcall
3911 @cindex indirect calls, Blackfin
3912 @cindex @code{longcall} function attribute, Blackfin
3913 @cindex @code{shortcall} function attribute, Blackfin
3914 The @code{longcall} attribute
3915 indicates that the function might be far away from the call site and
3916 require a different (more expensive) calling sequence.  The
3917 @code{shortcall} attribute indicates that the function is always close
3918 enough for the shorter calling sequence to be used.  These attributes
3919 override the @option{-mlongcall} switch.
3921 @item nesting
3922 @cindex @code{nesting} function attribute, Blackfin
3923 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3924 Use this attribute together with @code{interrupt_handler},
3925 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3926 entry code should enable nested interrupts or exceptions.
3928 @item nmi_handler
3929 @cindex @code{nmi_handler} function attribute, Blackfin
3930 @cindex NMI handler functions on the Blackfin processor
3931 Use this attribute on the Blackfin to indicate that the specified function
3932 is an NMI handler.  The compiler generates function entry and
3933 exit sequences suitable for use in an NMI handler when this
3934 attribute is present.
3936 @item saveall
3937 @cindex @code{saveall} function attribute, Blackfin
3938 @cindex save all registers on the Blackfin
3939 Use this attribute to indicate that
3940 all registers except the stack pointer should be saved in the prologue
3941 regardless of whether they are used or not.
3942 @end table
3944 @node CR16 Function Attributes
3945 @subsection CR16 Function Attributes
3947 These function attributes are supported by the CR16 back end:
3949 @table @code
3950 @item interrupt
3951 @cindex @code{interrupt} function attribute, CR16
3952 Use this attribute to indicate
3953 that the specified function is an interrupt handler.  The compiler generates
3954 function entry and exit sequences suitable for use in an interrupt handler
3955 when this attribute is present.
3956 @end table
3958 @node Epiphany Function Attributes
3959 @subsection Epiphany Function Attributes
3961 These function attributes are supported by the Epiphany back end:
3963 @table @code
3964 @item disinterrupt
3965 @cindex @code{disinterrupt} function attribute, Epiphany
3966 This attribute causes the compiler to emit
3967 instructions to disable interrupts for the duration of the given
3968 function.
3970 @item forwarder_section
3971 @cindex @code{forwarder_section} function attribute, Epiphany
3972 This attribute modifies the behavior of an interrupt handler.
3973 The interrupt handler may be in external memory which cannot be
3974 reached by a branch instruction, so generate a local memory trampoline
3975 to transfer control.  The single parameter identifies the section where
3976 the trampoline is placed.
3978 @item interrupt
3979 @cindex @code{interrupt} function attribute, Epiphany
3980 Use this attribute to indicate
3981 that the specified function is an interrupt handler.  The compiler generates
3982 function entry and exit sequences suitable for use in an interrupt handler
3983 when this attribute is present.  It may also generate
3984 a special section with code to initialize the interrupt vector table.
3986 On Epiphany targets one or more optional parameters can be added like this:
3988 @smallexample
3989 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3990 @end smallexample
3992 Permissible values for these parameters are: @w{@code{reset}},
3993 @w{@code{software_exception}}, @w{@code{page_miss}},
3994 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3995 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3996 Multiple parameters indicate that multiple entries in the interrupt
3997 vector table should be initialized for this function, i.e.@: for each
3998 parameter @w{@var{name}}, a jump to the function is emitted in
3999 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4000 entirely, in which case no interrupt vector table entry is provided.
4002 Note that interrupts are enabled inside the function
4003 unless the @code{disinterrupt} attribute is also specified.
4005 The following examples are all valid uses of these attributes on
4006 Epiphany targets:
4007 @smallexample
4008 void __attribute__ ((interrupt)) universal_handler ();
4009 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4010 void __attribute__ ((interrupt ("dma0, dma1"))) 
4011   universal_dma_handler ();
4012 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4013   fast_timer_handler ();
4014 void __attribute__ ((interrupt ("dma0, dma1"), 
4015                      forwarder_section ("tramp")))
4016   external_dma_handler ();
4017 @end smallexample
4019 @item long_call
4020 @itemx short_call
4021 @cindex @code{long_call} function attribute, Epiphany
4022 @cindex @code{short_call} function attribute, Epiphany
4023 @cindex indirect calls, Epiphany
4024 These attributes specify how a particular function is called.
4025 These attributes override the
4026 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4027 command-line switch and @code{#pragma long_calls} settings.
4028 @end table
4031 @node H8/300 Function Attributes
4032 @subsection H8/300 Function Attributes
4034 These function attributes are available for H8/300 targets:
4036 @table @code
4037 @item function_vector
4038 @cindex @code{function_vector} function attribute, H8/300
4039 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4040 that the specified function should be called through the function vector.
4041 Calling a function through the function vector reduces code size; however,
4042 the function vector has a limited size (maximum 128 entries on the H8/300
4043 and 64 entries on the H8/300H and H8S)
4044 and shares space with the interrupt vector.
4046 @item interrupt_handler
4047 @cindex @code{interrupt_handler} function attribute, H8/300
4048 Use this attribute on the H8/300, H8/300H, and H8S to
4049 indicate that the specified function is an interrupt handler.  The compiler
4050 generates function entry and exit sequences suitable for use in an
4051 interrupt handler when this attribute is present.
4053 @item saveall
4054 @cindex @code{saveall} function attribute, H8/300
4055 @cindex save all registers on the H8/300, H8/300H, and H8S
4056 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4057 all registers except the stack pointer should be saved in the prologue
4058 regardless of whether they are used or not.
4059 @end table
4061 @node IA-64 Function Attributes
4062 @subsection IA-64 Function Attributes
4064 These function attributes are supported on IA-64 targets:
4066 @table @code
4067 @item syscall_linkage
4068 @cindex @code{syscall_linkage} function attribute, IA-64
4069 This attribute is used to modify the IA-64 calling convention by marking
4070 all input registers as live at all function exits.  This makes it possible
4071 to restart a system call after an interrupt without having to save/restore
4072 the input registers.  This also prevents kernel data from leaking into
4073 application code.
4075 @item version_id
4076 @cindex @code{version_id} function attribute, IA-64
4077 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4078 symbol to contain a version string, thus allowing for function level
4079 versioning.  HP-UX system header files may use function level versioning
4080 for some system calls.
4082 @smallexample
4083 extern int foo () __attribute__((version_id ("20040821")));
4084 @end smallexample
4086 @noindent
4087 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4088 @end table
4090 @node M32C Function Attributes
4091 @subsection M32C Function Attributes
4093 These function attributes are supported by the M32C back end:
4095 @table @code
4096 @item bank_switch
4097 @cindex @code{bank_switch} function attribute, M32C
4098 When added to an interrupt handler with the M32C port, causes the
4099 prologue and epilogue to use bank switching to preserve the registers
4100 rather than saving them on the stack.
4102 @item fast_interrupt
4103 @cindex @code{fast_interrupt} function attribute, M32C
4104 Use this attribute on the M32C port to indicate that the specified
4105 function is a fast interrupt handler.  This is just like the
4106 @code{interrupt} attribute, except that @code{freit} is used to return
4107 instead of @code{reit}.
4109 @item function_vector
4110 @cindex @code{function_vector} function attribute, M16C/M32C
4111 On M16C/M32C targets, the @code{function_vector} attribute declares a
4112 special page subroutine call function. Use of this attribute reduces
4113 the code size by 2 bytes for each call generated to the
4114 subroutine. The argument to the attribute is the vector number entry
4115 from the special page vector table which contains the 16 low-order
4116 bits of the subroutine's entry address. Each vector table has special
4117 page number (18 to 255) that is used in @code{jsrs} instructions.
4118 Jump addresses of the routines are generated by adding 0x0F0000 (in
4119 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4120 2-byte addresses set in the vector table. Therefore you need to ensure
4121 that all the special page vector routines should get mapped within the
4122 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4123 (for M32C).
4125 In the following example 2 bytes are saved for each call to
4126 function @code{foo}.
4128 @smallexample
4129 void foo (void) __attribute__((function_vector(0x18)));
4130 void foo (void)
4134 void bar (void)
4136     foo();
4138 @end smallexample
4140 If functions are defined in one file and are called in another file,
4141 then be sure to write this declaration in both files.
4143 This attribute is ignored for R8C target.
4145 @item interrupt
4146 @cindex @code{interrupt} function attribute, M32C
4147 Use this attribute to indicate
4148 that the specified function is an interrupt handler.  The compiler generates
4149 function entry and exit sequences suitable for use in an interrupt handler
4150 when this attribute is present.
4151 @end table
4153 @node M32R/D Function Attributes
4154 @subsection M32R/D Function Attributes
4156 These function attributes are supported by the M32R/D back end:
4158 @table @code
4159 @item interrupt
4160 @cindex @code{interrupt} function attribute, M32R/D
4161 Use this attribute to indicate
4162 that the specified function is an interrupt handler.  The compiler generates
4163 function entry and exit sequences suitable for use in an interrupt handler
4164 when this attribute is present.
4166 @item model (@var{model-name})
4167 @cindex @code{model} function attribute, M32R/D
4168 @cindex function addressability on the M32R/D
4170 On the M32R/D, use this attribute to set the addressability of an
4171 object, and of the code generated for a function.  The identifier
4172 @var{model-name} is one of @code{small}, @code{medium}, or
4173 @code{large}, representing each of the code models.
4175 Small model objects live in the lower 16MB of memory (so that their
4176 addresses can be loaded with the @code{ld24} instruction), and are
4177 callable with the @code{bl} instruction.
4179 Medium model objects may live anywhere in the 32-bit address space (the
4180 compiler generates @code{seth/add3} instructions to load their addresses),
4181 and are callable with the @code{bl} instruction.
4183 Large model objects may live anywhere in the 32-bit address space (the
4184 compiler generates @code{seth/add3} instructions to load their addresses),
4185 and may not be reachable with the @code{bl} instruction (the compiler
4186 generates the much slower @code{seth/add3/jl} instruction sequence).
4187 @end table
4189 @node m68k Function Attributes
4190 @subsection m68k Function Attributes
4192 These function attributes are supported by the m68k back end:
4194 @table @code
4195 @item interrupt
4196 @itemx interrupt_handler
4197 @cindex @code{interrupt} function attribute, m68k
4198 @cindex @code{interrupt_handler} function attribute, m68k
4199 Use this attribute to
4200 indicate that the specified function is an interrupt handler.  The compiler
4201 generates function entry and exit sequences suitable for use in an
4202 interrupt handler when this attribute is present.  Either name may be used.
4204 @item interrupt_thread
4205 @cindex @code{interrupt_thread} function attribute, fido
4206 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4207 that the specified function is an interrupt handler that is designed
4208 to run as a thread.  The compiler omits generate prologue/epilogue
4209 sequences and replaces the return instruction with a @code{sleep}
4210 instruction.  This attribute is available only on fido.
4211 @end table
4213 @node MCORE Function Attributes
4214 @subsection MCORE Function Attributes
4216 These function attributes are supported by the MCORE back end:
4218 @table @code
4219 @item naked
4220 @cindex @code{naked} function attribute, MCORE
4221 This attribute allows the compiler to construct the
4222 requisite function declaration, while allowing the body of the
4223 function to be assembly code. The specified function will not have
4224 prologue/epilogue sequences generated by the compiler. Only basic
4225 @code{asm} statements can safely be included in naked functions
4226 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4227 basic @code{asm} and C code may appear to work, they cannot be
4228 depended upon to work reliably and are not supported.
4229 @end table
4231 @node MeP Function Attributes
4232 @subsection MeP Function Attributes
4234 These function attributes are supported by the MeP back end:
4236 @table @code
4237 @item disinterrupt
4238 @cindex @code{disinterrupt} function attribute, MeP
4239 On MeP targets, this attribute causes the compiler to emit
4240 instructions to disable interrupts for the duration of the given
4241 function.
4243 @item interrupt
4244 @cindex @code{interrupt} function attribute, MeP
4245 Use this attribute to indicate
4246 that the specified function is an interrupt handler.  The compiler generates
4247 function entry and exit sequences suitable for use in an interrupt handler
4248 when this attribute is present.
4250 @item near
4251 @cindex @code{near} function attribute, MeP
4252 This attribute causes the compiler to assume the called
4253 function is close enough to use the normal calling convention,
4254 overriding the @option{-mtf} command-line option.
4256 @item far
4257 @cindex @code{far} function attribute, MeP
4258 On MeP targets this causes the compiler to use a calling convention
4259 that assumes the called function is too far away for the built-in
4260 addressing modes.
4262 @item vliw
4263 @cindex @code{vliw} function attribute, MeP
4264 The @code{vliw} attribute tells the compiler to emit
4265 instructions in VLIW mode instead of core mode.  Note that this
4266 attribute is not allowed unless a VLIW coprocessor has been configured
4267 and enabled through command-line options.
4268 @end table
4270 @node MicroBlaze Function Attributes
4271 @subsection MicroBlaze Function Attributes
4273 These function attributes are supported on MicroBlaze targets:
4275 @table @code
4276 @item save_volatiles
4277 @cindex @code{save_volatiles} function attribute, MicroBlaze
4278 Use this attribute to indicate that the function is
4279 an interrupt handler.  All volatile registers (in addition to non-volatile
4280 registers) are saved in the function prologue.  If the function is a leaf
4281 function, only volatiles used by the function are saved.  A normal function
4282 return is generated instead of a return from interrupt.
4284 @item break_handler
4285 @cindex @code{break_handler} function attribute, MicroBlaze
4286 @cindex break handler functions
4287 Use this attribute to indicate that
4288 the specified function is a break handler.  The compiler generates function
4289 entry and exit sequences suitable for use in an break handler when this
4290 attribute is present. The return from @code{break_handler} is done through
4291 the @code{rtbd} instead of @code{rtsd}.
4293 @smallexample
4294 void f () __attribute__ ((break_handler));
4295 @end smallexample
4297 @item interrupt_handler
4298 @itemx fast_interrupt 
4299 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4300 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4301 These attributes indicate that the specified function is an interrupt
4302 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4303 used in low-latency interrupt mode, and @code{interrupt_handler} for
4304 interrupts that do not use low-latency handlers.  In both cases, GCC
4305 emits appropriate prologue code and generates a return from the handler
4306 using @code{rtid} instead of @code{rtsd}.
4307 @end table
4309 @node Microsoft Windows Function Attributes
4310 @subsection Microsoft Windows Function Attributes
4312 The following attributes are available on Microsoft Windows and Symbian OS
4313 targets.
4315 @table @code
4316 @item dllexport
4317 @cindex @code{dllexport} function attribute
4318 @cindex @code{__declspec(dllexport)}
4319 On Microsoft Windows targets and Symbian OS targets the
4320 @code{dllexport} attribute causes the compiler to provide a global
4321 pointer to a pointer in a DLL, so that it can be referenced with the
4322 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4323 name is formed by combining @code{_imp__} and the function or variable
4324 name.
4326 You can use @code{__declspec(dllexport)} as a synonym for
4327 @code{__attribute__ ((dllexport))} for compatibility with other
4328 compilers.
4330 On systems that support the @code{visibility} attribute, this
4331 attribute also implies ``default'' visibility.  It is an error to
4332 explicitly specify any other visibility.
4334 GCC's default behavior is to emit all inline functions with the
4335 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4336 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4337 ignore the attribute for inlined functions unless the 
4338 @option{-fkeep-inline-functions} flag is used instead.
4340 The attribute is ignored for undefined symbols.
4342 When applied to C++ classes, the attribute marks defined non-inlined
4343 member functions and static data members as exports.  Static consts
4344 initialized in-class are not marked unless they are also defined
4345 out-of-class.
4347 For Microsoft Windows targets there are alternative methods for
4348 including the symbol in the DLL's export table such as using a
4349 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4350 the @option{--export-all} linker flag.
4352 @item dllimport
4353 @cindex @code{dllimport} function attribute
4354 @cindex @code{__declspec(dllimport)}
4355 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4356 attribute causes the compiler to reference a function or variable via
4357 a global pointer to a pointer that is set up by the DLL exporting the
4358 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4359 targets, the pointer name is formed by combining @code{_imp__} and the
4360 function or variable name.
4362 You can use @code{__declspec(dllimport)} as a synonym for
4363 @code{__attribute__ ((dllimport))} for compatibility with other
4364 compilers.
4366 On systems that support the @code{visibility} attribute, this
4367 attribute also implies ``default'' visibility.  It is an error to
4368 explicitly specify any other visibility.
4370 Currently, the attribute is ignored for inlined functions.  If the
4371 attribute is applied to a symbol @emph{definition}, an error is reported.
4372 If a symbol previously declared @code{dllimport} is later defined, the
4373 attribute is ignored in subsequent references, and a warning is emitted.
4374 The attribute is also overridden by a subsequent declaration as
4375 @code{dllexport}.
4377 When applied to C++ classes, the attribute marks non-inlined
4378 member functions and static data members as imports.  However, the
4379 attribute is ignored for virtual methods to allow creation of vtables
4380 using thunks.
4382 On the SH Symbian OS target the @code{dllimport} attribute also has
4383 another affect---it can cause the vtable and run-time type information
4384 for a class to be exported.  This happens when the class has a
4385 dllimported constructor or a non-inline, non-pure virtual function
4386 and, for either of those two conditions, the class also has an inline
4387 constructor or destructor and has a key function that is defined in
4388 the current translation unit.
4390 For Microsoft Windows targets the use of the @code{dllimport}
4391 attribute on functions is not necessary, but provides a small
4392 performance benefit by eliminating a thunk in the DLL@.  The use of the
4393 @code{dllimport} attribute on imported variables can be avoided by passing the
4394 @option{--enable-auto-import} switch to the GNU linker.  As with
4395 functions, using the attribute for a variable eliminates a thunk in
4396 the DLL@.
4398 One drawback to using this attribute is that a pointer to a
4399 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4400 address. However, a pointer to a @emph{function} with the
4401 @code{dllimport} attribute can be used as a constant initializer; in
4402 this case, the address of a stub function in the import lib is
4403 referenced.  On Microsoft Windows targets, the attribute can be disabled
4404 for functions by setting the @option{-mnop-fun-dllimport} flag.
4405 @end table
4407 @node MIPS Function Attributes
4408 @subsection MIPS Function Attributes
4410 These function attributes are supported by the MIPS back end:
4412 @table @code
4413 @item interrupt
4414 @cindex @code{interrupt} function attribute, MIPS
4415 Use this attribute to indicate that the specified function is an interrupt
4416 handler.  The compiler generates function entry and exit sequences suitable
4417 for use in an interrupt handler when this attribute is present.
4418 An optional argument is supported for the interrupt attribute which allows
4419 the interrupt mode to be described.  By default GCC assumes the external
4420 interrupt controller (EIC) mode is in use, this can be explicitly set using
4421 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4422 Priority Level (IPL) is copied to the current IPL which has the effect of only
4423 enabling higher priority interrupts.  To use vectored interrupt mode use
4424 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4425 the behavior of the non-masked interrupt support and GCC will arrange to mask
4426 all interrupts from sw0 up to and including the specified interrupt vector.
4428 You can use the following attributes to modify the behavior
4429 of an interrupt handler:
4430 @table @code
4431 @item use_shadow_register_set
4432 @cindex @code{use_shadow_register_set} function attribute, MIPS
4433 Assume that the handler uses a shadow register set, instead of
4434 the main general-purpose registers.  An optional argument @code{intstack} is
4435 supported to indicate that the shadow register set contains a valid stack
4436 pointer.
4438 @item keep_interrupts_masked
4439 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4440 Keep interrupts masked for the whole function.  Without this attribute,
4441 GCC tries to reenable interrupts for as much of the function as it can.
4443 @item use_debug_exception_return
4444 @cindex @code{use_debug_exception_return} function attribute, MIPS
4445 Return using the @code{deret} instruction.  Interrupt handlers that don't
4446 have this attribute return using @code{eret} instead.
4447 @end table
4449 You can use any combination of these attributes, as shown below:
4450 @smallexample
4451 void __attribute__ ((interrupt)) v0 ();
4452 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4453 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4454 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4455 void __attribute__ ((interrupt, use_shadow_register_set,
4456                      keep_interrupts_masked)) v4 ();
4457 void __attribute__ ((interrupt, use_shadow_register_set,
4458                      use_debug_exception_return)) v5 ();
4459 void __attribute__ ((interrupt, keep_interrupts_masked,
4460                      use_debug_exception_return)) v6 ();
4461 void __attribute__ ((interrupt, use_shadow_register_set,
4462                      keep_interrupts_masked,
4463                      use_debug_exception_return)) v7 ();
4464 void __attribute__ ((interrupt("eic"))) v8 ();
4465 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4466 @end smallexample
4468 @item long_call
4469 @itemx near
4470 @itemx far
4471 @cindex indirect calls, MIPS
4472 @cindex @code{long_call} function attribute, MIPS
4473 @cindex @code{near} function attribute, MIPS
4474 @cindex @code{far} function attribute, MIPS
4475 These attributes specify how a particular function is called on MIPS@.
4476 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4477 command-line switch.  The @code{long_call} and @code{far} attributes are
4478 synonyms, and cause the compiler to always call
4479 the function by first loading its address into a register, and then using
4480 the contents of that register.  The @code{near} attribute has the opposite
4481 effect; it specifies that non-PIC calls should be made using the more
4482 efficient @code{jal} instruction.
4484 @item mips16
4485 @itemx nomips16
4486 @cindex @code{mips16} function attribute, MIPS
4487 @cindex @code{nomips16} function attribute, MIPS
4489 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4490 function attributes to locally select or turn off MIPS16 code generation.
4491 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4492 while MIPS16 code generation is disabled for functions with the
4493 @code{nomips16} attribute.  These attributes override the
4494 @option{-mips16} and @option{-mno-mips16} options on the command line
4495 (@pxref{MIPS Options}).
4497 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4498 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4499 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4500 may interact badly with some GCC extensions such as @code{__builtin_apply}
4501 (@pxref{Constructing Calls}).
4503 @item micromips, MIPS
4504 @itemx nomicromips, MIPS
4505 @cindex @code{micromips} function attribute
4506 @cindex @code{nomicromips} function attribute
4508 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4509 function attributes to locally select or turn off microMIPS code generation.
4510 A function with the @code{micromips} attribute is emitted as microMIPS code,
4511 while microMIPS code generation is disabled for functions with the
4512 @code{nomicromips} attribute.  These attributes override the
4513 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4514 (@pxref{MIPS Options}).
4516 When compiling files containing mixed microMIPS and non-microMIPS code, the
4517 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4518 command line,
4519 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4520 may interact badly with some GCC extensions such as @code{__builtin_apply}
4521 (@pxref{Constructing Calls}).
4523 @item nocompression
4524 @cindex @code{nocompression} function attribute, MIPS
4525 On MIPS targets, you can use the @code{nocompression} function attribute
4526 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4527 overrides the @option{-mips16} and @option{-mmicromips} options on the
4528 command line (@pxref{MIPS Options}).
4529 @end table
4531 @node MSP430 Function Attributes
4532 @subsection MSP430 Function Attributes
4534 These function attributes are supported by the MSP430 back end:
4536 @table @code
4537 @item critical
4538 @cindex @code{critical} function attribute, MSP430
4539 Critical functions disable interrupts upon entry and restore the
4540 previous interrupt state upon exit.  Critical functions cannot also
4541 have the @code{naked} or @code{reentrant} attributes.  They can have
4542 the @code{interrupt} attribute.
4544 @item interrupt
4545 @cindex @code{interrupt} function attribute, MSP430
4546 Use this attribute to indicate
4547 that the specified function is an interrupt handler.  The compiler generates
4548 function entry and exit sequences suitable for use in an interrupt handler
4549 when this attribute is present.
4551 You can provide an argument to the interrupt
4552 attribute which specifies a name or number.  If the argument is a
4553 number it indicates the slot in the interrupt vector table (0 - 31) to
4554 which this handler should be assigned.  If the argument is a name it
4555 is treated as a symbolic name for the vector slot.  These names should
4556 match up with appropriate entries in the linker script.  By default
4557 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4558 @code{reset} for vector 31 are recognized.
4560 @item naked
4561 @cindex @code{naked} function attribute, MSP430
4562 This attribute allows the compiler to construct the
4563 requisite function declaration, while allowing the body of the
4564 function to be assembly code. The specified function will not have
4565 prologue/epilogue sequences generated by the compiler. Only basic
4566 @code{asm} statements can safely be included in naked functions
4567 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4568 basic @code{asm} and C code may appear to work, they cannot be
4569 depended upon to work reliably and are not supported.
4571 @item reentrant
4572 @cindex @code{reentrant} function attribute, MSP430
4573 Reentrant functions disable interrupts upon entry and enable them
4574 upon exit.  Reentrant functions cannot also have the @code{naked}
4575 or @code{critical} attributes.  They can have the @code{interrupt}
4576 attribute.
4578 @item wakeup
4579 @cindex @code{wakeup} function attribute, MSP430
4580 This attribute only applies to interrupt functions.  It is silently
4581 ignored if applied to a non-interrupt function.  A wakeup interrupt
4582 function will rouse the processor from any low-power state that it
4583 might be in when the function exits.
4585 @item lower
4586 @itemx upper
4587 @itemx either
4588 @cindex @code{lower} function attribute, MSP430
4589 @cindex @code{upper} function attribute, MSP430
4590 @cindex @code{either} function attribute, MSP430
4591 On the MSP430 target these attributes can be used to specify whether
4592 the function or variable should be placed into low memory, high
4593 memory, or the placement should be left to the linker to decide.  The
4594 attributes are only significant if compiling for the MSP430X
4595 architecture.
4597 The attributes work in conjunction with a linker script that has been
4598 augmented to specify where to place sections with a @code{.lower} and
4599 a @code{.upper} prefix.  So, for example, as well as placing the
4600 @code{.data} section, the script also specifies the placement of a
4601 @code{.lower.data} and a @code{.upper.data} section.  The intention
4602 is that @code{lower} sections are placed into a small but easier to
4603 access memory region and the upper sections are placed into a larger, but
4604 slower to access, region.
4606 The @code{either} attribute is special.  It tells the linker to place
4607 the object into the corresponding @code{lower} section if there is
4608 room for it.  If there is insufficient room then the object is placed
4609 into the corresponding @code{upper} section instead.  Note that the
4610 placement algorithm is not very sophisticated.  It does not attempt to
4611 find an optimal packing of the @code{lower} sections.  It just makes
4612 one pass over the objects and does the best that it can.  Using the
4613 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4614 options can help the packing, however, since they produce smaller,
4615 easier to pack regions.
4616 @end table
4618 @node NDS32 Function Attributes
4619 @subsection NDS32 Function Attributes
4621 These function attributes are supported by the NDS32 back end:
4623 @table @code
4624 @item exception
4625 @cindex @code{exception} function attribute
4626 @cindex exception handler functions, NDS32
4627 Use this attribute on the NDS32 target to indicate that the specified function
4628 is an exception handler.  The compiler will generate corresponding sections
4629 for use in an exception handler.
4631 @item interrupt
4632 @cindex @code{interrupt} function attribute, NDS32
4633 On NDS32 target, this attribute indicates that the specified function
4634 is an interrupt handler.  The compiler generates corresponding sections
4635 for use in an interrupt handler.  You can use the following attributes
4636 to modify the behavior:
4637 @table @code
4638 @item nested
4639 @cindex @code{nested} function attribute, NDS32
4640 This interrupt service routine is interruptible.
4641 @item not_nested
4642 @cindex @code{not_nested} function attribute, NDS32
4643 This interrupt service routine is not interruptible.
4644 @item nested_ready
4645 @cindex @code{nested_ready} function attribute, NDS32
4646 This interrupt service routine is interruptible after @code{PSW.GIE}
4647 (global interrupt enable) is set.  This allows interrupt service routine to
4648 finish some short critical code before enabling interrupts.
4649 @item save_all
4650 @cindex @code{save_all} function attribute, NDS32
4651 The system will help save all registers into stack before entering
4652 interrupt handler.
4653 @item partial_save
4654 @cindex @code{partial_save} function attribute, NDS32
4655 The system will help save caller registers into stack before entering
4656 interrupt handler.
4657 @end table
4659 @item naked
4660 @cindex @code{naked} function attribute, NDS32
4661 This attribute allows the compiler to construct the
4662 requisite function declaration, while allowing the body of the
4663 function to be assembly code. The specified function will not have
4664 prologue/epilogue sequences generated by the compiler. Only basic
4665 @code{asm} statements can safely be included in naked functions
4666 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4667 basic @code{asm} and C code may appear to work, they cannot be
4668 depended upon to work reliably and are not supported.
4670 @item reset
4671 @cindex @code{reset} function attribute, NDS32
4672 @cindex reset handler functions
4673 Use this attribute on the NDS32 target to indicate that the specified function
4674 is a reset handler.  The compiler will generate corresponding sections
4675 for use in a reset handler.  You can use the following attributes
4676 to provide extra exception handling:
4677 @table @code
4678 @item nmi
4679 @cindex @code{nmi} function attribute, NDS32
4680 Provide a user-defined function to handle NMI exception.
4681 @item warm
4682 @cindex @code{warm} function attribute, NDS32
4683 Provide a user-defined function to handle warm reset exception.
4684 @end table
4685 @end table
4687 @node Nios II Function Attributes
4688 @subsection Nios II Function Attributes
4690 These function attributes are supported by the Nios II back end:
4692 @table @code
4693 @item target (@var{options})
4694 @cindex @code{target} function attribute
4695 As discussed in @ref{Common Function Attributes}, this attribute 
4696 allows specification of target-specific compilation options.
4698 When compiling for Nios II, the following options are allowed:
4700 @table @samp
4701 @item custom-@var{insn}=@var{N}
4702 @itemx no-custom-@var{insn}
4703 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4704 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4705 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4706 custom instruction with encoding @var{N} when generating code that uses 
4707 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4708 the custom instruction @var{insn}.
4709 These target attributes correspond to the
4710 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4711 command-line options, and support the same set of @var{insn} keywords.
4712 @xref{Nios II Options}, for more information.
4714 @item custom-fpu-cfg=@var{name}
4715 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4716 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4717 command-line option, to select a predefined set of custom instructions
4718 named @var{name}.
4719 @xref{Nios II Options}, for more information.
4720 @end table
4721 @end table
4723 @node Nvidia PTX Function Attributes
4724 @subsection Nvidia PTX Function Attributes
4726 These function attributes are supported by the Nvidia PTX back end:
4728 @table @code
4729 @item kernel
4730 @cindex @code{kernel} attribute, Nvidia PTX
4731 This attribute indicates that the corresponding function should be compiled
4732 as a kernel function, which can be invoked from the host via the CUDA RT 
4733 library.
4734 By default functions are only callable only from other PTX functions.
4736 Kernel functions must have @code{void} return type.
4737 @end table
4739 @node PowerPC Function Attributes
4740 @subsection PowerPC Function Attributes
4742 These function attributes are supported by the PowerPC back end:
4744 @table @code
4745 @item longcall
4746 @itemx shortcall
4747 @cindex indirect calls, PowerPC
4748 @cindex @code{longcall} function attribute, PowerPC
4749 @cindex @code{shortcall} function attribute, PowerPC
4750 The @code{longcall} attribute
4751 indicates that the function might be far away from the call site and
4752 require a different (more expensive) calling sequence.  The
4753 @code{shortcall} attribute indicates that the function is always close
4754 enough for the shorter calling sequence to be used.  These attributes
4755 override both the @option{-mlongcall} switch and
4756 the @code{#pragma longcall} setting.
4758 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4759 calls are necessary.
4761 @item target (@var{options})
4762 @cindex @code{target} function attribute
4763 As discussed in @ref{Common Function Attributes}, this attribute 
4764 allows specification of target-specific compilation options.
4766 On the PowerPC, the following options are allowed:
4768 @table @samp
4769 @item altivec
4770 @itemx no-altivec
4771 @cindex @code{target("altivec")} function attribute, PowerPC
4772 Generate code that uses (does not use) AltiVec instructions.  In
4773 32-bit code, you cannot enable AltiVec instructions unless
4774 @option{-mabi=altivec} is used on the command line.
4776 @item cmpb
4777 @itemx no-cmpb
4778 @cindex @code{target("cmpb")} function attribute, PowerPC
4779 Generate code that uses (does not use) the compare bytes instruction
4780 implemented on the POWER6 processor and other processors that support
4781 the PowerPC V2.05 architecture.
4783 @item dlmzb
4784 @itemx no-dlmzb
4785 @cindex @code{target("dlmzb")} function attribute, PowerPC
4786 Generate code that uses (does not use) the string-search @samp{dlmzb}
4787 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4788 generated by default when targeting those processors.
4790 @item fprnd
4791 @itemx no-fprnd
4792 @cindex @code{target("fprnd")} function attribute, PowerPC
4793 Generate code that uses (does not use) the FP round to integer
4794 instructions implemented on the POWER5+ processor and other processors
4795 that support the PowerPC V2.03 architecture.
4797 @item hard-dfp
4798 @itemx no-hard-dfp
4799 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4800 Generate code that uses (does not use) the decimal floating-point
4801 instructions implemented on some POWER processors.
4803 @item isel
4804 @itemx no-isel
4805 @cindex @code{target("isel")} function attribute, PowerPC
4806 Generate code that uses (does not use) ISEL instruction.
4808 @item mfcrf
4809 @itemx no-mfcrf
4810 @cindex @code{target("mfcrf")} function attribute, PowerPC
4811 Generate code that uses (does not use) the move from condition
4812 register field instruction implemented on the POWER4 processor and
4813 other processors that support the PowerPC V2.01 architecture.
4815 @item mfpgpr
4816 @itemx no-mfpgpr
4817 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4818 Generate code that uses (does not use) the FP move to/from general
4819 purpose register instructions implemented on the POWER6X processor and
4820 other processors that support the extended PowerPC V2.05 architecture.
4822 @item mulhw
4823 @itemx no-mulhw
4824 @cindex @code{target("mulhw")} function attribute, PowerPC
4825 Generate code that uses (does not use) the half-word multiply and
4826 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4827 These instructions are generated by default when targeting those
4828 processors.
4830 @item multiple
4831 @itemx no-multiple
4832 @cindex @code{target("multiple")} function attribute, PowerPC
4833 Generate code that uses (does not use) the load multiple word
4834 instructions and the store multiple word instructions.
4836 @item update
4837 @itemx no-update
4838 @cindex @code{target("update")} function attribute, PowerPC
4839 Generate code that uses (does not use) the load or store instructions
4840 that update the base register to the address of the calculated memory
4841 location.
4843 @item popcntb
4844 @itemx no-popcntb
4845 @cindex @code{target("popcntb")} function attribute, PowerPC
4846 Generate code that uses (does not use) the popcount and double-precision
4847 FP reciprocal estimate instruction implemented on the POWER5
4848 processor and other processors that support the PowerPC V2.02
4849 architecture.
4851 @item popcntd
4852 @itemx no-popcntd
4853 @cindex @code{target("popcntd")} function attribute, PowerPC
4854 Generate code that uses (does not use) the popcount instruction
4855 implemented on the POWER7 processor and other processors that support
4856 the PowerPC V2.06 architecture.
4858 @item powerpc-gfxopt
4859 @itemx no-powerpc-gfxopt
4860 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4861 Generate code that uses (does not use) the optional PowerPC
4862 architecture instructions in the Graphics group, including
4863 floating-point select.
4865 @item powerpc-gpopt
4866 @itemx no-powerpc-gpopt
4867 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4868 Generate code that uses (does not use) the optional PowerPC
4869 architecture instructions in the General Purpose group, including
4870 floating-point square root.
4872 @item recip-precision
4873 @itemx no-recip-precision
4874 @cindex @code{target("recip-precision")} function attribute, PowerPC
4875 Assume (do not assume) that the reciprocal estimate instructions
4876 provide higher-precision estimates than is mandated by the PowerPC
4877 ABI.
4879 @item string
4880 @itemx no-string
4881 @cindex @code{target("string")} function attribute, PowerPC
4882 Generate code that uses (does not use) the load string instructions
4883 and the store string word instructions to save multiple registers and
4884 do small block moves.
4886 @item vsx
4887 @itemx no-vsx
4888 @cindex @code{target("vsx")} function attribute, PowerPC
4889 Generate code that uses (does not use) vector/scalar (VSX)
4890 instructions, and also enable the use of built-in functions that allow
4891 more direct access to the VSX instruction set.  In 32-bit code, you
4892 cannot enable VSX or AltiVec instructions unless
4893 @option{-mabi=altivec} is used on the command line.
4895 @item friz
4896 @itemx no-friz
4897 @cindex @code{target("friz")} function attribute, PowerPC
4898 Generate (do not generate) the @code{friz} instruction when the
4899 @option{-funsafe-math-optimizations} option is used to optimize
4900 rounding a floating-point value to 64-bit integer and back to floating
4901 point.  The @code{friz} instruction does not return the same value if
4902 the floating-point number is too large to fit in an integer.
4904 @item avoid-indexed-addresses
4905 @itemx no-avoid-indexed-addresses
4906 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4907 Generate code that tries to avoid (not avoid) the use of indexed load
4908 or store instructions.
4910 @item paired
4911 @itemx no-paired
4912 @cindex @code{target("paired")} function attribute, PowerPC
4913 Generate code that uses (does not use) the generation of PAIRED simd
4914 instructions.
4916 @item longcall
4917 @itemx no-longcall
4918 @cindex @code{target("longcall")} function attribute, PowerPC
4919 Generate code that assumes (does not assume) that all calls are far
4920 away so that a longer more expensive calling sequence is required.
4922 @item cpu=@var{CPU}
4923 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4924 Specify the architecture to generate code for when compiling the
4925 function.  If you select the @code{target("cpu=power7")} attribute when
4926 generating 32-bit code, VSX and AltiVec instructions are not generated
4927 unless you use the @option{-mabi=altivec} option on the command line.
4929 @item tune=@var{TUNE}
4930 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4931 Specify the architecture to tune for when compiling the function.  If
4932 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4933 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4934 compilation tunes for the @var{CPU} architecture, and not the
4935 default tuning specified on the command line.
4936 @end table
4938 On the PowerPC, the inliner does not inline a
4939 function that has different target options than the caller, unless the
4940 callee has a subset of the target options of the caller.
4941 @end table
4943 @node RL78 Function Attributes
4944 @subsection RL78 Function Attributes
4946 These function attributes are supported by the RL78 back end:
4948 @table @code
4949 @item interrupt
4950 @itemx brk_interrupt
4951 @cindex @code{interrupt} function attribute, RL78
4952 @cindex @code{brk_interrupt} function attribute, RL78
4953 These attributes indicate
4954 that the specified function is an interrupt handler.  The compiler generates
4955 function entry and exit sequences suitable for use in an interrupt handler
4956 when this attribute is present.
4958 Use @code{brk_interrupt} instead of @code{interrupt} for
4959 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4960 that must end with @code{RETB} instead of @code{RETI}).
4962 @item naked
4963 @cindex @code{naked} function attribute, RL78
4964 This attribute allows the compiler to construct the
4965 requisite function declaration, while allowing the body of the
4966 function to be assembly code. The specified function will not have
4967 prologue/epilogue sequences generated by the compiler. Only basic
4968 @code{asm} statements can safely be included in naked functions
4969 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4970 basic @code{asm} and C code may appear to work, they cannot be
4971 depended upon to work reliably and are not supported.
4972 @end table
4974 @node RX Function Attributes
4975 @subsection RX Function Attributes
4977 These function attributes are supported by the RX back end:
4979 @table @code
4980 @item fast_interrupt
4981 @cindex @code{fast_interrupt} function attribute, RX
4982 Use this attribute on the RX port to indicate that the specified
4983 function is a fast interrupt handler.  This is just like the
4984 @code{interrupt} attribute, except that @code{freit} is used to return
4985 instead of @code{reit}.
4987 @item interrupt
4988 @cindex @code{interrupt} function attribute, RX
4989 Use this attribute to indicate
4990 that the specified function is an interrupt handler.  The compiler generates
4991 function entry and exit sequences suitable for use in an interrupt handler
4992 when this attribute is present.
4994 On RX targets, you may specify one or more vector numbers as arguments
4995 to the attribute, as well as naming an alternate table name.
4996 Parameters are handled sequentially, so one handler can be assigned to
4997 multiple entries in multiple tables.  One may also pass the magic
4998 string @code{"$default"} which causes the function to be used for any
4999 unfilled slots in the current table.
5001 This example shows a simple assignment of a function to one vector in
5002 the default table (note that preprocessor macros may be used for
5003 chip-specific symbolic vector names):
5004 @smallexample
5005 void __attribute__ ((interrupt (5))) txd1_handler ();
5006 @end smallexample
5008 This example assigns a function to two slots in the default table
5009 (using preprocessor macros defined elsewhere) and makes it the default
5010 for the @code{dct} table:
5011 @smallexample
5012 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5013         txd1_handler ();
5014 @end smallexample
5016 @item naked
5017 @cindex @code{naked} function attribute, RX
5018 This attribute allows the compiler to construct the
5019 requisite function declaration, while allowing the body of the
5020 function to be assembly code. The specified function will not have
5021 prologue/epilogue sequences generated by the compiler. Only basic
5022 @code{asm} statements can safely be included in naked functions
5023 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5024 basic @code{asm} and C code may appear to work, they cannot be
5025 depended upon to work reliably and are not supported.
5027 @item vector
5028 @cindex @code{vector} function attribute, RX
5029 This RX attribute is similar to the @code{interrupt} attribute, including its
5030 parameters, but does not make the function an interrupt-handler type
5031 function (i.e. it retains the normal C function calling ABI).  See the
5032 @code{interrupt} attribute for a description of its arguments.
5033 @end table
5035 @node S/390 Function Attributes
5036 @subsection S/390 Function Attributes
5038 These function attributes are supported on the S/390:
5040 @table @code
5041 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5042 @cindex @code{hotpatch} function attribute, S/390
5044 On S/390 System z targets, you can use this function attribute to
5045 make GCC generate a ``hot-patching'' function prologue.  If the
5046 @option{-mhotpatch=} command-line option is used at the same time,
5047 the @code{hotpatch} attribute takes precedence.  The first of the
5048 two arguments specifies the number of halfwords to be added before
5049 the function label.  A second argument can be used to specify the
5050 number of halfwords to be added after the function label.  For
5051 both arguments the maximum allowed value is 1000000.
5053 If both arguments are zero, hotpatching is disabled.
5055 @item target (@var{options})
5056 @cindex @code{target} function attribute
5057 As discussed in @ref{Common Function Attributes}, this attribute
5058 allows specification of target-specific compilation options.
5060 On S/390, the following options are supported:
5062 @table @samp
5063 @item arch=
5064 @item tune=
5065 @item stack-guard=
5066 @item stack-size=
5067 @item branch-cost=
5068 @item warn-framesize=
5069 @item backchain
5070 @itemx no-backchain
5071 @item hard-dfp
5072 @itemx no-hard-dfp
5073 @item hard-float
5074 @itemx soft-float
5075 @item htm
5076 @itemx no-htm
5077 @item vx
5078 @itemx no-vx
5079 @item packed-stack
5080 @itemx no-packed-stack
5081 @item small-exec
5082 @itemx no-small-exec
5083 @item mvcle
5084 @itemx no-mvcle
5085 @item warn-dynamicstack
5086 @itemx no-warn-dynamicstack
5087 @end table
5089 The options work exactly like the S/390 specific command line
5090 options (without the prefix @option{-m}) except that they do not
5091 change any feature macros.  For example,
5093 @smallexample
5094 @code{target("no-vx")}
5095 @end smallexample
5097 does not undefine the @code{__VEC__} macro.
5098 @end table
5100 @node SH Function Attributes
5101 @subsection SH Function Attributes
5103 These function attributes are supported on the SH family of processors:
5105 @table @code
5106 @item function_vector
5107 @cindex @code{function_vector} function attribute, SH
5108 @cindex calling functions through the function vector on SH2A
5109 On SH2A targets, this attribute declares a function to be called using the
5110 TBR relative addressing mode.  The argument to this attribute is the entry
5111 number of the same function in a vector table containing all the TBR
5112 relative addressable functions.  For correct operation the TBR must be setup
5113 accordingly to point to the start of the vector table before any functions with
5114 this attribute are invoked.  Usually a good place to do the initialization is
5115 the startup routine.  The TBR relative vector table can have at max 256 function
5116 entries.  The jumps to these functions are generated using a SH2A specific,
5117 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5118 from GNU binutils version 2.7 or later for this attribute to work correctly.
5120 In an application, for a function being called once, this attribute
5121 saves at least 8 bytes of code; and if other successive calls are being
5122 made to the same function, it saves 2 bytes of code per each of these
5123 calls.
5125 @item interrupt_handler
5126 @cindex @code{interrupt_handler} function attribute, SH
5127 Use this attribute to
5128 indicate that the specified function is an interrupt handler.  The compiler
5129 generates function entry and exit sequences suitable for use in an
5130 interrupt handler when this attribute is present.
5132 @item nosave_low_regs
5133 @cindex @code{nosave_low_regs} function attribute, SH
5134 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5135 function should not save and restore registers R0..R7.  This can be used on SH3*
5136 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5137 interrupt handlers.
5139 @item renesas
5140 @cindex @code{renesas} function attribute, SH
5141 On SH targets this attribute specifies that the function or struct follows the
5142 Renesas ABI.
5144 @item resbank
5145 @cindex @code{resbank} function attribute, SH
5146 On the SH2A target, this attribute enables the high-speed register
5147 saving and restoration using a register bank for @code{interrupt_handler}
5148 routines.  Saving to the bank is performed automatically after the CPU
5149 accepts an interrupt that uses a register bank.
5151 The nineteen 32-bit registers comprising general register R0 to R14,
5152 control register GBR, and system registers MACH, MACL, and PR and the
5153 vector table address offset are saved into a register bank.  Register
5154 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5155 from the bank is executed by issuing a RESBANK instruction.
5157 @item sp_switch
5158 @cindex @code{sp_switch} function attribute, SH
5159 Use this attribute on the SH to indicate an @code{interrupt_handler}
5160 function should switch to an alternate stack.  It expects a string
5161 argument that names a global variable holding the address of the
5162 alternate stack.
5164 @smallexample
5165 void *alt_stack;
5166 void f () __attribute__ ((interrupt_handler,
5167                           sp_switch ("alt_stack")));
5168 @end smallexample
5170 @item trap_exit
5171 @cindex @code{trap_exit} function attribute, SH
5172 Use this attribute on the SH for an @code{interrupt_handler} to return using
5173 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5174 argument specifying the trap number to be used.
5176 @item trapa_handler
5177 @cindex @code{trapa_handler} function attribute, SH
5178 On SH targets this function attribute is similar to @code{interrupt_handler}
5179 but it does not save and restore all registers.
5180 @end table
5182 @node SPU Function Attributes
5183 @subsection SPU Function Attributes
5185 These function attributes are supported by the SPU back end:
5187 @table @code
5188 @item naked
5189 @cindex @code{naked} function attribute, SPU
5190 This attribute allows the compiler to construct the
5191 requisite function declaration, while allowing the body of the
5192 function to be assembly code. The specified function will not have
5193 prologue/epilogue sequences generated by the compiler. Only basic
5194 @code{asm} statements can safely be included in naked functions
5195 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5196 basic @code{asm} and C code may appear to work, they cannot be
5197 depended upon to work reliably and are not supported.
5198 @end table
5200 @node Symbian OS Function Attributes
5201 @subsection Symbian OS Function Attributes
5203 @xref{Microsoft Windows Function Attributes}, for discussion of the
5204 @code{dllexport} and @code{dllimport} attributes.
5206 @node V850 Function Attributes
5207 @subsection V850 Function Attributes
5209 The V850 back end supports these function attributes:
5211 @table @code
5212 @item interrupt
5213 @itemx interrupt_handler
5214 @cindex @code{interrupt} function attribute, V850
5215 @cindex @code{interrupt_handler} function attribute, V850
5216 Use these attributes to indicate
5217 that the specified function is an interrupt handler.  The compiler generates
5218 function entry and exit sequences suitable for use in an interrupt handler
5219 when either attribute is present.
5220 @end table
5222 @node Visium Function Attributes
5223 @subsection Visium Function Attributes
5225 These function attributes are supported by the Visium back end:
5227 @table @code
5228 @item interrupt
5229 @cindex @code{interrupt} function attribute, Visium
5230 Use this attribute to indicate
5231 that the specified function is an interrupt handler.  The compiler generates
5232 function entry and exit sequences suitable for use in an interrupt handler
5233 when this attribute is present.
5234 @end table
5236 @node x86 Function Attributes
5237 @subsection x86 Function Attributes
5239 These function attributes are supported by the x86 back end:
5241 @table @code
5242 @item cdecl
5243 @cindex @code{cdecl} function attribute, x86-32
5244 @cindex functions that pop the argument stack on x86-32
5245 @opindex mrtd
5246 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5247 assume that the calling function pops off the stack space used to
5248 pass arguments.  This is
5249 useful to override the effects of the @option{-mrtd} switch.
5251 @item fastcall
5252 @cindex @code{fastcall} function attribute, x86-32
5253 @cindex functions that pop the argument stack on x86-32
5254 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5255 pass the first argument (if of integral type) in the register ECX and
5256 the second argument (if of integral type) in the register EDX@.  Subsequent
5257 and other typed arguments are passed on the stack.  The called function
5258 pops the arguments off the stack.  If the number of arguments is variable all
5259 arguments are pushed on the stack.
5261 @item thiscall
5262 @cindex @code{thiscall} function attribute, x86-32
5263 @cindex functions that pop the argument stack on x86-32
5264 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5265 pass the first argument (if of integral type) in the register ECX.
5266 Subsequent and other typed arguments are passed on the stack. The called
5267 function pops the arguments off the stack.
5268 If the number of arguments is variable all arguments are pushed on the
5269 stack.
5270 The @code{thiscall} attribute is intended for C++ non-static member functions.
5271 As a GCC extension, this calling convention can be used for C functions
5272 and for static member methods.
5274 @item ms_abi
5275 @itemx sysv_abi
5276 @cindex @code{ms_abi} function attribute, x86
5277 @cindex @code{sysv_abi} function attribute, x86
5279 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5280 to indicate which calling convention should be used for a function.  The
5281 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5282 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5283 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5284 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5286 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5287 requires the @option{-maccumulate-outgoing-args} option.
5289 @item callee_pop_aggregate_return (@var{number})
5290 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5292 On x86-32 targets, you can use this attribute to control how
5293 aggregates are returned in memory.  If the caller is responsible for
5294 popping the hidden pointer together with the rest of the arguments, specify
5295 @var{number} equal to zero.  If callee is responsible for popping the
5296 hidden pointer, specify @var{number} equal to one.  
5298 The default x86-32 ABI assumes that the callee pops the
5299 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5300 the compiler assumes that the
5301 caller pops the stack for hidden pointer.
5303 @item ms_hook_prologue
5304 @cindex @code{ms_hook_prologue} function attribute, x86
5306 On 32-bit and 64-bit x86 targets, you can use
5307 this function attribute to make GCC generate the ``hot-patching'' function
5308 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5309 and newer.
5311 @item regparm (@var{number})
5312 @cindex @code{regparm} function attribute, x86
5313 @cindex functions that are passed arguments in registers on x86-32
5314 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5315 pass arguments number one to @var{number} if they are of integral type
5316 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5317 take a variable number of arguments continue to be passed all of their
5318 arguments on the stack.
5320 Beware that on some ELF systems this attribute is unsuitable for
5321 global functions in shared libraries with lazy binding (which is the
5322 default).  Lazy binding sends the first call via resolving code in
5323 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5324 per the standard calling conventions.  Solaris 8 is affected by this.
5325 Systems with the GNU C Library version 2.1 or higher
5326 and FreeBSD are believed to be
5327 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5328 disabled with the linker or the loader if desired, to avoid the
5329 problem.)
5331 @item sseregparm
5332 @cindex @code{sseregparm} function attribute, x86
5333 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5334 causes the compiler to pass up to 3 floating-point arguments in
5335 SSE registers instead of on the stack.  Functions that take a
5336 variable number of arguments continue to pass all of their
5337 floating-point arguments on the stack.
5339 @item force_align_arg_pointer
5340 @cindex @code{force_align_arg_pointer} function attribute, x86
5341 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5342 applied to individual function definitions, generating an alternate
5343 prologue and epilogue that realigns the run-time stack if necessary.
5344 This supports mixing legacy codes that run with a 4-byte aligned stack
5345 with modern codes that keep a 16-byte stack for SSE compatibility.
5347 @item stdcall
5348 @cindex @code{stdcall} function attribute, x86-32
5349 @cindex functions that pop the argument stack on x86-32
5350 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5351 assume that the called function pops off the stack space used to
5352 pass arguments, unless it takes a variable number of arguments.
5354 @item no_caller_saved_registers
5355 @cindex @code{no_caller_saved_registers} function attribute, x86
5356 Use this attribute to indicate that the specified function has no
5357 caller-saved registers. That is, all registers are callee-saved. For
5358 example, this attribute can be used for a function called from an
5359 interrupt handler. The compiler generates proper function entry and
5360 exit sequences to save and restore any modified registers, except for
5361 the EFLAGS register.  Since GCC doesn't preserve MPX, SSE, MMX nor x87
5362 states, the GCC option @option{-mgeneral-regs-only} should be used to
5363 compile functions with @code{no_caller_saved_registers} attribute.
5365 @item interrupt
5366 @cindex @code{interrupt} function attribute, x86
5367 Use this attribute to indicate that the specified function is an
5368 interrupt handler or an exception handler (depending on parameters passed
5369 to the function, explained further).  The compiler generates function
5370 entry and exit sequences suitable for use in an interrupt handler when
5371 this attribute is present.  The @code{IRET} instruction, instead of the
5372 @code{RET} instruction, is used to return from interrupt handlers.  All
5373 registers, except for the EFLAGS register which is restored by the
5374 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5375 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5376 @option{-mgeneral-regs-only} should be used to compile interrupt and
5377 exception handlers.
5379 Any interruptible-without-stack-switch code must be compiled with
5380 @option{-mno-red-zone} since interrupt handlers can and will, because
5381 of the hardware design, touch the red zone.
5383 An interrupt handler must be declared with a mandatory pointer
5384 argument:
5386 @smallexample
5387 struct interrupt_frame;
5389 __attribute__ ((interrupt))
5390 void
5391 f (struct interrupt_frame *frame)
5394 @end smallexample
5396 @noindent
5397 and you must define @code{struct interrupt_frame} as described in the
5398 processor's manual.
5400 Exception handlers differ from interrupt handlers because the system
5401 pushes an error code on the stack.  An exception handler declaration is
5402 similar to that for an interrupt handler, but with a different mandatory
5403 function signature.  The compiler arranges to pop the error code off the
5404 stack before the @code{IRET} instruction.
5406 @smallexample
5407 #ifdef __x86_64__
5408 typedef unsigned long long int uword_t;
5409 #else
5410 typedef unsigned int uword_t;
5411 #endif
5413 struct interrupt_frame;
5415 __attribute__ ((interrupt))
5416 void
5417 f (struct interrupt_frame *frame, uword_t error_code)
5419   ...
5421 @end smallexample
5423 Exception handlers should only be used for exceptions that push an error
5424 code; you should use an interrupt handler in other cases.  The system
5425 will crash if the wrong kind of handler is used.
5427 @item target (@var{options})
5428 @cindex @code{target} function attribute
5429 As discussed in @ref{Common Function Attributes}, this attribute 
5430 allows specification of target-specific compilation options.
5432 On the x86, the following options are allowed:
5433 @table @samp
5434 @item abm
5435 @itemx no-abm
5436 @cindex @code{target("abm")} function attribute, x86
5437 Enable/disable the generation of the advanced bit instructions.
5439 @item aes
5440 @itemx no-aes
5441 @cindex @code{target("aes")} function attribute, x86
5442 Enable/disable the generation of the AES instructions.
5444 @item default
5445 @cindex @code{target("default")} function attribute, x86
5446 @xref{Function Multiversioning}, where it is used to specify the
5447 default function version.
5449 @item mmx
5450 @itemx no-mmx
5451 @cindex @code{target("mmx")} function attribute, x86
5452 Enable/disable the generation of the MMX instructions.
5454 @item pclmul
5455 @itemx no-pclmul
5456 @cindex @code{target("pclmul")} function attribute, x86
5457 Enable/disable the generation of the PCLMUL instructions.
5459 @item popcnt
5460 @itemx no-popcnt
5461 @cindex @code{target("popcnt")} function attribute, x86
5462 Enable/disable the generation of the POPCNT instruction.
5464 @item sse
5465 @itemx no-sse
5466 @cindex @code{target("sse")} function attribute, x86
5467 Enable/disable the generation of the SSE instructions.
5469 @item sse2
5470 @itemx no-sse2
5471 @cindex @code{target("sse2")} function attribute, x86
5472 Enable/disable the generation of the SSE2 instructions.
5474 @item sse3
5475 @itemx no-sse3
5476 @cindex @code{target("sse3")} function attribute, x86
5477 Enable/disable the generation of the SSE3 instructions.
5479 @item sse4
5480 @itemx no-sse4
5481 @cindex @code{target("sse4")} function attribute, x86
5482 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5483 and SSE4.2).
5485 @item sse4.1
5486 @itemx no-sse4.1
5487 @cindex @code{target("sse4.1")} function attribute, x86
5488 Enable/disable the generation of the sse4.1 instructions.
5490 @item sse4.2
5491 @itemx no-sse4.2
5492 @cindex @code{target("sse4.2")} function attribute, x86
5493 Enable/disable the generation of the sse4.2 instructions.
5495 @item sse4a
5496 @itemx no-sse4a
5497 @cindex @code{target("sse4a")} function attribute, x86
5498 Enable/disable the generation of the SSE4A instructions.
5500 @item fma4
5501 @itemx no-fma4
5502 @cindex @code{target("fma4")} function attribute, x86
5503 Enable/disable the generation of the FMA4 instructions.
5505 @item xop
5506 @itemx no-xop
5507 @cindex @code{target("xop")} function attribute, x86
5508 Enable/disable the generation of the XOP instructions.
5510 @item lwp
5511 @itemx no-lwp
5512 @cindex @code{target("lwp")} function attribute, x86
5513 Enable/disable the generation of the LWP instructions.
5515 @item ssse3
5516 @itemx no-ssse3
5517 @cindex @code{target("ssse3")} function attribute, x86
5518 Enable/disable the generation of the SSSE3 instructions.
5520 @item cld
5521 @itemx no-cld
5522 @cindex @code{target("cld")} function attribute, x86
5523 Enable/disable the generation of the CLD before string moves.
5525 @item fancy-math-387
5526 @itemx no-fancy-math-387
5527 @cindex @code{target("fancy-math-387")} function attribute, x86
5528 Enable/disable the generation of the @code{sin}, @code{cos}, and
5529 @code{sqrt} instructions on the 387 floating-point unit.
5531 @item ieee-fp
5532 @itemx no-ieee-fp
5533 @cindex @code{target("ieee-fp")} function attribute, x86
5534 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5536 @item inline-all-stringops
5537 @itemx no-inline-all-stringops
5538 @cindex @code{target("inline-all-stringops")} function attribute, x86
5539 Enable/disable inlining of string operations.
5541 @item inline-stringops-dynamically
5542 @itemx no-inline-stringops-dynamically
5543 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5544 Enable/disable the generation of the inline code to do small string
5545 operations and calling the library routines for large operations.
5547 @item align-stringops
5548 @itemx no-align-stringops
5549 @cindex @code{target("align-stringops")} function attribute, x86
5550 Do/do not align destination of inlined string operations.
5552 @item recip
5553 @itemx no-recip
5554 @cindex @code{target("recip")} function attribute, x86
5555 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5556 instructions followed an additional Newton-Raphson step instead of
5557 doing a floating-point division.
5559 @item arch=@var{ARCH}
5560 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5561 Specify the architecture to generate code for in compiling the function.
5563 @item tune=@var{TUNE}
5564 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5565 Specify the architecture to tune for in compiling the function.
5567 @item fpmath=@var{FPMATH}
5568 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5569 Specify which floating-point unit to use.  You must specify the
5570 @code{target("fpmath=sse,387")} option as
5571 @code{target("fpmath=sse+387")} because the comma would separate
5572 different options.
5573 @end table
5575 On the x86, the inliner does not inline a
5576 function that has different target options than the caller, unless the
5577 callee has a subset of the target options of the caller.  For example
5578 a function declared with @code{target("sse3")} can inline a function
5579 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5580 @end table
5582 @node Xstormy16 Function Attributes
5583 @subsection Xstormy16 Function Attributes
5585 These function attributes are supported by the Xstormy16 back end:
5587 @table @code
5588 @item interrupt
5589 @cindex @code{interrupt} function attribute, Xstormy16
5590 Use this attribute to indicate
5591 that the specified function is an interrupt handler.  The compiler generates
5592 function entry and exit sequences suitable for use in an interrupt handler
5593 when this attribute is present.
5594 @end table
5596 @node Variable Attributes
5597 @section Specifying Attributes of Variables
5598 @cindex attribute of variables
5599 @cindex variable attributes
5601 The keyword @code{__attribute__} allows you to specify special
5602 attributes of variables or structure fields.  This keyword is followed
5603 by an attribute specification inside double parentheses.  Some
5604 attributes are currently defined generically for variables.
5605 Other attributes are defined for variables on particular target
5606 systems.  Other attributes are available for functions
5607 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5608 enumerators (@pxref{Enumerator Attributes}), statements
5609 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5610 Other front ends might define more attributes
5611 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5613 @xref{Attribute Syntax}, for details of the exact syntax for using
5614 attributes.
5616 @menu
5617 * Common Variable Attributes::
5618 * AVR Variable Attributes::
5619 * Blackfin Variable Attributes::
5620 * H8/300 Variable Attributes::
5621 * IA-64 Variable Attributes::
5622 * M32R/D Variable Attributes::
5623 * MeP Variable Attributes::
5624 * Microsoft Windows Variable Attributes::
5625 * MSP430 Variable Attributes::
5626 * Nvidia PTX Variable Attributes::
5627 * PowerPC Variable Attributes::
5628 * RL78 Variable Attributes::
5629 * SPU Variable Attributes::
5630 * V850 Variable Attributes::
5631 * x86 Variable Attributes::
5632 * Xstormy16 Variable Attributes::
5633 @end menu
5635 @node Common Variable Attributes
5636 @subsection Common Variable Attributes
5638 The following attributes are supported on most targets.
5640 @table @code
5641 @cindex @code{aligned} variable attribute
5642 @item aligned (@var{alignment})
5643 This attribute specifies a minimum alignment for the variable or
5644 structure field, measured in bytes.  For example, the declaration:
5646 @smallexample
5647 int x __attribute__ ((aligned (16))) = 0;
5648 @end smallexample
5650 @noindent
5651 causes the compiler to allocate the global variable @code{x} on a
5652 16-byte boundary.  On a 68040, this could be used in conjunction with
5653 an @code{asm} expression to access the @code{move16} instruction which
5654 requires 16-byte aligned operands.
5656 You can also specify the alignment of structure fields.  For example, to
5657 create a double-word aligned @code{int} pair, you could write:
5659 @smallexample
5660 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5661 @end smallexample
5663 @noindent
5664 This is an alternative to creating a union with a @code{double} member,
5665 which forces the union to be double-word aligned.
5667 As in the preceding examples, you can explicitly specify the alignment
5668 (in bytes) that you wish the compiler to use for a given variable or
5669 structure field.  Alternatively, you can leave out the alignment factor
5670 and just ask the compiler to align a variable or field to the
5671 default alignment for the target architecture you are compiling for.
5672 The default alignment is sufficient for all scalar types, but may not be
5673 enough for all vector types on a target that supports vector operations.
5674 The default alignment is fixed for a particular target ABI.
5676 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5677 which is the largest alignment ever used for any data type on the
5678 target machine you are compiling for.  For example, you could write:
5680 @smallexample
5681 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5682 @end smallexample
5684 The compiler automatically sets the alignment for the declared
5685 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5686 often make copy operations more efficient, because the compiler can
5687 use whatever instructions copy the biggest chunks of memory when
5688 performing copies to or from the variables or fields that you have
5689 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5690 may change depending on command-line options.
5692 When used on a struct, or struct member, the @code{aligned} attribute can
5693 only increase the alignment; in order to decrease it, the @code{packed}
5694 attribute must be specified as well.  When used as part of a typedef, the
5695 @code{aligned} attribute can both increase and decrease alignment, and
5696 specifying the @code{packed} attribute generates a warning.
5698 Note that the effectiveness of @code{aligned} attributes may be limited
5699 by inherent limitations in your linker.  On many systems, the linker is
5700 only able to arrange for variables to be aligned up to a certain maximum
5701 alignment.  (For some linkers, the maximum supported alignment may
5702 be very very small.)  If your linker is only able to align variables
5703 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5704 in an @code{__attribute__} still only provides you with 8-byte
5705 alignment.  See your linker documentation for further information.
5707 The @code{aligned} attribute can also be used for functions
5708 (@pxref{Common Function Attributes}.)
5710 @item cleanup (@var{cleanup_function})
5711 @cindex @code{cleanup} variable attribute
5712 The @code{cleanup} attribute runs a function when the variable goes
5713 out of scope.  This attribute can only be applied to auto function
5714 scope variables; it may not be applied to parameters or variables
5715 with static storage duration.  The function must take one parameter,
5716 a pointer to a type compatible with the variable.  The return value
5717 of the function (if any) is ignored.
5719 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5720 is run during the stack unwinding that happens during the
5721 processing of the exception.  Note that the @code{cleanup} attribute
5722 does not allow the exception to be caught, only to perform an action.
5723 It is undefined what happens if @var{cleanup_function} does not
5724 return normally.
5726 @item common
5727 @itemx nocommon
5728 @cindex @code{common} variable attribute
5729 @cindex @code{nocommon} variable attribute
5730 @opindex fcommon
5731 @opindex fno-common
5732 The @code{common} attribute requests GCC to place a variable in
5733 ``common'' storage.  The @code{nocommon} attribute requests the
5734 opposite---to allocate space for it directly.
5736 These attributes override the default chosen by the
5737 @option{-fno-common} and @option{-fcommon} flags respectively.
5739 @item deprecated
5740 @itemx deprecated (@var{msg})
5741 @cindex @code{deprecated} variable attribute
5742 The @code{deprecated} attribute results in a warning if the variable
5743 is used anywhere in the source file.  This is useful when identifying
5744 variables that are expected to be removed in a future version of a
5745 program.  The warning also includes the location of the declaration
5746 of the deprecated variable, to enable users to easily find further
5747 information about why the variable is deprecated, or what they should
5748 do instead.  Note that the warning only occurs for uses:
5750 @smallexample
5751 extern int old_var __attribute__ ((deprecated));
5752 extern int old_var;
5753 int new_fn () @{ return old_var; @}
5754 @end smallexample
5756 @noindent
5757 results in a warning on line 3 but not line 2.  The optional @var{msg}
5758 argument, which must be a string, is printed in the warning if
5759 present.
5761 The @code{deprecated} attribute can also be used for functions and
5762 types (@pxref{Common Function Attributes},
5763 @pxref{Common Type Attributes}).
5765 @item mode (@var{mode})
5766 @cindex @code{mode} variable attribute
5767 This attribute specifies the data type for the declaration---whichever
5768 type corresponds to the mode @var{mode}.  This in effect lets you
5769 request an integer or floating-point type according to its width.
5771 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
5772 for a list of the possible keywords for @var{mode}.
5773 You may also specify a mode of @code{byte} or @code{__byte__} to
5774 indicate the mode corresponding to a one-byte integer, @code{word} or
5775 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5776 or @code{__pointer__} for the mode used to represent pointers.
5778 @item packed
5779 @cindex @code{packed} variable attribute
5780 The @code{packed} attribute specifies that a variable or structure field
5781 should have the smallest possible alignment---one byte for a variable,
5782 and one bit for a field, unless you specify a larger value with the
5783 @code{aligned} attribute.
5785 Here is a structure in which the field @code{x} is packed, so that it
5786 immediately follows @code{a}:
5788 @smallexample
5789 struct foo
5791   char a;
5792   int x[2] __attribute__ ((packed));
5794 @end smallexample
5796 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5797 @code{packed} attribute on bit-fields of type @code{char}.  This has
5798 been fixed in GCC 4.4 but the change can lead to differences in the
5799 structure layout.  See the documentation of
5800 @option{-Wpacked-bitfield-compat} for more information.
5802 @item section ("@var{section-name}")
5803 @cindex @code{section} variable attribute
5804 Normally, the compiler places the objects it generates in sections like
5805 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5806 or you need certain particular variables to appear in special sections,
5807 for example to map to special hardware.  The @code{section}
5808 attribute specifies that a variable (or function) lives in a particular
5809 section.  For example, this small program uses several specific section names:
5811 @smallexample
5812 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5813 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5814 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5815 int init_data __attribute__ ((section ("INITDATA")));
5817 main()
5819   /* @r{Initialize stack pointer} */
5820   init_sp (stack + sizeof (stack));
5822   /* @r{Initialize initialized data} */
5823   memcpy (&init_data, &data, &edata - &data);
5825   /* @r{Turn on the serial ports} */
5826   init_duart (&a);
5827   init_duart (&b);
5829 @end smallexample
5831 @noindent
5832 Use the @code{section} attribute with
5833 @emph{global} variables and not @emph{local} variables,
5834 as shown in the example.
5836 You may use the @code{section} attribute with initialized or
5837 uninitialized global variables but the linker requires
5838 each object be defined once, with the exception that uninitialized
5839 variables tentatively go in the @code{common} (or @code{bss}) section
5840 and can be multiply ``defined''.  Using the @code{section} attribute
5841 changes what section the variable goes into and may cause the
5842 linker to issue an error if an uninitialized variable has multiple
5843 definitions.  You can force a variable to be initialized with the
5844 @option{-fno-common} flag or the @code{nocommon} attribute.
5846 Some file formats do not support arbitrary sections so the @code{section}
5847 attribute is not available on all platforms.
5848 If you need to map the entire contents of a module to a particular
5849 section, consider using the facilities of the linker instead.
5851 @item tls_model ("@var{tls_model}")
5852 @cindex @code{tls_model} variable attribute
5853 The @code{tls_model} attribute sets thread-local storage model
5854 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5855 overriding @option{-ftls-model=} command-line switch on a per-variable
5856 basis.
5857 The @var{tls_model} argument should be one of @code{global-dynamic},
5858 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5860 Not all targets support this attribute.
5862 @item unused
5863 @cindex @code{unused} variable attribute
5864 This attribute, attached to a variable, means that the variable is meant
5865 to be possibly unused.  GCC does not produce a warning for this
5866 variable.
5868 @item used
5869 @cindex @code{used} variable attribute
5870 This attribute, attached to a variable with static storage, means that
5871 the variable must be emitted even if it appears that the variable is not
5872 referenced.
5874 When applied to a static data member of a C++ class template, the
5875 attribute also means that the member is instantiated if the
5876 class itself is instantiated.
5878 @item vector_size (@var{bytes})
5879 @cindex @code{vector_size} variable attribute
5880 This attribute specifies the vector size for the variable, measured in
5881 bytes.  For example, the declaration:
5883 @smallexample
5884 int foo __attribute__ ((vector_size (16)));
5885 @end smallexample
5887 @noindent
5888 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5889 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5890 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5892 This attribute is only applicable to integral and float scalars,
5893 although arrays, pointers, and function return values are allowed in
5894 conjunction with this construct.
5896 Aggregates with this attribute are invalid, even if they are of the same
5897 size as a corresponding scalar.  For example, the declaration:
5899 @smallexample
5900 struct S @{ int a; @};
5901 struct S  __attribute__ ((vector_size (16))) foo;
5902 @end smallexample
5904 @noindent
5905 is invalid even if the size of the structure is the same as the size of
5906 the @code{int}.
5908 @item visibility ("@var{visibility_type}")
5909 @cindex @code{visibility} variable attribute
5910 This attribute affects the linkage of the declaration to which it is attached.
5911 The @code{visibility} attribute is described in
5912 @ref{Common Function Attributes}.
5914 @item weak
5915 @cindex @code{weak} variable attribute
5916 The @code{weak} attribute is described in
5917 @ref{Common Function Attributes}.
5919 @end table
5921 @node AVR Variable Attributes
5922 @subsection AVR Variable Attributes
5924 @table @code
5925 @item progmem
5926 @cindex @code{progmem} variable attribute, AVR
5927 The @code{progmem} attribute is used on the AVR to place read-only
5928 data in the non-volatile program memory (flash). The @code{progmem}
5929 attribute accomplishes this by putting respective variables into a
5930 section whose name starts with @code{.progmem}.
5932 This attribute works similar to the @code{section} attribute
5933 but adds additional checking.
5935 @table @asis
5936 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5937 @code{progmem} affects the location
5938 of the data but not how this data is accessed.
5939 In order to read data located with the @code{progmem} attribute
5940 (inline) assembler must be used.
5941 @smallexample
5942 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5943 #include <avr/pgmspace.h> 
5945 /* Locate var in flash memory */
5946 const int var[2] PROGMEM = @{ 1, 2 @};
5948 int read_var (int i)
5950     /* Access var[] by accessor macro from avr/pgmspace.h */
5951     return (int) pgm_read_word (& var[i]);
5953 @end smallexample
5955 AVR is a Harvard architecture processor and data and read-only data
5956 normally resides in the data memory (RAM).
5958 See also the @ref{AVR Named Address Spaces} section for
5959 an alternate way to locate and access data in flash memory.
5961 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
5962 On such devices, there is no need for attribute @code{progmem} or
5963 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
5964 Just use standard C / C++.  The compiler will generate @code{LD*}
5965 instructions.  As flash memory is visible in the RAM address range,
5966 and the default linker script does @emph{not} locate @code{.rodata} in
5967 RAM, no special features are needed in order not to waste RAM for
5968 read-only data or to read from flash.  You might even get slightly better
5969 performance by
5970 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
5971 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
5972 an overview.
5974 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5975 The compiler adds @code{0x4000}
5976 to the addresses of objects and declarations in @code{progmem} and locates
5977 the objects in flash memory, namely in section @code{.progmem.data}.
5978 The offset is needed because the flash memory is visible in the RAM
5979 address space starting at address @code{0x4000}.
5981 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5982 no special functions or macros are needed.
5984 @smallexample
5985 /* var is located in flash memory */
5986 extern const int var[2] __attribute__((progmem));
5988 int read_var (int i)
5990     return var[i];
5992 @end smallexample
5994 Please notice that on these devices, there is no need for @code{progmem}
5995 at all.
5997 @end table
5999 @item io
6000 @itemx io (@var{addr})
6001 @cindex @code{io} variable attribute, AVR
6002 Variables with the @code{io} attribute are used to address
6003 memory-mapped peripherals in the io address range.
6004 If an address is specified, the variable
6005 is assigned that address, and the value is interpreted as an
6006 address in the data address space.
6007 Example:
6009 @smallexample
6010 volatile int porta __attribute__((io (0x22)));
6011 @end smallexample
6013 The address specified in the address in the data address range.
6015 Otherwise, the variable it is not assigned an address, but the
6016 compiler will still use in/out instructions where applicable,
6017 assuming some other module assigns an address in the io address range.
6018 Example:
6020 @smallexample
6021 extern volatile int porta __attribute__((io));
6022 @end smallexample
6024 @item io_low
6025 @itemx io_low (@var{addr})
6026 @cindex @code{io_low} variable attribute, AVR
6027 This is like the @code{io} attribute, but additionally it informs the
6028 compiler that the object lies in the lower half of the I/O area,
6029 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6030 instructions.
6032 @item address
6033 @itemx address (@var{addr})
6034 @cindex @code{address} variable attribute, AVR
6035 Variables with the @code{address} attribute are used to address
6036 memory-mapped peripherals that may lie outside the io address range.
6038 @smallexample
6039 volatile int porta __attribute__((address (0x600)));
6040 @end smallexample
6042 @item absdata
6043 @cindex @code{absdata} variable attribute, AVR
6044 Variables in static storage and with the @code{absdata} attribute can
6045 be accessed by the @code{LDS} and @code{STS} instructions which take
6046 absolute addresses.
6048 @itemize @bullet
6049 @item
6050 This attribute is only supported for the reduced AVR Tiny core
6051 like ATtiny40.
6053 @item
6054 You must make sure that respective data is located in the
6055 address range @code{0x40}@dots{}@code{0xbf} accessible by
6056 @code{LDS} and @code{STS}.  One way to achieve this as an
6057 appropriate linker description file.
6059 @item
6060 If the location does not fit the address range of @code{LDS}
6061 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6062 warning like
6063 @quotation
6064 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6065 @end quotation
6067 @end itemize
6069 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6071 @end table
6073 @node Blackfin Variable Attributes
6074 @subsection Blackfin Variable Attributes
6076 Three attributes are currently defined for the Blackfin.
6078 @table @code
6079 @item l1_data
6080 @itemx l1_data_A
6081 @itemx l1_data_B
6082 @cindex @code{l1_data} variable attribute, Blackfin
6083 @cindex @code{l1_data_A} variable attribute, Blackfin
6084 @cindex @code{l1_data_B} variable attribute, Blackfin
6085 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6086 Variables with @code{l1_data} attribute are put into the specific section
6087 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6088 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6089 attribute are put into the specific section named @code{.l1.data.B}.
6091 @item l2
6092 @cindex @code{l2} variable attribute, Blackfin
6093 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6094 Variables with @code{l2} attribute are put into the specific section
6095 named @code{.l2.data}.
6096 @end table
6098 @node H8/300 Variable Attributes
6099 @subsection H8/300 Variable Attributes
6101 These variable attributes are available for H8/300 targets:
6103 @table @code
6104 @item eightbit_data
6105 @cindex @code{eightbit_data} variable attribute, H8/300
6106 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6107 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6108 variable should be placed into the eight-bit data section.
6109 The compiler generates more efficient code for certain operations
6110 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6111 256 bytes of data.
6113 You must use GAS and GLD from GNU binutils version 2.7 or later for
6114 this attribute to work correctly.
6116 @item tiny_data
6117 @cindex @code{tiny_data} variable attribute, H8/300
6118 @cindex tiny data section on the H8/300H and H8S
6119 Use this attribute on the H8/300H and H8S to indicate that the specified
6120 variable should be placed into the tiny data section.
6121 The compiler generates more efficient code for loads and stores
6122 on data in the tiny data section.  Note the tiny data area is limited to
6123 slightly under 32KB of data.
6125 @end table
6127 @node IA-64 Variable Attributes
6128 @subsection IA-64 Variable Attributes
6130 The IA-64 back end supports the following variable attribute:
6132 @table @code
6133 @item model (@var{model-name})
6134 @cindex @code{model} variable attribute, IA-64
6136 On IA-64, use this attribute to set the addressability of an object.
6137 At present, the only supported identifier for @var{model-name} is
6138 @code{small}, indicating addressability via ``small'' (22-bit)
6139 addresses (so that their addresses can be loaded with the @code{addl}
6140 instruction).  Caveat: such addressing is by definition not position
6141 independent and hence this attribute must not be used for objects
6142 defined by shared libraries.
6144 @end table
6146 @node M32R/D Variable Attributes
6147 @subsection M32R/D Variable Attributes
6149 One attribute is currently defined for the M32R/D@.
6151 @table @code
6152 @item model (@var{model-name})
6153 @cindex @code{model-name} variable attribute, M32R/D
6154 @cindex variable addressability on the M32R/D
6155 Use this attribute on the M32R/D to set the addressability of an object.
6156 The identifier @var{model-name} is one of @code{small}, @code{medium},
6157 or @code{large}, representing each of the code models.
6159 Small model objects live in the lower 16MB of memory (so that their
6160 addresses can be loaded with the @code{ld24} instruction).
6162 Medium and large model objects may live anywhere in the 32-bit address space
6163 (the compiler generates @code{seth/add3} instructions to load their
6164 addresses).
6165 @end table
6167 @node MeP Variable Attributes
6168 @subsection MeP Variable Attributes
6170 The MeP target has a number of addressing modes and busses.  The
6171 @code{near} space spans the standard memory space's first 16 megabytes
6172 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6173 The @code{based} space is a 128-byte region in the memory space that
6174 is addressed relative to the @code{$tp} register.  The @code{tiny}
6175 space is a 65536-byte region relative to the @code{$gp} register.  In
6176 addition to these memory regions, the MeP target has a separate 16-bit
6177 control bus which is specified with @code{cb} attributes.
6179 @table @code
6181 @item based
6182 @cindex @code{based} variable attribute, MeP
6183 Any variable with the @code{based} attribute is assigned to the
6184 @code{.based} section, and is accessed with relative to the
6185 @code{$tp} register.
6187 @item tiny
6188 @cindex @code{tiny} variable attribute, MeP
6189 Likewise, the @code{tiny} attribute assigned variables to the
6190 @code{.tiny} section, relative to the @code{$gp} register.
6192 @item near
6193 @cindex @code{near} variable attribute, MeP
6194 Variables with the @code{near} attribute are assumed to have addresses
6195 that fit in a 24-bit addressing mode.  This is the default for large
6196 variables (@code{-mtiny=4} is the default) but this attribute can
6197 override @code{-mtiny=} for small variables, or override @code{-ml}.
6199 @item far
6200 @cindex @code{far} variable attribute, MeP
6201 Variables with the @code{far} attribute are addressed using a full
6202 32-bit address.  Since this covers the entire memory space, this
6203 allows modules to make no assumptions about where variables might be
6204 stored.
6206 @item io
6207 @cindex @code{io} variable attribute, MeP
6208 @itemx io (@var{addr})
6209 Variables with the @code{io} attribute are used to address
6210 memory-mapped peripherals.  If an address is specified, the variable
6211 is assigned that address, else it is not assigned an address (it is
6212 assumed some other module assigns an address).  Example:
6214 @smallexample
6215 int timer_count __attribute__((io(0x123)));
6216 @end smallexample
6218 @item cb
6219 @itemx cb (@var{addr})
6220 @cindex @code{cb} variable attribute, MeP
6221 Variables with the @code{cb} attribute are used to access the control
6222 bus, using special instructions.  @code{addr} indicates the control bus
6223 address.  Example:
6225 @smallexample
6226 int cpu_clock __attribute__((cb(0x123)));
6227 @end smallexample
6229 @end table
6231 @node Microsoft Windows Variable Attributes
6232 @subsection Microsoft Windows Variable Attributes
6234 You can use these attributes on Microsoft Windows targets.
6235 @ref{x86 Variable Attributes} for additional Windows compatibility
6236 attributes available on all x86 targets.
6238 @table @code
6239 @item dllimport
6240 @itemx dllexport
6241 @cindex @code{dllimport} variable attribute
6242 @cindex @code{dllexport} variable attribute
6243 The @code{dllimport} and @code{dllexport} attributes are described in
6244 @ref{Microsoft Windows Function Attributes}.
6246 @item selectany
6247 @cindex @code{selectany} variable attribute
6248 The @code{selectany} attribute causes an initialized global variable to
6249 have link-once semantics.  When multiple definitions of the variable are
6250 encountered by the linker, the first is selected and the remainder are
6251 discarded.  Following usage by the Microsoft compiler, the linker is told
6252 @emph{not} to warn about size or content differences of the multiple
6253 definitions.
6255 Although the primary usage of this attribute is for POD types, the
6256 attribute can also be applied to global C++ objects that are initialized
6257 by a constructor.  In this case, the static initialization and destruction
6258 code for the object is emitted in each translation defining the object,
6259 but the calls to the constructor and destructor are protected by a
6260 link-once guard variable.
6262 The @code{selectany} attribute is only available on Microsoft Windows
6263 targets.  You can use @code{__declspec (selectany)} as a synonym for
6264 @code{__attribute__ ((selectany))} for compatibility with other
6265 compilers.
6267 @item shared
6268 @cindex @code{shared} variable attribute
6269 On Microsoft Windows, in addition to putting variable definitions in a named
6270 section, the section can also be shared among all running copies of an
6271 executable or DLL@.  For example, this small program defines shared data
6272 by putting it in a named section @code{shared} and marking the section
6273 shareable:
6275 @smallexample
6276 int foo __attribute__((section ("shared"), shared)) = 0;
6279 main()
6281   /* @r{Read and write foo.  All running
6282      copies see the same value.}  */
6283   return 0;
6285 @end smallexample
6287 @noindent
6288 You may only use the @code{shared} attribute along with @code{section}
6289 attribute with a fully-initialized global definition because of the way
6290 linkers work.  See @code{section} attribute for more information.
6292 The @code{shared} attribute is only available on Microsoft Windows@.
6294 @end table
6296 @node MSP430 Variable Attributes
6297 @subsection MSP430 Variable Attributes
6299 @table @code
6300 @item noinit
6301 @cindex @code{noinit} variable attribute, MSP430 
6302 Any data with the @code{noinit} attribute will not be initialised by
6303 the C runtime startup code, or the program loader.  Not initialising
6304 data in this way can reduce program startup times.
6306 @item persistent
6307 @cindex @code{persistent} variable attribute, MSP430 
6308 Any variable with the @code{persistent} attribute will not be
6309 initialised by the C runtime startup code.  Instead its value will be
6310 set once, when the application is loaded, and then never initialised
6311 again, even if the processor is reset or the program restarts.
6312 Persistent data is intended to be placed into FLASH RAM, where its
6313 value will be retained across resets.  The linker script being used to
6314 create the application should ensure that persistent data is correctly
6315 placed.
6317 @item lower
6318 @itemx upper
6319 @itemx either
6320 @cindex @code{lower} variable attribute, MSP430 
6321 @cindex @code{upper} variable attribute, MSP430 
6322 @cindex @code{either} variable attribute, MSP430 
6323 These attributes are the same as the MSP430 function attributes of the
6324 same name (@pxref{MSP430 Function Attributes}).  
6325 These attributes can be applied to both functions and variables.
6326 @end table
6328 @node Nvidia PTX Variable Attributes
6329 @subsection Nvidia PTX Variable Attributes
6331 These variable attributes are supported by the Nvidia PTX back end:
6333 @table @code
6334 @item shared
6335 @cindex @code{shared} attribute, Nvidia PTX
6336 Use this attribute to place a variable in the @code{.shared} memory space.
6337 This memory space is private to each cooperative thread array; only threads
6338 within one thread block refer to the same instance of the variable.
6339 The runtime does not initialize variables in this memory space.
6340 @end table
6342 @node PowerPC Variable Attributes
6343 @subsection PowerPC Variable Attributes
6345 Three attributes currently are defined for PowerPC configurations:
6346 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6348 @cindex @code{ms_struct} variable attribute, PowerPC
6349 @cindex @code{gcc_struct} variable attribute, PowerPC
6350 For full documentation of the struct attributes please see the
6351 documentation in @ref{x86 Variable Attributes}.
6353 @cindex @code{altivec} variable attribute, PowerPC
6354 For documentation of @code{altivec} attribute please see the
6355 documentation in @ref{PowerPC Type Attributes}.
6357 @node RL78 Variable Attributes
6358 @subsection RL78 Variable Attributes
6360 @cindex @code{saddr} variable attribute, RL78
6361 The RL78 back end supports the @code{saddr} variable attribute.  This
6362 specifies placement of the corresponding variable in the SADDR area,
6363 which can be accessed more efficiently than the default memory region.
6365 @node SPU Variable Attributes
6366 @subsection SPU Variable Attributes
6368 @cindex @code{spu_vector} variable attribute, SPU
6369 The SPU supports the @code{spu_vector} attribute for variables.  For
6370 documentation of this attribute please see the documentation in
6371 @ref{SPU Type Attributes}.
6373 @node V850 Variable Attributes
6374 @subsection V850 Variable Attributes
6376 These variable attributes are supported by the V850 back end:
6378 @table @code
6380 @item sda
6381 @cindex @code{sda} variable attribute, V850
6382 Use this attribute to explicitly place a variable in the small data area,
6383 which can hold up to 64 kilobytes.
6385 @item tda
6386 @cindex @code{tda} variable attribute, V850
6387 Use this attribute to explicitly place a variable in the tiny data area,
6388 which can hold up to 256 bytes in total.
6390 @item zda
6391 @cindex @code{zda} variable attribute, V850
6392 Use this attribute to explicitly place a variable in the first 32 kilobytes
6393 of memory.
6394 @end table
6396 @node x86 Variable Attributes
6397 @subsection x86 Variable Attributes
6399 Two attributes are currently defined for x86 configurations:
6400 @code{ms_struct} and @code{gcc_struct}.
6402 @table @code
6403 @item ms_struct
6404 @itemx gcc_struct
6405 @cindex @code{ms_struct} variable attribute, x86
6406 @cindex @code{gcc_struct} variable attribute, x86
6408 If @code{packed} is used on a structure, or if bit-fields are used,
6409 it may be that the Microsoft ABI lays out the structure differently
6410 than the way GCC normally does.  Particularly when moving packed
6411 data between functions compiled with GCC and the native Microsoft compiler
6412 (either via function call or as data in a file), it may be necessary to access
6413 either format.
6415 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6416 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6417 command-line options, respectively;
6418 see @ref{x86 Options}, for details of how structure layout is affected.
6419 @xref{x86 Type Attributes}, for information about the corresponding
6420 attributes on types.
6422 @end table
6424 @node Xstormy16 Variable Attributes
6425 @subsection Xstormy16 Variable Attributes
6427 One attribute is currently defined for xstormy16 configurations:
6428 @code{below100}.
6430 @table @code
6431 @item below100
6432 @cindex @code{below100} variable attribute, Xstormy16
6434 If a variable has the @code{below100} attribute (@code{BELOW100} is
6435 allowed also), GCC places the variable in the first 0x100 bytes of
6436 memory and use special opcodes to access it.  Such variables are
6437 placed in either the @code{.bss_below100} section or the
6438 @code{.data_below100} section.
6440 @end table
6442 @node Type Attributes
6443 @section Specifying Attributes of Types
6444 @cindex attribute of types
6445 @cindex type attributes
6447 The keyword @code{__attribute__} allows you to specify special
6448 attributes of types.  Some type attributes apply only to @code{struct}
6449 and @code{union} types, while others can apply to any type defined
6450 via a @code{typedef} declaration.  Other attributes are defined for
6451 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6452 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6453 statements (@pxref{Statement Attributes}), and for
6454 variables (@pxref{Variable Attributes}).
6456 The @code{__attribute__} keyword is followed by an attribute specification
6457 inside double parentheses.  
6459 You may specify type attributes in an enum, struct or union type
6460 declaration or definition by placing them immediately after the
6461 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6462 syntax is to place them just past the closing curly brace of the
6463 definition.
6465 You can also include type attributes in a @code{typedef} declaration.
6466 @xref{Attribute Syntax}, for details of the exact syntax for using
6467 attributes.
6469 @menu
6470 * Common Type Attributes::
6471 * ARM Type Attributes::
6472 * MeP Type Attributes::
6473 * PowerPC Type Attributes::
6474 * SPU Type Attributes::
6475 * x86 Type Attributes::
6476 @end menu
6478 @node Common Type Attributes
6479 @subsection Common Type Attributes
6481 The following type attributes are supported on most targets.
6483 @table @code
6484 @cindex @code{aligned} type attribute
6485 @item aligned (@var{alignment})
6486 This attribute specifies a minimum alignment (in bytes) for variables
6487 of the specified type.  For example, the declarations:
6489 @smallexample
6490 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6491 typedef int more_aligned_int __attribute__ ((aligned (8)));
6492 @end smallexample
6494 @noindent
6495 force the compiler to ensure (as far as it can) that each variable whose
6496 type is @code{struct S} or @code{more_aligned_int} is allocated and
6497 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6498 variables of type @code{struct S} aligned to 8-byte boundaries allows
6499 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6500 store) instructions when copying one variable of type @code{struct S} to
6501 another, thus improving run-time efficiency.
6503 Note that the alignment of any given @code{struct} or @code{union} type
6504 is required by the ISO C standard to be at least a perfect multiple of
6505 the lowest common multiple of the alignments of all of the members of
6506 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6507 effectively adjust the alignment of a @code{struct} or @code{union}
6508 type by attaching an @code{aligned} attribute to any one of the members
6509 of such a type, but the notation illustrated in the example above is a
6510 more obvious, intuitive, and readable way to request the compiler to
6511 adjust the alignment of an entire @code{struct} or @code{union} type.
6513 As in the preceding example, you can explicitly specify the alignment
6514 (in bytes) that you wish the compiler to use for a given @code{struct}
6515 or @code{union} type.  Alternatively, you can leave out the alignment factor
6516 and just ask the compiler to align a type to the maximum
6517 useful alignment for the target machine you are compiling for.  For
6518 example, you could write:
6520 @smallexample
6521 struct S @{ short f[3]; @} __attribute__ ((aligned));
6522 @end smallexample
6524 Whenever you leave out the alignment factor in an @code{aligned}
6525 attribute specification, the compiler automatically sets the alignment
6526 for the type to the largest alignment that is ever used for any data
6527 type on the target machine you are compiling for.  Doing this can often
6528 make copy operations more efficient, because the compiler can use
6529 whatever instructions copy the biggest chunks of memory when performing
6530 copies to or from the variables that have types that you have aligned
6531 this way.
6533 In the example above, if the size of each @code{short} is 2 bytes, then
6534 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6535 power of two that is greater than or equal to that is 8, so the
6536 compiler sets the alignment for the entire @code{struct S} type to 8
6537 bytes.
6539 Note that although you can ask the compiler to select a time-efficient
6540 alignment for a given type and then declare only individual stand-alone
6541 objects of that type, the compiler's ability to select a time-efficient
6542 alignment is primarily useful only when you plan to create arrays of
6543 variables having the relevant (efficiently aligned) type.  If you
6544 declare or use arrays of variables of an efficiently-aligned type, then
6545 it is likely that your program also does pointer arithmetic (or
6546 subscripting, which amounts to the same thing) on pointers to the
6547 relevant type, and the code that the compiler generates for these
6548 pointer arithmetic operations is often more efficient for
6549 efficiently-aligned types than for other types.
6551 Note that the effectiveness of @code{aligned} attributes may be limited
6552 by inherent limitations in your linker.  On many systems, the linker is
6553 only able to arrange for variables to be aligned up to a certain maximum
6554 alignment.  (For some linkers, the maximum supported alignment may
6555 be very very small.)  If your linker is only able to align variables
6556 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6557 in an @code{__attribute__} still only provides you with 8-byte
6558 alignment.  See your linker documentation for further information.
6560 The @code{aligned} attribute can only increase alignment.  Alignment
6561 can be decreased by specifying the @code{packed} attribute.  See below.
6563 @item bnd_variable_size
6564 @cindex @code{bnd_variable_size} type attribute
6565 @cindex Pointer Bounds Checker attributes
6566 When applied to a structure field, this attribute tells Pointer
6567 Bounds Checker that the size of this field should not be computed
6568 using static type information.  It may be used to mark variably-sized
6569 static array fields placed at the end of a structure.
6571 @smallexample
6572 struct S
6574   int size;
6575   char data[1];
6577 S *p = (S *)malloc (sizeof(S) + 100);
6578 p->data[10] = 0; //Bounds violation
6579 @end smallexample
6581 @noindent
6582 By using an attribute for the field we may avoid unwanted bound
6583 violation checks:
6585 @smallexample
6586 struct S
6588   int size;
6589   char data[1] __attribute__((bnd_variable_size));
6591 S *p = (S *)malloc (sizeof(S) + 100);
6592 p->data[10] = 0; //OK
6593 @end smallexample
6595 @item deprecated
6596 @itemx deprecated (@var{msg})
6597 @cindex @code{deprecated} type attribute
6598 The @code{deprecated} attribute results in a warning if the type
6599 is used anywhere in the source file.  This is useful when identifying
6600 types that are expected to be removed in a future version of a program.
6601 If possible, the warning also includes the location of the declaration
6602 of the deprecated type, to enable users to easily find further
6603 information about why the type is deprecated, or what they should do
6604 instead.  Note that the warnings only occur for uses and then only
6605 if the type is being applied to an identifier that itself is not being
6606 declared as deprecated.
6608 @smallexample
6609 typedef int T1 __attribute__ ((deprecated));
6610 T1 x;
6611 typedef T1 T2;
6612 T2 y;
6613 typedef T1 T3 __attribute__ ((deprecated));
6614 T3 z __attribute__ ((deprecated));
6615 @end smallexample
6617 @noindent
6618 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6619 warning is issued for line 4 because T2 is not explicitly
6620 deprecated.  Line 5 has no warning because T3 is explicitly
6621 deprecated.  Similarly for line 6.  The optional @var{msg}
6622 argument, which must be a string, is printed in the warning if
6623 present.
6625 The @code{deprecated} attribute can also be used for functions and
6626 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6628 @item designated_init
6629 @cindex @code{designated_init} type attribute
6630 This attribute may only be applied to structure types.  It indicates
6631 that any initialization of an object of this type must use designated
6632 initializers rather than positional initializers.  The intent of this
6633 attribute is to allow the programmer to indicate that a structure's
6634 layout may change, and that therefore relying on positional
6635 initialization will result in future breakage.
6637 GCC emits warnings based on this attribute by default; use
6638 @option{-Wno-designated-init} to suppress them.
6640 @item may_alias
6641 @cindex @code{may_alias} type attribute
6642 Accesses through pointers to types with this attribute are not subject
6643 to type-based alias analysis, but are instead assumed to be able to alias
6644 any other type of objects.
6645 In the context of section 6.5 paragraph 7 of the C99 standard,
6646 an lvalue expression
6647 dereferencing such a pointer is treated like having a character type.
6648 See @option{-fstrict-aliasing} for more information on aliasing issues.
6649 This extension exists to support some vector APIs, in which pointers to
6650 one vector type are permitted to alias pointers to a different vector type.
6652 Note that an object of a type with this attribute does not have any
6653 special semantics.
6655 Example of use:
6657 @smallexample
6658 typedef short __attribute__((__may_alias__)) short_a;
6661 main (void)
6663   int a = 0x12345678;
6664   short_a *b = (short_a *) &a;
6666   b[1] = 0;
6668   if (a == 0x12345678)
6669     abort();
6671   exit(0);
6673 @end smallexample
6675 @noindent
6676 If you replaced @code{short_a} with @code{short} in the variable
6677 declaration, the above program would abort when compiled with
6678 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6679 above.
6681 @item packed
6682 @cindex @code{packed} type attribute
6683 This attribute, attached to @code{struct} or @code{union} type
6684 definition, specifies that each member (other than zero-width bit-fields)
6685 of the structure or union is placed to minimize the memory required.  When
6686 attached to an @code{enum} definition, it indicates that the smallest
6687 integral type should be used.
6689 @opindex fshort-enums
6690 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6691 types is equivalent to specifying the @code{packed} attribute on each
6692 of the structure or union members.  Specifying the @option{-fshort-enums}
6693 flag on the command line is equivalent to specifying the @code{packed}
6694 attribute on all @code{enum} definitions.
6696 In the following example @code{struct my_packed_struct}'s members are
6697 packed closely together, but the internal layout of its @code{s} member
6698 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6699 be packed too.
6701 @smallexample
6702 struct my_unpacked_struct
6703  @{
6704     char c;
6705     int i;
6706  @};
6708 struct __attribute__ ((__packed__)) my_packed_struct
6709   @{
6710      char c;
6711      int  i;
6712      struct my_unpacked_struct s;
6713   @};
6714 @end smallexample
6716 You may only specify the @code{packed} attribute attribute on the definition
6717 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6718 that does not also define the enumerated type, structure or union.
6720 @item scalar_storage_order ("@var{endianness}")
6721 @cindex @code{scalar_storage_order} type attribute
6722 When attached to a @code{union} or a @code{struct}, this attribute sets
6723 the storage order, aka endianness, of the scalar fields of the type, as
6724 well as the array fields whose component is scalar.  The supported
6725 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
6726 has no effects on fields which are themselves a @code{union}, a @code{struct}
6727 or an array whose component is a @code{union} or a @code{struct}, and it is
6728 possible for these fields to have a different scalar storage order than the
6729 enclosing type.
6731 This attribute is supported only for targets that use a uniform default
6732 scalar storage order (fortunately, most of them), i.e. targets that store
6733 the scalars either all in big-endian or all in little-endian.
6735 Additional restrictions are enforced for types with the reverse scalar
6736 storage order with regard to the scalar storage order of the target:
6738 @itemize
6739 @item Taking the address of a scalar field of a @code{union} or a
6740 @code{struct} with reverse scalar storage order is not permitted and yields
6741 an error.
6742 @item Taking the address of an array field, whose component is scalar, of
6743 a @code{union} or a @code{struct} with reverse scalar storage order is
6744 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6745 is specified.
6746 @item Taking the address of a @code{union} or a @code{struct} with reverse
6747 scalar storage order is permitted.
6748 @end itemize
6750 These restrictions exist because the storage order attribute is lost when
6751 the address of a scalar or the address of an array with scalar component is
6752 taken, so storing indirectly through this address generally does not work.
6753 The second case is nevertheless allowed to be able to perform a block copy
6754 from or to the array.
6756 Moreover, the use of type punning or aliasing to toggle the storage order
6757 is not supported; that is to say, a given scalar object cannot be accessed
6758 through distinct types that assign a different storage order to it.
6760 @item transparent_union
6761 @cindex @code{transparent_union} type attribute
6763 This attribute, attached to a @code{union} type definition, indicates
6764 that any function parameter having that union type causes calls to that
6765 function to be treated in a special way.
6767 First, the argument corresponding to a transparent union type can be of
6768 any type in the union; no cast is required.  Also, if the union contains
6769 a pointer type, the corresponding argument can be a null pointer
6770 constant or a void pointer expression; and if the union contains a void
6771 pointer type, the corresponding argument can be any pointer expression.
6772 If the union member type is a pointer, qualifiers like @code{const} on
6773 the referenced type must be respected, just as with normal pointer
6774 conversions.
6776 Second, the argument is passed to the function using the calling
6777 conventions of the first member of the transparent union, not the calling
6778 conventions of the union itself.  All members of the union must have the
6779 same machine representation; this is necessary for this argument passing
6780 to work properly.
6782 Transparent unions are designed for library functions that have multiple
6783 interfaces for compatibility reasons.  For example, suppose the
6784 @code{wait} function must accept either a value of type @code{int *} to
6785 comply with POSIX, or a value of type @code{union wait *} to comply with
6786 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6787 @code{wait} would accept both kinds of arguments, but it would also
6788 accept any other pointer type and this would make argument type checking
6789 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6790 as follows:
6792 @smallexample
6793 typedef union __attribute__ ((__transparent_union__))
6794   @{
6795     int *__ip;
6796     union wait *__up;
6797   @} wait_status_ptr_t;
6799 pid_t wait (wait_status_ptr_t);
6800 @end smallexample
6802 @noindent
6803 This interface allows either @code{int *} or @code{union wait *}
6804 arguments to be passed, using the @code{int *} calling convention.
6805 The program can call @code{wait} with arguments of either type:
6807 @smallexample
6808 int w1 () @{ int w; return wait (&w); @}
6809 int w2 () @{ union wait w; return wait (&w); @}
6810 @end smallexample
6812 @noindent
6813 With this interface, @code{wait}'s implementation might look like this:
6815 @smallexample
6816 pid_t wait (wait_status_ptr_t p)
6818   return waitpid (-1, p.__ip, 0);
6820 @end smallexample
6822 @item unused
6823 @cindex @code{unused} type attribute
6824 When attached to a type (including a @code{union} or a @code{struct}),
6825 this attribute means that variables of that type are meant to appear
6826 possibly unused.  GCC does not produce a warning for any variables of
6827 that type, even if the variable appears to do nothing.  This is often
6828 the case with lock or thread classes, which are usually defined and then
6829 not referenced, but contain constructors and destructors that have
6830 nontrivial bookkeeping functions.
6832 @item visibility
6833 @cindex @code{visibility} type attribute
6834 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6835 applied to class, struct, union and enum types.  Unlike other type
6836 attributes, the attribute must appear between the initial keyword and
6837 the name of the type; it cannot appear after the body of the type.
6839 Note that the type visibility is applied to vague linkage entities
6840 associated with the class (vtable, typeinfo node, etc.).  In
6841 particular, if a class is thrown as an exception in one shared object
6842 and caught in another, the class must have default visibility.
6843 Otherwise the two shared objects are unable to use the same
6844 typeinfo node and exception handling will break.
6846 @end table
6848 To specify multiple attributes, separate them by commas within the
6849 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6850 packed))}.
6852 @node ARM Type Attributes
6853 @subsection ARM Type Attributes
6855 @cindex @code{notshared} type attribute, ARM
6856 On those ARM targets that support @code{dllimport} (such as Symbian
6857 OS), you can use the @code{notshared} attribute to indicate that the
6858 virtual table and other similar data for a class should not be
6859 exported from a DLL@.  For example:
6861 @smallexample
6862 class __declspec(notshared) C @{
6863 public:
6864   __declspec(dllimport) C();
6865   virtual void f();
6868 __declspec(dllexport)
6869 C::C() @{@}
6870 @end smallexample
6872 @noindent
6873 In this code, @code{C::C} is exported from the current DLL, but the
6874 virtual table for @code{C} is not exported.  (You can use
6875 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6876 most Symbian OS code uses @code{__declspec}.)
6878 @node MeP Type Attributes
6879 @subsection MeP Type Attributes
6881 @cindex @code{based} type attribute, MeP
6882 @cindex @code{tiny} type attribute, MeP
6883 @cindex @code{near} type attribute, MeP
6884 @cindex @code{far} type attribute, MeP
6885 Many of the MeP variable attributes may be applied to types as well.
6886 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6887 @code{far} attributes may be applied to either.  The @code{io} and
6888 @code{cb} attributes may not be applied to types.
6890 @node PowerPC Type Attributes
6891 @subsection PowerPC Type Attributes
6893 Three attributes currently are defined for PowerPC configurations:
6894 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6896 @cindex @code{ms_struct} type attribute, PowerPC
6897 @cindex @code{gcc_struct} type attribute, PowerPC
6898 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6899 attributes please see the documentation in @ref{x86 Type Attributes}.
6901 @cindex @code{altivec} type attribute, PowerPC
6902 The @code{altivec} attribute allows one to declare AltiVec vector data
6903 types supported by the AltiVec Programming Interface Manual.  The
6904 attribute requires an argument to specify one of three vector types:
6905 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6906 and @code{bool__} (always followed by unsigned).
6908 @smallexample
6909 __attribute__((altivec(vector__)))
6910 __attribute__((altivec(pixel__))) unsigned short
6911 __attribute__((altivec(bool__))) unsigned
6912 @end smallexample
6914 These attributes mainly are intended to support the @code{__vector},
6915 @code{__pixel}, and @code{__bool} AltiVec keywords.
6917 @node SPU Type Attributes
6918 @subsection SPU Type Attributes
6920 @cindex @code{spu_vector} type attribute, SPU
6921 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6922 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6923 Language Extensions Specification.  It is intended to support the
6924 @code{__vector} keyword.
6926 @node x86 Type Attributes
6927 @subsection x86 Type Attributes
6929 Two attributes are currently defined for x86 configurations:
6930 @code{ms_struct} and @code{gcc_struct}.
6932 @table @code
6934 @item ms_struct
6935 @itemx gcc_struct
6936 @cindex @code{ms_struct} type attribute, x86
6937 @cindex @code{gcc_struct} type attribute, x86
6939 If @code{packed} is used on a structure, or if bit-fields are used
6940 it may be that the Microsoft ABI packs them differently
6941 than GCC normally packs them.  Particularly when moving packed
6942 data between functions compiled with GCC and the native Microsoft compiler
6943 (either via function call or as data in a file), it may be necessary to access
6944 either format.
6946 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6947 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6948 command-line options, respectively;
6949 see @ref{x86 Options}, for details of how structure layout is affected.
6950 @xref{x86 Variable Attributes}, for information about the corresponding
6951 attributes on variables.
6953 @end table
6955 @node Label Attributes
6956 @section Label Attributes
6957 @cindex Label Attributes
6959 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
6960 details of the exact syntax for using attributes.  Other attributes are 
6961 available for functions (@pxref{Function Attributes}), variables 
6962 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6963 statements (@pxref{Statement Attributes}), and for types
6964 (@pxref{Type Attributes}).
6966 This example uses the @code{cold} label attribute to indicate the 
6967 @code{ErrorHandling} branch is unlikely to be taken and that the
6968 @code{ErrorHandling} label is unused:
6970 @smallexample
6972    asm goto ("some asm" : : : : NoError);
6974 /* This branch (the fall-through from the asm) is less commonly used */
6975 ErrorHandling: 
6976    __attribute__((cold, unused)); /* Semi-colon is required here */
6977    printf("error\n");
6978    return 0;
6980 NoError:
6981    printf("no error\n");
6982    return 1;
6983 @end smallexample
6985 @table @code
6986 @item unused
6987 @cindex @code{unused} label attribute
6988 This feature is intended for program-generated code that may contain 
6989 unused labels, but which is compiled with @option{-Wall}.  It is
6990 not normally appropriate to use in it human-written code, though it
6991 could be useful in cases where the code that jumps to the label is
6992 contained within an @code{#ifdef} conditional.
6994 @item hot
6995 @cindex @code{hot} label attribute
6996 The @code{hot} attribute on a label is used to inform the compiler that
6997 the path following the label is more likely than paths that are not so
6998 annotated.  This attribute is used in cases where @code{__builtin_expect}
6999 cannot be used, for instance with computed goto or @code{asm goto}.
7001 @item cold
7002 @cindex @code{cold} label attribute
7003 The @code{cold} attribute on labels is used to inform the compiler that
7004 the path following the label is unlikely to be executed.  This attribute
7005 is used in cases where @code{__builtin_expect} cannot be used, for instance
7006 with computed goto or @code{asm goto}.
7008 @end table
7010 @node Enumerator Attributes
7011 @section Enumerator Attributes
7012 @cindex Enumerator Attributes
7014 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7015 details of the exact syntax for using attributes.  Other attributes are
7016 available for functions (@pxref{Function Attributes}), variables
7017 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7018 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7020 This example uses the @code{deprecated} enumerator attribute to indicate the
7021 @code{oldval} enumerator is deprecated:
7023 @smallexample
7024 enum E @{
7025   oldval __attribute__((deprecated)),
7026   newval
7030 fn (void)
7032   return oldval;
7034 @end smallexample
7036 @table @code
7037 @item deprecated
7038 @cindex @code{deprecated} enumerator attribute
7039 The @code{deprecated} attribute results in a warning if the enumerator
7040 is used anywhere in the source file.  This is useful when identifying
7041 enumerators that are expected to be removed in a future version of a
7042 program.  The warning also includes the location of the declaration
7043 of the deprecated enumerator, to enable users to easily find further
7044 information about why the enumerator is deprecated, or what they should
7045 do instead.  Note that the warnings only occurs for uses.
7047 @end table
7049 @node Statement Attributes
7050 @section Statement Attributes
7051 @cindex Statement Attributes
7053 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7054 for details of the exact syntax for using attributes.  Other attributes are
7055 available for functions (@pxref{Function Attributes}), variables
7056 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7057 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7059 This example uses the @code{fallthrough} statement attribute to indicate that
7060 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7062 @smallexample
7063 switch (cond)
7064   @{
7065   case 1:
7066     bar (1);
7067     __attribute__((fallthrough));
7068   case 2:
7069     @dots{}
7070   @}
7071 @end smallexample
7073 @table @code
7074 @item fallthrough
7075 @cindex @code{fallthrough} statement attribute
7076 The @code{fallthrough} attribute with a null statement serves as a
7077 fallthrough statement.  It hints to the compiler that a statement
7078 that falls through to another case label, or user-defined label
7079 in a switch statement is intentional and thus the
7080 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7081 fallthrough attribute may appear at most once in each attribute
7082 list, and may not be mixed with other attributes.  It can only
7083 be used in a switch statement (the compiler will issue an error
7084 otherwise), after a preceding statement and before a logically
7085 succeeding case label, or user-defined label.
7087 @end table
7089 @node Attribute Syntax
7090 @section Attribute Syntax
7091 @cindex attribute syntax
7093 This section describes the syntax with which @code{__attribute__} may be
7094 used, and the constructs to which attribute specifiers bind, for the C
7095 language.  Some details may vary for C++ and Objective-C@.  Because of
7096 infelicities in the grammar for attributes, some forms described here
7097 may not be successfully parsed in all cases.
7099 There are some problems with the semantics of attributes in C++.  For
7100 example, there are no manglings for attributes, although they may affect
7101 code generation, so problems may arise when attributed types are used in
7102 conjunction with templates or overloading.  Similarly, @code{typeid}
7103 does not distinguish between types with different attributes.  Support
7104 for attributes in C++ may be restricted in future to attributes on
7105 declarations only, but not on nested declarators.
7107 @xref{Function Attributes}, for details of the semantics of attributes
7108 applying to functions.  @xref{Variable Attributes}, for details of the
7109 semantics of attributes applying to variables.  @xref{Type Attributes},
7110 for details of the semantics of attributes applying to structure, union
7111 and enumerated types.
7112 @xref{Label Attributes}, for details of the semantics of attributes 
7113 applying to labels.
7114 @xref{Enumerator Attributes}, for details of the semantics of attributes
7115 applying to enumerators.
7116 @xref{Statement Attributes}, for details of the semantics of attributes
7117 applying to statements.
7119 An @dfn{attribute specifier} is of the form
7120 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7121 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7122 each attribute is one of the following:
7124 @itemize @bullet
7125 @item
7126 Empty.  Empty attributes are ignored.
7128 @item
7129 An attribute name
7130 (which may be an identifier such as @code{unused}, or a reserved
7131 word such as @code{const}).
7133 @item
7134 An attribute name followed by a parenthesized list of
7135 parameters for the attribute.
7136 These parameters take one of the following forms:
7138 @itemize @bullet
7139 @item
7140 An identifier.  For example, @code{mode} attributes use this form.
7142 @item
7143 An identifier followed by a comma and a non-empty comma-separated list
7144 of expressions.  For example, @code{format} attributes use this form.
7146 @item
7147 A possibly empty comma-separated list of expressions.  For example,
7148 @code{format_arg} attributes use this form with the list being a single
7149 integer constant expression, and @code{alias} attributes use this form
7150 with the list being a single string constant.
7151 @end itemize
7152 @end itemize
7154 An @dfn{attribute specifier list} is a sequence of one or more attribute
7155 specifiers, not separated by any other tokens.
7157 You may optionally specify attribute names with @samp{__}
7158 preceding and following the name.
7159 This allows you to use them in header files without
7160 being concerned about a possible macro of the same name.  For example,
7161 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7164 @subsubheading Label Attributes
7166 In GNU C, an attribute specifier list may appear after the colon following a
7167 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7168 attributes on labels if the attribute specifier is immediately
7169 followed by a semicolon (i.e., the label applies to an empty
7170 statement).  If the semicolon is missing, C++ label attributes are
7171 ambiguous, as it is permissible for a declaration, which could begin
7172 with an attribute list, to be labelled in C++.  Declarations cannot be
7173 labelled in C90 or C99, so the ambiguity does not arise there.
7175 @subsubheading Enumerator Attributes
7177 In GNU C, an attribute specifier list may appear as part of an enumerator.
7178 The attribute goes after the enumeration constant, before @code{=}, if
7179 present.  The optional attribute in the enumerator appertains to the
7180 enumeration constant.  It is not possible to place the attribute after
7181 the constant expression, if present.
7183 @subsubheading Statement Attributes
7184 In GNU C, an attribute specifier list may appear as part of a null
7185 statement.  The attribute goes before the semicolon.
7187 @subsubheading Type Attributes
7189 An attribute specifier list may appear as part of a @code{struct},
7190 @code{union} or @code{enum} specifier.  It may go either immediately
7191 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7192 the closing brace.  The former syntax is preferred.
7193 Where attribute specifiers follow the closing brace, they are considered
7194 to relate to the structure, union or enumerated type defined, not to any
7195 enclosing declaration the type specifier appears in, and the type
7196 defined is not complete until after the attribute specifiers.
7197 @c Otherwise, there would be the following problems: a shift/reduce
7198 @c conflict between attributes binding the struct/union/enum and
7199 @c binding to the list of specifiers/qualifiers; and "aligned"
7200 @c attributes could use sizeof for the structure, but the size could be
7201 @c changed later by "packed" attributes.
7204 @subsubheading All other attributes
7206 Otherwise, an attribute specifier appears as part of a declaration,
7207 counting declarations of unnamed parameters and type names, and relates
7208 to that declaration (which may be nested in another declaration, for
7209 example in the case of a parameter declaration), or to a particular declarator
7210 within a declaration.  Where an
7211 attribute specifier is applied to a parameter declared as a function or
7212 an array, it should apply to the function or array rather than the
7213 pointer to which the parameter is implicitly converted, but this is not
7214 yet correctly implemented.
7216 Any list of specifiers and qualifiers at the start of a declaration may
7217 contain attribute specifiers, whether or not such a list may in that
7218 context contain storage class specifiers.  (Some attributes, however,
7219 are essentially in the nature of storage class specifiers, and only make
7220 sense where storage class specifiers may be used; for example,
7221 @code{section}.)  There is one necessary limitation to this syntax: the
7222 first old-style parameter declaration in a function definition cannot
7223 begin with an attribute specifier, because such an attribute applies to
7224 the function instead by syntax described below (which, however, is not
7225 yet implemented in this case).  In some other cases, attribute
7226 specifiers are permitted by this grammar but not yet supported by the
7227 compiler.  All attribute specifiers in this place relate to the
7228 declaration as a whole.  In the obsolescent usage where a type of
7229 @code{int} is implied by the absence of type specifiers, such a list of
7230 specifiers and qualifiers may be an attribute specifier list with no
7231 other specifiers or qualifiers.
7233 At present, the first parameter in a function prototype must have some
7234 type specifier that is not an attribute specifier; this resolves an
7235 ambiguity in the interpretation of @code{void f(int
7236 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7237 the parentheses of a function declarator contain only attributes then
7238 those attributes are ignored, rather than yielding an error or warning
7239 or implying a single parameter of type int, but this is subject to
7240 change.
7242 An attribute specifier list may appear immediately before a declarator
7243 (other than the first) in a comma-separated list of declarators in a
7244 declaration of more than one identifier using a single list of
7245 specifiers and qualifiers.  Such attribute specifiers apply
7246 only to the identifier before whose declarator they appear.  For
7247 example, in
7249 @smallexample
7250 __attribute__((noreturn)) void d0 (void),
7251     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7252      d2 (void);
7253 @end smallexample
7255 @noindent
7256 the @code{noreturn} attribute applies to all the functions
7257 declared; the @code{format} attribute only applies to @code{d1}.
7259 An attribute specifier list may appear immediately before the comma,
7260 @code{=} or semicolon terminating the declaration of an identifier other
7261 than a function definition.  Such attribute specifiers apply
7262 to the declared object or function.  Where an
7263 assembler name for an object or function is specified (@pxref{Asm
7264 Labels}), the attribute must follow the @code{asm}
7265 specification.
7267 An attribute specifier list may, in future, be permitted to appear after
7268 the declarator in a function definition (before any old-style parameter
7269 declarations or the function body).
7271 Attribute specifiers may be mixed with type qualifiers appearing inside
7272 the @code{[]} of a parameter array declarator, in the C99 construct by
7273 which such qualifiers are applied to the pointer to which the array is
7274 implicitly converted.  Such attribute specifiers apply to the pointer,
7275 not to the array, but at present this is not implemented and they are
7276 ignored.
7278 An attribute specifier list may appear at the start of a nested
7279 declarator.  At present, there are some limitations in this usage: the
7280 attributes correctly apply to the declarator, but for most individual
7281 attributes the semantics this implies are not implemented.
7282 When attribute specifiers follow the @code{*} of a pointer
7283 declarator, they may be mixed with any type qualifiers present.
7284 The following describes the formal semantics of this syntax.  It makes the
7285 most sense if you are familiar with the formal specification of
7286 declarators in the ISO C standard.
7288 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7289 D1}, where @code{T} contains declaration specifiers that specify a type
7290 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7291 contains an identifier @var{ident}.  The type specified for @var{ident}
7292 for derived declarators whose type does not include an attribute
7293 specifier is as in the ISO C standard.
7295 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7296 and the declaration @code{T D} specifies the type
7297 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7298 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7299 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7301 If @code{D1} has the form @code{*
7302 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7303 declaration @code{T D} specifies the type
7304 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7305 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7306 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7307 @var{ident}.
7309 For example,
7311 @smallexample
7312 void (__attribute__((noreturn)) ****f) (void);
7313 @end smallexample
7315 @noindent
7316 specifies the type ``pointer to pointer to pointer to pointer to
7317 non-returning function returning @code{void}''.  As another example,
7319 @smallexample
7320 char *__attribute__((aligned(8))) *f;
7321 @end smallexample
7323 @noindent
7324 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7325 Note again that this does not work with most attributes; for example,
7326 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7327 is not yet supported.
7329 For compatibility with existing code written for compiler versions that
7330 did not implement attributes on nested declarators, some laxity is
7331 allowed in the placing of attributes.  If an attribute that only applies
7332 to types is applied to a declaration, it is treated as applying to
7333 the type of that declaration.  If an attribute that only applies to
7334 declarations is applied to the type of a declaration, it is treated
7335 as applying to that declaration; and, for compatibility with code
7336 placing the attributes immediately before the identifier declared, such
7337 an attribute applied to a function return type is treated as
7338 applying to the function type, and such an attribute applied to an array
7339 element type is treated as applying to the array type.  If an
7340 attribute that only applies to function types is applied to a
7341 pointer-to-function type, it is treated as applying to the pointer
7342 target type; if such an attribute is applied to a function return type
7343 that is not a pointer-to-function type, it is treated as applying
7344 to the function type.
7346 @node Function Prototypes
7347 @section Prototypes and Old-Style Function Definitions
7348 @cindex function prototype declarations
7349 @cindex old-style function definitions
7350 @cindex promotion of formal parameters
7352 GNU C extends ISO C to allow a function prototype to override a later
7353 old-style non-prototype definition.  Consider the following example:
7355 @smallexample
7356 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7357 #ifdef __STDC__
7358 #define P(x) x
7359 #else
7360 #define P(x) ()
7361 #endif
7363 /* @r{Prototype function declaration.}  */
7364 int isroot P((uid_t));
7366 /* @r{Old-style function definition.}  */
7368 isroot (x)   /* @r{??? lossage here ???} */
7369      uid_t x;
7371   return x == 0;
7373 @end smallexample
7375 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7376 not allow this example, because subword arguments in old-style
7377 non-prototype definitions are promoted.  Therefore in this example the
7378 function definition's argument is really an @code{int}, which does not
7379 match the prototype argument type of @code{short}.
7381 This restriction of ISO C makes it hard to write code that is portable
7382 to traditional C compilers, because the programmer does not know
7383 whether the @code{uid_t} type is @code{short}, @code{int}, or
7384 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7385 to override a later old-style definition.  More precisely, in GNU C, a
7386 function prototype argument type overrides the argument type specified
7387 by a later old-style definition if the former type is the same as the
7388 latter type before promotion.  Thus in GNU C the above example is
7389 equivalent to the following:
7391 @smallexample
7392 int isroot (uid_t);
7395 isroot (uid_t x)
7397   return x == 0;
7399 @end smallexample
7401 @noindent
7402 GNU C++ does not support old-style function definitions, so this
7403 extension is irrelevant.
7405 @node C++ Comments
7406 @section C++ Style Comments
7407 @cindex @code{//}
7408 @cindex C++ comments
7409 @cindex comments, C++ style
7411 In GNU C, you may use C++ style comments, which start with @samp{//} and
7412 continue until the end of the line.  Many other C implementations allow
7413 such comments, and they are included in the 1999 C standard.  However,
7414 C++ style comments are not recognized if you specify an @option{-std}
7415 option specifying a version of ISO C before C99, or @option{-ansi}
7416 (equivalent to @option{-std=c90}).
7418 @node Dollar Signs
7419 @section Dollar Signs in Identifier Names
7420 @cindex $
7421 @cindex dollar signs in identifier names
7422 @cindex identifier names, dollar signs in
7424 In GNU C, you may normally use dollar signs in identifier names.
7425 This is because many traditional C implementations allow such identifiers.
7426 However, dollar signs in identifiers are not supported on a few target
7427 machines, typically because the target assembler does not allow them.
7429 @node Character Escapes
7430 @section The Character @key{ESC} in Constants
7432 You can use the sequence @samp{\e} in a string or character constant to
7433 stand for the ASCII character @key{ESC}.
7435 @node Alignment
7436 @section Inquiring on Alignment of Types or Variables
7437 @cindex alignment
7438 @cindex type alignment
7439 @cindex variable alignment
7441 The keyword @code{__alignof__} allows you to inquire about how an object
7442 is aligned, or the minimum alignment usually required by a type.  Its
7443 syntax is just like @code{sizeof}.
7445 For example, if the target machine requires a @code{double} value to be
7446 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7447 This is true on many RISC machines.  On more traditional machine
7448 designs, @code{__alignof__ (double)} is 4 or even 2.
7450 Some machines never actually require alignment; they allow reference to any
7451 data type even at an odd address.  For these machines, @code{__alignof__}
7452 reports the smallest alignment that GCC gives the data type, usually as
7453 mandated by the target ABI.
7455 If the operand of @code{__alignof__} is an lvalue rather than a type,
7456 its value is the required alignment for its type, taking into account
7457 any minimum alignment specified with GCC's @code{__attribute__}
7458 extension (@pxref{Variable Attributes}).  For example, after this
7459 declaration:
7461 @smallexample
7462 struct foo @{ int x; char y; @} foo1;
7463 @end smallexample
7465 @noindent
7466 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7467 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7469 It is an error to ask for the alignment of an incomplete type.
7472 @node Inline
7473 @section An Inline Function is As Fast As a Macro
7474 @cindex inline functions
7475 @cindex integrating function code
7476 @cindex open coding
7477 @cindex macros, inline alternative
7479 By declaring a function inline, you can direct GCC to make
7480 calls to that function faster.  One way GCC can achieve this is to
7481 integrate that function's code into the code for its callers.  This
7482 makes execution faster by eliminating the function-call overhead; in
7483 addition, if any of the actual argument values are constant, their
7484 known values may permit simplifications at compile time so that not
7485 all of the inline function's code needs to be included.  The effect on
7486 code size is less predictable; object code may be larger or smaller
7487 with function inlining, depending on the particular case.  You can
7488 also direct GCC to try to integrate all ``simple enough'' functions
7489 into their callers with the option @option{-finline-functions}.
7491 GCC implements three different semantics of declaring a function
7492 inline.  One is available with @option{-std=gnu89} or
7493 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7494 on all inline declarations, another when
7495 @option{-std=c99}, @option{-std=c11},
7496 @option{-std=gnu99} or @option{-std=gnu11}
7497 (without @option{-fgnu89-inline}), and the third
7498 is used when compiling C++.
7500 To declare a function inline, use the @code{inline} keyword in its
7501 declaration, like this:
7503 @smallexample
7504 static inline int
7505 inc (int *a)
7507   return (*a)++;
7509 @end smallexample
7511 If you are writing a header file to be included in ISO C90 programs, write
7512 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7514 The three types of inlining behave similarly in two important cases:
7515 when the @code{inline} keyword is used on a @code{static} function,
7516 like the example above, and when a function is first declared without
7517 using the @code{inline} keyword and then is defined with
7518 @code{inline}, like this:
7520 @smallexample
7521 extern int inc (int *a);
7522 inline int
7523 inc (int *a)
7525   return (*a)++;
7527 @end smallexample
7529 In both of these common cases, the program behaves the same as if you
7530 had not used the @code{inline} keyword, except for its speed.
7532 @cindex inline functions, omission of
7533 @opindex fkeep-inline-functions
7534 When a function is both inline and @code{static}, if all calls to the
7535 function are integrated into the caller, and the function's address is
7536 never used, then the function's own assembler code is never referenced.
7537 In this case, GCC does not actually output assembler code for the
7538 function, unless you specify the option @option{-fkeep-inline-functions}.
7539 If there is a nonintegrated call, then the function is compiled to
7540 assembler code as usual.  The function must also be compiled as usual if
7541 the program refers to its address, because that cannot be inlined.
7543 @opindex Winline
7544 Note that certain usages in a function definition can make it unsuitable
7545 for inline substitution.  Among these usages are: variadic functions,
7546 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7547 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7548 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7549 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7550 function marked @code{inline} could not be substituted, and gives the
7551 reason for the failure.
7553 @cindex automatic @code{inline} for C++ member fns
7554 @cindex @code{inline} automatic for C++ member fns
7555 @cindex member fns, automatically @code{inline}
7556 @cindex C++ member fns, automatically @code{inline}
7557 @opindex fno-default-inline
7558 As required by ISO C++, GCC considers member functions defined within
7559 the body of a class to be marked inline even if they are
7560 not explicitly declared with the @code{inline} keyword.  You can
7561 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7562 Options,,Options Controlling C++ Dialect}.
7564 GCC does not inline any functions when not optimizing unless you specify
7565 the @samp{always_inline} attribute for the function, like this:
7567 @smallexample
7568 /* @r{Prototype.}  */
7569 inline void foo (const char) __attribute__((always_inline));
7570 @end smallexample
7572 The remainder of this section is specific to GNU C90 inlining.
7574 @cindex non-static inline function
7575 When an inline function is not @code{static}, then the compiler must assume
7576 that there may be calls from other source files; since a global symbol can
7577 be defined only once in any program, the function must not be defined in
7578 the other source files, so the calls therein cannot be integrated.
7579 Therefore, a non-@code{static} inline function is always compiled on its
7580 own in the usual fashion.
7582 If you specify both @code{inline} and @code{extern} in the function
7583 definition, then the definition is used only for inlining.  In no case
7584 is the function compiled on its own, not even if you refer to its
7585 address explicitly.  Such an address becomes an external reference, as
7586 if you had only declared the function, and had not defined it.
7588 This combination of @code{inline} and @code{extern} has almost the
7589 effect of a macro.  The way to use it is to put a function definition in
7590 a header file with these keywords, and put another copy of the
7591 definition (lacking @code{inline} and @code{extern}) in a library file.
7592 The definition in the header file causes most calls to the function
7593 to be inlined.  If any uses of the function remain, they refer to
7594 the single copy in the library.
7596 @node Volatiles
7597 @section When is a Volatile Object Accessed?
7598 @cindex accessing volatiles
7599 @cindex volatile read
7600 @cindex volatile write
7601 @cindex volatile access
7603 C has the concept of volatile objects.  These are normally accessed by
7604 pointers and used for accessing hardware or inter-thread
7605 communication.  The standard encourages compilers to refrain from
7606 optimizations concerning accesses to volatile objects, but leaves it
7607 implementation defined as to what constitutes a volatile access.  The
7608 minimum requirement is that at a sequence point all previous accesses
7609 to volatile objects have stabilized and no subsequent accesses have
7610 occurred.  Thus an implementation is free to reorder and combine
7611 volatile accesses that occur between sequence points, but cannot do
7612 so for accesses across a sequence point.  The use of volatile does
7613 not allow you to violate the restriction on updating objects multiple
7614 times between two sequence points.
7616 Accesses to non-volatile objects are not ordered with respect to
7617 volatile accesses.  You cannot use a volatile object as a memory
7618 barrier to order a sequence of writes to non-volatile memory.  For
7619 instance:
7621 @smallexample
7622 int *ptr = @var{something};
7623 volatile int vobj;
7624 *ptr = @var{something};
7625 vobj = 1;
7626 @end smallexample
7628 @noindent
7629 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7630 that the write to @var{*ptr} occurs by the time the update
7631 of @var{vobj} happens.  If you need this guarantee, you must use
7632 a stronger memory barrier such as:
7634 @smallexample
7635 int *ptr = @var{something};
7636 volatile int vobj;
7637 *ptr = @var{something};
7638 asm volatile ("" : : : "memory");
7639 vobj = 1;
7640 @end smallexample
7642 A scalar volatile object is read when it is accessed in a void context:
7644 @smallexample
7645 volatile int *src = @var{somevalue};
7646 *src;
7647 @end smallexample
7649 Such expressions are rvalues, and GCC implements this as a
7650 read of the volatile object being pointed to.
7652 Assignments are also expressions and have an rvalue.  However when
7653 assigning to a scalar volatile, the volatile object is not reread,
7654 regardless of whether the assignment expression's rvalue is used or
7655 not.  If the assignment's rvalue is used, the value is that assigned
7656 to the volatile object.  For instance, there is no read of @var{vobj}
7657 in all the following cases:
7659 @smallexample
7660 int obj;
7661 volatile int vobj;
7662 vobj = @var{something};
7663 obj = vobj = @var{something};
7664 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7665 obj = (@var{something}, vobj = @var{anotherthing});
7666 @end smallexample
7668 If you need to read the volatile object after an assignment has
7669 occurred, you must use a separate expression with an intervening
7670 sequence point.
7672 As bit-fields are not individually addressable, volatile bit-fields may
7673 be implicitly read when written to, or when adjacent bit-fields are
7674 accessed.  Bit-field operations may be optimized such that adjacent
7675 bit-fields are only partially accessed, if they straddle a storage unit
7676 boundary.  For these reasons it is unwise to use volatile bit-fields to
7677 access hardware.
7679 @node Using Assembly Language with C
7680 @section How to Use Inline Assembly Language in C Code
7681 @cindex @code{asm} keyword
7682 @cindex assembly language in C
7683 @cindex inline assembly language
7684 @cindex mixing assembly language and C
7686 The @code{asm} keyword allows you to embed assembler instructions
7687 within C code.  GCC provides two forms of inline @code{asm}
7688 statements.  A @dfn{basic @code{asm}} statement is one with no
7689 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7690 statement (@pxref{Extended Asm}) includes one or more operands.  
7691 The extended form is preferred for mixing C and assembly language
7692 within a function, but to include assembly language at
7693 top level you must use basic @code{asm}.
7695 You can also use the @code{asm} keyword to override the assembler name
7696 for a C symbol, or to place a C variable in a specific register.
7698 @menu
7699 * Basic Asm::          Inline assembler without operands.
7700 * Extended Asm::       Inline assembler with operands.
7701 * Constraints::        Constraints for @code{asm} operands
7702 * Asm Labels::         Specifying the assembler name to use for a C symbol.
7703 * Explicit Register Variables::  Defining variables residing in specified 
7704                        registers.
7705 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
7706 @end menu
7708 @node Basic Asm
7709 @subsection Basic Asm --- Assembler Instructions Without Operands
7710 @cindex basic @code{asm}
7711 @cindex assembly language in C, basic
7713 A basic @code{asm} statement has the following syntax:
7715 @example
7716 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7717 @end example
7719 The @code{asm} keyword is a GNU extension.
7720 When writing code that can be compiled with @option{-ansi} and the
7721 various @option{-std} options, use @code{__asm__} instead of 
7722 @code{asm} (@pxref{Alternate Keywords}).
7724 @subsubheading Qualifiers
7725 @table @code
7726 @item volatile
7727 The optional @code{volatile} qualifier has no effect. 
7728 All basic @code{asm} blocks are implicitly volatile.
7729 @end table
7731 @subsubheading Parameters
7732 @table @var
7734 @item AssemblerInstructions
7735 This is a literal string that specifies the assembler code. The string can 
7736 contain any instructions recognized by the assembler, including directives. 
7737 GCC does not parse the assembler instructions themselves and 
7738 does not know what they mean or even whether they are valid assembler input. 
7740 You may place multiple assembler instructions together in a single @code{asm} 
7741 string, separated by the characters normally used in assembly code for the 
7742 system. A combination that works in most places is a newline to break the 
7743 line, plus a tab character (written as @samp{\n\t}).
7744 Some assemblers allow semicolons as a line separator. However, 
7745 note that some assembler dialects use semicolons to start a comment. 
7746 @end table
7748 @subsubheading Remarks
7749 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7750 smaller, safer, and more efficient code, and in most cases it is a
7751 better solution than basic @code{asm}.  However, there are two
7752 situations where only basic @code{asm} can be used:
7754 @itemize @bullet
7755 @item
7756 Extended @code{asm} statements have to be inside a C
7757 function, so to write inline assembly language at file scope (``top-level''),
7758 outside of C functions, you must use basic @code{asm}.
7759 You can use this technique to emit assembler directives,
7760 define assembly language macros that can be invoked elsewhere in the file,
7761 or write entire functions in assembly language.
7763 @item
7764 Functions declared
7765 with the @code{naked} attribute also require basic @code{asm}
7766 (@pxref{Function Attributes}).
7767 @end itemize
7769 Safely accessing C data and calling functions from basic @code{asm} is more 
7770 complex than it may appear. To access C data, it is better to use extended 
7771 @code{asm}.
7773 Do not expect a sequence of @code{asm} statements to remain perfectly 
7774 consecutive after compilation. If certain instructions need to remain 
7775 consecutive in the output, put them in a single multi-instruction @code{asm}
7776 statement. Note that GCC's optimizers can move @code{asm} statements 
7777 relative to other code, including across jumps.
7779 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7780 GCC does not know about these jumps, and therefore cannot take 
7781 account of them when deciding how to optimize. Jumps from @code{asm} to C 
7782 labels are only supported in extended @code{asm}.
7784 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7785 assembly code when optimizing. This can lead to unexpected duplicate 
7786 symbol errors during compilation if your assembly code defines symbols or 
7787 labels.
7789 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7790 making it a potential source of incompatibilities between compilers.  These
7791 incompatibilities may not produce compiler warnings/errors.
7793 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7794 means there is no way to communicate to the compiler what is happening
7795 inside them.  GCC has no visibility of symbols in the @code{asm} and may
7796 discard them as unreferenced.  It also does not know about side effects of
7797 the assembler code, such as modifications to memory or registers.  Unlike
7798 some compilers, GCC assumes that no changes to general purpose registers
7799 occur.  This assumption may change in a future release.
7801 To avoid complications from future changes to the semantics and the
7802 compatibility issues between compilers, consider replacing basic @code{asm}
7803 with extended @code{asm}.  See
7804 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7805 from basic asm to extended asm} for information about how to perform this
7806 conversion.
7808 The compiler copies the assembler instructions in a basic @code{asm} 
7809 verbatim to the assembly language output file, without 
7810 processing dialects or any of the @samp{%} operators that are available with
7811 extended @code{asm}. This results in minor differences between basic 
7812 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7813 registers you might use @samp{%eax} in basic @code{asm} and
7814 @samp{%%eax} in extended @code{asm}.
7816 On targets such as x86 that support multiple assembler dialects,
7817 all basic @code{asm} blocks use the assembler dialect specified by the 
7818 @option{-masm} command-line option (@pxref{x86 Options}).  
7819 Basic @code{asm} provides no
7820 mechanism to provide different assembler strings for different dialects.
7822 For basic @code{asm} with non-empty assembler string GCC assumes
7823 the assembler block does not change any general purpose registers,
7824 but it may read or write any globally accessible variable.
7826 Here is an example of basic @code{asm} for i386:
7828 @example
7829 /* Note that this code will not compile with -masm=intel */
7830 #define DebugBreak() asm("int $3")
7831 @end example
7833 @node Extended Asm
7834 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7835 @cindex extended @code{asm}
7836 @cindex assembly language in C, extended
7838 With extended @code{asm} you can read and write C variables from 
7839 assembler and perform jumps from assembler code to C labels.  
7840 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7841 the operand parameters after the assembler template:
7843 @example
7844 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7845                  : @var{OutputOperands} 
7846                  @r{[} : @var{InputOperands}
7847                  @r{[} : @var{Clobbers} @r{]} @r{]})
7849 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7850                       : 
7851                       : @var{InputOperands}
7852                       : @var{Clobbers}
7853                       : @var{GotoLabels})
7854 @end example
7856 The @code{asm} keyword is a GNU extension.
7857 When writing code that can be compiled with @option{-ansi} and the
7858 various @option{-std} options, use @code{__asm__} instead of 
7859 @code{asm} (@pxref{Alternate Keywords}).
7861 @subsubheading Qualifiers
7862 @table @code
7864 @item volatile
7865 The typical use of extended @code{asm} statements is to manipulate input 
7866 values to produce output values. However, your @code{asm} statements may 
7867 also produce side effects. If so, you may need to use the @code{volatile} 
7868 qualifier to disable certain optimizations. @xref{Volatile}.
7870 @item goto
7871 This qualifier informs the compiler that the @code{asm} statement may 
7872 perform a jump to one of the labels listed in the @var{GotoLabels}.
7873 @xref{GotoLabels}.
7874 @end table
7876 @subsubheading Parameters
7877 @table @var
7878 @item AssemblerTemplate
7879 This is a literal string that is the template for the assembler code. It is a 
7880 combination of fixed text and tokens that refer to the input, output, 
7881 and goto parameters. @xref{AssemblerTemplate}.
7883 @item OutputOperands
7884 A comma-separated list of the C variables modified by the instructions in the 
7885 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7887 @item InputOperands
7888 A comma-separated list of C expressions read by the instructions in the 
7889 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7891 @item Clobbers
7892 A comma-separated list of registers or other values changed by the 
7893 @var{AssemblerTemplate}, beyond those listed as outputs.
7894 An empty list is permitted.  @xref{Clobbers}.
7896 @item GotoLabels
7897 When you are using the @code{goto} form of @code{asm}, this section contains 
7898 the list of all C labels to which the code in the 
7899 @var{AssemblerTemplate} may jump. 
7900 @xref{GotoLabels}.
7902 @code{asm} statements may not perform jumps into other @code{asm} statements,
7903 only to the listed @var{GotoLabels}.
7904 GCC's optimizers do not know about other jumps; therefore they cannot take 
7905 account of them when deciding how to optimize.
7906 @end table
7908 The total number of input + output + goto operands is limited to 30.
7910 @subsubheading Remarks
7911 The @code{asm} statement allows you to include assembly instructions directly 
7912 within C code. This may help you to maximize performance in time-sensitive 
7913 code or to access assembly instructions that are not readily available to C 
7914 programs.
7916 Note that extended @code{asm} statements must be inside a function. Only 
7917 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7918 Functions declared with the @code{naked} attribute also require basic 
7919 @code{asm} (@pxref{Function Attributes}).
7921 While the uses of @code{asm} are many and varied, it may help to think of an 
7922 @code{asm} statement as a series of low-level instructions that convert input 
7923 parameters to output parameters. So a simple (if not particularly useful) 
7924 example for i386 using @code{asm} might look like this:
7926 @example
7927 int src = 1;
7928 int dst;   
7930 asm ("mov %1, %0\n\t"
7931     "add $1, %0"
7932     : "=r" (dst) 
7933     : "r" (src));
7935 printf("%d\n", dst);
7936 @end example
7938 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7940 @anchor{Volatile}
7941 @subsubsection Volatile
7942 @cindex volatile @code{asm}
7943 @cindex @code{asm} volatile
7945 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7946 there is no need for the output variables. Also, the optimizers may move 
7947 code out of loops if they believe that the code will always return the same 
7948 result (i.e. none of its input values change between calls). Using the 
7949 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7950 that have no output operands, including @code{asm goto} statements, 
7951 are implicitly volatile.
7953 This i386 code demonstrates a case that does not use (or require) the 
7954 @code{volatile} qualifier. If it is performing assertion checking, this code 
7955 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7956 unreferenced by any code. As a result, the optimizers can discard the 
7957 @code{asm} statement, which in turn removes the need for the entire 
7958 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7959 isn't needed you allow the optimizers to produce the most efficient code 
7960 possible.
7962 @example
7963 void DoCheck(uint32_t dwSomeValue)
7965    uint32_t dwRes;
7967    // Assumes dwSomeValue is not zero.
7968    asm ("bsfl %1,%0"
7969      : "=r" (dwRes)
7970      : "r" (dwSomeValue)
7971      : "cc");
7973    assert(dwRes > 3);
7975 @end example
7977 The next example shows a case where the optimizers can recognize that the input 
7978 (@code{dwSomeValue}) never changes during the execution of the function and can 
7979 therefore move the @code{asm} outside the loop to produce more efficient code. 
7980 Again, using @code{volatile} disables this type of optimization.
7982 @example
7983 void do_print(uint32_t dwSomeValue)
7985    uint32_t dwRes;
7987    for (uint32_t x=0; x < 5; x++)
7988    @{
7989       // Assumes dwSomeValue is not zero.
7990       asm ("bsfl %1,%0"
7991         : "=r" (dwRes)
7992         : "r" (dwSomeValue)
7993         : "cc");
7995       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7996    @}
7998 @end example
8000 The following example demonstrates a case where you need to use the 
8001 @code{volatile} qualifier. 
8002 It uses the x86 @code{rdtsc} instruction, which reads 
8003 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8004 the optimizers might assume that the @code{asm} block will always return the 
8005 same value and therefore optimize away the second call.
8007 @example
8008 uint64_t msr;
8010 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8011         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8012         "or %%rdx, %0"        // 'Or' in the lower bits.
8013         : "=a" (msr)
8014         : 
8015         : "rdx");
8017 printf("msr: %llx\n", msr);
8019 // Do other work...
8021 // Reprint the timestamp
8022 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8023         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8024         "or %%rdx, %0"        // 'Or' in the lower bits.
8025         : "=a" (msr)
8026         : 
8027         : "rdx");
8029 printf("msr: %llx\n", msr);
8030 @end example
8032 GCC's optimizers do not treat this code like the non-volatile code in the 
8033 earlier examples. They do not move it out of loops or omit it on the 
8034 assumption that the result from a previous call is still valid.
8036 Note that the compiler can move even volatile @code{asm} instructions relative 
8037 to other code, including across jump instructions. For example, on many 
8038 targets there is a system register that controls the rounding mode of 
8039 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8040 following PowerPC example, does not work reliably.
8042 @example
8043 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8044 sum = x + y;
8045 @end example
8047 The compiler may move the addition back before the volatile @code{asm}. To 
8048 make it work as expected, add an artificial dependency to the @code{asm} by 
8049 referencing a variable in the subsequent code, for example: 
8051 @example
8052 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8053 sum = x + y;
8054 @end example
8056 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8057 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8058 errors during compilation if your asm code defines symbols or labels. 
8059 Using @samp{%=} 
8060 (@pxref{AssemblerTemplate}) may help resolve this problem.
8062 @anchor{AssemblerTemplate}
8063 @subsubsection Assembler Template
8064 @cindex @code{asm} assembler template
8066 An assembler template is a literal string containing assembler instructions.
8067 The compiler replaces tokens in the template that refer 
8068 to inputs, outputs, and goto labels,
8069 and then outputs the resulting string to the assembler. The 
8070 string can contain any instructions recognized by the assembler, including 
8071 directives. GCC does not parse the assembler instructions 
8072 themselves and does not know what they mean or even whether they are valid 
8073 assembler input. However, it does count the statements 
8074 (@pxref{Size of an asm}).
8076 You may place multiple assembler instructions together in a single @code{asm} 
8077 string, separated by the characters normally used in assembly code for the 
8078 system. A combination that works in most places is a newline to break the 
8079 line, plus a tab character to move to the instruction field (written as 
8080 @samp{\n\t}). 
8081 Some assemblers allow semicolons as a line separator. However, note 
8082 that some assembler dialects use semicolons to start a comment. 
8084 Do not expect a sequence of @code{asm} statements to remain perfectly 
8085 consecutive after compilation, even when you are using the @code{volatile} 
8086 qualifier. If certain instructions need to remain consecutive in the output, 
8087 put them in a single multi-instruction asm statement.
8089 Accessing data from C programs without using input/output operands (such as 
8090 by using global symbols directly from the assembler template) may not work as 
8091 expected. Similarly, calling functions directly from an assembler template 
8092 requires a detailed understanding of the target assembler and ABI.
8094 Since GCC does not parse the assembler template,
8095 it has no visibility of any 
8096 symbols it references. This may result in GCC discarding those symbols as 
8097 unreferenced unless they are also listed as input, output, or goto operands.
8099 @subsubheading Special format strings
8101 In addition to the tokens described by the input, output, and goto operands, 
8102 these tokens have special meanings in the assembler template:
8104 @table @samp
8105 @item %% 
8106 Outputs a single @samp{%} into the assembler code.
8108 @item %= 
8109 Outputs a number that is unique to each instance of the @code{asm} 
8110 statement in the entire compilation. This option is useful when creating local 
8111 labels and referring to them multiple times in a single template that 
8112 generates multiple assembler instructions. 
8114 @item %@{
8115 @itemx %|
8116 @itemx %@}
8117 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8118 into the assembler code.  When unescaped, these characters have special
8119 meaning to indicate multiple assembler dialects, as described below.
8120 @end table
8122 @subsubheading Multiple assembler dialects in @code{asm} templates
8124 On targets such as x86, GCC supports multiple assembler dialects.
8125 The @option{-masm} option controls which dialect GCC uses as its 
8126 default for inline assembler. The target-specific documentation for the 
8127 @option{-masm} option contains the list of supported dialects, as well as the 
8128 default dialect if the option is not specified. This information may be 
8129 important to understand, since assembler code that works correctly when 
8130 compiled using one dialect will likely fail if compiled using another.
8131 @xref{x86 Options}.
8133 If your code needs to support multiple assembler dialects (for example, if 
8134 you are writing public headers that need to support a variety of compilation 
8135 options), use constructs of this form:
8137 @example
8138 @{ dialect0 | dialect1 | dialect2... @}
8139 @end example
8141 This construct outputs @code{dialect0} 
8142 when using dialect #0 to compile the code, 
8143 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8144 braces than the number of dialects the compiler supports, the construct 
8145 outputs nothing.
8147 For example, if an x86 compiler supports two dialects
8148 (@samp{att}, @samp{intel}), an 
8149 assembler template such as this:
8151 @example
8152 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8153 @end example
8155 @noindent
8156 is equivalent to one of
8158 @example
8159 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8160 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8161 @end example
8163 Using that same compiler, this code:
8165 @example
8166 "xchg@{l@}\t@{%%@}ebx, %1"
8167 @end example
8169 @noindent
8170 corresponds to either
8172 @example
8173 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8174 "xchg\tebx, %1"                    @r{/* intel dialect */}
8175 @end example
8177 There is no support for nesting dialect alternatives.
8179 @anchor{OutputOperands}
8180 @subsubsection Output Operands
8181 @cindex @code{asm} output operands
8183 An @code{asm} statement has zero or more output operands indicating the names
8184 of C variables modified by the assembler code.
8186 In this i386 example, @code{old} (referred to in the template string as 
8187 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8188 (@code{%2}) is an input:
8190 @example
8191 bool old;
8193 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8194          "sbb %0,%0"      // Use the CF to calculate old.
8195    : "=r" (old), "+rm" (*Base)
8196    : "Ir" (Offset)
8197    : "cc");
8199 return old;
8200 @end example
8202 Operands are separated by commas.  Each operand has this format:
8204 @example
8205 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8206 @end example
8208 @table @var
8209 @item asmSymbolicName
8210 Specifies a symbolic name for the operand.
8211 Reference the name in the assembler template 
8212 by enclosing it in square brackets 
8213 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8214 that contains the definition. Any valid C variable name is acceptable, 
8215 including names already defined in the surrounding code. No two operands 
8216 within the same @code{asm} statement can use the same symbolic name.
8218 When not using an @var{asmSymbolicName}, use the (zero-based) position
8219 of the operand 
8220 in the list of operands in the assembler template. For example if there are 
8221 three output operands, use @samp{%0} in the template to refer to the first, 
8222 @samp{%1} for the second, and @samp{%2} for the third. 
8224 @item constraint
8225 A string constant specifying constraints on the placement of the operand; 
8226 @xref{Constraints}, for details.
8228 Output constraints must begin with either @samp{=} (a variable overwriting an 
8229 existing value) or @samp{+} (when reading and writing). When using 
8230 @samp{=}, do not assume the location contains the existing value
8231 on entry to the @code{asm}, except 
8232 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8234 After the prefix, there must be one or more additional constraints 
8235 (@pxref{Constraints}) that describe where the value resides. Common 
8236 constraints include @samp{r} for register and @samp{m} for memory. 
8237 When you list more than one possible location (for example, @code{"=rm"}),
8238 the compiler chooses the most efficient one based on the current context. 
8239 If you list as many alternates as the @code{asm} statement allows, you permit 
8240 the optimizers to produce the best possible code. 
8241 If you must use a specific register, but your Machine Constraints do not
8242 provide sufficient control to select the specific register you want, 
8243 local register variables may provide a solution (@pxref{Local Register 
8244 Variables}).
8246 @item cvariablename
8247 Specifies a C lvalue expression to hold the output, typically a variable name.
8248 The enclosing parentheses are a required part of the syntax.
8250 @end table
8252 When the compiler selects the registers to use to 
8253 represent the output operands, it does not use any of the clobbered registers 
8254 (@pxref{Clobbers}).
8256 Output operand expressions must be lvalues. The compiler cannot check whether 
8257 the operands have data types that are reasonable for the instruction being 
8258 executed. For output expressions that are not directly addressable (for 
8259 example a bit-field), the constraint must allow a register. In that case, GCC 
8260 uses the register as the output of the @code{asm}, and then stores that 
8261 register into the output. 
8263 Operands using the @samp{+} constraint modifier count as two operands 
8264 (that is, both as input and output) towards the total maximum of 30 operands
8265 per @code{asm} statement.
8267 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8268 operands that must not overlap an input.  Otherwise, 
8269 GCC may allocate the output operand in the same register as an unrelated 
8270 input operand, on the assumption that the assembler code consumes its 
8271 inputs before producing outputs. This assumption may be false if the assembler 
8272 code actually consists of more than one instruction.
8274 The same problem can occur if one output parameter (@var{a}) allows a register 
8275 constraint and another output parameter (@var{b}) allows a memory constraint.
8276 The code generated by GCC to access the memory address in @var{b} can contain
8277 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8278 registers to be inputs to the asm. As above, GCC assumes that such input
8279 registers are consumed before any outputs are written. This assumption may 
8280 result in incorrect behavior if the asm writes to @var{a} before using 
8281 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8282 ensures that modifying @var{a} does not affect the address referenced by 
8283 @var{b}. Otherwise, the location of @var{b} 
8284 is undefined if @var{a} is modified before using @var{b}.
8286 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8287 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8288 dependent. The list of supported modifiers for x86 is found at 
8289 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8291 If the C code that follows the @code{asm} makes no use of any of the output 
8292 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8293 optimizers from discarding the @code{asm} statement as unneeded 
8294 (see @ref{Volatile}).
8296 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8297 references the first output operand as @code{%0} (were there a second, it 
8298 would be @code{%1}, etc). The number of the first input operand is one greater 
8299 than that of the last output operand. In this i386 example, that makes 
8300 @code{Mask} referenced as @code{%1}:
8302 @example
8303 uint32_t Mask = 1234;
8304 uint32_t Index;
8306   asm ("bsfl %1, %0"
8307      : "=r" (Index)
8308      : "r" (Mask)
8309      : "cc");
8310 @end example
8312 That code overwrites the variable @code{Index} (@samp{=}),
8313 placing the value in a register (@samp{r}).
8314 Using the generic @samp{r} constraint instead of a constraint for a specific 
8315 register allows the compiler to pick the register to use, which can result 
8316 in more efficient code. This may not be possible if an assembler instruction 
8317 requires a specific register.
8319 The following i386 example uses the @var{asmSymbolicName} syntax.
8320 It produces the 
8321 same result as the code above, but some may consider it more readable or more 
8322 maintainable since reordering index numbers is not necessary when adding or 
8323 removing operands. The names @code{aIndex} and @code{aMask}
8324 are only used in this example to emphasize which 
8325 names get used where.
8326 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8328 @example
8329 uint32_t Mask = 1234;
8330 uint32_t Index;
8332   asm ("bsfl %[aMask], %[aIndex]"
8333      : [aIndex] "=r" (Index)
8334      : [aMask] "r" (Mask)
8335      : "cc");
8336 @end example
8338 Here are some more examples of output operands.
8340 @example
8341 uint32_t c = 1;
8342 uint32_t d;
8343 uint32_t *e = &c;
8345 asm ("mov %[e], %[d]"
8346    : [d] "=rm" (d)
8347    : [e] "rm" (*e));
8348 @end example
8350 Here, @code{d} may either be in a register or in memory. Since the compiler 
8351 might already have the current value of the @code{uint32_t} location
8352 pointed to by @code{e}
8353 in a register, you can enable it to choose the best location
8354 for @code{d} by specifying both constraints.
8356 @anchor{FlagOutputOperands}
8357 @subsubsection Flag Output Operands
8358 @cindex @code{asm} flag output operands
8360 Some targets have a special register that holds the ``flags'' for the
8361 result of an operation or comparison.  Normally, the contents of that
8362 register are either unmodifed by the asm, or the asm is considered to
8363 clobber the contents.
8365 On some targets, a special form of output operand exists by which
8366 conditions in the flags register may be outputs of the asm.  The set of
8367 conditions supported are target specific, but the general rule is that
8368 the output variable must be a scalar integer, and the value is boolean.
8369 When supported, the target defines the preprocessor symbol
8370 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8372 Because of the special nature of the flag output operands, the constraint
8373 may not include alternatives.
8375 Most often, the target has only one flags register, and thus is an implied
8376 operand of many instructions.  In this case, the operand should not be
8377 referenced within the assembler template via @code{%0} etc, as there's
8378 no corresponding text in the assembly language.
8380 @table @asis
8381 @item x86 family
8382 The flag output constraints for the x86 family are of the form
8383 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8384 conditions defined in the ISA manual for @code{j@var{cc}} or
8385 @code{set@var{cc}}.
8387 @table @code
8388 @item a
8389 ``above'' or unsigned greater than
8390 @item ae
8391 ``above or equal'' or unsigned greater than or equal
8392 @item b
8393 ``below'' or unsigned less than
8394 @item be
8395 ``below or equal'' or unsigned less than or equal
8396 @item c
8397 carry flag set
8398 @item e
8399 @itemx z
8400 ``equal'' or zero flag set
8401 @item g
8402 signed greater than
8403 @item ge
8404 signed greater than or equal
8405 @item l
8406 signed less than
8407 @item le
8408 signed less than or equal
8409 @item o
8410 overflow flag set
8411 @item p
8412 parity flag set
8413 @item s
8414 sign flag set
8415 @item na
8416 @itemx nae
8417 @itemx nb
8418 @itemx nbe
8419 @itemx nc
8420 @itemx ne
8421 @itemx ng
8422 @itemx nge
8423 @itemx nl
8424 @itemx nle
8425 @itemx no
8426 @itemx np
8427 @itemx ns
8428 @itemx nz
8429 ``not'' @var{flag}, or inverted versions of those above
8430 @end table
8432 @end table
8434 @anchor{InputOperands}
8435 @subsubsection Input Operands
8436 @cindex @code{asm} input operands
8437 @cindex @code{asm} expressions
8439 Input operands make values from C variables and expressions available to the 
8440 assembly code.
8442 Operands are separated by commas.  Each operand has this format:
8444 @example
8445 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8446 @end example
8448 @table @var
8449 @item asmSymbolicName
8450 Specifies a symbolic name for the operand.
8451 Reference the name in the assembler template 
8452 by enclosing it in square brackets 
8453 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8454 that contains the definition. Any valid C variable name is acceptable, 
8455 including names already defined in the surrounding code. No two operands 
8456 within the same @code{asm} statement can use the same symbolic name.
8458 When not using an @var{asmSymbolicName}, use the (zero-based) position
8459 of the operand 
8460 in the list of operands in the assembler template. For example if there are
8461 two output operands and three inputs,
8462 use @samp{%2} in the template to refer to the first input operand,
8463 @samp{%3} for the second, and @samp{%4} for the third. 
8465 @item constraint
8466 A string constant specifying constraints on the placement of the operand; 
8467 @xref{Constraints}, for details.
8469 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8470 When you list more than one possible location (for example, @samp{"irm"}), 
8471 the compiler chooses the most efficient one based on the current context.
8472 If you must use a specific register, but your Machine Constraints do not
8473 provide sufficient control to select the specific register you want, 
8474 local register variables may provide a solution (@pxref{Local Register 
8475 Variables}).
8477 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8478 that the specified input must be in the same place as the output constraint 
8479 at the (zero-based) index in the output constraint list. 
8480 When using @var{asmSymbolicName} syntax for the output operands,
8481 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8483 @item cexpression
8484 This is the C variable or expression being passed to the @code{asm} statement 
8485 as input.  The enclosing parentheses are a required part of the syntax.
8487 @end table
8489 When the compiler selects the registers to use to represent the input 
8490 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8492 If there are no output operands but there are input operands, place two 
8493 consecutive colons where the output operands would go:
8495 @example
8496 __asm__ ("some instructions"
8497    : /* No outputs. */
8498    : "r" (Offset / 8));
8499 @end example
8501 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8502 (except for inputs tied to outputs). The compiler assumes that on exit from 
8503 the @code{asm} statement these operands contain the same values as they 
8504 had before executing the statement. 
8505 It is @emph{not} possible to use clobbers
8506 to inform the compiler that the values in these inputs are changing. One 
8507 common work-around is to tie the changing input variable to an output variable 
8508 that never gets used. Note, however, that if the code that follows the 
8509 @code{asm} statement makes no use of any of the output operands, the GCC 
8510 optimizers may discard the @code{asm} statement as unneeded 
8511 (see @ref{Volatile}).
8513 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8514 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8515 dependent. The list of supported modifiers for x86 is found at 
8516 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8518 In this example using the fictitious @code{combine} instruction, the 
8519 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8520 location as output operand 0. Only input operands may use numbers in 
8521 constraints, and they must each refer to an output operand. Only a number (or 
8522 the symbolic assembler name) in the constraint can guarantee that one operand 
8523 is in the same place as another. The mere fact that @code{foo} is the value of 
8524 both operands is not enough to guarantee that they are in the same place in 
8525 the generated assembler code.
8527 @example
8528 asm ("combine %2, %0" 
8529    : "=r" (foo) 
8530    : "0" (foo), "g" (bar));
8531 @end example
8533 Here is an example using symbolic names.
8535 @example
8536 asm ("cmoveq %1, %2, %[result]" 
8537    : [result] "=r"(result) 
8538    : "r" (test), "r" (new), "[result]" (old));
8539 @end example
8541 @anchor{Clobbers}
8542 @subsubsection Clobbers
8543 @cindex @code{asm} clobbers
8545 While the compiler is aware of changes to entries listed in the output 
8546 operands, the inline @code{asm} code may modify more than just the outputs. For 
8547 example, calculations may require additional registers, or the processor may 
8548 overwrite a register as a side effect of a particular assembler instruction. 
8549 In order to inform the compiler of these changes, list them in the clobber 
8550 list. Clobber list items are either register names or the special clobbers 
8551 (listed below). Each clobber list item is a string constant 
8552 enclosed in double quotes and separated by commas.
8554 Clobber descriptions may not in any way overlap with an input or output 
8555 operand. For example, you may not have an operand describing a register class 
8556 with one member when listing that register in the clobber list. Variables 
8557 declared to live in specific registers (@pxref{Explicit Register 
8558 Variables}) and used 
8559 as @code{asm} input or output operands must have no part mentioned in the 
8560 clobber description. In particular, there is no way to specify that input 
8561 operands get modified without also specifying them as output operands.
8563 When the compiler selects which registers to use to represent input and output 
8564 operands, it does not use any of the clobbered registers. As a result, 
8565 clobbered registers are available for any use in the assembler code.
8567 Here is a realistic example for the VAX showing the use of clobbered 
8568 registers: 
8570 @example
8571 asm volatile ("movc3 %0, %1, %2"
8572                    : /* No outputs. */
8573                    : "g" (from), "g" (to), "g" (count)
8574                    : "r0", "r1", "r2", "r3", "r4", "r5");
8575 @end example
8577 Also, there are two special clobber arguments:
8579 @table @code
8580 @item "cc"
8581 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
8582 register. On some machines, GCC represents the condition codes as a specific 
8583 hardware register; @code{"cc"} serves to name this register.
8584 On other machines, condition code handling is different, 
8585 and specifying @code{"cc"} has no effect. But 
8586 it is valid no matter what the target.
8588 @item "memory"
8589 The @code{"memory"} clobber tells the compiler that the assembly code
8590 performs memory 
8591 reads or writes to items other than those listed in the input and output 
8592 operands (for example, accessing the memory pointed to by one of the input 
8593 parameters). To ensure memory contains correct values, GCC may need to flush 
8594 specific register values to memory before executing the @code{asm}. Further, 
8595 the compiler does not assume that any values read from memory before an 
8596 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
8597 needed.  
8598 Using the @code{"memory"} clobber effectively forms a read/write
8599 memory barrier for the compiler.
8601 Note that this clobber does not prevent the @emph{processor} from doing 
8602 speculative reads past the @code{asm} statement. To prevent that, you need 
8603 processor-specific fence instructions.
8605 Flushing registers to memory has performance implications and may be an issue 
8606 for time-sensitive code.  You can use a trick to avoid this if the size of 
8607 the memory being accessed is known at compile time. For example, if accessing 
8608 ten bytes of a string, use a memory input like: 
8610 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8612 @end table
8614 @anchor{GotoLabels}
8615 @subsubsection Goto Labels
8616 @cindex @code{asm} goto labels
8618 @code{asm goto} allows assembly code to jump to one or more C labels.  The
8619 @var{GotoLabels} section in an @code{asm goto} statement contains 
8620 a comma-separated 
8621 list of all C labels to which the assembler code may jump. GCC assumes that 
8622 @code{asm} execution falls through to the next statement (if this is not the 
8623 case, consider using the @code{__builtin_unreachable} intrinsic after the 
8624 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
8625 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
8626 Attributes}).
8628 An @code{asm goto} statement cannot have outputs.
8629 This is due to an internal restriction of 
8630 the compiler: control transfer instructions cannot have outputs. 
8631 If the assembler code does modify anything, use the @code{"memory"} clobber 
8632 to force the 
8633 optimizers to flush all register values to memory and reload them if 
8634 necessary after the @code{asm} statement.
8636 Also note that an @code{asm goto} statement is always implicitly
8637 considered volatile.
8639 To reference a label in the assembler template,
8640 prefix it with @samp{%l} (lowercase @samp{L}) followed 
8641 by its (zero-based) position in @var{GotoLabels} plus the number of input 
8642 operands.  For example, if the @code{asm} has three inputs and references two 
8643 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8645 Alternately, you can reference labels using the actual C label name enclosed
8646 in brackets.  For example, to reference a label named @code{carry}, you can
8647 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
8648 section when using this approach.
8650 Here is an example of @code{asm goto} for i386:
8652 @example
8653 asm goto (
8654     "btl %1, %0\n\t"
8655     "jc %l2"
8656     : /* No outputs. */
8657     : "r" (p1), "r" (p2) 
8658     : "cc" 
8659     : carry);
8661 return 0;
8663 carry:
8664 return 1;
8665 @end example
8667 The following example shows an @code{asm goto} that uses a memory clobber.
8669 @example
8670 int frob(int x)
8672   int y;
8673   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8674             : /* No outputs. */
8675             : "r"(x), "r"(&y)
8676             : "r5", "memory" 
8677             : error);
8678   return y;
8679 error:
8680   return -1;
8682 @end example
8684 @anchor{x86Operandmodifiers}
8685 @subsubsection x86 Operand Modifiers
8687 References to input, output, and goto operands in the assembler template
8688 of extended @code{asm} statements can use 
8689 modifiers to affect the way the operands are formatted in 
8690 the code output to the assembler. For example, the 
8691 following code uses the @samp{h} and @samp{b} modifiers for x86:
8693 @example
8694 uint16_t  num;
8695 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8696 @end example
8698 @noindent
8699 These modifiers generate this assembler code:
8701 @example
8702 xchg %ah, %al
8703 @end example
8705 The rest of this discussion uses the following code for illustrative purposes.
8707 @example
8708 int main()
8710    int iInt = 1;
8712 top:
8714    asm volatile goto ("some assembler instructions here"
8715    : /* No outputs. */
8716    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8717    : /* No clobbers. */
8718    : top);
8720 @end example
8722 With no modifiers, this is what the output from the operands would be for the 
8723 @samp{att} and @samp{intel} dialects of assembler:
8725 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
8726 @headitem Operand @tab @samp{att} @tab @samp{intel}
8727 @item @code{%0}
8728 @tab @code{%eax}
8729 @tab @code{eax}
8730 @item @code{%1}
8731 @tab @code{$2}
8732 @tab @code{2}
8733 @item @code{%2}
8734 @tab @code{$.L2}
8735 @tab @code{OFFSET FLAT:.L2}
8736 @end multitable
8738 The table below shows the list of supported modifiers and their effects.
8740 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
8741 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
8742 @item @code{z}
8743 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8744 @tab @code{%z0}
8745 @tab @code{l}
8746 @tab 
8747 @item @code{b}
8748 @tab Print the QImode name of the register.
8749 @tab @code{%b0}
8750 @tab @code{%al}
8751 @tab @code{al}
8752 @item @code{h}
8753 @tab Print the QImode name for a ``high'' register.
8754 @tab @code{%h0}
8755 @tab @code{%ah}
8756 @tab @code{ah}
8757 @item @code{w}
8758 @tab Print the HImode name of the register.
8759 @tab @code{%w0}
8760 @tab @code{%ax}
8761 @tab @code{ax}
8762 @item @code{k}
8763 @tab Print the SImode name of the register.
8764 @tab @code{%k0}
8765 @tab @code{%eax}
8766 @tab @code{eax}
8767 @item @code{q}
8768 @tab Print the DImode name of the register.
8769 @tab @code{%q0}
8770 @tab @code{%rax}
8771 @tab @code{rax}
8772 @item @code{l}
8773 @tab Print the label name with no punctuation.
8774 @tab @code{%l2}
8775 @tab @code{.L2}
8776 @tab @code{.L2}
8777 @item @code{c}
8778 @tab Require a constant operand and print the constant expression with no punctuation.
8779 @tab @code{%c1}
8780 @tab @code{2}
8781 @tab @code{2}
8782 @end multitable
8784 @anchor{x86floatingpointasmoperands}
8785 @subsubsection x86 Floating-Point @code{asm} Operands
8787 On x86 targets, there are several rules on the usage of stack-like registers
8788 in the operands of an @code{asm}.  These rules apply only to the operands
8789 that are stack-like registers:
8791 @enumerate
8792 @item
8793 Given a set of input registers that die in an @code{asm}, it is
8794 necessary to know which are implicitly popped by the @code{asm}, and
8795 which must be explicitly popped by GCC@.
8797 An input register that is implicitly popped by the @code{asm} must be
8798 explicitly clobbered, unless it is constrained to match an
8799 output operand.
8801 @item
8802 For any input register that is implicitly popped by an @code{asm}, it is
8803 necessary to know how to adjust the stack to compensate for the pop.
8804 If any non-popped input is closer to the top of the reg-stack than
8805 the implicitly popped register, it would not be possible to know what the
8806 stack looked like---it's not clear how the rest of the stack ``slides
8807 up''.
8809 All implicitly popped input registers must be closer to the top of
8810 the reg-stack than any input that is not implicitly popped.
8812 It is possible that if an input dies in an @code{asm}, the compiler might
8813 use the input register for an output reload.  Consider this example:
8815 @smallexample
8816 asm ("foo" : "=t" (a) : "f" (b));
8817 @end smallexample
8819 @noindent
8820 This code says that input @code{b} is not popped by the @code{asm}, and that
8821 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8822 deeper after the @code{asm} than it was before.  But, it is possible that
8823 reload may think that it can use the same register for both the input and
8824 the output.
8826 To prevent this from happening,
8827 if any input operand uses the @samp{f} constraint, all output register
8828 constraints must use the @samp{&} early-clobber modifier.
8830 The example above is correctly written as:
8832 @smallexample
8833 asm ("foo" : "=&t" (a) : "f" (b));
8834 @end smallexample
8836 @item
8837 Some operands need to be in particular places on the stack.  All
8838 output operands fall in this category---GCC has no other way to
8839 know which registers the outputs appear in unless you indicate
8840 this in the constraints.
8842 Output operands must specifically indicate which register an output
8843 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
8844 constraints must select a class with a single register.
8846 @item
8847 Output operands may not be ``inserted'' between existing stack registers.
8848 Since no 387 opcode uses a read/write operand, all output operands
8849 are dead before the @code{asm}, and are pushed by the @code{asm}.
8850 It makes no sense to push anywhere but the top of the reg-stack.
8852 Output operands must start at the top of the reg-stack: output
8853 operands may not ``skip'' a register.
8855 @item
8856 Some @code{asm} statements may need extra stack space for internal
8857 calculations.  This can be guaranteed by clobbering stack registers
8858 unrelated to the inputs and outputs.
8860 @end enumerate
8862 This @code{asm}
8863 takes one input, which is internally popped, and produces two outputs.
8865 @smallexample
8866 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8867 @end smallexample
8869 @noindent
8870 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8871 and replaces them with one output.  The @code{st(1)} clobber is necessary 
8872 for the compiler to know that @code{fyl2xp1} pops both inputs.
8874 @smallexample
8875 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8876 @end smallexample
8878 @lowersections
8879 @include md.texi
8880 @raisesections
8882 @node Asm Labels
8883 @subsection Controlling Names Used in Assembler Code
8884 @cindex assembler names for identifiers
8885 @cindex names used in assembler code
8886 @cindex identifiers, names in assembler code
8888 You can specify the name to be used in the assembler code for a C
8889 function or variable by writing the @code{asm} (or @code{__asm__})
8890 keyword after the declarator.
8891 It is up to you to make sure that the assembler names you choose do not
8892 conflict with any other assembler symbols, or reference registers.
8894 @subsubheading Assembler names for data:
8896 This sample shows how to specify the assembler name for data:
8898 @smallexample
8899 int foo asm ("myfoo") = 2;
8900 @end smallexample
8902 @noindent
8903 This specifies that the name to be used for the variable @code{foo} in
8904 the assembler code should be @samp{myfoo} rather than the usual
8905 @samp{_foo}.
8907 On systems where an underscore is normally prepended to the name of a C
8908 variable, this feature allows you to define names for the
8909 linker that do not start with an underscore.
8911 GCC does not support using this feature with a non-static local variable 
8912 since such variables do not have assembler names.  If you are
8913 trying to put the variable in a particular register, see 
8914 @ref{Explicit Register Variables}.
8916 @subsubheading Assembler names for functions:
8918 To specify the assembler name for functions, write a declaration for the 
8919 function before its definition and put @code{asm} there, like this:
8921 @smallexample
8922 int func (int x, int y) asm ("MYFUNC");
8923      
8924 int func (int x, int y)
8926    /* @r{@dots{}} */
8927 @end smallexample
8929 @noindent
8930 This specifies that the name to be used for the function @code{func} in
8931 the assembler code should be @code{MYFUNC}.
8933 @node Explicit Register Variables
8934 @subsection Variables in Specified Registers
8935 @anchor{Explicit Reg Vars}
8936 @cindex explicit register variables
8937 @cindex variables in specified registers
8938 @cindex specified registers
8940 GNU C allows you to associate specific hardware registers with C 
8941 variables.  In almost all cases, allowing the compiler to assign
8942 registers produces the best code.  However under certain unusual
8943 circumstances, more precise control over the variable storage is 
8944 required.
8946 Both global and local variables can be associated with a register.  The
8947 consequences of performing this association are very different between
8948 the two, as explained in the sections below.
8950 @menu
8951 * Global Register Variables::   Variables declared at global scope.
8952 * Local Register Variables::    Variables declared within a function.
8953 @end menu
8955 @node Global Register Variables
8956 @subsubsection Defining Global Register Variables
8957 @anchor{Global Reg Vars}
8958 @cindex global register variables
8959 @cindex registers, global variables in
8960 @cindex registers, global allocation
8962 You can define a global register variable and associate it with a specified 
8963 register like this:
8965 @smallexample
8966 register int *foo asm ("r12");
8967 @end smallexample
8969 @noindent
8970 Here @code{r12} is the name of the register that should be used. Note that 
8971 this is the same syntax used for defining local register variables, but for 
8972 a global variable the declaration appears outside a function. The 
8973 @code{register} keyword is required, and cannot be combined with 
8974 @code{static}. The register name must be a valid register name for the
8975 target platform.
8977 Registers are a scarce resource on most systems and allowing the 
8978 compiler to manage their usage usually results in the best code. However, 
8979 under special circumstances it can make sense to reserve some globally.
8980 For example this may be useful in programs such as programming language 
8981 interpreters that have a couple of global variables that are accessed 
8982 very often.
8984 After defining a global register variable, for the current compilation
8985 unit:
8987 @itemize @bullet
8988 @item The register is reserved entirely for this use, and will not be 
8989 allocated for any other purpose.
8990 @item The register is not saved and restored by any functions.
8991 @item Stores into this register are never deleted even if they appear to be 
8992 dead, but references may be deleted, moved or simplified.
8993 @end itemize
8995 Note that these points @emph{only} apply to code that is compiled with the
8996 definition. The behavior of code that is merely linked in (for example 
8997 code from libraries) is not affected.
8999 If you want to recompile source files that do not actually use your global 
9000 register variable so they do not use the specified register for any other 
9001 purpose, you need not actually add the global register declaration to 
9002 their source code. It suffices to specify the compiler option 
9003 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9004 register.
9006 @subsubheading Declaring the variable
9008 Global register variables can not have initial values, because an
9009 executable file has no means to supply initial contents for a register.
9011 When selecting a register, choose one that is normally saved and 
9012 restored by function calls on your machine. This ensures that code
9013 which is unaware of this reservation (such as library routines) will 
9014 restore it before returning.
9016 On machines with register windows, be sure to choose a global
9017 register that is not affected magically by the function call mechanism.
9019 @subsubheading Using the variable
9021 @cindex @code{qsort}, and global register variables
9022 When calling routines that are not aware of the reservation, be 
9023 cautious if those routines call back into code which uses them. As an 
9024 example, if you call the system library version of @code{qsort}, it may 
9025 clobber your registers during execution, but (if you have selected 
9026 appropriate registers) it will restore them before returning. However 
9027 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9028 function. As a result, global values will not reliably be available to 
9029 the comparison function unless the @code{qsort} function itself is rebuilt.
9031 Similarly, it is not safe to access the global register variables from signal
9032 handlers or from more than one thread of control. Unless you recompile 
9033 them specially for the task at hand, the system library routines may 
9034 temporarily use the register for other things.
9036 @cindex register variable after @code{longjmp}
9037 @cindex global register after @code{longjmp}
9038 @cindex value after @code{longjmp}
9039 @findex longjmp
9040 @findex setjmp
9041 On most machines, @code{longjmp} restores to each global register
9042 variable the value it had at the time of the @code{setjmp}. On some
9043 machines, however, @code{longjmp} does not change the value of global
9044 register variables. To be portable, the function that called @code{setjmp}
9045 should make other arrangements to save the values of the global register
9046 variables, and to restore them in a @code{longjmp}. This way, the same
9047 thing happens regardless of what @code{longjmp} does.
9049 Eventually there may be a way of asking the compiler to choose a register 
9050 automatically, but first we need to figure out how it should choose and 
9051 how to enable you to guide the choice.  No solution is evident.
9053 @node Local Register Variables
9054 @subsubsection Specifying Registers for Local Variables
9055 @anchor{Local Reg Vars}
9056 @cindex local variables, specifying registers
9057 @cindex specifying registers for local variables
9058 @cindex registers for local variables
9060 You can define a local register variable and associate it with a specified 
9061 register like this:
9063 @smallexample
9064 register int *foo asm ("r12");
9065 @end smallexample
9067 @noindent
9068 Here @code{r12} is the name of the register that should be used.  Note
9069 that this is the same syntax used for defining global register variables, 
9070 but for a local variable the declaration appears within a function.  The 
9071 @code{register} keyword is required, and cannot be combined with 
9072 @code{static}.  The register name must be a valid register name for the
9073 target platform.
9075 As with global register variables, it is recommended that you choose 
9076 a register that is normally saved and restored by function calls on your 
9077 machine, so that calls to library routines will not clobber it.
9079 The only supported use for this feature is to specify registers
9080 for input and output operands when calling Extended @code{asm} 
9081 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9082 particular machine don't provide sufficient control to select the desired 
9083 register.  To force an operand into a register, create a local variable 
9084 and specify the register name after the variable's declaration.  Then use 
9085 the local variable for the @code{asm} operand and specify any constraint 
9086 letter that matches the register:
9088 @smallexample
9089 register int *p1 asm ("r0") = @dots{};
9090 register int *p2 asm ("r1") = @dots{};
9091 register int *result asm ("r0");
9092 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9093 @end smallexample
9095 @emph{Warning:} In the above example, be aware that a register (for example 
9096 @code{r0}) can be call-clobbered by subsequent code, including function 
9097 calls and library calls for arithmetic operators on other variables (for 
9098 example the initialization of @code{p2}).  In this case, use temporary 
9099 variables for expressions between the register assignments:
9101 @smallexample
9102 int t1 = @dots{};
9103 register int *p1 asm ("r0") = @dots{};
9104 register int *p2 asm ("r1") = t1;
9105 register int *result asm ("r0");
9106 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9107 @end smallexample
9109 Defining a register variable does not reserve the register.  Other than
9110 when invoking the Extended @code{asm}, the contents of the specified 
9111 register are not guaranteed.  For this reason, the following uses 
9112 are explicitly @emph{not} supported.  If they appear to work, it is only 
9113 happenstance, and may stop working as intended due to (seemingly) 
9114 unrelated changes in surrounding code, or even minor changes in the 
9115 optimization of a future version of gcc:
9117 @itemize @bullet
9118 @item Passing parameters to or from Basic @code{asm}
9119 @item Passing parameters to or from Extended @code{asm} without using input 
9120 or output operands.
9121 @item Passing parameters to or from routines written in assembler (or
9122 other languages) using non-standard calling conventions.
9123 @end itemize
9125 Some developers use Local Register Variables in an attempt to improve 
9126 gcc's allocation of registers, especially in large functions.  In this 
9127 case the register name is essentially a hint to the register allocator.
9128 While in some instances this can generate better code, improvements are
9129 subject to the whims of the allocator/optimizers.  Since there are no
9130 guarantees that your improvements won't be lost, this usage of Local
9131 Register Variables is discouraged.
9133 On the MIPS platform, there is related use for local register variables 
9134 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9135 Defining coprocessor specifics for MIPS targets, gccint, 
9136 GNU Compiler Collection (GCC) Internals}).
9138 @node Size of an asm
9139 @subsection Size of an @code{asm}
9141 Some targets require that GCC track the size of each instruction used
9142 in order to generate correct code.  Because the final length of the
9143 code produced by an @code{asm} statement is only known by the
9144 assembler, GCC must make an estimate as to how big it will be.  It
9145 does this by counting the number of instructions in the pattern of the
9146 @code{asm} and multiplying that by the length of the longest
9147 instruction supported by that processor.  (When working out the number
9148 of instructions, it assumes that any occurrence of a newline or of
9149 whatever statement separator character is supported by the assembler --
9150 typically @samp{;} --- indicates the end of an instruction.)
9152 Normally, GCC's estimate is adequate to ensure that correct
9153 code is generated, but it is possible to confuse the compiler if you use
9154 pseudo instructions or assembler macros that expand into multiple real
9155 instructions, or if you use assembler directives that expand to more
9156 space in the object file than is needed for a single instruction.
9157 If this happens then the assembler may produce a diagnostic saying that
9158 a label is unreachable.
9160 @node Alternate Keywords
9161 @section Alternate Keywords
9162 @cindex alternate keywords
9163 @cindex keywords, alternate
9165 @option{-ansi} and the various @option{-std} options disable certain
9166 keywords.  This causes trouble when you want to use GNU C extensions, or
9167 a general-purpose header file that should be usable by all programs,
9168 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9169 @code{inline} are not available in programs compiled with
9170 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9171 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9172 ISO C99 keyword
9173 @code{restrict} is only available when @option{-std=gnu99} (which will
9174 eventually be the default) or @option{-std=c99} (or the equivalent
9175 @option{-std=iso9899:1999}), or an option for a later standard
9176 version, is used.
9178 The way to solve these problems is to put @samp{__} at the beginning and
9179 end of each problematical keyword.  For example, use @code{__asm__}
9180 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9182 Other C compilers won't accept these alternative keywords; if you want to
9183 compile with another compiler, you can define the alternate keywords as
9184 macros to replace them with the customary keywords.  It looks like this:
9186 @smallexample
9187 #ifndef __GNUC__
9188 #define __asm__ asm
9189 #endif
9190 @end smallexample
9192 @findex __extension__
9193 @opindex pedantic
9194 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9195 You can
9196 prevent such warnings within one expression by writing
9197 @code{__extension__} before the expression.  @code{__extension__} has no
9198 effect aside from this.
9200 @node Incomplete Enums
9201 @section Incomplete @code{enum} Types
9203 You can define an @code{enum} tag without specifying its possible values.
9204 This results in an incomplete type, much like what you get if you write
9205 @code{struct foo} without describing the elements.  A later declaration
9206 that does specify the possible values completes the type.
9208 You cannot allocate variables or storage using the type while it is
9209 incomplete.  However, you can work with pointers to that type.
9211 This extension may not be very useful, but it makes the handling of
9212 @code{enum} more consistent with the way @code{struct} and @code{union}
9213 are handled.
9215 This extension is not supported by GNU C++.
9217 @node Function Names
9218 @section Function Names as Strings
9219 @cindex @code{__func__} identifier
9220 @cindex @code{__FUNCTION__} identifier
9221 @cindex @code{__PRETTY_FUNCTION__} identifier
9223 GCC provides three magic constants that hold the name of the current
9224 function as a string.  In C++11 and later modes, all three are treated
9225 as constant expressions and can be used in @code{constexpr} constexts.
9226 The first of these constants is @code{__func__}, which is part of
9227 the C99 standard:
9229 The identifier @code{__func__} is implicitly declared by the translator
9230 as if, immediately following the opening brace of each function
9231 definition, the declaration
9233 @smallexample
9234 static const char __func__[] = "function-name";
9235 @end smallexample
9237 @noindent
9238 appeared, where function-name is the name of the lexically-enclosing
9239 function.  This name is the unadorned name of the function.  As an
9240 extension, at file (or, in C++, namespace scope), @code{__func__}
9241 evaluates to the empty string.
9243 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9244 backward compatibility with old versions of GCC.
9246 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9247 @code{__func__}, except that at file (or, in C++, namespace scope),
9248 it evaluates to the string @code{"top level"}.  In addition, in C++,
9249 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9250 well as its bare name.  For example, this program:
9252 @smallexample
9253 extern "C" int printf (const char *, ...);
9255 class a @{
9256  public:
9257   void sub (int i)
9258     @{
9259       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9260       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9261     @}
9265 main (void)
9267   a ax;
9268   ax.sub (0);
9269   return 0;
9271 @end smallexample
9273 @noindent
9274 gives this output:
9276 @smallexample
9277 __FUNCTION__ = sub
9278 __PRETTY_FUNCTION__ = void a::sub(int)
9279 @end smallexample
9281 These identifiers are variables, not preprocessor macros, and may not
9282 be used to initialize @code{char} arrays or be concatenated with string
9283 literals.
9285 @node Return Address
9286 @section Getting the Return or Frame Address of a Function
9288 These functions may be used to get information about the callers of a
9289 function.
9291 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9292 This function returns the return address of the current function, or of
9293 one of its callers.  The @var{level} argument is number of frames to
9294 scan up the call stack.  A value of @code{0} yields the return address
9295 of the current function, a value of @code{1} yields the return address
9296 of the caller of the current function, and so forth.  When inlining
9297 the expected behavior is that the function returns the address of
9298 the function that is returned to.  To work around this behavior use
9299 the @code{noinline} function attribute.
9301 The @var{level} argument must be a constant integer.
9303 On some machines it may be impossible to determine the return address of
9304 any function other than the current one; in such cases, or when the top
9305 of the stack has been reached, this function returns @code{0} or a
9306 random value.  In addition, @code{__builtin_frame_address} may be used
9307 to determine if the top of the stack has been reached.
9309 Additional post-processing of the returned value may be needed, see
9310 @code{__builtin_extract_return_addr}.
9312 Calling this function with a nonzero argument can have unpredictable
9313 effects, including crashing the calling program.  As a result, calls
9314 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9315 option is in effect.  Such calls should only be made in debugging
9316 situations.
9317 @end deftypefn
9319 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9320 The address as returned by @code{__builtin_return_address} may have to be fed
9321 through this function to get the actual encoded address.  For example, on the
9322 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9323 platforms an offset has to be added for the true next instruction to be
9324 executed.
9326 If no fixup is needed, this function simply passes through @var{addr}.
9327 @end deftypefn
9329 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9330 This function does the reverse of @code{__builtin_extract_return_addr}.
9331 @end deftypefn
9333 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9334 This function is similar to @code{__builtin_return_address}, but it
9335 returns the address of the function frame rather than the return address
9336 of the function.  Calling @code{__builtin_frame_address} with a value of
9337 @code{0} yields the frame address of the current function, a value of
9338 @code{1} yields the frame address of the caller of the current function,
9339 and so forth.
9341 The frame is the area on the stack that holds local variables and saved
9342 registers.  The frame address is normally the address of the first word
9343 pushed on to the stack by the function.  However, the exact definition
9344 depends upon the processor and the calling convention.  If the processor
9345 has a dedicated frame pointer register, and the function has a frame,
9346 then @code{__builtin_frame_address} returns the value of the frame
9347 pointer register.
9349 On some machines it may be impossible to determine the frame address of
9350 any function other than the current one; in such cases, or when the top
9351 of the stack has been reached, this function returns @code{0} if
9352 the first frame pointer is properly initialized by the startup code.
9354 Calling this function with a nonzero argument can have unpredictable
9355 effects, including crashing the calling program.  As a result, calls
9356 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9357 option is in effect.  Such calls should only be made in debugging
9358 situations.
9359 @end deftypefn
9361 @node Vector Extensions
9362 @section Using Vector Instructions through Built-in Functions
9364 On some targets, the instruction set contains SIMD vector instructions which
9365 operate on multiple values contained in one large register at the same time.
9366 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9367 this way.
9369 The first step in using these extensions is to provide the necessary data
9370 types.  This should be done using an appropriate @code{typedef}:
9372 @smallexample
9373 typedef int v4si __attribute__ ((vector_size (16)));
9374 @end smallexample
9376 @noindent
9377 The @code{int} type specifies the base type, while the attribute specifies
9378 the vector size for the variable, measured in bytes.  For example, the
9379 declaration above causes the compiler to set the mode for the @code{v4si}
9380 type to be 16 bytes wide and divided into @code{int} sized units.  For
9381 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9382 corresponding mode of @code{foo} is @acronym{V4SI}.
9384 The @code{vector_size} attribute is only applicable to integral and
9385 float scalars, although arrays, pointers, and function return values
9386 are allowed in conjunction with this construct. Only sizes that are
9387 a power of two are currently allowed.
9389 All the basic integer types can be used as base types, both as signed
9390 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9391 @code{long long}.  In addition, @code{float} and @code{double} can be
9392 used to build floating-point vector types.
9394 Specifying a combination that is not valid for the current architecture
9395 causes GCC to synthesize the instructions using a narrower mode.
9396 For example, if you specify a variable of type @code{V4SI} and your
9397 architecture does not allow for this specific SIMD type, GCC
9398 produces code that uses 4 @code{SIs}.
9400 The types defined in this manner can be used with a subset of normal C
9401 operations.  Currently, GCC allows using the following operators
9402 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9404 The operations behave like C++ @code{valarrays}.  Addition is defined as
9405 the addition of the corresponding elements of the operands.  For
9406 example, in the code below, each of the 4 elements in @var{a} is
9407 added to the corresponding 4 elements in @var{b} and the resulting
9408 vector is stored in @var{c}.
9410 @smallexample
9411 typedef int v4si __attribute__ ((vector_size (16)));
9413 v4si a, b, c;
9415 c = a + b;
9416 @end smallexample
9418 Subtraction, multiplication, division, and the logical operations
9419 operate in a similar manner.  Likewise, the result of using the unary
9420 minus or complement operators on a vector type is a vector whose
9421 elements are the negative or complemented values of the corresponding
9422 elements in the operand.
9424 It is possible to use shifting operators @code{<<}, @code{>>} on
9425 integer-type vectors. The operation is defined as following: @code{@{a0,
9426 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9427 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9428 elements. 
9430 For convenience, it is allowed to use a binary vector operation
9431 where one operand is a scalar. In that case the compiler transforms
9432 the scalar operand into a vector where each element is the scalar from
9433 the operation. The transformation happens only if the scalar could be
9434 safely converted to the vector-element type.
9435 Consider the following code.
9437 @smallexample
9438 typedef int v4si __attribute__ ((vector_size (16)));
9440 v4si a, b, c;
9441 long l;
9443 a = b + 1;    /* a = b + @{1,1,1,1@}; */
9444 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
9446 a = l + a;    /* Error, cannot convert long to int. */
9447 @end smallexample
9449 Vectors can be subscripted as if the vector were an array with
9450 the same number of elements and base type.  Out of bound accesses
9451 invoke undefined behavior at run time.  Warnings for out of bound
9452 accesses for vector subscription can be enabled with
9453 @option{-Warray-bounds}.
9455 Vector comparison is supported with standard comparison
9456 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9457 vector expressions of integer-type or real-type. Comparison between
9458 integer-type vectors and real-type vectors are not supported.  The
9459 result of the comparison is a vector of the same width and number of
9460 elements as the comparison operands with a signed integral element
9461 type.
9463 Vectors are compared element-wise producing 0 when comparison is false
9464 and -1 (constant of the appropriate type where all bits are set)
9465 otherwise. Consider the following example.
9467 @smallexample
9468 typedef int v4si __attribute__ ((vector_size (16)));
9470 v4si a = @{1,2,3,4@};
9471 v4si b = @{3,2,1,4@};
9472 v4si c;
9474 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
9475 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
9476 @end smallexample
9478 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9479 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9480 integer vector with the same number of elements of the same size as @code{b}
9481 and @code{c}, computes all three arguments and creates a vector
9482 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
9483 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9484 As in the case of binary operations, this syntax is also accepted when
9485 one of @code{b} or @code{c} is a scalar that is then transformed into a
9486 vector. If both @code{b} and @code{c} are scalars and the type of
9487 @code{true?b:c} has the same size as the element type of @code{a}, then
9488 @code{b} and @code{c} are converted to a vector type whose elements have
9489 this type and with the same number of elements as @code{a}.
9491 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9492 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9493 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9494 For mixed operations between a scalar @code{s} and a vector @code{v},
9495 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9496 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9498 Vector shuffling is available using functions
9499 @code{__builtin_shuffle (vec, mask)} and
9500 @code{__builtin_shuffle (vec0, vec1, mask)}.
9501 Both functions construct a permutation of elements from one or two
9502 vectors and return a vector of the same type as the input vector(s).
9503 The @var{mask} is an integral vector with the same width (@var{W})
9504 and element count (@var{N}) as the output vector.
9506 The elements of the input vectors are numbered in memory ordering of
9507 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
9508 elements of @var{mask} are considered modulo @var{N} in the single-operand
9509 case and modulo @math{2*@var{N}} in the two-operand case.
9511 Consider the following example,
9513 @smallexample
9514 typedef int v4si __attribute__ ((vector_size (16)));
9516 v4si a = @{1,2,3,4@};
9517 v4si b = @{5,6,7,8@};
9518 v4si mask1 = @{0,1,1,3@};
9519 v4si mask2 = @{0,4,2,5@};
9520 v4si res;
9522 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
9523 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
9524 @end smallexample
9526 Note that @code{__builtin_shuffle} is intentionally semantically
9527 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9529 You can declare variables and use them in function calls and returns, as
9530 well as in assignments and some casts.  You can specify a vector type as
9531 a return type for a function.  Vector types can also be used as function
9532 arguments.  It is possible to cast from one vector type to another,
9533 provided they are of the same size (in fact, you can also cast vectors
9534 to and from other datatypes of the same size).
9536 You cannot operate between vectors of different lengths or different
9537 signedness without a cast.
9539 @node Offsetof
9540 @section Support for @code{offsetof}
9541 @findex __builtin_offsetof
9543 GCC implements for both C and C++ a syntactic extension to implement
9544 the @code{offsetof} macro.
9546 @smallexample
9547 primary:
9548         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9550 offsetof_member_designator:
9551           @code{identifier}
9552         | offsetof_member_designator "." @code{identifier}
9553         | offsetof_member_designator "[" @code{expr} "]"
9554 @end smallexample
9556 This extension is sufficient such that
9558 @smallexample
9559 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
9560 @end smallexample
9562 @noindent
9563 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
9564 may be dependent.  In either case, @var{member} may consist of a single
9565 identifier, or a sequence of member accesses and array references.
9567 @node __sync Builtins
9568 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9570 The following built-in functions
9571 are intended to be compatible with those described
9572 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9573 section 7.4.  As such, they depart from normal GCC practice by not using
9574 the @samp{__builtin_} prefix and also by being overloaded so that they
9575 work on multiple types.
9577 The definition given in the Intel documentation allows only for the use of
9578 the types @code{int}, @code{long}, @code{long long} or their unsigned
9579 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9580 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9581 Operations on pointer arguments are performed as if the operands were
9582 of the @code{uintptr_t} type.  That is, they are not scaled by the size
9583 of the type to which the pointer points.
9585 These functions are implemented in terms of the @samp{__atomic}
9586 builtins (@pxref{__atomic Builtins}).  They should not be used for new
9587 code which should use the @samp{__atomic} builtins instead.
9589 Not all operations are supported by all target processors.  If a particular
9590 operation cannot be implemented on the target processor, a warning is
9591 generated and a call to an external function is generated.  The external
9592 function carries the same name as the built-in version,
9593 with an additional suffix
9594 @samp{_@var{n}} where @var{n} is the size of the data type.
9596 @c ??? Should we have a mechanism to suppress this warning?  This is almost
9597 @c useful for implementing the operation under the control of an external
9598 @c mutex.
9600 In most cases, these built-in functions are considered a @dfn{full barrier}.
9601 That is,
9602 no memory operand is moved across the operation, either forward or
9603 backward.  Further, instructions are issued as necessary to prevent the
9604 processor from speculating loads across the operation and from queuing stores
9605 after the operation.
9607 All of the routines are described in the Intel documentation to take
9608 ``an optional list of variables protected by the memory barrier''.  It's
9609 not clear what is meant by that; it could mean that @emph{only} the
9610 listed variables are protected, or it could mean a list of additional
9611 variables to be protected.  The list is ignored by GCC which treats it as
9612 empty.  GCC interprets an empty list as meaning that all globally
9613 accessible variables should be protected.
9615 @table @code
9616 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9617 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9618 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9619 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9620 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9621 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9622 @findex __sync_fetch_and_add
9623 @findex __sync_fetch_and_sub
9624 @findex __sync_fetch_and_or
9625 @findex __sync_fetch_and_and
9626 @findex __sync_fetch_and_xor
9627 @findex __sync_fetch_and_nand
9628 These built-in functions perform the operation suggested by the name, and
9629 returns the value that had previously been in memory.  That is, operations
9630 on integer operands have the following semantics.  Operations on pointer
9631 arguments are performed as if the operands were of the @code{uintptr_t}
9632 type.  That is, they are not scaled by the size of the type to which
9633 the pointer points.
9635 @smallexample
9636 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9637 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
9638 @end smallexample
9640 The object pointed to by the first argument must be of integer or pointer
9641 type.  It must not be a boolean type.
9643 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9644 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9646 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9647 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9648 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9649 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9650 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9651 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9652 @findex __sync_add_and_fetch
9653 @findex __sync_sub_and_fetch
9654 @findex __sync_or_and_fetch
9655 @findex __sync_and_and_fetch
9656 @findex __sync_xor_and_fetch
9657 @findex __sync_nand_and_fetch
9658 These built-in functions perform the operation suggested by the name, and
9659 return the new value.  That is, operations on integer operands have
9660 the following semantics.  Operations on pointer operands are performed as
9661 if the operand's type were @code{uintptr_t}.
9663 @smallexample
9664 @{ *ptr @var{op}= value; return *ptr; @}
9665 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
9666 @end smallexample
9668 The same constraints on arguments apply as for the corresponding
9669 @code{__sync_op_and_fetch} built-in functions.
9671 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9672 as @code{*ptr = ~(*ptr & value)} instead of
9673 @code{*ptr = ~*ptr & value}.
9675 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9676 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9677 @findex __sync_bool_compare_and_swap
9678 @findex __sync_val_compare_and_swap
9679 These built-in functions perform an atomic compare and swap.
9680 That is, if the current
9681 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9682 @code{*@var{ptr}}.
9684 The ``bool'' version returns true if the comparison is successful and
9685 @var{newval} is written.  The ``val'' version returns the contents
9686 of @code{*@var{ptr}} before the operation.
9688 @item __sync_synchronize (...)
9689 @findex __sync_synchronize
9690 This built-in function issues a full memory barrier.
9692 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9693 @findex __sync_lock_test_and_set
9694 This built-in function, as described by Intel, is not a traditional test-and-set
9695 operation, but rather an atomic exchange operation.  It writes @var{value}
9696 into @code{*@var{ptr}}, and returns the previous contents of
9697 @code{*@var{ptr}}.
9699 Many targets have only minimal support for such locks, and do not support
9700 a full exchange operation.  In this case, a target may support reduced
9701 functionality here by which the @emph{only} valid value to store is the
9702 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
9703 is implementation defined.
9705 This built-in function is not a full barrier,
9706 but rather an @dfn{acquire barrier}.
9707 This means that references after the operation cannot move to (or be
9708 speculated to) before the operation, but previous memory stores may not
9709 be globally visible yet, and previous memory loads may not yet be
9710 satisfied.
9712 @item void __sync_lock_release (@var{type} *ptr, ...)
9713 @findex __sync_lock_release
9714 This built-in function releases the lock acquired by
9715 @code{__sync_lock_test_and_set}.
9716 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9718 This built-in function is not a full barrier,
9719 but rather a @dfn{release barrier}.
9720 This means that all previous memory stores are globally visible, and all
9721 previous memory loads have been satisfied, but following memory reads
9722 are not prevented from being speculated to before the barrier.
9723 @end table
9725 @node __atomic Builtins
9726 @section Built-in Functions for Memory Model Aware Atomic Operations
9728 The following built-in functions approximately match the requirements
9729 for the C++11 memory model.  They are all
9730 identified by being prefixed with @samp{__atomic} and most are
9731 overloaded so that they work with multiple types.
9733 These functions are intended to replace the legacy @samp{__sync}
9734 builtins.  The main difference is that the memory order that is requested
9735 is a parameter to the functions.  New code should always use the
9736 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9738 Note that the @samp{__atomic} builtins assume that programs will
9739 conform to the C++11 memory model.  In particular, they assume
9740 that programs are free of data races.  See the C++11 standard for
9741 detailed requirements.
9743 The @samp{__atomic} builtins can be used with any integral scalar or
9744 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
9745 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9746 supported by the architecture.
9748 The four non-arithmetic functions (load, store, exchange, and 
9749 compare_exchange) all have a generic version as well.  This generic
9750 version works on any data type.  It uses the lock-free built-in function
9751 if the specific data type size makes that possible; otherwise, an
9752 external call is left to be resolved at run time.  This external call is
9753 the same format with the addition of a @samp{size_t} parameter inserted
9754 as the first parameter indicating the size of the object being pointed to.
9755 All objects must be the same size.
9757 There are 6 different memory orders that can be specified.  These map
9758 to the C++11 memory orders with the same names, see the C++11 standard
9759 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9760 on atomic synchronization} for detailed definitions.  Individual
9761 targets may also support additional memory orders for use on specific
9762 architectures.  Refer to the target documentation for details of
9763 these.
9765 An atomic operation can both constrain code motion and
9766 be mapped to hardware instructions for synchronization between threads
9767 (e.g., a fence).  To which extent this happens is controlled by the
9768 memory orders, which are listed here in approximately ascending order of
9769 strength.  The description of each memory order is only meant to roughly
9770 illustrate the effects and is not a specification; see the C++11
9771 memory model for precise semantics.
9773 @table  @code
9774 @item __ATOMIC_RELAXED
9775 Implies no inter-thread ordering constraints.
9776 @item __ATOMIC_CONSUME
9777 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9778 memory order because of a deficiency in C++11's semantics for
9779 @code{memory_order_consume}.
9780 @item __ATOMIC_ACQUIRE
9781 Creates an inter-thread happens-before constraint from the release (or
9782 stronger) semantic store to this acquire load.  Can prevent hoisting
9783 of code to before the operation.
9784 @item __ATOMIC_RELEASE
9785 Creates an inter-thread happens-before constraint to acquire (or stronger)
9786 semantic loads that read from this release store.  Can prevent sinking
9787 of code to after the operation.
9788 @item __ATOMIC_ACQ_REL
9789 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9790 @code{__ATOMIC_RELEASE}.
9791 @item __ATOMIC_SEQ_CST
9792 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9793 @end table
9795 Note that in the C++11 memory model, @emph{fences} (e.g.,
9796 @samp{__atomic_thread_fence}) take effect in combination with other
9797 atomic operations on specific memory locations (e.g., atomic loads);
9798 operations on specific memory locations do not necessarily affect other
9799 operations in the same way.
9801 Target architectures are encouraged to provide their own patterns for
9802 each of the atomic built-in functions.  If no target is provided, the original
9803 non-memory model set of @samp{__sync} atomic built-in functions are
9804 used, along with any required synchronization fences surrounding it in
9805 order to achieve the proper behavior.  Execution in this case is subject
9806 to the same restrictions as those built-in functions.
9808 If there is no pattern or mechanism to provide a lock-free instruction
9809 sequence, a call is made to an external routine with the same parameters
9810 to be resolved at run time.
9812 When implementing patterns for these built-in functions, the memory order
9813 parameter can be ignored as long as the pattern implements the most
9814 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
9815 orders execute correctly with this memory order but they may not execute as
9816 efficiently as they could with a more appropriate implementation of the
9817 relaxed requirements.
9819 Note that the C++11 standard allows for the memory order parameter to be
9820 determined at run time rather than at compile time.  These built-in
9821 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9822 than invoke a runtime library call or inline a switch statement.  This is
9823 standard compliant, safe, and the simplest approach for now.
9825 The memory order parameter is a signed int, but only the lower 16 bits are
9826 reserved for the memory order.  The remainder of the signed int is reserved
9827 for target use and should be 0.  Use of the predefined atomic values
9828 ensures proper usage.
9830 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9831 This built-in function implements an atomic load operation.  It returns the
9832 contents of @code{*@var{ptr}}.
9834 The valid memory order variants are
9835 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9836 and @code{__ATOMIC_CONSUME}.
9838 @end deftypefn
9840 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9841 This is the generic version of an atomic load.  It returns the
9842 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9844 @end deftypefn
9846 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9847 This built-in function implements an atomic store operation.  It writes 
9848 @code{@var{val}} into @code{*@var{ptr}}.  
9850 The valid memory order variants are
9851 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9853 @end deftypefn
9855 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9856 This is the generic version of an atomic store.  It stores the value
9857 of @code{*@var{val}} into @code{*@var{ptr}}.
9859 @end deftypefn
9861 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9862 This built-in function implements an atomic exchange operation.  It writes
9863 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9864 @code{*@var{ptr}}.
9866 The valid memory order variants are
9867 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9868 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9870 @end deftypefn
9872 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9873 This is the generic version of an atomic exchange.  It stores the
9874 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9875 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9877 @end deftypefn
9879 @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)
9880 This built-in function implements an atomic compare and exchange operation.
9881 This compares the contents of @code{*@var{ptr}} with the contents of
9882 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9883 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
9884 equal, the operation is a @emph{read} and the current contents of
9885 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
9886 for weak compare_exchange, which may fail spuriously, and false for
9887 the strong variation, which never fails spuriously.  Many targets
9888 only offer the strong variation and ignore the parameter.  When in doubt, use
9889 the strong variation.
9891 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9892 and memory is affected according to the
9893 memory order specified by @var{success_memorder}.  There are no
9894 restrictions on what memory order can be used here.
9896 Otherwise, false is returned and memory is affected according
9897 to @var{failure_memorder}. This memory order cannot be
9898 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
9899 stronger order than that specified by @var{success_memorder}.
9901 @end deftypefn
9903 @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)
9904 This built-in function implements the generic version of
9905 @code{__atomic_compare_exchange}.  The function is virtually identical to
9906 @code{__atomic_compare_exchange_n}, except the desired value is also a
9907 pointer.
9909 @end deftypefn
9911 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9912 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9913 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9914 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9915 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9916 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9917 These built-in functions perform the operation suggested by the name, and
9918 return the result of the operation.  Operations on pointer arguments are
9919 performed as if the operands were of the @code{uintptr_t} type.  That is,
9920 they are not scaled by the size of the type to which the pointer points.
9922 @smallexample
9923 @{ *ptr @var{op}= val; return *ptr; @}
9924 @end smallexample
9926 The object pointed to by the first argument must be of integer or pointer
9927 type.  It must not be a boolean type.  All memory orders are valid.
9929 @end deftypefn
9931 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9932 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9933 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9934 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9935 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9936 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9937 These built-in functions perform the operation suggested by the name, and
9938 return the value that had previously been in @code{*@var{ptr}}.  Operations
9939 on pointer arguments are performed as if the operands were of
9940 the @code{uintptr_t} type.  That is, they are not scaled by the size of
9941 the type to which the pointer points.
9943 @smallexample
9944 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9945 @end smallexample
9947 The same constraints on arguments apply as for the corresponding
9948 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
9950 @end deftypefn
9952 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9954 This built-in function performs an atomic test-and-set operation on
9955 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9956 defined nonzero ``set'' value and the return value is @code{true} if and only
9957 if the previous contents were ``set''.
9958 It should be only used for operands of type @code{bool} or @code{char}. For 
9959 other types only part of the value may be set.
9961 All memory orders are valid.
9963 @end deftypefn
9965 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9967 This built-in function performs an atomic clear operation on
9968 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9969 It should be only used for operands of type @code{bool} or @code{char} and 
9970 in conjunction with @code{__atomic_test_and_set}.
9971 For other types it may only clear partially. If the type is not @code{bool}
9972 prefer using @code{__atomic_store}.
9974 The valid memory order variants are
9975 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9976 @code{__ATOMIC_RELEASE}.
9978 @end deftypefn
9980 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9982 This built-in function acts as a synchronization fence between threads
9983 based on the specified memory order.
9985 All memory orders are valid.
9987 @end deftypefn
9989 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9991 This built-in function acts as a synchronization fence between a thread
9992 and signal handlers based in the same thread.
9994 All memory orders are valid.
9996 @end deftypefn
9998 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10000 This built-in function returns true if objects of @var{size} bytes always
10001 generate lock-free atomic instructions for the target architecture.
10002 @var{size} must resolve to a compile-time constant and the result also
10003 resolves to a compile-time constant.
10005 @var{ptr} is an optional pointer to the object that may be used to determine
10006 alignment.  A value of 0 indicates typical alignment should be used.  The 
10007 compiler may also ignore this parameter.
10009 @smallexample
10010 if (__atomic_always_lock_free (sizeof (long long), 0))
10011 @end smallexample
10013 @end deftypefn
10015 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10017 This built-in function returns true if objects of @var{size} bytes always
10018 generate lock-free atomic instructions for the target architecture.  If
10019 the built-in function is not known to be lock-free, a call is made to a
10020 runtime routine named @code{__atomic_is_lock_free}.
10022 @var{ptr} is an optional pointer to the object that may be used to determine
10023 alignment.  A value of 0 indicates typical alignment should be used.  The 
10024 compiler may also ignore this parameter.
10025 @end deftypefn
10027 @node Integer Overflow Builtins
10028 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10030 The following built-in functions allow performing simple arithmetic operations
10031 together with checking whether the operations overflowed.
10033 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10034 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10035 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10036 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10037 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10038 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10039 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10041 These built-in functions promote the first two operands into infinite precision signed
10042 type and perform addition on those promoted operands.  The result is then
10043 cast to the type the third pointer argument points to and stored there.
10044 If the stored result is equal to the infinite precision result, the built-in
10045 functions return false, otherwise they return true.  As the addition is
10046 performed in infinite signed precision, these built-in functions have fully defined
10047 behavior for all argument values.
10049 The first built-in function allows arbitrary integral types for operands and
10050 the result type must be pointer to some integral type other than enumerated or
10051 boolean type, the rest of the built-in functions have explicit integer types.
10053 The compiler will attempt to use hardware instructions to implement
10054 these built-in functions where possible, like conditional jump on overflow
10055 after addition, conditional jump on carry etc.
10057 @end deftypefn
10059 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10060 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10061 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10062 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10063 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10064 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10065 @deftypefnx {Built-in Function} bool __builtin_usubll_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 subtraction, subtract the second argument
10069 from the first one, instead of addition.
10071 @end deftypefn
10073 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10074 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10075 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10076 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10077 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10078 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10079 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10081 These built-in functions are similar to the add overflow checking built-in
10082 functions above, except they perform multiplication, instead of addition.
10084 @end deftypefn
10086 The following built-in functions allow checking if simple arithmetic operation
10087 would overflow.
10089 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10090 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10091 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10093 These built-in functions are similar to @code{__builtin_add_overflow},
10094 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10095 they don't store the result of the arithmetic operation anywhere and the
10096 last argument is not a pointer, but some expression with integral type other
10097 than enumerated or boolean type.
10099 The built-in functions promote the first two operands into infinite precision signed type
10100 and perform addition on those promoted operands. The result is then
10101 cast to the type of the third argument.  If the cast result is equal to the infinite
10102 precision result, the built-in functions return false, otherwise they return true.
10103 The value of the third argument is ignored, just the side-effects in the third argument
10104 are evaluated, and no integral argument promotions are performed on the last argument.
10105 If the third argument is a bit-field, the type used for the result cast has the
10106 precision and signedness of the given bit-field, rather than precision and signedness
10107 of the underlying type.
10109 For example, the following macro can be used to portably check, at
10110 compile-time, whether or not adding two constant integers will overflow,
10111 and perform the addition only when it is known to be safe and not to trigger
10112 a @option{-Woverflow} warning.
10114 @smallexample
10115 #define INT_ADD_OVERFLOW_P(a, b) \
10116    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10118 enum @{
10119     A = INT_MAX, B = 3,
10120     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10121     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10123 @end smallexample
10125 The compiler will attempt to use hardware instructions to implement
10126 these built-in functions where possible, like conditional jump on overflow
10127 after addition, conditional jump on carry etc.
10129 @end deftypefn
10131 @node x86 specific memory model extensions for transactional memory
10132 @section x86-Specific Memory Model Extensions for Transactional Memory
10134 The x86 architecture supports additional memory ordering flags
10135 to mark critical sections for hardware lock elision. 
10136 These must be specified in addition to an existing memory order to
10137 atomic intrinsics.
10139 @table @code
10140 @item __ATOMIC_HLE_ACQUIRE
10141 Start lock elision on a lock variable.
10142 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10143 @item __ATOMIC_HLE_RELEASE
10144 End lock elision on a lock variable.
10145 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10146 @end table
10148 When a lock acquire fails, it is required for good performance to abort
10149 the transaction quickly. This can be done with a @code{_mm_pause}.
10151 @smallexample
10152 #include <immintrin.h> // For _mm_pause
10154 int lockvar;
10156 /* Acquire lock with lock elision */
10157 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10158     _mm_pause(); /* Abort failed transaction */
10160 /* Free lock with lock elision */
10161 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10162 @end smallexample
10164 @node Object Size Checking
10165 @section Object Size Checking Built-in Functions
10166 @findex __builtin_object_size
10167 @findex __builtin___memcpy_chk
10168 @findex __builtin___mempcpy_chk
10169 @findex __builtin___memmove_chk
10170 @findex __builtin___memset_chk
10171 @findex __builtin___strcpy_chk
10172 @findex __builtin___stpcpy_chk
10173 @findex __builtin___strncpy_chk
10174 @findex __builtin___strcat_chk
10175 @findex __builtin___strncat_chk
10176 @findex __builtin___sprintf_chk
10177 @findex __builtin___snprintf_chk
10178 @findex __builtin___vsprintf_chk
10179 @findex __builtin___vsnprintf_chk
10180 @findex __builtin___printf_chk
10181 @findex __builtin___vprintf_chk
10182 @findex __builtin___fprintf_chk
10183 @findex __builtin___vfprintf_chk
10185 GCC implements a limited buffer overflow protection mechanism that can
10186 prevent some buffer overflow attacks by determining the sizes of objects
10187 into which data is about to be written and preventing the writes when
10188 the size isn't sufficient.  The built-in functions described below yield
10189 the best results when used together and when optimization is enabled.
10190 For example, to detect object sizes across function boundaries or to
10191 follow pointer assignments through non-trivial control flow they rely
10192 on various optimization passes enabled with @option{-O2}.  However, to
10193 a limited extent, they can be used without optimization as well.
10195 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10196 is a built-in construct that returns a constant number of bytes from
10197 @var{ptr} to the end of the object @var{ptr} pointer points to
10198 (if known at compile time).  @code{__builtin_object_size} never evaluates
10199 its arguments for side-effects.  If there are any side-effects in them, it
10200 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10201 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10202 point to and all of them are known at compile time, the returned number
10203 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10204 0 and minimum if nonzero.  If it is not possible to determine which objects
10205 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10206 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10207 for @var{type} 2 or 3.
10209 @var{type} is an integer constant from 0 to 3.  If the least significant
10210 bit is clear, objects are whole variables, if it is set, a closest
10211 surrounding subobject is considered the object a pointer points to.
10212 The second bit determines if maximum or minimum of remaining bytes
10213 is computed.
10215 @smallexample
10216 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10217 char *p = &var.buf1[1], *q = &var.b;
10219 /* Here the object p points to is var.  */
10220 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10221 /* The subobject p points to is var.buf1.  */
10222 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10223 /* The object q points to is var.  */
10224 assert (__builtin_object_size (q, 0)
10225         == (char *) (&var + 1) - (char *) &var.b);
10226 /* The subobject q points to is var.b.  */
10227 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10228 @end smallexample
10229 @end deftypefn
10231 There are built-in functions added for many common string operation
10232 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10233 built-in is provided.  This built-in has an additional last argument,
10234 which is the number of bytes remaining in the object the @var{dest}
10235 argument points to or @code{(size_t) -1} if the size is not known.
10237 The built-in functions are optimized into the normal string functions
10238 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10239 it is known at compile time that the destination object will not
10240 be overflowed.  If the compiler can determine at compile time that the
10241 object will always be overflowed, it issues a warning.
10243 The intended use can be e.g.@:
10245 @smallexample
10246 #undef memcpy
10247 #define bos0(dest) __builtin_object_size (dest, 0)
10248 #define memcpy(dest, src, n) \
10249   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10251 char *volatile p;
10252 char buf[10];
10253 /* It is unknown what object p points to, so this is optimized
10254    into plain memcpy - no checking is possible.  */
10255 memcpy (p, "abcde", n);
10256 /* Destination is known and length too.  It is known at compile
10257    time there will be no overflow.  */
10258 memcpy (&buf[5], "abcde", 5);
10259 /* Destination is known, but the length is not known at compile time.
10260    This will result in __memcpy_chk call that can check for overflow
10261    at run time.  */
10262 memcpy (&buf[5], "abcde", n);
10263 /* Destination is known and it is known at compile time there will
10264    be overflow.  There will be a warning and __memcpy_chk call that
10265    will abort the program at run time.  */
10266 memcpy (&buf[6], "abcde", 5);
10267 @end smallexample
10269 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10270 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10271 @code{strcat} and @code{strncat}.
10273 There are also checking built-in functions for formatted output functions.
10274 @smallexample
10275 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10276 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10277                               const char *fmt, ...);
10278 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10279                               va_list ap);
10280 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10281                                const char *fmt, va_list ap);
10282 @end smallexample
10284 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10285 etc.@: functions and can contain implementation specific flags on what
10286 additional security measures the checking function might take, such as
10287 handling @code{%n} differently.
10289 The @var{os} argument is the object size @var{s} points to, like in the
10290 other built-in functions.  There is a small difference in the behavior
10291 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10292 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10293 the checking function is called with @var{os} argument set to
10294 @code{(size_t) -1}.
10296 In addition to this, there are checking built-in functions
10297 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10298 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10299 These have just one additional argument, @var{flag}, right before
10300 format string @var{fmt}.  If the compiler is able to optimize them to
10301 @code{fputc} etc.@: functions, it does, otherwise the checking function
10302 is called and the @var{flag} argument passed to it.
10304 @node Pointer Bounds Checker builtins
10305 @section Pointer Bounds Checker Built-in Functions
10306 @cindex Pointer Bounds Checker builtins
10307 @findex __builtin___bnd_set_ptr_bounds
10308 @findex __builtin___bnd_narrow_ptr_bounds
10309 @findex __builtin___bnd_copy_ptr_bounds
10310 @findex __builtin___bnd_init_ptr_bounds
10311 @findex __builtin___bnd_null_ptr_bounds
10312 @findex __builtin___bnd_store_ptr_bounds
10313 @findex __builtin___bnd_chk_ptr_lbounds
10314 @findex __builtin___bnd_chk_ptr_ubounds
10315 @findex __builtin___bnd_chk_ptr_bounds
10316 @findex __builtin___bnd_get_ptr_lbound
10317 @findex __builtin___bnd_get_ptr_ubound
10319 GCC provides a set of built-in functions to control Pointer Bounds Checker
10320 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
10321 even if you compile with Pointer Bounds Checker off
10322 (@option{-fno-check-pointer-bounds}).
10323 The behavior may differ in such case as documented below.
10325 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10327 This built-in function returns a new pointer with the value of @var{q}, and
10328 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
10329 Bounds Checker off, the built-in function just returns the first argument.
10331 @smallexample
10332 extern void *__wrap_malloc (size_t n)
10334   void *p = (void *)__real_malloc (n);
10335   if (!p) return __builtin___bnd_null_ptr_bounds (p);
10336   return __builtin___bnd_set_ptr_bounds (p, n);
10338 @end smallexample
10340 @end deftypefn
10342 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
10344 This built-in function returns a new pointer with the value of @var{p}
10345 and associates it with the narrowed bounds formed by the intersection
10346 of bounds associated with @var{q} and the bounds
10347 [@var{p}, @var{p} + @var{size} - 1].
10348 With Pointer Bounds Checker off, the built-in function just returns the first
10349 argument.
10351 @smallexample
10352 void init_objects (object *objs, size_t size)
10354   size_t i;
10355   /* Initialize objects one-by-one passing pointers with bounds of 
10356      an object, not the full array of objects.  */
10357   for (i = 0; i < size; i++)
10358     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10359                                                     sizeof(object)));
10361 @end smallexample
10363 @end deftypefn
10365 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10367 This built-in function returns a new pointer with the value of @var{q},
10368 and associates it with the bounds already associated with pointer @var{r}.
10369 With Pointer Bounds Checker off, the built-in function just returns the first
10370 argument.
10372 @smallexample
10373 /* Here is a way to get pointer to object's field but
10374    still with the full object's bounds.  */
10375 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
10376                                                   objptr);
10377 @end smallexample
10379 @end deftypefn
10381 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10383 This built-in function returns a new pointer with the value of @var{q}, and
10384 associates it with INIT (allowing full memory access) bounds. With Pointer
10385 Bounds Checker off, the built-in function just returns the first argument.
10387 @end deftypefn
10389 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10391 This built-in function returns a new pointer with the value of @var{q}, and
10392 associates it with NULL (allowing no memory access) bounds. With Pointer
10393 Bounds Checker off, the built-in function just returns the first argument.
10395 @end deftypefn
10397 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10399 This built-in function stores the bounds associated with pointer @var{ptr_val}
10400 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
10401 bounds from legacy code without touching the associated pointer's memory when
10402 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
10403 function call is ignored.
10405 @end deftypefn
10407 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10409 This built-in function checks if the pointer @var{q} is within the lower
10410 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10411 function call is ignored.
10413 @smallexample
10414 extern void *__wrap_memset (void *dst, int c, size_t len)
10416   if (len > 0)
10417     @{
10418       __builtin___bnd_chk_ptr_lbounds (dst);
10419       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10420       __real_memset (dst, c, len);
10421     @}
10422   return dst;
10424 @end smallexample
10426 @end deftypefn
10428 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10430 This built-in function checks if the pointer @var{q} is within the upper
10431 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10432 function call is ignored.
10434 @end deftypefn
10436 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10438 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10439 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
10440 off, the built-in function call is ignored.
10442 @smallexample
10443 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10445   if (n > 0)
10446     @{
10447       __bnd_chk_ptr_bounds (dst, n);
10448       __bnd_chk_ptr_bounds (src, n);
10449       __real_memcpy (dst, src, n);
10450     @}
10451   return dst;
10453 @end smallexample
10455 @end deftypefn
10457 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10459 This built-in function returns the lower bound associated
10460 with the pointer @var{q}, as a pointer value.  
10461 This is useful for debugging using @code{printf}.
10462 With Pointer Bounds Checker off, the built-in function returns 0.
10464 @smallexample
10465 void *lb = __builtin___bnd_get_ptr_lbound (q);
10466 void *ub = __builtin___bnd_get_ptr_ubound (q);
10467 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
10468 @end smallexample
10470 @end deftypefn
10472 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10474 This built-in function returns the upper bound (which is a pointer) associated
10475 with the pointer @var{q}.  With Pointer Bounds Checker off,
10476 the built-in function returns -1.
10478 @end deftypefn
10480 @node Cilk Plus Builtins
10481 @section Cilk Plus C/C++ Language Extension Built-in Functions
10483 GCC provides support for the following built-in reduction functions if Cilk Plus
10484 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10486 @itemize @bullet
10487 @item @code{__sec_implicit_index}
10488 @item @code{__sec_reduce}
10489 @item @code{__sec_reduce_add}
10490 @item @code{__sec_reduce_all_nonzero}
10491 @item @code{__sec_reduce_all_zero}
10492 @item @code{__sec_reduce_any_nonzero}
10493 @item @code{__sec_reduce_any_zero}
10494 @item @code{__sec_reduce_max}
10495 @item @code{__sec_reduce_min}
10496 @item @code{__sec_reduce_max_ind}
10497 @item @code{__sec_reduce_min_ind}
10498 @item @code{__sec_reduce_mul}
10499 @item @code{__sec_reduce_mutating}
10500 @end itemize
10502 Further details and examples about these built-in functions are described 
10503 in the Cilk Plus language manual which can be found at 
10504 @uref{https://www.cilkplus.org}.
10506 @node Other Builtins
10507 @section Other Built-in Functions Provided by GCC
10508 @cindex built-in functions
10509 @findex __builtin_alloca
10510 @findex __builtin_alloca_with_align
10511 @findex __builtin_call_with_static_chain
10512 @findex __builtin_fpclassify
10513 @findex __builtin_isfinite
10514 @findex __builtin_isnormal
10515 @findex __builtin_isgreater
10516 @findex __builtin_isgreaterequal
10517 @findex __builtin_isinf_sign
10518 @findex __builtin_isless
10519 @findex __builtin_islessequal
10520 @findex __builtin_islessgreater
10521 @findex __builtin_isunordered
10522 @findex __builtin_powi
10523 @findex __builtin_powif
10524 @findex __builtin_powil
10525 @findex _Exit
10526 @findex _exit
10527 @findex abort
10528 @findex abs
10529 @findex acos
10530 @findex acosf
10531 @findex acosh
10532 @findex acoshf
10533 @findex acoshl
10534 @findex acosl
10535 @findex alloca
10536 @findex asin
10537 @findex asinf
10538 @findex asinh
10539 @findex asinhf
10540 @findex asinhl
10541 @findex asinl
10542 @findex atan
10543 @findex atan2
10544 @findex atan2f
10545 @findex atan2l
10546 @findex atanf
10547 @findex atanh
10548 @findex atanhf
10549 @findex atanhl
10550 @findex atanl
10551 @findex bcmp
10552 @findex bzero
10553 @findex cabs
10554 @findex cabsf
10555 @findex cabsl
10556 @findex cacos
10557 @findex cacosf
10558 @findex cacosh
10559 @findex cacoshf
10560 @findex cacoshl
10561 @findex cacosl
10562 @findex calloc
10563 @findex carg
10564 @findex cargf
10565 @findex cargl
10566 @findex casin
10567 @findex casinf
10568 @findex casinh
10569 @findex casinhf
10570 @findex casinhl
10571 @findex casinl
10572 @findex catan
10573 @findex catanf
10574 @findex catanh
10575 @findex catanhf
10576 @findex catanhl
10577 @findex catanl
10578 @findex cbrt
10579 @findex cbrtf
10580 @findex cbrtl
10581 @findex ccos
10582 @findex ccosf
10583 @findex ccosh
10584 @findex ccoshf
10585 @findex ccoshl
10586 @findex ccosl
10587 @findex ceil
10588 @findex ceilf
10589 @findex ceill
10590 @findex cexp
10591 @findex cexpf
10592 @findex cexpl
10593 @findex cimag
10594 @findex cimagf
10595 @findex cimagl
10596 @findex clog
10597 @findex clogf
10598 @findex clogl
10599 @findex clog10
10600 @findex clog10f
10601 @findex clog10l
10602 @findex conj
10603 @findex conjf
10604 @findex conjl
10605 @findex copysign
10606 @findex copysignf
10607 @findex copysignl
10608 @findex cos
10609 @findex cosf
10610 @findex cosh
10611 @findex coshf
10612 @findex coshl
10613 @findex cosl
10614 @findex cpow
10615 @findex cpowf
10616 @findex cpowl
10617 @findex cproj
10618 @findex cprojf
10619 @findex cprojl
10620 @findex creal
10621 @findex crealf
10622 @findex creall
10623 @findex csin
10624 @findex csinf
10625 @findex csinh
10626 @findex csinhf
10627 @findex csinhl
10628 @findex csinl
10629 @findex csqrt
10630 @findex csqrtf
10631 @findex csqrtl
10632 @findex ctan
10633 @findex ctanf
10634 @findex ctanh
10635 @findex ctanhf
10636 @findex ctanhl
10637 @findex ctanl
10638 @findex dcgettext
10639 @findex dgettext
10640 @findex drem
10641 @findex dremf
10642 @findex dreml
10643 @findex erf
10644 @findex erfc
10645 @findex erfcf
10646 @findex erfcl
10647 @findex erff
10648 @findex erfl
10649 @findex exit
10650 @findex exp
10651 @findex exp10
10652 @findex exp10f
10653 @findex exp10l
10654 @findex exp2
10655 @findex exp2f
10656 @findex exp2l
10657 @findex expf
10658 @findex expl
10659 @findex expm1
10660 @findex expm1f
10661 @findex expm1l
10662 @findex fabs
10663 @findex fabsf
10664 @findex fabsl
10665 @findex fdim
10666 @findex fdimf
10667 @findex fdiml
10668 @findex ffs
10669 @findex floor
10670 @findex floorf
10671 @findex floorl
10672 @findex fma
10673 @findex fmaf
10674 @findex fmal
10675 @findex fmax
10676 @findex fmaxf
10677 @findex fmaxl
10678 @findex fmin
10679 @findex fminf
10680 @findex fminl
10681 @findex fmod
10682 @findex fmodf
10683 @findex fmodl
10684 @findex fprintf
10685 @findex fprintf_unlocked
10686 @findex fputs
10687 @findex fputs_unlocked
10688 @findex frexp
10689 @findex frexpf
10690 @findex frexpl
10691 @findex fscanf
10692 @findex gamma
10693 @findex gammaf
10694 @findex gammal
10695 @findex gamma_r
10696 @findex gammaf_r
10697 @findex gammal_r
10698 @findex gettext
10699 @findex hypot
10700 @findex hypotf
10701 @findex hypotl
10702 @findex ilogb
10703 @findex ilogbf
10704 @findex ilogbl
10705 @findex imaxabs
10706 @findex index
10707 @findex isalnum
10708 @findex isalpha
10709 @findex isascii
10710 @findex isblank
10711 @findex iscntrl
10712 @findex isdigit
10713 @findex isgraph
10714 @findex islower
10715 @findex isprint
10716 @findex ispunct
10717 @findex isspace
10718 @findex isupper
10719 @findex iswalnum
10720 @findex iswalpha
10721 @findex iswblank
10722 @findex iswcntrl
10723 @findex iswdigit
10724 @findex iswgraph
10725 @findex iswlower
10726 @findex iswprint
10727 @findex iswpunct
10728 @findex iswspace
10729 @findex iswupper
10730 @findex iswxdigit
10731 @findex isxdigit
10732 @findex j0
10733 @findex j0f
10734 @findex j0l
10735 @findex j1
10736 @findex j1f
10737 @findex j1l
10738 @findex jn
10739 @findex jnf
10740 @findex jnl
10741 @findex labs
10742 @findex ldexp
10743 @findex ldexpf
10744 @findex ldexpl
10745 @findex lgamma
10746 @findex lgammaf
10747 @findex lgammal
10748 @findex lgamma_r
10749 @findex lgammaf_r
10750 @findex lgammal_r
10751 @findex llabs
10752 @findex llrint
10753 @findex llrintf
10754 @findex llrintl
10755 @findex llround
10756 @findex llroundf
10757 @findex llroundl
10758 @findex log
10759 @findex log10
10760 @findex log10f
10761 @findex log10l
10762 @findex log1p
10763 @findex log1pf
10764 @findex log1pl
10765 @findex log2
10766 @findex log2f
10767 @findex log2l
10768 @findex logb
10769 @findex logbf
10770 @findex logbl
10771 @findex logf
10772 @findex logl
10773 @findex lrint
10774 @findex lrintf
10775 @findex lrintl
10776 @findex lround
10777 @findex lroundf
10778 @findex lroundl
10779 @findex malloc
10780 @findex memchr
10781 @findex memcmp
10782 @findex memcpy
10783 @findex mempcpy
10784 @findex memset
10785 @findex modf
10786 @findex modff
10787 @findex modfl
10788 @findex nearbyint
10789 @findex nearbyintf
10790 @findex nearbyintl
10791 @findex nextafter
10792 @findex nextafterf
10793 @findex nextafterl
10794 @findex nexttoward
10795 @findex nexttowardf
10796 @findex nexttowardl
10797 @findex pow
10798 @findex pow10
10799 @findex pow10f
10800 @findex pow10l
10801 @findex powf
10802 @findex powl
10803 @findex printf
10804 @findex printf_unlocked
10805 @findex putchar
10806 @findex puts
10807 @findex remainder
10808 @findex remainderf
10809 @findex remainderl
10810 @findex remquo
10811 @findex remquof
10812 @findex remquol
10813 @findex rindex
10814 @findex rint
10815 @findex rintf
10816 @findex rintl
10817 @findex round
10818 @findex roundf
10819 @findex roundl
10820 @findex scalb
10821 @findex scalbf
10822 @findex scalbl
10823 @findex scalbln
10824 @findex scalblnf
10825 @findex scalblnf
10826 @findex scalbn
10827 @findex scalbnf
10828 @findex scanfnl
10829 @findex signbit
10830 @findex signbitf
10831 @findex signbitl
10832 @findex signbitd32
10833 @findex signbitd64
10834 @findex signbitd128
10835 @findex significand
10836 @findex significandf
10837 @findex significandl
10838 @findex sin
10839 @findex sincos
10840 @findex sincosf
10841 @findex sincosl
10842 @findex sinf
10843 @findex sinh
10844 @findex sinhf
10845 @findex sinhl
10846 @findex sinl
10847 @findex snprintf
10848 @findex sprintf
10849 @findex sqrt
10850 @findex sqrtf
10851 @findex sqrtl
10852 @findex sscanf
10853 @findex stpcpy
10854 @findex stpncpy
10855 @findex strcasecmp
10856 @findex strcat
10857 @findex strchr
10858 @findex strcmp
10859 @findex strcpy
10860 @findex strcspn
10861 @findex strdup
10862 @findex strfmon
10863 @findex strftime
10864 @findex strlen
10865 @findex strncasecmp
10866 @findex strncat
10867 @findex strncmp
10868 @findex strncpy
10869 @findex strndup
10870 @findex strpbrk
10871 @findex strrchr
10872 @findex strspn
10873 @findex strstr
10874 @findex tan
10875 @findex tanf
10876 @findex tanh
10877 @findex tanhf
10878 @findex tanhl
10879 @findex tanl
10880 @findex tgamma
10881 @findex tgammaf
10882 @findex tgammal
10883 @findex toascii
10884 @findex tolower
10885 @findex toupper
10886 @findex towlower
10887 @findex towupper
10888 @findex trunc
10889 @findex truncf
10890 @findex truncl
10891 @findex vfprintf
10892 @findex vfscanf
10893 @findex vprintf
10894 @findex vscanf
10895 @findex vsnprintf
10896 @findex vsprintf
10897 @findex vsscanf
10898 @findex y0
10899 @findex y0f
10900 @findex y0l
10901 @findex y1
10902 @findex y1f
10903 @findex y1l
10904 @findex yn
10905 @findex ynf
10906 @findex ynl
10908 GCC provides a large number of built-in functions other than the ones
10909 mentioned above.  Some of these are for internal use in the processing
10910 of exceptions or variable-length argument lists and are not
10911 documented here because they may change from time to time; we do not
10912 recommend general use of these functions.
10914 The remaining functions are provided for optimization purposes.
10916 With the exception of built-ins that have library equivalents such as
10917 the standard C library functions discussed below, or that expand to
10918 library calls, GCC built-in functions are always expanded inline and
10919 thus do not have corresponding entry points and their address cannot
10920 be obtained.  Attempting to use them in an expression other than
10921 a function call results in a compile-time error.
10923 @opindex fno-builtin
10924 GCC includes built-in versions of many of the functions in the standard
10925 C library.  These functions come in two forms: one whose names start with
10926 the @code{__builtin_} prefix, and the other without.  Both forms have the
10927 same type (including prototype), the same address (when their address is
10928 taken), and the same meaning as the C library functions even if you specify
10929 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
10930 functions are only optimized in certain cases; if they are not optimized in
10931 a particular case, a call to the library function is emitted.
10933 @opindex ansi
10934 @opindex std
10935 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10936 @option{-std=c99} or @option{-std=c11}), the functions
10937 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10938 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10939 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10940 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10941 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10942 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10943 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10944 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10945 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10946 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10947 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10948 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10949 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10950 @code{significandl}, @code{significand}, @code{sincosf},
10951 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10952 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10953 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10954 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10955 @code{yn}
10956 may be handled as built-in functions.
10957 All these functions have corresponding versions
10958 prefixed with @code{__builtin_}, which may be used even in strict C90
10959 mode.
10961 The ISO C99 functions
10962 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10963 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10964 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10965 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10966 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10967 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10968 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10969 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10970 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10971 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10972 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10973 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10974 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10975 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10976 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10977 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10978 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10979 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10980 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10981 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10982 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10983 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10984 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10985 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10986 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10987 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10988 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10989 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10990 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10991 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10992 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10993 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10994 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10995 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10996 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10997 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10998 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10999 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11000 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11001 are handled as built-in functions
11002 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11004 There are also built-in versions of the ISO C99 functions
11005 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11006 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11007 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11008 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11009 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11010 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11011 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11012 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11013 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11014 that are recognized in any mode since ISO C90 reserves these names for
11015 the purpose to which ISO C99 puts them.  All these functions have
11016 corresponding versions prefixed with @code{__builtin_}.
11018 There are also built-in functions @code{__builtin_fabsf@var{n}},
11019 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11020 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11021 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11022 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11023 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11025 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11026 @code{clog10l} which names are reserved by ISO C99 for future use.
11027 All these functions have versions prefixed with @code{__builtin_}.
11029 The ISO C94 functions
11030 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11031 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11032 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11033 @code{towupper}
11034 are handled as built-in functions
11035 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11037 The ISO C90 functions
11038 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11039 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11040 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11041 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11042 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11043 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11044 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11045 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11046 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11047 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11048 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11049 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11050 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11051 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11052 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11053 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11054 are all recognized as built-in functions unless
11055 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11056 is specified for an individual function).  All of these functions have
11057 corresponding versions prefixed with @code{__builtin_}.
11059 GCC provides built-in versions of the ISO C99 floating-point comparison
11060 macros that avoid raising exceptions for unordered operands.  They have
11061 the same names as the standard macros ( @code{isgreater},
11062 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11063 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11064 prefixed.  We intend for a library implementor to be able to simply
11065 @code{#define} each standard macro to its built-in equivalent.
11066 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11067 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11068 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11069 built-in functions appear both with and without the @code{__builtin_} prefix.
11071 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11072 The @code{__builtin_alloca} function must be called at block scope.
11073 The function allocates an object @var{size} bytes large on the stack
11074 of the calling function.  The object is aligned on the default stack
11075 alignment boundary for the target determined by the
11076 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11077 function returns a pointer to the first byte of the allocated object.
11078 The lifetime of the allocated object ends just before the calling
11079 function returns to its caller.   This is so even when
11080 @code{__builtin_alloca} is called within a nested block.
11082 For example, the following function allocates eight objects of @code{n}
11083 bytes each on the stack, storing a pointer to each in consecutive elements
11084 of the array @code{a}.  It then passes the array to function @code{g}
11085 which can safely use the storage pointed to by each of the array elements.
11087 @smallexample
11088 void f (unsigned n)
11090   void *a [8];
11091   for (int i = 0; i != 8; ++i)
11092     a [i] = __builtin_alloca (n);
11094   g (a, n);   // @r{safe}
11096 @end smallexample
11098 Since the @code{__builtin_alloca} function doesn't validate its argument
11099 it is the responsibility of its caller to make sure the argument doesn't
11100 cause it to exceed the stack size limit.
11101 The @code{__builtin_alloca} function is provided to make it possible to
11102 allocate on the stack arrays of bytes with an upper bound that may be
11103 computed at run time.  Since C99 Variable Length Arrays offer
11104 similar functionality under a portable, more convenient, and safer
11105 interface they are recommended instead, in both C99 and C++ programs
11106 where GCC provides them as an extension.
11107 @xref{Variable Length}, for details.
11109 @end deftypefn
11111 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11112 The @code{__builtin_alloca_with_align} function must be called at block
11113 scope.  The function allocates an object @var{size} bytes large on
11114 the stack of the calling function.  The allocated object is aligned on
11115 the boundary specified by the argument @var{alignment} whose unit is given
11116 in bits (not bytes).  The @var{size} argument must be positive and not
11117 exceed the stack size limit.  The @var{alignment} argument must be a constant
11118 integer expression that evaluates to a power of 2 greater than or equal to
11119 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11120 with other values are rejected with an error indicating the valid bounds.
11121 The function returns a pointer to the first byte of the allocated object.
11122 The lifetime of the allocated object ends at the end of the block in which
11123 the function was called.  The allocated storage is released no later than
11124 just before the calling function returns to its caller, but may be released
11125 at the end of the block in which the function was called.
11127 For example, in the following function the call to @code{g} is unsafe
11128 because when @code{overalign} is non-zero, the space allocated by
11129 @code{__builtin_alloca_with_align} may have been released at the end
11130 of the @code{if} statement in which it was called.
11132 @smallexample
11133 void f (unsigned n, bool overalign)
11135   void *p;
11136   if (overalign)
11137     p = __builtin_alloca_with_align (n, 64 /* bits */);
11138   else
11139     p = __builtin_alloc (n);
11141   g (p, n);   // @r{unsafe}
11143 @end smallexample
11145 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11146 @var{size} argument it is the responsibility of its caller to make sure
11147 the argument doesn't cause it to exceed the stack size limit.
11148 The @code{__builtin_alloca_with_align} function is provided to make
11149 it possible to allocate on the stack overaligned arrays of bytes with
11150 an upper bound that may be computed at run time.  Since C99
11151 Variable Length Arrays offer the same functionality under
11152 a portable, more convenient, and safer interface they are recommended
11153 instead, in both C99 and C++ programs where GCC provides them as
11154 an extension.  @xref{Variable Length}, for details.
11156 @end deftypefn
11158 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11160 You can use the built-in function @code{__builtin_types_compatible_p} to
11161 determine whether two types are the same.
11163 This built-in function returns 1 if the unqualified versions of the
11164 types @var{type1} and @var{type2} (which are types, not expressions) are
11165 compatible, 0 otherwise.  The result of this built-in function can be
11166 used in integer constant expressions.
11168 This built-in function ignores top level qualifiers (e.g., @code{const},
11169 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11170 int}.
11172 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11173 hand, @code{int} and @code{char *} are not compatible, even if the size
11174 of their types, on the particular architecture are the same.  Also, the
11175 amount of pointer indirection is taken into account when determining
11176 similarity.  Consequently, @code{short *} is not similar to
11177 @code{short **}.  Furthermore, two types that are typedefed are
11178 considered compatible if their underlying types are compatible.
11180 An @code{enum} type is not considered to be compatible with another
11181 @code{enum} type even if both are compatible with the same integer
11182 type; this is what the C standard specifies.
11183 For example, @code{enum @{foo, bar@}} is not similar to
11184 @code{enum @{hot, dog@}}.
11186 You typically use this function in code whose execution varies
11187 depending on the arguments' types.  For example:
11189 @smallexample
11190 #define foo(x)                                                  \
11191   (@{                                                           \
11192     typeof (x) tmp = (x);                                       \
11193     if (__builtin_types_compatible_p (typeof (x), long double)) \
11194       tmp = foo_long_double (tmp);                              \
11195     else if (__builtin_types_compatible_p (typeof (x), double)) \
11196       tmp = foo_double (tmp);                                   \
11197     else if (__builtin_types_compatible_p (typeof (x), float))  \
11198       tmp = foo_float (tmp);                                    \
11199     else                                                        \
11200       abort ();                                                 \
11201     tmp;                                                        \
11202   @})
11203 @end smallexample
11205 @emph{Note:} This construct is only available for C@.
11207 @end deftypefn
11209 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11211 The @var{call_exp} expression must be a function call, and the
11212 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11213 is passed to the function call in the target's static chain location.
11214 The result of builtin is the result of the function call.
11216 @emph{Note:} This builtin is only available for C@.
11217 This builtin can be used to call Go closures from C.
11219 @end deftypefn
11221 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11223 You can use the built-in function @code{__builtin_choose_expr} to
11224 evaluate code depending on the value of a constant expression.  This
11225 built-in function returns @var{exp1} if @var{const_exp}, which is an
11226 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11228 This built-in function is analogous to the @samp{? :} operator in C,
11229 except that the expression returned has its type unaltered by promotion
11230 rules.  Also, the built-in function does not evaluate the expression
11231 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11232 @var{exp2} is not evaluated even if it has side-effects.
11234 This built-in function can return an lvalue if the chosen argument is an
11235 lvalue.
11237 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11238 type.  Similarly, if @var{exp2} is returned, its return type is the same
11239 as @var{exp2}.
11241 Example:
11243 @smallexample
11244 #define foo(x)                                                    \
11245   __builtin_choose_expr (                                         \
11246     __builtin_types_compatible_p (typeof (x), double),            \
11247     foo_double (x),                                               \
11248     __builtin_choose_expr (                                       \
11249       __builtin_types_compatible_p (typeof (x), float),           \
11250       foo_float (x),                                              \
11251       /* @r{The void expression results in a compile-time error}  \
11252          @r{when assigning the result to something.}  */          \
11253       (void)0))
11254 @end smallexample
11256 @emph{Note:} This construct is only available for C@.  Furthermore, the
11257 unused expression (@var{exp1} or @var{exp2} depending on the value of
11258 @var{const_exp}) may still generate syntax errors.  This may change in
11259 future revisions.
11261 @end deftypefn
11263 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11265 The built-in function @code{__builtin_complex} is provided for use in
11266 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11267 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11268 real binary floating-point type, and the result has the corresponding
11269 complex type with real and imaginary parts @var{real} and @var{imag}.
11270 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11271 infinities, NaNs and negative zeros are involved.
11273 @end deftypefn
11275 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11276 You can use the built-in function @code{__builtin_constant_p} to
11277 determine if a value is known to be constant at compile time and hence
11278 that GCC can perform constant-folding on expressions involving that
11279 value.  The argument of the function is the value to test.  The function
11280 returns the integer 1 if the argument is known to be a compile-time
11281 constant and 0 if it is not known to be a compile-time constant.  A
11282 return of 0 does not indicate that the value is @emph{not} a constant,
11283 but merely that GCC cannot prove it is a constant with the specified
11284 value of the @option{-O} option.
11286 You typically use this function in an embedded application where
11287 memory is a critical resource.  If you have some complex calculation,
11288 you may want it to be folded if it involves constants, but need to call
11289 a function if it does not.  For example:
11291 @smallexample
11292 #define Scale_Value(X)      \
11293   (__builtin_constant_p (X) \
11294   ? ((X) * SCALE + OFFSET) : Scale (X))
11295 @end smallexample
11297 You may use this built-in function in either a macro or an inline
11298 function.  However, if you use it in an inlined function and pass an
11299 argument of the function as the argument to the built-in, GCC 
11300 never returns 1 when you call the inline function with a string constant
11301 or compound literal (@pxref{Compound Literals}) and does not return 1
11302 when you pass a constant numeric value to the inline function unless you
11303 specify the @option{-O} option.
11305 You may also use @code{__builtin_constant_p} in initializers for static
11306 data.  For instance, you can write
11308 @smallexample
11309 static const int table[] = @{
11310    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11311    /* @r{@dots{}} */
11313 @end smallexample
11315 @noindent
11316 This is an acceptable initializer even if @var{EXPRESSION} is not a
11317 constant expression, including the case where
11318 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11319 folded to a constant but @var{EXPRESSION} contains operands that are
11320 not otherwise permitted in a static initializer (for example,
11321 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11322 built-in in this case, because it has no opportunity to perform
11323 optimization.
11324 @end deftypefn
11326 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11327 @opindex fprofile-arcs
11328 You may use @code{__builtin_expect} to provide the compiler with
11329 branch prediction information.  In general, you should prefer to
11330 use actual profile feedback for this (@option{-fprofile-arcs}), as
11331 programmers are notoriously bad at predicting how their programs
11332 actually perform.  However, there are applications in which this
11333 data is hard to collect.
11335 The return value is the value of @var{exp}, which should be an integral
11336 expression.  The semantics of the built-in are that it is expected that
11337 @var{exp} == @var{c}.  For example:
11339 @smallexample
11340 if (__builtin_expect (x, 0))
11341   foo ();
11342 @end smallexample
11344 @noindent
11345 indicates that we do not expect to call @code{foo}, since
11346 we expect @code{x} to be zero.  Since you are limited to integral
11347 expressions for @var{exp}, you should use constructions such as
11349 @smallexample
11350 if (__builtin_expect (ptr != NULL, 1))
11351   foo (*ptr);
11352 @end smallexample
11354 @noindent
11355 when testing pointer or floating-point values.
11356 @end deftypefn
11358 @deftypefn {Built-in Function} void __builtin_trap (void)
11359 This function causes the program to exit abnormally.  GCC implements
11360 this function by using a target-dependent mechanism (such as
11361 intentionally executing an illegal instruction) or by calling
11362 @code{abort}.  The mechanism used may vary from release to release so
11363 you should not rely on any particular implementation.
11364 @end deftypefn
11366 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11367 If control flow reaches the point of the @code{__builtin_unreachable},
11368 the program is undefined.  It is useful in situations where the
11369 compiler cannot deduce the unreachability of the code.
11371 One such case is immediately following an @code{asm} statement that
11372 either never terminates, or one that transfers control elsewhere
11373 and never returns.  In this example, without the
11374 @code{__builtin_unreachable}, GCC issues a warning that control
11375 reaches the end of a non-void function.  It also generates code
11376 to return after the @code{asm}.
11378 @smallexample
11379 int f (int c, int v)
11381   if (c)
11382     @{
11383       return v;
11384     @}
11385   else
11386     @{
11387       asm("jmp error_handler");
11388       __builtin_unreachable ();
11389     @}
11391 @end smallexample
11393 @noindent
11394 Because the @code{asm} statement unconditionally transfers control out
11395 of the function, control never reaches the end of the function
11396 body.  The @code{__builtin_unreachable} is in fact unreachable and
11397 communicates this fact to the compiler.
11399 Another use for @code{__builtin_unreachable} is following a call a
11400 function that never returns but that is not declared
11401 @code{__attribute__((noreturn))}, as in this example:
11403 @smallexample
11404 void function_that_never_returns (void);
11406 int g (int c)
11408   if (c)
11409     @{
11410       return 1;
11411     @}
11412   else
11413     @{
11414       function_that_never_returns ();
11415       __builtin_unreachable ();
11416     @}
11418 @end smallexample
11420 @end deftypefn
11422 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11423 This function returns its first argument, and allows the compiler
11424 to assume that the returned pointer is at least @var{align} bytes
11425 aligned.  This built-in can have either two or three arguments,
11426 if it has three, the third argument should have integer type, and
11427 if it is nonzero means misalignment offset.  For example:
11429 @smallexample
11430 void *x = __builtin_assume_aligned (arg, 16);
11431 @end smallexample
11433 @noindent
11434 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11435 16-byte aligned, while:
11437 @smallexample
11438 void *x = __builtin_assume_aligned (arg, 32, 8);
11439 @end smallexample
11441 @noindent
11442 means that the compiler can assume for @code{x}, set to @code{arg}, that
11443 @code{(char *) x - 8} is 32-byte aligned.
11444 @end deftypefn
11446 @deftypefn {Built-in Function} int __builtin_LINE ()
11447 This function is the equivalent of the preprocessor @code{__LINE__}
11448 macro and returns a constant integer expression that evaluates to
11449 the line number of the invocation of the built-in.  When used as a C++
11450 default argument for a function @var{F}, it returns the line number
11451 of the call to @var{F}.
11452 @end deftypefn
11454 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11455 This function is the equivalent of the @code{__FUNCTION__} symbol
11456 and returns an address constant pointing to the name of the function
11457 from which the built-in was invoked, or the empty string if
11458 the invocation is not at function scope.  When used as a C++ default
11459 argument for a function @var{F}, it returns the name of @var{F}'s
11460 caller or the empty string if the call was not made at function
11461 scope.
11462 @end deftypefn
11464 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11465 This function is the equivalent of the preprocessor @code{__FILE__}
11466 macro and returns an address constant pointing to the file name
11467 containing the invocation of the built-in, or the empty string if
11468 the invocation is not at function scope.  When used as a C++ default
11469 argument for a function @var{F}, it returns the file name of the call
11470 to @var{F} or the empty string if the call was not made at function
11471 scope.
11473 For example, in the following, each call to function @code{foo} will
11474 print a line similar to @code{"file.c:123: foo: message"} with the name
11475 of the file and the line number of the @code{printf} call, the name of
11476 the function @code{foo}, followed by the word @code{message}.
11478 @smallexample
11479 const char*
11480 function (const char *func = __builtin_FUNCTION ())
11482   return func;
11485 void foo (void)
11487   printf ("%s:%i: %s: message\n", file (), line (), function ());
11489 @end smallexample
11491 @end deftypefn
11493 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11494 This function is used to flush the processor's instruction cache for
11495 the region of memory between @var{begin} inclusive and @var{end}
11496 exclusive.  Some targets require that the instruction cache be
11497 flushed, after modifying memory containing code, in order to obtain
11498 deterministic behavior.
11500 If the target does not require instruction cache flushes,
11501 @code{__builtin___clear_cache} has no effect.  Otherwise either
11502 instructions are emitted in-line to clear the instruction cache or a
11503 call to the @code{__clear_cache} function in libgcc is made.
11504 @end deftypefn
11506 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11507 This function is used to minimize cache-miss latency by moving data into
11508 a cache before it is accessed.
11509 You can insert calls to @code{__builtin_prefetch} into code for which
11510 you know addresses of data in memory that is likely to be accessed soon.
11511 If the target supports them, data prefetch instructions are generated.
11512 If the prefetch is done early enough before the access then the data will
11513 be in the cache by the time it is accessed.
11515 The value of @var{addr} is the address of the memory to prefetch.
11516 There are two optional arguments, @var{rw} and @var{locality}.
11517 The value of @var{rw} is a compile-time constant one or zero; one
11518 means that the prefetch is preparing for a write to the memory address
11519 and zero, the default, means that the prefetch is preparing for a read.
11520 The value @var{locality} must be a compile-time constant integer between
11521 zero and three.  A value of zero means that the data has no temporal
11522 locality, so it need not be left in the cache after the access.  A value
11523 of three means that the data has a high degree of temporal locality and
11524 should be left in all levels of cache possible.  Values of one and two
11525 mean, respectively, a low or moderate degree of temporal locality.  The
11526 default is three.
11528 @smallexample
11529 for (i = 0; i < n; i++)
11530   @{
11531     a[i] = a[i] + b[i];
11532     __builtin_prefetch (&a[i+j], 1, 1);
11533     __builtin_prefetch (&b[i+j], 0, 1);
11534     /* @r{@dots{}} */
11535   @}
11536 @end smallexample
11538 Data prefetch does not generate faults if @var{addr} is invalid, but
11539 the address expression itself must be valid.  For example, a prefetch
11540 of @code{p->next} does not fault if @code{p->next} is not a valid
11541 address, but evaluation faults if @code{p} is not a valid address.
11543 If the target does not support data prefetch, the address expression
11544 is evaluated if it includes side effects but no other code is generated
11545 and GCC does not issue a warning.
11546 @end deftypefn
11548 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11549 Returns a positive infinity, if supported by the floating-point format,
11550 else @code{DBL_MAX}.  This function is suitable for implementing the
11551 ISO C macro @code{HUGE_VAL}.
11552 @end deftypefn
11554 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11555 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11556 @end deftypefn
11558 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11559 Similar to @code{__builtin_huge_val}, except the return
11560 type is @code{long double}.
11561 @end deftypefn
11563 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11564 Similar to @code{__builtin_huge_val}, except the return type is
11565 @code{_Float@var{n}}.
11566 @end deftypefn
11568 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11569 Similar to @code{__builtin_huge_val}, except the return type is
11570 @code{_Float@var{n}x}.
11571 @end deftypefn
11573 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11574 This built-in implements the C99 fpclassify functionality.  The first
11575 five int arguments should be the target library's notion of the
11576 possible FP classes and are used for return values.  They must be
11577 constant values and they must appear in this order: @code{FP_NAN},
11578 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11579 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
11580 to classify.  GCC treats the last argument as type-generic, which
11581 means it does not do default promotion from float to double.
11582 @end deftypefn
11584 @deftypefn {Built-in Function} double __builtin_inf (void)
11585 Similar to @code{__builtin_huge_val}, except a warning is generated
11586 if the target floating-point format does not support infinities.
11587 @end deftypefn
11589 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11590 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11591 @end deftypefn
11593 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11594 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11595 @end deftypefn
11597 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11598 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11599 @end deftypefn
11601 @deftypefn {Built-in Function} float __builtin_inff (void)
11602 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11603 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11604 @end deftypefn
11606 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11607 Similar to @code{__builtin_inf}, except the return
11608 type is @code{long double}.
11609 @end deftypefn
11611 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11612 Similar to @code{__builtin_inf}, except the return
11613 type is @code{_Float@var{n}}.
11614 @end deftypefn
11616 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11617 Similar to @code{__builtin_inf}, except the return
11618 type is @code{_Float@var{n}x}.
11619 @end deftypefn
11621 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11622 Similar to @code{isinf}, except the return value is -1 for
11623 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11624 Note while the parameter list is an
11625 ellipsis, this function only accepts exactly one floating-point
11626 argument.  GCC treats this parameter as type-generic, which means it
11627 does not do default promotion from float to double.
11628 @end deftypefn
11630 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11631 This is an implementation of the ISO C99 function @code{nan}.
11633 Since ISO C99 defines this function in terms of @code{strtod}, which we
11634 do not implement, a description of the parsing is in order.  The string
11635 is parsed as by @code{strtol}; that is, the base is recognized by
11636 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
11637 in the significand such that the least significant bit of the number
11638 is at the least significant bit of the significand.  The number is
11639 truncated to fit the significand field provided.  The significand is
11640 forced to be a quiet NaN@.
11642 This function, if given a string literal all of which would have been
11643 consumed by @code{strtol}, is evaluated early enough that it is considered a
11644 compile-time constant.
11645 @end deftypefn
11647 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11648 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11649 @end deftypefn
11651 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11652 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11653 @end deftypefn
11655 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11656 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11657 @end deftypefn
11659 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11660 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11661 @end deftypefn
11663 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11664 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11665 @end deftypefn
11667 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11668 Similar to @code{__builtin_nan}, except the return type is
11669 @code{_Float@var{n}}.
11670 @end deftypefn
11672 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11673 Similar to @code{__builtin_nan}, except the return type is
11674 @code{_Float@var{n}x}.
11675 @end deftypefn
11677 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11678 Similar to @code{__builtin_nan}, except the significand is forced
11679 to be a signaling NaN@.  The @code{nans} function is proposed by
11680 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11681 @end deftypefn
11683 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11684 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11685 @end deftypefn
11687 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11688 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11689 @end deftypefn
11691 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11692 Similar to @code{__builtin_nans}, except the return type is
11693 @code{_Float@var{n}}.
11694 @end deftypefn
11696 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11697 Similar to @code{__builtin_nans}, except the return type is
11698 @code{_Float@var{n}x}.
11699 @end deftypefn
11701 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11702 Returns one plus the index of the least significant 1-bit of @var{x}, or
11703 if @var{x} is zero, returns zero.
11704 @end deftypefn
11706 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11707 Returns the number of leading 0-bits in @var{x}, starting at the most
11708 significant bit position.  If @var{x} is 0, the result is undefined.
11709 @end deftypefn
11711 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11712 Returns the number of trailing 0-bits in @var{x}, starting at the least
11713 significant bit position.  If @var{x} is 0, the result is undefined.
11714 @end deftypefn
11716 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11717 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11718 number of bits following the most significant bit that are identical
11719 to it.  There are no special cases for 0 or other values. 
11720 @end deftypefn
11722 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11723 Returns the number of 1-bits in @var{x}.
11724 @end deftypefn
11726 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11727 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11728 modulo 2.
11729 @end deftypefn
11731 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11732 Similar to @code{__builtin_ffs}, except the argument type is
11733 @code{long}.
11734 @end deftypefn
11736 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11737 Similar to @code{__builtin_clz}, except the argument type is
11738 @code{unsigned long}.
11739 @end deftypefn
11741 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11742 Similar to @code{__builtin_ctz}, except the argument type is
11743 @code{unsigned long}.
11744 @end deftypefn
11746 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11747 Similar to @code{__builtin_clrsb}, except the argument type is
11748 @code{long}.
11749 @end deftypefn
11751 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11752 Similar to @code{__builtin_popcount}, except the argument type is
11753 @code{unsigned long}.
11754 @end deftypefn
11756 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11757 Similar to @code{__builtin_parity}, except the argument type is
11758 @code{unsigned long}.
11759 @end deftypefn
11761 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11762 Similar to @code{__builtin_ffs}, except the argument type is
11763 @code{long long}.
11764 @end deftypefn
11766 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11767 Similar to @code{__builtin_clz}, except the argument type is
11768 @code{unsigned long long}.
11769 @end deftypefn
11771 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11772 Similar to @code{__builtin_ctz}, except the argument type is
11773 @code{unsigned long long}.
11774 @end deftypefn
11776 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11777 Similar to @code{__builtin_clrsb}, except the argument type is
11778 @code{long long}.
11779 @end deftypefn
11781 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11782 Similar to @code{__builtin_popcount}, except the argument type is
11783 @code{unsigned long long}.
11784 @end deftypefn
11786 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11787 Similar to @code{__builtin_parity}, except the argument type is
11788 @code{unsigned long long}.
11789 @end deftypefn
11791 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11792 Returns the first argument raised to the power of the second.  Unlike the
11793 @code{pow} function no guarantees about precision and rounding are made.
11794 @end deftypefn
11796 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11797 Similar to @code{__builtin_powi}, except the argument and return types
11798 are @code{float}.
11799 @end deftypefn
11801 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11802 Similar to @code{__builtin_powi}, except the argument and return types
11803 are @code{long double}.
11804 @end deftypefn
11806 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11807 Returns @var{x} with the order of the bytes reversed; for example,
11808 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
11809 exactly 8 bits.
11810 @end deftypefn
11812 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11813 Similar to @code{__builtin_bswap16}, except the argument and return types
11814 are 32 bit.
11815 @end deftypefn
11817 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11818 Similar to @code{__builtin_bswap32}, except the argument and return types
11819 are 64 bit.
11820 @end deftypefn
11822 @node Target Builtins
11823 @section Built-in Functions Specific to Particular Target Machines
11825 On some target machines, GCC supports many built-in functions specific
11826 to those machines.  Generally these generate calls to specific machine
11827 instructions, but allow the compiler to schedule those calls.
11829 @menu
11830 * AArch64 Built-in Functions::
11831 * Alpha Built-in Functions::
11832 * Altera Nios II Built-in Functions::
11833 * ARC Built-in Functions::
11834 * ARC SIMD Built-in Functions::
11835 * ARM iWMMXt Built-in Functions::
11836 * ARM C Language Extensions (ACLE)::
11837 * ARM Floating Point Status and Control Intrinsics::
11838 * ARM ARMv8-M Security Extensions::
11839 * AVR Built-in Functions::
11840 * Blackfin Built-in Functions::
11841 * FR-V Built-in Functions::
11842 * MIPS DSP Built-in Functions::
11843 * MIPS Paired-Single Support::
11844 * MIPS Loongson Built-in Functions::
11845 * MIPS SIMD Architecture (MSA) Support::
11846 * Other MIPS Built-in Functions::
11847 * MSP430 Built-in Functions::
11848 * NDS32 Built-in Functions::
11849 * picoChip Built-in Functions::
11850 * PowerPC Built-in Functions::
11851 * PowerPC AltiVec/VSX Built-in Functions::
11852 * PowerPC Hardware Transactional Memory Built-in Functions::
11853 * RX Built-in Functions::
11854 * S/390 System z Built-in Functions::
11855 * SH Built-in Functions::
11856 * SPARC VIS Built-in Functions::
11857 * SPU Built-in Functions::
11858 * TI C6X Built-in Functions::
11859 * TILE-Gx Built-in Functions::
11860 * TILEPro Built-in Functions::
11861 * x86 Built-in Functions::
11862 * x86 transactional memory intrinsics::
11863 @end menu
11865 @node AArch64 Built-in Functions
11866 @subsection AArch64 Built-in Functions
11868 These built-in functions are available for the AArch64 family of
11869 processors.
11870 @smallexample
11871 unsigned int __builtin_aarch64_get_fpcr ()
11872 void __builtin_aarch64_set_fpcr (unsigned int)
11873 unsigned int __builtin_aarch64_get_fpsr ()
11874 void __builtin_aarch64_set_fpsr (unsigned int)
11875 @end smallexample
11877 @node Alpha Built-in Functions
11878 @subsection Alpha Built-in Functions
11880 These built-in functions are available for the Alpha family of
11881 processors, depending on the command-line switches used.
11883 The following built-in functions are always available.  They
11884 all generate the machine instruction that is part of the name.
11886 @smallexample
11887 long __builtin_alpha_implver (void)
11888 long __builtin_alpha_rpcc (void)
11889 long __builtin_alpha_amask (long)
11890 long __builtin_alpha_cmpbge (long, long)
11891 long __builtin_alpha_extbl (long, long)
11892 long __builtin_alpha_extwl (long, long)
11893 long __builtin_alpha_extll (long, long)
11894 long __builtin_alpha_extql (long, long)
11895 long __builtin_alpha_extwh (long, long)
11896 long __builtin_alpha_extlh (long, long)
11897 long __builtin_alpha_extqh (long, long)
11898 long __builtin_alpha_insbl (long, long)
11899 long __builtin_alpha_inswl (long, long)
11900 long __builtin_alpha_insll (long, long)
11901 long __builtin_alpha_insql (long, long)
11902 long __builtin_alpha_inswh (long, long)
11903 long __builtin_alpha_inslh (long, long)
11904 long __builtin_alpha_insqh (long, long)
11905 long __builtin_alpha_mskbl (long, long)
11906 long __builtin_alpha_mskwl (long, long)
11907 long __builtin_alpha_mskll (long, long)
11908 long __builtin_alpha_mskql (long, long)
11909 long __builtin_alpha_mskwh (long, long)
11910 long __builtin_alpha_msklh (long, long)
11911 long __builtin_alpha_mskqh (long, long)
11912 long __builtin_alpha_umulh (long, long)
11913 long __builtin_alpha_zap (long, long)
11914 long __builtin_alpha_zapnot (long, long)
11915 @end smallexample
11917 The following built-in functions are always with @option{-mmax}
11918 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11919 later.  They all generate the machine instruction that is part
11920 of the name.
11922 @smallexample
11923 long __builtin_alpha_pklb (long)
11924 long __builtin_alpha_pkwb (long)
11925 long __builtin_alpha_unpkbl (long)
11926 long __builtin_alpha_unpkbw (long)
11927 long __builtin_alpha_minub8 (long, long)
11928 long __builtin_alpha_minsb8 (long, long)
11929 long __builtin_alpha_minuw4 (long, long)
11930 long __builtin_alpha_minsw4 (long, long)
11931 long __builtin_alpha_maxub8 (long, long)
11932 long __builtin_alpha_maxsb8 (long, long)
11933 long __builtin_alpha_maxuw4 (long, long)
11934 long __builtin_alpha_maxsw4 (long, long)
11935 long __builtin_alpha_perr (long, long)
11936 @end smallexample
11938 The following built-in functions are always with @option{-mcix}
11939 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11940 later.  They all generate the machine instruction that is part
11941 of the name.
11943 @smallexample
11944 long __builtin_alpha_cttz (long)
11945 long __builtin_alpha_ctlz (long)
11946 long __builtin_alpha_ctpop (long)
11947 @end smallexample
11949 The following built-in functions are available on systems that use the OSF/1
11950 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
11951 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11952 @code{rdval} and @code{wrval}.
11954 @smallexample
11955 void *__builtin_thread_pointer (void)
11956 void __builtin_set_thread_pointer (void *)
11957 @end smallexample
11959 @node Altera Nios II Built-in Functions
11960 @subsection Altera Nios II Built-in Functions
11962 These built-in functions are available for the Altera Nios II
11963 family of processors.
11965 The following built-in functions are always available.  They
11966 all generate the machine instruction that is part of the name.
11968 @example
11969 int __builtin_ldbio (volatile const void *)
11970 int __builtin_ldbuio (volatile const void *)
11971 int __builtin_ldhio (volatile const void *)
11972 int __builtin_ldhuio (volatile const void *)
11973 int __builtin_ldwio (volatile const void *)
11974 void __builtin_stbio (volatile void *, int)
11975 void __builtin_sthio (volatile void *, int)
11976 void __builtin_stwio (volatile void *, int)
11977 void __builtin_sync (void)
11978 int __builtin_rdctl (int) 
11979 int __builtin_rdprs (int, int)
11980 void __builtin_wrctl (int, int)
11981 void __builtin_flushd (volatile void *)
11982 void __builtin_flushda (volatile void *)
11983 int __builtin_wrpie (int);
11984 void __builtin_eni (int);
11985 int __builtin_ldex (volatile const void *)
11986 int __builtin_stex (volatile void *, int)
11987 int __builtin_ldsex (volatile const void *)
11988 int __builtin_stsex (volatile void *, int)
11989 @end example
11991 The following built-in functions are always available.  They
11992 all generate a Nios II Custom Instruction. The name of the
11993 function represents the types that the function takes and
11994 returns. The letter before the @code{n} is the return type
11995 or void if absent. The @code{n} represents the first parameter
11996 to all the custom instructions, the custom instruction number.
11997 The two letters after the @code{n} represent the up to two
11998 parameters to the function.
12000 The letters represent the following data types:
12001 @table @code
12002 @item <no letter>
12003 @code{void} for return type and no parameter for parameter types.
12005 @item i
12006 @code{int} for return type and parameter type
12008 @item f
12009 @code{float} for return type and parameter type
12011 @item p
12012 @code{void *} for return type and parameter type
12014 @end table
12016 And the function names are:
12017 @example
12018 void __builtin_custom_n (void)
12019 void __builtin_custom_ni (int)
12020 void __builtin_custom_nf (float)
12021 void __builtin_custom_np (void *)
12022 void __builtin_custom_nii (int, int)
12023 void __builtin_custom_nif (int, float)
12024 void __builtin_custom_nip (int, void *)
12025 void __builtin_custom_nfi (float, int)
12026 void __builtin_custom_nff (float, float)
12027 void __builtin_custom_nfp (float, void *)
12028 void __builtin_custom_npi (void *, int)
12029 void __builtin_custom_npf (void *, float)
12030 void __builtin_custom_npp (void *, void *)
12031 int __builtin_custom_in (void)
12032 int __builtin_custom_ini (int)
12033 int __builtin_custom_inf (float)
12034 int __builtin_custom_inp (void *)
12035 int __builtin_custom_inii (int, int)
12036 int __builtin_custom_inif (int, float)
12037 int __builtin_custom_inip (int, void *)
12038 int __builtin_custom_infi (float, int)
12039 int __builtin_custom_inff (float, float)
12040 int __builtin_custom_infp (float, void *)
12041 int __builtin_custom_inpi (void *, int)
12042 int __builtin_custom_inpf (void *, float)
12043 int __builtin_custom_inpp (void *, void *)
12044 float __builtin_custom_fn (void)
12045 float __builtin_custom_fni (int)
12046 float __builtin_custom_fnf (float)
12047 float __builtin_custom_fnp (void *)
12048 float __builtin_custom_fnii (int, int)
12049 float __builtin_custom_fnif (int, float)
12050 float __builtin_custom_fnip (int, void *)
12051 float __builtin_custom_fnfi (float, int)
12052 float __builtin_custom_fnff (float, float)
12053 float __builtin_custom_fnfp (float, void *)
12054 float __builtin_custom_fnpi (void *, int)
12055 float __builtin_custom_fnpf (void *, float)
12056 float __builtin_custom_fnpp (void *, void *)
12057 void * __builtin_custom_pn (void)
12058 void * __builtin_custom_pni (int)
12059 void * __builtin_custom_pnf (float)
12060 void * __builtin_custom_pnp (void *)
12061 void * __builtin_custom_pnii (int, int)
12062 void * __builtin_custom_pnif (int, float)
12063 void * __builtin_custom_pnip (int, void *)
12064 void * __builtin_custom_pnfi (float, int)
12065 void * __builtin_custom_pnff (float, float)
12066 void * __builtin_custom_pnfp (float, void *)
12067 void * __builtin_custom_pnpi (void *, int)
12068 void * __builtin_custom_pnpf (void *, float)
12069 void * __builtin_custom_pnpp (void *, void *)
12070 @end example
12072 @node ARC Built-in Functions
12073 @subsection ARC Built-in Functions
12075 The following built-in functions are provided for ARC targets.  The
12076 built-ins generate the corresponding assembly instructions.  In the
12077 examples given below, the generated code often requires an operand or
12078 result to be in a register.  Where necessary further code will be
12079 generated to ensure this is true, but for brevity this is not
12080 described in each case.
12082 @emph{Note:} Using a built-in to generate an instruction not supported
12083 by a target may cause problems. At present the compiler is not
12084 guaranteed to detect such misuse, and as a result an internal compiler
12085 error may be generated.
12087 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12088 Return 1 if @var{val} is known to have the byte alignment given
12089 by @var{alignval}, otherwise return 0.
12090 Note that this is different from
12091 @smallexample
12092 __alignof__(*(char *)@var{val}) >= alignval
12093 @end smallexample
12094 because __alignof__ sees only the type of the dereference, whereas
12095 __builtin_arc_align uses alignment information from the pointer
12096 as well as from the pointed-to type.
12097 The information available will depend on optimization level.
12098 @end deftypefn
12100 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12101 Generates
12102 @example
12104 @end example
12105 @end deftypefn
12107 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12108 The operand is the number of a register to be read.  Generates:
12109 @example
12110 mov  @var{dest}, r@var{regno}
12111 @end example
12112 where the value in @var{dest} will be the result returned from the
12113 built-in.
12114 @end deftypefn
12116 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12117 The first operand is the number of a register to be written, the
12118 second operand is a compile time constant to write into that
12119 register.  Generates:
12120 @example
12121 mov  r@var{regno}, @var{val}
12122 @end example
12123 @end deftypefn
12125 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12126 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12127 Generates:
12128 @example
12129 divaw  @var{dest}, @var{a}, @var{b}
12130 @end example
12131 where the value in @var{dest} will be the result returned from the
12132 built-in.
12133 @end deftypefn
12135 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12136 Generates
12137 @example
12138 flag  @var{a}
12139 @end example
12140 @end deftypefn
12142 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12143 The operand, @var{auxv}, is the address of an auxiliary register and
12144 must be a compile time constant.  Generates:
12145 @example
12146 lr  @var{dest}, [@var{auxr}]
12147 @end example
12148 Where the value in @var{dest} will be the result returned from the
12149 built-in.
12150 @end deftypefn
12152 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12153 Only available with @option{-mmul64}.  Generates:
12154 @example
12155 mul64  @var{a}, @var{b}
12156 @end example
12157 @end deftypefn
12159 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12160 Only available with @option{-mmul64}.  Generates:
12161 @example
12162 mulu64  @var{a}, @var{b}
12163 @end example
12164 @end deftypefn
12166 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12167 Generates:
12168 @example
12170 @end example
12171 @end deftypefn
12173 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12174 Only valid if the @samp{norm} instruction is available through the
12175 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12176 Generates:
12177 @example
12178 norm  @var{dest}, @var{src}
12179 @end example
12180 Where the value in @var{dest} will be the result returned from the
12181 built-in.
12182 @end deftypefn
12184 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12185 Only valid if the @samp{normw} instruction is available through the
12186 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12187 Generates:
12188 @example
12189 normw  @var{dest}, @var{src}
12190 @end example
12191 Where the value in @var{dest} will be the result returned from the
12192 built-in.
12193 @end deftypefn
12195 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12196 Generates:
12197 @example
12198 rtie
12199 @end example
12200 @end deftypefn
12202 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12203 Generates:
12204 @example
12205 sleep  @var{a}
12206 @end example
12207 @end deftypefn
12209 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12210 The first argument, @var{auxv}, is the address of an auxiliary
12211 register, the second argument, @var{val}, is a compile time constant
12212 to be written to the register.  Generates:
12213 @example
12214 sr  @var{auxr}, [@var{val}]
12215 @end example
12216 @end deftypefn
12218 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12219 Only valid with @option{-mswap}.  Generates:
12220 @example
12221 swap  @var{dest}, @var{src}
12222 @end example
12223 Where the value in @var{dest} will be the result returned from the
12224 built-in.
12225 @end deftypefn
12227 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12228 Generates:
12229 @example
12231 @end example
12232 @end deftypefn
12234 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12235 Only available with @option{-mcpu=ARC700}.  Generates:
12236 @example
12237 sync
12238 @end example
12239 @end deftypefn
12241 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12242 Only available with @option{-mcpu=ARC700}.  Generates:
12243 @example
12244 trap_s  @var{c}
12245 @end example
12246 @end deftypefn
12248 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12249 Only available with @option{-mcpu=ARC700}.  Generates:
12250 @example
12251 unimp_s
12252 @end example
12253 @end deftypefn
12255 The instructions generated by the following builtins are not
12256 considered as candidates for scheduling.  They are not moved around by
12257 the compiler during scheduling, and thus can be expected to appear
12258 where they are put in the C code:
12259 @example
12260 __builtin_arc_brk()
12261 __builtin_arc_core_read()
12262 __builtin_arc_core_write()
12263 __builtin_arc_flag()
12264 __builtin_arc_lr()
12265 __builtin_arc_sleep()
12266 __builtin_arc_sr()
12267 __builtin_arc_swi()
12268 @end example
12270 @node ARC SIMD Built-in Functions
12271 @subsection ARC SIMD Built-in Functions
12273 SIMD builtins provided by the compiler can be used to generate the
12274 vector instructions.  This section describes the available builtins
12275 and their usage in programs.  With the @option{-msimd} option, the
12276 compiler provides 128-bit vector types, which can be specified using
12277 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12278 can be included to use the following predefined types:
12279 @example
12280 typedef int __v4si   __attribute__((vector_size(16)));
12281 typedef short __v8hi __attribute__((vector_size(16)));
12282 @end example
12284 These types can be used to define 128-bit variables.  The built-in
12285 functions listed in the following section can be used on these
12286 variables to generate the vector operations.
12288 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12289 @file{arc-simd.h} also provides equivalent macros called
12290 @code{_@var{someinsn}} that can be used for programming ease and
12291 improved readability.  The following macros for DMA control are also
12292 provided:
12293 @example
12294 #define _setup_dma_in_channel_reg _vdiwr
12295 #define _setup_dma_out_channel_reg _vdowr
12296 @end example
12298 The following is a complete list of all the SIMD built-ins provided
12299 for ARC, grouped by calling signature.
12301 The following take two @code{__v8hi} arguments and return a
12302 @code{__v8hi} result:
12303 @example
12304 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12305 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12306 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12307 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12308 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12309 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12310 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12311 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12312 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12313 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12314 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12315 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12316 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12317 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12318 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12319 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12320 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12321 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12322 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12323 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12324 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12325 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12326 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12327 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12328 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12329 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12330 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12331 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12332 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12333 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12334 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12335 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12336 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12337 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12338 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12339 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12340 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12341 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12342 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12343 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12344 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12345 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12346 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12347 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12348 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12349 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12350 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12351 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12352 @end example
12354 The following take one @code{__v8hi} and one @code{int} argument and return a
12355 @code{__v8hi} result:
12357 @example
12358 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12359 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12360 __v8hi __builtin_arc_vbminw (__v8hi, int)
12361 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12362 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12363 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12364 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12365 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12366 @end example
12368 The following take one @code{__v8hi} argument and one @code{int} argument which
12369 must be a 3-bit compile time constant indicating a register number
12370 I0-I7.  They return a @code{__v8hi} result.
12371 @example
12372 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12373 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12374 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12375 @end example
12377 The following take one @code{__v8hi} argument and one @code{int}
12378 argument which must be a 6-bit compile time constant.  They return a
12379 @code{__v8hi} result.
12380 @example
12381 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12382 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12383 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12384 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12385 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12386 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12387 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12388 @end example
12390 The following take one @code{__v8hi} argument and one @code{int} argument which
12391 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12392 result.
12393 @example
12394 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12395 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12396 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12397 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12398 @end example
12400 The following take two @code{int} arguments, the second of which which
12401 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12402 result:
12403 @example
12404 __v8hi __builtin_arc_vmovaw (int, const int)
12405 __v8hi __builtin_arc_vmovw (int, const int)
12406 __v8hi __builtin_arc_vmovzw (int, const int)
12407 @end example
12409 The following take a single @code{__v8hi} argument and return a
12410 @code{__v8hi} result:
12411 @example
12412 __v8hi __builtin_arc_vabsaw (__v8hi)
12413 __v8hi __builtin_arc_vabsw (__v8hi)
12414 __v8hi __builtin_arc_vaddsuw (__v8hi)
12415 __v8hi __builtin_arc_vexch1 (__v8hi)
12416 __v8hi __builtin_arc_vexch2 (__v8hi)
12417 __v8hi __builtin_arc_vexch4 (__v8hi)
12418 __v8hi __builtin_arc_vsignw (__v8hi)
12419 __v8hi __builtin_arc_vupbaw (__v8hi)
12420 __v8hi __builtin_arc_vupbw (__v8hi)
12421 __v8hi __builtin_arc_vupsbaw (__v8hi)
12422 __v8hi __builtin_arc_vupsbw (__v8hi)
12423 @end example
12425 The following take two @code{int} arguments and return no result:
12426 @example
12427 void __builtin_arc_vdirun (int, int)
12428 void __builtin_arc_vdorun (int, int)
12429 @end example
12431 The following take two @code{int} arguments and return no result.  The
12432 first argument must a 3-bit compile time constant indicating one of
12433 the DR0-DR7 DMA setup channels:
12434 @example
12435 void __builtin_arc_vdiwr (const int, int)
12436 void __builtin_arc_vdowr (const int, int)
12437 @end example
12439 The following take an @code{int} argument and return no result:
12440 @example
12441 void __builtin_arc_vendrec (int)
12442 void __builtin_arc_vrec (int)
12443 void __builtin_arc_vrecrun (int)
12444 void __builtin_arc_vrun (int)
12445 @end example
12447 The following take a @code{__v8hi} argument and two @code{int}
12448 arguments and return a @code{__v8hi} result.  The second argument must
12449 be a 3-bit compile time constants, indicating one the registers I0-I7,
12450 and the third argument must be an 8-bit compile time constant.
12452 @emph{Note:} Although the equivalent hardware instructions do not take
12453 an SIMD register as an operand, these builtins overwrite the relevant
12454 bits of the @code{__v8hi} register provided as the first argument with
12455 the value loaded from the @code{[Ib, u8]} location in the SDM.
12457 @example
12458 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12459 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12460 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12461 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12462 @end example
12464 The following take two @code{int} arguments and return a @code{__v8hi}
12465 result.  The first argument must be a 3-bit compile time constants,
12466 indicating one the registers I0-I7, and the second argument must be an
12467 8-bit compile time constant.
12469 @example
12470 __v8hi __builtin_arc_vld128 (const int, const int)
12471 __v8hi __builtin_arc_vld64w (const int, const int)
12472 @end example
12474 The following take a @code{__v8hi} argument and two @code{int}
12475 arguments and return no result.  The second argument must be a 3-bit
12476 compile time constants, indicating one the registers I0-I7, and the
12477 third argument must be an 8-bit compile time constant.
12479 @example
12480 void __builtin_arc_vst128 (__v8hi, const int, const int)
12481 void __builtin_arc_vst64 (__v8hi, const int, const int)
12482 @end example
12484 The following take a @code{__v8hi} argument and three @code{int}
12485 arguments and return no result.  The second argument must be a 3-bit
12486 compile-time constant, identifying the 16-bit sub-register to be
12487 stored, the third argument must be a 3-bit compile time constants,
12488 indicating one the registers I0-I7, and the fourth argument must be an
12489 8-bit compile time constant.
12491 @example
12492 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12493 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12494 @end example
12496 @node ARM iWMMXt Built-in Functions
12497 @subsection ARM iWMMXt Built-in Functions
12499 These built-in functions are available for the ARM family of
12500 processors when the @option{-mcpu=iwmmxt} switch is used:
12502 @smallexample
12503 typedef int v2si __attribute__ ((vector_size (8)));
12504 typedef short v4hi __attribute__ ((vector_size (8)));
12505 typedef char v8qi __attribute__ ((vector_size (8)));
12507 int __builtin_arm_getwcgr0 (void)
12508 void __builtin_arm_setwcgr0 (int)
12509 int __builtin_arm_getwcgr1 (void)
12510 void __builtin_arm_setwcgr1 (int)
12511 int __builtin_arm_getwcgr2 (void)
12512 void __builtin_arm_setwcgr2 (int)
12513 int __builtin_arm_getwcgr3 (void)
12514 void __builtin_arm_setwcgr3 (int)
12515 int __builtin_arm_textrmsb (v8qi, int)
12516 int __builtin_arm_textrmsh (v4hi, int)
12517 int __builtin_arm_textrmsw (v2si, int)
12518 int __builtin_arm_textrmub (v8qi, int)
12519 int __builtin_arm_textrmuh (v4hi, int)
12520 int __builtin_arm_textrmuw (v2si, int)
12521 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12522 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12523 v2si __builtin_arm_tinsrw (v2si, int, int)
12524 long long __builtin_arm_tmia (long long, int, int)
12525 long long __builtin_arm_tmiabb (long long, int, int)
12526 long long __builtin_arm_tmiabt (long long, int, int)
12527 long long __builtin_arm_tmiaph (long long, int, int)
12528 long long __builtin_arm_tmiatb (long long, int, int)
12529 long long __builtin_arm_tmiatt (long long, int, int)
12530 int __builtin_arm_tmovmskb (v8qi)
12531 int __builtin_arm_tmovmskh (v4hi)
12532 int __builtin_arm_tmovmskw (v2si)
12533 long long __builtin_arm_waccb (v8qi)
12534 long long __builtin_arm_wacch (v4hi)
12535 long long __builtin_arm_waccw (v2si)
12536 v8qi __builtin_arm_waddb (v8qi, v8qi)
12537 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12538 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12539 v4hi __builtin_arm_waddh (v4hi, v4hi)
12540 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12541 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12542 v2si __builtin_arm_waddw (v2si, v2si)
12543 v2si __builtin_arm_waddwss (v2si, v2si)
12544 v2si __builtin_arm_waddwus (v2si, v2si)
12545 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12546 long long __builtin_arm_wand(long long, long long)
12547 long long __builtin_arm_wandn (long long, long long)
12548 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12549 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12550 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12551 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12552 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12553 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12554 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12555 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12556 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12557 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12558 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12559 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12560 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12561 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12562 long long __builtin_arm_wmacsz (v4hi, v4hi)
12563 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12564 long long __builtin_arm_wmacuz (v4hi, v4hi)
12565 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12566 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12567 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12568 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12569 v2si __builtin_arm_wmaxsw (v2si, v2si)
12570 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12571 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12572 v2si __builtin_arm_wmaxuw (v2si, v2si)
12573 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12574 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12575 v2si __builtin_arm_wminsw (v2si, v2si)
12576 v8qi __builtin_arm_wminub (v8qi, v8qi)
12577 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12578 v2si __builtin_arm_wminuw (v2si, v2si)
12579 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12580 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12581 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12582 long long __builtin_arm_wor (long long, long long)
12583 v2si __builtin_arm_wpackdss (long long, long long)
12584 v2si __builtin_arm_wpackdus (long long, long long)
12585 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12586 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12587 v4hi __builtin_arm_wpackwss (v2si, v2si)
12588 v4hi __builtin_arm_wpackwus (v2si, v2si)
12589 long long __builtin_arm_wrord (long long, long long)
12590 long long __builtin_arm_wrordi (long long, int)
12591 v4hi __builtin_arm_wrorh (v4hi, long long)
12592 v4hi __builtin_arm_wrorhi (v4hi, int)
12593 v2si __builtin_arm_wrorw (v2si, long long)
12594 v2si __builtin_arm_wrorwi (v2si, int)
12595 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12596 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12597 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12598 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12599 v4hi __builtin_arm_wshufh (v4hi, int)
12600 long long __builtin_arm_wslld (long long, long long)
12601 long long __builtin_arm_wslldi (long long, int)
12602 v4hi __builtin_arm_wsllh (v4hi, long long)
12603 v4hi __builtin_arm_wsllhi (v4hi, int)
12604 v2si __builtin_arm_wsllw (v2si, long long)
12605 v2si __builtin_arm_wsllwi (v2si, int)
12606 long long __builtin_arm_wsrad (long long, long long)
12607 long long __builtin_arm_wsradi (long long, int)
12608 v4hi __builtin_arm_wsrah (v4hi, long long)
12609 v4hi __builtin_arm_wsrahi (v4hi, int)
12610 v2si __builtin_arm_wsraw (v2si, long long)
12611 v2si __builtin_arm_wsrawi (v2si, int)
12612 long long __builtin_arm_wsrld (long long, long long)
12613 long long __builtin_arm_wsrldi (long long, int)
12614 v4hi __builtin_arm_wsrlh (v4hi, long long)
12615 v4hi __builtin_arm_wsrlhi (v4hi, int)
12616 v2si __builtin_arm_wsrlw (v2si, long long)
12617 v2si __builtin_arm_wsrlwi (v2si, int)
12618 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12619 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12620 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12621 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12622 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12623 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12624 v2si __builtin_arm_wsubw (v2si, v2si)
12625 v2si __builtin_arm_wsubwss (v2si, v2si)
12626 v2si __builtin_arm_wsubwus (v2si, v2si)
12627 v4hi __builtin_arm_wunpckehsb (v8qi)
12628 v2si __builtin_arm_wunpckehsh (v4hi)
12629 long long __builtin_arm_wunpckehsw (v2si)
12630 v4hi __builtin_arm_wunpckehub (v8qi)
12631 v2si __builtin_arm_wunpckehuh (v4hi)
12632 long long __builtin_arm_wunpckehuw (v2si)
12633 v4hi __builtin_arm_wunpckelsb (v8qi)
12634 v2si __builtin_arm_wunpckelsh (v4hi)
12635 long long __builtin_arm_wunpckelsw (v2si)
12636 v4hi __builtin_arm_wunpckelub (v8qi)
12637 v2si __builtin_arm_wunpckeluh (v4hi)
12638 long long __builtin_arm_wunpckeluw (v2si)
12639 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12640 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12641 v2si __builtin_arm_wunpckihw (v2si, v2si)
12642 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12643 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12644 v2si __builtin_arm_wunpckilw (v2si, v2si)
12645 long long __builtin_arm_wxor (long long, long long)
12646 long long __builtin_arm_wzero ()
12647 @end smallexample
12650 @node ARM C Language Extensions (ACLE)
12651 @subsection ARM C Language Extensions (ACLE)
12653 GCC implements extensions for C as described in the ARM C Language
12654 Extensions (ACLE) specification, which can be found at
12655 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12657 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12658 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
12659 intrinsics can be found at
12660 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12661 The built-in intrinsics for the Advanced SIMD extension are available when
12662 NEON is enabled.
12664 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
12665 back ends support CRC32 intrinsics and the ARM back end supports the
12666 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
12667 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12668 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12669 intrinsics yet.
12671 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12672 availability of extensions.
12674 @node ARM Floating Point Status and Control Intrinsics
12675 @subsection ARM Floating Point Status and Control Intrinsics
12677 These built-in functions are available for the ARM family of
12678 processors with floating-point unit.
12680 @smallexample
12681 unsigned int __builtin_arm_get_fpscr ()
12682 void __builtin_arm_set_fpscr (unsigned int)
12683 @end smallexample
12685 @node ARM ARMv8-M Security Extensions
12686 @subsection ARM ARMv8-M Security Extensions
12688 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
12689 Security Extensions: Requirements on Development Tools Engineering
12690 Specification, which can be found at
12691 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
12693 As part of the Security Extensions GCC implements two new function attributes:
12694 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
12696 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
12697 is used here to mean any function pointer type.
12699 @smallexample
12700 cmse_address_info_t cmse_TT (void *)
12701 cmse_address_info_t cmse_TT_fptr (FPTR)
12702 cmse_address_info_t cmse_TTT (void *)
12703 cmse_address_info_t cmse_TTT_fptr (FPTR)
12704 cmse_address_info_t cmse_TTA (void *)
12705 cmse_address_info_t cmse_TTA_fptr (FPTR)
12706 cmse_address_info_t cmse_TTAT (void *)
12707 cmse_address_info_t cmse_TTAT_fptr (FPTR)
12708 void * cmse_check_address_range (void *, size_t, int)
12709 typeof(p) cmse_nsfptr_create (FPTR p)
12710 intptr_t cmse_is_nsfptr (FPTR)
12711 int cmse_nonsecure_caller (void)
12712 @end smallexample
12714 @node AVR Built-in Functions
12715 @subsection AVR Built-in Functions
12717 For each built-in function for AVR, there is an equally named,
12718 uppercase built-in macro defined. That way users can easily query if
12719 or if not a specific built-in is implemented or not. For example, if
12720 @code{__builtin_avr_nop} is available the macro
12721 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12723 The following built-in functions map to the respective machine
12724 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12725 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12726 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12727 as library call if no hardware multiplier is available.
12729 @smallexample
12730 void __builtin_avr_nop (void)
12731 void __builtin_avr_sei (void)
12732 void __builtin_avr_cli (void)
12733 void __builtin_avr_sleep (void)
12734 void __builtin_avr_wdr (void)
12735 unsigned char __builtin_avr_swap (unsigned char)
12736 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12737 int __builtin_avr_fmuls (char, char)
12738 int __builtin_avr_fmulsu (char, unsigned char)
12739 @end smallexample
12741 In order to delay execution for a specific number of cycles, GCC
12742 implements
12743 @smallexample
12744 void __builtin_avr_delay_cycles (unsigned long ticks)
12745 @end smallexample
12747 @noindent
12748 @code{ticks} is the number of ticks to delay execution. Note that this
12749 built-in does not take into account the effect of interrupts that
12750 might increase delay time. @code{ticks} must be a compile-time
12751 integer constant; delays with a variable number of cycles are not supported.
12753 @smallexample
12754 char __builtin_avr_flash_segment (const __memx void*)
12755 @end smallexample
12757 @noindent
12758 This built-in takes a byte address to the 24-bit
12759 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12760 the number of the flash segment (the 64 KiB chunk) where the address
12761 points to.  Counting starts at @code{0}.
12762 If the address does not point to flash memory, return @code{-1}.
12764 @smallexample
12765 unsigned char __builtin_avr_insert_bits (unsigned long map,
12766                                          unsigned char bits,
12767                                          unsigned char val)
12768 @end smallexample
12770 @noindent
12771 Insert bits from @var{bits} into @var{val} and return the resulting
12772 value. The nibbles of @var{map} determine how the insertion is
12773 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12774 @enumerate
12775 @item If @var{X} is @code{0xf},
12776 then the @var{n}-th bit of @var{val} is returned unaltered.
12778 @item If X is in the range 0@dots{}7,
12779 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12781 @item If X is in the range 8@dots{}@code{0xe},
12782 then the @var{n}-th result bit is undefined.
12783 @end enumerate
12785 @noindent
12786 One typical use case for this built-in is adjusting input and
12787 output values to non-contiguous port layouts. Some examples:
12789 @smallexample
12790 // same as val, bits is unused
12791 __builtin_avr_insert_bits (0xffffffff, bits, val)
12792 @end smallexample
12794 @smallexample
12795 // same as bits, val is unused
12796 __builtin_avr_insert_bits (0x76543210, bits, val)
12797 @end smallexample
12799 @smallexample
12800 // same as rotating bits by 4
12801 __builtin_avr_insert_bits (0x32107654, bits, 0)
12802 @end smallexample
12804 @smallexample
12805 // high nibble of result is the high nibble of val
12806 // low nibble of result is the low nibble of bits
12807 __builtin_avr_insert_bits (0xffff3210, bits, val)
12808 @end smallexample
12810 @smallexample
12811 // reverse the bit order of bits
12812 __builtin_avr_insert_bits (0x01234567, bits, 0)
12813 @end smallexample
12815 @smallexample
12816 void __builtin_avr_nops (unsigned count)
12817 @end smallexample
12819 @noindent
12820 Insert @code{count} @code{NOP} instructions.
12821 The number of instructions must be a compile-time integer constant.
12823 @node Blackfin Built-in Functions
12824 @subsection Blackfin Built-in Functions
12826 Currently, there are two Blackfin-specific built-in functions.  These are
12827 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12828 using inline assembly; by using these built-in functions the compiler can
12829 automatically add workarounds for hardware errata involving these
12830 instructions.  These functions are named as follows:
12832 @smallexample
12833 void __builtin_bfin_csync (void)
12834 void __builtin_bfin_ssync (void)
12835 @end smallexample
12837 @node FR-V Built-in Functions
12838 @subsection FR-V Built-in Functions
12840 GCC provides many FR-V-specific built-in functions.  In general,
12841 these functions are intended to be compatible with those described
12842 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12843 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
12844 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12845 pointer rather than by value.
12847 Most of the functions are named after specific FR-V instructions.
12848 Such functions are said to be ``directly mapped'' and are summarized
12849 here in tabular form.
12851 @menu
12852 * Argument Types::
12853 * Directly-mapped Integer Functions::
12854 * Directly-mapped Media Functions::
12855 * Raw read/write Functions::
12856 * Other Built-in Functions::
12857 @end menu
12859 @node Argument Types
12860 @subsubsection Argument Types
12862 The arguments to the built-in functions can be divided into three groups:
12863 register numbers, compile-time constants and run-time values.  In order
12864 to make this classification clear at a glance, the arguments and return
12865 values are given the following pseudo types:
12867 @multitable @columnfractions .20 .30 .15 .35
12868 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12869 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12870 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12871 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12872 @item @code{uw2} @tab @code{unsigned long long} @tab No
12873 @tab an unsigned doubleword
12874 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12875 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12876 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12877 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12878 @end multitable
12880 These pseudo types are not defined by GCC, they are simply a notational
12881 convenience used in this manual.
12883 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12884 and @code{sw2} are evaluated at run time.  They correspond to
12885 register operands in the underlying FR-V instructions.
12887 @code{const} arguments represent immediate operands in the underlying
12888 FR-V instructions.  They must be compile-time constants.
12890 @code{acc} arguments are evaluated at compile time and specify the number
12891 of an accumulator register.  For example, an @code{acc} argument of 2
12892 selects the ACC2 register.
12894 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12895 number of an IACC register.  See @pxref{Other Built-in Functions}
12896 for more details.
12898 @node Directly-mapped Integer Functions
12899 @subsubsection Directly-Mapped Integer Functions
12901 The functions listed below map directly to FR-V I-type instructions.
12903 @multitable @columnfractions .45 .32 .23
12904 @item Function prototype @tab Example usage @tab Assembly output
12905 @item @code{sw1 __ADDSS (sw1, sw1)}
12906 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12907 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12908 @item @code{sw1 __SCAN (sw1, sw1)}
12909 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12910 @tab @code{SCAN @var{a},@var{b},@var{c}}
12911 @item @code{sw1 __SCUTSS (sw1)}
12912 @tab @code{@var{b} = __SCUTSS (@var{a})}
12913 @tab @code{SCUTSS @var{a},@var{b}}
12914 @item @code{sw1 __SLASS (sw1, sw1)}
12915 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12916 @tab @code{SLASS @var{a},@var{b},@var{c}}
12917 @item @code{void __SMASS (sw1, sw1)}
12918 @tab @code{__SMASS (@var{a}, @var{b})}
12919 @tab @code{SMASS @var{a},@var{b}}
12920 @item @code{void __SMSSS (sw1, sw1)}
12921 @tab @code{__SMSSS (@var{a}, @var{b})}
12922 @tab @code{SMSSS @var{a},@var{b}}
12923 @item @code{void __SMU (sw1, sw1)}
12924 @tab @code{__SMU (@var{a}, @var{b})}
12925 @tab @code{SMU @var{a},@var{b}}
12926 @item @code{sw2 __SMUL (sw1, sw1)}
12927 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12928 @tab @code{SMUL @var{a},@var{b},@var{c}}
12929 @item @code{sw1 __SUBSS (sw1, sw1)}
12930 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12931 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12932 @item @code{uw2 __UMUL (uw1, uw1)}
12933 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12934 @tab @code{UMUL @var{a},@var{b},@var{c}}
12935 @end multitable
12937 @node Directly-mapped Media Functions
12938 @subsubsection Directly-Mapped Media Functions
12940 The functions listed below map directly to FR-V M-type instructions.
12942 @multitable @columnfractions .45 .32 .23
12943 @item Function prototype @tab Example usage @tab Assembly output
12944 @item @code{uw1 __MABSHS (sw1)}
12945 @tab @code{@var{b} = __MABSHS (@var{a})}
12946 @tab @code{MABSHS @var{a},@var{b}}
12947 @item @code{void __MADDACCS (acc, acc)}
12948 @tab @code{__MADDACCS (@var{b}, @var{a})}
12949 @tab @code{MADDACCS @var{a},@var{b}}
12950 @item @code{sw1 __MADDHSS (sw1, sw1)}
12951 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12952 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12953 @item @code{uw1 __MADDHUS (uw1, uw1)}
12954 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12955 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12956 @item @code{uw1 __MAND (uw1, uw1)}
12957 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12958 @tab @code{MAND @var{a},@var{b},@var{c}}
12959 @item @code{void __MASACCS (acc, acc)}
12960 @tab @code{__MASACCS (@var{b}, @var{a})}
12961 @tab @code{MASACCS @var{a},@var{b}}
12962 @item @code{uw1 __MAVEH (uw1, uw1)}
12963 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12964 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12965 @item @code{uw2 __MBTOH (uw1)}
12966 @tab @code{@var{b} = __MBTOH (@var{a})}
12967 @tab @code{MBTOH @var{a},@var{b}}
12968 @item @code{void __MBTOHE (uw1 *, uw1)}
12969 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12970 @tab @code{MBTOHE @var{a},@var{b}}
12971 @item @code{void __MCLRACC (acc)}
12972 @tab @code{__MCLRACC (@var{a})}
12973 @tab @code{MCLRACC @var{a}}
12974 @item @code{void __MCLRACCA (void)}
12975 @tab @code{__MCLRACCA ()}
12976 @tab @code{MCLRACCA}
12977 @item @code{uw1 __Mcop1 (uw1, uw1)}
12978 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12979 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12980 @item @code{uw1 __Mcop2 (uw1, uw1)}
12981 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12982 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12983 @item @code{uw1 __MCPLHI (uw2, const)}
12984 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12985 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12986 @item @code{uw1 __MCPLI (uw2, const)}
12987 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12988 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12989 @item @code{void __MCPXIS (acc, sw1, sw1)}
12990 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12991 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12992 @item @code{void __MCPXIU (acc, uw1, uw1)}
12993 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12994 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12995 @item @code{void __MCPXRS (acc, sw1, sw1)}
12996 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12997 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12998 @item @code{void __MCPXRU (acc, uw1, uw1)}
12999 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13000 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13001 @item @code{uw1 __MCUT (acc, uw1)}
13002 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13003 @tab @code{MCUT @var{a},@var{b},@var{c}}
13004 @item @code{uw1 __MCUTSS (acc, sw1)}
13005 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13006 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13007 @item @code{void __MDADDACCS (acc, acc)}
13008 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13009 @tab @code{MDADDACCS @var{a},@var{b}}
13010 @item @code{void __MDASACCS (acc, acc)}
13011 @tab @code{__MDASACCS (@var{b}, @var{a})}
13012 @tab @code{MDASACCS @var{a},@var{b}}
13013 @item @code{uw2 __MDCUTSSI (acc, const)}
13014 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13015 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13016 @item @code{uw2 __MDPACKH (uw2, uw2)}
13017 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13018 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13019 @item @code{uw2 __MDROTLI (uw2, const)}
13020 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13021 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13022 @item @code{void __MDSUBACCS (acc, acc)}
13023 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13024 @tab @code{MDSUBACCS @var{a},@var{b}}
13025 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13026 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13027 @tab @code{MDUNPACKH @var{a},@var{b}}
13028 @item @code{uw2 __MEXPDHD (uw1, const)}
13029 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13030 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13031 @item @code{uw1 __MEXPDHW (uw1, const)}
13032 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13033 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13034 @item @code{uw1 __MHDSETH (uw1, const)}
13035 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13036 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13037 @item @code{sw1 __MHDSETS (const)}
13038 @tab @code{@var{b} = __MHDSETS (@var{a})}
13039 @tab @code{MHDSETS #@var{a},@var{b}}
13040 @item @code{uw1 __MHSETHIH (uw1, const)}
13041 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13042 @tab @code{MHSETHIH #@var{a},@var{b}}
13043 @item @code{sw1 __MHSETHIS (sw1, const)}
13044 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13045 @tab @code{MHSETHIS #@var{a},@var{b}}
13046 @item @code{uw1 __MHSETLOH (uw1, const)}
13047 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13048 @tab @code{MHSETLOH #@var{a},@var{b}}
13049 @item @code{sw1 __MHSETLOS (sw1, const)}
13050 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13051 @tab @code{MHSETLOS #@var{a},@var{b}}
13052 @item @code{uw1 __MHTOB (uw2)}
13053 @tab @code{@var{b} = __MHTOB (@var{a})}
13054 @tab @code{MHTOB @var{a},@var{b}}
13055 @item @code{void __MMACHS (acc, sw1, sw1)}
13056 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13057 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13058 @item @code{void __MMACHU (acc, uw1, uw1)}
13059 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13060 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13061 @item @code{void __MMRDHS (acc, sw1, sw1)}
13062 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13063 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13064 @item @code{void __MMRDHU (acc, uw1, uw1)}
13065 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13066 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13067 @item @code{void __MMULHS (acc, sw1, sw1)}
13068 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13069 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13070 @item @code{void __MMULHU (acc, uw1, uw1)}
13071 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13072 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13073 @item @code{void __MMULXHS (acc, sw1, sw1)}
13074 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13075 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13076 @item @code{void __MMULXHU (acc, uw1, uw1)}
13077 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13078 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13079 @item @code{uw1 __MNOT (uw1)}
13080 @tab @code{@var{b} = __MNOT (@var{a})}
13081 @tab @code{MNOT @var{a},@var{b}}
13082 @item @code{uw1 __MOR (uw1, uw1)}
13083 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13084 @tab @code{MOR @var{a},@var{b},@var{c}}
13085 @item @code{uw1 __MPACKH (uh, uh)}
13086 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13087 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13088 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13089 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13090 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13091 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13092 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13093 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13094 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13095 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13096 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13097 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13098 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13099 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13100 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13101 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13102 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13103 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13104 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13105 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13106 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13107 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13108 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13109 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13110 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13111 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13112 @item @code{void __MQMACHS (acc, sw2, sw2)}
13113 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13114 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13115 @item @code{void __MQMACHU (acc, uw2, uw2)}
13116 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13117 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13118 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13119 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13120 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13121 @item @code{void __MQMULHS (acc, sw2, sw2)}
13122 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13123 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13124 @item @code{void __MQMULHU (acc, uw2, uw2)}
13125 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13126 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13127 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13128 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13129 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13130 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13131 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13132 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13133 @item @code{sw2 __MQSATHS (sw2, sw2)}
13134 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13135 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13136 @item @code{uw2 __MQSLLHI (uw2, int)}
13137 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13138 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13139 @item @code{sw2 __MQSRAHI (sw2, int)}
13140 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13141 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13142 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13143 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13144 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13145 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13146 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13147 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13148 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13149 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13150 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13151 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13152 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13153 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13154 @item @code{uw1 __MRDACC (acc)}
13155 @tab @code{@var{b} = __MRDACC (@var{a})}
13156 @tab @code{MRDACC @var{a},@var{b}}
13157 @item @code{uw1 __MRDACCG (acc)}
13158 @tab @code{@var{b} = __MRDACCG (@var{a})}
13159 @tab @code{MRDACCG @var{a},@var{b}}
13160 @item @code{uw1 __MROTLI (uw1, const)}
13161 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13162 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13163 @item @code{uw1 __MROTRI (uw1, const)}
13164 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13165 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13166 @item @code{sw1 __MSATHS (sw1, sw1)}
13167 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13168 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13169 @item @code{uw1 __MSATHU (uw1, uw1)}
13170 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13171 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13172 @item @code{uw1 __MSLLHI (uw1, const)}
13173 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13174 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13175 @item @code{sw1 __MSRAHI (sw1, const)}
13176 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13177 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13178 @item @code{uw1 __MSRLHI (uw1, const)}
13179 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13180 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13181 @item @code{void __MSUBACCS (acc, acc)}
13182 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13183 @tab @code{MSUBACCS @var{a},@var{b}}
13184 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13185 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13186 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13187 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13188 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13189 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13190 @item @code{void __MTRAP (void)}
13191 @tab @code{__MTRAP ()}
13192 @tab @code{MTRAP}
13193 @item @code{uw2 __MUNPACKH (uw1)}
13194 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13195 @tab @code{MUNPACKH @var{a},@var{b}}
13196 @item @code{uw1 __MWCUT (uw2, uw1)}
13197 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13198 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13199 @item @code{void __MWTACC (acc, uw1)}
13200 @tab @code{__MWTACC (@var{b}, @var{a})}
13201 @tab @code{MWTACC @var{a},@var{b}}
13202 @item @code{void __MWTACCG (acc, uw1)}
13203 @tab @code{__MWTACCG (@var{b}, @var{a})}
13204 @tab @code{MWTACCG @var{a},@var{b}}
13205 @item @code{uw1 __MXOR (uw1, uw1)}
13206 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13207 @tab @code{MXOR @var{a},@var{b},@var{c}}
13208 @end multitable
13210 @node Raw read/write Functions
13211 @subsubsection Raw Read/Write Functions
13213 This sections describes built-in functions related to read and write
13214 instructions to access memory.  These functions generate
13215 @code{membar} instructions to flush the I/O load and stores where
13216 appropriate, as described in Fujitsu's manual described above.
13218 @table @code
13220 @item unsigned char __builtin_read8 (void *@var{data})
13221 @item unsigned short __builtin_read16 (void *@var{data})
13222 @item unsigned long __builtin_read32 (void *@var{data})
13223 @item unsigned long long __builtin_read64 (void *@var{data})
13225 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13226 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13227 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13228 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13229 @end table
13231 @node Other Built-in Functions
13232 @subsubsection Other Built-in Functions
13234 This section describes built-in functions that are not named after
13235 a specific FR-V instruction.
13237 @table @code
13238 @item sw2 __IACCreadll (iacc @var{reg})
13239 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13240 for future expansion and must be 0.
13242 @item sw1 __IACCreadl (iacc @var{reg})
13243 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13244 Other values of @var{reg} are rejected as invalid.
13246 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13247 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13248 is reserved for future expansion and must be 0.
13250 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13251 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13252 is 1.  Other values of @var{reg} are rejected as invalid.
13254 @item void __data_prefetch0 (const void *@var{x})
13255 Use the @code{dcpl} instruction to load the contents of address @var{x}
13256 into the data cache.
13258 @item void __data_prefetch (const void *@var{x})
13259 Use the @code{nldub} instruction to load the contents of address @var{x}
13260 into the data cache.  The instruction is issued in slot I1@.
13261 @end table
13263 @node MIPS DSP Built-in Functions
13264 @subsection MIPS DSP Built-in Functions
13266 The MIPS DSP Application-Specific Extension (ASE) includes new
13267 instructions that are designed to improve the performance of DSP and
13268 media applications.  It provides instructions that operate on packed
13269 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13271 GCC supports MIPS DSP operations using both the generic
13272 vector extensions (@pxref{Vector Extensions}) and a collection of
13273 MIPS-specific built-in functions.  Both kinds of support are
13274 enabled by the @option{-mdsp} command-line option.
13276 Revision 2 of the ASE was introduced in the second half of 2006.
13277 This revision adds extra instructions to the original ASE, but is
13278 otherwise backwards-compatible with it.  You can select revision 2
13279 using the command-line option @option{-mdspr2}; this option implies
13280 @option{-mdsp}.
13282 The SCOUNT and POS bits of the DSP control register are global.  The
13283 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13284 POS bits.  During optimization, the compiler does not delete these
13285 instructions and it does not delete calls to functions containing
13286 these instructions.
13288 At present, GCC only provides support for operations on 32-bit
13289 vectors.  The vector type associated with 8-bit integer data is
13290 usually called @code{v4i8}, the vector type associated with Q7
13291 is usually called @code{v4q7}, the vector type associated with 16-bit
13292 integer data is usually called @code{v2i16}, and the vector type
13293 associated with Q15 is usually called @code{v2q15}.  They can be
13294 defined in C as follows:
13296 @smallexample
13297 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13298 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13299 typedef short v2i16 __attribute__ ((vector_size(4)));
13300 typedef short v2q15 __attribute__ ((vector_size(4)));
13301 @end smallexample
13303 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13304 initialized in the same way as aggregates.  For example:
13306 @smallexample
13307 v4i8 a = @{1, 2, 3, 4@};
13308 v4i8 b;
13309 b = (v4i8) @{5, 6, 7, 8@};
13311 v2q15 c = @{0x0fcb, 0x3a75@};
13312 v2q15 d;
13313 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13314 @end smallexample
13316 @emph{Note:} The CPU's endianness determines the order in which values
13317 are packed.  On little-endian targets, the first value is the least
13318 significant and the last value is the most significant.  The opposite
13319 order applies to big-endian targets.  For example, the code above
13320 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13321 and @code{4} on big-endian targets.
13323 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13324 representation.  As shown in this example, the integer representation
13325 of a Q7 value can be obtained by multiplying the fractional value by
13326 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13327 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13328 @code{0x1.0p31}.
13330 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13331 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13332 and @code{c} and @code{d} are @code{v2q15} values.
13334 @multitable @columnfractions .50 .50
13335 @item C code @tab MIPS instruction
13336 @item @code{a + b} @tab @code{addu.qb}
13337 @item @code{c + d} @tab @code{addq.ph}
13338 @item @code{a - b} @tab @code{subu.qb}
13339 @item @code{c - d} @tab @code{subq.ph}
13340 @end multitable
13342 The table below lists the @code{v2i16} operation for which
13343 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13344 @code{v2i16} values.
13346 @multitable @columnfractions .50 .50
13347 @item C code @tab MIPS instruction
13348 @item @code{e * f} @tab @code{mul.ph}
13349 @end multitable
13351 It is easier to describe the DSP built-in functions if we first define
13352 the following types:
13354 @smallexample
13355 typedef int q31;
13356 typedef int i32;
13357 typedef unsigned int ui32;
13358 typedef long long a64;
13359 @end smallexample
13361 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13362 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13363 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13364 @code{long long}, but we use @code{a64} to indicate values that are
13365 placed in one of the four DSP accumulators (@code{$ac0},
13366 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13368 Also, some built-in functions prefer or require immediate numbers as
13369 parameters, because the corresponding DSP instructions accept both immediate
13370 numbers and register operands, or accept immediate numbers only.  The
13371 immediate parameters are listed as follows.
13373 @smallexample
13374 imm0_3: 0 to 3.
13375 imm0_7: 0 to 7.
13376 imm0_15: 0 to 15.
13377 imm0_31: 0 to 31.
13378 imm0_63: 0 to 63.
13379 imm0_255: 0 to 255.
13380 imm_n32_31: -32 to 31.
13381 imm_n512_511: -512 to 511.
13382 @end smallexample
13384 The following built-in functions map directly to a particular MIPS DSP
13385 instruction.  Please refer to the architecture specification
13386 for details on what each instruction does.
13388 @smallexample
13389 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13390 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13391 q31 __builtin_mips_addq_s_w (q31, q31)
13392 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13393 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13394 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13395 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13396 q31 __builtin_mips_subq_s_w (q31, q31)
13397 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13398 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13399 i32 __builtin_mips_addsc (i32, i32)
13400 i32 __builtin_mips_addwc (i32, i32)
13401 i32 __builtin_mips_modsub (i32, i32)
13402 i32 __builtin_mips_raddu_w_qb (v4i8)
13403 v2q15 __builtin_mips_absq_s_ph (v2q15)
13404 q31 __builtin_mips_absq_s_w (q31)
13405 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13406 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13407 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13408 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13409 q31 __builtin_mips_preceq_w_phl (v2q15)
13410 q31 __builtin_mips_preceq_w_phr (v2q15)
13411 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13412 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13413 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13414 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13415 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13416 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13417 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13418 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13419 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13420 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13421 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13422 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13423 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13424 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13425 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13426 q31 __builtin_mips_shll_s_w (q31, i32)
13427 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13428 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13429 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13430 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13431 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13432 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13433 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13434 q31 __builtin_mips_shra_r_w (q31, i32)
13435 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13436 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13437 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13438 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13439 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13440 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13441 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13442 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13443 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13444 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13445 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13446 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13447 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13448 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13449 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13450 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13451 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13452 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13453 i32 __builtin_mips_bitrev (i32)
13454 i32 __builtin_mips_insv (i32, i32)
13455 v4i8 __builtin_mips_repl_qb (imm0_255)
13456 v4i8 __builtin_mips_repl_qb (i32)
13457 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13458 v2q15 __builtin_mips_repl_ph (i32)
13459 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13460 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13461 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13462 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13463 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13464 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13465 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13466 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13467 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13468 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13469 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13470 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13471 i32 __builtin_mips_extr_w (a64, imm0_31)
13472 i32 __builtin_mips_extr_w (a64, i32)
13473 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13474 i32 __builtin_mips_extr_s_h (a64, i32)
13475 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13476 i32 __builtin_mips_extr_rs_w (a64, i32)
13477 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13478 i32 __builtin_mips_extr_r_w (a64, i32)
13479 i32 __builtin_mips_extp (a64, imm0_31)
13480 i32 __builtin_mips_extp (a64, i32)
13481 i32 __builtin_mips_extpdp (a64, imm0_31)
13482 i32 __builtin_mips_extpdp (a64, i32)
13483 a64 __builtin_mips_shilo (a64, imm_n32_31)
13484 a64 __builtin_mips_shilo (a64, i32)
13485 a64 __builtin_mips_mthlip (a64, i32)
13486 void __builtin_mips_wrdsp (i32, imm0_63)
13487 i32 __builtin_mips_rddsp (imm0_63)
13488 i32 __builtin_mips_lbux (void *, i32)
13489 i32 __builtin_mips_lhx (void *, i32)
13490 i32 __builtin_mips_lwx (void *, i32)
13491 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13492 i32 __builtin_mips_bposge32 (void)
13493 a64 __builtin_mips_madd (a64, i32, i32);
13494 a64 __builtin_mips_maddu (a64, ui32, ui32);
13495 a64 __builtin_mips_msub (a64, i32, i32);
13496 a64 __builtin_mips_msubu (a64, ui32, ui32);
13497 a64 __builtin_mips_mult (i32, i32);
13498 a64 __builtin_mips_multu (ui32, ui32);
13499 @end smallexample
13501 The following built-in functions map directly to a particular MIPS DSP REV 2
13502 instruction.  Please refer to the architecture specification
13503 for details on what each instruction does.
13505 @smallexample
13506 v4q7 __builtin_mips_absq_s_qb (v4q7);
13507 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13508 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13509 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13510 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13511 i32 __builtin_mips_append (i32, i32, imm0_31);
13512 i32 __builtin_mips_balign (i32, i32, imm0_3);
13513 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13514 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13515 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13516 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13517 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13518 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13519 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13520 q31 __builtin_mips_mulq_rs_w (q31, q31);
13521 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13522 q31 __builtin_mips_mulq_s_w (q31, q31);
13523 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13524 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13525 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13526 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13527 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13528 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13529 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13530 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13531 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13532 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13533 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13534 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13535 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13536 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13537 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13538 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13539 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13540 q31 __builtin_mips_addqh_w (q31, q31);
13541 q31 __builtin_mips_addqh_r_w (q31, q31);
13542 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13543 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13544 q31 __builtin_mips_subqh_w (q31, q31);
13545 q31 __builtin_mips_subqh_r_w (q31, q31);
13546 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13547 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13548 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13549 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13550 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13551 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13552 @end smallexample
13555 @node MIPS Paired-Single Support
13556 @subsection MIPS Paired-Single Support
13558 The MIPS64 architecture includes a number of instructions that
13559 operate on pairs of single-precision floating-point values.
13560 Each pair is packed into a 64-bit floating-point register,
13561 with one element being designated the ``upper half'' and
13562 the other being designated the ``lower half''.
13564 GCC supports paired-single operations using both the generic
13565 vector extensions (@pxref{Vector Extensions}) and a collection of
13566 MIPS-specific built-in functions.  Both kinds of support are
13567 enabled by the @option{-mpaired-single} command-line option.
13569 The vector type associated with paired-single values is usually
13570 called @code{v2sf}.  It can be defined in C as follows:
13572 @smallexample
13573 typedef float v2sf __attribute__ ((vector_size (8)));
13574 @end smallexample
13576 @code{v2sf} values are initialized in the same way as aggregates.
13577 For example:
13579 @smallexample
13580 v2sf a = @{1.5, 9.1@};
13581 v2sf b;
13582 float e, f;
13583 b = (v2sf) @{e, f@};
13584 @end smallexample
13586 @emph{Note:} The CPU's endianness determines which value is stored in
13587 the upper half of a register and which value is stored in the lower half.
13588 On little-endian targets, the first value is the lower one and the second
13589 value is the upper one.  The opposite order applies to big-endian targets.
13590 For example, the code above sets the lower half of @code{a} to
13591 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13593 @node MIPS Loongson Built-in Functions
13594 @subsection MIPS Loongson Built-in Functions
13596 GCC provides intrinsics to access the SIMD instructions provided by the
13597 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13598 available after inclusion of the @code{loongson.h} header file,
13599 operate on the following 64-bit vector types:
13601 @itemize
13602 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13603 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13604 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13605 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13606 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13607 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13608 @end itemize
13610 The intrinsics provided are listed below; each is named after the
13611 machine instruction to which it corresponds, with suffixes added as
13612 appropriate to distinguish intrinsics that expand to the same machine
13613 instruction yet have different argument types.  Refer to the architecture
13614 documentation for a description of the functionality of each
13615 instruction.
13617 @smallexample
13618 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13619 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13620 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13621 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13622 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13623 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13624 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13625 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13626 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13627 uint64_t paddd_u (uint64_t s, uint64_t t);
13628 int64_t paddd_s (int64_t s, int64_t t);
13629 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13630 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13631 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13632 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13633 uint64_t pandn_ud (uint64_t s, uint64_t t);
13634 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13635 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13636 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13637 int64_t pandn_sd (int64_t s, int64_t t);
13638 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13639 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13640 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13641 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13642 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13643 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13644 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13645 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13646 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13647 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13648 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13649 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13650 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13651 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13652 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13653 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13654 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13655 uint16x4_t pextrh_u (uint16x4_t s, int field);
13656 int16x4_t pextrh_s (int16x4_t s, int field);
13657 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13658 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13659 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13660 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13661 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13662 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13663 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13664 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13665 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13666 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13667 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13668 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13669 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13670 uint8x8_t pmovmskb_u (uint8x8_t s);
13671 int8x8_t pmovmskb_s (int8x8_t s);
13672 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13673 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13674 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13675 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13676 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13677 uint16x4_t biadd (uint8x8_t s);
13678 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13679 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13680 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13681 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13682 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13683 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13684 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13685 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13686 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13687 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13688 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13689 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13690 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13691 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13692 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13693 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13694 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13695 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13696 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13697 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13698 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13699 uint64_t psubd_u (uint64_t s, uint64_t t);
13700 int64_t psubd_s (int64_t s, int64_t t);
13701 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13702 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13703 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13704 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13705 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13706 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13707 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13708 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13709 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13710 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13711 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13712 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13713 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13714 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13715 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13716 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13717 @end smallexample
13719 @menu
13720 * Paired-Single Arithmetic::
13721 * Paired-Single Built-in Functions::
13722 * MIPS-3D Built-in Functions::
13723 @end menu
13725 @node Paired-Single Arithmetic
13726 @subsubsection Paired-Single Arithmetic
13728 The table below lists the @code{v2sf} operations for which hardware
13729 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13730 values and @code{x} is an integral value.
13732 @multitable @columnfractions .50 .50
13733 @item C code @tab MIPS instruction
13734 @item @code{a + b} @tab @code{add.ps}
13735 @item @code{a - b} @tab @code{sub.ps}
13736 @item @code{-a} @tab @code{neg.ps}
13737 @item @code{a * b} @tab @code{mul.ps}
13738 @item @code{a * b + c} @tab @code{madd.ps}
13739 @item @code{a * b - c} @tab @code{msub.ps}
13740 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13741 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13742 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13743 @end multitable
13745 Note that the multiply-accumulate instructions can be disabled
13746 using the command-line option @code{-mno-fused-madd}.
13748 @node Paired-Single Built-in Functions
13749 @subsubsection Paired-Single Built-in Functions
13751 The following paired-single functions map directly to a particular
13752 MIPS instruction.  Please refer to the architecture specification
13753 for details on what each instruction does.
13755 @table @code
13756 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13757 Pair lower lower (@code{pll.ps}).
13759 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13760 Pair upper lower (@code{pul.ps}).
13762 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13763 Pair lower upper (@code{plu.ps}).
13765 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13766 Pair upper upper (@code{puu.ps}).
13768 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13769 Convert pair to paired single (@code{cvt.ps.s}).
13771 @item float __builtin_mips_cvt_s_pl (v2sf)
13772 Convert pair lower to single (@code{cvt.s.pl}).
13774 @item float __builtin_mips_cvt_s_pu (v2sf)
13775 Convert pair upper to single (@code{cvt.s.pu}).
13777 @item v2sf __builtin_mips_abs_ps (v2sf)
13778 Absolute value (@code{abs.ps}).
13780 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13781 Align variable (@code{alnv.ps}).
13783 @emph{Note:} The value of the third parameter must be 0 or 4
13784 modulo 8, otherwise the result is unpredictable.  Please read the
13785 instruction description for details.
13786 @end table
13788 The following multi-instruction functions are also available.
13789 In each case, @var{cond} can be any of the 16 floating-point conditions:
13790 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13791 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13792 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13794 @table @code
13795 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13796 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13797 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13798 @code{movt.ps}/@code{movf.ps}).
13800 The @code{movt} functions return the value @var{x} computed by:
13802 @smallexample
13803 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13804 mov.ps @var{x},@var{c}
13805 movt.ps @var{x},@var{d},@var{cc}
13806 @end smallexample
13808 The @code{movf} functions are similar but use @code{movf.ps} instead
13809 of @code{movt.ps}.
13811 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13812 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13813 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13814 @code{bc1t}/@code{bc1f}).
13816 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13817 and return either the upper or lower half of the result.  For example:
13819 @smallexample
13820 v2sf a, b;
13821 if (__builtin_mips_upper_c_eq_ps (a, b))
13822   upper_halves_are_equal ();
13823 else
13824   upper_halves_are_unequal ();
13826 if (__builtin_mips_lower_c_eq_ps (a, b))
13827   lower_halves_are_equal ();
13828 else
13829   lower_halves_are_unequal ();
13830 @end smallexample
13831 @end table
13833 @node MIPS-3D Built-in Functions
13834 @subsubsection MIPS-3D Built-in Functions
13836 The MIPS-3D Application-Specific Extension (ASE) includes additional
13837 paired-single instructions that are designed to improve the performance
13838 of 3D graphics operations.  Support for these instructions is controlled
13839 by the @option{-mips3d} command-line option.
13841 The functions listed below map directly to a particular MIPS-3D
13842 instruction.  Please refer to the architecture specification for
13843 more details on what each instruction does.
13845 @table @code
13846 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13847 Reduction add (@code{addr.ps}).
13849 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13850 Reduction multiply (@code{mulr.ps}).
13852 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13853 Convert paired single to paired word (@code{cvt.pw.ps}).
13855 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13856 Convert paired word to paired single (@code{cvt.ps.pw}).
13858 @item float __builtin_mips_recip1_s (float)
13859 @itemx double __builtin_mips_recip1_d (double)
13860 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13861 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13863 @item float __builtin_mips_recip2_s (float, float)
13864 @itemx double __builtin_mips_recip2_d (double, double)
13865 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13866 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13868 @item float __builtin_mips_rsqrt1_s (float)
13869 @itemx double __builtin_mips_rsqrt1_d (double)
13870 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13871 Reduced-precision reciprocal square root (sequence step 1)
13872 (@code{rsqrt1.@var{fmt}}).
13874 @item float __builtin_mips_rsqrt2_s (float, float)
13875 @itemx double __builtin_mips_rsqrt2_d (double, double)
13876 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13877 Reduced-precision reciprocal square root (sequence step 2)
13878 (@code{rsqrt2.@var{fmt}}).
13879 @end table
13881 The following multi-instruction functions are also available.
13882 In each case, @var{cond} can be any of the 16 floating-point conditions:
13883 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13884 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13885 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13887 @table @code
13888 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13889 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13890 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13891 @code{bc1t}/@code{bc1f}).
13893 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13894 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13895 For example:
13897 @smallexample
13898 float a, b;
13899 if (__builtin_mips_cabs_eq_s (a, b))
13900   true ();
13901 else
13902   false ();
13903 @end smallexample
13905 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13906 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13907 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13908 @code{bc1t}/@code{bc1f}).
13910 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13911 and return either the upper or lower half of the result.  For example:
13913 @smallexample
13914 v2sf a, b;
13915 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13916   upper_halves_are_equal ();
13917 else
13918   upper_halves_are_unequal ();
13920 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13921   lower_halves_are_equal ();
13922 else
13923   lower_halves_are_unequal ();
13924 @end smallexample
13926 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13927 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13928 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13929 @code{movt.ps}/@code{movf.ps}).
13931 The @code{movt} functions return the value @var{x} computed by:
13933 @smallexample
13934 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13935 mov.ps @var{x},@var{c}
13936 movt.ps @var{x},@var{d},@var{cc}
13937 @end smallexample
13939 The @code{movf} functions are similar but use @code{movf.ps} instead
13940 of @code{movt.ps}.
13942 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13943 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13944 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13945 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13946 Comparison of two paired-single values
13947 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13948 @code{bc1any2t}/@code{bc1any2f}).
13950 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13951 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13952 result is true and the @code{all} forms return true if both results are true.
13953 For example:
13955 @smallexample
13956 v2sf a, b;
13957 if (__builtin_mips_any_c_eq_ps (a, b))
13958   one_is_true ();
13959 else
13960   both_are_false ();
13962 if (__builtin_mips_all_c_eq_ps (a, b))
13963   both_are_true ();
13964 else
13965   one_is_false ();
13966 @end smallexample
13968 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13969 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13970 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13971 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13972 Comparison of four paired-single values
13973 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13974 @code{bc1any4t}/@code{bc1any4f}).
13976 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13977 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13978 The @code{any} forms return true if any of the four results are true
13979 and the @code{all} forms return true if all four results are true.
13980 For example:
13982 @smallexample
13983 v2sf a, b, c, d;
13984 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13985   some_are_true ();
13986 else
13987   all_are_false ();
13989 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13990   all_are_true ();
13991 else
13992   some_are_false ();
13993 @end smallexample
13994 @end table
13996 @node MIPS SIMD Architecture (MSA) Support
13997 @subsection MIPS SIMD Architecture (MSA) Support
13999 @menu
14000 * MIPS SIMD Architecture Built-in Functions::
14001 @end menu
14003 GCC provides intrinsics to access the SIMD instructions provided by the
14004 MSA MIPS SIMD Architecture.  The interface is made available by including
14005 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14006 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14007 @code{__msa_*}.
14009 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14010 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14011 data elements.  The following vectors typedefs are included in @code{msa.h}:
14012 @itemize
14013 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14014 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14015 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14016 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14017 @item @code{v4i32}, a vector of four signed 32-bit integers;
14018 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14019 @item @code{v2i64}, a vector of two signed 64-bit integers;
14020 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14021 @item @code{v4f32}, a vector of four 32-bit floats;
14022 @item @code{v2f64}, a vector of two 64-bit doubles.
14023 @end itemize
14025 Instructions and corresponding built-ins may have additional restrictions and/or
14026 input/output values manipulated:
14027 @itemize
14028 @item @code{imm0_1}, an integer literal in range 0 to 1;
14029 @item @code{imm0_3}, an integer literal in range 0 to 3;
14030 @item @code{imm0_7}, an integer literal in range 0 to 7;
14031 @item @code{imm0_15}, an integer literal in range 0 to 15;
14032 @item @code{imm0_31}, an integer literal in range 0 to 31;
14033 @item @code{imm0_63}, an integer literal in range 0 to 63;
14034 @item @code{imm0_255}, an integer literal in range 0 to 255;
14035 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14036 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14037 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14038 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14039 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14040 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14041 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14042 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14043 @item @code{imm1_4}, an integer literal in range 1 to 4;
14044 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14045 @end itemize
14047 @smallexample
14049 typedef int i32;
14050 #if __LONG_MAX__ == __LONG_LONG_MAX__
14051 typedef long i64;
14052 #else
14053 typedef long long i64;
14054 #endif
14056 typedef unsigned int u32;
14057 #if __LONG_MAX__ == __LONG_LONG_MAX__
14058 typedef unsigned long u64;
14059 #else
14060 typedef unsigned long long u64;
14061 #endif
14063 typedef double f64;
14064 typedef float f32;
14066 @end smallexample
14068 @node MIPS SIMD Architecture Built-in Functions
14069 @subsubsection MIPS SIMD Architecture Built-in Functions
14071 The intrinsics provided are listed below; each is named after the
14072 machine instruction.
14074 @smallexample
14075 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14076 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14077 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14078 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14080 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14081 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14082 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14083 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14085 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14086 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14087 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14088 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14090 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14091 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14092 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14093 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14095 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14096 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14097 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14098 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14100 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14101 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14102 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14103 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14105 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14107 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14109 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14110 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14111 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14112 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14114 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14115 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14116 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14117 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14119 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14120 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14121 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14122 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14124 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14125 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14126 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14127 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14129 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14130 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14131 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14132 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14134 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14135 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14136 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14137 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14139 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14140 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14141 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14142 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14144 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14145 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14146 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14147 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14149 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14150 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14151 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14152 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14154 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14155 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14156 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14157 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14159 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14160 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14161 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14162 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14164 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14165 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14166 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14167 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14169 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14171 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14173 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14175 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14177 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14178 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14179 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14180 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14182 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14183 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14184 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14185 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14187 i32 __builtin_msa_bnz_b (v16u8);
14188 i32 __builtin_msa_bnz_h (v8u16);
14189 i32 __builtin_msa_bnz_w (v4u32);
14190 i32 __builtin_msa_bnz_d (v2u64);
14192 i32 __builtin_msa_bnz_v (v16u8);
14194 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14196 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14198 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14199 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14200 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14201 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14203 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14204 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14205 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14206 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14208 i32 __builtin_msa_bz_b (v16u8);
14209 i32 __builtin_msa_bz_h (v8u16);
14210 i32 __builtin_msa_bz_w (v4u32);
14211 i32 __builtin_msa_bz_d (v2u64);
14213 i32 __builtin_msa_bz_v (v16u8);
14215 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14216 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14217 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14218 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14220 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14221 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14222 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14223 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14225 i32 __builtin_msa_cfcmsa (imm0_31);
14227 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14228 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14229 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14230 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14232 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14233 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14234 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14235 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14237 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14238 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14239 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14240 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14242 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14243 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14244 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14245 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14247 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14248 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14249 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14250 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14252 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14253 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14254 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14255 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14257 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14258 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14259 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14260 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14262 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14263 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14264 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14265 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14267 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14268 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14269 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14270 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14272 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14273 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14274 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14275 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14277 void __builtin_msa_ctcmsa (imm0_31, i32);
14279 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14280 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14281 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14282 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14284 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14285 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14286 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14287 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14289 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14290 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14291 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14293 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14294 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14295 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14297 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14298 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14299 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14301 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14302 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14303 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14305 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14306 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14307 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14309 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14310 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14311 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14313 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14314 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14316 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14317 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14319 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14320 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14322 v4i32 __builtin_msa_fclass_w (v4f32);
14323 v2i64 __builtin_msa_fclass_d (v2f64);
14325 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14326 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14328 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14329 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14331 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14332 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14334 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14335 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14337 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14338 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14340 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14341 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14343 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14344 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14346 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14347 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14349 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14350 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14352 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14353 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14355 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14356 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14358 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14359 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14361 v4f32 __builtin_msa_fexupl_w (v8i16);
14362 v2f64 __builtin_msa_fexupl_d (v4f32);
14364 v4f32 __builtin_msa_fexupr_w (v8i16);
14365 v2f64 __builtin_msa_fexupr_d (v4f32);
14367 v4f32 __builtin_msa_ffint_s_w (v4i32);
14368 v2f64 __builtin_msa_ffint_s_d (v2i64);
14370 v4f32 __builtin_msa_ffint_u_w (v4u32);
14371 v2f64 __builtin_msa_ffint_u_d (v2u64);
14373 v4f32 __builtin_msa_ffql_w (v8i16);
14374 v2f64 __builtin_msa_ffql_d (v4i32);
14376 v4f32 __builtin_msa_ffqr_w (v8i16);
14377 v2f64 __builtin_msa_ffqr_d (v4i32);
14379 v16i8 __builtin_msa_fill_b (i32);
14380 v8i16 __builtin_msa_fill_h (i32);
14381 v4i32 __builtin_msa_fill_w (i32);
14382 v2i64 __builtin_msa_fill_d (i64);
14384 v4f32 __builtin_msa_flog2_w (v4f32);
14385 v2f64 __builtin_msa_flog2_d (v2f64);
14387 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14388 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14390 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14391 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14393 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14394 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14396 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14397 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14399 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14400 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14402 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14403 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14405 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14406 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14408 v4f32 __builtin_msa_frint_w (v4f32);
14409 v2f64 __builtin_msa_frint_d (v2f64);
14411 v4f32 __builtin_msa_frcp_w (v4f32);
14412 v2f64 __builtin_msa_frcp_d (v2f64);
14414 v4f32 __builtin_msa_frsqrt_w (v4f32);
14415 v2f64 __builtin_msa_frsqrt_d (v2f64);
14417 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14418 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14420 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14421 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14423 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14424 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14426 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14427 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14429 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14430 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14432 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14433 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14435 v4f32 __builtin_msa_fsqrt_w (v4f32);
14436 v2f64 __builtin_msa_fsqrt_d (v2f64);
14438 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14439 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14441 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14442 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14444 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14445 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14447 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14448 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14450 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14451 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14453 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14454 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14456 v4i32 __builtin_msa_ftint_s_w (v4f32);
14457 v2i64 __builtin_msa_ftint_s_d (v2f64);
14459 v4u32 __builtin_msa_ftint_u_w (v4f32);
14460 v2u64 __builtin_msa_ftint_u_d (v2f64);
14462 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14463 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14465 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14466 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14468 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14469 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14471 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14472 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14473 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14475 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14476 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14477 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14479 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14480 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14481 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14483 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14484 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14485 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14487 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14488 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14489 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14490 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14492 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14493 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14494 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14495 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14497 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14498 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14499 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14500 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14502 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14503 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14504 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14505 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14507 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14508 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14509 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14510 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14512 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14513 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14514 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14515 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14517 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14518 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14519 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14520 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14522 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14523 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14524 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14525 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14527 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14528 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14530 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14531 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14533 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14534 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14535 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14536 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14538 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14539 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14540 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14541 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14543 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14544 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14545 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14546 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14548 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14549 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14550 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14551 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14553 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14554 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14555 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14556 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14558 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14559 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14560 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14561 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14563 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14564 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14565 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14566 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14568 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14569 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14570 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14571 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14573 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14574 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14575 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14576 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14578 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14579 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14580 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14581 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14583 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14584 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14585 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14586 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14588 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14589 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14590 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14591 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14593 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14594 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14595 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14596 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14598 v16i8 __builtin_msa_move_v (v16i8);
14600 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14601 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14603 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14604 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14606 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14607 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14608 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14609 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14611 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14612 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14614 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14615 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14617 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14618 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14619 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14620 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14622 v16i8 __builtin_msa_nloc_b (v16i8);
14623 v8i16 __builtin_msa_nloc_h (v8i16);
14624 v4i32 __builtin_msa_nloc_w (v4i32);
14625 v2i64 __builtin_msa_nloc_d (v2i64);
14627 v16i8 __builtin_msa_nlzc_b (v16i8);
14628 v8i16 __builtin_msa_nlzc_h (v8i16);
14629 v4i32 __builtin_msa_nlzc_w (v4i32);
14630 v2i64 __builtin_msa_nlzc_d (v2i64);
14632 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14634 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14636 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14638 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14640 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14641 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14642 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14643 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14645 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14646 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14647 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14648 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14650 v16i8 __builtin_msa_pcnt_b (v16i8);
14651 v8i16 __builtin_msa_pcnt_h (v8i16);
14652 v4i32 __builtin_msa_pcnt_w (v4i32);
14653 v2i64 __builtin_msa_pcnt_d (v2i64);
14655 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14656 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14657 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14658 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14660 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14661 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14662 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14663 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14665 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14666 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14667 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14669 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14670 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14671 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14672 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14674 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14675 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14676 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14677 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14679 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14680 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14681 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14682 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14684 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14685 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14686 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14687 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14689 v16i8 __builtin_msa_splat_b (v16i8, i32);
14690 v8i16 __builtin_msa_splat_h (v8i16, i32);
14691 v4i32 __builtin_msa_splat_w (v4i32, i32);
14692 v2i64 __builtin_msa_splat_d (v2i64, i32);
14694 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14695 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14696 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14697 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14699 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14700 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14701 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14702 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14704 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14705 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14706 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14707 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14709 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14710 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14711 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14712 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14714 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14715 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14716 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14717 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14719 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14720 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14721 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14722 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14724 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14725 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14726 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14727 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14729 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14730 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14731 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14732 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14734 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14735 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14736 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14737 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14739 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14740 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14741 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14742 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14744 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14745 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14746 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14747 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14749 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14750 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14751 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14752 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14754 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14755 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14756 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14757 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14759 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14760 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14761 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14762 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14764 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14765 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14766 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14767 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14769 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14770 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14771 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14772 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14774 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14775 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14776 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14777 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14779 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14781 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14782 @end smallexample
14784 @node Other MIPS Built-in Functions
14785 @subsection Other MIPS Built-in Functions
14787 GCC provides other MIPS-specific built-in functions:
14789 @table @code
14790 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14791 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14792 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14793 when this function is available.
14795 @item unsigned int __builtin_mips_get_fcsr (void)
14796 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14797 Get and set the contents of the floating-point control and status register
14798 (FPU control register 31).  These functions are only available in hard-float
14799 code but can be called in both MIPS16 and non-MIPS16 contexts.
14801 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14802 register except the condition codes, which GCC assumes are preserved.
14803 @end table
14805 @node MSP430 Built-in Functions
14806 @subsection MSP430 Built-in Functions
14808 GCC provides a couple of special builtin functions to aid in the
14809 writing of interrupt handlers in C.
14811 @table @code
14812 @item __bic_SR_register_on_exit (int @var{mask})
14813 This clears the indicated bits in the saved copy of the status register
14814 currently residing on the stack.  This only works inside interrupt
14815 handlers and the changes to the status register will only take affect
14816 once the handler returns.
14818 @item __bis_SR_register_on_exit (int @var{mask})
14819 This sets the indicated bits in the saved copy of the status register
14820 currently residing on the stack.  This only works inside interrupt
14821 handlers and the changes to the status register will only take affect
14822 once the handler returns.
14824 @item __delay_cycles (long long @var{cycles})
14825 This inserts an instruction sequence that takes exactly @var{cycles}
14826 cycles (between 0 and about 17E9) to complete.  The inserted sequence
14827 may use jumps, loops, or no-ops, and does not interfere with any other
14828 instructions.  Note that @var{cycles} must be a compile-time constant
14829 integer - that is, you must pass a number, not a variable that may be
14830 optimized to a constant later.  The number of cycles delayed by this
14831 builtin is exact.
14832 @end table
14834 @node NDS32 Built-in Functions
14835 @subsection NDS32 Built-in Functions
14837 These built-in functions are available for the NDS32 target:
14839 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14840 Insert an ISYNC instruction into the instruction stream where
14841 @var{addr} is an instruction address for serialization.
14842 @end deftypefn
14844 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14845 Insert an ISB instruction into the instruction stream.
14846 @end deftypefn
14848 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14849 Return the content of a system register which is mapped by @var{sr}.
14850 @end deftypefn
14852 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14853 Return the content of a user space register which is mapped by @var{usr}.
14854 @end deftypefn
14856 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14857 Move the @var{value} to a system register which is mapped by @var{sr}.
14858 @end deftypefn
14860 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14861 Move the @var{value} to a user space register which is mapped by @var{usr}.
14862 @end deftypefn
14864 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14865 Enable global interrupt.
14866 @end deftypefn
14868 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14869 Disable global interrupt.
14870 @end deftypefn
14872 @node picoChip Built-in Functions
14873 @subsection picoChip Built-in Functions
14875 GCC provides an interface to selected machine instructions from the
14876 picoChip instruction set.
14878 @table @code
14879 @item int __builtin_sbc (int @var{value})
14880 Sign bit count.  Return the number of consecutive bits in @var{value}
14881 that have the same value as the sign bit.  The result is the number of
14882 leading sign bits minus one, giving the number of redundant sign bits in
14883 @var{value}.
14885 @item int __builtin_byteswap (int @var{value})
14886 Byte swap.  Return the result of swapping the upper and lower bytes of
14887 @var{value}.
14889 @item int __builtin_brev (int @var{value})
14890 Bit reversal.  Return the result of reversing the bits in
14891 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14892 and so on.
14894 @item int __builtin_adds (int @var{x}, int @var{y})
14895 Saturating addition.  Return the result of adding @var{x} and @var{y},
14896 storing the value 32767 if the result overflows.
14898 @item int __builtin_subs (int @var{x}, int @var{y})
14899 Saturating subtraction.  Return the result of subtracting @var{y} from
14900 @var{x}, storing the value @minus{}32768 if the result overflows.
14902 @item void __builtin_halt (void)
14903 Halt.  The processor stops execution.  This built-in is useful for
14904 implementing assertions.
14906 @end table
14908 @node PowerPC Built-in Functions
14909 @subsection PowerPC Built-in Functions
14911 The following built-in functions are always available and can be used to
14912 check the PowerPC target platform type:
14914 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14915 This function is a @code{nop} on the PowerPC platform and is included solely
14916 to maintain API compatibility with the x86 builtins.
14917 @end deftypefn
14919 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14920 This function returns a value of @code{1} if the run-time CPU is of type
14921 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14922 detected:
14924 @table @samp
14925 @item power9
14926 IBM POWER9 Server CPU.
14927 @item power8
14928 IBM POWER8 Server CPU.
14929 @item power7
14930 IBM POWER7 Server CPU.
14931 @item power6x
14932 IBM POWER6 Server CPU (RAW mode).
14933 @item power6
14934 IBM POWER6 Server CPU (Architected mode).
14935 @item power5+
14936 IBM POWER5+ Server CPU.
14937 @item power5
14938 IBM POWER5 Server CPU.
14939 @item ppc970
14940 IBM 970 Server CPU (ie, Apple G5).
14941 @item power4
14942 IBM POWER4 Server CPU.
14943 @item ppca2
14944 IBM A2 64-bit Embedded CPU
14945 @item ppc476
14946 IBM PowerPC 476FP 32-bit Embedded CPU.
14947 @item ppc464
14948 IBM PowerPC 464 32-bit Embedded CPU.
14949 @item ppc440
14950 PowerPC 440 32-bit Embedded CPU.
14951 @item ppc405
14952 PowerPC 405 32-bit Embedded CPU.
14953 @item ppc-cell-be
14954 IBM PowerPC Cell Broadband Engine Architecture CPU.
14955 @end table
14957 Here is an example:
14958 @smallexample
14959 if (__builtin_cpu_is ("power8"))
14960   @{
14961      do_power8 (); // POWER8 specific implementation.
14962   @}
14963 else
14964   @{
14965      do_generic (); // Generic implementation.
14966   @}
14967 @end smallexample
14968 @end deftypefn
14970 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14971 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14972 feature @var{feature} and returns @code{0} otherwise. The following features can be
14973 detected:
14975 @table @samp
14976 @item 4xxmac
14977 4xx CPU has a Multiply Accumulator.
14978 @item altivec
14979 CPU has a SIMD/Vector Unit.
14980 @item arch_2_05
14981 CPU supports ISA 2.05 (eg, POWER6)
14982 @item arch_2_06
14983 CPU supports ISA 2.06 (eg, POWER7)
14984 @item arch_2_07
14985 CPU supports ISA 2.07 (eg, POWER8)
14986 @item arch_3_00
14987 CPU supports ISA 3.0 (eg, POWER9)
14988 @item archpmu
14989 CPU supports the set of compatible performance monitoring events.
14990 @item booke
14991 CPU supports the Embedded ISA category.
14992 @item cellbe
14993 CPU has a CELL broadband engine.
14994 @item dfp
14995 CPU has a decimal floating point unit.
14996 @item dscr
14997 CPU supports the data stream control register.
14998 @item ebb
14999 CPU supports event base branching.
15000 @item efpdouble
15001 CPU has a SPE double precision floating point unit.
15002 @item efpsingle
15003 CPU has a SPE single precision floating point unit.
15004 @item fpu
15005 CPU has a floating point unit.
15006 @item htm
15007 CPU has hardware transaction memory instructions.
15008 @item htm-nosc
15009 Kernel aborts hardware transactions when a syscall is made.
15010 @item ic_snoop
15011 CPU supports icache snooping capabilities.
15012 @item ieee128
15013 CPU supports 128-bit IEEE binary floating point instructions.
15014 @item isel
15015 CPU supports the integer select instruction.
15016 @item mmu
15017 CPU has a memory management unit.
15018 @item notb
15019 CPU does not have a timebase (eg, 601 and 403gx).
15020 @item pa6t
15021 CPU supports the PA Semi 6T CORE ISA.
15022 @item power4
15023 CPU supports ISA 2.00 (eg, POWER4)
15024 @item power5
15025 CPU supports ISA 2.02 (eg, POWER5)
15026 @item power5+
15027 CPU supports ISA 2.03 (eg, POWER5+)
15028 @item power6x
15029 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15030 @item ppc32
15031 CPU supports 32-bit mode execution.
15032 @item ppc601
15033 CPU supports the old POWER ISA (eg, 601)
15034 @item ppc64
15035 CPU supports 64-bit mode execution.
15036 @item ppcle
15037 CPU supports a little-endian mode that uses address swizzling.
15038 @item smt
15039 CPU support simultaneous multi-threading.
15040 @item spe
15041 CPU has a signal processing extension unit.
15042 @item tar
15043 CPU supports the target address register.
15044 @item true_le
15045 CPU supports true little-endian mode.
15046 @item ucache
15047 CPU has unified I/D cache.
15048 @item vcrypto
15049 CPU supports the vector cryptography instructions.
15050 @item vsx
15051 CPU supports the vector-scalar extension.
15052 @end table
15054 Here is an example:
15055 @smallexample
15056 if (__builtin_cpu_supports ("fpu"))
15057   @{
15058      asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15059   @}
15060 else
15061   @{
15062      dst = __fadd (src1, src2); // Software FP addition function.
15063   @}
15064 @end smallexample
15065 @end deftypefn
15067 These built-in functions are available for the PowerPC family of
15068 processors:
15069 @smallexample
15070 float __builtin_recipdivf (float, float);
15071 float __builtin_rsqrtf (float);
15072 double __builtin_recipdiv (double, double);
15073 double __builtin_rsqrt (double);
15074 uint64_t __builtin_ppc_get_timebase ();
15075 unsigned long __builtin_ppc_mftb ();
15076 double __builtin_unpack_longdouble (long double, int);
15077 long double __builtin_pack_longdouble (double, double);
15078 @end smallexample
15080 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15081 @code{__builtin_rsqrtf} functions generate multiple instructions to
15082 implement the reciprocal sqrt functionality using reciprocal sqrt
15083 estimate instructions.
15085 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15086 functions generate multiple instructions to implement division using
15087 the reciprocal estimate instructions.
15089 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15090 functions generate instructions to read the Time Base Register.  The
15091 @code{__builtin_ppc_get_timebase} function may generate multiple
15092 instructions and always returns the 64 bits of the Time Base Register.
15093 The @code{__builtin_ppc_mftb} function always generates one instruction and
15094 returns the Time Base Register value as an unsigned long, throwing away
15095 the most significant word on 32-bit environments.
15097 Additional built-in functions are available for the 64-bit PowerPC
15098 family of processors, for efficient use of 128-bit floating point
15099 (@code{__float128}) values.
15101 The following floating-point built-in functions are available with
15102 @code{-mfloat128} and Altivec support.  All of them implement the
15103 function that is part of the name.
15105 @smallexample
15106 __float128 __builtin_fabsq (__float128)
15107 __float128 __builtin_copysignq (__float128, __float128)
15108 @end smallexample
15110 The following built-in functions are available with @code{-mfloat128}
15111 and Altivec support.
15113 @table @code
15114 @item __float128 __builtin_infq (void)
15115 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15116 @findex __builtin_infq
15118 @item __float128 __builtin_huge_valq (void)
15119 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15120 @findex __builtin_huge_valq
15122 @item __float128 __builtin_nanq (void)
15123 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
15124 @findex __builtin_nanq
15126 @item __float128 __builtin_nansq (void)
15127 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
15128 @findex __builtin_nansq
15129 @end table
15131 The following built-in functions are available for the PowerPC family
15132 of processors, starting with ISA 2.05 or later (@option{-mcpu=power6}
15133 or @option{-mcmpb}):
15134 @smallexample
15135 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15136 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15137 @end smallexample
15139 The @code{__builtin_cmpb} function
15140 performs a byte-wise compare on the contents of its two arguments,
15141 returning the result of the byte-wise comparison as the returned
15142 value.  For each byte comparison, the corresponding byte of the return
15143 value holds 0xff if the input bytes are equal and 0 if the input bytes
15144 are not equal.  If either of the arguments to this built-in function
15145 is wider than 32 bits, the function call expands into the form that
15146 expects @code{unsigned long long int} arguments
15147 which is only available on 64-bit targets.
15149 The following built-in functions are available for the PowerPC family
15150 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15151 or @option{-mpopcntd}):
15152 @smallexample
15153 long __builtin_bpermd (long, long);
15154 int __builtin_divwe (int, int);
15155 int __builtin_divweo (int, int);
15156 unsigned int __builtin_divweu (unsigned int, unsigned int);
15157 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15158 long __builtin_divde (long, long);
15159 long __builtin_divdeo (long, long);
15160 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15161 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15162 unsigned int cdtbcd (unsigned int);
15163 unsigned int cbcdtd (unsigned int);
15164 unsigned int addg6s (unsigned int, unsigned int);
15165 @end smallexample
15167 The @code{__builtin_divde}, @code{__builtin_divdeo},
15168 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15169 64-bit environment support ISA 2.06 or later.
15171 The following built-in functions are available for the PowerPC family
15172 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15173 @smallexample
15174 long long __builtin_darn (void);
15175 long long __builtin_darn_raw (void);
15176 int __builtin_darn_32 (void);
15178 unsigned int scalar_extract_exp (double source);
15179 unsigned long long int scalar_extract_sig (double source);
15181 double
15182 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15183 double
15184 scalar_insert_exp (double significand, unsigned long long int exponent);
15186 int scalar_cmp_exp_gt (double arg1, double arg2);
15187 int scalar_cmp_exp_lt (double arg1, double arg2);
15188 int scalar_cmp_exp_eq (double arg1, double arg2);
15189 int scalar_cmp_exp_unordered (double arg1, double arg2);
15191 bool scalar_test_data_class (float source, const int condition);
15192 bool scalar_test_data_class (double source, const int condition);
15194 bool scalar_test_neg (float source);
15195 bool scalar_test_neg (double source);
15197 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15198 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15199 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15201 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15202 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15203 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15204 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15206 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15207 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15208 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15209 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15211 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15212 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15213 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15214 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15216 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15217 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15218 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15219 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15220 @end smallexample
15222 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15223 functions require a
15224 64-bit environment supporting ISA 3.0 or later.
15225 The @code{__builtin_darn} function provides a 64-bit conditioned
15226 random number.  The @code{__builtin_darn_raw} function provides a
15227 64-bit raw random number.  The @code{__builtin_darn_32} function
15228 provides a 32-bit random number.
15230 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
15231 functions require a 64-bit environment supporting ISA 3.0 or later.
15232 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
15233 functions return the significand and the biased exponent value
15234 respectively of their @code{source} arguments.
15235 Within the result returned by @code{scalar_extract_sig},
15236 the @code{0x10000000000000} bit is set if the
15237 function's @code{source} argument is in normalized form.
15238 Otherwise, this bit is set to 0.
15239 Note that the sign of the significand is not represented in the result
15240 returned from the @code{scalar_extract_sig} function.  Use the
15241 @code{scalar_test_neg} function to test the sign of its @code{double}
15242 argument.
15244 The @code{scalar_insert_exp} 
15245 function requires a 64-bit environment supporting ISA 3.0 or later.
15246 The @code{scalar_insert_exp} built-in function returns a double-precision
15247 floating point value that is constructed by assembling the values of its
15248 @code{significand} and @code{exponent} arguments.  The sign of the
15249 result is copied from the most significant bit of the
15250 @code{significand} argument.  The significand and exponent components
15251 of the result are composed of the least significant 11 bits of the
15252 @code{exponent} argument and the least significant 52 bits of the
15253 @code{significand} argument.
15255 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15256 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15257 functions return a non-zero value if @code{arg1} is greater than, less
15258 than, equal to, or not comparable to @code{arg2} respectively.  The
15259 arguments are not comparable if one or the other equals NaN (not a
15260 number). 
15262 The @code{scalar_test_data_class} built-in function returns 1
15263 if any of the condition tests enabled by the value of the
15264 @code{condition} variable are true, and 0 otherwise.  The
15265 @code{condition} argument must be a compile-time constant integer with
15266 value not exceeding 127.  The
15267 @code{condition} argument is encoded as a bitmask with each bit
15268 enabling the testing of a different condition, as characterized by the
15269 following:
15270 @smallexample
15271 0x40    Test for NaN
15272 0x20    Test for +Infinity
15273 0x10    Test for -Infinity
15274 0x08    Test for +Zero
15275 0x04    Test for -Zero
15276 0x02    Test for +Denormal
15277 0x01    Test for -Denormal
15278 @end smallexample
15280 The @code{scalar_test_neg} built-in function returns 1 if its
15281 @code{source} argument holds a negative value, 0 otherwise.
15283 The @code{__builtin_byte_in_set} function requires a
15284 64-bit environment supporting ISA 3.0 or later.  This function returns
15285 a non-zero value if and only if its @code{u} argument exactly equals one of
15286 the eight bytes contained within its 64-bit @code{set} argument.
15288 The @code{__builtin_byte_in_range} and
15289 @code{__builtin_byte_in_either_range} require an environment
15290 supporting ISA 3.0 or later.  For these two functions, the
15291 @code{range} argument is encoded as 4 bytes, organized as
15292 @code{hi_1:lo_1:hi_2:lo_2}.
15293 The @code{__builtin_byte_in_range} function returns a
15294 non-zero value if and only if its @code{u} argument is within the
15295 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15296 The @code{__builtin_byte_in_either_range} function returns non-zero if
15297 and only if its @code{u} argument is within either the range bounded
15298 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15299 between @code{lo_2} and @code{hi_2} inclusive.
15301 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15302 if and only if the number of signficant digits of its @code{value} argument
15303 is less than its @code{comparison} argument.  The
15304 @code{__builtin_dfp_dtstsfi_lt_dd} and
15305 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15306 require that the type of the @code{value} argument be
15307 @code{__Decimal64} and @code{__Decimal128} respectively.
15309 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15310 if and only if the number of signficant digits of its @code{value} argument
15311 is greater than its @code{comparison} argument.  The
15312 @code{__builtin_dfp_dtstsfi_gt_dd} and
15313 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15314 require that the type of the @code{value} argument be
15315 @code{__Decimal64} and @code{__Decimal128} respectively.
15317 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15318 if and only if the number of signficant digits of its @code{value} argument
15319 equals its @code{comparison} argument.  The
15320 @code{__builtin_dfp_dtstsfi_eq_dd} and
15321 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15322 require that the type of the @code{value} argument be
15323 @code{__Decimal64} and @code{__Decimal128} respectively.
15325 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15326 if and only if its @code{value} argument has an undefined number of
15327 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15328 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15329 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15330 require that the type of the @code{value} argument be
15331 @code{__Decimal64} and @code{__Decimal128} respectively.
15333 The following built-in functions are also available for the PowerPC family
15334 of processors, starting with ISA 3.0 or later
15335 (@option{-mcpu=power9}).  These string functions are described
15336 separately in order to group the descriptions closer to the function
15337 prototypes:
15338 @smallexample
15339 int vec_all_nez (vector signed char, vector signed char);
15340 int vec_all_nez (vector unsigned char, vector unsigned char);
15341 int vec_all_nez (vector signed short, vector signed short);
15342 int vec_all_nez (vector unsigned short, vector unsigned short);
15343 int vec_all_nez (vector signed int, vector signed int);
15344 int vec_all_nez (vector unsigned int, vector unsigned int);
15346 int vec_any_eqz (vector signed char, vector signed char);
15347 int vec_any_eqz (vector unsigned char, vector unsigned char);
15348 int vec_any_eqz (vector signed short, vector signed short);
15349 int vec_any_eqz (vector unsigned short, vector unsigned short);
15350 int vec_any_eqz (vector signed int, vector signed int);
15351 int vec_any_eqz (vector unsigned int, vector unsigned int);
15353 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15354 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15355 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15356 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15357 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15358 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15360 signed int vec_cntlz_lsbb (vector signed char);
15361 signed int vec_cntlz_lsbb (vector unsigned char);
15363 signed int vec_cnttz_lsbb (vector signed char);
15364 signed int vec_cnttz_lsbb (vector unsigned char);
15366 vector signed char vec_xl_len (signed char *addr, size_t len);
15367 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
15368 vector signed int vec_xl_len (signed int *addr, size_t len);
15369 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
15370 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
15371 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
15372 vector signed long long vec_xl_len (signed long long *addr, size_t len);
15373 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
15374 vector signed short vec_xl_len (signed short *addr, size_t len);
15375 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
15376 vector double vec_xl_len (double *addr, size_t len);
15377 vector float vec_xl_len (float *addr, size_t len);
15379 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
15380 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
15381 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
15382 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
15383 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
15384 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
15385 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
15386 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
15387 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
15388 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
15389 void vec_xst_len (vector double data, double *addr, size_t len);
15390 void vec_xst_len (vector float data, float *addr, size_t len);
15392 signed char vec_xlx (unsigned int index, vector signed char data);
15393 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
15394 signed short vec_xlx (unsigned int index, vector signed short data);
15395 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
15396 signed int vec_xlx (unsigned int index, vector signed int data);
15397 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
15398 float vec_xlx (unsigned int index, vector float data);
15400 signed char vec_xrx (unsigned int index, vector signed char data);
15401 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
15402 signed short vec_xrx (unsigned int index, vector signed short data);
15403 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
15404 signed int vec_xrx (unsigned int index, vector signed int data);
15405 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
15406 float vec_xrx (unsigned int index, vector float data);
15407 @end smallexample
15409 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
15410 perform pairwise comparisons between the elements at the same
15411 positions within their two vector arguments.
15412 The @code{vec_all_nez} function returns a
15413 non-zero value if and only if all pairwise comparisons are not
15414 equal and no element of either vector argument contains a zero.
15415 The @code{vec_any_eqz} function returns a
15416 non-zero value if and only if at least one pairwise comparison is equal
15417 or if at least one element of either vector argument contains a zero.
15418 The @code{vec_cmpnez} function returns a vector of the same type as
15419 its two arguments, within which each element consists of all ones to
15420 denote that either the corresponding elements of the incoming arguments are
15421 not equal or that at least one of the corresponding elements contains
15422 zero.  Otherwise, the element of the returned vector contains all zeros.
15424 The @code{vec_cntlz_lsbb} function returns the count of the number of
15425 consecutive leading byte elements (starting from position 0 within the
15426 supplied vector argument) for which the least-significant bit
15427 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
15428 the number of consecutive trailing byte elements (starting from
15429 position 15 and counting backwards within the supplied vector
15430 argument) for which the least-significant bit equals zero.
15432 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
15433 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
15434 function loads a variable length vector from memory.  The
15435 @code{vec_xst_len} function stores a variable length vector to memory.
15436 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
15437 @code{addr} argument represents the memory address to or from which
15438 data will be transferred, and the
15439 @code{len} argument represents the number of bytes to be
15440 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
15441 If this expression's value is not a multiple of the vector element's
15442 size, the behavior of this function is undefined.
15443 In the case that the underlying computer is configured to run in
15444 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
15445 the corresponding vector.  In little-endian mode, the data transfer
15446 moves bytes @code{(16 - len)} to @code{15} of the corresponding
15447 vector.  For the load function, any bytes of the result vector that
15448 are not loaded from memory are set to zero.
15449 The value of the @code{addr} argument need not be aligned on a
15450 multiple of the vector's element size.
15452 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
15453 element selected by the @code{index} argument from the vector
15454 represented by the @code{data} argument.  The @code{index} argument
15455 always specifies a byte offset, regardless of the size of the vector
15456 element.  With @code{vec_xlx}, @code{index} is the offset of the first
15457 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
15458 represents the last byte of the element to be extracted, measured
15459 from the right end of the vector.  In other words, the last byte of
15460 the element to be extracted is found at position @code{(15 - index)}.
15461 There is no requirement that @code{index} be a multiple of the vector
15462 element size.  However, if the size of the vector element added to
15463 @code{index} is greater than 15, the content of the returned value is
15464 undefined.
15466 The following built-in functions are available for the PowerPC family
15467 of processors when hardware decimal floating point
15468 (@option{-mhard-dfp}) is available:
15469 @smallexample
15470 long long __builtin_dxex (_Decimal64);
15471 long long __builtin_dxexq (_Decimal128);
15472 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15473 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15474 _Decimal64 __builtin_denbcd (int, _Decimal64);
15475 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15476 _Decimal64 __builtin_diex (long long, _Decimal64);
15477 _Decimal128 _builtin_diexq (long long, _Decimal128);
15478 _Decimal64 __builtin_dscli (_Decimal64, int);
15479 _Decimal128 __builtin_dscliq (_Decimal128, int);
15480 _Decimal64 __builtin_dscri (_Decimal64, int);
15481 _Decimal128 __builtin_dscriq (_Decimal128, int);
15482 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15483 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15484 @end smallexample
15486 The following built-in functions are available for the PowerPC family
15487 of processors when the Vector Scalar (vsx) instruction set is
15488 available:
15489 @smallexample
15490 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15491 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15492                                                 unsigned long long);
15493 @end smallexample
15495 @node PowerPC AltiVec/VSX Built-in Functions
15496 @subsection PowerPC AltiVec Built-in Functions
15498 GCC provides an interface for the PowerPC family of processors to access
15499 the AltiVec operations described in Motorola's AltiVec Programming
15500 Interface Manual.  The interface is made available by including
15501 @code{<altivec.h>} and using @option{-maltivec} and
15502 @option{-mabi=altivec}.  The interface supports the following vector
15503 types.
15505 @smallexample
15506 vector unsigned char
15507 vector signed char
15508 vector bool char
15510 vector unsigned short
15511 vector signed short
15512 vector bool short
15513 vector pixel
15515 vector unsigned int
15516 vector signed int
15517 vector bool int
15518 vector float
15519 @end smallexample
15521 If @option{-mvsx} is used the following additional vector types are
15522 implemented.
15524 @smallexample
15525 vector unsigned long
15526 vector signed long
15527 vector double
15528 @end smallexample
15530 The long types are only implemented for 64-bit code generation, and
15531 the long type is only used in the floating point/integer conversion
15532 instructions.
15534 GCC's implementation of the high-level language interface available from
15535 C and C++ code differs from Motorola's documentation in several ways.
15537 @itemize @bullet
15539 @item
15540 A vector constant is a list of constant expressions within curly braces.
15542 @item
15543 A vector initializer requires no cast if the vector constant is of the
15544 same type as the variable it is initializing.
15546 @item
15547 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15548 vector type is the default signedness of the base type.  The default
15549 varies depending on the operating system, so a portable program should
15550 always specify the signedness.
15552 @item
15553 Compiling with @option{-maltivec} adds keywords @code{__vector},
15554 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15555 @code{bool}.  When compiling ISO C, the context-sensitive substitution
15556 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15557 disabled.  To use them, you must include @code{<altivec.h>} instead.
15559 @item
15560 GCC allows using a @code{typedef} name as the type specifier for a
15561 vector type.
15563 @item
15564 For C, overloaded functions are implemented with macros so the following
15565 does not work:
15567 @smallexample
15568   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15569 @end smallexample
15571 @noindent
15572 Since @code{vec_add} is a macro, the vector constant in the example
15573 is treated as four separate arguments.  Wrap the entire argument in
15574 parentheses for this to work.
15575 @end itemize
15577 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15578 Internally, GCC uses built-in functions to achieve the functionality in
15579 the aforementioned header file, but they are not supported and are
15580 subject to change without notice.
15582 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
15583 which may be found at
15584 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
15585 Appendix A of this document lists the vector API interfaces that must be
15586 provided by compliant compilers.  Programmers should preferentially use
15587 the interfaces described therein.  However, historically GCC has provided
15588 additional interfaces for access to vector instructions.  These are
15589 briefly described below.
15591 The following interfaces are supported for the generic and specific
15592 AltiVec operations and the AltiVec predicates.  In cases where there
15593 is a direct mapping between generic and specific operations, only the
15594 generic names are shown here, although the specific operations can also
15595 be used.
15597 Arguments that are documented as @code{const int} require literal
15598 integral values within the range required for that operation.
15600 @smallexample
15601 vector signed char vec_abs (vector signed char);
15602 vector signed short vec_abs (vector signed short);
15603 vector signed int vec_abs (vector signed int);
15604 vector float vec_abs (vector float);
15606 vector signed char vec_abss (vector signed char);
15607 vector signed short vec_abss (vector signed short);
15608 vector signed int vec_abss (vector signed int);
15610 vector signed char vec_add (vector bool char, vector signed char);
15611 vector signed char vec_add (vector signed char, vector bool char);
15612 vector signed char vec_add (vector signed char, vector signed char);
15613 vector unsigned char vec_add (vector bool char, vector unsigned char);
15614 vector unsigned char vec_add (vector unsigned char, vector bool char);
15615 vector unsigned char vec_add (vector unsigned char,
15616                               vector unsigned char);
15617 vector signed short vec_add (vector bool short, vector signed short);
15618 vector signed short vec_add (vector signed short, vector bool short);
15619 vector signed short vec_add (vector signed short, vector signed short);
15620 vector unsigned short vec_add (vector bool short,
15621                                vector unsigned short);
15622 vector unsigned short vec_add (vector unsigned short,
15623                                vector bool short);
15624 vector unsigned short vec_add (vector unsigned short,
15625                                vector unsigned short);
15626 vector signed int vec_add (vector bool int, vector signed int);
15627 vector signed int vec_add (vector signed int, vector bool int);
15628 vector signed int vec_add (vector signed int, vector signed int);
15629 vector unsigned int vec_add (vector bool int, vector unsigned int);
15630 vector unsigned int vec_add (vector unsigned int, vector bool int);
15631 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15632 vector float vec_add (vector float, vector float);
15634 vector float vec_vaddfp (vector float, vector float);
15636 vector signed int vec_vadduwm (vector bool int, vector signed int);
15637 vector signed int vec_vadduwm (vector signed int, vector bool int);
15638 vector signed int vec_vadduwm (vector signed int, vector signed int);
15639 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15640 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15641 vector unsigned int vec_vadduwm (vector unsigned int,
15642                                  vector unsigned int);
15644 vector signed short vec_vadduhm (vector bool short,
15645                                  vector signed short);
15646 vector signed short vec_vadduhm (vector signed short,
15647                                  vector bool short);
15648 vector signed short vec_vadduhm (vector signed short,
15649                                  vector signed short);
15650 vector unsigned short vec_vadduhm (vector bool short,
15651                                    vector unsigned short);
15652 vector unsigned short vec_vadduhm (vector unsigned short,
15653                                    vector bool short);
15654 vector unsigned short vec_vadduhm (vector unsigned short,
15655                                    vector unsigned short);
15657 vector signed char vec_vaddubm (vector bool char, vector signed char);
15658 vector signed char vec_vaddubm (vector signed char, vector bool char);
15659 vector signed char vec_vaddubm (vector signed char, vector signed char);
15660 vector unsigned char vec_vaddubm (vector bool char,
15661                                   vector unsigned char);
15662 vector unsigned char vec_vaddubm (vector unsigned char,
15663                                   vector bool char);
15664 vector unsigned char vec_vaddubm (vector unsigned char,
15665                                   vector unsigned char);
15667 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15669 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15670 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15671 vector unsigned char vec_adds (vector unsigned char,
15672                                vector unsigned char);
15673 vector signed char vec_adds (vector bool char, vector signed char);
15674 vector signed char vec_adds (vector signed char, vector bool char);
15675 vector signed char vec_adds (vector signed char, vector signed char);
15676 vector unsigned short vec_adds (vector bool short,
15677                                 vector unsigned short);
15678 vector unsigned short vec_adds (vector unsigned short,
15679                                 vector bool short);
15680 vector unsigned short vec_adds (vector unsigned short,
15681                                 vector unsigned short);
15682 vector signed short vec_adds (vector bool short, vector signed short);
15683 vector signed short vec_adds (vector signed short, vector bool short);
15684 vector signed short vec_adds (vector signed short, vector signed short);
15685 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15686 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15687 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15688 vector signed int vec_adds (vector bool int, vector signed int);
15689 vector signed int vec_adds (vector signed int, vector bool int);
15690 vector signed int vec_adds (vector signed int, vector signed int);
15692 vector signed int vec_vaddsws (vector bool int, vector signed int);
15693 vector signed int vec_vaddsws (vector signed int, vector bool int);
15694 vector signed int vec_vaddsws (vector signed int, vector signed int);
15696 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15697 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15698 vector unsigned int vec_vadduws (vector unsigned int,
15699                                  vector unsigned int);
15701 vector signed short vec_vaddshs (vector bool short,
15702                                  vector signed short);
15703 vector signed short vec_vaddshs (vector signed short,
15704                                  vector bool short);
15705 vector signed short vec_vaddshs (vector signed short,
15706                                  vector signed short);
15708 vector unsigned short vec_vadduhs (vector bool short,
15709                                    vector unsigned short);
15710 vector unsigned short vec_vadduhs (vector unsigned short,
15711                                    vector bool short);
15712 vector unsigned short vec_vadduhs (vector unsigned short,
15713                                    vector unsigned short);
15715 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15716 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15717 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15719 vector unsigned char vec_vaddubs (vector bool char,
15720                                   vector unsigned char);
15721 vector unsigned char vec_vaddubs (vector unsigned char,
15722                                   vector bool char);
15723 vector unsigned char vec_vaddubs (vector unsigned char,
15724                                   vector unsigned char);
15726 vector float vec_and (vector float, vector float);
15727 vector float vec_and (vector float, vector bool int);
15728 vector float vec_and (vector bool int, vector float);
15729 vector bool int vec_and (vector bool int, vector bool int);
15730 vector signed int vec_and (vector bool int, vector signed int);
15731 vector signed int vec_and (vector signed int, vector bool int);
15732 vector signed int vec_and (vector signed int, vector signed int);
15733 vector unsigned int vec_and (vector bool int, vector unsigned int);
15734 vector unsigned int vec_and (vector unsigned int, vector bool int);
15735 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15736 vector bool short vec_and (vector bool short, vector bool short);
15737 vector signed short vec_and (vector bool short, vector signed short);
15738 vector signed short vec_and (vector signed short, vector bool short);
15739 vector signed short vec_and (vector signed short, vector signed short);
15740 vector unsigned short vec_and (vector bool short,
15741                                vector unsigned short);
15742 vector unsigned short vec_and (vector unsigned short,
15743                                vector bool short);
15744 vector unsigned short vec_and (vector unsigned short,
15745                                vector unsigned short);
15746 vector signed char vec_and (vector bool char, vector signed char);
15747 vector bool char vec_and (vector bool char, vector bool char);
15748 vector signed char vec_and (vector signed char, vector bool char);
15749 vector signed char vec_and (vector signed char, vector signed char);
15750 vector unsigned char vec_and (vector bool char, vector unsigned char);
15751 vector unsigned char vec_and (vector unsigned char, vector bool char);
15752 vector unsigned char vec_and (vector unsigned char,
15753                               vector unsigned char);
15755 vector float vec_andc (vector float, vector float);
15756 vector float vec_andc (vector float, vector bool int);
15757 vector float vec_andc (vector bool int, vector float);
15758 vector bool int vec_andc (vector bool int, vector bool int);
15759 vector signed int vec_andc (vector bool int, vector signed int);
15760 vector signed int vec_andc (vector signed int, vector bool int);
15761 vector signed int vec_andc (vector signed int, vector signed int);
15762 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15763 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15764 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15765 vector bool short vec_andc (vector bool short, vector bool short);
15766 vector signed short vec_andc (vector bool short, vector signed short);
15767 vector signed short vec_andc (vector signed short, vector bool short);
15768 vector signed short vec_andc (vector signed short, vector signed short);
15769 vector unsigned short vec_andc (vector bool short,
15770                                 vector unsigned short);
15771 vector unsigned short vec_andc (vector unsigned short,
15772                                 vector bool short);
15773 vector unsigned short vec_andc (vector unsigned short,
15774                                 vector unsigned short);
15775 vector signed char vec_andc (vector bool char, vector signed char);
15776 vector bool char vec_andc (vector bool char, vector bool char);
15777 vector signed char vec_andc (vector signed char, vector bool char);
15778 vector signed char vec_andc (vector signed char, vector signed char);
15779 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15780 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15781 vector unsigned char vec_andc (vector unsigned char,
15782                                vector unsigned char);
15784 vector unsigned char vec_avg (vector unsigned char,
15785                               vector unsigned char);
15786 vector signed char vec_avg (vector signed char, vector signed char);
15787 vector unsigned short vec_avg (vector unsigned short,
15788                                vector unsigned short);
15789 vector signed short vec_avg (vector signed short, vector signed short);
15790 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15791 vector signed int vec_avg (vector signed int, vector signed int);
15793 vector signed int vec_vavgsw (vector signed int, vector signed int);
15795 vector unsigned int vec_vavguw (vector unsigned int,
15796                                 vector unsigned int);
15798 vector signed short vec_vavgsh (vector signed short,
15799                                 vector signed short);
15801 vector unsigned short vec_vavguh (vector unsigned short,
15802                                   vector unsigned short);
15804 vector signed char vec_vavgsb (vector signed char, vector signed char);
15806 vector unsigned char vec_vavgub (vector unsigned char,
15807                                  vector unsigned char);
15809 vector float vec_copysign (vector float);
15811 vector float vec_ceil (vector float);
15813 vector signed int vec_cmpb (vector float, vector float);
15815 vector bool char vec_cmpeq (vector bool char, vector bool char);
15816 vector bool short vec_cmpeq (vector bool short, vector bool short);
15817 vector bool int vec_cmpeq (vector bool int, vector bool int);
15818 vector bool char vec_cmpeq (vector signed char, vector signed char);
15819 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15820 vector bool short vec_cmpeq (vector signed short, vector signed short);
15821 vector bool short vec_cmpeq (vector unsigned short,
15822                              vector unsigned short);
15823 vector bool int vec_cmpeq (vector signed int, vector signed int);
15824 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15825 vector bool int vec_cmpeq (vector float, vector float);
15827 vector bool int vec_vcmpeqfp (vector float, vector float);
15829 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15830 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15832 vector bool short vec_vcmpequh (vector signed short,
15833                                 vector signed short);
15834 vector bool short vec_vcmpequh (vector unsigned short,
15835                                 vector unsigned short);
15837 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15838 vector bool char vec_vcmpequb (vector unsigned char,
15839                                vector unsigned char);
15841 vector bool int vec_cmpge (vector float, vector float);
15843 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15844 vector bool char vec_cmpgt (vector signed char, vector signed char);
15845 vector bool short vec_cmpgt (vector unsigned short,
15846                              vector unsigned short);
15847 vector bool short vec_cmpgt (vector signed short, vector signed short);
15848 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15849 vector bool int vec_cmpgt (vector signed int, vector signed int);
15850 vector bool int vec_cmpgt (vector float, vector float);
15852 vector bool int vec_vcmpgtfp (vector float, vector float);
15854 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15856 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15858 vector bool short vec_vcmpgtsh (vector signed short,
15859                                 vector signed short);
15861 vector bool short vec_vcmpgtuh (vector unsigned short,
15862                                 vector unsigned short);
15864 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15866 vector bool char vec_vcmpgtub (vector unsigned char,
15867                                vector unsigned char);
15869 vector bool int vec_cmple (vector float, vector float);
15871 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15872 vector bool char vec_cmplt (vector signed char, vector signed char);
15873 vector bool short vec_cmplt (vector unsigned short,
15874                              vector unsigned short);
15875 vector bool short vec_cmplt (vector signed short, vector signed short);
15876 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15877 vector bool int vec_cmplt (vector signed int, vector signed int);
15878 vector bool int vec_cmplt (vector float, vector float);
15880 vector float vec_cpsgn (vector float, vector float);
15882 vector float vec_ctf (vector unsigned int, const int);
15883 vector float vec_ctf (vector signed int, const int);
15884 vector double vec_ctf (vector unsigned long, const int);
15885 vector double vec_ctf (vector signed long, const int);
15887 vector float vec_vcfsx (vector signed int, const int);
15889 vector float vec_vcfux (vector unsigned int, const int);
15891 vector signed int vec_cts (vector float, const int);
15892 vector signed long vec_cts (vector double, const int);
15894 vector unsigned int vec_ctu (vector float, const int);
15895 vector unsigned long vec_ctu (vector double, const int);
15897 vector double vec_doublee (vector float);
15898 vector double vec_doublee (vector signed int);
15899 vector double vec_doublee (vector unsigned int);
15901 vector double vec_doubleo (vector float);
15902 vector double vec_doubleo (vector signed int);
15903 vector double vec_doubleo (vector unsigned int);
15905 vector double vec_doubleh (vector float);
15906 vector double vec_doubleh (vector signed int);
15907 vector double vec_doubleh (vector unsigned int);
15909 vector double vec_doublel (vector float);
15910 vector double vec_doublel (vector signed int);
15911 vector double vec_doublel (vector unsigned int);
15913 void vec_dss (const int);
15915 void vec_dssall (void);
15917 void vec_dst (const vector unsigned char *, int, const int);
15918 void vec_dst (const vector signed char *, int, const int);
15919 void vec_dst (const vector bool char *, int, const int);
15920 void vec_dst (const vector unsigned short *, int, const int);
15921 void vec_dst (const vector signed short *, int, const int);
15922 void vec_dst (const vector bool short *, int, const int);
15923 void vec_dst (const vector pixel *, int, const int);
15924 void vec_dst (const vector unsigned int *, int, const int);
15925 void vec_dst (const vector signed int *, int, const int);
15926 void vec_dst (const vector bool int *, int, const int);
15927 void vec_dst (const vector float *, int, const int);
15928 void vec_dst (const unsigned char *, int, const int);
15929 void vec_dst (const signed char *, int, const int);
15930 void vec_dst (const unsigned short *, int, const int);
15931 void vec_dst (const short *, int, const int);
15932 void vec_dst (const unsigned int *, int, const int);
15933 void vec_dst (const int *, int, const int);
15934 void vec_dst (const unsigned long *, int, const int);
15935 void vec_dst (const long *, int, const int);
15936 void vec_dst (const float *, int, const int);
15938 void vec_dstst (const vector unsigned char *, int, const int);
15939 void vec_dstst (const vector signed char *, int, const int);
15940 void vec_dstst (const vector bool char *, int, const int);
15941 void vec_dstst (const vector unsigned short *, int, const int);
15942 void vec_dstst (const vector signed short *, int, const int);
15943 void vec_dstst (const vector bool short *, int, const int);
15944 void vec_dstst (const vector pixel *, int, const int);
15945 void vec_dstst (const vector unsigned int *, int, const int);
15946 void vec_dstst (const vector signed int *, int, const int);
15947 void vec_dstst (const vector bool int *, int, const int);
15948 void vec_dstst (const vector float *, int, const int);
15949 void vec_dstst (const unsigned char *, int, const int);
15950 void vec_dstst (const signed char *, int, const int);
15951 void vec_dstst (const unsigned short *, int, const int);
15952 void vec_dstst (const short *, int, const int);
15953 void vec_dstst (const unsigned int *, int, const int);
15954 void vec_dstst (const int *, int, const int);
15955 void vec_dstst (const unsigned long *, int, const int);
15956 void vec_dstst (const long *, int, const int);
15957 void vec_dstst (const float *, int, const int);
15959 void vec_dststt (const vector unsigned char *, int, const int);
15960 void vec_dststt (const vector signed char *, int, const int);
15961 void vec_dststt (const vector bool char *, int, const int);
15962 void vec_dststt (const vector unsigned short *, int, const int);
15963 void vec_dststt (const vector signed short *, int, const int);
15964 void vec_dststt (const vector bool short *, int, const int);
15965 void vec_dststt (const vector pixel *, int, const int);
15966 void vec_dststt (const vector unsigned int *, int, const int);
15967 void vec_dststt (const vector signed int *, int, const int);
15968 void vec_dststt (const vector bool int *, int, const int);
15969 void vec_dststt (const vector float *, int, const int);
15970 void vec_dststt (const unsigned char *, int, const int);
15971 void vec_dststt (const signed char *, int, const int);
15972 void vec_dststt (const unsigned short *, int, const int);
15973 void vec_dststt (const short *, int, const int);
15974 void vec_dststt (const unsigned int *, int, const int);
15975 void vec_dststt (const int *, int, const int);
15976 void vec_dststt (const unsigned long *, int, const int);
15977 void vec_dststt (const long *, int, const int);
15978 void vec_dststt (const float *, int, const int);
15980 void vec_dstt (const vector unsigned char *, int, const int);
15981 void vec_dstt (const vector signed char *, int, const int);
15982 void vec_dstt (const vector bool char *, int, const int);
15983 void vec_dstt (const vector unsigned short *, int, const int);
15984 void vec_dstt (const vector signed short *, int, const int);
15985 void vec_dstt (const vector bool short *, int, const int);
15986 void vec_dstt (const vector pixel *, int, const int);
15987 void vec_dstt (const vector unsigned int *, int, const int);
15988 void vec_dstt (const vector signed int *, int, const int);
15989 void vec_dstt (const vector bool int *, int, const int);
15990 void vec_dstt (const vector float *, int, const int);
15991 void vec_dstt (const unsigned char *, int, const int);
15992 void vec_dstt (const signed char *, int, const int);
15993 void vec_dstt (const unsigned short *, int, const int);
15994 void vec_dstt (const short *, int, const int);
15995 void vec_dstt (const unsigned int *, int, const int);
15996 void vec_dstt (const int *, int, const int);
15997 void vec_dstt (const unsigned long *, int, const int);
15998 void vec_dstt (const long *, int, const int);
15999 void vec_dstt (const float *, int, const int);
16001 vector float vec_expte (vector float);
16003 vector float vec_floor (vector float);
16005 vector float vec_float (vector signed int);
16006 vector float vec_float (vector unsigned int);
16008 vector float vec_float2 (vector signed long long, vector signed long long);
16009 vector float vec_float2 (vector unsigned long long, vector signed long long);
16011 vector float vec_floate (vector double);
16012 vector float vec_floate (vector signed long long);
16013 vector float vec_floate (vector unsigned long long);
16015 vector float vec_floato (vector double);
16016 vector float vec_floato (vector signed long long);
16017 vector float vec_floato (vector unsigned long long);
16019 vector float vec_ld (int, const vector float *);
16020 vector float vec_ld (int, const float *);
16021 vector bool int vec_ld (int, const vector bool int *);
16022 vector signed int vec_ld (int, const vector signed int *);
16023 vector signed int vec_ld (int, const int *);
16024 vector signed int vec_ld (int, const long *);
16025 vector unsigned int vec_ld (int, const vector unsigned int *);
16026 vector unsigned int vec_ld (int, const unsigned int *);
16027 vector unsigned int vec_ld (int, const unsigned long *);
16028 vector bool short vec_ld (int, const vector bool short *);
16029 vector pixel vec_ld (int, const vector pixel *);
16030 vector signed short vec_ld (int, const vector signed short *);
16031 vector signed short vec_ld (int, const short *);
16032 vector unsigned short vec_ld (int, const vector unsigned short *);
16033 vector unsigned short vec_ld (int, const unsigned short *);
16034 vector bool char vec_ld (int, const vector bool char *);
16035 vector signed char vec_ld (int, const vector signed char *);
16036 vector signed char vec_ld (int, const signed char *);
16037 vector unsigned char vec_ld (int, const vector unsigned char *);
16038 vector unsigned char vec_ld (int, const unsigned char *);
16040 vector signed char vec_lde (int, const signed char *);
16041 vector unsigned char vec_lde (int, const unsigned char *);
16042 vector signed short vec_lde (int, const short *);
16043 vector unsigned short vec_lde (int, const unsigned short *);
16044 vector float vec_lde (int, const float *);
16045 vector signed int vec_lde (int, const int *);
16046 vector unsigned int vec_lde (int, const unsigned int *);
16047 vector signed int vec_lde (int, const long *);
16048 vector unsigned int vec_lde (int, const unsigned long *);
16050 vector float vec_lvewx (int, float *);
16051 vector signed int vec_lvewx (int, int *);
16052 vector unsigned int vec_lvewx (int, unsigned int *);
16053 vector signed int vec_lvewx (int, long *);
16054 vector unsigned int vec_lvewx (int, unsigned long *);
16056 vector signed short vec_lvehx (int, short *);
16057 vector unsigned short vec_lvehx (int, unsigned short *);
16059 vector signed char vec_lvebx (int, char *);
16060 vector unsigned char vec_lvebx (int, unsigned char *);
16062 vector float vec_ldl (int, const vector float *);
16063 vector float vec_ldl (int, const float *);
16064 vector bool int vec_ldl (int, const vector bool int *);
16065 vector signed int vec_ldl (int, const vector signed int *);
16066 vector signed int vec_ldl (int, const int *);
16067 vector signed int vec_ldl (int, const long *);
16068 vector unsigned int vec_ldl (int, const vector unsigned int *);
16069 vector unsigned int vec_ldl (int, const unsigned int *);
16070 vector unsigned int vec_ldl (int, const unsigned long *);
16071 vector bool short vec_ldl (int, const vector bool short *);
16072 vector pixel vec_ldl (int, const vector pixel *);
16073 vector signed short vec_ldl (int, const vector signed short *);
16074 vector signed short vec_ldl (int, const short *);
16075 vector unsigned short vec_ldl (int, const vector unsigned short *);
16076 vector unsigned short vec_ldl (int, const unsigned short *);
16077 vector bool char vec_ldl (int, const vector bool char *);
16078 vector signed char vec_ldl (int, const vector signed char *);
16079 vector signed char vec_ldl (int, const signed char *);
16080 vector unsigned char vec_ldl (int, const vector unsigned char *);
16081 vector unsigned char vec_ldl (int, const unsigned char *);
16083 vector float vec_loge (vector float);
16085 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16086 vector unsigned char vec_lvsl (int, const volatile signed char *);
16087 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16088 vector unsigned char vec_lvsl (int, const volatile short *);
16089 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16090 vector unsigned char vec_lvsl (int, const volatile int *);
16091 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16092 vector unsigned char vec_lvsl (int, const volatile long *);
16093 vector unsigned char vec_lvsl (int, const volatile float *);
16095 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16096 vector unsigned char vec_lvsr (int, const volatile signed char *);
16097 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16098 vector unsigned char vec_lvsr (int, const volatile short *);
16099 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16100 vector unsigned char vec_lvsr (int, const volatile int *);
16101 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16102 vector unsigned char vec_lvsr (int, const volatile long *);
16103 vector unsigned char vec_lvsr (int, const volatile float *);
16105 vector float vec_madd (vector float, vector float, vector float);
16107 vector signed short vec_madds (vector signed short,
16108                                vector signed short,
16109                                vector signed short);
16111 vector unsigned char vec_max (vector bool char, vector unsigned char);
16112 vector unsigned char vec_max (vector unsigned char, vector bool char);
16113 vector unsigned char vec_max (vector unsigned char,
16114                               vector unsigned char);
16115 vector signed char vec_max (vector bool char, vector signed char);
16116 vector signed char vec_max (vector signed char, vector bool char);
16117 vector signed char vec_max (vector signed char, vector signed char);
16118 vector unsigned short vec_max (vector bool short,
16119                                vector unsigned short);
16120 vector unsigned short vec_max (vector unsigned short,
16121                                vector bool short);
16122 vector unsigned short vec_max (vector unsigned short,
16123                                vector unsigned short);
16124 vector signed short vec_max (vector bool short, vector signed short);
16125 vector signed short vec_max (vector signed short, vector bool short);
16126 vector signed short vec_max (vector signed short, vector signed short);
16127 vector unsigned int vec_max (vector bool int, vector unsigned int);
16128 vector unsigned int vec_max (vector unsigned int, vector bool int);
16129 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16130 vector signed int vec_max (vector bool int, vector signed int);
16131 vector signed int vec_max (vector signed int, vector bool int);
16132 vector signed int vec_max (vector signed int, vector signed int);
16133 vector float vec_max (vector float, vector float);
16135 vector float vec_vmaxfp (vector float, vector float);
16137 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16138 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16139 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16141 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16142 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16143 vector unsigned int vec_vmaxuw (vector unsigned int,
16144                                 vector unsigned int);
16146 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16147 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16148 vector signed short vec_vmaxsh (vector signed short,
16149                                 vector signed short);
16151 vector unsigned short vec_vmaxuh (vector bool short,
16152                                   vector unsigned short);
16153 vector unsigned short vec_vmaxuh (vector unsigned short,
16154                                   vector bool short);
16155 vector unsigned short vec_vmaxuh (vector unsigned short,
16156                                   vector unsigned short);
16158 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16159 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16160 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16162 vector unsigned char vec_vmaxub (vector bool char,
16163                                  vector unsigned char);
16164 vector unsigned char vec_vmaxub (vector unsigned char,
16165                                  vector bool char);
16166 vector unsigned char vec_vmaxub (vector unsigned char,
16167                                  vector unsigned char);
16169 vector bool char vec_mergeh (vector bool char, vector bool char);
16170 vector signed char vec_mergeh (vector signed char, vector signed char);
16171 vector unsigned char vec_mergeh (vector unsigned char,
16172                                  vector unsigned char);
16173 vector bool short vec_mergeh (vector bool short, vector bool short);
16174 vector pixel vec_mergeh (vector pixel, vector pixel);
16175 vector signed short vec_mergeh (vector signed short,
16176                                 vector signed short);
16177 vector unsigned short vec_mergeh (vector unsigned short,
16178                                   vector unsigned short);
16179 vector float vec_mergeh (vector float, vector float);
16180 vector bool int vec_mergeh (vector bool int, vector bool int);
16181 vector signed int vec_mergeh (vector signed int, vector signed int);
16182 vector unsigned int vec_mergeh (vector unsigned int,
16183                                 vector unsigned int);
16185 vector float vec_vmrghw (vector float, vector float);
16186 vector bool int vec_vmrghw (vector bool int, vector bool int);
16187 vector signed int vec_vmrghw (vector signed int, vector signed int);
16188 vector unsigned int vec_vmrghw (vector unsigned int,
16189                                 vector unsigned int);
16191 vector bool short vec_vmrghh (vector bool short, vector bool short);
16192 vector signed short vec_vmrghh (vector signed short,
16193                                 vector signed short);
16194 vector unsigned short vec_vmrghh (vector unsigned short,
16195                                   vector unsigned short);
16196 vector pixel vec_vmrghh (vector pixel, vector pixel);
16198 vector bool char vec_vmrghb (vector bool char, vector bool char);
16199 vector signed char vec_vmrghb (vector signed char, vector signed char);
16200 vector unsigned char vec_vmrghb (vector unsigned char,
16201                                  vector unsigned char);
16203 vector bool char vec_mergel (vector bool char, vector bool char);
16204 vector signed char vec_mergel (vector signed char, vector signed char);
16205 vector unsigned char vec_mergel (vector unsigned char,
16206                                  vector unsigned char);
16207 vector bool short vec_mergel (vector bool short, vector bool short);
16208 vector pixel vec_mergel (vector pixel, vector pixel);
16209 vector signed short vec_mergel (vector signed short,
16210                                 vector signed short);
16211 vector unsigned short vec_mergel (vector unsigned short,
16212                                   vector unsigned short);
16213 vector float vec_mergel (vector float, vector float);
16214 vector bool int vec_mergel (vector bool int, vector bool int);
16215 vector signed int vec_mergel (vector signed int, vector signed int);
16216 vector unsigned int vec_mergel (vector unsigned int,
16217                                 vector unsigned int);
16219 vector float vec_vmrglw (vector float, vector float);
16220 vector signed int vec_vmrglw (vector signed int, vector signed int);
16221 vector unsigned int vec_vmrglw (vector unsigned int,
16222                                 vector unsigned int);
16223 vector bool int vec_vmrglw (vector bool int, vector bool int);
16225 vector bool short vec_vmrglh (vector bool short, vector bool short);
16226 vector signed short vec_vmrglh (vector signed short,
16227                                 vector signed short);
16228 vector unsigned short vec_vmrglh (vector unsigned short,
16229                                   vector unsigned short);
16230 vector pixel vec_vmrglh (vector pixel, vector pixel);
16232 vector bool char vec_vmrglb (vector bool char, vector bool char);
16233 vector signed char vec_vmrglb (vector signed char, vector signed char);
16234 vector unsigned char vec_vmrglb (vector unsigned char,
16235                                  vector unsigned char);
16237 vector unsigned short vec_mfvscr (void);
16239 vector unsigned char vec_min (vector bool char, vector unsigned char);
16240 vector unsigned char vec_min (vector unsigned char, vector bool char);
16241 vector unsigned char vec_min (vector unsigned char,
16242                               vector unsigned char);
16243 vector signed char vec_min (vector bool char, vector signed char);
16244 vector signed char vec_min (vector signed char, vector bool char);
16245 vector signed char vec_min (vector signed char, vector signed char);
16246 vector unsigned short vec_min (vector bool short,
16247                                vector unsigned short);
16248 vector unsigned short vec_min (vector unsigned short,
16249                                vector bool short);
16250 vector unsigned short vec_min (vector unsigned short,
16251                                vector unsigned short);
16252 vector signed short vec_min (vector bool short, vector signed short);
16253 vector signed short vec_min (vector signed short, vector bool short);
16254 vector signed short vec_min (vector signed short, vector signed short);
16255 vector unsigned int vec_min (vector bool int, vector unsigned int);
16256 vector unsigned int vec_min (vector unsigned int, vector bool int);
16257 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16258 vector signed int vec_min (vector bool int, vector signed int);
16259 vector signed int vec_min (vector signed int, vector bool int);
16260 vector signed int vec_min (vector signed int, vector signed int);
16261 vector float vec_min (vector float, vector float);
16263 vector float vec_vminfp (vector float, vector float);
16265 vector signed int vec_vminsw (vector bool int, vector signed int);
16266 vector signed int vec_vminsw (vector signed int, vector bool int);
16267 vector signed int vec_vminsw (vector signed int, vector signed int);
16269 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16270 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16271 vector unsigned int vec_vminuw (vector unsigned int,
16272                                 vector unsigned int);
16274 vector signed short vec_vminsh (vector bool short, vector signed short);
16275 vector signed short vec_vminsh (vector signed short, vector bool short);
16276 vector signed short vec_vminsh (vector signed short,
16277                                 vector signed short);
16279 vector unsigned short vec_vminuh (vector bool short,
16280                                   vector unsigned short);
16281 vector unsigned short vec_vminuh (vector unsigned short,
16282                                   vector bool short);
16283 vector unsigned short vec_vminuh (vector unsigned short,
16284                                   vector unsigned short);
16286 vector signed char vec_vminsb (vector bool char, vector signed char);
16287 vector signed char vec_vminsb (vector signed char, vector bool char);
16288 vector signed char vec_vminsb (vector signed char, vector signed char);
16290 vector unsigned char vec_vminub (vector bool char,
16291                                  vector unsigned char);
16292 vector unsigned char vec_vminub (vector unsigned char,
16293                                  vector bool char);
16294 vector unsigned char vec_vminub (vector unsigned char,
16295                                  vector unsigned char);
16297 vector signed short vec_mladd (vector signed short,
16298                                vector signed short,
16299                                vector signed short);
16300 vector signed short vec_mladd (vector signed short,
16301                                vector unsigned short,
16302                                vector unsigned short);
16303 vector signed short vec_mladd (vector unsigned short,
16304                                vector signed short,
16305                                vector signed short);
16306 vector unsigned short vec_mladd (vector unsigned short,
16307                                  vector unsigned short,
16308                                  vector unsigned short);
16310 vector signed short vec_mradds (vector signed short,
16311                                 vector signed short,
16312                                 vector signed short);
16314 vector unsigned int vec_msum (vector unsigned char,
16315                               vector unsigned char,
16316                               vector unsigned int);
16317 vector signed int vec_msum (vector signed char,
16318                             vector unsigned char,
16319                             vector signed int);
16320 vector unsigned int vec_msum (vector unsigned short,
16321                               vector unsigned short,
16322                               vector unsigned int);
16323 vector signed int vec_msum (vector signed short,
16324                             vector signed short,
16325                             vector signed int);
16327 vector signed int vec_vmsumshm (vector signed short,
16328                                 vector signed short,
16329                                 vector signed int);
16331 vector unsigned int vec_vmsumuhm (vector unsigned short,
16332                                   vector unsigned short,
16333                                   vector unsigned int);
16335 vector signed int vec_vmsummbm (vector signed char,
16336                                 vector unsigned char,
16337                                 vector signed int);
16339 vector unsigned int vec_vmsumubm (vector unsigned char,
16340                                   vector unsigned char,
16341                                   vector unsigned int);
16343 vector unsigned int vec_msums (vector unsigned short,
16344                                vector unsigned short,
16345                                vector unsigned int);
16346 vector signed int vec_msums (vector signed short,
16347                              vector signed short,
16348                              vector signed int);
16350 vector signed int vec_vmsumshs (vector signed short,
16351                                 vector signed short,
16352                                 vector signed int);
16354 vector unsigned int vec_vmsumuhs (vector unsigned short,
16355                                   vector unsigned short,
16356                                   vector unsigned int);
16358 void vec_mtvscr (vector signed int);
16359 void vec_mtvscr (vector unsigned int);
16360 void vec_mtvscr (vector bool int);
16361 void vec_mtvscr (vector signed short);
16362 void vec_mtvscr (vector unsigned short);
16363 void vec_mtvscr (vector bool short);
16364 void vec_mtvscr (vector pixel);
16365 void vec_mtvscr (vector signed char);
16366 void vec_mtvscr (vector unsigned char);
16367 void vec_mtvscr (vector bool char);
16369 vector unsigned short vec_mule (vector unsigned char,
16370                                 vector unsigned char);
16371 vector signed short vec_mule (vector signed char,
16372                               vector signed char);
16373 vector unsigned int vec_mule (vector unsigned short,
16374                               vector unsigned short);
16375 vector signed int vec_mule (vector signed short, vector signed short);
16376 vector unsigned long long vec_mule (vector unsigned int,
16377                                     vector unsigned int);
16378 vector signed long long vec_mule (vector signed int,
16379                                   vector signed int);
16381 vector signed int vec_vmulesh (vector signed short,
16382                                vector signed short);
16384 vector unsigned int vec_vmuleuh (vector unsigned short,
16385                                  vector unsigned short);
16387 vector signed short vec_vmulesb (vector signed char,
16388                                  vector signed char);
16390 vector unsigned short vec_vmuleub (vector unsigned char,
16391                                   vector unsigned char);
16393 vector unsigned short vec_mulo (vector unsigned char,
16394                                 vector unsigned char);
16395 vector signed short vec_mulo (vector signed char, vector signed char);
16396 vector unsigned int vec_mulo (vector unsigned short,
16397                               vector unsigned short);
16398 vector signed int vec_mulo (vector signed short, vector signed short);
16399 vector unsigned long long vec_mulo (vector unsigned int,
16400                                     vector unsigned int);
16401 vector signed long long vec_mulo (vector signed int,
16402                                   vector signed int);
16404 vector signed int vec_vmulosh (vector signed short,
16405                                vector signed short);
16407 vector unsigned int vec_vmulouh (vector unsigned short,
16408                                  vector unsigned short);
16410 vector signed short vec_vmulosb (vector signed char,
16411                                  vector signed char);
16413 vector unsigned short vec_vmuloub (vector unsigned char,
16414                                    vector unsigned char);
16416 vector float vec_nmsub (vector float, vector float, vector float);
16418 vector signed char vec_nabs (vector signed char);
16419 vector signed short vec_nabs (vector signed short);
16420 vector signed int vec_nabs (vector signed int);
16421 vector float vec_nabs (vector float);
16422 vector double vec_nabs (vector double);
16424 vector signed char vec_neg (vector signed char);
16425 vector signed short vec_neg (vector signed short);
16426 vector signed int vec_neg (vector signed int);
16427 vector signed long long vec_neg (vector signed long long);
16428 vector float  char vec_neg (vector float);
16429 vector double vec_neg (vector double);
16431 vector float vec_nor (vector float, vector float);
16432 vector signed int vec_nor (vector signed int, vector signed int);
16433 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16434 vector bool int vec_nor (vector bool int, vector bool int);
16435 vector signed short vec_nor (vector signed short, vector signed short);
16436 vector unsigned short vec_nor (vector unsigned short,
16437                                vector unsigned short);
16438 vector bool short vec_nor (vector bool short, vector bool short);
16439 vector signed char vec_nor (vector signed char, vector signed char);
16440 vector unsigned char vec_nor (vector unsigned char,
16441                               vector unsigned char);
16442 vector bool char vec_nor (vector bool char, vector bool char);
16444 vector float vec_or (vector float, vector float);
16445 vector float vec_or (vector float, vector bool int);
16446 vector float vec_or (vector bool int, vector float);
16447 vector bool int vec_or (vector bool int, vector bool int);
16448 vector signed int vec_or (vector bool int, vector signed int);
16449 vector signed int vec_or (vector signed int, vector bool int);
16450 vector signed int vec_or (vector signed int, vector signed int);
16451 vector unsigned int vec_or (vector bool int, vector unsigned int);
16452 vector unsigned int vec_or (vector unsigned int, vector bool int);
16453 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16454 vector bool short vec_or (vector bool short, vector bool short);
16455 vector signed short vec_or (vector bool short, vector signed short);
16456 vector signed short vec_or (vector signed short, vector bool short);
16457 vector signed short vec_or (vector signed short, vector signed short);
16458 vector unsigned short vec_or (vector bool short, vector unsigned short);
16459 vector unsigned short vec_or (vector unsigned short, vector bool short);
16460 vector unsigned short vec_or (vector unsigned short,
16461                               vector unsigned short);
16462 vector signed char vec_or (vector bool char, vector signed char);
16463 vector bool char vec_or (vector bool char, vector bool char);
16464 vector signed char vec_or (vector signed char, vector bool char);
16465 vector signed char vec_or (vector signed char, vector signed char);
16466 vector unsigned char vec_or (vector bool char, vector unsigned char);
16467 vector unsigned char vec_or (vector unsigned char, vector bool char);
16468 vector unsigned char vec_or (vector unsigned char,
16469                              vector unsigned char);
16471 vector signed char vec_pack (vector signed short, vector signed short);
16472 vector unsigned char vec_pack (vector unsigned short,
16473                                vector unsigned short);
16474 vector bool char vec_pack (vector bool short, vector bool short);
16475 vector signed short vec_pack (vector signed int, vector signed int);
16476 vector unsigned short vec_pack (vector unsigned int,
16477                                 vector unsigned int);
16478 vector bool short vec_pack (vector bool int, vector bool int);
16480 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16481 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16482 vector unsigned short vec_vpkuwum (vector unsigned int,
16483                                    vector unsigned int);
16485 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16486 vector signed char vec_vpkuhum (vector signed short,
16487                                 vector signed short);
16488 vector unsigned char vec_vpkuhum (vector unsigned short,
16489                                   vector unsigned short);
16491 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16493 vector unsigned char vec_packs (vector unsigned short,
16494                                 vector unsigned short);
16495 vector signed char vec_packs (vector signed short, vector signed short);
16496 vector unsigned short vec_packs (vector unsigned int,
16497                                  vector unsigned int);
16498 vector signed short vec_packs (vector signed int, vector signed int);
16500 vector signed short vec_vpkswss (vector signed int, vector signed int);
16502 vector unsigned short vec_vpkuwus (vector unsigned int,
16503                                    vector unsigned int);
16505 vector signed char vec_vpkshss (vector signed short,
16506                                 vector signed short);
16508 vector unsigned char vec_vpkuhus (vector unsigned short,
16509                                   vector unsigned short);
16511 vector unsigned char vec_packsu (vector unsigned short,
16512                                  vector unsigned short);
16513 vector unsigned char vec_packsu (vector signed short,
16514                                  vector signed short);
16515 vector unsigned short vec_packsu (vector unsigned int,
16516                                   vector unsigned int);
16517 vector unsigned short vec_packsu (vector signed int, vector signed int);
16519 vector unsigned short vec_vpkswus (vector signed int,
16520                                    vector signed int);
16522 vector unsigned char vec_vpkshus (vector signed short,
16523                                   vector signed short);
16525 vector float vec_perm (vector float,
16526                        vector float,
16527                        vector unsigned char);
16528 vector signed int vec_perm (vector signed int,
16529                             vector signed int,
16530                             vector unsigned char);
16531 vector unsigned int vec_perm (vector unsigned int,
16532                               vector unsigned int,
16533                               vector unsigned char);
16534 vector bool int vec_perm (vector bool int,
16535                           vector bool int,
16536                           vector unsigned char);
16537 vector signed short vec_perm (vector signed short,
16538                               vector signed short,
16539                               vector unsigned char);
16540 vector unsigned short vec_perm (vector unsigned short,
16541                                 vector unsigned short,
16542                                 vector unsigned char);
16543 vector bool short vec_perm (vector bool short,
16544                             vector bool short,
16545                             vector unsigned char);
16546 vector pixel vec_perm (vector pixel,
16547                        vector pixel,
16548                        vector unsigned char);
16549 vector signed char vec_perm (vector signed char,
16550                              vector signed char,
16551                              vector unsigned char);
16552 vector unsigned char vec_perm (vector unsigned char,
16553                                vector unsigned char,
16554                                vector unsigned char);
16555 vector bool char vec_perm (vector bool char,
16556                            vector bool char,
16557                            vector unsigned char);
16559 vector float vec_re (vector float);
16561 vector bool char vec_reve (vector bool char);
16562 vector signed char vec_reve (vector signed char);
16563 vector unsigned char vec_reve (vector unsigned char);
16564 vector bool int vec_reve (vector bool int);
16565 vector signed int vec_reve (vector signed int);
16566 vector unsigned int vec_reve (vector unsigned int);
16567 vector bool long long vec_reve (vector bool long long);
16568 vector signed long long vec_reve (vector signed long long);
16569 vector unsigned long long vec_reve (vector unsigned long long);
16570 vector bool short vec_reve (vector bool short);
16571 vector signed short vec_reve (vector signed short);
16572 vector unsigned short vec_reve (vector unsigned short);
16574 vector signed char vec_rl (vector signed char,
16575                            vector unsigned char);
16576 vector unsigned char vec_rl (vector unsigned char,
16577                              vector unsigned char);
16578 vector signed short vec_rl (vector signed short, vector unsigned short);
16579 vector unsigned short vec_rl (vector unsigned short,
16580                               vector unsigned short);
16581 vector signed int vec_rl (vector signed int, vector unsigned int);
16582 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16584 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16585 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16587 vector signed short vec_vrlh (vector signed short,
16588                               vector unsigned short);
16589 vector unsigned short vec_vrlh (vector unsigned short,
16590                                 vector unsigned short);
16592 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16593 vector unsigned char vec_vrlb (vector unsigned char,
16594                                vector unsigned char);
16596 vector float vec_round (vector float);
16598 vector float vec_recip (vector float, vector float);
16600 vector float vec_rsqrt (vector float);
16602 vector float vec_rsqrte (vector float);
16604 vector float vec_sel (vector float, vector float, vector bool int);
16605 vector float vec_sel (vector float, vector float, vector unsigned int);
16606 vector signed int vec_sel (vector signed int,
16607                            vector signed int,
16608                            vector bool int);
16609 vector signed int vec_sel (vector signed int,
16610                            vector signed int,
16611                            vector unsigned int);
16612 vector unsigned int vec_sel (vector unsigned int,
16613                              vector unsigned int,
16614                              vector bool int);
16615 vector unsigned int vec_sel (vector unsigned int,
16616                              vector unsigned int,
16617                              vector unsigned int);
16618 vector bool int vec_sel (vector bool int,
16619                          vector bool int,
16620                          vector bool int);
16621 vector bool int vec_sel (vector bool int,
16622                          vector bool int,
16623                          vector unsigned int);
16624 vector signed short vec_sel (vector signed short,
16625                              vector signed short,
16626                              vector bool short);
16627 vector signed short vec_sel (vector signed short,
16628                              vector signed short,
16629                              vector unsigned short);
16630 vector unsigned short vec_sel (vector unsigned short,
16631                                vector unsigned short,
16632                                vector bool short);
16633 vector unsigned short vec_sel (vector unsigned short,
16634                                vector unsigned short,
16635                                vector unsigned short);
16636 vector bool short vec_sel (vector bool short,
16637                            vector bool short,
16638                            vector bool short);
16639 vector bool short vec_sel (vector bool short,
16640                            vector bool short,
16641                            vector unsigned short);
16642 vector signed char vec_sel (vector signed char,
16643                             vector signed char,
16644                             vector bool char);
16645 vector signed char vec_sel (vector signed char,
16646                             vector signed char,
16647                             vector unsigned char);
16648 vector unsigned char vec_sel (vector unsigned char,
16649                               vector unsigned char,
16650                               vector bool char);
16651 vector unsigned char vec_sel (vector unsigned char,
16652                               vector unsigned char,
16653                               vector unsigned char);
16654 vector bool char vec_sel (vector bool char,
16655                           vector bool char,
16656                           vector bool char);
16657 vector bool char vec_sel (vector bool char,
16658                           vector bool char,
16659                           vector unsigned char);
16661 vector signed long long vec_signed (vector double);
16662 vector signed int vec_signed (vector float);
16664 vector signed int vec_signede (vector double);
16665 vector signed int vec_signedo (vector double);
16666 vector signed int vec_signed2 (vector double, vector double);
16668 vector signed char vec_sl (vector signed char,
16669                            vector unsigned char);
16670 vector unsigned char vec_sl (vector unsigned char,
16671                              vector unsigned char);
16672 vector signed short vec_sl (vector signed short, vector unsigned short);
16673 vector unsigned short vec_sl (vector unsigned short,
16674                               vector unsigned short);
16675 vector signed int vec_sl (vector signed int, vector unsigned int);
16676 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16678 vector signed int vec_vslw (vector signed int, vector unsigned int);
16679 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16681 vector signed short vec_vslh (vector signed short,
16682                               vector unsigned short);
16683 vector unsigned short vec_vslh (vector unsigned short,
16684                                 vector unsigned short);
16686 vector signed char vec_vslb (vector signed char, vector unsigned char);
16687 vector unsigned char vec_vslb (vector unsigned char,
16688                                vector unsigned char);
16690 vector float vec_sld (vector float, vector float, const int);
16691 vector double vec_sld (vector double, vector double, const int);
16693 vector signed int vec_sld (vector signed int,
16694                            vector signed int,
16695                            const int);
16696 vector unsigned int vec_sld (vector unsigned int,
16697                              vector unsigned int,
16698                              const int);
16699 vector bool int vec_sld (vector bool int,
16700                          vector bool int,
16701                          const int);
16702 vector signed short vec_sld (vector signed short,
16703                              vector signed short,
16704                              const int);
16705 vector unsigned short vec_sld (vector unsigned short,
16706                                vector unsigned short,
16707                                const int);
16708 vector bool short vec_sld (vector bool short,
16709                            vector bool short,
16710                            const int);
16711 vector pixel vec_sld (vector pixel,
16712                       vector pixel,
16713                       const int);
16714 vector signed char vec_sld (vector signed char,
16715                             vector signed char,
16716                             const int);
16717 vector unsigned char vec_sld (vector unsigned char,
16718                               vector unsigned char,
16719                               const int);
16720 vector bool char vec_sld (vector bool char,
16721                           vector bool char,
16722                           const int);
16724 vector signed char vec_sldw (vector signed char,
16725                              vector signed char,
16726                              const int);
16727 vector unsigned char vec_sldw (vector unsigned char,
16728                                vector unsigned char,
16729                                const int);
16730 vector signed short vec_sldw (vector signed short,
16731                               vector signed short,
16732                               const int);
16733 vector unsigned short vec_sldw (vector unsigned short,
16734                                 vector unsigned short,
16735                                 const int);
16736 vector signed int vec_sldw (vector signed int,
16737                             vector signed int,
16738                             const int);
16739 vector unsigned int vec_sldw (vector unsigned int,
16740                               vector unsigned int,
16741                               const int);
16742 vector signed long long vec_sldw (vector signed long long,
16743                                   vector signed long long,
16744                                   const int);
16745 vector unsigned long long vec_sldw (vector unsigned long long,
16746                                     vector unsigned long long,
16747                                     const int);
16749 vector signed int vec_sll (vector signed int,
16750                            vector unsigned int);
16751 vector signed int vec_sll (vector signed int,
16752                            vector unsigned short);
16753 vector signed int vec_sll (vector signed int,
16754                            vector unsigned char);
16755 vector unsigned int vec_sll (vector unsigned int,
16756                              vector unsigned int);
16757 vector unsigned int vec_sll (vector unsigned int,
16758                              vector unsigned short);
16759 vector unsigned int vec_sll (vector unsigned int,
16760                              vector unsigned char);
16761 vector bool int vec_sll (vector bool int,
16762                          vector unsigned int);
16763 vector bool int vec_sll (vector bool int,
16764                          vector unsigned short);
16765 vector bool int vec_sll (vector bool int,
16766                          vector unsigned char);
16767 vector signed short vec_sll (vector signed short,
16768                              vector unsigned int);
16769 vector signed short vec_sll (vector signed short,
16770                              vector unsigned short);
16771 vector signed short vec_sll (vector signed short,
16772                              vector unsigned char);
16773 vector unsigned short vec_sll (vector unsigned short,
16774                                vector unsigned int);
16775 vector unsigned short vec_sll (vector unsigned short,
16776                                vector unsigned short);
16777 vector unsigned short vec_sll (vector unsigned short,
16778                                vector unsigned char);
16779 vector bool short vec_sll (vector bool short, vector unsigned int);
16780 vector bool short vec_sll (vector bool short, vector unsigned short);
16781 vector bool short vec_sll (vector bool short, vector unsigned char);
16782 vector pixel vec_sll (vector pixel, vector unsigned int);
16783 vector pixel vec_sll (vector pixel, vector unsigned short);
16784 vector pixel vec_sll (vector pixel, vector unsigned char);
16785 vector signed char vec_sll (vector signed char, vector unsigned int);
16786 vector signed char vec_sll (vector signed char, vector unsigned short);
16787 vector signed char vec_sll (vector signed char, vector unsigned char);
16788 vector unsigned char vec_sll (vector unsigned char,
16789                               vector unsigned int);
16790 vector unsigned char vec_sll (vector unsigned char,
16791                               vector unsigned short);
16792 vector unsigned char vec_sll (vector unsigned char,
16793                               vector unsigned char);
16794 vector bool char vec_sll (vector bool char, vector unsigned int);
16795 vector bool char vec_sll (vector bool char, vector unsigned short);
16796 vector bool char vec_sll (vector bool char, vector unsigned char);
16798 vector float vec_slo (vector float, vector signed char);
16799 vector float vec_slo (vector float, vector unsigned char);
16800 vector signed int vec_slo (vector signed int, vector signed char);
16801 vector signed int vec_slo (vector signed int, vector unsigned char);
16802 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16803 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16804 vector signed short vec_slo (vector signed short, vector signed char);
16805 vector signed short vec_slo (vector signed short, vector unsigned char);
16806 vector unsigned short vec_slo (vector unsigned short,
16807                                vector signed char);
16808 vector unsigned short vec_slo (vector unsigned short,
16809                                vector unsigned char);
16810 vector pixel vec_slo (vector pixel, vector signed char);
16811 vector pixel vec_slo (vector pixel, vector unsigned char);
16812 vector signed char vec_slo (vector signed char, vector signed char);
16813 vector signed char vec_slo (vector signed char, vector unsigned char);
16814 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16815 vector unsigned char vec_slo (vector unsigned char,
16816                               vector unsigned char);
16817 vector signed long long vec_slo (vector signed long long, vector signed char);
16818 vector signed long long vec_slo (vector signed long long, vector unsigned char);
16819 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
16820 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
16822 vector signed char vec_splat (vector signed char, const int);
16823 vector unsigned char vec_splat (vector unsigned char, const int);
16824 vector bool char vec_splat (vector bool char, const int);
16825 vector signed short vec_splat (vector signed short, const int);
16826 vector unsigned short vec_splat (vector unsigned short, const int);
16827 vector bool short vec_splat (vector bool short, const int);
16828 vector pixel vec_splat (vector pixel, const int);
16829 vector float vec_splat (vector float, const int);
16830 vector signed int vec_splat (vector signed int, const int);
16831 vector unsigned int vec_splat (vector unsigned int, const int);
16832 vector bool int vec_splat (vector bool int, const int);
16833 vector signed long vec_splat (vector signed long, const int);
16834 vector unsigned long vec_splat (vector unsigned long, const int);
16836 vector signed char vec_splats (signed char);
16837 vector unsigned char vec_splats (unsigned char);
16838 vector signed short vec_splats (signed short);
16839 vector unsigned short vec_splats (unsigned short);
16840 vector signed int vec_splats (signed int);
16841 vector unsigned int vec_splats (unsigned int);
16842 vector float vec_splats (float);
16844 vector float vec_vspltw (vector float, const int);
16845 vector signed int vec_vspltw (vector signed int, const int);
16846 vector unsigned int vec_vspltw (vector unsigned int, const int);
16847 vector bool int vec_vspltw (vector bool int, const int);
16849 vector bool short vec_vsplth (vector bool short, const int);
16850 vector signed short vec_vsplth (vector signed short, const int);
16851 vector unsigned short vec_vsplth (vector unsigned short, const int);
16852 vector pixel vec_vsplth (vector pixel, const int);
16854 vector signed char vec_vspltb (vector signed char, const int);
16855 vector unsigned char vec_vspltb (vector unsigned char, const int);
16856 vector bool char vec_vspltb (vector bool char, const int);
16858 vector signed char vec_splat_s8 (const int);
16860 vector signed short vec_splat_s16 (const int);
16862 vector signed int vec_splat_s32 (const int);
16864 vector unsigned char vec_splat_u8 (const int);
16866 vector unsigned short vec_splat_u16 (const int);
16868 vector unsigned int vec_splat_u32 (const int);
16870 vector signed char vec_sr (vector signed char, vector unsigned char);
16871 vector unsigned char vec_sr (vector unsigned char,
16872                              vector unsigned char);
16873 vector signed short vec_sr (vector signed short,
16874                             vector unsigned short);
16875 vector unsigned short vec_sr (vector unsigned short,
16876                               vector unsigned short);
16877 vector signed int vec_sr (vector signed int, vector unsigned int);
16878 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16880 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16881 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16883 vector signed short vec_vsrh (vector signed short,
16884                               vector unsigned short);
16885 vector unsigned short vec_vsrh (vector unsigned short,
16886                                 vector unsigned short);
16888 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16889 vector unsigned char vec_vsrb (vector unsigned char,
16890                                vector unsigned char);
16892 vector signed char vec_sra (vector signed char, vector unsigned char);
16893 vector unsigned char vec_sra (vector unsigned char,
16894                               vector unsigned char);
16895 vector signed short vec_sra (vector signed short,
16896                              vector unsigned short);
16897 vector unsigned short vec_sra (vector unsigned short,
16898                                vector unsigned short);
16899 vector signed int vec_sra (vector signed int, vector unsigned int);
16900 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16902 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16903 vector unsigned int vec_vsraw (vector unsigned int,
16904                                vector unsigned int);
16906 vector signed short vec_vsrah (vector signed short,
16907                                vector unsigned short);
16908 vector unsigned short vec_vsrah (vector unsigned short,
16909                                  vector unsigned short);
16911 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16912 vector unsigned char vec_vsrab (vector unsigned char,
16913                                 vector unsigned char);
16915 vector signed int vec_srl (vector signed int, vector unsigned int);
16916 vector signed int vec_srl (vector signed int, vector unsigned short);
16917 vector signed int vec_srl (vector signed int, vector unsigned char);
16918 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16919 vector unsigned int vec_srl (vector unsigned int,
16920                              vector unsigned short);
16921 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16922 vector bool int vec_srl (vector bool int, vector unsigned int);
16923 vector bool int vec_srl (vector bool int, vector unsigned short);
16924 vector bool int vec_srl (vector bool int, vector unsigned char);
16925 vector signed short vec_srl (vector signed short, vector unsigned int);
16926 vector signed short vec_srl (vector signed short,
16927                              vector unsigned short);
16928 vector signed short vec_srl (vector signed short, vector unsigned char);
16929 vector unsigned short vec_srl (vector unsigned short,
16930                                vector unsigned int);
16931 vector unsigned short vec_srl (vector unsigned short,
16932                                vector unsigned short);
16933 vector unsigned short vec_srl (vector unsigned short,
16934                                vector unsigned char);
16935 vector bool short vec_srl (vector bool short, vector unsigned int);
16936 vector bool short vec_srl (vector bool short, vector unsigned short);
16937 vector bool short vec_srl (vector bool short, vector unsigned char);
16938 vector pixel vec_srl (vector pixel, vector unsigned int);
16939 vector pixel vec_srl (vector pixel, vector unsigned short);
16940 vector pixel vec_srl (vector pixel, vector unsigned char);
16941 vector signed char vec_srl (vector signed char, vector unsigned int);
16942 vector signed char vec_srl (vector signed char, vector unsigned short);
16943 vector signed char vec_srl (vector signed char, vector unsigned char);
16944 vector unsigned char vec_srl (vector unsigned char,
16945                               vector unsigned int);
16946 vector unsigned char vec_srl (vector unsigned char,
16947                               vector unsigned short);
16948 vector unsigned char vec_srl (vector unsigned char,
16949                               vector unsigned char);
16950 vector bool char vec_srl (vector bool char, vector unsigned int);
16951 vector bool char vec_srl (vector bool char, vector unsigned short);
16952 vector bool char vec_srl (vector bool char, vector unsigned char);
16954 vector float vec_sro (vector float, vector signed char);
16955 vector float vec_sro (vector float, vector unsigned char);
16956 vector signed int vec_sro (vector signed int, vector signed char);
16957 vector signed int vec_sro (vector signed int, vector unsigned char);
16958 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16959 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16960 vector signed short vec_sro (vector signed short, vector signed char);
16961 vector signed short vec_sro (vector signed short, vector unsigned char);
16962 vector unsigned short vec_sro (vector unsigned short,
16963                                vector signed char);
16964 vector unsigned short vec_sro (vector unsigned short,
16965                                vector unsigned char);
16966 vector pixel vec_sro (vector pixel, vector signed char);
16967 vector pixel vec_sro (vector pixel, vector unsigned char);
16968 vector signed char vec_sro (vector signed char, vector signed char);
16969 vector signed char vec_sro (vector signed char, vector unsigned char);
16970 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16971 vector unsigned char vec_sro (vector unsigned char,
16972                               vector unsigned char);
16974 void vec_st (vector float, int, vector float *);
16975 void vec_st (vector float, int, float *);
16976 void vec_st (vector signed int, int, vector signed int *);
16977 void vec_st (vector signed int, int, int *);
16978 void vec_st (vector unsigned int, int, vector unsigned int *);
16979 void vec_st (vector unsigned int, int, unsigned int *);
16980 void vec_st (vector bool int, int, vector bool int *);
16981 void vec_st (vector bool int, int, unsigned int *);
16982 void vec_st (vector bool int, int, int *);
16983 void vec_st (vector signed short, int, vector signed short *);
16984 void vec_st (vector signed short, int, short *);
16985 void vec_st (vector unsigned short, int, vector unsigned short *);
16986 void vec_st (vector unsigned short, int, unsigned short *);
16987 void vec_st (vector bool short, int, vector bool short *);
16988 void vec_st (vector bool short, int, unsigned short *);
16989 void vec_st (vector pixel, int, vector pixel *);
16990 void vec_st (vector pixel, int, unsigned short *);
16991 void vec_st (vector pixel, int, short *);
16992 void vec_st (vector bool short, int, short *);
16993 void vec_st (vector signed char, int, vector signed char *);
16994 void vec_st (vector signed char, int, signed char *);
16995 void vec_st (vector unsigned char, int, vector unsigned char *);
16996 void vec_st (vector unsigned char, int, unsigned char *);
16997 void vec_st (vector bool char, int, vector bool char *);
16998 void vec_st (vector bool char, int, unsigned char *);
16999 void vec_st (vector bool char, int, signed char *);
17001 void vec_ste (vector signed char, int, signed char *);
17002 void vec_ste (vector unsigned char, int, unsigned char *);
17003 void vec_ste (vector bool char, int, signed char *);
17004 void vec_ste (vector bool char, int, unsigned char *);
17005 void vec_ste (vector signed short, int, short *);
17006 void vec_ste (vector unsigned short, int, unsigned short *);
17007 void vec_ste (vector bool short, int, short *);
17008 void vec_ste (vector bool short, int, unsigned short *);
17009 void vec_ste (vector pixel, int, short *);
17010 void vec_ste (vector pixel, int, unsigned short *);
17011 void vec_ste (vector float, int, float *);
17012 void vec_ste (vector signed int, int, int *);
17013 void vec_ste (vector unsigned int, int, unsigned int *);
17014 void vec_ste (vector bool int, int, int *);
17015 void vec_ste (vector bool int, int, unsigned int *);
17017 void vec_stvewx (vector float, int, float *);
17018 void vec_stvewx (vector signed int, int, int *);
17019 void vec_stvewx (vector unsigned int, int, unsigned int *);
17020 void vec_stvewx (vector bool int, int, int *);
17021 void vec_stvewx (vector bool int, int, unsigned int *);
17023 void vec_stvehx (vector signed short, int, short *);
17024 void vec_stvehx (vector unsigned short, int, unsigned short *);
17025 void vec_stvehx (vector bool short, int, short *);
17026 void vec_stvehx (vector bool short, int, unsigned short *);
17027 void vec_stvehx (vector pixel, int, short *);
17028 void vec_stvehx (vector pixel, int, unsigned short *);
17030 void vec_stvebx (vector signed char, int, signed char *);
17031 void vec_stvebx (vector unsigned char, int, unsigned char *);
17032 void vec_stvebx (vector bool char, int, signed char *);
17033 void vec_stvebx (vector bool char, int, unsigned char *);
17035 void vec_stl (vector float, int, vector float *);
17036 void vec_stl (vector float, int, float *);
17037 void vec_stl (vector signed int, int, vector signed int *);
17038 void vec_stl (vector signed int, int, int *);
17039 void vec_stl (vector unsigned int, int, vector unsigned int *);
17040 void vec_stl (vector unsigned int, int, unsigned int *);
17041 void vec_stl (vector bool int, int, vector bool int *);
17042 void vec_stl (vector bool int, int, unsigned int *);
17043 void vec_stl (vector bool int, int, int *);
17044 void vec_stl (vector signed short, int, vector signed short *);
17045 void vec_stl (vector signed short, int, short *);
17046 void vec_stl (vector unsigned short, int, vector unsigned short *);
17047 void vec_stl (vector unsigned short, int, unsigned short *);
17048 void vec_stl (vector bool short, int, vector bool short *);
17049 void vec_stl (vector bool short, int, unsigned short *);
17050 void vec_stl (vector bool short, int, short *);
17051 void vec_stl (vector pixel, int, vector pixel *);
17052 void vec_stl (vector pixel, int, unsigned short *);
17053 void vec_stl (vector pixel, int, short *);
17054 void vec_stl (vector signed char, int, vector signed char *);
17055 void vec_stl (vector signed char, int, signed char *);
17056 void vec_stl (vector unsigned char, int, vector unsigned char *);
17057 void vec_stl (vector unsigned char, int, unsigned char *);
17058 void vec_stl (vector bool char, int, vector bool char *);
17059 void vec_stl (vector bool char, int, unsigned char *);
17060 void vec_stl (vector bool char, int, signed char *);
17062 vector signed char vec_sub (vector bool char, vector signed char);
17063 vector signed char vec_sub (vector signed char, vector bool char);
17064 vector signed char vec_sub (vector signed char, vector signed char);
17065 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17066 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17067 vector unsigned char vec_sub (vector unsigned char,
17068                               vector unsigned char);
17069 vector signed short vec_sub (vector bool short, vector signed short);
17070 vector signed short vec_sub (vector signed short, vector bool short);
17071 vector signed short vec_sub (vector signed short, vector signed short);
17072 vector unsigned short vec_sub (vector bool short,
17073                                vector unsigned short);
17074 vector unsigned short vec_sub (vector unsigned short,
17075                                vector bool short);
17076 vector unsigned short vec_sub (vector unsigned short,
17077                                vector unsigned short);
17078 vector signed int vec_sub (vector bool int, vector signed int);
17079 vector signed int vec_sub (vector signed int, vector bool int);
17080 vector signed int vec_sub (vector signed int, vector signed int);
17081 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17082 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17083 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17084 vector float vec_sub (vector float, vector float);
17086 vector float vec_vsubfp (vector float, vector float);
17088 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17089 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17090 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17091 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17092 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17093 vector unsigned int vec_vsubuwm (vector unsigned int,
17094                                  vector unsigned int);
17096 vector signed short vec_vsubuhm (vector bool short,
17097                                  vector signed short);
17098 vector signed short vec_vsubuhm (vector signed short,
17099                                  vector bool short);
17100 vector signed short vec_vsubuhm (vector signed short,
17101                                  vector signed short);
17102 vector unsigned short vec_vsubuhm (vector bool short,
17103                                    vector unsigned short);
17104 vector unsigned short vec_vsubuhm (vector unsigned short,
17105                                    vector bool short);
17106 vector unsigned short vec_vsubuhm (vector unsigned short,
17107                                    vector unsigned short);
17109 vector signed char vec_vsububm (vector bool char, vector signed char);
17110 vector signed char vec_vsububm (vector signed char, vector bool char);
17111 vector signed char vec_vsububm (vector signed char, vector signed char);
17112 vector unsigned char vec_vsububm (vector bool char,
17113                                   vector unsigned char);
17114 vector unsigned char vec_vsububm (vector unsigned char,
17115                                   vector bool char);
17116 vector unsigned char vec_vsububm (vector unsigned char,
17117                                   vector unsigned char);
17119 vector signed int vec_subc (vector signed int, vector signed int);
17120 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17121 vector signed __int128 vec_subc (vector signed __int128,
17122                                  vector signed __int128);
17123 vector unsigned __int128 vec_subc (vector unsigned __int128,
17124                                    vector unsigned __int128);
17126 vector signed int vec_sube (vector signed int, vector signed int,
17127                             vector signed int);
17128 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17129                               vector unsigned int);
17130 vector signed __int128 vec_sube (vector signed __int128,
17131                                  vector signed __int128,
17132                                  vector signed __int128);
17133 vector unsigned __int128 vec_sube (vector unsigned __int128,
17134                                    vector unsigned __int128,
17135                                    vector unsigned __int128);
17137 vector signed int vec_subec (vector signed int, vector signed int,
17138                              vector signed int);
17139 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17140                                vector unsigned int);
17141 vector signed __int128 vec_subec (vector signed __int128,
17142                                   vector signed __int128,
17143                                   vector signed __int128);
17144 vector unsigned __int128 vec_subec (vector unsigned __int128,
17145                                     vector unsigned __int128,
17146                                     vector unsigned __int128);
17148 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17149 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17150 vector unsigned char vec_subs (vector unsigned char,
17151                                vector unsigned char);
17152 vector signed char vec_subs (vector bool char, vector signed char);
17153 vector signed char vec_subs (vector signed char, vector bool char);
17154 vector signed char vec_subs (vector signed char, vector signed char);
17155 vector unsigned short vec_subs (vector bool short,
17156                                 vector unsigned short);
17157 vector unsigned short vec_subs (vector unsigned short,
17158                                 vector bool short);
17159 vector unsigned short vec_subs (vector unsigned short,
17160                                 vector unsigned short);
17161 vector signed short vec_subs (vector bool short, vector signed short);
17162 vector signed short vec_subs (vector signed short, vector bool short);
17163 vector signed short vec_subs (vector signed short, vector signed short);
17164 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17165 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17166 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17167 vector signed int vec_subs (vector bool int, vector signed int);
17168 vector signed int vec_subs (vector signed int, vector bool int);
17169 vector signed int vec_subs (vector signed int, vector signed int);
17171 vector signed int vec_vsubsws (vector bool int, vector signed int);
17172 vector signed int vec_vsubsws (vector signed int, vector bool int);
17173 vector signed int vec_vsubsws (vector signed int, vector signed int);
17175 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17176 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17177 vector unsigned int vec_vsubuws (vector unsigned int,
17178                                  vector unsigned int);
17180 vector signed short vec_vsubshs (vector bool short,
17181                                  vector signed short);
17182 vector signed short vec_vsubshs (vector signed short,
17183                                  vector bool short);
17184 vector signed short vec_vsubshs (vector signed short,
17185                                  vector signed short);
17187 vector unsigned short vec_vsubuhs (vector bool short,
17188                                    vector unsigned short);
17189 vector unsigned short vec_vsubuhs (vector unsigned short,
17190                                    vector bool short);
17191 vector unsigned short vec_vsubuhs (vector unsigned short,
17192                                    vector unsigned short);
17194 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17195 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17196 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17198 vector unsigned char vec_vsububs (vector bool char,
17199                                   vector unsigned char);
17200 vector unsigned char vec_vsububs (vector unsigned char,
17201                                   vector bool char);
17202 vector unsigned char vec_vsububs (vector unsigned char,
17203                                   vector unsigned char);
17205 vector unsigned int vec_sum4s (vector unsigned char,
17206                                vector unsigned int);
17207 vector signed int vec_sum4s (vector signed char, vector signed int);
17208 vector signed int vec_sum4s (vector signed short, vector signed int);
17210 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17212 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17214 vector unsigned int vec_vsum4ubs (vector unsigned char,
17215                                   vector unsigned int);
17217 vector signed int vec_sum2s (vector signed int, vector signed int);
17219 vector signed int vec_sums (vector signed int, vector signed int);
17221 vector float vec_trunc (vector float);
17223 vector signed long long vec_unsigned (vector double);
17224 vector signed int vec_unsigned (vector float);
17226 vector signed int vec_unsignede (vector double);
17227 vector signed int vec_unsignedo (vector double);
17228 vector signed int vec_unsigned2 (vector double, vector double);
17230 vector signed short vec_unpackh (vector signed char);
17231 vector bool short vec_unpackh (vector bool char);
17232 vector signed int vec_unpackh (vector signed short);
17233 vector bool int vec_unpackh (vector bool short);
17234 vector unsigned int vec_unpackh (vector pixel);
17236 vector bool int vec_vupkhsh (vector bool short);
17237 vector signed int vec_vupkhsh (vector signed short);
17239 vector unsigned int vec_vupkhpx (vector pixel);
17241 vector bool short vec_vupkhsb (vector bool char);
17242 vector signed short vec_vupkhsb (vector signed char);
17244 vector signed short vec_unpackl (vector signed char);
17245 vector bool short vec_unpackl (vector bool char);
17246 vector unsigned int vec_unpackl (vector pixel);
17247 vector signed int vec_unpackl (vector signed short);
17248 vector bool int vec_unpackl (vector bool short);
17250 vector unsigned int vec_vupklpx (vector pixel);
17252 vector bool int vec_vupklsh (vector bool short);
17253 vector signed int vec_vupklsh (vector signed short);
17255 vector bool short vec_vupklsb (vector bool char);
17256 vector signed short vec_vupklsb (vector signed char);
17258 vector float vec_xor (vector float, vector float);
17259 vector float vec_xor (vector float, vector bool int);
17260 vector float vec_xor (vector bool int, vector float);
17261 vector bool int vec_xor (vector bool int, vector bool int);
17262 vector signed int vec_xor (vector bool int, vector signed int);
17263 vector signed int vec_xor (vector signed int, vector bool int);
17264 vector signed int vec_xor (vector signed int, vector signed int);
17265 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17266 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17267 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17268 vector bool short vec_xor (vector bool short, vector bool short);
17269 vector signed short vec_xor (vector bool short, vector signed short);
17270 vector signed short vec_xor (vector signed short, vector bool short);
17271 vector signed short vec_xor (vector signed short, vector signed short);
17272 vector unsigned short vec_xor (vector bool short,
17273                                vector unsigned short);
17274 vector unsigned short vec_xor (vector unsigned short,
17275                                vector bool short);
17276 vector unsigned short vec_xor (vector unsigned short,
17277                                vector unsigned short);
17278 vector signed char vec_xor (vector bool char, vector signed char);
17279 vector bool char vec_xor (vector bool char, vector bool char);
17280 vector signed char vec_xor (vector signed char, vector bool char);
17281 vector signed char vec_xor (vector signed char, vector signed char);
17282 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17283 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17284 vector unsigned char vec_xor (vector unsigned char,
17285                               vector unsigned char);
17287 int vec_all_eq (vector signed char, vector bool char);
17288 int vec_all_eq (vector signed char, vector signed char);
17289 int vec_all_eq (vector unsigned char, vector bool char);
17290 int vec_all_eq (vector unsigned char, vector unsigned char);
17291 int vec_all_eq (vector bool char, vector bool char);
17292 int vec_all_eq (vector bool char, vector unsigned char);
17293 int vec_all_eq (vector bool char, vector signed char);
17294 int vec_all_eq (vector signed short, vector bool short);
17295 int vec_all_eq (vector signed short, vector signed short);
17296 int vec_all_eq (vector unsigned short, vector bool short);
17297 int vec_all_eq (vector unsigned short, vector unsigned short);
17298 int vec_all_eq (vector bool short, vector bool short);
17299 int vec_all_eq (vector bool short, vector unsigned short);
17300 int vec_all_eq (vector bool short, vector signed short);
17301 int vec_all_eq (vector pixel, vector pixel);
17302 int vec_all_eq (vector signed int, vector bool int);
17303 int vec_all_eq (vector signed int, vector signed int);
17304 int vec_all_eq (vector unsigned int, vector bool int);
17305 int vec_all_eq (vector unsigned int, vector unsigned int);
17306 int vec_all_eq (vector bool int, vector bool int);
17307 int vec_all_eq (vector bool int, vector unsigned int);
17308 int vec_all_eq (vector bool int, vector signed int);
17309 int vec_all_eq (vector float, vector float);
17311 int vec_all_ge (vector bool char, vector unsigned char);
17312 int vec_all_ge (vector unsigned char, vector bool char);
17313 int vec_all_ge (vector unsigned char, vector unsigned char);
17314 int vec_all_ge (vector bool char, vector signed char);
17315 int vec_all_ge (vector signed char, vector bool char);
17316 int vec_all_ge (vector signed char, vector signed char);
17317 int vec_all_ge (vector bool short, vector unsigned short);
17318 int vec_all_ge (vector unsigned short, vector bool short);
17319 int vec_all_ge (vector unsigned short, vector unsigned short);
17320 int vec_all_ge (vector signed short, vector signed short);
17321 int vec_all_ge (vector bool short, vector signed short);
17322 int vec_all_ge (vector signed short, vector bool short);
17323 int vec_all_ge (vector bool int, vector unsigned int);
17324 int vec_all_ge (vector unsigned int, vector bool int);
17325 int vec_all_ge (vector unsigned int, vector unsigned int);
17326 int vec_all_ge (vector bool int, vector signed int);
17327 int vec_all_ge (vector signed int, vector bool int);
17328 int vec_all_ge (vector signed int, vector signed int);
17329 int vec_all_ge (vector float, vector float);
17331 int vec_all_gt (vector bool char, vector unsigned char);
17332 int vec_all_gt (vector unsigned char, vector bool char);
17333 int vec_all_gt (vector unsigned char, vector unsigned char);
17334 int vec_all_gt (vector bool char, vector signed char);
17335 int vec_all_gt (vector signed char, vector bool char);
17336 int vec_all_gt (vector signed char, vector signed char);
17337 int vec_all_gt (vector bool short, vector unsigned short);
17338 int vec_all_gt (vector unsigned short, vector bool short);
17339 int vec_all_gt (vector unsigned short, vector unsigned short);
17340 int vec_all_gt (vector bool short, vector signed short);
17341 int vec_all_gt (vector signed short, vector bool short);
17342 int vec_all_gt (vector signed short, vector signed short);
17343 int vec_all_gt (vector bool int, vector unsigned int);
17344 int vec_all_gt (vector unsigned int, vector bool int);
17345 int vec_all_gt (vector unsigned int, vector unsigned int);
17346 int vec_all_gt (vector bool int, vector signed int);
17347 int vec_all_gt (vector signed int, vector bool int);
17348 int vec_all_gt (vector signed int, vector signed int);
17349 int vec_all_gt (vector float, vector float);
17351 int vec_all_in (vector float, vector float);
17353 int vec_all_le (vector bool char, vector unsigned char);
17354 int vec_all_le (vector unsigned char, vector bool char);
17355 int vec_all_le (vector unsigned char, vector unsigned char);
17356 int vec_all_le (vector bool char, vector signed char);
17357 int vec_all_le (vector signed char, vector bool char);
17358 int vec_all_le (vector signed char, vector signed char);
17359 int vec_all_le (vector bool short, vector unsigned short);
17360 int vec_all_le (vector unsigned short, vector bool short);
17361 int vec_all_le (vector unsigned short, vector unsigned short);
17362 int vec_all_le (vector bool short, vector signed short);
17363 int vec_all_le (vector signed short, vector bool short);
17364 int vec_all_le (vector signed short, vector signed short);
17365 int vec_all_le (vector bool int, vector unsigned int);
17366 int vec_all_le (vector unsigned int, vector bool int);
17367 int vec_all_le (vector unsigned int, vector unsigned int);
17368 int vec_all_le (vector bool int, vector signed int);
17369 int vec_all_le (vector signed int, vector bool int);
17370 int vec_all_le (vector signed int, vector signed int);
17371 int vec_all_le (vector float, vector float);
17373 int vec_all_lt (vector bool char, vector unsigned char);
17374 int vec_all_lt (vector unsigned char, vector bool char);
17375 int vec_all_lt (vector unsigned char, vector unsigned char);
17376 int vec_all_lt (vector bool char, vector signed char);
17377 int vec_all_lt (vector signed char, vector bool char);
17378 int vec_all_lt (vector signed char, vector signed char);
17379 int vec_all_lt (vector bool short, vector unsigned short);
17380 int vec_all_lt (vector unsigned short, vector bool short);
17381 int vec_all_lt (vector unsigned short, vector unsigned short);
17382 int vec_all_lt (vector bool short, vector signed short);
17383 int vec_all_lt (vector signed short, vector bool short);
17384 int vec_all_lt (vector signed short, vector signed short);
17385 int vec_all_lt (vector bool int, vector unsigned int);
17386 int vec_all_lt (vector unsigned int, vector bool int);
17387 int vec_all_lt (vector unsigned int, vector unsigned int);
17388 int vec_all_lt (vector bool int, vector signed int);
17389 int vec_all_lt (vector signed int, vector bool int);
17390 int vec_all_lt (vector signed int, vector signed int);
17391 int vec_all_lt (vector float, vector float);
17393 int vec_all_nan (vector float);
17395 int vec_all_ne (vector signed char, vector bool char);
17396 int vec_all_ne (vector signed char, vector signed char);
17397 int vec_all_ne (vector unsigned char, vector bool char);
17398 int vec_all_ne (vector unsigned char, vector unsigned char);
17399 int vec_all_ne (vector bool char, vector bool char);
17400 int vec_all_ne (vector bool char, vector unsigned char);
17401 int vec_all_ne (vector bool char, vector signed char);
17402 int vec_all_ne (vector signed short, vector bool short);
17403 int vec_all_ne (vector signed short, vector signed short);
17404 int vec_all_ne (vector unsigned short, vector bool short);
17405 int vec_all_ne (vector unsigned short, vector unsigned short);
17406 int vec_all_ne (vector bool short, vector bool short);
17407 int vec_all_ne (vector bool short, vector unsigned short);
17408 int vec_all_ne (vector bool short, vector signed short);
17409 int vec_all_ne (vector pixel, vector pixel);
17410 int vec_all_ne (vector signed int, vector bool int);
17411 int vec_all_ne (vector signed int, vector signed int);
17412 int vec_all_ne (vector unsigned int, vector bool int);
17413 int vec_all_ne (vector unsigned int, vector unsigned int);
17414 int vec_all_ne (vector bool int, vector bool int);
17415 int vec_all_ne (vector bool int, vector unsigned int);
17416 int vec_all_ne (vector bool int, vector signed int);
17417 int vec_all_ne (vector float, vector float);
17419 int vec_all_nge (vector float, vector float);
17421 int vec_all_ngt (vector float, vector float);
17423 int vec_all_nle (vector float, vector float);
17425 int vec_all_nlt (vector float, vector float);
17427 int vec_all_numeric (vector float);
17429 int vec_any_eq (vector signed char, vector bool char);
17430 int vec_any_eq (vector signed char, vector signed char);
17431 int vec_any_eq (vector unsigned char, vector bool char);
17432 int vec_any_eq (vector unsigned char, vector unsigned char);
17433 int vec_any_eq (vector bool char, vector bool char);
17434 int vec_any_eq (vector bool char, vector unsigned char);
17435 int vec_any_eq (vector bool char, vector signed char);
17436 int vec_any_eq (vector signed short, vector bool short);
17437 int vec_any_eq (vector signed short, vector signed short);
17438 int vec_any_eq (vector unsigned short, vector bool short);
17439 int vec_any_eq (vector unsigned short, vector unsigned short);
17440 int vec_any_eq (vector bool short, vector bool short);
17441 int vec_any_eq (vector bool short, vector unsigned short);
17442 int vec_any_eq (vector bool short, vector signed short);
17443 int vec_any_eq (vector pixel, vector pixel);
17444 int vec_any_eq (vector signed int, vector bool int);
17445 int vec_any_eq (vector signed int, vector signed int);
17446 int vec_any_eq (vector unsigned int, vector bool int);
17447 int vec_any_eq (vector unsigned int, vector unsigned int);
17448 int vec_any_eq (vector bool int, vector bool int);
17449 int vec_any_eq (vector bool int, vector unsigned int);
17450 int vec_any_eq (vector bool int, vector signed int);
17451 int vec_any_eq (vector float, vector float);
17453 int vec_any_ge (vector signed char, vector bool char);
17454 int vec_any_ge (vector unsigned char, vector bool char);
17455 int vec_any_ge (vector unsigned char, vector unsigned char);
17456 int vec_any_ge (vector signed char, vector signed char);
17457 int vec_any_ge (vector bool char, vector unsigned char);
17458 int vec_any_ge (vector bool char, vector signed char);
17459 int vec_any_ge (vector unsigned short, vector bool short);
17460 int vec_any_ge (vector unsigned short, vector unsigned short);
17461 int vec_any_ge (vector signed short, vector signed short);
17462 int vec_any_ge (vector signed short, vector bool short);
17463 int vec_any_ge (vector bool short, vector unsigned short);
17464 int vec_any_ge (vector bool short, vector signed short);
17465 int vec_any_ge (vector signed int, vector bool int);
17466 int vec_any_ge (vector unsigned int, vector bool int);
17467 int vec_any_ge (vector unsigned int, vector unsigned int);
17468 int vec_any_ge (vector signed int, vector signed int);
17469 int vec_any_ge (vector bool int, vector unsigned int);
17470 int vec_any_ge (vector bool int, vector signed int);
17471 int vec_any_ge (vector float, vector float);
17473 int vec_any_gt (vector bool char, vector unsigned char);
17474 int vec_any_gt (vector unsigned char, vector bool char);
17475 int vec_any_gt (vector unsigned char, vector unsigned char);
17476 int vec_any_gt (vector bool char, vector signed char);
17477 int vec_any_gt (vector signed char, vector bool char);
17478 int vec_any_gt (vector signed char, vector signed char);
17479 int vec_any_gt (vector bool short, vector unsigned short);
17480 int vec_any_gt (vector unsigned short, vector bool short);
17481 int vec_any_gt (vector unsigned short, vector unsigned short);
17482 int vec_any_gt (vector bool short, vector signed short);
17483 int vec_any_gt (vector signed short, vector bool short);
17484 int vec_any_gt (vector signed short, vector signed short);
17485 int vec_any_gt (vector bool int, vector unsigned int);
17486 int vec_any_gt (vector unsigned int, vector bool int);
17487 int vec_any_gt (vector unsigned int, vector unsigned int);
17488 int vec_any_gt (vector bool int, vector signed int);
17489 int vec_any_gt (vector signed int, vector bool int);
17490 int vec_any_gt (vector signed int, vector signed int);
17491 int vec_any_gt (vector float, vector float);
17493 int vec_any_le (vector bool char, vector unsigned char);
17494 int vec_any_le (vector unsigned char, vector bool char);
17495 int vec_any_le (vector unsigned char, vector unsigned char);
17496 int vec_any_le (vector bool char, vector signed char);
17497 int vec_any_le (vector signed char, vector bool char);
17498 int vec_any_le (vector signed char, vector signed char);
17499 int vec_any_le (vector bool short, vector unsigned short);
17500 int vec_any_le (vector unsigned short, vector bool short);
17501 int vec_any_le (vector unsigned short, vector unsigned short);
17502 int vec_any_le (vector bool short, vector signed short);
17503 int vec_any_le (vector signed short, vector bool short);
17504 int vec_any_le (vector signed short, vector signed short);
17505 int vec_any_le (vector bool int, vector unsigned int);
17506 int vec_any_le (vector unsigned int, vector bool int);
17507 int vec_any_le (vector unsigned int, vector unsigned int);
17508 int vec_any_le (vector bool int, vector signed int);
17509 int vec_any_le (vector signed int, vector bool int);
17510 int vec_any_le (vector signed int, vector signed int);
17511 int vec_any_le (vector float, vector float);
17513 int vec_any_lt (vector bool char, vector unsigned char);
17514 int vec_any_lt (vector unsigned char, vector bool char);
17515 int vec_any_lt (vector unsigned char, vector unsigned char);
17516 int vec_any_lt (vector bool char, vector signed char);
17517 int vec_any_lt (vector signed char, vector bool char);
17518 int vec_any_lt (vector signed char, vector signed char);
17519 int vec_any_lt (vector bool short, vector unsigned short);
17520 int vec_any_lt (vector unsigned short, vector bool short);
17521 int vec_any_lt (vector unsigned short, vector unsigned short);
17522 int vec_any_lt (vector bool short, vector signed short);
17523 int vec_any_lt (vector signed short, vector bool short);
17524 int vec_any_lt (vector signed short, vector signed short);
17525 int vec_any_lt (vector bool int, vector unsigned int);
17526 int vec_any_lt (vector unsigned int, vector bool int);
17527 int vec_any_lt (vector unsigned int, vector unsigned int);
17528 int vec_any_lt (vector bool int, vector signed int);
17529 int vec_any_lt (vector signed int, vector bool int);
17530 int vec_any_lt (vector signed int, vector signed int);
17531 int vec_any_lt (vector float, vector float);
17533 int vec_any_nan (vector float);
17535 int vec_any_ne (vector signed char, vector bool char);
17536 int vec_any_ne (vector signed char, vector signed char);
17537 int vec_any_ne (vector unsigned char, vector bool char);
17538 int vec_any_ne (vector unsigned char, vector unsigned char);
17539 int vec_any_ne (vector bool char, vector bool char);
17540 int vec_any_ne (vector bool char, vector unsigned char);
17541 int vec_any_ne (vector bool char, vector signed char);
17542 int vec_any_ne (vector signed short, vector bool short);
17543 int vec_any_ne (vector signed short, vector signed short);
17544 int vec_any_ne (vector unsigned short, vector bool short);
17545 int vec_any_ne (vector unsigned short, vector unsigned short);
17546 int vec_any_ne (vector bool short, vector bool short);
17547 int vec_any_ne (vector bool short, vector unsigned short);
17548 int vec_any_ne (vector bool short, vector signed short);
17549 int vec_any_ne (vector pixel, vector pixel);
17550 int vec_any_ne (vector signed int, vector bool int);
17551 int vec_any_ne (vector signed int, vector signed int);
17552 int vec_any_ne (vector unsigned int, vector bool int);
17553 int vec_any_ne (vector unsigned int, vector unsigned int);
17554 int vec_any_ne (vector bool int, vector bool int);
17555 int vec_any_ne (vector bool int, vector unsigned int);
17556 int vec_any_ne (vector bool int, vector signed int);
17557 int vec_any_ne (vector float, vector float);
17559 int vec_any_nge (vector float, vector float);
17561 int vec_any_ngt (vector float, vector float);
17563 int vec_any_nle (vector float, vector float);
17565 int vec_any_nlt (vector float, vector float);
17567 int vec_any_numeric (vector float);
17569 int vec_any_out (vector float, vector float);
17570 @end smallexample
17572 If the vector/scalar (VSX) instruction set is available, the following
17573 additional functions are available:
17575 @smallexample
17576 vector double vec_abs (vector double);
17577 vector double vec_add (vector double, vector double);
17578 vector double vec_and (vector double, vector double);
17579 vector double vec_and (vector double, vector bool long);
17580 vector double vec_and (vector bool long, vector double);
17581 vector long vec_and (vector long, vector long);
17582 vector long vec_and (vector long, vector bool long);
17583 vector long vec_and (vector bool long, vector long);
17584 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17585 vector unsigned long vec_and (vector unsigned long, vector bool long);
17586 vector unsigned long vec_and (vector bool long, vector unsigned long);
17587 vector double vec_andc (vector double, vector double);
17588 vector double vec_andc (vector double, vector bool long);
17589 vector double vec_andc (vector bool long, vector double);
17590 vector long vec_andc (vector long, vector long);
17591 vector long vec_andc (vector long, vector bool long);
17592 vector long vec_andc (vector bool long, vector long);
17593 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17594 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17595 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17596 vector double vec_ceil (vector double);
17597 vector bool long vec_cmpeq (vector double, vector double);
17598 vector bool long vec_cmpge (vector double, vector double);
17599 vector bool long vec_cmpgt (vector double, vector double);
17600 vector bool long vec_cmple (vector double, vector double);
17601 vector bool long vec_cmplt (vector double, vector double);
17602 vector double vec_cpsgn (vector double, vector double);
17603 vector float vec_div (vector float, vector float);
17604 vector double vec_div (vector double, vector double);
17605 vector long vec_div (vector long, vector long);
17606 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17607 vector double vec_floor (vector double);
17608 vector double vec_ld (int, const vector double *);
17609 vector double vec_ld (int, const double *);
17610 vector double vec_ldl (int, const vector double *);
17611 vector double vec_ldl (int, const double *);
17612 vector unsigned char vec_lvsl (int, const volatile double *);
17613 vector unsigned char vec_lvsr (int, const volatile double *);
17614 vector double vec_madd (vector double, vector double, vector double);
17615 vector double vec_max (vector double, vector double);
17616 vector signed long vec_mergeh (vector signed long, vector signed long);
17617 vector signed long vec_mergeh (vector signed long, vector bool long);
17618 vector signed long vec_mergeh (vector bool long, vector signed long);
17619 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17620 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17621 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17622 vector signed long vec_mergel (vector signed long, vector signed long);
17623 vector signed long vec_mergel (vector signed long, vector bool long);
17624 vector signed long vec_mergel (vector bool long, vector signed long);
17625 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17626 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17627 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17628 vector double vec_min (vector double, vector double);
17629 vector float vec_msub (vector float, vector float, vector float);
17630 vector double vec_msub (vector double, vector double, vector double);
17631 vector float vec_mul (vector float, vector float);
17632 vector double vec_mul (vector double, vector double);
17633 vector long vec_mul (vector long, vector long);
17634 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17635 vector float vec_nearbyint (vector float);
17636 vector double vec_nearbyint (vector double);
17637 vector float vec_nmadd (vector float, vector float, vector float);
17638 vector double vec_nmadd (vector double, vector double, vector double);
17639 vector double vec_nmsub (vector double, vector double, vector double);
17640 vector double vec_nor (vector double, vector double);
17641 vector long vec_nor (vector long, vector long);
17642 vector long vec_nor (vector long, vector bool long);
17643 vector long vec_nor (vector bool long, vector long);
17644 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17645 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17646 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17647 vector double vec_or (vector double, vector double);
17648 vector double vec_or (vector double, vector bool long);
17649 vector double vec_or (vector bool long, vector double);
17650 vector long vec_or (vector long, vector long);
17651 vector long vec_or (vector long, vector bool long);
17652 vector long vec_or (vector bool long, vector long);
17653 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17654 vector unsigned long vec_or (vector unsigned long, vector bool long);
17655 vector unsigned long vec_or (vector bool long, vector unsigned long);
17656 vector double vec_perm (vector double, vector double, vector unsigned char);
17657 vector long vec_perm (vector long, vector long, vector unsigned char);
17658 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17659                                vector unsigned char);
17660 vector double vec_rint (vector double);
17661 vector double vec_recip (vector double, vector double);
17662 vector double vec_rsqrt (vector double);
17663 vector double vec_rsqrte (vector double);
17664 vector double vec_sel (vector double, vector double, vector bool long);
17665 vector double vec_sel (vector double, vector double, vector unsigned long);
17666 vector long vec_sel (vector long, vector long, vector long);
17667 vector long vec_sel (vector long, vector long, vector unsigned long);
17668 vector long vec_sel (vector long, vector long, vector bool long);
17669 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17670                               vector long);
17671 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17672                               vector unsigned long);
17673 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17674                               vector bool long);
17675 vector double vec_splats (double);
17676 vector signed long vec_splats (signed long);
17677 vector unsigned long vec_splats (unsigned long);
17678 vector float vec_sqrt (vector float);
17679 vector double vec_sqrt (vector double);
17680 void vec_st (vector double, int, vector double *);
17681 void vec_st (vector double, int, double *);
17682 vector double vec_sub (vector double, vector double);
17683 vector double vec_trunc (vector double);
17684 vector double vec_xl (int, vector double *);
17685 vector double vec_xl (int, double *);
17686 vector long long vec_xl (int, vector long long *);
17687 vector long long vec_xl (int, long long *);
17688 vector unsigned long long vec_xl (int, vector unsigned long long *);
17689 vector unsigned long long vec_xl (int, unsigned long long *);
17690 vector float vec_xl (int, vector float *);
17691 vector float vec_xl (int, float *);
17692 vector int vec_xl (int, vector int *);
17693 vector int vec_xl (int, int *);
17694 vector unsigned int vec_xl (int, vector unsigned int *);
17695 vector unsigned int vec_xl (int, unsigned int *);
17696 vector double vec_xor (vector double, vector double);
17697 vector double vec_xor (vector double, vector bool long);
17698 vector double vec_xor (vector bool long, vector double);
17699 vector long vec_xor (vector long, vector long);
17700 vector long vec_xor (vector long, vector bool long);
17701 vector long vec_xor (vector bool long, vector long);
17702 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17703 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17704 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17705 void vec_xst (vector double, int, vector double *);
17706 void vec_xst (vector double, int, double *);
17707 void vec_xst (vector long long, int, vector long long *);
17708 void vec_xst (vector long long, int, long long *);
17709 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17710 void vec_xst (vector unsigned long long, int, unsigned long long *);
17711 void vec_xst (vector float, int, vector float *);
17712 void vec_xst (vector float, int, float *);
17713 void vec_xst (vector int, int, vector int *);
17714 void vec_xst (vector int, int, int *);
17715 void vec_xst (vector unsigned int, int, vector unsigned int *);
17716 void vec_xst (vector unsigned int, int, unsigned int *);
17717 int vec_all_eq (vector double, vector double);
17718 int vec_all_ge (vector double, vector double);
17719 int vec_all_gt (vector double, vector double);
17720 int vec_all_le (vector double, vector double);
17721 int vec_all_lt (vector double, vector double);
17722 int vec_all_nan (vector double);
17723 int vec_all_ne (vector double, vector double);
17724 int vec_all_nge (vector double, vector double);
17725 int vec_all_ngt (vector double, vector double);
17726 int vec_all_nle (vector double, vector double);
17727 int vec_all_nlt (vector double, vector double);
17728 int vec_all_numeric (vector double);
17729 int vec_any_eq (vector double, vector double);
17730 int vec_any_ge (vector double, vector double);
17731 int vec_any_gt (vector double, vector double);
17732 int vec_any_le (vector double, vector double);
17733 int vec_any_lt (vector double, vector double);
17734 int vec_any_nan (vector double);
17735 int vec_any_ne (vector double, vector double);
17736 int vec_any_nge (vector double, vector double);
17737 int vec_any_ngt (vector double, vector double);
17738 int vec_any_nle (vector double, vector double);
17739 int vec_any_nlt (vector double, vector double);
17740 int vec_any_numeric (vector double);
17742 vector double vec_vsx_ld (int, const vector double *);
17743 vector double vec_vsx_ld (int, const double *);
17744 vector float vec_vsx_ld (int, const vector float *);
17745 vector float vec_vsx_ld (int, const float *);
17746 vector bool int vec_vsx_ld (int, const vector bool int *);
17747 vector signed int vec_vsx_ld (int, const vector signed int *);
17748 vector signed int vec_vsx_ld (int, const int *);
17749 vector signed int vec_vsx_ld (int, const long *);
17750 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17751 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17752 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17753 vector bool short vec_vsx_ld (int, const vector bool short *);
17754 vector pixel vec_vsx_ld (int, const vector pixel *);
17755 vector signed short vec_vsx_ld (int, const vector signed short *);
17756 vector signed short vec_vsx_ld (int, const short *);
17757 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17758 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17759 vector bool char vec_vsx_ld (int, const vector bool char *);
17760 vector signed char vec_vsx_ld (int, const vector signed char *);
17761 vector signed char vec_vsx_ld (int, const signed char *);
17762 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17763 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17765 void vec_vsx_st (vector double, int, vector double *);
17766 void vec_vsx_st (vector double, int, double *);
17767 void vec_vsx_st (vector float, int, vector float *);
17768 void vec_vsx_st (vector float, int, float *);
17769 void vec_vsx_st (vector signed int, int, vector signed int *);
17770 void vec_vsx_st (vector signed int, int, int *);
17771 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17772 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17773 void vec_vsx_st (vector bool int, int, vector bool int *);
17774 void vec_vsx_st (vector bool int, int, unsigned int *);
17775 void vec_vsx_st (vector bool int, int, int *);
17776 void vec_vsx_st (vector signed short, int, vector signed short *);
17777 void vec_vsx_st (vector signed short, int, short *);
17778 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17779 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17780 void vec_vsx_st (vector bool short, int, vector bool short *);
17781 void vec_vsx_st (vector bool short, int, unsigned short *);
17782 void vec_vsx_st (vector pixel, int, vector pixel *);
17783 void vec_vsx_st (vector pixel, int, unsigned short *);
17784 void vec_vsx_st (vector pixel, int, short *);
17785 void vec_vsx_st (vector bool short, int, short *);
17786 void vec_vsx_st (vector signed char, int, vector signed char *);
17787 void vec_vsx_st (vector signed char, int, signed char *);
17788 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17789 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17790 void vec_vsx_st (vector bool char, int, vector bool char *);
17791 void vec_vsx_st (vector bool char, int, unsigned char *);
17792 void vec_vsx_st (vector bool char, int, signed char *);
17794 vector double vec_xxpermdi (vector double, vector double, const int);
17795 vector float vec_xxpermdi (vector float, vector float, const int);
17796 vector long long vec_xxpermdi (vector long long, vector long long, const int);
17797 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17798                                         vector unsigned long long, const int);
17799 vector int vec_xxpermdi (vector int, vector int, const int);
17800 vector unsigned int vec_xxpermdi (vector unsigned int,
17801                                   vector unsigned int, const int);
17802 vector short vec_xxpermdi (vector short, vector short, const int);
17803 vector unsigned short vec_xxpermdi (vector unsigned short,
17804                                     vector unsigned short, const int);
17805 vector signed char vec_xxpermdi (vector signed char, vector signed char,
17806                                  const int);
17807 vector unsigned char vec_xxpermdi (vector unsigned char,
17808                                    vector unsigned char, const int);
17810 vector double vec_xxsldi (vector double, vector double, int);
17811 vector float vec_xxsldi (vector float, vector float, int);
17812 vector long long vec_xxsldi (vector long long, vector long long, int);
17813 vector unsigned long long vec_xxsldi (vector unsigned long long,
17814                                       vector unsigned long long, int);
17815 vector int vec_xxsldi (vector int, vector int, int);
17816 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17817 vector short vec_xxsldi (vector short, vector short, int);
17818 vector unsigned short vec_xxsldi (vector unsigned short,
17819                                   vector unsigned short, int);
17820 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17821 vector unsigned char vec_xxsldi (vector unsigned char,
17822                                  vector unsigned char, int);
17823 @end smallexample
17825 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17826 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17827 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
17828 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17829 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17831 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17832 instruction set are available, the following additional functions are
17833 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
17834 can use @var{vector long} instead of @var{vector long long},
17835 @var{vector bool long} instead of @var{vector bool long long}, and
17836 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17838 @smallexample
17839 vector long long vec_abs (vector long long);
17841 vector long long vec_add (vector long long, vector long long);
17842 vector unsigned long long vec_add (vector unsigned long long,
17843                                    vector unsigned long long);
17845 int vec_all_eq (vector long long, vector long long);
17846 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17847 int vec_all_ge (vector long long, vector long long);
17848 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17849 int vec_all_gt (vector long long, vector long long);
17850 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17851 int vec_all_le (vector long long, vector long long);
17852 int vec_all_le (vector unsigned long long, vector unsigned long long);
17853 int vec_all_lt (vector long long, vector long long);
17854 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17855 int vec_all_ne (vector long long, vector long long);
17856 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17858 int vec_any_eq (vector long long, vector long long);
17859 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17860 int vec_any_ge (vector long long, vector long long);
17861 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17862 int vec_any_gt (vector long long, vector long long);
17863 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17864 int vec_any_le (vector long long, vector long long);
17865 int vec_any_le (vector unsigned long long, vector unsigned long long);
17866 int vec_any_lt (vector long long, vector long long);
17867 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17868 int vec_any_ne (vector long long, vector long long);
17869 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17871 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
17873 vector long long vec_eqv (vector long long, vector long long);
17874 vector long long vec_eqv (vector bool long long, vector long long);
17875 vector long long vec_eqv (vector long long, vector bool long long);
17876 vector unsigned long long vec_eqv (vector unsigned long long,
17877                                    vector unsigned long long);
17878 vector unsigned long long vec_eqv (vector bool long long,
17879                                    vector unsigned long long);
17880 vector unsigned long long vec_eqv (vector unsigned long long,
17881                                    vector bool long long);
17882 vector int vec_eqv (vector int, vector int);
17883 vector int vec_eqv (vector bool int, vector int);
17884 vector int vec_eqv (vector int, vector bool int);
17885 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17886 vector unsigned int vec_eqv (vector bool unsigned int,
17887                              vector unsigned int);
17888 vector unsigned int vec_eqv (vector unsigned int,
17889                              vector bool unsigned int);
17890 vector short vec_eqv (vector short, vector short);
17891 vector short vec_eqv (vector bool short, vector short);
17892 vector short vec_eqv (vector short, vector bool short);
17893 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17894 vector unsigned short vec_eqv (vector bool unsigned short,
17895                                vector unsigned short);
17896 vector unsigned short vec_eqv (vector unsigned short,
17897                                vector bool unsigned short);
17898 vector signed char vec_eqv (vector signed char, vector signed char);
17899 vector signed char vec_eqv (vector bool signed char, vector signed char);
17900 vector signed char vec_eqv (vector signed char, vector bool signed char);
17901 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17902 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17903 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17905 vector long long vec_max (vector long long, vector long long);
17906 vector unsigned long long vec_max (vector unsigned long long,
17907                                    vector unsigned long long);
17909 vector signed int vec_mergee (vector signed int, vector signed int);
17910 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17911 vector bool int vec_mergee (vector bool int, vector bool int);
17913 vector signed int vec_mergeo (vector signed int, vector signed int);
17914 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17915 vector bool int vec_mergeo (vector bool int, vector bool int);
17917 vector long long vec_min (vector long long, vector long long);
17918 vector unsigned long long vec_min (vector unsigned long long,
17919                                    vector unsigned long long);
17921 vector signed long long vec_nabs (vector signed long long);
17923 vector long long vec_nand (vector long long, vector long long);
17924 vector long long vec_nand (vector bool long long, vector long long);
17925 vector long long vec_nand (vector long long, vector bool long long);
17926 vector unsigned long long vec_nand (vector unsigned long long,
17927                                     vector unsigned long long);
17928 vector unsigned long long vec_nand (vector bool long long,
17929                                    vector unsigned long long);
17930 vector unsigned long long vec_nand (vector unsigned long long,
17931                                     vector bool long long);
17932 vector int vec_nand (vector int, vector int);
17933 vector int vec_nand (vector bool int, vector int);
17934 vector int vec_nand (vector int, vector bool int);
17935 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17936 vector unsigned int vec_nand (vector bool unsigned int,
17937                               vector unsigned int);
17938 vector unsigned int vec_nand (vector unsigned int,
17939                               vector bool unsigned int);
17940 vector short vec_nand (vector short, vector short);
17941 vector short vec_nand (vector bool short, vector short);
17942 vector short vec_nand (vector short, vector bool short);
17943 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17944 vector unsigned short vec_nand (vector bool unsigned short,
17945                                 vector unsigned short);
17946 vector unsigned short vec_nand (vector unsigned short,
17947                                 vector bool unsigned short);
17948 vector signed char vec_nand (vector signed char, vector signed char);
17949 vector signed char vec_nand (vector bool signed char, vector signed char);
17950 vector signed char vec_nand (vector signed char, vector bool signed char);
17951 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17952 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17953 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17955 vector long long vec_orc (vector long long, vector long long);
17956 vector long long vec_orc (vector bool long long, vector long long);
17957 vector long long vec_orc (vector long long, vector bool long long);
17958 vector unsigned long long vec_orc (vector unsigned long long,
17959                                    vector unsigned long long);
17960 vector unsigned long long vec_orc (vector bool long long,
17961                                    vector unsigned long long);
17962 vector unsigned long long vec_orc (vector unsigned long long,
17963                                    vector bool long long);
17964 vector int vec_orc (vector int, vector int);
17965 vector int vec_orc (vector bool int, vector int);
17966 vector int vec_orc (vector int, vector bool int);
17967 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17968 vector unsigned int vec_orc (vector bool unsigned int,
17969                              vector unsigned int);
17970 vector unsigned int vec_orc (vector unsigned int,
17971                              vector bool unsigned int);
17972 vector short vec_orc (vector short, vector short);
17973 vector short vec_orc (vector bool short, vector short);
17974 vector short vec_orc (vector short, vector bool short);
17975 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17976 vector unsigned short vec_orc (vector bool unsigned short,
17977                                vector unsigned short);
17978 vector unsigned short vec_orc (vector unsigned short,
17979                                vector bool unsigned short);
17980 vector signed char vec_orc (vector signed char, vector signed char);
17981 vector signed char vec_orc (vector bool signed char, vector signed char);
17982 vector signed char vec_orc (vector signed char, vector bool signed char);
17983 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17984 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17985 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17987 vector int vec_pack (vector long long, vector long long);
17988 vector unsigned int vec_pack (vector unsigned long long,
17989                               vector unsigned long long);
17990 vector bool int vec_pack (vector bool long long, vector bool long long);
17991 vector float vec_pack (vector double, vector double);
17993 vector int vec_packs (vector long long, vector long long);
17994 vector unsigned int vec_packs (vector unsigned long long,
17995                                vector unsigned long long);
17997 vector unsigned int vec_packsu (vector long long, vector long long);
17998 vector unsigned int vec_packsu (vector unsigned long long,
17999                                 vector unsigned long long);
18001 vector unsigned char vec_popcnt (vector signed char);
18002 vector unsigned char vec_popcnt (vector unsigned char);
18003 vector unsigned short vec_popcnt (vector signed short);
18004 vector unsigned short vec_popcnt (vector unsigned short);
18005 vector unsigned int vec_popcnt (vector signed int);
18006 vector unsigned int vec_popcnt (vector unsigned int);
18007 vector unsigned long long vec_popcnt (vector signed long long);
18008 vector unsigned long long vec_popcnt (vector unsigned long long);
18010 vector long long vec_rl (vector long long,
18011                          vector unsigned long long);
18012 vector long long vec_rl (vector unsigned long long,
18013                          vector unsigned long long);
18015 vector long long vec_sl (vector long long, vector unsigned long long);
18016 vector long long vec_sl (vector unsigned long long,
18017                          vector unsigned long long);
18019 vector long long vec_sr (vector long long, vector unsigned long long);
18020 vector unsigned long long char vec_sr (vector unsigned long long,
18021                                        vector unsigned long long);
18023 vector long long vec_sra (vector long long, vector unsigned long long);
18024 vector unsigned long long vec_sra (vector unsigned long long,
18025                                    vector unsigned long long);
18027 vector long long vec_sub (vector long long, vector long long);
18028 vector unsigned long long vec_sub (vector unsigned long long,
18029                                    vector unsigned long long);
18031 vector long long vec_unpackh (vector int);
18032 vector unsigned long long vec_unpackh (vector unsigned int);
18034 vector long long vec_unpackl (vector int);
18035 vector unsigned long long vec_unpackl (vector unsigned int);
18037 vector long long vec_vaddudm (vector long long, vector long long);
18038 vector long long vec_vaddudm (vector bool long long, vector long long);
18039 vector long long vec_vaddudm (vector long long, vector bool long long);
18040 vector unsigned long long vec_vaddudm (vector unsigned long long,
18041                                        vector unsigned long long);
18042 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18043                                        vector unsigned long long);
18044 vector unsigned long long vec_vaddudm (vector unsigned long long,
18045                                        vector bool unsigned long long);
18047 vector long long vec_vbpermq (vector signed char, vector signed char);
18048 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18050 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18051 vector unsigned char vec_bperm (vector unsigned long long,
18052                                 vector unsigned char);
18053 vector unsigned long long vec_bperm (vector unsigned __int128,
18054                                      vector unsigned char);
18056 vector long long vec_cntlz (vector long long);
18057 vector unsigned long long vec_cntlz (vector unsigned long long);
18058 vector int vec_cntlz (vector int);
18059 vector unsigned int vec_cntlz (vector int);
18060 vector short vec_cntlz (vector short);
18061 vector unsigned short vec_cntlz (vector unsigned short);
18062 vector signed char vec_cntlz (vector signed char);
18063 vector unsigned char vec_cntlz (vector unsigned char);
18065 vector long long vec_vclz (vector long long);
18066 vector unsigned long long vec_vclz (vector unsigned long long);
18067 vector int vec_vclz (vector int);
18068 vector unsigned int vec_vclz (vector int);
18069 vector short vec_vclz (vector short);
18070 vector unsigned short vec_vclz (vector unsigned short);
18071 vector signed char vec_vclz (vector signed char);
18072 vector unsigned char vec_vclz (vector unsigned char);
18074 vector signed char vec_vclzb (vector signed char);
18075 vector unsigned char vec_vclzb (vector unsigned char);
18077 vector long long vec_vclzd (vector long long);
18078 vector unsigned long long vec_vclzd (vector unsigned long long);
18080 vector short vec_vclzh (vector short);
18081 vector unsigned short vec_vclzh (vector unsigned short);
18083 vector int vec_vclzw (vector int);
18084 vector unsigned int vec_vclzw (vector int);
18086 vector signed char vec_vgbbd (vector signed char);
18087 vector unsigned char vec_vgbbd (vector unsigned char);
18089 vector long long vec_vmaxsd (vector long long, vector long long);
18091 vector unsigned long long vec_vmaxud (vector unsigned long long,
18092                                       unsigned vector long long);
18094 vector long long vec_vminsd (vector long long, vector long long);
18096 vector unsigned long long vec_vminud (vector long long,
18097                                       vector long long);
18099 vector int vec_vpksdss (vector long long, vector long long);
18100 vector unsigned int vec_vpksdss (vector long long, vector long long);
18102 vector unsigned int vec_vpkudus (vector unsigned long long,
18103                                  vector unsigned long long);
18105 vector int vec_vpkudum (vector long long, vector long long);
18106 vector unsigned int vec_vpkudum (vector unsigned long long,
18107                                  vector unsigned long long);
18108 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18110 vector long long vec_vpopcnt (vector long long);
18111 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18112 vector int vec_vpopcnt (vector int);
18113 vector unsigned int vec_vpopcnt (vector int);
18114 vector short vec_vpopcnt (vector short);
18115 vector unsigned short vec_vpopcnt (vector unsigned short);
18116 vector signed char vec_vpopcnt (vector signed char);
18117 vector unsigned char vec_vpopcnt (vector unsigned char);
18119 vector signed char vec_vpopcntb (vector signed char);
18120 vector unsigned char vec_vpopcntb (vector unsigned char);
18122 vector long long vec_vpopcntd (vector long long);
18123 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18125 vector short vec_vpopcnth (vector short);
18126 vector unsigned short vec_vpopcnth (vector unsigned short);
18128 vector int vec_vpopcntw (vector int);
18129 vector unsigned int vec_vpopcntw (vector int);
18131 vector long long vec_vrld (vector long long, vector unsigned long long);
18132 vector unsigned long long vec_vrld (vector unsigned long long,
18133                                     vector unsigned long long);
18135 vector long long vec_vsld (vector long long, vector unsigned long long);
18136 vector long long vec_vsld (vector unsigned long long,
18137                            vector unsigned long long);
18139 vector long long vec_vsrad (vector long long, vector unsigned long long);
18140 vector unsigned long long vec_vsrad (vector unsigned long long,
18141                                      vector unsigned long long);
18143 vector long long vec_vsrd (vector long long, vector unsigned long long);
18144 vector unsigned long long char vec_vsrd (vector unsigned long long,
18145                                          vector unsigned long long);
18147 vector long long vec_vsubudm (vector long long, vector long long);
18148 vector long long vec_vsubudm (vector bool long long, vector long long);
18149 vector long long vec_vsubudm (vector long long, vector bool long long);
18150 vector unsigned long long vec_vsubudm (vector unsigned long long,
18151                                        vector unsigned long long);
18152 vector unsigned long long vec_vsubudm (vector bool long long,
18153                                        vector unsigned long long);
18154 vector unsigned long long vec_vsubudm (vector unsigned long long,
18155                                        vector bool long long);
18157 vector long long vec_vupkhsw (vector int);
18158 vector unsigned long long vec_vupkhsw (vector unsigned int);
18160 vector long long vec_vupklsw (vector int);
18161 vector unsigned long long vec_vupklsw (vector int);
18162 @end smallexample
18164 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18165 instruction set are available, the following additional functions are
18166 available for 64-bit targets.  New vector types
18167 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18168 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18169 builtins.
18171 The normal vector extract, and set operations work on
18172 @var{vector __int128_t} and @var{vector __uint128_t} types,
18173 but the index value must be 0.
18175 @smallexample
18176 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18177 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18179 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18180 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18182 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18183                                 vector __int128_t);
18184 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18185                                  vector __uint128_t);
18187 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18188                                 vector __int128_t);
18189 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18190                                  vector __uint128_t);
18192 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18193                                 vector __int128_t);
18194 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18195                                  vector __uint128_t);
18197 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18198                                 vector __int128_t);
18199 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18200                                  vector __uint128_t);
18202 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18203 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18205 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18206 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18208 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
18209 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
18210 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
18211 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
18212 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
18213 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
18214 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
18215 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
18216 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
18217 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
18218 @end smallexample
18220 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18221 are available:
18223 @smallexample
18224 vector unsigned long long vec_bperm (vector unsigned long long,
18225                                      vector unsigned char);
18227 vector bool char vec_cmpne (vector bool char, vector bool char);
18228 vector bool short vec_cmpne (vector bool short, vector bool short);
18229 vector bool int vec_cmpne (vector bool int, vector bool int);
18230 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18232 vector long long vec_vctz (vector long long);
18233 vector unsigned long long vec_vctz (vector unsigned long long);
18234 vector int vec_vctz (vector int);
18235 vector unsigned int vec_vctz (vector int);
18236 vector short vec_vctz (vector short);
18237 vector unsigned short vec_vctz (vector unsigned short);
18238 vector signed char vec_vctz (vector signed char);
18239 vector unsigned char vec_vctz (vector unsigned char);
18241 vector signed char vec_vctzb (vector signed char);
18242 vector unsigned char vec_vctzb (vector unsigned char);
18244 vector long long vec_vctzd (vector long long);
18245 vector unsigned long long vec_vctzd (vector unsigned long long);
18247 vector short vec_vctzh (vector short);
18248 vector unsigned short vec_vctzh (vector unsigned short);
18250 vector int vec_vctzw (vector int);
18251 vector unsigned int vec_vctzw (vector int);
18253 long long vec_vextract4b (const vector signed char, const int);
18254 long long vec_vextract4b (const vector unsigned char, const int);
18256 vector signed char vec_insert4b (vector int, vector signed char, const int);
18257 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18258                                    const int);
18259 vector signed char vec_insert4b (long long, vector signed char, const int);
18260 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
18262 vector int vec_vprtyb (vector int);
18263 vector unsigned int vec_vprtyb (vector unsigned int);
18264 vector long long vec_vprtyb (vector long long);
18265 vector unsigned long long vec_vprtyb (vector unsigned long long);
18267 vector int vec_vprtybw (vector int);
18268 vector unsigned int vec_vprtybw (vector unsigned int);
18270 vector long long vec_vprtybd (vector long long);
18271 vector unsigned long long vec_vprtybd (vector unsigned long long);
18272 @end smallexample
18274 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18275 are available:
18277 @smallexample
18278 vector long vec_vprtyb (vector long);
18279 vector unsigned long vec_vprtyb (vector unsigned long);
18280 vector __int128_t vec_vprtyb (vector __int128_t);
18281 vector __uint128_t vec_vprtyb (vector __uint128_t);
18283 vector long vec_vprtybd (vector long);
18284 vector unsigned long vec_vprtybd (vector unsigned long);
18286 vector __int128_t vec_vprtybq (vector __int128_t);
18287 vector __uint128_t vec_vprtybd (vector __uint128_t);
18288 @end smallexample
18290 The following built-in vector functions are available for the PowerPC family
18291 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18292 @smallexample
18293 __vector unsigned char
18294 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18295 __vector unsigned char
18296 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18297 @end smallexample
18299 The @code{vec_slv} and @code{vec_srv} functions operate on
18300 all of the bytes of their @code{src} and @code{shift_distance}
18301 arguments in parallel.  The behavior of the @code{vec_slv} is as if
18302 there existed a temporary array of 17 unsigned characters
18303 @code{slv_array} within which elements 0 through 15 are the same as
18304 the entries in the @code{src} array and element 16 equals 0.  The
18305 result returned from the @code{vec_slv} function is a
18306 @code{__vector} of 16 unsigned characters within which element
18307 @code{i} is computed using the C expression
18308 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18309 shift_distance[i]))},
18310 with this resulting value coerced to the @code{unsigned char} type.
18311 The behavior of the @code{vec_srv} is as if
18312 there existed a temporary array of 17 unsigned characters
18313 @code{srv_array} within which element 0 equals zero and
18314 elements 1 through 16 equal the elements 0 through 15 of
18315 the @code{src} array.  The
18316 result returned from the @code{vec_srv} function is a
18317 @code{__vector} of 16 unsigned characters within which element
18318 @code{i} is computed using the C expression
18319 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18320 (0x07 & shift_distance[i]))},
18321 with this resulting value coerced to the @code{unsigned char} type.
18323 The following built-in functions are available for the PowerPC family
18324 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18325 @smallexample
18326 __vector unsigned char
18327 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18328 __vector unsigned short
18329 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18330 __vector unsigned int
18331 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18333 __vector unsigned char
18334 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18335 __vector unsigned short
18336 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18337 __vector unsigned int
18338 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18339 @end smallexample
18341 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18342 @code{vec_absdw} built-in functions each computes the absolute
18343 differences of the pairs of vector elements supplied in its two vector
18344 arguments, placing the absolute differences into the corresponding
18345 elements of the vector result.
18347 The following built-in functions are available for the PowerPC family
18348 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18349 @smallexample
18350 __vector unsigned int
18351 vec_extract_exp (__vector float source);
18352 __vector unsigned long long int
18353 vec_extract_exp (__vector double source);
18355 __vector unsigned int
18356 vec_extract_sig (__vector float source);
18357 __vector unsigned long long int
18358 vec_extract_sig (__vector double source);
18360 __vector float
18361 vec_insert_exp (__vector unsigned int significands,
18362                 __vector unsigned int exponents);
18363 __vector float
18364 vec_insert_exp (__vector unsigned float significands,
18365                 __vector unsigned int exponents);
18366 __vector double
18367 vec_insert_exp (__vector unsigned long long int significands,
18368                 __vector unsigned long long int exponents);
18369 __vector double
18370 vec_insert_exp (__vector unsigned double significands,
18371                 __vector unsigned long long int exponents);
18373 __vector bool int vec_test_data_class (__vector float source,
18374                                        const int condition);
18375 __vector bool long long int vec_test_data_class (__vector double source,
18376                                                  const int condition);
18377 @end smallexample
18379 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18380 functions return vectors representing the significands and biased
18381 exponent values of their @code{source} arguments respectively.
18382 Within the result vector returned by @code{vec_extract_sig}, the
18383 @code{0x800000} bit of each vector element returned when the
18384 function's @code{source} argument is of type @code{float} is set to 1
18385 if the corresponding floating point value is in normalized form.
18386 Otherwise, this bit is set to 0.  When the @code{source} argument is
18387 of type @code{double}, the @code{0x10000000000000} bit within each of
18388 the result vector's elements is set according to the same rules.
18389 Note that the sign of the significand is not represented in the result
18390 returned from the @code{vec_extract_sig} function.  To extract the
18391 sign bits, use the
18392 @code{vec_cpsgn} function, which returns a new vector within which all
18393 of the sign bits of its second argument vector are overwritten with the
18394 sign bits copied from the coresponding elements of its first argument
18395 vector, and all other (non-sign) bits of the second argument vector
18396 are copied unchanged into the result vector.
18398 The @code{vec_insert_exp} built-in functions return a vector of
18399 single- or double-precision floating
18400 point values constructed by assembling the values of their
18401 @code{significands} and @code{exponents} arguments into the
18402 corresponding elements of the returned vector.
18403 The sign of each
18404 element of the result is copied from the most significant bit of the
18405 corresponding entry within the @code{significands} argument.
18406 Note that the relevant
18407 bits of the @code{significands} argument are the same, for both integer
18408 and floating point types.
18410 significand and exponent components of each element of the result are
18411 composed of the least significant bits of the corresponding
18412 @code{significands} element and the least significant bits of the
18413 corresponding @code{exponents} element.
18415 The @code{vec_test_data_class} built-in function returns a vector
18416 representing the results of testing the @code{source} vector for the
18417 condition selected by the @code{condition} argument.  The
18418 @code{condition} argument must be a compile-time constant integer with
18419 value not exceeding 127.  The
18420 @code{condition} argument is encoded as a bitmask with each bit
18421 enabling the testing of a different condition, as characterized by the
18422 following:
18423 @smallexample
18424 0x40    Test for NaN
18425 0x20    Test for +Infinity
18426 0x10    Test for -Infinity
18427 0x08    Test for +Zero
18428 0x04    Test for -Zero
18429 0x02    Test for +Denormal
18430 0x01    Test for -Denormal
18431 @end smallexample
18433 If any of the enabled test conditions is true, the corresponding entry
18434 in the result vector is -1.  Otherwise (all of the enabled test
18435 conditions are false), the corresponding entry of the result vector is 0.
18437 The following built-in functions are available for the PowerPC family
18438 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18439 @smallexample
18440 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
18441                               vector unsigned int);
18442 vector unsigned long long vec_rlmi (vector unsigned long long,
18443                                     vector unsigned long long,
18444                                     vector unsigned long long);
18445 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
18446                               vector unsigned int);
18447 vector unsigned long long vec_rlnm (vector unsigned long long,
18448                                     vector unsigned long long,
18449                                     vector unsigned long long);
18450 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
18451 vector unsigned long long vec_vrlnm (vector unsigned long long,
18452                                      vector unsigned long long);
18453 @end smallexample
18455 The result of @code{vec_rlmi} is obtained by rotating each element of
18456 the first argument vector left and inserting it under mask into the
18457 second argument vector.  The third argument vector contains the mask
18458 beginning in bits 11:15, the mask end in bits 19:23, and the shift
18459 count in bits 27:31, of each element.
18461 The result of @code{vec_rlnm} is obtained by rotating each element of
18462 the first argument vector left and ANDing it with a mask specified by
18463 the second and third argument vectors.  The second argument vector
18464 contains the shift count for each element in the low-order byte.  The
18465 third argument vector contains the mask end for each element in the
18466 low-order byte, with the mask begin in the next higher byte.
18468 The result of @code{vec_vrlnm} is obtained by rotating each element
18469 of the first argument vector left and ANDing it with a mask.  The
18470 second argument vector contains the mask  beginning in bits 11:15,
18471 the mask end in bits 19:23, and the shift count in bits 27:31,
18472 of each element.
18474 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18475 are available:
18476 @smallexample
18477 vector signed char vec_revb (vector signed char);
18478 vector unsigned char vec_revb (vector unsigned char);
18479 vector short vec_revb (vector short);
18480 vector unsigned short vec_revb (vector unsigned short);
18481 vector int vec_revb (vector int);
18482 vector unsigned int vec_revb (vector unsigned int);
18483 vector float vec_revb (vector float);
18484 vector long long vec_revb (vector long long);
18485 vector unsigned long long vec_revb (vector unsigned long long);
18486 vector double vec_revb (vector double);
18487 @end smallexample
18489 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18490 are available:
18491 @smallexample
18492 vector long vec_revb (vector long);
18493 vector unsigned long vec_revb (vector unsigned long);
18494 vector __int128_t vec_revb (vector __int128_t);
18495 vector __uint128_t vec_revb (vector __uint128_t);
18496 @end smallexample
18498 The @code{vec_revb} built-in function reverses the bytes on an element
18499 by element basis.  A vector of @code{vector unsigned char} or
18500 @code{vector signed char} reverses the bytes in the whole word.
18502 If the cryptographic instructions are enabled (@option{-mcrypto} or
18503 @option{-mcpu=power8}), the following builtins are enabled.
18505 @smallexample
18506 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
18508 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
18509                                                     vector unsigned long long);
18511 vector unsigned long long __builtin_crypto_vcipherlast
18512                                      (vector unsigned long long,
18513                                       vector unsigned long long);
18515 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
18516                                                      vector unsigned long long);
18518 vector unsigned long long __builtin_crypto_vncipherlast
18519                                      (vector unsigned long long,
18520                                       vector unsigned long long);
18522 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
18523                                                 vector unsigned char,
18524                                                 vector unsigned char);
18526 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
18527                                                  vector unsigned short,
18528                                                  vector unsigned short);
18530 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
18531                                                vector unsigned int,
18532                                                vector unsigned int);
18534 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
18535                                                      vector unsigned long long,
18536                                                      vector unsigned long long);
18538 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
18539                                                vector unsigned char);
18541 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
18542                                                 vector unsigned short);
18544 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
18545                                               vector unsigned int);
18547 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
18548                                                     vector unsigned long long);
18550 vector unsigned long long __builtin_crypto_vshasigmad
18551                                (vector unsigned long long, int, int);
18553 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
18554                                                  int, int);
18555 @end smallexample
18557 The second argument to @var{__builtin_crypto_vshasigmad} and
18558 @var{__builtin_crypto_vshasigmaw} must be a constant
18559 integer that is 0 or 1.  The third argument to these built-in functions
18560 must be a constant integer in the range of 0 to 15.
18562 If the ISA 3.0 instruction set additions 
18563 are enabled (@option{-mcpu=power9}), the following additional
18564 functions are available for both 32-bit and 64-bit targets.
18566 vector short vec_xl (int, vector short *);
18567 vector short vec_xl (int, short *);
18568 vector unsigned short vec_xl (int, vector unsigned short *);
18569 vector unsigned short vec_xl (int, unsigned short *);
18570 vector char vec_xl (int, vector char *);
18571 vector char vec_xl (int, char *);
18572 vector unsigned char vec_xl (int, vector unsigned char *);
18573 vector unsigned char vec_xl (int, unsigned char *);
18575 void vec_xst (vector short, int, vector short *);
18576 void vec_xst (vector short, int, short *);
18577 void vec_xst (vector unsigned short, int, vector unsigned short *);
18578 void vec_xst (vector unsigned short, int, unsigned short *);
18579 void vec_xst (vector char, int, vector char *);
18580 void vec_xst (vector char, int, char *);
18581 void vec_xst (vector unsigned char, int, vector unsigned char *);
18582 void vec_xst (vector unsigned char, int, unsigned char *);
18584 @node PowerPC Hardware Transactional Memory Built-in Functions
18585 @subsection PowerPC Hardware Transactional Memory Built-in Functions
18586 GCC provides two interfaces for accessing the Hardware Transactional
18587 Memory (HTM) instructions available on some of the PowerPC family
18588 of processors (eg, POWER8).  The two interfaces come in a low level
18589 interface, consisting of built-in functions specific to PowerPC and a
18590 higher level interface consisting of inline functions that are common
18591 between PowerPC and S/390.
18593 @subsubsection PowerPC HTM Low Level Built-in Functions
18595 The following low level built-in functions are available with
18596 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
18597 They all generate the machine instruction that is part of the name.
18599 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
18600 the full 4-bit condition register value set by their associated hardware
18601 instruction.  The header file @code{htmintrin.h} defines some macros that can
18602 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
18603 returns a simple true or false value depending on whether a transaction was
18604 successfully started or not.  The arguments of the builtins match exactly the
18605 type and order of the associated hardware instruction's operands, except for
18606 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18607 Refer to the ISA manual for a description of each instruction's operands.
18609 @smallexample
18610 unsigned int __builtin_tbegin (unsigned int)
18611 unsigned int __builtin_tend (unsigned int)
18613 unsigned int __builtin_tabort (unsigned int)
18614 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18615 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18616 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18617 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18619 unsigned int __builtin_tcheck (void)
18620 unsigned int __builtin_treclaim (unsigned int)
18621 unsigned int __builtin_trechkpt (void)
18622 unsigned int __builtin_tsr (unsigned int)
18623 @end smallexample
18625 In addition to the above HTM built-ins, we have added built-ins for
18626 some common extended mnemonics of the HTM instructions:
18628 @smallexample
18629 unsigned int __builtin_tendall (void)
18630 unsigned int __builtin_tresume (void)
18631 unsigned int __builtin_tsuspend (void)
18632 @end smallexample
18634 Note that the semantics of the above HTM builtins are required to mimic
18635 the locking semantics used for critical sections.  Builtins that are used
18636 to create a new transaction or restart a suspended transaction must have
18637 lock acquisition like semantics while those builtins that end or suspend a
18638 transaction must have lock release like semantics.  Specifically, this must
18639 mimic lock semantics as specified by C++11, for example: Lock acquisition is
18640 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
18641 that returns 0, and lock release is as-if an execution of
18642 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
18643 implicit implementation-defined lock used for all transactions.  The HTM
18644 instructions associated with with the builtins inherently provide the
18645 correct acquisition and release hardware barriers required.  However,
18646 the compiler must also be prohibited from moving loads and stores across
18647 the builtins in a way that would violate their semantics.  This has been
18648 accomplished by adding memory barriers to the associated HTM instructions
18649 (which is a conservative approach to provide acquire and release semantics).
18650 Earlier versions of the compiler did not treat the HTM instructions as
18651 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
18652 be used to determine whether the current compiler treats HTM instructions
18653 as memory barriers or not.  This allows the user to explicitly add memory
18654 barriers to their code when using an older version of the compiler.
18656 The following set of built-in functions are available to gain access
18657 to the HTM specific special purpose registers.
18659 @smallexample
18660 unsigned long __builtin_get_texasr (void)
18661 unsigned long __builtin_get_texasru (void)
18662 unsigned long __builtin_get_tfhar (void)
18663 unsigned long __builtin_get_tfiar (void)
18665 void __builtin_set_texasr (unsigned long);
18666 void __builtin_set_texasru (unsigned long);
18667 void __builtin_set_tfhar (unsigned long);
18668 void __builtin_set_tfiar (unsigned long);
18669 @end smallexample
18671 Example usage of these low level built-in functions may look like:
18673 @smallexample
18674 #include <htmintrin.h>
18676 int num_retries = 10;
18678 while (1)
18679   @{
18680     if (__builtin_tbegin (0))
18681       @{
18682         /* Transaction State Initiated.  */
18683         if (is_locked (lock))
18684           __builtin_tabort (0);
18685         ... transaction code...
18686         __builtin_tend (0);
18687         break;
18688       @}
18689     else
18690       @{
18691         /* Transaction State Failed.  Use locks if the transaction
18692            failure is "persistent" or we've tried too many times.  */
18693         if (num_retries-- <= 0
18694             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18695           @{
18696             acquire_lock (lock);
18697             ... non transactional fallback path...
18698             release_lock (lock);
18699             break;
18700           @}
18701       @}
18702   @}
18703 @end smallexample
18705 One final built-in function has been added that returns the value of
18706 the 2-bit Transaction State field of the Machine Status Register (MSR)
18707 as stored in @code{CR0}.
18709 @smallexample
18710 unsigned long __builtin_ttest (void)
18711 @end smallexample
18713 This built-in can be used to determine the current transaction state
18714 using the following code example:
18716 @smallexample
18717 #include <htmintrin.h>
18719 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
18721 if (tx_state == _HTM_TRANSACTIONAL)
18722   @{
18723     /* Code to use in transactional state.  */
18724   @}
18725 else if (tx_state == _HTM_NONTRANSACTIONAL)
18726   @{
18727     /* Code to use in non-transactional state.  */
18728   @}
18729 else if (tx_state == _HTM_SUSPENDED)
18730   @{
18731     /* Code to use in transaction suspended state.  */
18732   @}
18733 @end smallexample
18735 @subsubsection PowerPC HTM High Level Inline Functions
18737 The following high level HTM interface is made available by including
18738 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18739 where CPU is `power8' or later.  This interface is common between PowerPC
18740 and S/390, allowing users to write one HTM source implementation that
18741 can be compiled and executed on either system.
18743 @smallexample
18744 long __TM_simple_begin (void)
18745 long __TM_begin (void* const TM_buff)
18746 long __TM_end (void)
18747 void __TM_abort (void)
18748 void __TM_named_abort (unsigned char const code)
18749 void __TM_resume (void)
18750 void __TM_suspend (void)
18752 long __TM_is_user_abort (void* const TM_buff)
18753 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18754 long __TM_is_illegal (void* const TM_buff)
18755 long __TM_is_footprint_exceeded (void* const TM_buff)
18756 long __TM_nesting_depth (void* const TM_buff)
18757 long __TM_is_nested_too_deep(void* const TM_buff)
18758 long __TM_is_conflict(void* const TM_buff)
18759 long __TM_is_failure_persistent(void* const TM_buff)
18760 long __TM_failure_address(void* const TM_buff)
18761 long long __TM_failure_code(void* const TM_buff)
18762 @end smallexample
18764 Using these common set of HTM inline functions, we can create
18765 a more portable version of the HTM example in the previous
18766 section that will work on either PowerPC or S/390:
18768 @smallexample
18769 #include <htmxlintrin.h>
18771 int num_retries = 10;
18772 TM_buff_type TM_buff;
18774 while (1)
18775   @{
18776     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18777       @{
18778         /* Transaction State Initiated.  */
18779         if (is_locked (lock))
18780           __TM_abort ();
18781         ... transaction code...
18782         __TM_end ();
18783         break;
18784       @}
18785     else
18786       @{
18787         /* Transaction State Failed.  Use locks if the transaction
18788            failure is "persistent" or we've tried too many times.  */
18789         if (num_retries-- <= 0
18790             || __TM_is_failure_persistent (TM_buff))
18791           @{
18792             acquire_lock (lock);
18793             ... non transactional fallback path...
18794             release_lock (lock);
18795             break;
18796           @}
18797       @}
18798   @}
18799 @end smallexample
18801 @node RX Built-in Functions
18802 @subsection RX Built-in Functions
18803 GCC supports some of the RX instructions which cannot be expressed in
18804 the C programming language via the use of built-in functions.  The
18805 following functions are supported:
18807 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
18808 Generates the @code{brk} machine instruction.
18809 @end deftypefn
18811 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
18812 Generates the @code{clrpsw} machine instruction to clear the specified
18813 bit in the processor status word.
18814 @end deftypefn
18816 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
18817 Generates the @code{int} machine instruction to generate an interrupt
18818 with the specified value.
18819 @end deftypefn
18821 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
18822 Generates the @code{machi} machine instruction to add the result of
18823 multiplying the top 16 bits of the two arguments into the
18824 accumulator.
18825 @end deftypefn
18827 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
18828 Generates the @code{maclo} machine instruction to add the result of
18829 multiplying the bottom 16 bits of the two arguments into the
18830 accumulator.
18831 @end deftypefn
18833 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
18834 Generates the @code{mulhi} machine instruction to place the result of
18835 multiplying the top 16 bits of the two arguments into the
18836 accumulator.
18837 @end deftypefn
18839 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
18840 Generates the @code{mullo} machine instruction to place the result of
18841 multiplying the bottom 16 bits of the two arguments into the
18842 accumulator.
18843 @end deftypefn
18845 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
18846 Generates the @code{mvfachi} machine instruction to read the top
18847 32 bits of the accumulator.
18848 @end deftypefn
18850 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
18851 Generates the @code{mvfacmi} machine instruction to read the middle
18852 32 bits of the accumulator.
18853 @end deftypefn
18855 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
18856 Generates the @code{mvfc} machine instruction which reads the control
18857 register specified in its argument and returns its value.
18858 @end deftypefn
18860 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
18861 Generates the @code{mvtachi} machine instruction to set the top
18862 32 bits of the accumulator.
18863 @end deftypefn
18865 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
18866 Generates the @code{mvtaclo} machine instruction to set the bottom
18867 32 bits of the accumulator.
18868 @end deftypefn
18870 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
18871 Generates the @code{mvtc} machine instruction which sets control
18872 register number @code{reg} to @code{val}.
18873 @end deftypefn
18875 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
18876 Generates the @code{mvtipl} machine instruction set the interrupt
18877 priority level.
18878 @end deftypefn
18880 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
18881 Generates the @code{racw} machine instruction to round the accumulator
18882 according to the specified mode.
18883 @end deftypefn
18885 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
18886 Generates the @code{revw} machine instruction which swaps the bytes in
18887 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18888 and also bits 16--23 occupy bits 24--31 and vice versa.
18889 @end deftypefn
18891 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
18892 Generates the @code{rmpa} machine instruction which initiates a
18893 repeated multiply and accumulate sequence.
18894 @end deftypefn
18896 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
18897 Generates the @code{round} machine instruction which returns the
18898 floating-point argument rounded according to the current rounding mode
18899 set in the floating-point status word register.
18900 @end deftypefn
18902 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
18903 Generates the @code{sat} machine instruction which returns the
18904 saturated value of the argument.
18905 @end deftypefn
18907 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
18908 Generates the @code{setpsw} machine instruction to set the specified
18909 bit in the processor status word.
18910 @end deftypefn
18912 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
18913 Generates the @code{wait} machine instruction.
18914 @end deftypefn
18916 @node S/390 System z Built-in Functions
18917 @subsection S/390 System z Built-in Functions
18918 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18919 Generates the @code{tbegin} machine instruction starting a
18920 non-constrained hardware transaction.  If the parameter is non-NULL the
18921 memory area is used to store the transaction diagnostic buffer and
18922 will be passed as first operand to @code{tbegin}.  This buffer can be
18923 defined using the @code{struct __htm_tdb} C struct defined in
18924 @code{htmintrin.h} and must reside on a double-word boundary.  The
18925 second tbegin operand is set to @code{0xff0c}. This enables
18926 save/restore of all GPRs and disables aborts for FPR and AR
18927 manipulations inside the transaction body.  The condition code set by
18928 the tbegin instruction is returned as integer value.  The tbegin
18929 instruction by definition overwrites the content of all FPRs.  The
18930 compiler will generate code which saves and restores the FPRs.  For
18931 soft-float code it is recommended to used the @code{*_nofloat}
18932 variant.  In order to prevent a TDB from being written it is required
18933 to pass a constant zero value as parameter.  Passing a zero value
18934 through a variable is not sufficient.  Although modifications of
18935 access registers inside the transaction will not trigger an
18936 transaction abort it is not supported to actually modify them.  Access
18937 registers do not get saved when entering a transaction. They will have
18938 undefined state when reaching the abort code.
18939 @end deftypefn
18941 Macros for the possible return codes of tbegin are defined in the
18942 @code{htmintrin.h} header file:
18944 @table @code
18945 @item _HTM_TBEGIN_STARTED
18946 @code{tbegin} has been executed as part of normal processing.  The
18947 transaction body is supposed to be executed.
18948 @item _HTM_TBEGIN_INDETERMINATE
18949 The transaction was aborted due to an indeterminate condition which
18950 might be persistent.
18951 @item _HTM_TBEGIN_TRANSIENT
18952 The transaction aborted due to a transient failure.  The transaction
18953 should be re-executed in that case.
18954 @item _HTM_TBEGIN_PERSISTENT
18955 The transaction aborted due to a persistent failure.  Re-execution
18956 under same circumstances will not be productive.
18957 @end table
18959 @defmac _HTM_FIRST_USER_ABORT_CODE
18960 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18961 specifies the first abort code which can be used for
18962 @code{__builtin_tabort}.  Values below this threshold are reserved for
18963 machine use.
18964 @end defmac
18966 @deftp {Data type} {struct __htm_tdb}
18967 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18968 the structure of the transaction diagnostic block as specified in the
18969 Principles of Operation manual chapter 5-91.
18970 @end deftp
18972 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18973 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18974 Using this variant in code making use of FPRs will leave the FPRs in
18975 undefined state when entering the transaction abort handler code.
18976 @end deftypefn
18978 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18979 In addition to @code{__builtin_tbegin} a loop for transient failures
18980 is generated.  If tbegin returns a condition code of 2 the transaction
18981 will be retried as often as specified in the second argument.  The
18982 perform processor assist instruction is used to tell the CPU about the
18983 number of fails so far.
18984 @end deftypefn
18986 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18987 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18988 restores.  Using this variant in code making use of FPRs will leave
18989 the FPRs in undefined state when entering the transaction abort
18990 handler code.
18991 @end deftypefn
18993 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18994 Generates the @code{tbeginc} machine instruction starting a constrained
18995 hardware transaction.  The second operand is set to @code{0xff08}.
18996 @end deftypefn
18998 @deftypefn {Built-in Function} int __builtin_tend (void)
18999 Generates the @code{tend} machine instruction finishing a transaction
19000 and making the changes visible to other threads.  The condition code
19001 generated by tend is returned as integer value.
19002 @end deftypefn
19004 @deftypefn {Built-in Function} void __builtin_tabort (int)
19005 Generates the @code{tabort} machine instruction with the specified
19006 abort code.  Abort codes from 0 through 255 are reserved and will
19007 result in an error message.
19008 @end deftypefn
19010 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19011 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19012 integer parameter is loaded into rX and a value of zero is loaded into
19013 rY.  The integer parameter specifies the number of times the
19014 transaction repeatedly aborted.
19015 @end deftypefn
19017 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19018 Generates the @code{etnd} machine instruction.  The current nesting
19019 depth is returned as integer value.  For a nesting depth of 0 the code
19020 is not executed as part of an transaction.
19021 @end deftypefn
19023 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19025 Generates the @code{ntstg} machine instruction.  The second argument
19026 is written to the first arguments location.  The store operation will
19027 not be rolled-back in case of an transaction abort.
19028 @end deftypefn
19030 @node SH Built-in Functions
19031 @subsection SH Built-in Functions
19032 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19033 families of processors:
19035 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19036 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
19037 used by system code that manages threads and execution contexts.  The compiler
19038 normally does not generate code that modifies the contents of @samp{GBR} and
19039 thus the value is preserved across function calls.  Changing the @samp{GBR}
19040 value in user code must be done with caution, since the compiler might use
19041 @samp{GBR} in order to access thread local variables.
19043 @end deftypefn
19045 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19046 Returns the value that is currently set in the @samp{GBR} register.
19047 Memory loads and stores that use the thread pointer as a base address are
19048 turned into @samp{GBR} based displacement loads and stores, if possible.
19049 For example:
19050 @smallexample
19051 struct my_tcb
19053    int a, b, c, d, e;
19056 int get_tcb_value (void)
19058   // Generate @samp{mov.l @@(8,gbr),r0} instruction
19059   return ((my_tcb*)__builtin_thread_pointer ())->c;
19062 @end smallexample
19063 @end deftypefn
19065 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19066 Returns the value that is currently set in the @samp{FPSCR} register.
19067 @end deftypefn
19069 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19070 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19071 preserving the current values of the FR, SZ and PR bits.
19072 @end deftypefn
19074 @node SPARC VIS Built-in Functions
19075 @subsection SPARC VIS Built-in Functions
19077 GCC supports SIMD operations on the SPARC using both the generic vector
19078 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19079 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
19080 switch, the VIS extension is exposed as the following built-in functions:
19082 @smallexample
19083 typedef int v1si __attribute__ ((vector_size (4)));
19084 typedef int v2si __attribute__ ((vector_size (8)));
19085 typedef short v4hi __attribute__ ((vector_size (8)));
19086 typedef short v2hi __attribute__ ((vector_size (4)));
19087 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19088 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19090 void __builtin_vis_write_gsr (int64_t);
19091 int64_t __builtin_vis_read_gsr (void);
19093 void * __builtin_vis_alignaddr (void *, long);
19094 void * __builtin_vis_alignaddrl (void *, long);
19095 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19096 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19097 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19098 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19100 v4hi __builtin_vis_fexpand (v4qi);
19102 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19103 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19104 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19105 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19106 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19107 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19108 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19110 v4qi __builtin_vis_fpack16 (v4hi);
19111 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19112 v2hi __builtin_vis_fpackfix (v2si);
19113 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19115 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19117 long __builtin_vis_edge8 (void *, void *);
19118 long __builtin_vis_edge8l (void *, void *);
19119 long __builtin_vis_edge16 (void *, void *);
19120 long __builtin_vis_edge16l (void *, void *);
19121 long __builtin_vis_edge32 (void *, void *);
19122 long __builtin_vis_edge32l (void *, void *);
19124 long __builtin_vis_fcmple16 (v4hi, v4hi);
19125 long __builtin_vis_fcmple32 (v2si, v2si);
19126 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19127 long __builtin_vis_fcmpne32 (v2si, v2si);
19128 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19129 long __builtin_vis_fcmpgt32 (v2si, v2si);
19130 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19131 long __builtin_vis_fcmpeq32 (v2si, v2si);
19133 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19134 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19135 v2si __builtin_vis_fpadd32 (v2si, v2si);
19136 v1si __builtin_vis_fpadd32s (v1si, v1si);
19137 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19138 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19139 v2si __builtin_vis_fpsub32 (v2si, v2si);
19140 v1si __builtin_vis_fpsub32s (v1si, v1si);
19142 long __builtin_vis_array8 (long, long);
19143 long __builtin_vis_array16 (long, long);
19144 long __builtin_vis_array32 (long, long);
19145 @end smallexample
19147 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19148 functions also become available:
19150 @smallexample
19151 long __builtin_vis_bmask (long, long);
19152 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19153 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19154 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19155 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19157 long __builtin_vis_edge8n (void *, void *);
19158 long __builtin_vis_edge8ln (void *, void *);
19159 long __builtin_vis_edge16n (void *, void *);
19160 long __builtin_vis_edge16ln (void *, void *);
19161 long __builtin_vis_edge32n (void *, void *);
19162 long __builtin_vis_edge32ln (void *, void *);
19163 @end smallexample
19165 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19166 functions also become available:
19168 @smallexample
19169 void __builtin_vis_cmask8 (long);
19170 void __builtin_vis_cmask16 (long);
19171 void __builtin_vis_cmask32 (long);
19173 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
19175 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
19176 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
19177 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
19178 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
19179 v2si __builtin_vis_fsll16 (v2si, v2si);
19180 v2si __builtin_vis_fslas16 (v2si, v2si);
19181 v2si __builtin_vis_fsrl16 (v2si, v2si);
19182 v2si __builtin_vis_fsra16 (v2si, v2si);
19184 long __builtin_vis_pdistn (v8qi, v8qi);
19186 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
19188 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
19189 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
19191 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
19192 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
19193 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
19194 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
19195 v2si __builtin_vis_fpadds32 (v2si, v2si);
19196 v1si __builtin_vis_fpadds32s (v1si, v1si);
19197 v2si __builtin_vis_fpsubs32 (v2si, v2si);
19198 v1si __builtin_vis_fpsubs32s (v1si, v1si);
19200 long __builtin_vis_fucmple8 (v8qi, v8qi);
19201 long __builtin_vis_fucmpne8 (v8qi, v8qi);
19202 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
19203 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
19205 float __builtin_vis_fhadds (float, float);
19206 double __builtin_vis_fhaddd (double, double);
19207 float __builtin_vis_fhsubs (float, float);
19208 double __builtin_vis_fhsubd (double, double);
19209 float __builtin_vis_fnhadds (float, float);
19210 double __builtin_vis_fnhaddd (double, double);
19212 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
19213 int64_t __builtin_vis_xmulx (int64_t, int64_t);
19214 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
19215 @end smallexample
19217 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
19218 functions also become available:
19220 @smallexample
19221 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
19222 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
19223 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
19224 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
19226 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
19227 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
19228 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
19229 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
19231 long __builtin_vis_fpcmple8 (v8qi, v8qi);
19232 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
19233 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
19234 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
19235 long __builtin_vis_fpcmpule32 (v2si, v2si);
19236 long __builtin_vis_fpcmpugt32 (v2si, v2si);
19238 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
19239 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
19240 v2si __builtin_vis_fpmax32 (v2si, v2si);
19242 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
19243 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
19244 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
19247 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
19248 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
19249 v2si __builtin_vis_fpmin32 (v2si, v2si);
19251 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
19252 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
19253 v2si __builtin_vis_fpminu32 (v2si, v2si);
19254 @end smallexample
19256 @node SPU Built-in Functions
19257 @subsection SPU Built-in Functions
19259 GCC provides extensions for the SPU processor as described in the
19260 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
19261 implementation differs in several ways.
19263 @itemize @bullet
19265 @item
19266 The optional extension of specifying vector constants in parentheses is
19267 not supported.
19269 @item
19270 A vector initializer requires no cast if the vector constant is of the
19271 same type as the variable it is initializing.
19273 @item
19274 If @code{signed} or @code{unsigned} is omitted, the signedness of the
19275 vector type is the default signedness of the base type.  The default
19276 varies depending on the operating system, so a portable program should
19277 always specify the signedness.
19279 @item
19280 By default, the keyword @code{__vector} is added. The macro
19281 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
19282 undefined.
19284 @item
19285 GCC allows using a @code{typedef} name as the type specifier for a
19286 vector type.
19288 @item
19289 For C, overloaded functions are implemented with macros so the following
19290 does not work:
19292 @smallexample
19293   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
19294 @end smallexample
19296 @noindent
19297 Since @code{spu_add} is a macro, the vector constant in the example
19298 is treated as four separate arguments.  Wrap the entire argument in
19299 parentheses for this to work.
19301 @item
19302 The extended version of @code{__builtin_expect} is not supported.
19304 @end itemize
19306 @emph{Note:} Only the interface described in the aforementioned
19307 specification is supported. Internally, GCC uses built-in functions to
19308 implement the required functionality, but these are not supported and
19309 are subject to change without notice.
19311 @node TI C6X Built-in Functions
19312 @subsection TI C6X Built-in Functions
19314 GCC provides intrinsics to access certain instructions of the TI C6X
19315 processors.  These intrinsics, listed below, are available after
19316 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
19317 to C6X instructions.
19319 @smallexample
19321 int _sadd (int, int)
19322 int _ssub (int, int)
19323 int _sadd2 (int, int)
19324 int _ssub2 (int, int)
19325 long long _mpy2 (int, int)
19326 long long _smpy2 (int, int)
19327 int _add4 (int, int)
19328 int _sub4 (int, int)
19329 int _saddu4 (int, int)
19331 int _smpy (int, int)
19332 int _smpyh (int, int)
19333 int _smpyhl (int, int)
19334 int _smpylh (int, int)
19336 int _sshl (int, int)
19337 int _subc (int, int)
19339 int _avg2 (int, int)
19340 int _avgu4 (int, int)
19342 int _clrr (int, int)
19343 int _extr (int, int)
19344 int _extru (int, int)
19345 int _abs (int)
19346 int _abs2 (int)
19348 @end smallexample
19350 @node TILE-Gx Built-in Functions
19351 @subsection TILE-Gx Built-in Functions
19353 GCC provides intrinsics to access every instruction of the TILE-Gx
19354 processor.  The intrinsics are of the form:
19356 @smallexample
19358 unsigned long long __insn_@var{op} (...)
19360 @end smallexample
19362 Where @var{op} is the name of the instruction.  Refer to the ISA manual
19363 for the complete list of instructions.
19365 GCC also provides intrinsics to directly access the network registers.
19366 The intrinsics are:
19368 @smallexample
19370 unsigned long long __tile_idn0_receive (void)
19371 unsigned long long __tile_idn1_receive (void)
19372 unsigned long long __tile_udn0_receive (void)
19373 unsigned long long __tile_udn1_receive (void)
19374 unsigned long long __tile_udn2_receive (void)
19375 unsigned long long __tile_udn3_receive (void)
19376 void __tile_idn_send (unsigned long long)
19377 void __tile_udn_send (unsigned long long)
19379 @end smallexample
19381 The intrinsic @code{void __tile_network_barrier (void)} is used to
19382 guarantee that no network operations before it are reordered with
19383 those after it.
19385 @node TILEPro Built-in Functions
19386 @subsection TILEPro Built-in Functions
19388 GCC provides intrinsics to access every instruction of the TILEPro
19389 processor.  The intrinsics are of the form:
19391 @smallexample
19393 unsigned __insn_@var{op} (...)
19395 @end smallexample
19397 @noindent
19398 where @var{op} is the name of the instruction.  Refer to the ISA manual
19399 for the complete list of instructions.
19401 GCC also provides intrinsics to directly access the network registers.
19402 The intrinsics are:
19404 @smallexample
19406 unsigned __tile_idn0_receive (void)
19407 unsigned __tile_idn1_receive (void)
19408 unsigned __tile_sn_receive (void)
19409 unsigned __tile_udn0_receive (void)
19410 unsigned __tile_udn1_receive (void)
19411 unsigned __tile_udn2_receive (void)
19412 unsigned __tile_udn3_receive (void)
19413 void __tile_idn_send (unsigned)
19414 void __tile_sn_send (unsigned)
19415 void __tile_udn_send (unsigned)
19417 @end smallexample
19419 The intrinsic @code{void __tile_network_barrier (void)} is used to
19420 guarantee that no network operations before it are reordered with
19421 those after it.
19423 @node x86 Built-in Functions
19424 @subsection x86 Built-in Functions
19426 These built-in functions are available for the x86-32 and x86-64 family
19427 of computers, depending on the command-line switches used.
19429 If you specify command-line switches such as @option{-msse},
19430 the compiler could use the extended instruction sets even if the built-ins
19431 are not used explicitly in the program.  For this reason, applications
19432 that perform run-time CPU detection must compile separate files for each
19433 supported architecture, using the appropriate flags.  In particular,
19434 the file containing the CPU detection code should be compiled without
19435 these options.
19437 The following machine modes are available for use with MMX built-in functions
19438 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
19439 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
19440 vector of eight 8-bit integers.  Some of the built-in functions operate on
19441 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
19443 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
19444 of two 32-bit floating-point values.
19446 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
19447 floating-point values.  Some instructions use a vector of four 32-bit
19448 integers, these use @code{V4SI}.  Finally, some instructions operate on an
19449 entire vector register, interpreting it as a 128-bit integer, these use mode
19450 @code{TI}.
19452 The x86-32 and x86-64 family of processors use additional built-in
19453 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
19454 floating point and @code{TC} 128-bit complex floating-point values.
19456 The following floating-point built-in functions are always available.  All
19457 of them implement the function that is part of the name.
19459 @smallexample
19460 __float128 __builtin_fabsq (__float128)
19461 __float128 __builtin_copysignq (__float128, __float128)
19462 @end smallexample
19464 The following built-in functions are always available.
19466 @table @code
19467 @item __float128 __builtin_infq (void)
19468 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
19469 @findex __builtin_infq
19471 @item __float128 __builtin_huge_valq (void)
19472 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
19473 @findex __builtin_huge_valq
19475 @item __float128 __builtin_nanq (void)
19476 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
19477 @findex __builtin_nanq
19479 @item __float128 __builtin_nansq (void)
19480 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
19481 @findex __builtin_nansq
19482 @end table
19484 The following built-in function is always available.
19486 @table @code
19487 @item void __builtin_ia32_pause (void)
19488 Generates the @code{pause} machine instruction with a compiler memory
19489 barrier.
19490 @end table
19492 The following built-in functions are always available and can be used to
19493 check the target platform type.
19495 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
19496 This function runs the CPU detection code to check the type of CPU and the
19497 features supported.  This built-in function needs to be invoked along with the built-in functions
19498 to check CPU type and features, @code{__builtin_cpu_is} and
19499 @code{__builtin_cpu_supports}, only when used in a function that is
19500 executed before any constructors are called.  The CPU detection code is
19501 automatically executed in a very high priority constructor.
19503 For example, this function has to be used in @code{ifunc} resolvers that
19504 check for CPU type using the built-in functions @code{__builtin_cpu_is}
19505 and @code{__builtin_cpu_supports}, or in constructors on targets that
19506 don't support constructor priority.
19507 @smallexample
19509 static void (*resolve_memcpy (void)) (void)
19511   // ifunc resolvers fire before constructors, explicitly call the init
19512   // function.
19513   __builtin_cpu_init ();
19514   if (__builtin_cpu_supports ("ssse3"))
19515     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
19516   else
19517     return default_memcpy;
19520 void *memcpy (void *, const void *, size_t)
19521      __attribute__ ((ifunc ("resolve_memcpy")));
19522 @end smallexample
19524 @end deftypefn
19526 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
19527 This function returns a positive integer if the run-time CPU
19528 is of type @var{cpuname}
19529 and returns @code{0} otherwise. The following CPU names can be detected:
19531 @table @samp
19532 @item intel
19533 Intel CPU.
19535 @item atom
19536 Intel Atom CPU.
19538 @item core2
19539 Intel Core 2 CPU.
19541 @item corei7
19542 Intel Core i7 CPU.
19544 @item nehalem
19545 Intel Core i7 Nehalem CPU.
19547 @item westmere
19548 Intel Core i7 Westmere CPU.
19550 @item sandybridge
19551 Intel Core i7 Sandy Bridge CPU.
19553 @item amd
19554 AMD CPU.
19556 @item amdfam10h
19557 AMD Family 10h CPU.
19559 @item barcelona
19560 AMD Family 10h Barcelona CPU.
19562 @item shanghai
19563 AMD Family 10h Shanghai CPU.
19565 @item istanbul
19566 AMD Family 10h Istanbul CPU.
19568 @item btver1
19569 AMD Family 14h CPU.
19571 @item amdfam15h
19572 AMD Family 15h CPU.
19574 @item bdver1
19575 AMD Family 15h Bulldozer version 1.
19577 @item bdver2
19578 AMD Family 15h Bulldozer version 2.
19580 @item bdver3
19581 AMD Family 15h Bulldozer version 3.
19583 @item bdver4
19584 AMD Family 15h Bulldozer version 4.
19586 @item btver2
19587 AMD Family 16h CPU.
19589 @item znver1
19590 AMD Family 17h CPU.
19591 @end table
19593 Here is an example:
19594 @smallexample
19595 if (__builtin_cpu_is ("corei7"))
19596   @{
19597      do_corei7 (); // Core i7 specific implementation.
19598   @}
19599 else
19600   @{
19601      do_generic (); // Generic implementation.
19602   @}
19603 @end smallexample
19604 @end deftypefn
19606 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
19607 This function returns a positive integer if the run-time CPU
19608 supports @var{feature}
19609 and returns @code{0} otherwise. The following features can be detected:
19611 @table @samp
19612 @item cmov
19613 CMOV instruction.
19614 @item mmx
19615 MMX instructions.
19616 @item popcnt
19617 POPCNT instruction.
19618 @item sse
19619 SSE instructions.
19620 @item sse2
19621 SSE2 instructions.
19622 @item sse3
19623 SSE3 instructions.
19624 @item ssse3
19625 SSSE3 instructions.
19626 @item sse4.1
19627 SSE4.1 instructions.
19628 @item sse4.2
19629 SSE4.2 instructions.
19630 @item avx
19631 AVX instructions.
19632 @item avx2
19633 AVX2 instructions.
19634 @item avx512f
19635 AVX512F instructions.
19636 @end table
19638 Here is an example:
19639 @smallexample
19640 if (__builtin_cpu_supports ("popcnt"))
19641   @{
19642      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
19643   @}
19644 else
19645   @{
19646      count = generic_countbits (n); //generic implementation.
19647   @}
19648 @end smallexample
19649 @end deftypefn
19652 The following built-in functions are made available by @option{-mmmx}.
19653 All of them generate the machine instruction that is part of the name.
19655 @smallexample
19656 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19657 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19658 v2si __builtin_ia32_paddd (v2si, v2si)
19659 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19660 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19661 v2si __builtin_ia32_psubd (v2si, v2si)
19662 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19663 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19664 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19665 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19666 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19667 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19668 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19669 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19670 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19671 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19672 di __builtin_ia32_pand (di, di)
19673 di __builtin_ia32_pandn (di,di)
19674 di __builtin_ia32_por (di, di)
19675 di __builtin_ia32_pxor (di, di)
19676 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
19677 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
19678 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
19679 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
19680 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
19681 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
19682 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
19683 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
19684 v2si __builtin_ia32_punpckhdq (v2si, v2si)
19685 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
19686 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
19687 v2si __builtin_ia32_punpckldq (v2si, v2si)
19688 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
19689 v4hi __builtin_ia32_packssdw (v2si, v2si)
19690 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
19692 v4hi __builtin_ia32_psllw (v4hi, v4hi)
19693 v2si __builtin_ia32_pslld (v2si, v2si)
19694 v1di __builtin_ia32_psllq (v1di, v1di)
19695 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
19696 v2si __builtin_ia32_psrld (v2si, v2si)
19697 v1di __builtin_ia32_psrlq (v1di, v1di)
19698 v4hi __builtin_ia32_psraw (v4hi, v4hi)
19699 v2si __builtin_ia32_psrad (v2si, v2si)
19700 v4hi __builtin_ia32_psllwi (v4hi, int)
19701 v2si __builtin_ia32_pslldi (v2si, int)
19702 v1di __builtin_ia32_psllqi (v1di, int)
19703 v4hi __builtin_ia32_psrlwi (v4hi, int)
19704 v2si __builtin_ia32_psrldi (v2si, int)
19705 v1di __builtin_ia32_psrlqi (v1di, int)
19706 v4hi __builtin_ia32_psrawi (v4hi, int)
19707 v2si __builtin_ia32_psradi (v2si, int)
19709 @end smallexample
19711 The following built-in functions are made available either with
19712 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
19713 the machine instruction that is part of the name.
19715 @smallexample
19716 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
19717 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
19718 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
19719 v1di __builtin_ia32_psadbw (v8qi, v8qi)
19720 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
19721 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19722 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19723 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19724 int __builtin_ia32_pmovmskb (v8qi)
19725 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19726 void __builtin_ia32_movntq (di *, di)
19727 void __builtin_ia32_sfence (void)
19728 @end smallexample
19730 The following built-in functions are available when @option{-msse} is used.
19731 All of them generate the machine instruction that is part of the name.
19733 @smallexample
19734 int __builtin_ia32_comieq (v4sf, v4sf)
19735 int __builtin_ia32_comineq (v4sf, v4sf)
19736 int __builtin_ia32_comilt (v4sf, v4sf)
19737 int __builtin_ia32_comile (v4sf, v4sf)
19738 int __builtin_ia32_comigt (v4sf, v4sf)
19739 int __builtin_ia32_comige (v4sf, v4sf)
19740 int __builtin_ia32_ucomieq (v4sf, v4sf)
19741 int __builtin_ia32_ucomineq (v4sf, v4sf)
19742 int __builtin_ia32_ucomilt (v4sf, v4sf)
19743 int __builtin_ia32_ucomile (v4sf, v4sf)
19744 int __builtin_ia32_ucomigt (v4sf, v4sf)
19745 int __builtin_ia32_ucomige (v4sf, v4sf)
19746 v4sf __builtin_ia32_addps (v4sf, v4sf)
19747 v4sf __builtin_ia32_subps (v4sf, v4sf)
19748 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19749 v4sf __builtin_ia32_divps (v4sf, v4sf)
19750 v4sf __builtin_ia32_addss (v4sf, v4sf)
19751 v4sf __builtin_ia32_subss (v4sf, v4sf)
19752 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19753 v4sf __builtin_ia32_divss (v4sf, v4sf)
19754 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19755 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19756 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19757 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19758 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19759 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19760 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19761 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19762 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19763 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19764 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19765 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19766 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19767 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19768 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19769 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19770 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19771 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19772 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19773 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19774 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19775 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19776 v4sf __builtin_ia32_minps (v4sf, v4sf)
19777 v4sf __builtin_ia32_minss (v4sf, v4sf)
19778 v4sf __builtin_ia32_andps (v4sf, v4sf)
19779 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19780 v4sf __builtin_ia32_orps (v4sf, v4sf)
19781 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19782 v4sf __builtin_ia32_movss (v4sf, v4sf)
19783 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19784 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19785 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19786 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19787 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19788 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19789 v2si __builtin_ia32_cvtps2pi (v4sf)
19790 int __builtin_ia32_cvtss2si (v4sf)
19791 v2si __builtin_ia32_cvttps2pi (v4sf)
19792 int __builtin_ia32_cvttss2si (v4sf)
19793 v4sf __builtin_ia32_rcpps (v4sf)
19794 v4sf __builtin_ia32_rsqrtps (v4sf)
19795 v4sf __builtin_ia32_sqrtps (v4sf)
19796 v4sf __builtin_ia32_rcpss (v4sf)
19797 v4sf __builtin_ia32_rsqrtss (v4sf)
19798 v4sf __builtin_ia32_sqrtss (v4sf)
19799 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19800 void __builtin_ia32_movntps (float *, v4sf)
19801 int __builtin_ia32_movmskps (v4sf)
19802 @end smallexample
19804 The following built-in functions are available when @option{-msse} is used.
19806 @table @code
19807 @item v4sf __builtin_ia32_loadups (float *)
19808 Generates the @code{movups} machine instruction as a load from memory.
19809 @item void __builtin_ia32_storeups (float *, v4sf)
19810 Generates the @code{movups} machine instruction as a store to memory.
19811 @item v4sf __builtin_ia32_loadss (float *)
19812 Generates the @code{movss} machine instruction as a load from memory.
19813 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19814 Generates the @code{movhps} machine instruction as a load from memory.
19815 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19816 Generates the @code{movlps} machine instruction as a load from memory
19817 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19818 Generates the @code{movhps} machine instruction as a store to memory.
19819 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19820 Generates the @code{movlps} machine instruction as a store to memory.
19821 @end table
19823 The following built-in functions are available when @option{-msse2} is used.
19824 All of them generate the machine instruction that is part of the name.
19826 @smallexample
19827 int __builtin_ia32_comisdeq (v2df, v2df)
19828 int __builtin_ia32_comisdlt (v2df, v2df)
19829 int __builtin_ia32_comisdle (v2df, v2df)
19830 int __builtin_ia32_comisdgt (v2df, v2df)
19831 int __builtin_ia32_comisdge (v2df, v2df)
19832 int __builtin_ia32_comisdneq (v2df, v2df)
19833 int __builtin_ia32_ucomisdeq (v2df, v2df)
19834 int __builtin_ia32_ucomisdlt (v2df, v2df)
19835 int __builtin_ia32_ucomisdle (v2df, v2df)
19836 int __builtin_ia32_ucomisdgt (v2df, v2df)
19837 int __builtin_ia32_ucomisdge (v2df, v2df)
19838 int __builtin_ia32_ucomisdneq (v2df, v2df)
19839 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19840 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19841 v2df __builtin_ia32_cmplepd (v2df, v2df)
19842 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19843 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19844 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19845 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19846 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19847 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19848 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19849 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19850 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19851 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19852 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19853 v2df __builtin_ia32_cmplesd (v2df, v2df)
19854 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19855 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19856 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19857 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19858 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19859 v2di __builtin_ia32_paddq (v2di, v2di)
19860 v2di __builtin_ia32_psubq (v2di, v2di)
19861 v2df __builtin_ia32_addpd (v2df, v2df)
19862 v2df __builtin_ia32_subpd (v2df, v2df)
19863 v2df __builtin_ia32_mulpd (v2df, v2df)
19864 v2df __builtin_ia32_divpd (v2df, v2df)
19865 v2df __builtin_ia32_addsd (v2df, v2df)
19866 v2df __builtin_ia32_subsd (v2df, v2df)
19867 v2df __builtin_ia32_mulsd (v2df, v2df)
19868 v2df __builtin_ia32_divsd (v2df, v2df)
19869 v2df __builtin_ia32_minpd (v2df, v2df)
19870 v2df __builtin_ia32_maxpd (v2df, v2df)
19871 v2df __builtin_ia32_minsd (v2df, v2df)
19872 v2df __builtin_ia32_maxsd (v2df, v2df)
19873 v2df __builtin_ia32_andpd (v2df, v2df)
19874 v2df __builtin_ia32_andnpd (v2df, v2df)
19875 v2df __builtin_ia32_orpd (v2df, v2df)
19876 v2df __builtin_ia32_xorpd (v2df, v2df)
19877 v2df __builtin_ia32_movsd (v2df, v2df)
19878 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19879 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19880 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19881 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19882 v4si __builtin_ia32_paddd128 (v4si, v4si)
19883 v2di __builtin_ia32_paddq128 (v2di, v2di)
19884 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19885 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19886 v4si __builtin_ia32_psubd128 (v4si, v4si)
19887 v2di __builtin_ia32_psubq128 (v2di, v2di)
19888 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19889 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19890 v2di __builtin_ia32_pand128 (v2di, v2di)
19891 v2di __builtin_ia32_pandn128 (v2di, v2di)
19892 v2di __builtin_ia32_por128 (v2di, v2di)
19893 v2di __builtin_ia32_pxor128 (v2di, v2di)
19894 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19895 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19896 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19897 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19898 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19899 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19900 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19901 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19902 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19903 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19904 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19905 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19906 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19907 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19908 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19909 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19910 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19911 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19912 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19913 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19914 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19915 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19916 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19917 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19918 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19919 v2df __builtin_ia32_loadupd (double *)
19920 void __builtin_ia32_storeupd (double *, v2df)
19921 v2df __builtin_ia32_loadhpd (v2df, double const *)
19922 v2df __builtin_ia32_loadlpd (v2df, double const *)
19923 int __builtin_ia32_movmskpd (v2df)
19924 int __builtin_ia32_pmovmskb128 (v16qi)
19925 void __builtin_ia32_movnti (int *, int)
19926 void __builtin_ia32_movnti64 (long long int *, long long int)
19927 void __builtin_ia32_movntpd (double *, v2df)
19928 void __builtin_ia32_movntdq (v2df *, v2df)
19929 v4si __builtin_ia32_pshufd (v4si, int)
19930 v8hi __builtin_ia32_pshuflw (v8hi, int)
19931 v8hi __builtin_ia32_pshufhw (v8hi, int)
19932 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19933 v2df __builtin_ia32_sqrtpd (v2df)
19934 v2df __builtin_ia32_sqrtsd (v2df)
19935 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19936 v2df __builtin_ia32_cvtdq2pd (v4si)
19937 v4sf __builtin_ia32_cvtdq2ps (v4si)
19938 v4si __builtin_ia32_cvtpd2dq (v2df)
19939 v2si __builtin_ia32_cvtpd2pi (v2df)
19940 v4sf __builtin_ia32_cvtpd2ps (v2df)
19941 v4si __builtin_ia32_cvttpd2dq (v2df)
19942 v2si __builtin_ia32_cvttpd2pi (v2df)
19943 v2df __builtin_ia32_cvtpi2pd (v2si)
19944 int __builtin_ia32_cvtsd2si (v2df)
19945 int __builtin_ia32_cvttsd2si (v2df)
19946 long long __builtin_ia32_cvtsd2si64 (v2df)
19947 long long __builtin_ia32_cvttsd2si64 (v2df)
19948 v4si __builtin_ia32_cvtps2dq (v4sf)
19949 v2df __builtin_ia32_cvtps2pd (v4sf)
19950 v4si __builtin_ia32_cvttps2dq (v4sf)
19951 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19952 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19953 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19954 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19955 void __builtin_ia32_clflush (const void *)
19956 void __builtin_ia32_lfence (void)
19957 void __builtin_ia32_mfence (void)
19958 v16qi __builtin_ia32_loaddqu (const char *)
19959 void __builtin_ia32_storedqu (char *, v16qi)
19960 v1di __builtin_ia32_pmuludq (v2si, v2si)
19961 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19962 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19963 v4si __builtin_ia32_pslld128 (v4si, v4si)
19964 v2di __builtin_ia32_psllq128 (v2di, v2di)
19965 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19966 v4si __builtin_ia32_psrld128 (v4si, v4si)
19967 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19968 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19969 v4si __builtin_ia32_psrad128 (v4si, v4si)
19970 v2di __builtin_ia32_pslldqi128 (v2di, int)
19971 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19972 v4si __builtin_ia32_pslldi128 (v4si, int)
19973 v2di __builtin_ia32_psllqi128 (v2di, int)
19974 v2di __builtin_ia32_psrldqi128 (v2di, int)
19975 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19976 v4si __builtin_ia32_psrldi128 (v4si, int)
19977 v2di __builtin_ia32_psrlqi128 (v2di, int)
19978 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19979 v4si __builtin_ia32_psradi128 (v4si, int)
19980 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19981 v2di __builtin_ia32_movq128 (v2di)
19982 @end smallexample
19984 The following built-in functions are available when @option{-msse3} is used.
19985 All of them generate the machine instruction that is part of the name.
19987 @smallexample
19988 v2df __builtin_ia32_addsubpd (v2df, v2df)
19989 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19990 v2df __builtin_ia32_haddpd (v2df, v2df)
19991 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19992 v2df __builtin_ia32_hsubpd (v2df, v2df)
19993 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19994 v16qi __builtin_ia32_lddqu (char const *)
19995 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19996 v4sf __builtin_ia32_movshdup (v4sf)
19997 v4sf __builtin_ia32_movsldup (v4sf)
19998 void __builtin_ia32_mwait (unsigned int, unsigned int)
19999 @end smallexample
20001 The following built-in functions are available when @option{-mssse3} is used.
20002 All of them generate the machine instruction that is part of the name.
20004 @smallexample
20005 v2si __builtin_ia32_phaddd (v2si, v2si)
20006 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20007 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20008 v2si __builtin_ia32_phsubd (v2si, v2si)
20009 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20010 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20011 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20012 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20013 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20014 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20015 v2si __builtin_ia32_psignd (v2si, v2si)
20016 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20017 v1di __builtin_ia32_palignr (v1di, v1di, int)
20018 v8qi __builtin_ia32_pabsb (v8qi)
20019 v2si __builtin_ia32_pabsd (v2si)
20020 v4hi __builtin_ia32_pabsw (v4hi)
20021 @end smallexample
20023 The following built-in functions are available when @option{-mssse3} is used.
20024 All of them generate the machine instruction that is part of the name.
20026 @smallexample
20027 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20028 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20029 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20030 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20031 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20032 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20033 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20034 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20035 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20036 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20037 v4si __builtin_ia32_psignd128 (v4si, v4si)
20038 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20039 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20040 v16qi __builtin_ia32_pabsb128 (v16qi)
20041 v4si __builtin_ia32_pabsd128 (v4si)
20042 v8hi __builtin_ia32_pabsw128 (v8hi)
20043 @end smallexample
20045 The following built-in functions are available when @option{-msse4.1} is
20046 used.  All of them generate the machine instruction that is part of the
20047 name.
20049 @smallexample
20050 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20051 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20052 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20053 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20054 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20055 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20056 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20057 v2di __builtin_ia32_movntdqa (v2di *);
20058 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20059 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20060 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20061 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20062 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20063 v8hi __builtin_ia32_phminposuw128 (v8hi)
20064 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20065 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20066 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20067 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20068 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20069 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20070 v4si __builtin_ia32_pminud128 (v4si, v4si)
20071 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20072 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20073 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20074 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20075 v2di __builtin_ia32_pmovsxdq128 (v4si)
20076 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20077 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20078 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20079 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20080 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20081 v2di __builtin_ia32_pmovzxdq128 (v4si)
20082 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20083 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20084 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20085 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20086 int __builtin_ia32_ptestc128 (v2di, v2di)
20087 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20088 int __builtin_ia32_ptestz128 (v2di, v2di)
20089 v2df __builtin_ia32_roundpd (v2df, const int)
20090 v4sf __builtin_ia32_roundps (v4sf, const int)
20091 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20092 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20093 @end smallexample
20095 The following built-in functions are available when @option{-msse4.1} is
20096 used.
20098 @table @code
20099 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20100 Generates the @code{insertps} machine instruction.
20101 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20102 Generates the @code{pextrb} machine instruction.
20103 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20104 Generates the @code{pinsrb} machine instruction.
20105 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20106 Generates the @code{pinsrd} machine instruction.
20107 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20108 Generates the @code{pinsrq} machine instruction in 64bit mode.
20109 @end table
20111 The following built-in functions are changed to generate new SSE4.1
20112 instructions when @option{-msse4.1} is used.
20114 @table @code
20115 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20116 Generates the @code{extractps} machine instruction.
20117 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20118 Generates the @code{pextrd} machine instruction.
20119 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20120 Generates the @code{pextrq} machine instruction in 64bit mode.
20121 @end table
20123 The following built-in functions are available when @option{-msse4.2} is
20124 used.  All of them generate the machine instruction that is part of the
20125 name.
20127 @smallexample
20128 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
20129 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
20130 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
20131 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
20132 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
20133 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
20134 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
20135 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
20136 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
20137 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
20138 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
20139 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
20140 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
20141 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
20142 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
20143 @end smallexample
20145 The following built-in functions are available when @option{-msse4.2} is
20146 used.
20148 @table @code
20149 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
20150 Generates the @code{crc32b} machine instruction.
20151 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
20152 Generates the @code{crc32w} machine instruction.
20153 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
20154 Generates the @code{crc32l} machine instruction.
20155 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
20156 Generates the @code{crc32q} machine instruction.
20157 @end table
20159 The following built-in functions are changed to generate new SSE4.2
20160 instructions when @option{-msse4.2} is used.
20162 @table @code
20163 @item int __builtin_popcount (unsigned int)
20164 Generates the @code{popcntl} machine instruction.
20165 @item int __builtin_popcountl (unsigned long)
20166 Generates the @code{popcntl} or @code{popcntq} machine instruction,
20167 depending on the size of @code{unsigned long}.
20168 @item int __builtin_popcountll (unsigned long long)
20169 Generates the @code{popcntq} machine instruction.
20170 @end table
20172 The following built-in functions are available when @option{-mavx} is
20173 used. All of them generate the machine instruction that is part of the
20174 name.
20176 @smallexample
20177 v4df __builtin_ia32_addpd256 (v4df,v4df)
20178 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
20179 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
20180 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
20181 v4df __builtin_ia32_andnpd256 (v4df,v4df)
20182 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
20183 v4df __builtin_ia32_andpd256 (v4df,v4df)
20184 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
20185 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
20186 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
20187 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
20188 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
20189 v2df __builtin_ia32_cmppd (v2df,v2df,int)
20190 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
20191 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
20192 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
20193 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
20194 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
20195 v4df __builtin_ia32_cvtdq2pd256 (v4si)
20196 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
20197 v4si __builtin_ia32_cvtpd2dq256 (v4df)
20198 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
20199 v8si __builtin_ia32_cvtps2dq256 (v8sf)
20200 v4df __builtin_ia32_cvtps2pd256 (v4sf)
20201 v4si __builtin_ia32_cvttpd2dq256 (v4df)
20202 v8si __builtin_ia32_cvttps2dq256 (v8sf)
20203 v4df __builtin_ia32_divpd256 (v4df,v4df)
20204 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
20205 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
20206 v4df __builtin_ia32_haddpd256 (v4df,v4df)
20207 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
20208 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
20209 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
20210 v32qi __builtin_ia32_lddqu256 (pcchar)
20211 v32qi __builtin_ia32_loaddqu256 (pcchar)
20212 v4df __builtin_ia32_loadupd256 (pcdouble)
20213 v8sf __builtin_ia32_loadups256 (pcfloat)
20214 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
20215 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
20216 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
20217 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
20218 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
20219 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
20220 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
20221 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
20222 v4df __builtin_ia32_maxpd256 (v4df,v4df)
20223 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
20224 v4df __builtin_ia32_minpd256 (v4df,v4df)
20225 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
20226 v4df __builtin_ia32_movddup256 (v4df)
20227 int __builtin_ia32_movmskpd256 (v4df)
20228 int __builtin_ia32_movmskps256 (v8sf)
20229 v8sf __builtin_ia32_movshdup256 (v8sf)
20230 v8sf __builtin_ia32_movsldup256 (v8sf)
20231 v4df __builtin_ia32_mulpd256 (v4df,v4df)
20232 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
20233 v4df __builtin_ia32_orpd256 (v4df,v4df)
20234 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
20235 v2df __builtin_ia32_pd_pd256 (v4df)
20236 v4df __builtin_ia32_pd256_pd (v2df)
20237 v4sf __builtin_ia32_ps_ps256 (v8sf)
20238 v8sf __builtin_ia32_ps256_ps (v4sf)
20239 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
20240 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
20241 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
20242 v8sf __builtin_ia32_rcpps256 (v8sf)
20243 v4df __builtin_ia32_roundpd256 (v4df,int)
20244 v8sf __builtin_ia32_roundps256 (v8sf,int)
20245 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
20246 v8sf __builtin_ia32_rsqrtps256 (v8sf)
20247 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
20248 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
20249 v4si __builtin_ia32_si_si256 (v8si)
20250 v8si __builtin_ia32_si256_si (v4si)
20251 v4df __builtin_ia32_sqrtpd256 (v4df)
20252 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
20253 v8sf __builtin_ia32_sqrtps256 (v8sf)
20254 void __builtin_ia32_storedqu256 (pchar,v32qi)
20255 void __builtin_ia32_storeupd256 (pdouble,v4df)
20256 void __builtin_ia32_storeups256 (pfloat,v8sf)
20257 v4df __builtin_ia32_subpd256 (v4df,v4df)
20258 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
20259 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
20260 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
20261 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
20262 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
20263 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
20264 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
20265 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
20266 v4sf __builtin_ia32_vbroadcastss (pcfloat)
20267 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
20268 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
20269 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
20270 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
20271 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
20272 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
20273 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
20274 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
20275 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
20276 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
20277 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
20278 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
20279 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
20280 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
20281 v2df __builtin_ia32_vpermilpd (v2df,int)
20282 v4df __builtin_ia32_vpermilpd256 (v4df,int)
20283 v4sf __builtin_ia32_vpermilps (v4sf,int)
20284 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
20285 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
20286 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
20287 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
20288 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
20289 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
20290 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
20291 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
20292 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
20293 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
20294 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
20295 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
20296 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
20297 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
20298 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
20299 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
20300 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
20301 void __builtin_ia32_vzeroall (void)
20302 void __builtin_ia32_vzeroupper (void)
20303 v4df __builtin_ia32_xorpd256 (v4df,v4df)
20304 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
20305 @end smallexample
20307 The following built-in functions are available when @option{-mavx2} is
20308 used. All of them generate the machine instruction that is part of the
20309 name.
20311 @smallexample
20312 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
20313 v32qi __builtin_ia32_pabsb256 (v32qi)
20314 v16hi __builtin_ia32_pabsw256 (v16hi)
20315 v8si __builtin_ia32_pabsd256 (v8si)
20316 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
20317 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
20318 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
20319 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
20320 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
20321 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
20322 v8si __builtin_ia32_paddd256 (v8si,v8si)
20323 v4di __builtin_ia32_paddq256 (v4di,v4di)
20324 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
20325 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
20326 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20327 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20328 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20329 v4di __builtin_ia32_andsi256 (v4di,v4di)
20330 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20331 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20332 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20333 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20334 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20335 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20336 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20337 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20338 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20339 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20340 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20341 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20342 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20343 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20344 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20345 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20346 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20347 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20348 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20349 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20350 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20351 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20352 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20353 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20354 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20355 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20356 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20357 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20358 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20359 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20360 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20361 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20362 v8si __builtin_ia32_pminud256 (v8si,v8si)
20363 int __builtin_ia32_pmovmskb256 (v32qi)
20364 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20365 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20366 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20367 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20368 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20369 v4di __builtin_ia32_pmovsxdq256 (v4si)
20370 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20371 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20372 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20373 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20374 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20375 v4di __builtin_ia32_pmovzxdq256 (v4si)
20376 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20377 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20378 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20379 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20380 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20381 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20382 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20383 v4di __builtin_ia32_por256 (v4di,v4di)
20384 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20385 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20386 v8si __builtin_ia32_pshufd256 (v8si,int)
20387 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
20388 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
20389 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
20390 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
20391 v8si __builtin_ia32_psignd256 (v8si,v8si)
20392 v4di __builtin_ia32_pslldqi256 (v4di,int)
20393 v16hi __builtin_ia32_psllwi256 (16hi,int)
20394 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
20395 v8si __builtin_ia32_pslldi256 (v8si,int)
20396 v8si __builtin_ia32_pslld256(v8si,v4si)
20397 v4di __builtin_ia32_psllqi256 (v4di,int)
20398 v4di __builtin_ia32_psllq256(v4di,v2di)
20399 v16hi __builtin_ia32_psrawi256 (v16hi,int)
20400 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
20401 v8si __builtin_ia32_psradi256 (v8si,int)
20402 v8si __builtin_ia32_psrad256 (v8si,v4si)
20403 v4di __builtin_ia32_psrldqi256 (v4di, int)
20404 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
20405 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
20406 v8si __builtin_ia32_psrldi256 (v8si,int)
20407 v8si __builtin_ia32_psrld256 (v8si,v4si)
20408 v4di __builtin_ia32_psrlqi256 (v4di,int)
20409 v4di __builtin_ia32_psrlq256(v4di,v2di)
20410 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
20411 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
20412 v8si __builtin_ia32_psubd256 (v8si,v8si)
20413 v4di __builtin_ia32_psubq256 (v4di,v4di)
20414 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
20415 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
20416 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
20417 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
20418 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
20419 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
20420 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
20421 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
20422 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
20423 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
20424 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
20425 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
20426 v4di __builtin_ia32_pxor256 (v4di,v4di)
20427 v4di __builtin_ia32_movntdqa256 (pv4di)
20428 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
20429 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
20430 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
20431 v4di __builtin_ia32_vbroadcastsi256 (v2di)
20432 v4si __builtin_ia32_pblendd128 (v4si,v4si)
20433 v8si __builtin_ia32_pblendd256 (v8si,v8si)
20434 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
20435 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
20436 v8si __builtin_ia32_pbroadcastd256 (v4si)
20437 v4di __builtin_ia32_pbroadcastq256 (v2di)
20438 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
20439 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
20440 v4si __builtin_ia32_pbroadcastd128 (v4si)
20441 v2di __builtin_ia32_pbroadcastq128 (v2di)
20442 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
20443 v4df __builtin_ia32_permdf256 (v4df,int)
20444 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
20445 v4di __builtin_ia32_permdi256 (v4di,int)
20446 v4di __builtin_ia32_permti256 (v4di,v4di,int)
20447 v4di __builtin_ia32_extract128i256 (v4di,int)
20448 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
20449 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
20450 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
20451 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
20452 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
20453 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
20454 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
20455 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
20456 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
20457 v8si __builtin_ia32_psllv8si (v8si,v8si)
20458 v4si __builtin_ia32_psllv4si (v4si,v4si)
20459 v4di __builtin_ia32_psllv4di (v4di,v4di)
20460 v2di __builtin_ia32_psllv2di (v2di,v2di)
20461 v8si __builtin_ia32_psrav8si (v8si,v8si)
20462 v4si __builtin_ia32_psrav4si (v4si,v4si)
20463 v8si __builtin_ia32_psrlv8si (v8si,v8si)
20464 v4si __builtin_ia32_psrlv4si (v4si,v4si)
20465 v4di __builtin_ia32_psrlv4di (v4di,v4di)
20466 v2di __builtin_ia32_psrlv2di (v2di,v2di)
20467 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
20468 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
20469 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
20470 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
20471 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
20472 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
20473 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
20474 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
20475 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
20476 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
20477 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
20478 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
20479 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
20480 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
20481 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
20482 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
20483 @end smallexample
20485 The following built-in functions are available when @option{-maes} is
20486 used.  All of them generate the machine instruction that is part of the
20487 name.
20489 @smallexample
20490 v2di __builtin_ia32_aesenc128 (v2di, v2di)
20491 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
20492 v2di __builtin_ia32_aesdec128 (v2di, v2di)
20493 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
20494 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
20495 v2di __builtin_ia32_aesimc128 (v2di)
20496 @end smallexample
20498 The following built-in function is available when @option{-mpclmul} is
20499 used.
20501 @table @code
20502 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
20503 Generates the @code{pclmulqdq} machine instruction.
20504 @end table
20506 The following built-in function is available when @option{-mfsgsbase} is
20507 used.  All of them generate the machine instruction that is part of the
20508 name.
20510 @smallexample
20511 unsigned int __builtin_ia32_rdfsbase32 (void)
20512 unsigned long long __builtin_ia32_rdfsbase64 (void)
20513 unsigned int __builtin_ia32_rdgsbase32 (void)
20514 unsigned long long __builtin_ia32_rdgsbase64 (void)
20515 void _writefsbase_u32 (unsigned int)
20516 void _writefsbase_u64 (unsigned long long)
20517 void _writegsbase_u32 (unsigned int)
20518 void _writegsbase_u64 (unsigned long long)
20519 @end smallexample
20521 The following built-in function is available when @option{-mrdrnd} is
20522 used.  All of them generate the machine instruction that is part of the
20523 name.
20525 @smallexample
20526 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
20527 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
20528 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
20529 @end smallexample
20531 The following built-in functions are available when @option{-msse4a} is used.
20532 All of them generate the machine instruction that is part of the name.
20534 @smallexample
20535 void __builtin_ia32_movntsd (double *, v2df)
20536 void __builtin_ia32_movntss (float *, v4sf)
20537 v2di __builtin_ia32_extrq  (v2di, v16qi)
20538 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
20539 v2di __builtin_ia32_insertq (v2di, v2di)
20540 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
20541 @end smallexample
20543 The following built-in functions are available when @option{-mxop} is used.
20544 @smallexample
20545 v2df __builtin_ia32_vfrczpd (v2df)
20546 v4sf __builtin_ia32_vfrczps (v4sf)
20547 v2df __builtin_ia32_vfrczsd (v2df)
20548 v4sf __builtin_ia32_vfrczss (v4sf)
20549 v4df __builtin_ia32_vfrczpd256 (v4df)
20550 v8sf __builtin_ia32_vfrczps256 (v8sf)
20551 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
20552 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
20553 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
20554 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
20555 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
20556 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
20557 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
20558 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
20559 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
20560 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
20561 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
20562 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
20563 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
20564 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
20565 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20566 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
20567 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
20568 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
20569 v4si __builtin_ia32_vpcomequd (v4si, v4si)
20570 v2di __builtin_ia32_vpcomequq (v2di, v2di)
20571 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
20572 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20573 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
20574 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
20575 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
20576 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
20577 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
20578 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
20579 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
20580 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
20581 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
20582 v4si __builtin_ia32_vpcomged (v4si, v4si)
20583 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
20584 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
20585 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
20586 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
20587 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
20588 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
20589 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
20590 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
20591 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
20592 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
20593 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
20594 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
20595 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
20596 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
20597 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
20598 v4si __builtin_ia32_vpcomled (v4si, v4si)
20599 v2di __builtin_ia32_vpcomleq (v2di, v2di)
20600 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
20601 v4si __builtin_ia32_vpcomleud (v4si, v4si)
20602 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
20603 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
20604 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
20605 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
20606 v4si __builtin_ia32_vpcomltd (v4si, v4si)
20607 v2di __builtin_ia32_vpcomltq (v2di, v2di)
20608 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
20609 v4si __builtin_ia32_vpcomltud (v4si, v4si)
20610 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
20611 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
20612 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
20613 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
20614 v4si __builtin_ia32_vpcomned (v4si, v4si)
20615 v2di __builtin_ia32_vpcomneq (v2di, v2di)
20616 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
20617 v4si __builtin_ia32_vpcomneud (v4si, v4si)
20618 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
20619 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
20620 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
20621 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
20622 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
20623 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
20624 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
20625 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
20626 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
20627 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
20628 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
20629 v4si __builtin_ia32_vphaddbd (v16qi)
20630 v2di __builtin_ia32_vphaddbq (v16qi)
20631 v8hi __builtin_ia32_vphaddbw (v16qi)
20632 v2di __builtin_ia32_vphadddq (v4si)
20633 v4si __builtin_ia32_vphaddubd (v16qi)
20634 v2di __builtin_ia32_vphaddubq (v16qi)
20635 v8hi __builtin_ia32_vphaddubw (v16qi)
20636 v2di __builtin_ia32_vphaddudq (v4si)
20637 v4si __builtin_ia32_vphadduwd (v8hi)
20638 v2di __builtin_ia32_vphadduwq (v8hi)
20639 v4si __builtin_ia32_vphaddwd (v8hi)
20640 v2di __builtin_ia32_vphaddwq (v8hi)
20641 v8hi __builtin_ia32_vphsubbw (v16qi)
20642 v2di __builtin_ia32_vphsubdq (v4si)
20643 v4si __builtin_ia32_vphsubwd (v8hi)
20644 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
20645 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
20646 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
20647 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
20648 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
20649 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
20650 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
20651 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
20652 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
20653 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
20654 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
20655 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20656 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20657 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20658 v4si __builtin_ia32_vprotd (v4si, v4si)
20659 v2di __builtin_ia32_vprotq (v2di, v2di)
20660 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20661 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20662 v4si __builtin_ia32_vpshad (v4si, v4si)
20663 v2di __builtin_ia32_vpshaq (v2di, v2di)
20664 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20665 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20666 v4si __builtin_ia32_vpshld (v4si, v4si)
20667 v2di __builtin_ia32_vpshlq (v2di, v2di)
20668 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20669 @end smallexample
20671 The following built-in functions are available when @option{-mfma4} is used.
20672 All of them generate the machine instruction that is part of the name.
20674 @smallexample
20675 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
20676 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
20677 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
20678 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
20679 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
20680 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
20681 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
20682 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
20683 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
20684 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
20685 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
20686 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
20687 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
20688 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
20689 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
20690 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
20691 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
20692 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
20693 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
20694 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
20695 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
20696 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
20697 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
20698 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
20699 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
20700 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
20701 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
20702 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
20703 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
20704 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
20705 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
20706 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
20708 @end smallexample
20710 The following built-in functions are available when @option{-mlwp} is used.
20712 @smallexample
20713 void __builtin_ia32_llwpcb16 (void *);
20714 void __builtin_ia32_llwpcb32 (void *);
20715 void __builtin_ia32_llwpcb64 (void *);
20716 void * __builtin_ia32_llwpcb16 (void);
20717 void * __builtin_ia32_llwpcb32 (void);
20718 void * __builtin_ia32_llwpcb64 (void);
20719 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
20720 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
20721 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20722 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20723 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20724 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20725 @end smallexample
20727 The following built-in functions are available when @option{-mbmi} is used.
20728 All of them generate the machine instruction that is part of the name.
20729 @smallexample
20730 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20731 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20732 @end smallexample
20734 The following built-in functions are available when @option{-mbmi2} is used.
20735 All of them generate the machine instruction that is part of the name.
20736 @smallexample
20737 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20738 unsigned int _pdep_u32 (unsigned int, unsigned int)
20739 unsigned int _pext_u32 (unsigned int, unsigned int)
20740 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20741 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20742 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20743 @end smallexample
20745 The following built-in functions are available when @option{-mlzcnt} is used.
20746 All of them generate the machine instruction that is part of the name.
20747 @smallexample
20748 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20749 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20750 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20751 @end smallexample
20753 The following built-in functions are available when @option{-mfxsr} is used.
20754 All of them generate the machine instruction that is part of the name.
20755 @smallexample
20756 void __builtin_ia32_fxsave (void *)
20757 void __builtin_ia32_fxrstor (void *)
20758 void __builtin_ia32_fxsave64 (void *)
20759 void __builtin_ia32_fxrstor64 (void *)
20760 @end smallexample
20762 The following built-in functions are available when @option{-mxsave} is used.
20763 All of them generate the machine instruction that is part of the name.
20764 @smallexample
20765 void __builtin_ia32_xsave (void *, long long)
20766 void __builtin_ia32_xrstor (void *, long long)
20767 void __builtin_ia32_xsave64 (void *, long long)
20768 void __builtin_ia32_xrstor64 (void *, long long)
20769 @end smallexample
20771 The following built-in functions are available when @option{-mxsaveopt} is used.
20772 All of them generate the machine instruction that is part of the name.
20773 @smallexample
20774 void __builtin_ia32_xsaveopt (void *, long long)
20775 void __builtin_ia32_xsaveopt64 (void *, long long)
20776 @end smallexample
20778 The following built-in functions are available when @option{-mtbm} is used.
20779 Both of them generate the immediate form of the bextr machine instruction.
20780 @smallexample
20781 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
20782                                         const unsigned int);
20783 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
20784                                               const unsigned long long);
20785 @end smallexample
20788 The following built-in functions are available when @option{-m3dnow} is used.
20789 All of them generate the machine instruction that is part of the name.
20791 @smallexample
20792 void __builtin_ia32_femms (void)
20793 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20794 v2si __builtin_ia32_pf2id (v2sf)
20795 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20796 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20797 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20798 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20799 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20800 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20801 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20802 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20803 v2sf __builtin_ia32_pfrcp (v2sf)
20804 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20805 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20806 v2sf __builtin_ia32_pfrsqrt (v2sf)
20807 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20808 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20809 v2sf __builtin_ia32_pi2fd (v2si)
20810 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20811 @end smallexample
20813 The following built-in functions are available when @option{-m3dnowa} is used.
20814 All of them generate the machine instruction that is part of the name.
20816 @smallexample
20817 v2si __builtin_ia32_pf2iw (v2sf)
20818 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20819 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20820 v2sf __builtin_ia32_pi2fw (v2si)
20821 v2sf __builtin_ia32_pswapdsf (v2sf)
20822 v2si __builtin_ia32_pswapdsi (v2si)
20823 @end smallexample
20825 The following built-in functions are available when @option{-mrtm} is used
20826 They are used for restricted transactional memory. These are the internal
20827 low level functions. Normally the functions in 
20828 @ref{x86 transactional memory intrinsics} should be used instead.
20830 @smallexample
20831 int __builtin_ia32_xbegin ()
20832 void __builtin_ia32_xend ()
20833 void __builtin_ia32_xabort (status)
20834 int __builtin_ia32_xtest ()
20835 @end smallexample
20837 The following built-in functions are available when @option{-mmwaitx} is used.
20838 All of them generate the machine instruction that is part of the name.
20839 @smallexample
20840 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20841 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20842 @end smallexample
20844 The following built-in functions are available when @option{-mclzero} is used.
20845 All of them generate the machine instruction that is part of the name.
20846 @smallexample
20847 void __builtin_i32_clzero (void *)
20848 @end smallexample
20850 The following built-in functions are available when @option{-mpku} is used.
20851 They generate reads and writes to PKRU.
20852 @smallexample
20853 void __builtin_ia32_wrpkru (unsigned int)
20854 unsigned int __builtin_ia32_rdpkru ()
20855 @end smallexample
20857 @node x86 transactional memory intrinsics
20858 @subsection x86 Transactional Memory Intrinsics
20860 These hardware transactional memory intrinsics for x86 allow you to use
20861 memory transactions with RTM (Restricted Transactional Memory).
20862 This support is enabled with the @option{-mrtm} option.
20863 For using HLE (Hardware Lock Elision) see 
20864 @ref{x86 specific memory model extensions for transactional memory} instead.
20866 A memory transaction commits all changes to memory in an atomic way,
20867 as visible to other threads. If the transaction fails it is rolled back
20868 and all side effects discarded.
20870 Generally there is no guarantee that a memory transaction ever succeeds
20871 and suitable fallback code always needs to be supplied.
20873 @deftypefn {RTM Function} {unsigned} _xbegin ()
20874 Start a RTM (Restricted Transactional Memory) transaction. 
20875 Returns @code{_XBEGIN_STARTED} when the transaction
20876 started successfully (note this is not 0, so the constant has to be 
20877 explicitly tested).  
20879 If the transaction aborts, all side-effects 
20880 are undone and an abort code encoded as a bit mask is returned.
20881 The following macros are defined:
20883 @table @code
20884 @item _XABORT_EXPLICIT
20885 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
20886 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20887 @item _XABORT_RETRY
20888 Transaction retry is possible.
20889 @item _XABORT_CONFLICT
20890 Transaction abort due to a memory conflict with another thread.
20891 @item _XABORT_CAPACITY
20892 Transaction abort due to the transaction using too much memory.
20893 @item _XABORT_DEBUG
20894 Transaction abort due to a debug trap.
20895 @item _XABORT_NESTED
20896 Transaction abort in an inner nested transaction.
20897 @end table
20899 There is no guarantee
20900 any transaction ever succeeds, so there always needs to be a valid
20901 fallback path.
20902 @end deftypefn
20904 @deftypefn {RTM Function} {void} _xend ()
20905 Commit the current transaction. When no transaction is active this faults.
20906 All memory side-effects of the transaction become visible
20907 to other threads in an atomic manner.
20908 @end deftypefn
20910 @deftypefn {RTM Function} {int} _xtest ()
20911 Return a nonzero value if a transaction is currently active, otherwise 0.
20912 @end deftypefn
20914 @deftypefn {RTM Function} {void} _xabort (status)
20915 Abort the current transaction. When no transaction is active this is a no-op.
20916 The @var{status} is an 8-bit constant; its value is encoded in the return 
20917 value from @code{_xbegin}.
20918 @end deftypefn
20920 Here is an example showing handling for @code{_XABORT_RETRY}
20921 and a fallback path for other failures:
20923 @smallexample
20924 #include <immintrin.h>
20926 int n_tries, max_tries;
20927 unsigned status = _XABORT_EXPLICIT;
20930 for (n_tries = 0; n_tries < max_tries; n_tries++) 
20931   @{
20932     status = _xbegin ();
20933     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20934       break;
20935   @}
20936 if (status == _XBEGIN_STARTED) 
20937   @{
20938     ... transaction code...
20939     _xend ();
20940   @} 
20941 else 
20942   @{
20943     ... non-transactional fallback path...
20944   @}
20945 @end smallexample
20947 @noindent
20948 Note that, in most cases, the transactional and non-transactional code
20949 must synchronize together to ensure consistency.
20951 @node Target Format Checks
20952 @section Format Checks Specific to Particular Target Machines
20954 For some target machines, GCC supports additional options to the
20955 format attribute
20956 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20958 @menu
20959 * Solaris Format Checks::
20960 * Darwin Format Checks::
20961 @end menu
20963 @node Solaris Format Checks
20964 @subsection Solaris Format Checks
20966 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20967 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
20968 conversions, and the two-argument @code{%b} conversion for displaying
20969 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
20971 @node Darwin Format Checks
20972 @subsection Darwin Format Checks
20974 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20975 attribute context.  Declarations made with such attribution are parsed for correct syntax
20976 and format argument types.  However, parsing of the format string itself is currently undefined
20977 and is not carried out by this version of the compiler.
20979 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20980 also be used as format arguments.  Note that the relevant headers are only likely to be
20981 available on Darwin (OSX) installations.  On such installations, the XCode and system
20982 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20983 associated functions.
20985 @node Pragmas
20986 @section Pragmas Accepted by GCC
20987 @cindex pragmas
20988 @cindex @code{#pragma}
20990 GCC supports several types of pragmas, primarily in order to compile
20991 code originally written for other compilers.  Note that in general
20992 we do not recommend the use of pragmas; @xref{Function Attributes},
20993 for further explanation.
20995 @menu
20996 * AArch64 Pragmas::
20997 * ARM Pragmas::
20998 * M32C Pragmas::
20999 * MeP Pragmas::
21000 * RS/6000 and PowerPC Pragmas::
21001 * S/390 Pragmas::
21002 * Darwin Pragmas::
21003 * Solaris Pragmas::
21004 * Symbol-Renaming Pragmas::
21005 * Structure-Layout Pragmas::
21006 * Weak Pragmas::
21007 * Diagnostic Pragmas::
21008 * Visibility Pragmas::
21009 * Push/Pop Macro Pragmas::
21010 * Function Specific Option Pragmas::
21011 * Loop-Specific Pragmas::
21012 @end menu
21014 @node AArch64 Pragmas
21015 @subsection AArch64 Pragmas
21017 The pragmas defined by the AArch64 target correspond to the AArch64
21018 target function attributes.  They can be specified as below:
21019 @smallexample
21020 #pragma GCC target("string")
21021 @end smallexample
21023 where @code{@var{string}} can be any string accepted as an AArch64 target
21024 attribute.  @xref{AArch64 Function Attributes}, for more details
21025 on the permissible values of @code{string}.
21027 @node ARM Pragmas
21028 @subsection ARM Pragmas
21030 The ARM target defines pragmas for controlling the default addition of
21031 @code{long_call} and @code{short_call} attributes to functions.
21032 @xref{Function Attributes}, for information about the effects of these
21033 attributes.
21035 @table @code
21036 @item long_calls
21037 @cindex pragma, long_calls
21038 Set all subsequent functions to have the @code{long_call} attribute.
21040 @item no_long_calls
21041 @cindex pragma, no_long_calls
21042 Set all subsequent functions to have the @code{short_call} attribute.
21044 @item long_calls_off
21045 @cindex pragma, long_calls_off
21046 Do not affect the @code{long_call} or @code{short_call} attributes of
21047 subsequent functions.
21048 @end table
21050 @node M32C Pragmas
21051 @subsection M32C Pragmas
21053 @table @code
21054 @item GCC memregs @var{number}
21055 @cindex pragma, memregs
21056 Overrides the command-line option @code{-memregs=} for the current
21057 file.  Use with care!  This pragma must be before any function in the
21058 file, and mixing different memregs values in different objects may
21059 make them incompatible.  This pragma is useful when a
21060 performance-critical function uses a memreg for temporary values,
21061 as it may allow you to reduce the number of memregs used.
21063 @item ADDRESS @var{name} @var{address}
21064 @cindex pragma, address
21065 For any declared symbols matching @var{name}, this does three things
21066 to that symbol: it forces the symbol to be located at the given
21067 address (a number), it forces the symbol to be volatile, and it
21068 changes the symbol's scope to be static.  This pragma exists for
21069 compatibility with other compilers, but note that the common
21070 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21071 instead).  Example:
21073 @smallexample
21074 #pragma ADDRESS port3 0x103
21075 char port3;
21076 @end smallexample
21078 @end table
21080 @node MeP Pragmas
21081 @subsection MeP Pragmas
21083 @table @code
21085 @item custom io_volatile (on|off)
21086 @cindex pragma, custom io_volatile
21087 Overrides the command-line option @code{-mio-volatile} for the current
21088 file.  Note that for compatibility with future GCC releases, this
21089 option should only be used once before any @code{io} variables in each
21090 file.
21092 @item GCC coprocessor available @var{registers}
21093 @cindex pragma, coprocessor available
21094 Specifies which coprocessor registers are available to the register
21095 allocator.  @var{registers} may be a single register, register range
21096 separated by ellipses, or comma-separated list of those.  Example:
21098 @smallexample
21099 #pragma GCC coprocessor available $c0...$c10, $c28
21100 @end smallexample
21102 @item GCC coprocessor call_saved @var{registers}
21103 @cindex pragma, coprocessor call_saved
21104 Specifies which coprocessor registers are to be saved and restored by
21105 any function using them.  @var{registers} may be a single register,
21106 register range separated by ellipses, or comma-separated list of
21107 those.  Example:
21109 @smallexample
21110 #pragma GCC coprocessor call_saved $c4...$c6, $c31
21111 @end smallexample
21113 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
21114 @cindex pragma, coprocessor subclass
21115 Creates and defines a register class.  These register classes can be
21116 used by inline @code{asm} constructs.  @var{registers} may be a single
21117 register, register range separated by ellipses, or comma-separated
21118 list of those.  Example:
21120 @smallexample
21121 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
21123 asm ("cpfoo %0" : "=B" (x));
21124 @end smallexample
21126 @item GCC disinterrupt @var{name} , @var{name} @dots{}
21127 @cindex pragma, disinterrupt
21128 For the named functions, the compiler adds code to disable interrupts
21129 for the duration of those functions.  If any functions so named 
21130 are not encountered in the source, a warning is emitted that the pragma is
21131 not used.  Examples:
21133 @smallexample
21134 #pragma disinterrupt foo
21135 #pragma disinterrupt bar, grill
21136 int foo () @{ @dots{} @}
21137 @end smallexample
21139 @item GCC call @var{name} , @var{name} @dots{}
21140 @cindex pragma, call
21141 For the named functions, the compiler always uses a register-indirect
21142 call model when calling the named functions.  Examples:
21144 @smallexample
21145 extern int foo ();
21146 #pragma call foo
21147 @end smallexample
21149 @end table
21151 @node RS/6000 and PowerPC Pragmas
21152 @subsection RS/6000 and PowerPC Pragmas
21154 The RS/6000 and PowerPC targets define one pragma for controlling
21155 whether or not the @code{longcall} attribute is added to function
21156 declarations by default.  This pragma overrides the @option{-mlongcall}
21157 option, but not the @code{longcall} and @code{shortcall} attributes.
21158 @xref{RS/6000 and PowerPC Options}, for more information about when long
21159 calls are and are not necessary.
21161 @table @code
21162 @item longcall (1)
21163 @cindex pragma, longcall
21164 Apply the @code{longcall} attribute to all subsequent function
21165 declarations.
21167 @item longcall (0)
21168 Do not apply the @code{longcall} attribute to subsequent function
21169 declarations.
21170 @end table
21172 @c Describe h8300 pragmas here.
21173 @c Describe sh pragmas here.
21174 @c Describe v850 pragmas here.
21176 @node S/390 Pragmas
21177 @subsection S/390 Pragmas
21179 The pragmas defined by the S/390 target correspond to the S/390
21180 target function attributes and some the additional options:
21182 @table @samp
21183 @item zvector
21184 @itemx no-zvector
21185 @end table
21187 Note that options of the pragma, unlike options of the target
21188 attribute, do change the value of preprocessor macros like
21189 @code{__VEC__}.  They can be specified as below:
21191 @smallexample
21192 #pragma GCC target("string[,string]...")
21193 #pragma GCC target("string"[,"string"]...)
21194 @end smallexample
21196 @node Darwin Pragmas
21197 @subsection Darwin Pragmas
21199 The following pragmas are available for all architectures running the
21200 Darwin operating system.  These are useful for compatibility with other
21201 Mac OS compilers.
21203 @table @code
21204 @item mark @var{tokens}@dots{}
21205 @cindex pragma, mark
21206 This pragma is accepted, but has no effect.
21208 @item options align=@var{alignment}
21209 @cindex pragma, options align
21210 This pragma sets the alignment of fields in structures.  The values of
21211 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
21212 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
21213 properly; to restore the previous setting, use @code{reset} for the
21214 @var{alignment}.
21216 @item segment @var{tokens}@dots{}
21217 @cindex pragma, segment
21218 This pragma is accepted, but has no effect.
21220 @item unused (@var{var} [, @var{var}]@dots{})
21221 @cindex pragma, unused
21222 This pragma declares variables to be possibly unused.  GCC does not
21223 produce warnings for the listed variables.  The effect is similar to
21224 that of the @code{unused} attribute, except that this pragma may appear
21225 anywhere within the variables' scopes.
21226 @end table
21228 @node Solaris Pragmas
21229 @subsection Solaris Pragmas
21231 The Solaris target supports @code{#pragma redefine_extname}
21232 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
21233 @code{#pragma} directives for compatibility with the system compiler.
21235 @table @code
21236 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
21237 @cindex pragma, align
21239 Increase the minimum alignment of each @var{variable} to @var{alignment}.
21240 This is the same as GCC's @code{aligned} attribute @pxref{Variable
21241 Attributes}).  Macro expansion occurs on the arguments to this pragma
21242 when compiling C and Objective-C@.  It does not currently occur when
21243 compiling C++, but this is a bug which may be fixed in a future
21244 release.
21246 @item fini (@var{function} [, @var{function}]...)
21247 @cindex pragma, fini
21249 This pragma causes each listed @var{function} to be called after
21250 main, or during shared module unloading, by adding a call to the
21251 @code{.fini} section.
21253 @item init (@var{function} [, @var{function}]...)
21254 @cindex pragma, init
21256 This pragma causes each listed @var{function} to be called during
21257 initialization (before @code{main}) or during shared module loading, by
21258 adding a call to the @code{.init} section.
21260 @end table
21262 @node Symbol-Renaming Pragmas
21263 @subsection Symbol-Renaming Pragmas
21265 GCC supports a @code{#pragma} directive that changes the name used in
21266 assembly for a given declaration. While this pragma is supported on all
21267 platforms, it is intended primarily to provide compatibility with the
21268 Solaris system headers. This effect can also be achieved using the asm
21269 labels extension (@pxref{Asm Labels}).
21271 @table @code
21272 @item redefine_extname @var{oldname} @var{newname}
21273 @cindex pragma, redefine_extname
21275 This pragma gives the C function @var{oldname} the assembly symbol
21276 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
21277 is defined if this pragma is available (currently on all platforms).
21278 @end table
21280 This pragma and the asm labels extension interact in a complicated
21281 manner.  Here are some corner cases you may want to be aware of:
21283 @enumerate
21284 @item This pragma silently applies only to declarations with external
21285 linkage.  Asm labels do not have this restriction.
21287 @item In C++, this pragma silently applies only to declarations with
21288 ``C'' linkage.  Again, asm labels do not have this restriction.
21290 @item If either of the ways of changing the assembly name of a
21291 declaration are applied to a declaration whose assembly name has
21292 already been determined (either by a previous use of one of these
21293 features, or because the compiler needed the assembly name in order to
21294 generate code), and the new name is different, a warning issues and
21295 the name does not change.
21297 @item The @var{oldname} used by @code{#pragma redefine_extname} is
21298 always the C-language name.
21299 @end enumerate
21301 @node Structure-Layout Pragmas
21302 @subsection Structure-Layout Pragmas
21304 For compatibility with Microsoft Windows compilers, GCC supports a
21305 set of @code{#pragma} directives that change the maximum alignment of
21306 members of structures (other than zero-width bit-fields), unions, and
21307 classes subsequently defined. The @var{n} value below always is required
21308 to be a small power of two and specifies the new alignment in bytes.
21310 @enumerate
21311 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
21312 @item @code{#pragma pack()} sets the alignment to the one that was in
21313 effect when compilation started (see also command-line option
21314 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
21315 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
21316 setting on an internal stack and then optionally sets the new alignment.
21317 @item @code{#pragma pack(pop)} restores the alignment setting to the one
21318 saved at the top of the internal stack (and removes that stack entry).
21319 Note that @code{#pragma pack([@var{n}])} does not influence this internal
21320 stack; thus it is possible to have @code{#pragma pack(push)} followed by
21321 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
21322 @code{#pragma pack(pop)}.
21323 @end enumerate
21325 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
21326 directive which lays out structures and unions subsequently defined as the
21327 documented @code{__attribute__ ((ms_struct))}.
21329 @enumerate
21330 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21331 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21332 @item @code{#pragma ms_struct reset} goes back to the default layout.
21333 @end enumerate
21335 Most targets also support the @code{#pragma scalar_storage_order} directive
21336 which lays out structures and unions subsequently defined as the documented
21337 @code{__attribute__ ((scalar_storage_order))}.
21339 @enumerate
21340 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21341 of the scalar fields to big-endian.
21342 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21343 of the scalar fields to little-endian.
21344 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21345 that was in effect when compilation started (see also command-line option
21346 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21347 @end enumerate
21349 @node Weak Pragmas
21350 @subsection Weak Pragmas
21352 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21353 directives for declaring symbols to be weak, and defining weak
21354 aliases.
21356 @table @code
21357 @item #pragma weak @var{symbol}
21358 @cindex pragma, weak
21359 This pragma declares @var{symbol} to be weak, as if the declaration
21360 had the attribute of the same name.  The pragma may appear before
21361 or after the declaration of @var{symbol}.  It is not an error for
21362 @var{symbol} to never be defined at all.
21364 @item #pragma weak @var{symbol1} = @var{symbol2}
21365 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21366 It is an error if @var{symbol2} is not defined in the current
21367 translation unit.
21368 @end table
21370 @node Diagnostic Pragmas
21371 @subsection Diagnostic Pragmas
21373 GCC allows the user to selectively enable or disable certain types of
21374 diagnostics, and change the kind of the diagnostic.  For example, a
21375 project's policy might require that all sources compile with
21376 @option{-Werror} but certain files might have exceptions allowing
21377 specific types of warnings.  Or, a project might selectively enable
21378 diagnostics and treat them as errors depending on which preprocessor
21379 macros are defined.
21381 @table @code
21382 @item #pragma GCC diagnostic @var{kind} @var{option}
21383 @cindex pragma, diagnostic
21385 Modifies the disposition of a diagnostic.  Note that not all
21386 diagnostics are modifiable; at the moment only warnings (normally
21387 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
21388 Use @option{-fdiagnostics-show-option} to determine which diagnostics
21389 are controllable and which option controls them.
21391 @var{kind} is @samp{error} to treat this diagnostic as an error,
21392 @samp{warning} to treat it like a warning (even if @option{-Werror} is
21393 in effect), or @samp{ignored} if the diagnostic is to be ignored.
21394 @var{option} is a double quoted string that matches the command-line
21395 option.
21397 @smallexample
21398 #pragma GCC diagnostic warning "-Wformat"
21399 #pragma GCC diagnostic error "-Wformat"
21400 #pragma GCC diagnostic ignored "-Wformat"
21401 @end smallexample
21403 Note that these pragmas override any command-line options.  GCC keeps
21404 track of the location of each pragma, and issues diagnostics according
21405 to the state as of that point in the source file.  Thus, pragmas occurring
21406 after a line do not affect diagnostics caused by that line.
21408 @item #pragma GCC diagnostic push
21409 @itemx #pragma GCC diagnostic pop
21411 Causes GCC to remember the state of the diagnostics as of each
21412 @code{push}, and restore to that point at each @code{pop}.  If a
21413 @code{pop} has no matching @code{push}, the command-line options are
21414 restored.
21416 @smallexample
21417 #pragma GCC diagnostic error "-Wuninitialized"
21418   foo(a);                       /* error is given for this one */
21419 #pragma GCC diagnostic push
21420 #pragma GCC diagnostic ignored "-Wuninitialized"
21421   foo(b);                       /* no diagnostic for this one */
21422 #pragma GCC diagnostic pop
21423   foo(c);                       /* error is given for this one */
21424 #pragma GCC diagnostic pop
21425   foo(d);                       /* depends on command-line options */
21426 @end smallexample
21428 @end table
21430 GCC also offers a simple mechanism for printing messages during
21431 compilation.
21433 @table @code
21434 @item #pragma message @var{string}
21435 @cindex pragma, diagnostic
21437 Prints @var{string} as a compiler message on compilation.  The message
21438 is informational only, and is neither a compilation warning nor an error.
21440 @smallexample
21441 #pragma message "Compiling " __FILE__ "..."
21442 @end smallexample
21444 @var{string} may be parenthesized, and is printed with location
21445 information.  For example,
21447 @smallexample
21448 #define DO_PRAGMA(x) _Pragma (#x)
21449 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
21451 TODO(Remember to fix this)
21452 @end smallexample
21454 @noindent
21455 prints @samp{/tmp/file.c:4: note: #pragma message:
21456 TODO - Remember to fix this}.
21458 @end table
21460 @node Visibility Pragmas
21461 @subsection Visibility Pragmas
21463 @table @code
21464 @item #pragma GCC visibility push(@var{visibility})
21465 @itemx #pragma GCC visibility pop
21466 @cindex pragma, visibility
21468 This pragma allows the user to set the visibility for multiple
21469 declarations without having to give each a visibility attribute
21470 (@pxref{Function Attributes}).
21472 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
21473 declarations.  Class members and template specializations are not
21474 affected; if you want to override the visibility for a particular
21475 member or instantiation, you must use an attribute.
21477 @end table
21480 @node Push/Pop Macro Pragmas
21481 @subsection Push/Pop Macro Pragmas
21483 For compatibility with Microsoft Windows compilers, GCC supports
21484 @samp{#pragma push_macro(@var{"macro_name"})}
21485 and @samp{#pragma pop_macro(@var{"macro_name"})}.
21487 @table @code
21488 @item #pragma push_macro(@var{"macro_name"})
21489 @cindex pragma, push_macro
21490 This pragma saves the value of the macro named as @var{macro_name} to
21491 the top of the stack for this macro.
21493 @item #pragma pop_macro(@var{"macro_name"})
21494 @cindex pragma, pop_macro
21495 This pragma sets the value of the macro named as @var{macro_name} to
21496 the value on top of the stack for this macro. If the stack for
21497 @var{macro_name} is empty, the value of the macro remains unchanged.
21498 @end table
21500 For example:
21502 @smallexample
21503 #define X  1
21504 #pragma push_macro("X")
21505 #undef X
21506 #define X -1
21507 #pragma pop_macro("X")
21508 int x [X];
21509 @end smallexample
21511 @noindent
21512 In this example, the definition of X as 1 is saved by @code{#pragma
21513 push_macro} and restored by @code{#pragma pop_macro}.
21515 @node Function Specific Option Pragmas
21516 @subsection Function Specific Option Pragmas
21518 @table @code
21519 @item #pragma GCC target (@var{"string"}...)
21520 @cindex pragma GCC target
21522 This pragma allows you to set target specific options for functions
21523 defined later in the source file.  One or more strings can be
21524 specified.  Each function that is defined after this point is as
21525 if @code{attribute((target("STRING")))} was specified for that
21526 function.  The parenthesis around the options is optional.
21527 @xref{Function Attributes}, for more information about the
21528 @code{target} attribute and the attribute syntax.
21530 The @code{#pragma GCC target} pragma is presently implemented for
21531 x86, PowerPC, and Nios II targets only.
21532 @end table
21534 @table @code
21535 @item #pragma GCC optimize (@var{"string"}...)
21536 @cindex pragma GCC optimize
21538 This pragma allows you to set global optimization options for functions
21539 defined later in the source file.  One or more strings can be
21540 specified.  Each function that is defined after this point is as
21541 if @code{attribute((optimize("STRING")))} was specified for that
21542 function.  The parenthesis around the options is optional.
21543 @xref{Function Attributes}, for more information about the
21544 @code{optimize} attribute and the attribute syntax.
21545 @end table
21547 @table @code
21548 @item #pragma GCC push_options
21549 @itemx #pragma GCC pop_options
21550 @cindex pragma GCC push_options
21551 @cindex pragma GCC pop_options
21553 These pragmas maintain a stack of the current target and optimization
21554 options.  It is intended for include files where you temporarily want
21555 to switch to using a different @samp{#pragma GCC target} or
21556 @samp{#pragma GCC optimize} and then to pop back to the previous
21557 options.
21558 @end table
21560 @table @code
21561 @item #pragma GCC reset_options
21562 @cindex pragma GCC reset_options
21564 This pragma clears the current @code{#pragma GCC target} and
21565 @code{#pragma GCC optimize} to use the default switches as specified
21566 on the command line.
21567 @end table
21569 @node Loop-Specific Pragmas
21570 @subsection Loop-Specific Pragmas
21572 @table @code
21573 @item #pragma GCC ivdep
21574 @cindex pragma GCC ivdep
21575 @end table
21577 With this pragma, the programmer asserts that there are no loop-carried
21578 dependencies which would prevent consecutive iterations of
21579 the following loop from executing concurrently with SIMD
21580 (single instruction multiple data) instructions.
21582 For example, the compiler can only unconditionally vectorize the following
21583 loop with the pragma:
21585 @smallexample
21586 void foo (int n, int *a, int *b, int *c)
21588   int i, j;
21589 #pragma GCC ivdep
21590   for (i = 0; i < n; ++i)
21591     a[i] = b[i] + c[i];
21593 @end smallexample
21595 @noindent
21596 In this example, using the @code{restrict} qualifier had the same
21597 effect. In the following example, that would not be possible. Assume
21598 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
21599 that it can unconditionally vectorize the following loop:
21601 @smallexample
21602 void ignore_vec_dep (int *a, int k, int c, int m)
21604 #pragma GCC ivdep
21605   for (int i = 0; i < m; i++)
21606     a[i] = a[i + k] * c;
21608 @end smallexample
21611 @node Unnamed Fields
21612 @section Unnamed Structure and Union Fields
21613 @cindex @code{struct}
21614 @cindex @code{union}
21616 As permitted by ISO C11 and for compatibility with other compilers,
21617 GCC allows you to define
21618 a structure or union that contains, as fields, structures and unions
21619 without names.  For example:
21621 @smallexample
21622 struct @{
21623   int a;
21624   union @{
21625     int b;
21626     float c;
21627   @};
21628   int d;
21629 @} foo;
21630 @end smallexample
21632 @noindent
21633 In this example, you are able to access members of the unnamed
21634 union with code like @samp{foo.b}.  Note that only unnamed structs and
21635 unions are allowed, you may not have, for example, an unnamed
21636 @code{int}.
21638 You must never create such structures that cause ambiguous field definitions.
21639 For example, in this structure:
21641 @smallexample
21642 struct @{
21643   int a;
21644   struct @{
21645     int a;
21646   @};
21647 @} foo;
21648 @end smallexample
21650 @noindent
21651 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
21652 The compiler gives errors for such constructs.
21654 @opindex fms-extensions
21655 Unless @option{-fms-extensions} is used, the unnamed field must be a
21656 structure or union definition without a tag (for example, @samp{struct
21657 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
21658 also be a definition with a tag such as @samp{struct foo @{ int a;
21659 @};}, a reference to a previously defined structure or union such as
21660 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21661 previously defined structure or union type.
21663 @opindex fplan9-extensions
21664 The option @option{-fplan9-extensions} enables
21665 @option{-fms-extensions} as well as two other extensions.  First, a
21666 pointer to a structure is automatically converted to a pointer to an
21667 anonymous field for assignments and function calls.  For example:
21669 @smallexample
21670 struct s1 @{ int a; @};
21671 struct s2 @{ struct s1; @};
21672 extern void f1 (struct s1 *);
21673 void f2 (struct s2 *p) @{ f1 (p); @}
21674 @end smallexample
21676 @noindent
21677 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
21678 converted into a pointer to the anonymous field.
21680 Second, when the type of an anonymous field is a @code{typedef} for a
21681 @code{struct} or @code{union}, code may refer to the field using the
21682 name of the @code{typedef}.
21684 @smallexample
21685 typedef struct @{ int a; @} s1;
21686 struct s2 @{ s1; @};
21687 s1 f1 (struct s2 *p) @{ return p->s1; @}
21688 @end smallexample
21690 These usages are only permitted when they are not ambiguous.
21692 @node Thread-Local
21693 @section Thread-Local Storage
21694 @cindex Thread-Local Storage
21695 @cindex @acronym{TLS}
21696 @cindex @code{__thread}
21698 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
21699 are allocated such that there is one instance of the variable per extant
21700 thread.  The runtime model GCC uses to implement this originates
21701 in the IA-64 processor-specific ABI, but has since been migrated
21702 to other processors as well.  It requires significant support from
21703 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
21704 system libraries (@file{libc.so} and @file{libpthread.so}), so it
21705 is not available everywhere.
21707 At the user level, the extension is visible with a new storage
21708 class keyword: @code{__thread}.  For example:
21710 @smallexample
21711 __thread int i;
21712 extern __thread struct state s;
21713 static __thread char *p;
21714 @end smallexample
21716 The @code{__thread} specifier may be used alone, with the @code{extern}
21717 or @code{static} specifiers, but with no other storage class specifier.
21718 When used with @code{extern} or @code{static}, @code{__thread} must appear
21719 immediately after the other storage class specifier.
21721 The @code{__thread} specifier may be applied to any global, file-scoped
21722 static, function-scoped static, or static data member of a class.  It may
21723 not be applied to block-scoped automatic or non-static data member.
21725 When the address-of operator is applied to a thread-local variable, it is
21726 evaluated at run time and returns the address of the current thread's
21727 instance of that variable.  An address so obtained may be used by any
21728 thread.  When a thread terminates, any pointers to thread-local variables
21729 in that thread become invalid.
21731 No static initialization may refer to the address of a thread-local variable.
21733 In C++, if an initializer is present for a thread-local variable, it must
21734 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21735 standard.
21737 See @uref{https://www.akkadia.org/drepper/tls.pdf,
21738 ELF Handling For Thread-Local Storage} for a detailed explanation of
21739 the four thread-local storage addressing models, and how the runtime
21740 is expected to function.
21742 @menu
21743 * C99 Thread-Local Edits::
21744 * C++98 Thread-Local Edits::
21745 @end menu
21747 @node C99 Thread-Local Edits
21748 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21750 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21751 that document the exact semantics of the language extension.
21753 @itemize @bullet
21754 @item
21755 @cite{5.1.2  Execution environments}
21757 Add new text after paragraph 1
21759 @quotation
21760 Within either execution environment, a @dfn{thread} is a flow of
21761 control within a program.  It is implementation defined whether
21762 or not there may be more than one thread associated with a program.
21763 It is implementation defined how threads beyond the first are
21764 created, the name and type of the function called at thread
21765 startup, and how threads may be terminated.  However, objects
21766 with thread storage duration shall be initialized before thread
21767 startup.
21768 @end quotation
21770 @item
21771 @cite{6.2.4  Storage durations of objects}
21773 Add new text before paragraph 3
21775 @quotation
21776 An object whose identifier is declared with the storage-class
21777 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21778 Its lifetime is the entire execution of the thread, and its
21779 stored value is initialized only once, prior to thread startup.
21780 @end quotation
21782 @item
21783 @cite{6.4.1  Keywords}
21785 Add @code{__thread}.
21787 @item
21788 @cite{6.7.1  Storage-class specifiers}
21790 Add @code{__thread} to the list of storage class specifiers in
21791 paragraph 1.
21793 Change paragraph 2 to
21795 @quotation
21796 With the exception of @code{__thread}, at most one storage-class
21797 specifier may be given [@dots{}].  The @code{__thread} specifier may
21798 be used alone, or immediately following @code{extern} or
21799 @code{static}.
21800 @end quotation
21802 Add new text after paragraph 6
21804 @quotation
21805 The declaration of an identifier for a variable that has
21806 block scope that specifies @code{__thread} shall also
21807 specify either @code{extern} or @code{static}.
21809 The @code{__thread} specifier shall be used only with
21810 variables.
21811 @end quotation
21812 @end itemize
21814 @node C++98 Thread-Local Edits
21815 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21817 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21818 that document the exact semantics of the language extension.
21820 @itemize @bullet
21821 @item
21822 @b{[intro.execution]}
21824 New text after paragraph 4
21826 @quotation
21827 A @dfn{thread} is a flow of control within the abstract machine.
21828 It is implementation defined whether or not there may be more than
21829 one thread.
21830 @end quotation
21832 New text after paragraph 7
21834 @quotation
21835 It is unspecified whether additional action must be taken to
21836 ensure when and whether side effects are visible to other threads.
21837 @end quotation
21839 @item
21840 @b{[lex.key]}
21842 Add @code{__thread}.
21844 @item
21845 @b{[basic.start.main]}
21847 Add after paragraph 5
21849 @quotation
21850 The thread that begins execution at the @code{main} function is called
21851 the @dfn{main thread}.  It is implementation defined how functions
21852 beginning threads other than the main thread are designated or typed.
21853 A function so designated, as well as the @code{main} function, is called
21854 a @dfn{thread startup function}.  It is implementation defined what
21855 happens if a thread startup function returns.  It is implementation
21856 defined what happens to other threads when any thread calls @code{exit}.
21857 @end quotation
21859 @item
21860 @b{[basic.start.init]}
21862 Add after paragraph 4
21864 @quotation
21865 The storage for an object of thread storage duration shall be
21866 statically initialized before the first statement of the thread startup
21867 function.  An object of thread storage duration shall not require
21868 dynamic initialization.
21869 @end quotation
21871 @item
21872 @b{[basic.start.term]}
21874 Add after paragraph 3
21876 @quotation
21877 The type of an object with thread storage duration shall not have a
21878 non-trivial destructor, nor shall it be an array type whose elements
21879 (directly or indirectly) have non-trivial destructors.
21880 @end quotation
21882 @item
21883 @b{[basic.stc]}
21885 Add ``thread storage duration'' to the list in paragraph 1.
21887 Change paragraph 2
21889 @quotation
21890 Thread, static, and automatic storage durations are associated with
21891 objects introduced by declarations [@dots{}].
21892 @end quotation
21894 Add @code{__thread} to the list of specifiers in paragraph 3.
21896 @item
21897 @b{[basic.stc.thread]}
21899 New section before @b{[basic.stc.static]}
21901 @quotation
21902 The keyword @code{__thread} applied to a non-local object gives the
21903 object thread storage duration.
21905 A local variable or class data member declared both @code{static}
21906 and @code{__thread} gives the variable or member thread storage
21907 duration.
21908 @end quotation
21910 @item
21911 @b{[basic.stc.static]}
21913 Change paragraph 1
21915 @quotation
21916 All objects that have neither thread storage duration, dynamic
21917 storage duration nor are local [@dots{}].
21918 @end quotation
21920 @item
21921 @b{[dcl.stc]}
21923 Add @code{__thread} to the list in paragraph 1.
21925 Change paragraph 1
21927 @quotation
21928 With the exception of @code{__thread}, at most one
21929 @var{storage-class-specifier} shall appear in a given
21930 @var{decl-specifier-seq}.  The @code{__thread} specifier may
21931 be used alone, or immediately following the @code{extern} or
21932 @code{static} specifiers.  [@dots{}]
21933 @end quotation
21935 Add after paragraph 5
21937 @quotation
21938 The @code{__thread} specifier can be applied only to the names of objects
21939 and to anonymous unions.
21940 @end quotation
21942 @item
21943 @b{[class.mem]}
21945 Add after paragraph 6
21947 @quotation
21948 Non-@code{static} members shall not be @code{__thread}.
21949 @end quotation
21950 @end itemize
21952 @node Binary constants
21953 @section Binary Constants using the @samp{0b} Prefix
21954 @cindex Binary constants using the @samp{0b} prefix
21956 Integer constants can be written as binary constants, consisting of a
21957 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21958 @samp{0B}.  This is particularly useful in environments that operate a
21959 lot on the bit level (like microcontrollers).
21961 The following statements are identical:
21963 @smallexample
21964 i =       42;
21965 i =     0x2a;
21966 i =      052;
21967 i = 0b101010;
21968 @end smallexample
21970 The type of these constants follows the same rules as for octal or
21971 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21972 can be applied.
21974 @node C++ Extensions
21975 @chapter Extensions to the C++ Language
21976 @cindex extensions, C++ language
21977 @cindex C++ language extensions
21979 The GNU compiler provides these extensions to the C++ language (and you
21980 can also use most of the C language extensions in your C++ programs).  If you
21981 want to write code that checks whether these features are available, you can
21982 test for the GNU compiler the same way as for C programs: check for a
21983 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
21984 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21985 Predefined Macros,cpp,The GNU C Preprocessor}).
21987 @menu
21988 * C++ Volatiles::       What constitutes an access to a volatile object.
21989 * Restricted Pointers:: C99 restricted pointers and references.
21990 * Vague Linkage::       Where G++ puts inlines, vtables and such.
21991 * C++ Interface::       You can use a single C++ header file for both
21992                         declarations and definitions.
21993 * Template Instantiation:: Methods for ensuring that exactly one copy of
21994                         each needed template instantiation is emitted.
21995 * Bound member functions:: You can extract a function pointer to the
21996                         method denoted by a @samp{->*} or @samp{.*} expression.
21997 * C++ Attributes::      Variable, function, and type attributes for C++ only.
21998 * Function Multiversioning::   Declaring multiple function versions.
21999 * Type Traits::         Compiler support for type traits.
22000 * C++ Concepts::        Improved support for generic programming.
22001 * Deprecated Features:: Things will disappear from G++.
22002 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22003 @end menu
22005 @node C++ Volatiles
22006 @section When is a Volatile C++ Object Accessed?
22007 @cindex accessing volatiles
22008 @cindex volatile read
22009 @cindex volatile write
22010 @cindex volatile access
22012 The C++ standard differs from the C standard in its treatment of
22013 volatile objects.  It fails to specify what constitutes a volatile
22014 access, except to say that C++ should behave in a similar manner to C
22015 with respect to volatiles, where possible.  However, the different
22016 lvalueness of expressions between C and C++ complicate the behavior.
22017 G++ behaves the same as GCC for volatile access, @xref{C
22018 Extensions,,Volatiles}, for a description of GCC's behavior.
22020 The C and C++ language specifications differ when an object is
22021 accessed in a void context:
22023 @smallexample
22024 volatile int *src = @var{somevalue};
22025 *src;
22026 @end smallexample
22028 The C++ standard specifies that such expressions do not undergo lvalue
22029 to rvalue conversion, and that the type of the dereferenced object may
22030 be incomplete.  The C++ standard does not specify explicitly that it
22031 is lvalue to rvalue conversion that is responsible for causing an
22032 access.  There is reason to believe that it is, because otherwise
22033 certain simple expressions become undefined.  However, because it
22034 would surprise most programmers, G++ treats dereferencing a pointer to
22035 volatile object of complete type as GCC would do for an equivalent
22036 type in C@.  When the object has incomplete type, G++ issues a
22037 warning; if you wish to force an error, you must force a conversion to
22038 rvalue with, for instance, a static cast.
22040 When using a reference to volatile, G++ does not treat equivalent
22041 expressions as accesses to volatiles, but instead issues a warning that
22042 no volatile is accessed.  The rationale for this is that otherwise it
22043 becomes difficult to determine where volatile access occur, and not
22044 possible to ignore the return value from functions returning volatile
22045 references.  Again, if you wish to force a read, cast the reference to
22046 an rvalue.
22048 G++ implements the same behavior as GCC does when assigning to a
22049 volatile object---there is no reread of the assigned-to object, the
22050 assigned rvalue is reused.  Note that in C++ assignment expressions
22051 are lvalues, and if used as an lvalue, the volatile object is
22052 referred to.  For instance, @var{vref} refers to @var{vobj}, as
22053 expected, in the following example:
22055 @smallexample
22056 volatile int vobj;
22057 volatile int &vref = vobj = @var{something};
22058 @end smallexample
22060 @node Restricted Pointers
22061 @section Restricting Pointer Aliasing
22062 @cindex restricted pointers
22063 @cindex restricted references
22064 @cindex restricted this pointer
22066 As with the C front end, G++ understands the C99 feature of restricted pointers,
22067 specified with the @code{__restrict__}, or @code{__restrict} type
22068 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
22069 language flag, @code{restrict} is not a keyword in C++.
22071 In addition to allowing restricted pointers, you can specify restricted
22072 references, which indicate that the reference is not aliased in the local
22073 context.
22075 @smallexample
22076 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22078   /* @r{@dots{}} */
22080 @end smallexample
22082 @noindent
22083 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22084 @var{rref} refers to a (different) unaliased integer.
22086 You may also specify whether a member function's @var{this} pointer is
22087 unaliased by using @code{__restrict__} as a member function qualifier.
22089 @smallexample
22090 void T::fn () __restrict__
22092   /* @r{@dots{}} */
22094 @end smallexample
22096 @noindent
22097 Within the body of @code{T::fn}, @var{this} has the effective
22098 definition @code{T *__restrict__ const this}.  Notice that the
22099 interpretation of a @code{__restrict__} member function qualifier is
22100 different to that of @code{const} or @code{volatile} qualifier, in that it
22101 is applied to the pointer rather than the object.  This is consistent with
22102 other compilers that implement restricted pointers.
22104 As with all outermost parameter qualifiers, @code{__restrict__} is
22105 ignored in function definition matching.  This means you only need to
22106 specify @code{__restrict__} in a function definition, rather than
22107 in a function prototype as well.
22109 @node Vague Linkage
22110 @section Vague Linkage
22111 @cindex vague linkage
22113 There are several constructs in C++ that require space in the object
22114 file but are not clearly tied to a single translation unit.  We say that
22115 these constructs have ``vague linkage''.  Typically such constructs are
22116 emitted wherever they are needed, though sometimes we can be more
22117 clever.
22119 @table @asis
22120 @item Inline Functions
22121 Inline functions are typically defined in a header file which can be
22122 included in many different compilations.  Hopefully they can usually be
22123 inlined, but sometimes an out-of-line copy is necessary, if the address
22124 of the function is taken or if inlining fails.  In general, we emit an
22125 out-of-line copy in all translation units where one is needed.  As an
22126 exception, we only emit inline virtual functions with the vtable, since
22127 it always requires a copy.
22129 Local static variables and string constants used in an inline function
22130 are also considered to have vague linkage, since they must be shared
22131 between all inlined and out-of-line instances of the function.
22133 @item VTables
22134 @cindex vtable
22135 C++ virtual functions are implemented in most compilers using a lookup
22136 table, known as a vtable.  The vtable contains pointers to the virtual
22137 functions provided by a class, and each object of the class contains a
22138 pointer to its vtable (or vtables, in some multiple-inheritance
22139 situations).  If the class declares any non-inline, non-pure virtual
22140 functions, the first one is chosen as the ``key method'' for the class,
22141 and the vtable is only emitted in the translation unit where the key
22142 method is defined.
22144 @emph{Note:} If the chosen key method is later defined as inline, the
22145 vtable is still emitted in every translation unit that defines it.
22146 Make sure that any inline virtuals are declared inline in the class
22147 body, even if they are not defined there.
22149 @item @code{type_info} objects
22150 @cindex @code{type_info}
22151 @cindex RTTI
22152 C++ requires information about types to be written out in order to
22153 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
22154 For polymorphic classes (classes with virtual functions), the @samp{type_info}
22155 object is written out along with the vtable so that @samp{dynamic_cast}
22156 can determine the dynamic type of a class object at run time.  For all
22157 other types, we write out the @samp{type_info} object when it is used: when
22158 applying @samp{typeid} to an expression, throwing an object, or
22159 referring to a type in a catch clause or exception specification.
22161 @item Template Instantiations
22162 Most everything in this section also applies to template instantiations,
22163 but there are other options as well.
22164 @xref{Template Instantiation,,Where's the Template?}.
22166 @end table
22168 When used with GNU ld version 2.8 or later on an ELF system such as
22169 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
22170 these constructs will be discarded at link time.  This is known as
22171 COMDAT support.
22173 On targets that don't support COMDAT, but do support weak symbols, GCC
22174 uses them.  This way one copy overrides all the others, but
22175 the unused copies still take up space in the executable.
22177 For targets that do not support either COMDAT or weak symbols,
22178 most entities with vague linkage are emitted as local symbols to
22179 avoid duplicate definition errors from the linker.  This does not happen
22180 for local statics in inlines, however, as having multiple copies
22181 almost certainly breaks things.
22183 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
22184 another way to control placement of these constructs.
22186 @node C++ Interface
22187 @section C++ Interface and Implementation Pragmas
22189 @cindex interface and implementation headers, C++
22190 @cindex C++ interface and implementation headers
22191 @cindex pragmas, interface and implementation
22193 @code{#pragma interface} and @code{#pragma implementation} provide the
22194 user with a way of explicitly directing the compiler to emit entities
22195 with vague linkage (and debugging information) in a particular
22196 translation unit.
22198 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
22199 by COMDAT support and the ``key method'' heuristic
22200 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
22201 program to grow due to unnecessary out-of-line copies of inline
22202 functions.
22204 @table @code
22205 @item #pragma interface
22206 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
22207 @kindex #pragma interface
22208 Use this directive in @emph{header files} that define object classes, to save
22209 space in most of the object files that use those classes.  Normally,
22210 local copies of certain information (backup copies of inline member
22211 functions, debugging information, and the internal tables that implement
22212 virtual functions) must be kept in each object file that includes class
22213 definitions.  You can use this pragma to avoid such duplication.  When a
22214 header file containing @samp{#pragma interface} is included in a
22215 compilation, this auxiliary information is not generated (unless
22216 the main input source file itself uses @samp{#pragma implementation}).
22217 Instead, the object files contain references to be resolved at link
22218 time.
22220 The second form of this directive is useful for the case where you have
22221 multiple headers with the same name in different directories.  If you
22222 use this form, you must specify the same string to @samp{#pragma
22223 implementation}.
22225 @item #pragma implementation
22226 @itemx #pragma implementation "@var{objects}.h"
22227 @kindex #pragma implementation
22228 Use this pragma in a @emph{main input file}, when you want full output from
22229 included header files to be generated (and made globally visible).  The
22230 included header file, in turn, should use @samp{#pragma interface}.
22231 Backup copies of inline member functions, debugging information, and the
22232 internal tables used to implement virtual functions are all generated in
22233 implementation files.
22235 @cindex implied @code{#pragma implementation}
22236 @cindex @code{#pragma implementation}, implied
22237 @cindex naming convention, implementation headers
22238 If you use @samp{#pragma implementation} with no argument, it applies to
22239 an include file with the same basename@footnote{A file's @dfn{basename}
22240 is the name stripped of all leading path information and of trailing
22241 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
22242 file.  For example, in @file{allclass.cc}, giving just
22243 @samp{#pragma implementation}
22244 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
22246 Use the string argument if you want a single implementation file to
22247 include code from multiple header files.  (You must also use
22248 @samp{#include} to include the header file; @samp{#pragma
22249 implementation} only specifies how to use the file---it doesn't actually
22250 include it.)
22252 There is no way to split up the contents of a single header file into
22253 multiple implementation files.
22254 @end table
22256 @cindex inlining and C++ pragmas
22257 @cindex C++ pragmas, effect on inlining
22258 @cindex pragmas in C++, effect on inlining
22259 @samp{#pragma implementation} and @samp{#pragma interface} also have an
22260 effect on function inlining.
22262 If you define a class in a header file marked with @samp{#pragma
22263 interface}, the effect on an inline function defined in that class is
22264 similar to an explicit @code{extern} declaration---the compiler emits
22265 no code at all to define an independent version of the function.  Its
22266 definition is used only for inlining with its callers.
22268 @opindex fno-implement-inlines
22269 Conversely, when you include the same header file in a main source file
22270 that declares it as @samp{#pragma implementation}, the compiler emits
22271 code for the function itself; this defines a version of the function
22272 that can be found via pointers (or by callers compiled without
22273 inlining).  If all calls to the function can be inlined, you can avoid
22274 emitting the function by compiling with @option{-fno-implement-inlines}.
22275 If any calls are not inlined, you will get linker errors.
22277 @node Template Instantiation
22278 @section Where's the Template?
22279 @cindex template instantiation
22281 C++ templates were the first language feature to require more
22282 intelligence from the environment than was traditionally found on a UNIX
22283 system.  Somehow the compiler and linker have to make sure that each
22284 template instance occurs exactly once in the executable if it is needed,
22285 and not at all otherwise.  There are two basic approaches to this
22286 problem, which are referred to as the Borland model and the Cfront model.
22288 @table @asis
22289 @item Borland model
22290 Borland C++ solved the template instantiation problem by adding the code
22291 equivalent of common blocks to their linker; the compiler emits template
22292 instances in each translation unit that uses them, and the linker
22293 collapses them together.  The advantage of this model is that the linker
22294 only has to consider the object files themselves; there is no external
22295 complexity to worry about.  The disadvantage is that compilation time
22296 is increased because the template code is being compiled repeatedly.
22297 Code written for this model tends to include definitions of all
22298 templates in the header file, since they must be seen to be
22299 instantiated.
22301 @item Cfront model
22302 The AT&T C++ translator, Cfront, solved the template instantiation
22303 problem by creating the notion of a template repository, an
22304 automatically maintained place where template instances are stored.  A
22305 more modern version of the repository works as follows: As individual
22306 object files are built, the compiler places any template definitions and
22307 instantiations encountered in the repository.  At link time, the link
22308 wrapper adds in the objects in the repository and compiles any needed
22309 instances that were not previously emitted.  The advantages of this
22310 model are more optimal compilation speed and the ability to use the
22311 system linker; to implement the Borland model a compiler vendor also
22312 needs to replace the linker.  The disadvantages are vastly increased
22313 complexity, and thus potential for error; for some code this can be
22314 just as transparent, but in practice it can been very difficult to build
22315 multiple programs in one directory and one program in multiple
22316 directories.  Code written for this model tends to separate definitions
22317 of non-inline member templates into a separate file, which should be
22318 compiled separately.
22319 @end table
22321 G++ implements the Borland model on targets where the linker supports it,
22322 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
22323 Otherwise G++ implements neither automatic model.
22325 You have the following options for dealing with template instantiations:
22327 @enumerate
22328 @item
22329 Do nothing.  Code written for the Borland model works fine, but
22330 each translation unit contains instances of each of the templates it
22331 uses.  The duplicate instances will be discarded by the linker, but in
22332 a large program, this can lead to an unacceptable amount of code
22333 duplication in object files or shared libraries.
22335 Duplicate instances of a template can be avoided by defining an explicit
22336 instantiation in one object file, and preventing the compiler from doing
22337 implicit instantiations in any other object files by using an explicit
22338 instantiation declaration, using the @code{extern template} syntax:
22340 @smallexample
22341 extern template int max (int, int);
22342 @end smallexample
22344 This syntax is defined in the C++ 2011 standard, but has been supported by
22345 G++ and other compilers since well before 2011.
22347 Explicit instantiations can be used for the largest or most frequently
22348 duplicated instances, without having to know exactly which other instances
22349 are used in the rest of the program.  You can scatter the explicit
22350 instantiations throughout your program, perhaps putting them in the
22351 translation units where the instances are used or the translation units
22352 that define the templates themselves; you can put all of the explicit
22353 instantiations you need into one big file; or you can create small files
22354 like
22356 @smallexample
22357 #include "Foo.h"
22358 #include "Foo.cc"
22360 template class Foo<int>;
22361 template ostream& operator <<
22362                 (ostream&, const Foo<int>&);
22363 @end smallexample
22365 @noindent
22366 for each of the instances you need, and create a template instantiation
22367 library from those.
22369 This is the simplest option, but also offers flexibility and
22370 fine-grained control when necessary. It is also the most portable
22371 alternative and programs using this approach will work with most modern
22372 compilers.
22374 @item
22375 @opindex frepo
22376 Compile your template-using code with @option{-frepo}.  The compiler
22377 generates files with the extension @samp{.rpo} listing all of the
22378 template instantiations used in the corresponding object files that
22379 could be instantiated there; the link wrapper, @samp{collect2},
22380 then updates the @samp{.rpo} files to tell the compiler where to place
22381 those instantiations and rebuild any affected object files.  The
22382 link-time overhead is negligible after the first pass, as the compiler
22383 continues to place the instantiations in the same files.
22385 This can be a suitable option for application code written for the Borland
22386 model, as it usually just works.  Code written for the Cfront model 
22387 needs to be modified so that the template definitions are available at
22388 one or more points of instantiation; usually this is as simple as adding
22389 @code{#include <tmethods.cc>} to the end of each template header.
22391 For library code, if you want the library to provide all of the template
22392 instantiations it needs, just try to link all of its object files
22393 together; the link will fail, but cause the instantiations to be
22394 generated as a side effect.  Be warned, however, that this may cause
22395 conflicts if multiple libraries try to provide the same instantiations.
22396 For greater control, use explicit instantiation as described in the next
22397 option.
22399 @item
22400 @opindex fno-implicit-templates
22401 Compile your code with @option{-fno-implicit-templates} to disable the
22402 implicit generation of template instances, and explicitly instantiate
22403 all the ones you use.  This approach requires more knowledge of exactly
22404 which instances you need than do the others, but it's less
22405 mysterious and allows greater control if you want to ensure that only
22406 the intended instances are used.
22408 If you are using Cfront-model code, you can probably get away with not
22409 using @option{-fno-implicit-templates} when compiling files that don't
22410 @samp{#include} the member template definitions.
22412 If you use one big file to do the instantiations, you may want to
22413 compile it without @option{-fno-implicit-templates} so you get all of the
22414 instances required by your explicit instantiations (but not by any
22415 other files) without having to specify them as well.
22417 In addition to forward declaration of explicit instantiations
22418 (with @code{extern}), G++ has extended the template instantiation
22419 syntax to support instantiation of the compiler support data for a
22420 template class (i.e.@: the vtable) without instantiating any of its
22421 members (with @code{inline}), and instantiation of only the static data
22422 members of a template class, without the support data or member
22423 functions (with @code{static}):
22425 @smallexample
22426 inline template class Foo<int>;
22427 static template class Foo<int>;
22428 @end smallexample
22429 @end enumerate
22431 @node Bound member functions
22432 @section Extracting the Function Pointer from a Bound Pointer to Member Function
22433 @cindex pmf
22434 @cindex pointer to member function
22435 @cindex bound pointer to member function
22437 In C++, pointer to member functions (PMFs) are implemented using a wide
22438 pointer of sorts to handle all the possible call mechanisms; the PMF
22439 needs to store information about how to adjust the @samp{this} pointer,
22440 and if the function pointed to is virtual, where to find the vtable, and
22441 where in the vtable to look for the member function.  If you are using
22442 PMFs in an inner loop, you should really reconsider that decision.  If
22443 that is not an option, you can extract the pointer to the function that
22444 would be called for a given object/PMF pair and call it directly inside
22445 the inner loop, to save a bit of time.
22447 Note that you still pay the penalty for the call through a
22448 function pointer; on most modern architectures, such a call defeats the
22449 branch prediction features of the CPU@.  This is also true of normal
22450 virtual function calls.
22452 The syntax for this extension is
22454 @smallexample
22455 extern A a;
22456 extern int (A::*fp)();
22457 typedef int (*fptr)(A *);
22459 fptr p = (fptr)(a.*fp);
22460 @end smallexample
22462 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
22463 no object is needed to obtain the address of the function.  They can be
22464 converted to function pointers directly:
22466 @smallexample
22467 fptr p1 = (fptr)(&A::foo);
22468 @end smallexample
22470 @opindex Wno-pmf-conversions
22471 You must specify @option{-Wno-pmf-conversions} to use this extension.
22473 @node C++ Attributes
22474 @section C++-Specific Variable, Function, and Type Attributes
22476 Some attributes only make sense for C++ programs.
22478 @table @code
22479 @item abi_tag ("@var{tag}", ...)
22480 @cindex @code{abi_tag} function attribute
22481 @cindex @code{abi_tag} variable attribute
22482 @cindex @code{abi_tag} type attribute
22483 The @code{abi_tag} attribute can be applied to a function, variable, or class
22484 declaration.  It modifies the mangled name of the entity to
22485 incorporate the tag name, in order to distinguish the function or
22486 class from an earlier version with a different ABI; perhaps the class
22487 has changed size, or the function has a different return type that is
22488 not encoded in the mangled name.
22490 The attribute can also be applied to an inline namespace, but does not
22491 affect the mangled name of the namespace; in this case it is only used
22492 for @option{-Wabi-tag} warnings and automatic tagging of functions and
22493 variables.  Tagging inline namespaces is generally preferable to
22494 tagging individual declarations, but the latter is sometimes
22495 necessary, such as when only certain members of a class need to be
22496 tagged.
22498 The argument can be a list of strings of arbitrary length.  The
22499 strings are sorted on output, so the order of the list is
22500 unimportant.
22502 A redeclaration of an entity must not add new ABI tags,
22503 since doing so would change the mangled name.
22505 The ABI tags apply to a name, so all instantiations and
22506 specializations of a template have the same tags.  The attribute will
22507 be ignored if applied to an explicit specialization or instantiation.
22509 The @option{-Wabi-tag} flag enables a warning about a class which does
22510 not have all the ABI tags used by its subobjects and virtual functions; for users with code
22511 that needs to coexist with an earlier ABI, using this option can help
22512 to find all affected types that need to be tagged.
22514 When a type involving an ABI tag is used as the type of a variable or
22515 return type of a function where that tag is not already present in the
22516 signature of the function, the tag is automatically applied to the
22517 variable or function.  @option{-Wabi-tag} also warns about this
22518 situation; this warning can be avoided by explicitly tagging the
22519 variable or function or moving it into a tagged inline namespace.
22521 @item init_priority (@var{priority})
22522 @cindex @code{init_priority} variable attribute
22524 In Standard C++, objects defined at namespace scope are guaranteed to be
22525 initialized in an order in strict accordance with that of their definitions
22526 @emph{in a given translation unit}.  No guarantee is made for initializations
22527 across translation units.  However, GNU C++ allows users to control the
22528 order of initialization of objects defined at namespace scope with the
22529 @code{init_priority} attribute by specifying a relative @var{priority},
22530 a constant integral expression currently bounded between 101 and 65535
22531 inclusive.  Lower numbers indicate a higher priority.
22533 In the following example, @code{A} would normally be created before
22534 @code{B}, but the @code{init_priority} attribute reverses that order:
22536 @smallexample
22537 Some_Class  A  __attribute__ ((init_priority (2000)));
22538 Some_Class  B  __attribute__ ((init_priority (543)));
22539 @end smallexample
22541 @noindent
22542 Note that the particular values of @var{priority} do not matter; only their
22543 relative ordering.
22545 @item warn_unused
22546 @cindex @code{warn_unused} type attribute
22548 For C++ types with non-trivial constructors and/or destructors it is
22549 impossible for the compiler to determine whether a variable of this
22550 type is truly unused if it is not referenced. This type attribute
22551 informs the compiler that variables of this type should be warned
22552 about if they appear to be unused, just like variables of fundamental
22553 types.
22555 This attribute is appropriate for types which just represent a value,
22556 such as @code{std::string}; it is not appropriate for types which
22557 control a resource, such as @code{std::lock_guard}.
22559 This attribute is also accepted in C, but it is unnecessary because C
22560 does not have constructors or destructors.
22562 @end table
22564 @node Function Multiversioning
22565 @section Function Multiversioning
22566 @cindex function versions
22568 With the GNU C++ front end, for x86 targets, you may specify multiple
22569 versions of a function, where each function is specialized for a
22570 specific target feature.  At runtime, the appropriate version of the
22571 function is automatically executed depending on the characteristics of
22572 the execution platform.  Here is an example.
22574 @smallexample
22575 __attribute__ ((target ("default")))
22576 int foo ()
22578   // The default version of foo.
22579   return 0;
22582 __attribute__ ((target ("sse4.2")))
22583 int foo ()
22585   // foo version for SSE4.2
22586   return 1;
22589 __attribute__ ((target ("arch=atom")))
22590 int foo ()
22592   // foo version for the Intel ATOM processor
22593   return 2;
22596 __attribute__ ((target ("arch=amdfam10")))
22597 int foo ()
22599   // foo version for the AMD Family 0x10 processors.
22600   return 3;
22603 int main ()
22605   int (*p)() = &foo;
22606   assert ((*p) () == foo ());
22607   return 0;
22609 @end smallexample
22611 In the above example, four versions of function foo are created. The
22612 first version of foo with the target attribute "default" is the default
22613 version.  This version gets executed when no other target specific
22614 version qualifies for execution on a particular platform. A new version
22615 of foo is created by using the same function signature but with a
22616 different target string.  Function foo is called or a pointer to it is
22617 taken just like a regular function.  GCC takes care of doing the
22618 dispatching to call the right version at runtime.  Refer to the
22619 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
22620 Function Multiversioning} for more details.
22622 @node Type Traits
22623 @section Type Traits
22625 The C++ front end implements syntactic extensions that allow
22626 compile-time determination of 
22627 various characteristics of a type (or of a
22628 pair of types).
22630 @table @code
22631 @item __has_nothrow_assign (type)
22632 If @code{type} is const qualified or is a reference type then the trait is
22633 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22634 is true, else if @code{type} is a cv class or union type with copy assignment
22635 operators that are known not to throw an exception then the trait is true,
22636 else it is false.  Requires: @code{type} shall be a complete type,
22637 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22639 @item __has_nothrow_copy (type)
22640 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22641 @code{type} is a cv class or union type with copy constructors that
22642 are known not to throw an exception then the trait is true, else it is false.
22643 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22644 @code{void}, or an array of unknown bound.
22646 @item __has_nothrow_constructor (type)
22647 If @code{__has_trivial_constructor (type)} is true then the trait is
22648 true, else if @code{type} is a cv class or union type (or array
22649 thereof) with a default constructor that is known not to throw an
22650 exception then the trait is true, else it is false.  Requires:
22651 @code{type} shall be a complete type, (possibly cv-qualified)
22652 @code{void}, or an array of unknown bound.
22654 @item __has_trivial_assign (type)
22655 If @code{type} is const qualified or is a reference type then the trait is
22656 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
22657 true, else if @code{type} is a cv class or union type with a trivial
22658 copy assignment ([class.copy]) then the trait is true, else it is
22659 false.  Requires: @code{type} shall be a complete type, (possibly
22660 cv-qualified) @code{void}, or an array of unknown bound.
22662 @item __has_trivial_copy (type)
22663 If @code{__is_pod (type)} is true or @code{type} is a reference type
22664 then the trait is true, else if @code{type} is a cv class or union type
22665 with a trivial copy constructor ([class.copy]) then the trait
22666 is true, else it is false.  Requires: @code{type} shall be a complete
22667 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22669 @item __has_trivial_constructor (type)
22670 If @code{__is_pod (type)} is true then the trait is true, else if
22671 @code{type} is a cv class or union type (or array thereof) with a
22672 trivial default constructor ([class.ctor]) then the trait is true,
22673 else it is false.  Requires: @code{type} shall be a complete
22674 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22676 @item __has_trivial_destructor (type)
22677 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22678 the trait is true, else if @code{type} is a cv class or union type (or
22679 array thereof) with a trivial destructor ([class.dtor]) then the trait
22680 is true, else it is false.  Requires: @code{type} shall be a complete
22681 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22683 @item __has_virtual_destructor (type)
22684 If @code{type} is a class type with a virtual destructor
22685 ([class.dtor]) then the trait is true, else it is false.  Requires:
22686 @code{type} shall be a complete type, (possibly cv-qualified)
22687 @code{void}, or an array of unknown bound.
22689 @item __is_abstract (type)
22690 If @code{type} is an abstract class ([class.abstract]) then the trait
22691 is true, else it is false.  Requires: @code{type} shall be a complete
22692 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22694 @item __is_base_of (base_type, derived_type)
22695 If @code{base_type} is a base class of @code{derived_type}
22696 ([class.derived]) then the trait is true, otherwise it is false.
22697 Top-level cv qualifications of @code{base_type} and
22698 @code{derived_type} are ignored.  For the purposes of this trait, a
22699 class type is considered is own base.  Requires: if @code{__is_class
22700 (base_type)} and @code{__is_class (derived_type)} are true and
22701 @code{base_type} and @code{derived_type} are not the same type
22702 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22703 type.  A diagnostic is produced if this requirement is not met.
22705 @item __is_class (type)
22706 If @code{type} is a cv class type, and not a union type
22707 ([basic.compound]) the trait is true, else it is false.
22709 @item __is_empty (type)
22710 If @code{__is_class (type)} is false then the trait is false.
22711 Otherwise @code{type} is considered empty if and only if: @code{type}
22712 has no non-static data members, or all non-static data members, if
22713 any, are bit-fields of length 0, and @code{type} has no virtual
22714 members, and @code{type} has no virtual base classes, and @code{type}
22715 has no base classes @code{base_type} for which
22716 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
22717 be a complete type, (possibly cv-qualified) @code{void}, or an array
22718 of unknown bound.
22720 @item __is_enum (type)
22721 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22722 true, else it is false.
22724 @item __is_literal_type (type)
22725 If @code{type} is a literal type ([basic.types]) the trait is
22726 true, else it is false.  Requires: @code{type} shall be a complete type,
22727 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22729 @item __is_pod (type)
22730 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22731 else it is false.  Requires: @code{type} shall be a complete type,
22732 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22734 @item __is_polymorphic (type)
22735 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22736 is true, else it is false.  Requires: @code{type} shall be a complete
22737 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22739 @item __is_standard_layout (type)
22740 If @code{type} is a standard-layout type ([basic.types]) the trait is
22741 true, else it is false.  Requires: @code{type} shall be a complete
22742 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22744 @item __is_trivial (type)
22745 If @code{type} is a trivial type ([basic.types]) the trait is
22746 true, else it is false.  Requires: @code{type} shall be a complete
22747 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22749 @item __is_union (type)
22750 If @code{type} is a cv union type ([basic.compound]) the trait is
22751 true, else it is false.
22753 @item __underlying_type (type)
22754 The underlying type of @code{type}.  Requires: @code{type} shall be
22755 an enumeration type ([dcl.enum]).
22757 @item __integer_pack (length)
22758 When used as the pattern of a pack expansion within a template
22759 definition, expands to a template argument pack containing integers
22760 from @code{0} to @code{length-1}.  This is provided for efficient
22761 implementation of @code{std::make_integer_sequence}.
22763 @end table
22766 @node C++ Concepts
22767 @section C++ Concepts
22769 C++ concepts provide much-improved support for generic programming. In
22770 particular, they allow the specification of constraints on template arguments.
22771 The constraints are used to extend the usual overloading and partial
22772 specialization capabilities of the language, allowing generic data structures
22773 and algorithms to be ``refined'' based on their properties rather than their
22774 type names.
22776 The following keywords are reserved for concepts.
22778 @table @code
22779 @item assumes
22780 States an expression as an assumption, and if possible, verifies that the
22781 assumption is valid. For example, @code{assume(n > 0)}.
22783 @item axiom
22784 Introduces an axiom definition. Axioms introduce requirements on values.
22786 @item forall
22787 Introduces a universally quantified object in an axiom. For example,
22788 @code{forall (int n) n + 0 == n}).
22790 @item concept
22791 Introduces a concept definition. Concepts are sets of syntactic and semantic
22792 requirements on types and their values.
22794 @item requires
22795 Introduces constraints on template arguments or requirements for a member
22796 function of a class template.
22798 @end table
22800 The front end also exposes a number of internal mechanism that can be used
22801 to simplify the writing of type traits. Note that some of these traits are
22802 likely to be removed in the future.
22804 @table @code
22805 @item __is_same (type1, type2)
22806 A binary type trait: true whenever the type arguments are the same.
22808 @end table
22811 @node Deprecated Features
22812 @section Deprecated Features
22814 In the past, the GNU C++ compiler was extended to experiment with new
22815 features, at a time when the C++ language was still evolving.  Now that
22816 the C++ standard is complete, some of those features are superseded by
22817 superior alternatives.  Using the old features might cause a warning in
22818 some cases that the feature will be dropped in the future.  In other
22819 cases, the feature might be gone already.
22821 While the list below is not exhaustive, it documents some of the options
22822 that are now deprecated:
22824 @table @code
22825 @item -fexternal-templates
22826 @itemx -falt-external-templates
22827 These are two of the many ways for G++ to implement template
22828 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
22829 defines how template definitions have to be organized across
22830 implementation units.  G++ has an implicit instantiation mechanism that
22831 should work just fine for standard-conforming code.
22833 @item -fstrict-prototype
22834 @itemx -fno-strict-prototype
22835 Previously it was possible to use an empty prototype parameter list to
22836 indicate an unspecified number of parameters (like C), rather than no
22837 parameters, as C++ demands.  This feature has been removed, except where
22838 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
22839 @end table
22841 G++ allows a virtual function returning @samp{void *} to be overridden
22842 by one returning a different pointer type.  This extension to the
22843 covariant return type rules is now deprecated and will be removed from a
22844 future version.
22846 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22847 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22848 and are now removed from G++.  Code using these operators should be
22849 modified to use @code{std::min} and @code{std::max} instead.
22851 The named return value extension has been deprecated, and is now
22852 removed from G++.
22854 The use of initializer lists with new expressions has been deprecated,
22855 and is now removed from G++.
22857 Floating and complex non-type template parameters have been deprecated,
22858 and are now removed from G++.
22860 The implicit typename extension has been deprecated and is now
22861 removed from G++.
22863 The use of default arguments in function pointers, function typedefs
22864 and other places where they are not permitted by the standard is
22865 deprecated and will be removed from a future version of G++.
22867 G++ allows floating-point literals to appear in integral constant expressions,
22868 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22869 This extension is deprecated and will be removed from a future version.
22871 G++ allows static data members of const floating-point type to be declared
22872 with an initializer in a class definition. The standard only allows
22873 initializers for static members of const integral types and const
22874 enumeration types so this extension has been deprecated and will be removed
22875 from a future version.
22877 @node Backwards Compatibility
22878 @section Backwards Compatibility
22879 @cindex Backwards Compatibility
22880 @cindex ARM [Annotated C++ Reference Manual]
22882 Now that there is a definitive ISO standard C++, G++ has a specification
22883 to adhere to.  The C++ language evolved over time, and features that
22884 used to be acceptable in previous drafts of the standard, such as the ARM
22885 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
22886 compilation of C++ written to such drafts, G++ contains some backwards
22887 compatibilities.  @emph{All such backwards compatibility features are
22888 liable to disappear in future versions of G++.} They should be considered
22889 deprecated.   @xref{Deprecated Features}.
22891 @table @code
22892 @item For scope
22893 If a variable is declared at for scope, it used to remain in scope until
22894 the end of the scope that contained the for statement (rather than just
22895 within the for scope).  G++ retains this, but issues a warning, if such a
22896 variable is accessed outside the for scope.
22898 @item Implicit C language
22899 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22900 scope to set the language.  On such systems, all header files are
22901 implicitly scoped inside a C language scope.  Also, an empty prototype
22902 @code{()} is treated as an unspecified number of arguments, rather
22903 than no arguments, as C++ demands.
22904 @end table
22906 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
22907 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr