* decl2.c (min_vis_expr_r, expr_visibility): New.
[official-gcc.git] / gcc / doc / extend.texi
blob5b180e76b214880b725ea3365c8ec6f0dbf88a7f
1 c Copyright (C) 1988-2018 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    Nested function in GNU C.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax::    Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments::        C++ comments are recognized.
67 * Dollar Signs::        Dollar sign is allowed in identifiers.
68 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
69 * Alignment::           Determining the alignment of a function, type or variable.
70 * Inline::              Defining inline functions (as fast as macros).
71 * Volatiles::           What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83                         arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86                         checking.
87 * Other Builtins::      Other built-in functions.
88 * Target Builtins::     Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas::             Pragmas accepted by GCC.
91 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
92 * Thread-Local::        Per-thread variables.
93 * Binary constants::    Binary constants using the @samp{0b} prefix.
94 @end menu
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@.  This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces.  For
111 example:
113 @smallexample
114 (@{ int y = foo (); int z;
115    if (y > 0) z = y;
116    else z = - y;
117    z; @})
118 @end smallexample
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct.  (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once).  For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects.  In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
146 @smallexample
147 #define maxint(a,b) \
148   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression.  For instance, if @code{A} is a class, then
162 @smallexample
163         A a;
165         (@{a;@}).Foo ()
166 @end smallexample
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end.  This makes statement
176 expressions inside macros slightly different from function calls.  In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call.  In the statement expression case they are destroyed during
180 the statement expression.  For instance,
182 @smallexample
183 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186 void foo ()
188   macro (X ());
189   function (X ());
191 @end smallexample
193 @noindent
194 has different places where temporaries are destroyed.  For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}.  In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++.  (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted.  Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression.  In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression.  For example,
219 @smallexample
220   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}.  If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope.  A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
244 @noindent
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself.  You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros.  If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them.  However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function.  A
263 local label avoids this problem.  For example:
265 @smallexample
266 #define SEARCH(value, array, target)              \
267 do @{                                              \
268   __label__ found;                                \
269   typeof (target) _SEARCH_target = (target);      \
270   typeof (*(array)) *_SEARCH_array = (array);     \
271   int i, j;                                       \
272   int value;                                      \
273   for (i = 0; i < max; i++)                       \
274     for (j = 0; j < max; j++)                     \
275       if (_SEARCH_array[i][j] == _SEARCH_target)  \
276         @{ (value) = i; goto found; @}              \
277   (value) = -1;                                   \
278  found:;                                          \
279 @} while (0)
280 @end smallexample
282 This could also be written using a statement expression:
284 @smallexample
285 #define SEARCH(array, target)                     \
286 (@{                                                \
287   __label__ found;                                \
288   typeof (target) _SEARCH_target = (target);      \
289   typeof (*(array)) *_SEARCH_array = (array);     \
290   int i, j;                                       \
291   int value;                                      \
292   for (i = 0; i < max; i++)                       \
293     for (j = 0; j < max; j++)                     \
294       if (_SEARCH_array[i][j] == _SEARCH_target)  \
295         @{ value = i; goto found; @}                \
296   value = -1;                                     \
297  found:                                           \
298   value;                                          \
300 @end smallexample
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any.  @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}.  The
314 value has type @code{void *}.  This value is a constant and can be used
315 wherever a constant of that type is valid.  For example:
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
323 To use these values, you need to be able to jump to one.  This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}.  For example,
329 @smallexample
330 goto *ptr;
331 @end smallexample
333 @noindent
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
343 @noindent
344 Then you can select a label with indexing, like this:
346 @smallexample
347 goto *array[i];
348 @end smallexample
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement.  The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen.  The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372                              &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned.  If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning.  If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
394 @cindex thunks
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
402 call it twice:
404 @smallexample
405 @group
406 foo (double a, double b)
408   double square (double z) @{ return z * z; @}
410   return square (a) + square (b);
412 @end group
413 @end smallexample
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition.  This is
417 called @dfn{lexical scoping}.  For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
420 @smallexample
421 @group
422 bar (int *array, int offset, int size)
424   int access (int *array, int index)
425     @{ return array[index + offset]; @}
426   int i;
427   /* @r{@dots{}} */
428   for (i = 0; i < size; i++)
429     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @end group
432 @end smallexample
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
441 @smallexample
442 hack (int *array, int size)
444   void store (int index, int value)
445     @{ array[index] = value; @}
447   intermediate (store, size);
449 @end smallexample
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument.  If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose.  If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk.  If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
463 safe.
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}.  This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}).  Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well.  Here is an example:
476 @smallexample
477 @group
478 bar (int *array, int offset, int size)
480   __label__ failure;
481   int access (int *array, int index)
482     @{
483       if (index > size)
484         goto failure;
485       return array[index + offset];
486     @}
487   int i;
488   /* @r{@dots{}} */
489   for (i = 0; i < size; i++)
490     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
491   /* @r{@dots{}} */
492   return 0;
494  /* @r{Control comes here from @code{access}
495     if it detects an error.}  */
496  failure:
497   return -1;
499 @end group
500 @end smallexample
502 A nested function always has no linkage.  Declaring one with
503 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
507 @smallexample
508 bar (int *array, int offset, int size)
510   __label__ failure;
511   auto int access (int *, int);
512   /* @r{@dots{}} */
513   int access (int *array, int index)
514     @{
515       if (index > size)
516         goto failure;
517       return array[index + offset];
518     @}
519   /* @r{@dots{}} */
521 @end smallexample
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
531 of the arguments.
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
536 that data type).
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language.  It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack.  Then it returns the
551 address of that block.
552 @end deftypefn
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
557 and @var{size}.
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}.  The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}.  The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
570 area.
571 @end deftypefn
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function.  You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
577 @end deftypefn
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function.  It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments.  This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable.  For example:
589 @smallexample
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594   int r = fprintf (f, "myprintf: ");
595   if (r < 0)
596     return r;
597   int s = fprintf (f, format, __builtin_va_arg_pack ());
598   if (s < 0)
599     return s;
600   return r + s;
602 @end smallexample
603 @end deftypefn
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function.  It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
613 @smallexample
614 #ifdef __OPTIMIZE__
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618   if (__builtin_va_arg_pack_len () > 1)
619     warn_open_too_many_arguments ();
621   if (__builtin_constant_p (oflag))
622     @{
623       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
624         @{
625           warn_open_missing_mode ();
626           return __open_2 (path, oflag);
627         @}
628       return open (path, oflag, __builtin_va_arg_pack ());
629     @}
631   if (__builtin_va_arg_pack_len () < 1)
632     return __open_2 (path, oflag);
634   return open (path, oflag, __builtin_va_arg_pack ());
636 #endif
637 @end smallexample
638 @end deftypefn
640 @node Typeof
641 @section Referring to a Type with @code{typeof}
642 @findex typeof
643 @findex sizeof
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type.  Here is an example with an expression:
653 @smallexample
654 typeof (x[0](1))
655 @end smallexample
657 @noindent
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
663 @smallexample
664 typeof (int *)
665 @end smallexample
667 @noindent
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used.  For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
680 such a type.
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
688 @smallexample
689 #define max(a,b) \
690   (@{ typeof (a) _a = (a); \
691       typeof (b) _b = (b); \
692     _a > _b ? _a : _b; @})
693 @end smallexample
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}.  Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
708 @noindent
709 Some more examples of the use of @code{typeof}:
711 @itemize @bullet
712 @item
713 This declares @code{y} with the type of what @code{x} points to.
715 @smallexample
716 typeof (*x) y;
717 @end smallexample
719 @item
720 This declares @code{y} as an array of such values.
722 @smallexample
723 typeof (*x) y[4];
724 @end smallexample
726 @item
727 This declares @code{y} as an array of pointers to characters:
729 @smallexample
730 typeof (typeof (char *)[4]) y;
731 @end smallexample
733 @noindent
734 It is equivalent to the following traditional C declaration:
736 @smallexample
737 char *y[4];
738 @end smallexample
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
743 @smallexample
744 #define pointer(T)  typeof(T *)
745 #define array(T, N) typeof(T [N])
746 @end smallexample
748 @noindent
749 Now the declaration can be rewritten this way:
751 @smallexample
752 array (pointer (char), 4) y;
753 @end smallexample
755 @noindent
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
758 @end itemize
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}.  In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer.  (In C++, you should use C++11
766 @code{auto} for this purpose.)  Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
769 @smallexample
770 #define max(a,b) \
771   (@{ __auto_type _a = (a); \
772       __auto_type _b = (b); \
773     _a > _b ? _a : _b; @})
774 @end smallexample
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778 @itemize @bullet
779 @item Each argument to the macro appears only once in the expansion of
780 the macro.  This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
782 such macros.
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
787 @end itemize
789 @node Conditionals
790 @section Conditionals with Omitted Operands
791 @cindex conditional expressions, extensions
792 @cindex omitted middle-operands
793 @cindex middle-operands, omitted
794 @cindex extensions, @code{?:}
795 @cindex @code{?:} extensions
797 The middle operand in a conditional expression may be omitted.  Then
798 if the first operand is nonzero, its value is the value of the conditional
799 expression.
801 Therefore, the expression
803 @smallexample
804 x ? : y
805 @end smallexample
807 @noindent
808 has the value of @code{x} if that is nonzero; otherwise, the value of
809 @code{y}.
811 This example is perfectly equivalent to
813 @smallexample
814 x ? x : y
815 @end smallexample
817 @cindex side effect in @code{?:}
818 @cindex @code{?:} side effect
819 @noindent
820 In this simple case, the ability to omit the middle operand is not
821 especially useful.  When it becomes useful is when the first operand does,
822 or may (if it is a macro argument), contain a side effect.  Then repeating
823 the operand in the middle would perform the side effect twice.  Omitting
824 the middle operand uses the value already computed without the undesirable
825 effects of recomputing it.
827 @node __int128
828 @section 128-bit Integers
829 @cindex @code{__int128} data types
831 As an extension the integer scalar type @code{__int128} is supported for
832 targets which have an integer mode wide enough to hold 128 bits.
833 Simply write @code{__int128} for a signed 128-bit integer, or
834 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
835 support in GCC for expressing an integer constant of type @code{__int128}
836 for targets with @code{long long} integer less than 128 bits wide.
838 @node Long Long
839 @section Double-Word Integers
840 @cindex @code{long long} data types
841 @cindex double-word arithmetic
842 @cindex multiprecision arithmetic
843 @cindex @code{LL} integer suffix
844 @cindex @code{ULL} integer suffix
846 ISO C99 and ISO C++11 support data types for integers that are at least
847 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
848 Simply write @code{long long int} for a signed integer, or
849 @code{unsigned long long int} for an unsigned integer.  To make an
850 integer constant of type @code{long long int}, add the suffix @samp{LL}
851 to the integer.  To make an integer constant of type @code{unsigned long
852 long int}, add the suffix @samp{ULL} to the integer.
854 You can use these types in arithmetic like any other integer types.
855 Addition, subtraction, and bitwise boolean operations on these types
856 are open-coded on all types of machines.  Multiplication is open-coded
857 if the machine supports a fullword-to-doubleword widening multiply
858 instruction.  Division and shifts are open-coded only on machines that
859 provide special support.  The operations that are not open-coded use
860 special library routines that come with GCC@.
862 There may be pitfalls when you use @code{long long} types for function
863 arguments without function prototypes.  If a function
864 expects type @code{int} for its argument, and you pass a value of type
865 @code{long long int}, confusion results because the caller and the
866 subroutine disagree about the number of bytes for the argument.
867 Likewise, if the function expects @code{long long int} and you pass
868 @code{int}.  The best way to avoid such problems is to use prototypes.
870 @node Complex
871 @section Complex Numbers
872 @cindex complex numbers
873 @cindex @code{_Complex} keyword
874 @cindex @code{__complex__} keyword
876 ISO C99 supports complex floating data types, and as an extension GCC
877 supports them in C90 mode and in C++.  GCC also supports complex integer data
878 types which are not part of ISO C99.  You can declare complex types
879 using the keyword @code{_Complex}.  As an extension, the older GNU
880 keyword @code{__complex__} is also supported.
882 For example, @samp{_Complex double x;} declares @code{x} as a
883 variable whose real part and imaginary part are both of type
884 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
885 have real and imaginary parts of type @code{short int}; this is not
886 likely to be useful, but it shows that the set of complex types is
887 complete.
889 To write a constant with a complex data type, use the suffix @samp{i} or
890 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
891 has type @code{_Complex float} and @code{3i} has type
892 @code{_Complex int}.  Such a constant always has a pure imaginary
893 value, but you can form any complex value you like by adding one to a
894 real constant.  This is a GNU extension; if you have an ISO C99
895 conforming C library (such as the GNU C Library), and want to construct complex
896 constants of floating type, you should include @code{<complex.h>} and
897 use the macros @code{I} or @code{_Complex_I} instead.
899 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
900 that includes the @samp{<complex>} header cannot use @samp{i} for the
901 GNU extension.  The @samp{j} suffix still has the GNU meaning.
903 @cindex @code{__real__} keyword
904 @cindex @code{__imag__} keyword
905 To extract the real part of a complex-valued expression @var{exp}, write
906 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
907 extract the imaginary part.  This is a GNU extension; for values of
908 floating type, you should use the ISO C99 functions @code{crealf},
909 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
910 @code{cimagl}, declared in @code{<complex.h>} and also provided as
911 built-in functions by GCC@.
913 @cindex complex conjugation
914 The operator @samp{~} performs complex conjugation when used on a value
915 with a complex type.  This is a GNU extension; for values of
916 floating type, you should use the ISO C99 functions @code{conjf},
917 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
918 provided as built-in functions by GCC@.
920 GCC can allocate complex automatic variables in a noncontiguous
921 fashion; it's even possible for the real part to be in a register while
922 the imaginary part is on the stack (or vice versa).  Only the DWARF
923 debug info format can represent this, so use of DWARF is recommended.
924 If you are using the stabs debug info format, GCC describes a noncontiguous
925 complex variable as if it were two separate variables of noncomplex type.
926 If the variable's actual name is @code{foo}, the two fictitious
927 variables are named @code{foo$real} and @code{foo$imag}.  You can
928 examine and set these two fictitious variables with your debugger.
930 @node Floating Types
931 @section Additional Floating Types
932 @cindex additional floating types
933 @cindex @code{_Float@var{n}} data types
934 @cindex @code{_Float@var{n}x} data types
935 @cindex @code{__float80} data type
936 @cindex @code{__float128} data type
937 @cindex @code{__ibm128} data type
938 @cindex @code{w} floating point suffix
939 @cindex @code{q} floating point suffix
940 @cindex @code{W} floating point suffix
941 @cindex @code{Q} floating point suffix
943 ISO/IEC TS 18661-3:2015 defines C support for additional floating
944 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
945 these type names; the set of types supported depends on the target
946 architecture.  These types are not supported when compiling C++.
947 Constants with these types use suffixes @code{f@var{n}} or
948 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
949 names can be used together with @code{_Complex} to declare complex
950 types.
952 As an extension, GNU C and GNU C++ support additional floating
953 types, which are not supported by all targets.
954 @itemize @bullet
955 @item @code{__float128} is available on i386, x86_64, IA-64, and
956 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
957 the vector scalar (VSX) instruction set.  @code{__float128} supports
958 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
959 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
960 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
961 double}.
963 @item @code{__float80} is available on the i386, x86_64, and IA-64
964 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
965 an alias for the type name @code{_Float64x} on these targets.
967 @item @code{__ibm128} is available on PowerPC targets, and provides
968 access to the IBM extended double format which is the current format
969 used for @code{long double}.  When @code{long double} transitions to
970 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
971 for use in conversions between the two types.
972 @end itemize
974 Support for these additional types includes the arithmetic operators:
975 add, subtract, multiply, divide; unary arithmetic operators;
976 relational operators; equality operators; and conversions to and from
977 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
978 in a literal constant of type @code{__float80} or type
979 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
981 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
982 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
983 expected in future versions of GCC that @code{_Float128} and @code{__float128}
984 will be enabled automatically.
986 The @code{_Float128} type is supported on all systems where
987 @code{__float128} is supported or where @code{long double} has the
988 IEEE binary128 format.  The @code{_Float64x} type is supported on all
989 systems where @code{__float128} is supported.  The @code{_Float32}
990 type is supported on all systems supporting IEEE binary32; the
991 @code{_Float64} and @code{_Float32x} types are supported on all systems
992 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
993 systems by default, and on ARM systems when the IEEE format for 16-bit
994 floating-point types is selected with @option{-mfp16-format=ieee}.
995 GCC does not currently support @code{_Float128x} on any systems.
997 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
998 types using the corresponding internal complex type, @code{XCmode} for
999 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1001 @smallexample
1002 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1003 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1004 @end smallexample
1006 On the PowerPC Linux VSX targets, you can declare complex types using
1007 the corresponding internal complex type, @code{KCmode} for
1008 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1010 @smallexample
1011 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1012 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1013 @end smallexample
1015 @node Half-Precision
1016 @section Half-Precision Floating Point
1017 @cindex half-precision floating point
1018 @cindex @code{__fp16} data type
1020 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1021 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1022 On ARM systems, you must enable this type explicitly with the
1023 @option{-mfp16-format} command-line option in order to use it.
1025 ARM targets support two incompatible representations for half-precision
1026 floating-point values.  You must choose one of the representations and
1027 use it consistently in your program.
1029 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1030 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1031 There are 11 bits of significand precision, approximately 3
1032 decimal digits.
1034 Specifying @option{-mfp16-format=alternative} selects the ARM
1035 alternative format.  This representation is similar to the IEEE
1036 format, but does not support infinities or NaNs.  Instead, the range
1037 of exponents is extended, so that this format can represent normalized
1038 values in the range of @math{2^{-14}} to 131008.
1040 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1041 not require use of the @option{-mfp16-format} command-line option.
1043 The @code{__fp16} type may only be used as an argument to intrinsics defined
1044 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1045 arithmetic and other operations, @code{__fp16} values in C or C++
1046 expressions are automatically promoted to @code{float}.
1048 The ARM target provides hardware support for conversions between
1049 @code{__fp16} and @code{float} values
1050 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1051 hardware support for conversions between @code{__fp16} and @code{double}
1052 values.  GCC generates code using these hardware instructions if you
1053 compile with options to select an FPU that provides them;
1054 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1055 in addition to the @option{-mfp16-format} option to select
1056 a half-precision format.
1058 Language-level support for the @code{__fp16} data type is
1059 independent of whether GCC generates code using hardware floating-point
1060 instructions.  In cases where hardware support is not specified, GCC
1061 implements conversions between @code{__fp16} and other types as library
1062 calls.
1064 It is recommended that portable code use the @code{_Float16} type defined
1065 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1067 @node Decimal Float
1068 @section Decimal Floating Types
1069 @cindex decimal floating types
1070 @cindex @code{_Decimal32} data type
1071 @cindex @code{_Decimal64} data type
1072 @cindex @code{_Decimal128} data type
1073 @cindex @code{df} integer suffix
1074 @cindex @code{dd} integer suffix
1075 @cindex @code{dl} integer suffix
1076 @cindex @code{DF} integer suffix
1077 @cindex @code{DD} integer suffix
1078 @cindex @code{DL} integer suffix
1080 As an extension, GNU C supports decimal floating types as
1081 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1082 floating types in GCC will evolve as the draft technical report changes.
1083 Calling conventions for any target might also change.  Not all targets
1084 support decimal floating types.
1086 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1087 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1088 @code{float}, @code{double}, and @code{long double} whose radix is not
1089 specified by the C standard but is usually two.
1091 Support for decimal floating types includes the arithmetic operators
1092 add, subtract, multiply, divide; unary arithmetic operators;
1093 relational operators; equality operators; and conversions to and from
1094 integer and other floating types.  Use a suffix @samp{df} or
1095 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1096 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1097 @code{_Decimal128}.
1099 GCC support of decimal float as specified by the draft technical report
1100 is incomplete:
1102 @itemize @bullet
1103 @item
1104 When the value of a decimal floating type cannot be represented in the
1105 integer type to which it is being converted, the result is undefined
1106 rather than the result value specified by the draft technical report.
1108 @item
1109 GCC does not provide the C library functionality associated with
1110 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1111 @file{wchar.h}, which must come from a separate C library implementation.
1112 Because of this the GNU C compiler does not define macro
1113 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1114 the technical report.
1115 @end itemize
1117 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1118 are supported by the DWARF debug information format.
1120 @node Hex Floats
1121 @section Hex Floats
1122 @cindex hex floats
1124 ISO C99 and ISO C++17 support floating-point numbers written not only in
1125 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1126 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1127 supports this in C90 mode (except in some cases when strictly
1128 conforming) and in C++98, C++11 and C++14 modes.  In that format the
1129 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1130 mandatory.  The exponent is a decimal number that indicates the power of
1131 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1132 @tex
1133 $1 {15\over16}$,
1134 @end tex
1135 @ifnottex
1136 1 15/16,
1137 @end ifnottex
1138 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1139 is the same as @code{1.55e1}.
1141 Unlike for floating-point numbers in the decimal notation the exponent
1142 is always required in the hexadecimal notation.  Otherwise the compiler
1143 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1144 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1145 extension for floating-point constants of type @code{float}.
1147 @node Fixed-Point
1148 @section Fixed-Point Types
1149 @cindex fixed-point types
1150 @cindex @code{_Fract} data type
1151 @cindex @code{_Accum} data type
1152 @cindex @code{_Sat} data type
1153 @cindex @code{hr} fixed-suffix
1154 @cindex @code{r} fixed-suffix
1155 @cindex @code{lr} fixed-suffix
1156 @cindex @code{llr} fixed-suffix
1157 @cindex @code{uhr} fixed-suffix
1158 @cindex @code{ur} fixed-suffix
1159 @cindex @code{ulr} fixed-suffix
1160 @cindex @code{ullr} fixed-suffix
1161 @cindex @code{hk} fixed-suffix
1162 @cindex @code{k} fixed-suffix
1163 @cindex @code{lk} fixed-suffix
1164 @cindex @code{llk} fixed-suffix
1165 @cindex @code{uhk} fixed-suffix
1166 @cindex @code{uk} fixed-suffix
1167 @cindex @code{ulk} fixed-suffix
1168 @cindex @code{ullk} fixed-suffix
1169 @cindex @code{HR} fixed-suffix
1170 @cindex @code{R} fixed-suffix
1171 @cindex @code{LR} fixed-suffix
1172 @cindex @code{LLR} fixed-suffix
1173 @cindex @code{UHR} fixed-suffix
1174 @cindex @code{UR} fixed-suffix
1175 @cindex @code{ULR} fixed-suffix
1176 @cindex @code{ULLR} fixed-suffix
1177 @cindex @code{HK} fixed-suffix
1178 @cindex @code{K} fixed-suffix
1179 @cindex @code{LK} fixed-suffix
1180 @cindex @code{LLK} fixed-suffix
1181 @cindex @code{UHK} fixed-suffix
1182 @cindex @code{UK} fixed-suffix
1183 @cindex @code{ULK} fixed-suffix
1184 @cindex @code{ULLK} fixed-suffix
1186 As an extension, GNU C supports fixed-point types as
1187 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1188 types in GCC will evolve as the draft technical report changes.
1189 Calling conventions for any target might also change.  Not all targets
1190 support fixed-point types.
1192 The fixed-point types are
1193 @code{short _Fract},
1194 @code{_Fract},
1195 @code{long _Fract},
1196 @code{long long _Fract},
1197 @code{unsigned short _Fract},
1198 @code{unsigned _Fract},
1199 @code{unsigned long _Fract},
1200 @code{unsigned long long _Fract},
1201 @code{_Sat short _Fract},
1202 @code{_Sat _Fract},
1203 @code{_Sat long _Fract},
1204 @code{_Sat long long _Fract},
1205 @code{_Sat unsigned short _Fract},
1206 @code{_Sat unsigned _Fract},
1207 @code{_Sat unsigned long _Fract},
1208 @code{_Sat unsigned long long _Fract},
1209 @code{short _Accum},
1210 @code{_Accum},
1211 @code{long _Accum},
1212 @code{long long _Accum},
1213 @code{unsigned short _Accum},
1214 @code{unsigned _Accum},
1215 @code{unsigned long _Accum},
1216 @code{unsigned long long _Accum},
1217 @code{_Sat short _Accum},
1218 @code{_Sat _Accum},
1219 @code{_Sat long _Accum},
1220 @code{_Sat long long _Accum},
1221 @code{_Sat unsigned short _Accum},
1222 @code{_Sat unsigned _Accum},
1223 @code{_Sat unsigned long _Accum},
1224 @code{_Sat unsigned long long _Accum}.
1226 Fixed-point data values contain fractional and optional integral parts.
1227 The format of fixed-point data varies and depends on the target machine.
1229 Support for fixed-point types includes:
1230 @itemize @bullet
1231 @item
1232 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1233 @item
1234 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1235 @item
1236 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1237 @item
1238 binary shift operators (@code{<<}, @code{>>})
1239 @item
1240 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1241 @item
1242 equality operators (@code{==}, @code{!=})
1243 @item
1244 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1245 @code{<<=}, @code{>>=})
1246 @item
1247 conversions to and from integer, floating-point, or fixed-point types
1248 @end itemize
1250 Use a suffix in a fixed-point literal constant:
1251 @itemize
1252 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1253 @code{_Sat short _Fract}
1254 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1255 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1256 @code{_Sat long _Fract}
1257 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1258 @code{_Sat long long _Fract}
1259 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1260 @code{_Sat unsigned short _Fract}
1261 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1262 @code{_Sat unsigned _Fract}
1263 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1264 @code{_Sat unsigned long _Fract}
1265 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1266 and @code{_Sat unsigned long long _Fract}
1267 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1268 @code{_Sat short _Accum}
1269 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1270 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1271 @code{_Sat long _Accum}
1272 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1273 @code{_Sat long long _Accum}
1274 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1275 @code{_Sat unsigned short _Accum}
1276 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1277 @code{_Sat unsigned _Accum}
1278 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1279 @code{_Sat unsigned long _Accum}
1280 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1281 and @code{_Sat unsigned long long _Accum}
1282 @end itemize
1284 GCC support of fixed-point types as specified by the draft technical report
1285 is incomplete:
1287 @itemize @bullet
1288 @item
1289 Pragmas to control overflow and rounding behaviors are not implemented.
1290 @end itemize
1292 Fixed-point types are supported by the DWARF debug information format.
1294 @node Named Address Spaces
1295 @section Named Address Spaces
1296 @cindex Named Address Spaces
1298 As an extension, GNU C supports named address spaces as
1299 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1300 address spaces in GCC will evolve as the draft technical report
1301 changes.  Calling conventions for any target might also change.  At
1302 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1303 address spaces other than the generic address space.
1305 Address space identifiers may be used exactly like any other C type
1306 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1307 document for more details.
1309 @anchor{AVR Named Address Spaces}
1310 @subsection AVR Named Address Spaces
1312 On the AVR target, there are several address spaces that can be used
1313 in order to put read-only data into the flash memory and access that
1314 data by means of the special instructions @code{LPM} or @code{ELPM}
1315 needed to read from flash.
1317 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1318 flash memory by means of @code{LD*} instructions because the flash
1319 memory is mapped into the RAM address space.  There is @emph{no need}
1320 for language extensions like @code{__flash} or attribute
1321 @ref{AVR Variable Attributes,,@code{progmem}}.
1322 The default linker description files for these devices cater for that
1323 feature and @code{.rodata} stays in flash: The compiler just generates
1324 @code{LD*} instructions, and the linker script adds core specific
1325 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1326 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1327 See @ref{AVR Options} for a list of respective devices.
1329 For devices not in @code{avrtiny} or @code{avrxmega3},
1330 any data including read-only data is located in RAM (the generic
1331 address space) because flash memory is not visible in the RAM address
1332 space.  In order to locate read-only data in flash memory @emph{and}
1333 to generate the right instructions to access this data without
1334 using (inline) assembler code, special address spaces are needed.
1336 @table @code
1337 @item __flash
1338 @cindex @code{__flash} AVR Named Address Spaces
1339 The @code{__flash} qualifier locates data in the
1340 @code{.progmem.data} section. Data is read using the @code{LPM}
1341 instruction. Pointers to this address space are 16 bits wide.
1343 @item __flash1
1344 @itemx __flash2
1345 @itemx __flash3
1346 @itemx __flash4
1347 @itemx __flash5
1348 @cindex @code{__flash1} AVR Named Address Spaces
1349 @cindex @code{__flash2} AVR Named Address Spaces
1350 @cindex @code{__flash3} AVR Named Address Spaces
1351 @cindex @code{__flash4} AVR Named Address Spaces
1352 @cindex @code{__flash5} AVR Named Address Spaces
1353 These are 16-bit address spaces locating data in section
1354 @code{.progmem@var{N}.data} where @var{N} refers to
1355 address space @code{__flash@var{N}}.
1356 The compiler sets the @code{RAMPZ} segment register appropriately 
1357 before reading data by means of the @code{ELPM} instruction.
1359 @item __memx
1360 @cindex @code{__memx} AVR Named Address Spaces
1361 This is a 24-bit address space that linearizes flash and RAM:
1362 If the high bit of the address is set, data is read from
1363 RAM using the lower two bytes as RAM address.
1364 If the high bit of the address is clear, data is read from flash
1365 with @code{RAMPZ} set according to the high byte of the address.
1366 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1368 Objects in this address space are located in @code{.progmemx.data}.
1369 @end table
1371 @b{Example}
1373 @smallexample
1374 char my_read (const __flash char ** p)
1376     /* p is a pointer to RAM that points to a pointer to flash.
1377        The first indirection of p reads that flash pointer
1378        from RAM and the second indirection reads a char from this
1379        flash address.  */
1381     return **p;
1384 /* Locate array[] in flash memory */
1385 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1387 int i = 1;
1389 int main (void)
1391    /* Return 17 by reading from flash memory */
1392    return array[array[i]];
1394 @end smallexample
1396 @noindent
1397 For each named address space supported by avr-gcc there is an equally
1398 named but uppercase built-in macro defined. 
1399 The purpose is to facilitate testing if respective address space
1400 support is available or not:
1402 @smallexample
1403 #ifdef __FLASH
1404 const __flash int var = 1;
1406 int read_var (void)
1408     return var;
1410 #else
1411 #include <avr/pgmspace.h> /* From AVR-LibC */
1413 const int var PROGMEM = 1;
1415 int read_var (void)
1417     return (int) pgm_read_word (&var);
1419 #endif /* __FLASH */
1420 @end smallexample
1422 @noindent
1423 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1424 locates data in flash but
1425 accesses to these data read from generic address space, i.e.@:
1426 from RAM,
1427 so that you need special accessors like @code{pgm_read_byte}
1428 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1429 together with attribute @code{progmem}.
1431 @noindent
1432 @b{Limitations and caveats}
1434 @itemize
1435 @item
1436 Reading across the 64@tie{}KiB section boundary of
1437 the @code{__flash} or @code{__flash@var{N}} address spaces
1438 shows undefined behavior. The only address space that
1439 supports reading across the 64@tie{}KiB flash segment boundaries is
1440 @code{__memx}.
1442 @item
1443 If you use one of the @code{__flash@var{N}} address spaces
1444 you must arrange your linker script to locate the
1445 @code{.progmem@var{N}.data} sections according to your needs.
1447 @item
1448 Any data or pointers to the non-generic address spaces must
1449 be qualified as @code{const}, i.e.@: as read-only data.
1450 This still applies if the data in one of these address
1451 spaces like software version number or calibration lookup table are intended to
1452 be changed after load time by, say, a boot loader. In this case
1453 the right qualification is @code{const} @code{volatile} so that the compiler
1454 must not optimize away known values or insert them
1455 as immediates into operands of instructions.
1457 @item
1458 The following code initializes a variable @code{pfoo}
1459 located in static storage with a 24-bit address:
1460 @smallexample
1461 extern const __memx char foo;
1462 const __memx void *pfoo = &foo;
1463 @end smallexample
1465 @item
1466 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1467 Just use vanilla C / C++ code without overhead as outlined above.
1468 Attribute @code{progmem} is supported but works differently,
1469 see @ref{AVR Variable Attributes}.
1471 @end itemize
1473 @subsection M32C Named Address Spaces
1474 @cindex @code{__far} M32C Named Address Spaces
1476 On the M32C target, with the R8C and M16C CPU variants, variables
1477 qualified with @code{__far} are accessed using 32-bit addresses in
1478 order to access memory beyond the first 64@tie{}Ki bytes.  If
1479 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1480 effect.
1482 @subsection RL78 Named Address Spaces
1483 @cindex @code{__far} RL78 Named Address Spaces
1485 On the RL78 target, variables qualified with @code{__far} are accessed
1486 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1487 addresses.  Non-far variables are assumed to appear in the topmost
1488 64@tie{}KiB of the address space.
1490 @subsection SPU Named Address Spaces
1491 @cindex @code{__ea} SPU Named Address Spaces
1493 On the SPU target variables may be declared as
1494 belonging to another address space by qualifying the type with the
1495 @code{__ea} address space identifier:
1497 @smallexample
1498 extern int __ea i;
1499 @end smallexample
1501 @noindent 
1502 The compiler generates special code to access the variable @code{i}.
1503 It may use runtime library
1504 support, or generate special machine instructions to access that address
1505 space.
1507 @subsection x86 Named Address Spaces
1508 @cindex x86 named address spaces
1510 On the x86 target, variables may be declared as being relative
1511 to the @code{%fs} or @code{%gs} segments.
1513 @table @code
1514 @item __seg_fs
1515 @itemx __seg_gs
1516 @cindex @code{__seg_fs} x86 named address space
1517 @cindex @code{__seg_gs} x86 named address space
1518 The object is accessed with the respective segment override prefix.
1520 The respective segment base must be set via some method specific to
1521 the operating system.  Rather than require an expensive system call
1522 to retrieve the segment base, these address spaces are not considered
1523 to be subspaces of the generic (flat) address space.  This means that
1524 explicit casts are required to convert pointers between these address
1525 spaces and the generic address space.  In practice the application
1526 should cast to @code{uintptr_t} and apply the segment base offset
1527 that it installed previously.
1529 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1530 defined when these address spaces are supported.
1531 @end table
1533 @node Zero Length
1534 @section Arrays of Length Zero
1535 @cindex arrays of length zero
1536 @cindex zero-length arrays
1537 @cindex length-zero arrays
1538 @cindex flexible array members
1540 Declaring zero-length arrays is allowed in GNU C as an extension.
1541 A zero-length array can be useful as the last element of a structure
1542 that is really a header for a variable-length object:
1544 @smallexample
1545 struct line @{
1546   int length;
1547   char contents[0];
1550 struct line *thisline = (struct line *)
1551   malloc (sizeof (struct line) + this_length);
1552 thisline->length = this_length;
1553 @end smallexample
1555 Although the size of a zero-length array is zero, an array member of
1556 this kind may increase the size of the enclosing type as a result of tail
1557 padding.  The offset of a zero-length array member from the beginning
1558 of the enclosing structure is the same as the offset of an array with
1559 one or more elements of the same type.  The alignment of a zero-length
1560 array is the same as the alignment of its elements.
1562 Declaring zero-length arrays in other contexts, including as interior
1563 members of structure objects or as non-member objects, is discouraged.
1564 Accessing elements of zero-length arrays declared in such contexts is
1565 undefined and may be diagnosed.
1567 In the absence of the zero-length array extension, in ISO C90
1568 the @code{contents} array in the example above would typically be declared
1569 to have a single element.  Unlike a zero-length array which only contributes
1570 to the size of the enclosing structure for the purposes of alignment,
1571 a one-element array always occupies at least as much space as a single
1572 object of the type.  Although using one-element arrays this way is
1573 discouraged, GCC handles accesses to trailing one-element array members
1574 analogously to zero-length arrays.
1576 The preferred mechanism to declare variable-length types like
1577 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1578 with slightly different syntax and semantics:
1580 @itemize @bullet
1581 @item
1582 Flexible array members are written as @code{contents[]} without
1583 the @code{0}.
1585 @item
1586 Flexible array members have incomplete type, and so the @code{sizeof}
1587 operator may not be applied.  As a quirk of the original implementation
1588 of zero-length arrays, @code{sizeof} evaluates to zero.
1590 @item
1591 Flexible array members may only appear as the last member of a
1592 @code{struct} that is otherwise non-empty.
1594 @item
1595 A structure containing a flexible array member, or a union containing
1596 such a structure (possibly recursively), may not be a member of a
1597 structure or an element of an array.  (However, these uses are
1598 permitted by GCC as extensions.)
1599 @end itemize
1601 Non-empty initialization of zero-length
1602 arrays is treated like any case where there are more initializer
1603 elements than the array holds, in that a suitable warning about ``excess
1604 elements in array'' is given, and the excess elements (all of them, in
1605 this case) are ignored.
1607 GCC allows static initialization of flexible array members.
1608 This is equivalent to defining a new structure containing the original
1609 structure followed by an array of sufficient size to contain the data.
1610 E.g.@: in the following, @code{f1} is constructed as if it were declared
1611 like @code{f2}.
1613 @smallexample
1614 struct f1 @{
1615   int x; int y[];
1616 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1618 struct f2 @{
1619   struct f1 f1; int data[3];
1620 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1621 @end smallexample
1623 @noindent
1624 The convenience of this extension is that @code{f1} has the desired
1625 type, eliminating the need to consistently refer to @code{f2.f1}.
1627 This has symmetry with normal static arrays, in that an array of
1628 unknown size is also written with @code{[]}.
1630 Of course, this extension only makes sense if the extra data comes at
1631 the end of a top-level object, as otherwise we would be overwriting
1632 data at subsequent offsets.  To avoid undue complication and confusion
1633 with initialization of deeply nested arrays, we simply disallow any
1634 non-empty initialization except when the structure is the top-level
1635 object.  For example:
1637 @smallexample
1638 struct foo @{ int x; int y[]; @};
1639 struct bar @{ struct foo z; @};
1641 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1642 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1643 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1644 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1645 @end smallexample
1647 @node Empty Structures
1648 @section Structures with No Members
1649 @cindex empty structures
1650 @cindex zero-size structures
1652 GCC permits a C structure to have no members:
1654 @smallexample
1655 struct empty @{
1657 @end smallexample
1659 The structure has size zero.  In C++, empty structures are part
1660 of the language.  G++ treats empty structures as if they had a single
1661 member of type @code{char}.
1663 @node Variable Length
1664 @section Arrays of Variable Length
1665 @cindex variable-length arrays
1666 @cindex arrays of variable length
1667 @cindex VLAs
1669 Variable-length automatic arrays are allowed in ISO C99, and as an
1670 extension GCC accepts them in C90 mode and in C++.  These arrays are
1671 declared like any other automatic arrays, but with a length that is not
1672 a constant expression.  The storage is allocated at the point of
1673 declaration and deallocated when the block scope containing the declaration
1674 exits.  For
1675 example:
1677 @smallexample
1678 FILE *
1679 concat_fopen (char *s1, char *s2, char *mode)
1681   char str[strlen (s1) + strlen (s2) + 1];
1682   strcpy (str, s1);
1683   strcat (str, s2);
1684   return fopen (str, mode);
1686 @end smallexample
1688 @cindex scope of a variable length array
1689 @cindex variable-length array scope
1690 @cindex deallocating variable length arrays
1691 Jumping or breaking out of the scope of the array name deallocates the
1692 storage.  Jumping into the scope is not allowed; you get an error
1693 message for it.
1695 @cindex variable-length array in a structure
1696 As an extension, GCC accepts variable-length arrays as a member of
1697 a structure or a union.  For example:
1699 @smallexample
1700 void
1701 foo (int n)
1703   struct S @{ int x[n]; @};
1705 @end smallexample
1707 @cindex @code{alloca} vs variable-length arrays
1708 You can use the function @code{alloca} to get an effect much like
1709 variable-length arrays.  The function @code{alloca} is available in
1710 many other C implementations (but not in all).  On the other hand,
1711 variable-length arrays are more elegant.
1713 There are other differences between these two methods.  Space allocated
1714 with @code{alloca} exists until the containing @emph{function} returns.
1715 The space for a variable-length array is deallocated as soon as the array
1716 name's scope ends, unless you also use @code{alloca} in this scope.
1718 You can also use variable-length arrays as arguments to functions:
1720 @smallexample
1721 struct entry
1722 tester (int len, char data[len][len])
1724   /* @r{@dots{}} */
1726 @end smallexample
1728 The length of an array is computed once when the storage is allocated
1729 and is remembered for the scope of the array in case you access it with
1730 @code{sizeof}.
1732 If you want to pass the array first and the length afterward, you can
1733 use a forward declaration in the parameter list---another GNU extension.
1735 @smallexample
1736 struct entry
1737 tester (int len; char data[len][len], int len)
1739   /* @r{@dots{}} */
1741 @end smallexample
1743 @cindex parameter forward declaration
1744 The @samp{int len} before the semicolon is a @dfn{parameter forward
1745 declaration}, and it serves the purpose of making the name @code{len}
1746 known when the declaration of @code{data} is parsed.
1748 You can write any number of such parameter forward declarations in the
1749 parameter list.  They can be separated by commas or semicolons, but the
1750 last one must end with a semicolon, which is followed by the ``real''
1751 parameter declarations.  Each forward declaration must match a ``real''
1752 declaration in parameter name and data type.  ISO C99 does not support
1753 parameter forward declarations.
1755 @node Variadic Macros
1756 @section Macros with a Variable Number of Arguments.
1757 @cindex variable number of arguments
1758 @cindex macro with variable arguments
1759 @cindex rest argument (in macro)
1760 @cindex variadic macros
1762 In the ISO C standard of 1999, a macro can be declared to accept a
1763 variable number of arguments much as a function can.  The syntax for
1764 defining the macro is similar to that of a function.  Here is an
1765 example:
1767 @smallexample
1768 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1769 @end smallexample
1771 @noindent
1772 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1773 such a macro, it represents the zero or more tokens until the closing
1774 parenthesis that ends the invocation, including any commas.  This set of
1775 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1776 wherever it appears.  See the CPP manual for more information.
1778 GCC has long supported variadic macros, and used a different syntax that
1779 allowed you to give a name to the variable arguments just like any other
1780 argument.  Here is an example:
1782 @smallexample
1783 #define debug(format, args...) fprintf (stderr, format, args)
1784 @end smallexample
1786 @noindent
1787 This is in all ways equivalent to the ISO C example above, but arguably
1788 more readable and descriptive.
1790 GNU CPP has two further variadic macro extensions, and permits them to
1791 be used with either of the above forms of macro definition.
1793 In standard C, you are not allowed to leave the variable argument out
1794 entirely; but you are allowed to pass an empty argument.  For example,
1795 this invocation is invalid in ISO C, because there is no comma after
1796 the string:
1798 @smallexample
1799 debug ("A message")
1800 @end smallexample
1802 GNU CPP permits you to completely omit the variable arguments in this
1803 way.  In the above examples, the compiler would complain, though since
1804 the expansion of the macro still has the extra comma after the format
1805 string.
1807 To help solve this problem, CPP behaves specially for variable arguments
1808 used with the token paste operator, @samp{##}.  If instead you write
1810 @smallexample
1811 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1812 @end smallexample
1814 @noindent
1815 and if the variable arguments are omitted or empty, the @samp{##}
1816 operator causes the preprocessor to remove the comma before it.  If you
1817 do provide some variable arguments in your macro invocation, GNU CPP
1818 does not complain about the paste operation and instead places the
1819 variable arguments after the comma.  Just like any other pasted macro
1820 argument, these arguments are not macro expanded.
1822 @node Escaped Newlines
1823 @section Slightly Looser Rules for Escaped Newlines
1824 @cindex escaped newlines
1825 @cindex newlines (escaped)
1827 The preprocessor treatment of escaped newlines is more relaxed 
1828 than that specified by the C90 standard, which requires the newline
1829 to immediately follow a backslash.  
1830 GCC's implementation allows whitespace in the form
1831 of spaces, horizontal and vertical tabs, and form feeds between the
1832 backslash and the subsequent newline.  The preprocessor issues a
1833 warning, but treats it as a valid escaped newline and combines the two
1834 lines to form a single logical line.  This works within comments and
1835 tokens, as well as between tokens.  Comments are @emph{not} treated as
1836 whitespace for the purposes of this relaxation, since they have not
1837 yet been replaced with spaces.
1839 @node Subscripting
1840 @section Non-Lvalue Arrays May Have Subscripts
1841 @cindex subscripting
1842 @cindex arrays, non-lvalue
1844 @cindex subscripting and function values
1845 In ISO C99, arrays that are not lvalues still decay to pointers, and
1846 may be subscripted, although they may not be modified or used after
1847 the next sequence point and the unary @samp{&} operator may not be
1848 applied to them.  As an extension, GNU C allows such arrays to be
1849 subscripted in C90 mode, though otherwise they do not decay to
1850 pointers outside C99 mode.  For example,
1851 this is valid in GNU C though not valid in C90:
1853 @smallexample
1854 @group
1855 struct foo @{int a[4];@};
1857 struct foo f();
1859 bar (int index)
1861   return f().a[index];
1863 @end group
1864 @end smallexample
1866 @node Pointer Arith
1867 @section Arithmetic on @code{void}- and Function-Pointers
1868 @cindex void pointers, arithmetic
1869 @cindex void, size of pointer to
1870 @cindex function pointers, arithmetic
1871 @cindex function, size of pointer to
1873 In GNU C, addition and subtraction operations are supported on pointers to
1874 @code{void} and on pointers to functions.  This is done by treating the
1875 size of a @code{void} or of a function as 1.
1877 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1878 and on function types, and returns 1.
1880 @opindex Wpointer-arith
1881 The option @option{-Wpointer-arith} requests a warning if these extensions
1882 are used.
1884 @node Pointers to Arrays
1885 @section Pointers to Arrays with Qualifiers Work as Expected
1886 @cindex pointers to arrays
1887 @cindex const qualifier
1889 In GNU C, pointers to arrays with qualifiers work similar to pointers
1890 to other qualified types. For example, a value of type @code{int (*)[5]}
1891 can be used to initialize a variable of type @code{const int (*)[5]}.
1892 These types are incompatible in ISO C because the @code{const} qualifier
1893 is formally attached to the element type of the array and not the
1894 array itself.
1896 @smallexample
1897 extern void
1898 transpose (int N, int M, double out[M][N], const double in[N][M]);
1899 double x[3][2];
1900 double y[2][3];
1901 @r{@dots{}}
1902 transpose(3, 2, y, x);
1903 @end smallexample
1905 @node Initializers
1906 @section Non-Constant Initializers
1907 @cindex initializers, non-constant
1908 @cindex non-constant initializers
1910 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1911 automatic variable are not required to be constant expressions in GNU C@.
1912 Here is an example of an initializer with run-time varying elements:
1914 @smallexample
1915 foo (float f, float g)
1917   float beat_freqs[2] = @{ f-g, f+g @};
1918   /* @r{@dots{}} */
1920 @end smallexample
1922 @node Compound Literals
1923 @section Compound Literals
1924 @cindex constructor expressions
1925 @cindex initializations in expressions
1926 @cindex structures, constructor expression
1927 @cindex expressions, constructor
1928 @cindex compound literals
1929 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1931 A compound literal looks like a cast of a brace-enclosed aggregate
1932 initializer list.  Its value is an object of the type specified in
1933 the cast, containing the elements specified in the initializer.
1934 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1935 C99 and later support compound literals.  As an extension, GCC
1936 supports compound literals also in C90 mode and in C++, although
1937 as explained below, the C++ semantics are somewhat different.
1939 Usually, the specified type of a compound literal is a structure.  Assume
1940 that @code{struct foo} and @code{structure} are declared as shown:
1942 @smallexample
1943 struct foo @{int a; char b[2];@} structure;
1944 @end smallexample
1946 @noindent
1947 Here is an example of constructing a @code{struct foo} with a compound literal:
1949 @smallexample
1950 structure = ((struct foo) @{x + y, 'a', 0@});
1951 @end smallexample
1953 @noindent
1954 This is equivalent to writing the following:
1956 @smallexample
1958   struct foo temp = @{x + y, 'a', 0@};
1959   structure = temp;
1961 @end smallexample
1963 You can also construct an array, though this is dangerous in C++, as
1964 explained below.  If all the elements of the compound literal are
1965 (made up of) simple constant expressions suitable for use in
1966 initializers of objects of static storage duration, then the compound
1967 literal can be coerced to a pointer to its first element and used in
1968 such an initializer, as shown here:
1970 @smallexample
1971 char **foo = (char *[]) @{ "x", "y", "z" @};
1972 @end smallexample
1974 Compound literals for scalar types and union types are also allowed.  In
1975 the following example the variable @code{i} is initialized to the value
1976 @code{2}, the result of incrementing the unnamed object created by
1977 the compound literal.
1979 @smallexample
1980 int i = ++(int) @{ 1 @};
1981 @end smallexample
1983 As a GNU extension, GCC allows initialization of objects with static storage
1984 duration by compound literals (which is not possible in ISO C99 because
1985 the initializer is not a constant).
1986 It is handled as if the object were initialized only with the brace-enclosed
1987 list if the types of the compound literal and the object match.
1988 The elements of the compound literal must be constant.
1989 If the object being initialized has array type of unknown size, the size is
1990 determined by the size of the compound literal.
1992 @smallexample
1993 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1994 static int y[] = (int []) @{1, 2, 3@};
1995 static int z[] = (int [3]) @{1@};
1996 @end smallexample
1998 @noindent
1999 The above lines are equivalent to the following:
2000 @smallexample
2001 static struct foo x = @{1, 'a', 'b'@};
2002 static int y[] = @{1, 2, 3@};
2003 static int z[] = @{1, 0, 0@};
2004 @end smallexample
2006 In C, a compound literal designates an unnamed object with static or
2007 automatic storage duration.  In C++, a compound literal designates a
2008 temporary object that only lives until the end of its full-expression.
2009 As a result, well-defined C code that takes the address of a subobject
2010 of a compound literal can be undefined in C++, so G++ rejects
2011 the conversion of a temporary array to a pointer.  For instance, if
2012 the array compound literal example above appeared inside a function,
2013 any subsequent use of @code{foo} in C++ would have undefined behavior
2014 because the lifetime of the array ends after the declaration of @code{foo}.
2016 As an optimization, G++ sometimes gives array compound literals longer
2017 lifetimes: when the array either appears outside a function or has
2018 a @code{const}-qualified type.  If @code{foo} and its initializer had
2019 elements of type @code{char *const} rather than @code{char *}, or if
2020 @code{foo} were a global variable, the array would have static storage
2021 duration.  But it is probably safest just to avoid the use of array
2022 compound literals in C++ code.
2024 @node Designated Inits
2025 @section Designated Initializers
2026 @cindex initializers with labeled elements
2027 @cindex labeled elements in initializers
2028 @cindex case labels in initializers
2029 @cindex designated initializers
2031 Standard C90 requires the elements of an initializer to appear in a fixed
2032 order, the same as the order of the elements in the array or structure
2033 being initialized.
2035 In ISO C99 you can give the elements in any order, specifying the array
2036 indices or structure field names they apply to, and GNU C allows this as
2037 an extension in C90 mode as well.  This extension is not
2038 implemented in GNU C++.
2040 To specify an array index, write
2041 @samp{[@var{index}] =} before the element value.  For example,
2043 @smallexample
2044 int a[6] = @{ [4] = 29, [2] = 15 @};
2045 @end smallexample
2047 @noindent
2048 is equivalent to
2050 @smallexample
2051 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2052 @end smallexample
2054 @noindent
2055 The index values must be constant expressions, even if the array being
2056 initialized is automatic.
2058 An alternative syntax for this that has been obsolete since GCC 2.5 but
2059 GCC still accepts is to write @samp{[@var{index}]} before the element
2060 value, with no @samp{=}.
2062 To initialize a range of elements to the same value, write
2063 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2064 extension.  For example,
2066 @smallexample
2067 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2068 @end smallexample
2070 @noindent
2071 If the value in it has side effects, the side effects happen only once,
2072 not for each initialized field by the range initializer.
2074 @noindent
2075 Note that the length of the array is the highest value specified
2076 plus one.
2078 In a structure initializer, specify the name of a field to initialize
2079 with @samp{.@var{fieldname} =} before the element value.  For example,
2080 given the following structure,
2082 @smallexample
2083 struct point @{ int x, y; @};
2084 @end smallexample
2086 @noindent
2087 the following initialization
2089 @smallexample
2090 struct point p = @{ .y = yvalue, .x = xvalue @};
2091 @end smallexample
2093 @noindent
2094 is equivalent to
2096 @smallexample
2097 struct point p = @{ xvalue, yvalue @};
2098 @end smallexample
2100 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2101 @samp{@var{fieldname}:}, as shown here:
2103 @smallexample
2104 struct point p = @{ y: yvalue, x: xvalue @};
2105 @end smallexample
2107 Omitted field members are implicitly initialized the same as objects
2108 that have static storage duration.
2110 @cindex designators
2111 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2112 @dfn{designator}.  You can also use a designator (or the obsolete colon
2113 syntax) when initializing a union, to specify which element of the union
2114 should be used.  For example,
2116 @smallexample
2117 union foo @{ int i; double d; @};
2119 union foo f = @{ .d = 4 @};
2120 @end smallexample
2122 @noindent
2123 converts 4 to a @code{double} to store it in the union using
2124 the second element.  By contrast, casting 4 to type @code{union foo}
2125 stores it into the union as the integer @code{i}, since it is
2126 an integer.  @xref{Cast to Union}.
2128 You can combine this technique of naming elements with ordinary C
2129 initialization of successive elements.  Each initializer element that
2130 does not have a designator applies to the next consecutive element of the
2131 array or structure.  For example,
2133 @smallexample
2134 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2135 @end smallexample
2137 @noindent
2138 is equivalent to
2140 @smallexample
2141 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2142 @end smallexample
2144 Labeling the elements of an array initializer is especially useful
2145 when the indices are characters or belong to an @code{enum} type.
2146 For example:
2148 @smallexample
2149 int whitespace[256]
2150   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2151       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2152 @end smallexample
2154 @cindex designator lists
2155 You can also write a series of @samp{.@var{fieldname}} and
2156 @samp{[@var{index}]} designators before an @samp{=} to specify a
2157 nested subobject to initialize; the list is taken relative to the
2158 subobject corresponding to the closest surrounding brace pair.  For
2159 example, with the @samp{struct point} declaration above:
2161 @smallexample
2162 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2163 @end smallexample
2165 @noindent
2166 If the same field is initialized multiple times, it has the value from
2167 the last initialization.  If any such overridden initialization has
2168 side effect, it is unspecified whether the side effect happens or not.
2169 Currently, GCC discards them and issues a warning.
2171 @node Case Ranges
2172 @section Case Ranges
2173 @cindex case ranges
2174 @cindex ranges in case statements
2176 You can specify a range of consecutive values in a single @code{case} label,
2177 like this:
2179 @smallexample
2180 case @var{low} ... @var{high}:
2181 @end smallexample
2183 @noindent
2184 This has the same effect as the proper number of individual @code{case}
2185 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2187 This feature is especially useful for ranges of ASCII character codes:
2189 @smallexample
2190 case 'A' ... 'Z':
2191 @end smallexample
2193 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2194 it may be parsed wrong when you use it with integer values.  For example,
2195 write this:
2197 @smallexample
2198 case 1 ... 5:
2199 @end smallexample
2201 @noindent
2202 rather than this:
2204 @smallexample
2205 case 1...5:
2206 @end smallexample
2208 @node Cast to Union
2209 @section Cast to a Union Type
2210 @cindex cast to a union
2211 @cindex union, casting to a
2213 A cast to union type looks similar to other casts, except that the type
2214 specified is a union type.  You can specify the type either with the
2215 @code{union} keyword or with a @code{typedef} name that refers to
2216 a union.  A cast to a union actually creates a compound literal and
2217 yields an lvalue, not an rvalue like true casts do.
2218 @xref{Compound Literals}.
2220 The types that may be cast to the union type are those of the members
2221 of the union.  Thus, given the following union and variables:
2223 @smallexample
2224 union foo @{ int i; double d; @};
2225 int x;
2226 double y;
2227 @end smallexample
2229 @noindent
2230 both @code{x} and @code{y} can be cast to type @code{union foo}.
2232 Using the cast as the right-hand side of an assignment to a variable of
2233 union type is equivalent to storing in a member of the union:
2235 @smallexample
2236 union foo u;
2237 /* @r{@dots{}} */
2238 u = (union foo) x  @equiv{}  u.i = x
2239 u = (union foo) y  @equiv{}  u.d = y
2240 @end smallexample
2242 You can also use the union cast as a function argument:
2244 @smallexample
2245 void hack (union foo);
2246 /* @r{@dots{}} */
2247 hack ((union foo) x);
2248 @end smallexample
2250 @node Mixed Declarations
2251 @section Mixed Declarations and Code
2252 @cindex mixed declarations and code
2253 @cindex declarations, mixed with code
2254 @cindex code, mixed with declarations
2256 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2257 within compound statements.  As an extension, GNU C also allows this in
2258 C90 mode.  For example, you could do:
2260 @smallexample
2261 int i;
2262 /* @r{@dots{}} */
2263 i++;
2264 int j = i + 2;
2265 @end smallexample
2267 Each identifier is visible from where it is declared until the end of
2268 the enclosing block.
2270 @node Function Attributes
2271 @section Declaring Attributes of Functions
2272 @cindex function attributes
2273 @cindex declaring attributes of functions
2274 @cindex @code{volatile} applied to function
2275 @cindex @code{const} applied to function
2277 In GNU C, you can use function attributes to declare certain things
2278 about functions called in your program which help the compiler
2279 optimize calls and check your code more carefully.  For example, you
2280 can use attributes to declare that a function never returns
2281 (@code{noreturn}), returns a value depending only on its arguments
2282 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2284 You can also use attributes to control memory placement, code
2285 generation options or call/return conventions within the function
2286 being annotated.  Many of these attributes are target-specific.  For
2287 example, many targets support attributes for defining interrupt
2288 handler functions, which typically must follow special register usage
2289 and return conventions.
2291 Function attributes are introduced by the @code{__attribute__} keyword
2292 on a declaration, followed by an attribute specification inside double
2293 parentheses.  You can specify multiple attributes in a declaration by
2294 separating them by commas within the double parentheses or by
2295 immediately following an attribute declaration with another attribute
2296 declaration.  @xref{Attribute Syntax}, for the exact rules on attribute
2297 syntax and placement.  Compatible attribute specifications on distinct
2298 declarations of the same function are merged.  An attribute specification
2299 that is not compatible with attributes already applied to a declaration
2300 of the same function is ignored with a warning.
2302 GCC also supports attributes on
2303 variable declarations (@pxref{Variable Attributes}),
2304 labels (@pxref{Label Attributes}),
2305 enumerators (@pxref{Enumerator Attributes}),
2306 statements (@pxref{Statement Attributes}),
2307 and types (@pxref{Type Attributes}).
2309 There is some overlap between the purposes of attributes and pragmas
2310 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2311 found convenient to use @code{__attribute__} to achieve a natural
2312 attachment of attributes to their corresponding declarations, whereas
2313 @code{#pragma} is of use for compatibility with other compilers
2314 or constructs that do not naturally form part of the grammar.
2316 In addition to the attributes documented here,
2317 GCC plugins may provide their own attributes.
2319 @menu
2320 * Common Function Attributes::
2321 * AArch64 Function Attributes::
2322 * ARC Function Attributes::
2323 * ARM Function Attributes::
2324 * AVR Function Attributes::
2325 * Blackfin Function Attributes::
2326 * CR16 Function Attributes::
2327 * C-SKY Function Attributes::
2328 * Epiphany Function Attributes::
2329 * H8/300 Function Attributes::
2330 * IA-64 Function Attributes::
2331 * M32C Function Attributes::
2332 * M32R/D Function Attributes::
2333 * m68k Function Attributes::
2334 * MCORE Function Attributes::
2335 * MeP Function Attributes::
2336 * MicroBlaze Function Attributes::
2337 * Microsoft Windows Function Attributes::
2338 * MIPS Function Attributes::
2339 * MSP430 Function Attributes::
2340 * NDS32 Function Attributes::
2341 * Nios II Function Attributes::
2342 * Nvidia PTX Function Attributes::
2343 * PowerPC Function Attributes::
2344 * RISC-V Function Attributes::
2345 * RL78 Function Attributes::
2346 * RX Function Attributes::
2347 * S/390 Function Attributes::
2348 * SH Function Attributes::
2349 * SPU Function Attributes::
2350 * Symbian OS Function Attributes::
2351 * V850 Function Attributes::
2352 * Visium Function Attributes::
2353 * x86 Function Attributes::
2354 * Xstormy16 Function Attributes::
2355 @end menu
2357 @node Common Function Attributes
2358 @subsection Common Function Attributes
2360 The following attributes are supported on most targets.
2362 @table @code
2363 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2365 @item alias ("@var{target}")
2366 @cindex @code{alias} function attribute
2367 The @code{alias} attribute causes the declaration to be emitted as an
2368 alias for another symbol, which must be specified.  For instance,
2370 @smallexample
2371 void __f () @{ /* @r{Do something.} */; @}
2372 void f () __attribute__ ((weak, alias ("__f")));
2373 @end smallexample
2375 @noindent
2376 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2377 mangled name for the target must be used.  It is an error if @samp{__f}
2378 is not defined in the same translation unit.
2380 This attribute requires assembler and object file support,
2381 and may not be available on all targets.
2383 @item aligned
2384 @itemx aligned (@var{alignment})
2385 @cindex @code{aligned} function attribute
2386 The @code{aligned} attribute specifies a minimum alignment for
2387 the function, measured in bytes.  When specified, @var{alignment} must
2388 be an integer constant power of 2.  Specifying no @var{alignment} argument
2389 implies the maximum alignment for the target, which is often, but by no
2390 means always, 8 or 16 bytes.
2392 You cannot use this attribute to decrease the alignment of a function,
2393 only to increase it.  However, when you explicitly specify a function
2394 alignment this overrides the effect of the
2395 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2396 function.
2398 Note that the effectiveness of @code{aligned} attributes may be
2399 limited by inherent limitations in your linker.  On many systems, the
2400 linker is only able to arrange for functions to be aligned up to a
2401 certain maximum alignment.  (For some linkers, the maximum supported
2402 alignment may be very very small.)  See your linker documentation for
2403 further information.
2405 The @code{aligned} attribute can also be used for variables and fields
2406 (@pxref{Variable Attributes}.)
2408 @item alloc_align
2409 @cindex @code{alloc_align} function attribute
2410 The @code{alloc_align} attribute is used to tell the compiler that the
2411 function return value points to memory, where the returned pointer minimum
2412 alignment is given by one of the functions parameters.  GCC uses this
2413 information to improve pointer alignment analysis.
2415 The function parameter denoting the allocated alignment is specified by
2416 one integer argument, whose number is the argument of the attribute.
2417 Argument numbering starts at one.
2419 For instance,
2421 @smallexample
2422 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2423 @end smallexample
2425 @noindent
2426 declares that @code{my_memalign} returns memory with minimum alignment
2427 given by parameter 1.
2429 @item alloc_size
2430 @cindex @code{alloc_size} function attribute
2431 The @code{alloc_size} attribute is used to tell the compiler that the
2432 function return value points to memory, where the size is given by
2433 one or two of the functions parameters.  GCC uses this
2434 information to improve the correctness of @code{__builtin_object_size}.
2436 The function parameter(s) denoting the allocated size are specified by
2437 one or two integer arguments supplied to the attribute.  The allocated size
2438 is either the value of the single function argument specified or the product
2439 of the two function arguments specified.  Argument numbering starts at
2440 one.
2442 For instance,
2444 @smallexample
2445 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2446 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2447 @end smallexample
2449 @noindent
2450 declares that @code{my_calloc} returns memory of the size given by
2451 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2452 of the size given by parameter 2.
2454 @item always_inline
2455 @cindex @code{always_inline} function attribute
2456 Generally, functions are not inlined unless optimization is specified.
2457 For functions declared inline, this attribute inlines the function
2458 independent of any restrictions that otherwise apply to inlining.
2459 Failure to inline such a function is diagnosed as an error.
2460 Note that if such a function is called indirectly the compiler may
2461 or may not inline it depending on optimization level and a failure
2462 to inline an indirect call may or may not be diagnosed.
2464 @item artificial
2465 @cindex @code{artificial} function attribute
2466 This attribute is useful for small inline wrappers that if possible
2467 should appear during debugging as a unit.  Depending on the debug
2468 info format it either means marking the function as artificial
2469 or using the caller location for all instructions within the inlined
2470 body.
2472 @item assume_aligned
2473 @cindex @code{assume_aligned} function attribute
2474 The @code{assume_aligned} attribute is used to tell the compiler that the
2475 function return value points to memory, where the returned pointer minimum
2476 alignment is given by the first argument.
2477 If the attribute has two arguments, the second argument is misalignment offset.
2479 For instance
2481 @smallexample
2482 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2483 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2484 @end smallexample
2486 @noindent
2487 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2488 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2489 to 8.
2491 @item cold
2492 @cindex @code{cold} function attribute
2493 The @code{cold} attribute on functions is used to inform the compiler that
2494 the function is unlikely to be executed.  The function is optimized for
2495 size rather than speed and on many targets it is placed into a special
2496 subsection of the text section so all cold functions appear close together,
2497 improving code locality of non-cold parts of program.  The paths leading
2498 to calls of cold functions within code are marked as unlikely by the branch
2499 prediction mechanism.  It is thus useful to mark functions used to handle
2500 unlikely conditions, such as @code{perror}, as cold to improve optimization
2501 of hot functions that do call marked functions in rare occasions.
2503 When profile feedback is available, via @option{-fprofile-use}, cold functions
2504 are automatically detected and this attribute is ignored.
2506 @item const
2507 @cindex @code{const} function attribute
2508 @cindex functions that have no side effects
2509 Many functions do not examine any values except their arguments, and
2510 have no effects except to return a value.  Calls to such functions lend
2511 themselves to optimization such as common subexpression elimination.
2512 The @code{const} attribute imposes greater restrictions on a function's
2513 definition than the similar @code{pure} attribute below because it prohibits
2514 the function from reading global variables.  Consequently, the presence of
2515 the attribute on a function declaration allows GCC to emit more efficient
2516 code for some calls to the function.  Decorating the same function with
2517 both the @code{const} and the @code{pure} attribute is diagnosed.
2519 @cindex pointer arguments
2520 Note that a function that has pointer arguments and examines the data
2521 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2522 function that calls a non-@code{const} function usually must not be
2523 @code{const}.  Because a @code{const} function cannot have any side
2524 effects it does not make sense for such a function to return @code{void}.
2525 Declaring such a function is diagnosed.
2527 @item constructor
2528 @itemx destructor
2529 @itemx constructor (@var{priority})
2530 @itemx destructor (@var{priority})
2531 @cindex @code{constructor} function attribute
2532 @cindex @code{destructor} function attribute
2533 The @code{constructor} attribute causes the function to be called
2534 automatically before execution enters @code{main ()}.  Similarly, the
2535 @code{destructor} attribute causes the function to be called
2536 automatically after @code{main ()} completes or @code{exit ()} is
2537 called.  Functions with these attributes are useful for
2538 initializing data that is used implicitly during the execution of
2539 the program.
2541 You may provide an optional integer priority to control the order in
2542 which constructor and destructor functions are run.  A constructor
2543 with a smaller priority number runs before a constructor with a larger
2544 priority number; the opposite relationship holds for destructors.  So,
2545 if you have a constructor that allocates a resource and a destructor
2546 that deallocates the same resource, both functions typically have the
2547 same priority.  The priorities for constructor and destructor
2548 functions are the same as those specified for namespace-scope C++
2549 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2550 constructors for C++ objects with static storage duration and functions
2551 decorated with attribute @code{constructor} are invoked is unspecified.
2552 In mixed declarations, attribute @code{init_priority} can be used to
2553 impose a specific ordering.
2555 @item copy
2556 @itemx copy (@var{function})
2557 @cindex @code{copy} function attribute
2558 The @code{copy} attribute applies the set of attributes with which
2559 @var{function} has been declared to the declaration of the function
2560 to which the attribute is applied.  The attribute is designed for
2561 libraries that define aliases or function resolvers that are expected
2562 to specify the same set of attributes as their targets.  The @code{copy}
2563 attribute can be used with functions, variables, or types.  However,
2564 the kind of symbol to which the attribute is applied (either function
2565 or variable) must match the kind of symbol to which the argument refers.
2566 The @code{copy} attribute copies only syntaxtic and semantic attributes
2567 but attributes that affect a symbol's linkage or visibility such as
2568 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
2569 attribute is also not copied.  @xref{Common Type Attributes}.
2570 @xref{Common Variable Attributes}.
2572 For example, the @var{StrongAlias} macro below makes use of the @code{alias}
2573 and @code{copy} attributes to define an alias named @var{alloc} for function
2574 @var{allocate} declated with attributes @var{alloc_size}, @var{malloc}, and
2575 @var{nothrow}.  Thanks to the @code{__typeof__} operator the alias has
2576 the same type as the target function.  As a result of the @code{copy}
2577 attribute the alias also shares the same attributes as the target.
2579 @smallexample
2580 #define StrongAlias(TagetFunc, AliasDecl)   \
2581   extern __typeof__ (TargetFunc) AliasDecl  \
2582     __attribute__ ((alias (#TargetFunc), copy (TargetFunc)));
2584 extern __attribute__ ((alloc_size (1), malloc, nothrow))
2585   void* allocate (size_t);
2586 StrongAlias (allocate, alloc);
2587 @end smallexample
2589 @item deprecated
2590 @itemx deprecated (@var{msg})
2591 @cindex @code{deprecated} function attribute
2592 The @code{deprecated} attribute results in a warning if the function
2593 is used anywhere in the source file.  This is useful when identifying
2594 functions that are expected to be removed in a future version of a
2595 program.  The warning also includes the location of the declaration
2596 of the deprecated function, to enable users to easily find further
2597 information about why the function is deprecated, or what they should
2598 do instead.  Note that the warnings only occurs for uses:
2600 @smallexample
2601 int old_fn () __attribute__ ((deprecated));
2602 int old_fn ();
2603 int (*fn_ptr)() = old_fn;
2604 @end smallexample
2606 @noindent
2607 results in a warning on line 3 but not line 2.  The optional @var{msg}
2608 argument, which must be a string, is printed in the warning if
2609 present.
2611 The @code{deprecated} attribute can also be used for variables and
2612 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2614 The message attached to the attribute is affected by the setting of
2615 the @option{-fmessage-length} option.
2617 @item error ("@var{message}")
2618 @itemx warning ("@var{message}")
2619 @cindex @code{error} function attribute
2620 @cindex @code{warning} function attribute
2621 If the @code{error} or @code{warning} attribute 
2622 is used on a function declaration and a call to such a function
2623 is not eliminated through dead code elimination or other optimizations, 
2624 an error or warning (respectively) that includes @var{message} is diagnosed.  
2625 This is useful
2626 for compile-time checking, especially together with @code{__builtin_constant_p}
2627 and inline functions where checking the inline function arguments is not
2628 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2630 While it is possible to leave the function undefined and thus invoke
2631 a link failure (to define the function with
2632 a message in @code{.gnu.warning*} section),
2633 when using these attributes the problem is diagnosed
2634 earlier and with exact location of the call even in presence of inline
2635 functions or when not emitting debugging information.
2637 @item externally_visible
2638 @cindex @code{externally_visible} function attribute
2639 This attribute, attached to a global variable or function, nullifies
2640 the effect of the @option{-fwhole-program} command-line option, so the
2641 object remains visible outside the current compilation unit.
2643 If @option{-fwhole-program} is used together with @option{-flto} and 
2644 @command{gold} is used as the linker plugin, 
2645 @code{externally_visible} attributes are automatically added to functions 
2646 (not variable yet due to a current @command{gold} issue) 
2647 that are accessed outside of LTO objects according to resolution file
2648 produced by @command{gold}.
2649 For other linkers that cannot generate resolution file,
2650 explicit @code{externally_visible} attributes are still necessary.
2652 @item flatten
2653 @cindex @code{flatten} function attribute
2654 Generally, inlining into a function is limited.  For a function marked with
2655 this attribute, every call inside this function is inlined, if possible.
2656 Functions declared with attribute @code{noinline} and similar are not
2657 inlined.  Whether the function itself is considered for inlining depends
2658 on its size and the current inlining parameters.
2660 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2661 @cindex @code{format} function attribute
2662 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2663 @opindex Wformat
2664 The @code{format} attribute specifies that a function takes @code{printf},
2665 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2666 should be type-checked against a format string.  For example, the
2667 declaration:
2669 @smallexample
2670 extern int
2671 my_printf (void *my_object, const char *my_format, ...)
2672       __attribute__ ((format (printf, 2, 3)));
2673 @end smallexample
2675 @noindent
2676 causes the compiler to check the arguments in calls to @code{my_printf}
2677 for consistency with the @code{printf} style format string argument
2678 @code{my_format}.
2680 The parameter @var{archetype} determines how the format string is
2681 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2682 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2683 @code{strfmon}.  (You can also use @code{__printf__},
2684 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2685 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2686 @code{ms_strftime} are also present.
2687 @var{archetype} values such as @code{printf} refer to the formats accepted
2688 by the system's C runtime library,
2689 while values prefixed with @samp{gnu_} always refer
2690 to the formats accepted by the GNU C Library.  On Microsoft Windows
2691 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2692 @file{msvcrt.dll} library.
2693 The parameter @var{string-index}
2694 specifies which argument is the format string argument (starting
2695 from 1), while @var{first-to-check} is the number of the first
2696 argument to check against the format string.  For functions
2697 where the arguments are not available to be checked (such as
2698 @code{vprintf}), specify the third parameter as zero.  In this case the
2699 compiler only checks the format string for consistency.  For
2700 @code{strftime} formats, the third parameter is required to be zero.
2701 Since non-static C++ methods have an implicit @code{this} argument, the
2702 arguments of such methods should be counted from two, not one, when
2703 giving values for @var{string-index} and @var{first-to-check}.
2705 In the example above, the format string (@code{my_format}) is the second
2706 argument of the function @code{my_print}, and the arguments to check
2707 start with the third argument, so the correct parameters for the format
2708 attribute are 2 and 3.
2710 @opindex ffreestanding
2711 @opindex fno-builtin
2712 The @code{format} attribute allows you to identify your own functions
2713 that take format strings as arguments, so that GCC can check the
2714 calls to these functions for errors.  The compiler always (unless
2715 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2716 for the standard library functions @code{printf}, @code{fprintf},
2717 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2718 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2719 warnings are requested (using @option{-Wformat}), so there is no need to
2720 modify the header file @file{stdio.h}.  In C99 mode, the functions
2721 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2722 @code{vsscanf} are also checked.  Except in strictly conforming C
2723 standard modes, the X/Open function @code{strfmon} is also checked as
2724 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2725 @xref{C Dialect Options,,Options Controlling C Dialect}.
2727 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2728 recognized in the same context.  Declarations including these format attributes
2729 are parsed for correct syntax, however the result of checking of such format
2730 strings is not yet defined, and is not carried out by this version of the
2731 compiler.
2733 The target may also provide additional types of format checks.
2734 @xref{Target Format Checks,,Format Checks Specific to Particular
2735 Target Machines}.
2737 @item format_arg (@var{string-index})
2738 @cindex @code{format_arg} function attribute
2739 @opindex Wformat-nonliteral
2740 The @code{format_arg} attribute specifies that a function takes one or
2741 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
2742 @code{strfmon} style function and modifies it (for example, to translate
2743 it into another language), so the result can be passed to a
2744 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2745 function (with the remaining arguments to the format function the same
2746 as they would have been for the unmodified string).  Multiple
2747 @code{format_arg} attributes may be applied to the same function, each
2748 designating a distinct parameter as a format string.  For example, the
2749 declaration:
2751 @smallexample
2752 extern char *
2753 my_dgettext (char *my_domain, const char *my_format)
2754       __attribute__ ((format_arg (2)));
2755 @end smallexample
2757 @noindent
2758 causes the compiler to check the arguments in calls to a @code{printf},
2759 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2760 format string argument is a call to the @code{my_dgettext} function, for
2761 consistency with the format string argument @code{my_format}.  If the
2762 @code{format_arg} attribute had not been specified, all the compiler
2763 could tell in such calls to format functions would be that the format
2764 string argument is not constant; this would generate a warning when
2765 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2766 without the attribute.
2768 In calls to a function declared with more than one @code{format_arg}
2769 attribute, each with a distinct argument value, the corresponding
2770 actual function arguments are checked against all format strings
2771 designated by the attributes.  This capability is designed to support
2772 the GNU @code{ngettext} family of functions.
2774 The parameter @var{string-index} specifies which argument is the format
2775 string argument (starting from one).  Since non-static C++ methods have
2776 an implicit @code{this} argument, the arguments of such methods should
2777 be counted from two.
2779 The @code{format_arg} attribute allows you to identify your own
2780 functions that modify format strings, so that GCC can check the
2781 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2782 type function whose operands are a call to one of your own function.
2783 The compiler always treats @code{gettext}, @code{dgettext}, and
2784 @code{dcgettext} in this manner except when strict ISO C support is
2785 requested by @option{-ansi} or an appropriate @option{-std} option, or
2786 @option{-ffreestanding} or @option{-fno-builtin}
2787 is used.  @xref{C Dialect Options,,Options
2788 Controlling C Dialect}.
2790 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2791 @code{NSString} reference for compatibility with the @code{format} attribute
2792 above.
2794 The target may also allow additional types in @code{format-arg} attributes.
2795 @xref{Target Format Checks,,Format Checks Specific to Particular
2796 Target Machines}.
2798 @item gnu_inline
2799 @cindex @code{gnu_inline} function attribute
2800 This attribute should be used with a function that is also declared
2801 with the @code{inline} keyword.  It directs GCC to treat the function
2802 as if it were defined in gnu90 mode even when compiling in C99 or
2803 gnu99 mode.
2805 If the function is declared @code{extern}, then this definition of the
2806 function is used only for inlining.  In no case is the function
2807 compiled as a standalone function, not even if you take its address
2808 explicitly.  Such an address becomes an external reference, as if you
2809 had only declared the function, and had not defined it.  This has
2810 almost the effect of a macro.  The way to use this is to put a
2811 function definition in a header file with this attribute, and put
2812 another copy of the function, without @code{extern}, in a library
2813 file.  The definition in the header file causes most calls to the
2814 function to be inlined.  If any uses of the function remain, they
2815 refer to the single copy in the library.  Note that the two
2816 definitions of the functions need not be precisely the same, although
2817 if they do not have the same effect your program may behave oddly.
2819 In C, if the function is neither @code{extern} nor @code{static}, then
2820 the function is compiled as a standalone function, as well as being
2821 inlined where possible.
2823 This is how GCC traditionally handled functions declared
2824 @code{inline}.  Since ISO C99 specifies a different semantics for
2825 @code{inline}, this function attribute is provided as a transition
2826 measure and as a useful feature in its own right.  This attribute is
2827 available in GCC 4.1.3 and later.  It is available if either of the
2828 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2829 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2830 Function is As Fast As a Macro}.
2832 In C++, this attribute does not depend on @code{extern} in any way,
2833 but it still requires the @code{inline} keyword to enable its special
2834 behavior.
2836 @item hot
2837 @cindex @code{hot} function attribute
2838 The @code{hot} attribute on a function is used to inform the compiler that
2839 the function is a hot spot of the compiled program.  The function is
2840 optimized more aggressively and on many targets it is placed into a special
2841 subsection of the text section so all hot functions appear close together,
2842 improving locality.
2844 When profile feedback is available, via @option{-fprofile-use}, hot functions
2845 are automatically detected and this attribute is ignored.
2847 @item ifunc ("@var{resolver}")
2848 @cindex @code{ifunc} function attribute
2849 @cindex indirect functions
2850 @cindex functions that are dynamically resolved
2851 The @code{ifunc} attribute is used to mark a function as an indirect
2852 function using the STT_GNU_IFUNC symbol type extension to the ELF
2853 standard.  This allows the resolution of the symbol value to be
2854 determined dynamically at load time, and an optimized version of the
2855 routine to be selected for the particular processor or other system
2856 characteristics determined then.  To use this attribute, first define
2857 the implementation functions available, and a resolver function that
2858 returns a pointer to the selected implementation function.  The
2859 implementation functions' declarations must match the API of the
2860 function being implemented.  The resolver should be declared to
2861 be a function taking no arguments and returning a pointer to
2862 a function of the same type as the implementation.  For example:
2864 @smallexample
2865 void *my_memcpy (void *dst, const void *src, size_t len)
2867   @dots{}
2868   return dst;
2871 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2873   return my_memcpy; // we will just always select this routine
2875 @end smallexample
2877 @noindent
2878 The exported header file declaring the function the user calls would
2879 contain:
2881 @smallexample
2882 extern void *memcpy (void *, const void *, size_t);
2883 @end smallexample
2885 @noindent
2886 allowing the user to call @code{memcpy} as a regular function, unaware of
2887 the actual implementation.  Finally, the indirect function needs to be
2888 defined in the same translation unit as the resolver function:
2890 @smallexample
2891 void *memcpy (void *, const void *, size_t)
2892      __attribute__ ((ifunc ("resolve_memcpy")));
2893 @end smallexample
2895 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2896 of the resolver function.  A C++ resolver for a non-static member function
2897 of class @code{C} should be declared to return a pointer to a non-member
2898 function taking pointer to @code{C} as the first argument, followed by
2899 the same arguments as of the implementation function.  G++ checks
2900 the signatures of the two functions and issues
2901 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2902 for the necessary cast from a pointer to the implementation member function
2903 to the type of the corresponding non-member function use
2904 the @option{-Wno-pmf-conversions} option.  For example:
2906 @smallexample
2907 class S
2909 private:
2910   int debug_impl (int);
2911   int optimized_impl (int);
2913   typedef int Func (S*, int);
2915   static Func* resolver ();
2916 public:
2918   int interface (int);
2921 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2922 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2924 S::Func* S::resolver ()
2926   int (S::*pimpl) (int)
2927     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2929   // Cast triggers -Wno-pmf-conversions.
2930   return reinterpret_cast<Func*>(pimpl);
2933 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2934 @end smallexample
2936 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2937 and GNU C Library version 2.11.1 are required to use this feature.
2939 @item interrupt
2940 @itemx interrupt_handler
2941 Many GCC back ends support attributes to indicate that a function is
2942 an interrupt handler, which tells the compiler to generate function
2943 entry and exit sequences that differ from those from regular
2944 functions.  The exact syntax and behavior are target-specific;
2945 refer to the following subsections for details.
2947 @item leaf
2948 @cindex @code{leaf} function attribute
2949 Calls to external functions with this attribute must return to the
2950 current compilation unit only by return or by exception handling.  In
2951 particular, a leaf function is not allowed to invoke callback functions
2952 passed to it from the current compilation unit, directly call functions
2953 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2954 might still call functions from other compilation units and thus they
2955 are not necessarily leaf in the sense that they contain no function
2956 calls at all.
2958 The attribute is intended for library functions to improve dataflow
2959 analysis.  The compiler takes the hint that any data not escaping the
2960 current compilation unit cannot be used or modified by the leaf
2961 function.  For example, the @code{sin} function is a leaf function, but
2962 @code{qsort} is not.
2964 Note that leaf functions might indirectly run a signal handler defined
2965 in the current compilation unit that uses static variables.  Similarly,
2966 when lazy symbol resolution is in effect, leaf functions might invoke
2967 indirect functions whose resolver function or implementation function is
2968 defined in the current compilation unit and uses static variables.  There
2969 is no standard-compliant way to write such a signal handler, resolver
2970 function, or implementation function, and the best that you can do is to
2971 remove the @code{leaf} attribute or mark all such static variables
2972 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2973 interposition, care should be taken that functions defined in the
2974 current compilation unit do not unexpectedly interpose other symbols
2975 based on the defined standards mode and defined feature test macros;
2976 otherwise an inadvertent callback would be added.
2978 The attribute has no effect on functions defined within the current
2979 compilation unit.  This is to allow easy merging of multiple compilation
2980 units into one, for example, by using the link-time optimization.  For
2981 this reason the attribute is not allowed on types to annotate indirect
2982 calls.
2984 @item malloc
2985 @cindex @code{malloc} function attribute
2986 @cindex functions that behave like malloc
2987 This tells the compiler that a function is @code{malloc}-like, i.e.,
2988 that the pointer @var{P} returned by the function cannot alias any
2989 other pointer valid when the function returns, and moreover no
2990 pointers to valid objects occur in any storage addressed by @var{P}.
2992 Using this attribute can improve optimization.  Compiler predicts
2993 that a function with the attribute returns non-null in most cases.
2994 Functions like
2995 @code{malloc} and @code{calloc} have this property because they return
2996 a pointer to uninitialized or zeroed-out storage.  However, functions
2997 like @code{realloc} do not have this property, as they can return a
2998 pointer to storage containing pointers.
3000 @item no_icf
3001 @cindex @code{no_icf} function attribute
3002 This function attribute prevents a functions from being merged with another
3003 semantically equivalent function.
3005 @item no_instrument_function
3006 @cindex @code{no_instrument_function} function attribute
3007 @opindex finstrument-functions
3008 If @option{-finstrument-functions} is given, profiling function calls are
3009 generated at entry and exit of most user-compiled functions.
3010 Functions with this attribute are not so instrumented.
3012 @item no_profile_instrument_function
3013 @cindex @code{no_profile_instrument_function} function attribute
3014 The @code{no_profile_instrument_function} attribute on functions is used
3015 to inform the compiler that it should not process any profile feedback based
3016 optimization code instrumentation.
3018 @item no_reorder
3019 @cindex @code{no_reorder} function attribute
3020 Do not reorder functions or variables marked @code{no_reorder}
3021 against each other or top level assembler statements the executable.
3022 The actual order in the program will depend on the linker command
3023 line. Static variables marked like this are also not removed.
3024 This has a similar effect
3025 as the @option{-fno-toplevel-reorder} option, but only applies to the
3026 marked symbols.
3028 @item no_sanitize ("@var{sanitize_option}")
3029 @cindex @code{no_sanitize} function attribute
3030 The @code{no_sanitize} attribute on functions is used
3031 to inform the compiler that it should not do sanitization of all options
3032 mentioned in @var{sanitize_option}.  A list of values acceptable by
3033 @option{-fsanitize} option can be provided.
3035 @smallexample
3036 void __attribute__ ((no_sanitize ("alignment", "object-size")))
3037 f () @{ /* @r{Do something.} */; @}
3038 void __attribute__ ((no_sanitize ("alignment,object-size")))
3039 g () @{ /* @r{Do something.} */; @}
3040 @end smallexample
3042 @item no_sanitize_address
3043 @itemx no_address_safety_analysis
3044 @cindex @code{no_sanitize_address} function attribute
3045 The @code{no_sanitize_address} attribute on functions is used
3046 to inform the compiler that it should not instrument memory accesses
3047 in the function when compiling with the @option{-fsanitize=address} option.
3048 The @code{no_address_safety_analysis} is a deprecated alias of the
3049 @code{no_sanitize_address} attribute, new code should use
3050 @code{no_sanitize_address}.
3052 @item no_sanitize_thread
3053 @cindex @code{no_sanitize_thread} function attribute
3054 The @code{no_sanitize_thread} attribute on functions is used
3055 to inform the compiler that it should not instrument memory accesses
3056 in the function when compiling with the @option{-fsanitize=thread} option.
3058 @item no_sanitize_undefined
3059 @cindex @code{no_sanitize_undefined} function attribute
3060 The @code{no_sanitize_undefined} attribute on functions is used
3061 to inform the compiler that it should not check for undefined behavior
3062 in the function when compiling with the @option{-fsanitize=undefined} option.
3064 @item no_split_stack
3065 @cindex @code{no_split_stack} function attribute
3066 @opindex fsplit-stack
3067 If @option{-fsplit-stack} is given, functions have a small
3068 prologue which decides whether to split the stack.  Functions with the
3069 @code{no_split_stack} attribute do not have that prologue, and thus
3070 may run with only a small amount of stack space available.
3072 @item no_stack_limit
3073 @cindex @code{no_stack_limit} function attribute
3074 This attribute locally overrides the @option{-fstack-limit-register}
3075 and @option{-fstack-limit-symbol} command-line options; it has the effect
3076 of disabling stack limit checking in the function it applies to.
3078 @item noclone
3079 @cindex @code{noclone} function attribute
3080 This function attribute prevents a function from being considered for
3081 cloning---a mechanism that produces specialized copies of functions
3082 and which is (currently) performed by interprocedural constant
3083 propagation.
3085 @item noinline
3086 @cindex @code{noinline} function attribute
3087 This function attribute prevents a function from being considered for
3088 inlining.
3089 @c Don't enumerate the optimizations by name here; we try to be
3090 @c future-compatible with this mechanism.
3091 If the function does not have side effects, there are optimizations
3092 other than inlining that cause function calls to be optimized away,
3093 although the function call is live.  To keep such calls from being
3094 optimized away, put
3095 @smallexample
3096 asm ("");
3097 @end smallexample
3099 @noindent
3100 (@pxref{Extended Asm}) in the called function, to serve as a special
3101 side effect.
3103 @item noipa
3104 @cindex @code{noipa} function attribute
3105 Disable interprocedural optimizations between the function with this
3106 attribute and its callers, as if the body of the function is not available
3107 when optimizing callers and the callers are unavailable when optimizing
3108 the body.  This attribute implies @code{noinline}, @code{noclone} and
3109 @code{no_icf} attributes.    However, this attribute is not equivalent
3110 to a combination of other attributes, because its purpose is to suppress
3111 existing and future optimizations employing interprocedural analysis,
3112 including those that do not have an attribute suitable for disabling
3113 them individually.  This attribute is supported mainly for the purpose
3114 of testing the compiler.
3116 @item nonnull
3117 @itemx nonnull (@var{arg-index}, @dots{})
3118 @cindex @code{nonnull} function attribute
3119 @cindex functions with non-null pointer arguments
3120 The @code{nonnull} attribute specifies that some function parameters should
3121 be non-null pointers.  For instance, the declaration:
3123 @smallexample
3124 extern void *
3125 my_memcpy (void *dest, const void *src, size_t len)
3126         __attribute__((nonnull (1, 2)));
3127 @end smallexample
3129 @noindent
3130 causes the compiler to check that, in calls to @code{my_memcpy},
3131 arguments @var{dest} and @var{src} are non-null.  If the compiler
3132 determines that a null pointer is passed in an argument slot marked
3133 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3134 is issued.  @xref{Warning Options}.  Unless disabled by
3135 the @option{-fno-delete-null-pointer-checks} option the compiler may
3136 also perform optimizations based on the knowledge that certain function
3137 arguments cannot be null. In addition,
3138 the @option{-fisolate-erroneous-paths-attribute} option can be specified
3139 to have GCC transform calls with null arguments to non-null functions
3140 into traps. @xref{Optimize Options}.
3142 If no @var{arg-index} is given to the @code{nonnull} attribute,
3143 all pointer arguments are marked as non-null.  To illustrate, the
3144 following declaration is equivalent to the previous example:
3146 @smallexample
3147 extern void *
3148 my_memcpy (void *dest, const void *src, size_t len)
3149         __attribute__((nonnull));
3150 @end smallexample
3152 @item noplt
3153 @cindex @code{noplt} function attribute
3154 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3155 Calls to functions marked with this attribute in position-independent code
3156 do not use the PLT.
3158 @smallexample
3159 @group
3160 /* Externally defined function foo.  */
3161 int foo () __attribute__ ((noplt));
3164 main (/* @r{@dots{}} */)
3166   /* @r{@dots{}} */
3167   foo ();
3168   /* @r{@dots{}} */
3170 @end group
3171 @end smallexample
3173 The @code{noplt} attribute on function @code{foo}
3174 tells the compiler to assume that
3175 the function @code{foo} is externally defined and that the call to
3176 @code{foo} must avoid the PLT
3177 in position-independent code.
3179 In position-dependent code, a few targets also convert calls to
3180 functions that are marked to not use the PLT to use the GOT instead.
3182 @item noreturn
3183 @cindex @code{noreturn} function attribute
3184 @cindex functions that never return
3185 A few standard library functions, such as @code{abort} and @code{exit},
3186 cannot return.  GCC knows this automatically.  Some programs define
3187 their own functions that never return.  You can declare them
3188 @code{noreturn} to tell the compiler this fact.  For example,
3190 @smallexample
3191 @group
3192 void fatal () __attribute__ ((noreturn));
3194 void
3195 fatal (/* @r{@dots{}} */)
3197   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3198   exit (1);
3200 @end group
3201 @end smallexample
3203 The @code{noreturn} keyword tells the compiler to assume that
3204 @code{fatal} cannot return.  It can then optimize without regard to what
3205 would happen if @code{fatal} ever did return.  This makes slightly
3206 better code.  More importantly, it helps avoid spurious warnings of
3207 uninitialized variables.
3209 The @code{noreturn} keyword does not affect the exceptional path when that
3210 applies: a @code{noreturn}-marked function may still return to the caller
3211 by throwing an exception or calling @code{longjmp}.
3213 In order to preserve backtraces, GCC will never turn calls to
3214 @code{noreturn} functions into tail calls.
3216 Do not assume that registers saved by the calling function are
3217 restored before calling the @code{noreturn} function.
3219 It does not make sense for a @code{noreturn} function to have a return
3220 type other than @code{void}.
3222 @item nothrow
3223 @cindex @code{nothrow} function attribute
3224 The @code{nothrow} attribute is used to inform the compiler that a
3225 function cannot throw an exception.  For example, most functions in
3226 the standard C library can be guaranteed not to throw an exception
3227 with the notable exceptions of @code{qsort} and @code{bsearch} that
3228 take function pointer arguments.
3230 @item optimize (@var{level}, @dots{})
3231 @item optimize (@var{string}, @dots{})
3232 @cindex @code{optimize} function attribute
3233 The @code{optimize} attribute is used to specify that a function is to
3234 be compiled with different optimization options than specified on the
3235 command line.  Valid arguments are constant non-negative integers and
3236 strings.  Each numeric argument specifies an optimization @var{level}.
3237 Each @var{string} argument consists of one or more comma-separated
3238 substrings.  Each substring that begins with the letter @code{O} refers
3239 to an optimization option such as @option{-O0} or @option{-Os}.  Other
3240 substrings are taken as suffixes to the @code{-f} prefix jointly
3241 forming the name of an optimization option.  @xref{Optimize Options}.
3243 @samp{#pragma GCC optimize} can be used to set optimization options
3244 for more than one function.  @xref{Function Specific Option Pragmas},
3245 for details about the pragma.
3247 Providing multiple strings as arguments separated by commas to specify
3248 multiple options is equivalent to separating the option suffixes with
3249 a comma (@samp{,}) within a single string.  Spaces are not permitted
3250 within the strings.
3252 Not every optimization option that starts with the @var{-f} prefix
3253 specified by the attribute necessarily has an effect on the function.
3254 The @code{optimize} attribute should be used for debugging purposes only.
3255 It is not suitable in production code.
3257 @item patchable_function_entry
3258 @cindex @code{patchable_function_entry} function attribute
3259 @cindex extra NOP instructions at the function entry point
3260 In case the target's text segment can be made writable at run time by
3261 any means, padding the function entry with a number of NOPs can be
3262 used to provide a universal tool for instrumentation.
3264 The @code{patchable_function_entry} function attribute can be used to
3265 change the number of NOPs to any desired value.  The two-value syntax
3266 is the same as for the command-line switch
3267 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3268 the function entry point before the @var{M}th NOP instruction.
3269 @var{M} defaults to 0 if omitted e.g.@: function entry point is before
3270 the first NOP.
3272 If patchable function entries are enabled globally using the command-line
3273 option @option{-fpatchable-function-entry=N,M}, then you must disable
3274 instrumentation on all functions that are part of the instrumentation
3275 framework with the attribute @code{patchable_function_entry (0)}
3276 to prevent recursion.
3278 @item pure
3279 @cindex @code{pure} function attribute
3280 @cindex functions that have no side effects
3281 Many functions have no effects except the return value and their
3282 return value depends only on the parameters and/or global variables.
3283 Calls to such functions can be subject
3284 to common subexpression elimination and loop optimization just as an
3285 arithmetic operator would be.  These functions should be declared
3286 with the attribute @code{pure}.  For example,
3288 @smallexample
3289 int square (int) __attribute__ ((pure));
3290 @end smallexample
3292 @noindent
3293 says that the hypothetical function @code{square} is safe to call
3294 fewer times than the program says.
3296 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3297 Interesting non-pure functions are functions with infinite loops or those
3298 depending on volatile memory or other system resource, that may change between
3299 two consecutive calls (such as @code{feof} in a multithreading environment).
3301 The @code{pure} attribute imposes similar but looser restrictions on
3302 a function's defintion than the @code{const} attribute: it allows the
3303 function to read global variables.  Decorating the same function with
3304 both the @code{pure} and the @code{const} attribute is diagnosed.
3305 Because a @code{pure} function cannot have any side effects it does not
3306 make sense for such a function to return @code{void}.  Declaring such
3307 a function is diagnosed.
3309 @item returns_nonnull
3310 @cindex @code{returns_nonnull} function attribute
3311 The @code{returns_nonnull} attribute specifies that the function
3312 return value should be a non-null pointer.  For instance, the declaration:
3314 @smallexample
3315 extern void *
3316 mymalloc (size_t len) __attribute__((returns_nonnull));
3317 @end smallexample
3319 @noindent
3320 lets the compiler optimize callers based on the knowledge
3321 that the return value will never be null.
3323 @item returns_twice
3324 @cindex @code{returns_twice} function attribute
3325 @cindex functions that return more than once
3326 The @code{returns_twice} attribute tells the compiler that a function may
3327 return more than one time.  The compiler ensures that all registers
3328 are dead before calling such a function and emits a warning about
3329 the variables that may be clobbered after the second return from the
3330 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3331 The @code{longjmp}-like counterpart of such function, if any, might need
3332 to be marked with the @code{noreturn} attribute.
3334 @item section ("@var{section-name}")
3335 @cindex @code{section} function attribute
3336 @cindex functions in arbitrary sections
3337 Normally, the compiler places the code it generates in the @code{text} section.
3338 Sometimes, however, you need additional sections, or you need certain
3339 particular functions to appear in special sections.  The @code{section}
3340 attribute specifies that a function lives in a particular section.
3341 For example, the declaration:
3343 @smallexample
3344 extern void foobar (void) __attribute__ ((section ("bar")));
3345 @end smallexample
3347 @noindent
3348 puts the function @code{foobar} in the @code{bar} section.
3350 Some file formats do not support arbitrary sections so the @code{section}
3351 attribute is not available on all platforms.
3352 If you need to map the entire contents of a module to a particular
3353 section, consider using the facilities of the linker instead.
3355 @item sentinel
3356 @cindex @code{sentinel} function attribute
3357 This function attribute ensures that a parameter in a function call is
3358 an explicit @code{NULL}.  The attribute is only valid on variadic
3359 functions.  By default, the sentinel is located at position zero, the
3360 last parameter of the function call.  If an optional integer position
3361 argument P is supplied to the attribute, the sentinel must be located at
3362 position P counting backwards from the end of the argument list.
3364 @smallexample
3365 __attribute__ ((sentinel))
3366 is equivalent to
3367 __attribute__ ((sentinel(0)))
3368 @end smallexample
3370 The attribute is automatically set with a position of 0 for the built-in
3371 functions @code{execl} and @code{execlp}.  The built-in function
3372 @code{execle} has the attribute set with a position of 1.
3374 A valid @code{NULL} in this context is defined as zero with any pointer
3375 type.  If your system defines the @code{NULL} macro with an integer type
3376 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3377 with a copy that redefines NULL appropriately.
3379 The warnings for missing or incorrect sentinels are enabled with
3380 @option{-Wformat}.
3382 @item simd
3383 @itemx simd("@var{mask}")
3384 @cindex @code{simd} function attribute
3385 This attribute enables creation of one or more function versions that
3386 can process multiple arguments using SIMD instructions from a
3387 single invocation.  Specifying this attribute allows compiler to
3388 assume that such versions are available at link time (provided
3389 in the same or another translation unit).  Generated versions are
3390 target-dependent and described in the corresponding Vector ABI document.  For
3391 x86_64 target this document can be found
3392 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3394 The optional argument @var{mask} may have the value
3395 @code{notinbranch} or @code{inbranch},
3396 and instructs the compiler to generate non-masked or masked
3397 clones correspondingly. By default, all clones are generated.
3399 If the attribute is specified and @code{#pragma omp declare simd} is
3400 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3401 switch is specified, then the attribute is ignored.
3403 @item stack_protect
3404 @cindex @code{stack_protect} function attribute
3405 This attribute adds stack protection code to the function if 
3406 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3407 or @option{-fstack-protector-explicit} are set.
3409 @item target (@var{string}, @dots{})
3410 @cindex @code{target} function attribute
3411 Multiple target back ends implement the @code{target} attribute
3412 to specify that a function is to
3413 be compiled with different target options than specified on the
3414 command line.  One or more strings can be provided as arguments.
3415 Each string consists of one or more comma-separated suffixes to
3416 the @code{-m} prefix jointly forming the name of a machine-dependent
3417 option.  @xref{Submodel Options,,Machine-Dependent Options}.
3419 The @code{target} attribute can be used for instance to have a function
3420 compiled with a different ISA (instruction set architecture) than the
3421 default.  @samp{#pragma GCC target} can be used to specify target-specific
3422 options for more than one function.  @xref{Function Specific Option Pragmas},
3423 for details about the pragma.
3425 For instance, on an x86, you could declare one function with the
3426 @code{target("sse4.1,arch=core2")} attribute and another with
3427 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3428 compiling the first function with @option{-msse4.1} and
3429 @option{-march=core2} options, and the second function with
3430 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3431 to make sure that a function is only invoked on a machine that
3432 supports the particular ISA it is compiled for (for example by using
3433 @code{cpuid} on x86 to determine what feature bits and architecture
3434 family are used).
3436 @smallexample
3437 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3438 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3439 @end smallexample
3441 Providing multiple strings as arguments separated by commas to specify
3442 multiple options is equivalent to separating the option suffixes with
3443 a comma (@samp{,}) within a single string.  Spaces are not permitted
3444 within the strings.
3446 The options supported are specific to each target; refer to @ref{x86
3447 Function Attributes}, @ref{PowerPC Function Attributes},
3448 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3449 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3450 for details.
3452 @item target_clones (@var{options})
3453 @cindex @code{target_clones} function attribute
3454 The @code{target_clones} attribute is used to specify that a function
3455 be cloned into multiple versions compiled with different target options
3456 than specified on the command line.  The supported options and restrictions
3457 are the same as for @code{target} attribute.
3459 For instance, on an x86, you could compile a function with
3460 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3461 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3463 On a PowerPC, you can compile a function with
3464 @code{target_clones("cpu=power9,default")}.  GCC will create two
3465 function clones, one compiled with @option{-mcpu=power9} and another
3466 with the default options.  GCC must be configured to use GLIBC 2.23 or
3467 newer in order to use the @code{target_clones} attribute.
3469 It also creates a resolver function (see
3470 the @code{ifunc} attribute above) that dynamically selects a clone
3471 suitable for current architecture.  The resolver is created only if there
3472 is a usage of a function with @code{target_clones} attribute.
3474 @item unused
3475 @cindex @code{unused} function attribute
3476 This attribute, attached to a function, means that the function is meant
3477 to be possibly unused.  GCC does not produce a warning for this
3478 function.
3480 @item used
3481 @cindex @code{used} function attribute
3482 This attribute, attached to a function, means that code must be emitted
3483 for the function even if it appears that the function is not referenced.
3484 This is useful, for example, when the function is referenced only in
3485 inline assembly.
3487 When applied to a member function of a C++ class template, the
3488 attribute also means that the function is instantiated if the
3489 class itself is instantiated.
3491 @item visibility ("@var{visibility_type}")
3492 @cindex @code{visibility} function attribute
3493 This attribute affects the linkage of the declaration to which it is attached.
3494 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3495 (@pxref{Common Type Attributes}) as well as functions.
3497 There are four supported @var{visibility_type} values: default,
3498 hidden, protected or internal visibility.
3500 @smallexample
3501 void __attribute__ ((visibility ("protected")))
3502 f () @{ /* @r{Do something.} */; @}
3503 int i __attribute__ ((visibility ("hidden")));
3504 @end smallexample
3506 The possible values of @var{visibility_type} correspond to the
3507 visibility settings in the ELF gABI.
3509 @table @code
3510 @c keep this list of visibilities in alphabetical order.
3512 @item default
3513 Default visibility is the normal case for the object file format.
3514 This value is available for the visibility attribute to override other
3515 options that may change the assumed visibility of entities.
3517 On ELF, default visibility means that the declaration is visible to other
3518 modules and, in shared libraries, means that the declared entity may be
3519 overridden.
3521 On Darwin, default visibility means that the declaration is visible to
3522 other modules.
3524 Default visibility corresponds to ``external linkage'' in the language.
3526 @item hidden
3527 Hidden visibility indicates that the entity declared has a new
3528 form of linkage, which we call ``hidden linkage''.  Two
3529 declarations of an object with hidden linkage refer to the same object
3530 if they are in the same shared object.
3532 @item internal
3533 Internal visibility is like hidden visibility, but with additional
3534 processor specific semantics.  Unless otherwise specified by the
3535 psABI, GCC defines internal visibility to mean that a function is
3536 @emph{never} called from another module.  Compare this with hidden
3537 functions which, while they cannot be referenced directly by other
3538 modules, can be referenced indirectly via function pointers.  By
3539 indicating that a function cannot be called from outside the module,
3540 GCC may for instance omit the load of a PIC register since it is known
3541 that the calling function loaded the correct value.
3543 @item protected
3544 Protected visibility is like default visibility except that it
3545 indicates that references within the defining module bind to the
3546 definition in that module.  That is, the declared entity cannot be
3547 overridden by another module.
3549 @end table
3551 All visibilities are supported on many, but not all, ELF targets
3552 (supported when the assembler supports the @samp{.visibility}
3553 pseudo-op).  Default visibility is supported everywhere.  Hidden
3554 visibility is supported on Darwin targets.
3556 The visibility attribute should be applied only to declarations that
3557 would otherwise have external linkage.  The attribute should be applied
3558 consistently, so that the same entity should not be declared with
3559 different settings of the attribute.
3561 In C++, the visibility attribute applies to types as well as functions
3562 and objects, because in C++ types have linkage.  A class must not have
3563 greater visibility than its non-static data member types and bases,
3564 and class members default to the visibility of their class.  Also, a
3565 declaration without explicit visibility is limited to the visibility
3566 of its type.
3568 In C++, you can mark member functions and static member variables of a
3569 class with the visibility attribute.  This is useful if you know a
3570 particular method or static member variable should only be used from
3571 one shared object; then you can mark it hidden while the rest of the
3572 class has default visibility.  Care must be taken to avoid breaking
3573 the One Definition Rule; for example, it is usually not useful to mark
3574 an inline method as hidden without marking the whole class as hidden.
3576 A C++ namespace declaration can also have the visibility attribute.
3578 @smallexample
3579 namespace nspace1 __attribute__ ((visibility ("protected")))
3580 @{ /* @r{Do something.} */; @}
3581 @end smallexample
3583 This attribute applies only to the particular namespace body, not to
3584 other definitions of the same namespace; it is equivalent to using
3585 @samp{#pragma GCC visibility} before and after the namespace
3586 definition (@pxref{Visibility Pragmas}).
3588 In C++, if a template argument has limited visibility, this
3589 restriction is implicitly propagated to the template instantiation.
3590 Otherwise, template instantiations and specializations default to the
3591 visibility of their template.
3593 If both the template and enclosing class have explicit visibility, the
3594 visibility from the template is used.
3596 @item warn_unused_result
3597 @cindex @code{warn_unused_result} function attribute
3598 The @code{warn_unused_result} attribute causes a warning to be emitted
3599 if a caller of the function with this attribute does not use its
3600 return value.  This is useful for functions where not checking
3601 the result is either a security problem or always a bug, such as
3602 @code{realloc}.
3604 @smallexample
3605 int fn () __attribute__ ((warn_unused_result));
3606 int foo ()
3608   if (fn () < 0) return -1;
3609   fn ();
3610   return 0;
3612 @end smallexample
3614 @noindent
3615 results in warning on line 5.
3617 @item weak
3618 @cindex @code{weak} function attribute
3619 The @code{weak} attribute causes the declaration to be emitted as a weak
3620 symbol rather than a global.  This is primarily useful in defining
3621 library functions that can be overridden in user code, though it can
3622 also be used with non-function declarations.  Weak symbols are supported
3623 for ELF targets, and also for a.out targets when using the GNU assembler
3624 and linker.
3626 @item weakref
3627 @itemx weakref ("@var{target}")
3628 @cindex @code{weakref} function attribute
3629 The @code{weakref} attribute marks a declaration as a weak reference.
3630 Without arguments, it should be accompanied by an @code{alias} attribute
3631 naming the target symbol.  Optionally, the @var{target} may be given as
3632 an argument to @code{weakref} itself.  In either case, @code{weakref}
3633 implicitly marks the declaration as @code{weak}.  Without a
3634 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3635 @code{weakref} is equivalent to @code{weak}.
3637 @smallexample
3638 static int x() __attribute__ ((weakref ("y")));
3639 /* is equivalent to... */
3640 static int x() __attribute__ ((weak, weakref, alias ("y")));
3641 /* and to... */
3642 static int x() __attribute__ ((weakref));
3643 static int x() __attribute__ ((alias ("y")));
3644 @end smallexample
3646 A weak reference is an alias that does not by itself require a
3647 definition to be given for the target symbol.  If the target symbol is
3648 only referenced through weak references, then it becomes a @code{weak}
3649 undefined symbol.  If it is directly referenced, however, then such
3650 strong references prevail, and a definition is required for the
3651 symbol, not necessarily in the same translation unit.
3653 The effect is equivalent to moving all references to the alias to a
3654 separate translation unit, renaming the alias to the aliased symbol,
3655 declaring it as weak, compiling the two separate translation units and
3656 performing a reloadable link on them.
3658 At present, a declaration to which @code{weakref} is attached can
3659 only be @code{static}.
3662 @end table
3664 @c This is the end of the target-independent attribute table
3666 @node AArch64 Function Attributes
3667 @subsection AArch64 Function Attributes
3669 The following target-specific function attributes are available for the
3670 AArch64 target.  For the most part, these options mirror the behavior of
3671 similar command-line options (@pxref{AArch64 Options}), but on a
3672 per-function basis.
3674 @table @code
3675 @item general-regs-only
3676 @cindex @code{general-regs-only} function attribute, AArch64
3677 Indicates that no floating-point or Advanced SIMD registers should be
3678 used when generating code for this function.  If the function explicitly
3679 uses floating-point code, then the compiler gives an error.  This is
3680 the same behavior as that of the command-line option
3681 @option{-mgeneral-regs-only}.
3683 @item fix-cortex-a53-835769
3684 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3685 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3686 applied to this function.  To explicitly disable the workaround for this
3687 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3688 This corresponds to the behavior of the command line options
3689 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3691 @item cmodel=
3692 @cindex @code{cmodel=} function attribute, AArch64
3693 Indicates that code should be generated for a particular code model for
3694 this function.  The behavior and permissible arguments are the same as
3695 for the command line option @option{-mcmodel=}.
3697 @item strict-align
3698 @itemx no-strict-align
3699 @cindex @code{strict-align} function attribute, AArch64
3700 @code{strict-align} indicates that the compiler should not assume that unaligned
3701 memory references are handled by the system.  To allow the compiler to assume
3702 that aligned memory references are handled by the system, the inverse attribute
3703 @code{no-strict-align} can be specified.  The behavior is same as for the
3704 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3706 @item omit-leaf-frame-pointer
3707 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3708 Indicates that the frame pointer should be omitted for a leaf function call.
3709 To keep the frame pointer, the inverse attribute
3710 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3711 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3712 and @option{-mno-omit-leaf-frame-pointer}.
3714 @item tls-dialect=
3715 @cindex @code{tls-dialect=} function attribute, AArch64
3716 Specifies the TLS dialect to use for this function.  The behavior and
3717 permissible arguments are the same as for the command-line option
3718 @option{-mtls-dialect=}.
3720 @item arch=
3721 @cindex @code{arch=} function attribute, AArch64
3722 Specifies the architecture version and architectural extensions to use
3723 for this function.  The behavior and permissible arguments are the same as
3724 for the @option{-march=} command-line option.
3726 @item tune=
3727 @cindex @code{tune=} function attribute, AArch64
3728 Specifies the core for which to tune the performance of this function.
3729 The behavior and permissible arguments are the same as for the @option{-mtune=}
3730 command-line option.
3732 @item cpu=
3733 @cindex @code{cpu=} function attribute, AArch64
3734 Specifies the core for which to tune the performance of this function and also
3735 whose architectural features to use.  The behavior and valid arguments are the
3736 same as for the @option{-mcpu=} command-line option.
3738 @item sign-return-address
3739 @cindex @code{sign-return-address} function attribute, AArch64
3740 Select the function scope on which return address signing will be applied.  The
3741 behavior and permissible arguments are the same as for the command-line option
3742 @option{-msign-return-address=}.  The default value is @code{none}.
3744 @end table
3746 The above target attributes can be specified as follows:
3748 @smallexample
3749 __attribute__((target("@var{attr-string}")))
3751 f (int a)
3753   return a + 5;
3755 @end smallexample
3757 where @code{@var{attr-string}} is one of the attribute strings specified above.
3759 Additionally, the architectural extension string may be specified on its
3760 own.  This can be used to turn on and off particular architectural extensions
3761 without having to specify a particular architecture version or core.  Example:
3763 @smallexample
3764 __attribute__((target("+crc+nocrypto")))
3766 foo (int a)
3768   return a + 5;
3770 @end smallexample
3772 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3773 extension and disables the @code{crypto} extension for the function @code{foo}
3774 without modifying an existing @option{-march=} or @option{-mcpu} option.
3776 Multiple target function attributes can be specified by separating them with
3777 a comma.  For example:
3778 @smallexample
3779 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3781 foo (int a)
3783   return a + 5;
3785 @end smallexample
3787 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3788 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3790 @subsubsection Inlining rules
3791 Specifying target attributes on individual functions or performing link-time
3792 optimization across translation units compiled with different target options
3793 can affect function inlining rules:
3795 In particular, a caller function can inline a callee function only if the
3796 architectural features available to the callee are a subset of the features
3797 available to the caller.
3798 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3799 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3800 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3801 because the all the architectural features that function @code{bar} requires
3802 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3803 inline function @code{foo}.
3805 Additionally inlining a function compiled with @option{-mstrict-align} into a
3806 function compiled without @code{-mstrict-align} is not allowed.
3807 However, inlining a function compiled without @option{-mstrict-align} into a
3808 function compiled with @option{-mstrict-align} is allowed.
3810 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3811 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3812 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3813 architectural feature rules specified above.
3815 @node ARC Function Attributes
3816 @subsection ARC Function Attributes
3818 These function attributes are supported by the ARC back end:
3820 @table @code
3821 @item interrupt
3822 @cindex @code{interrupt} function attribute, ARC
3823 Use this attribute to indicate
3824 that the specified function is an interrupt handler.  The compiler generates
3825 function entry and exit sequences suitable for use in an interrupt handler
3826 when this attribute is present.
3828 On the ARC, you must specify the kind of interrupt to be handled
3829 in a parameter to the interrupt attribute like this:
3831 @smallexample
3832 void f () __attribute__ ((interrupt ("ilink1")));
3833 @end smallexample
3835 Permissible values for this parameter are: @w{@code{ilink1}} and
3836 @w{@code{ilink2}}.
3838 @item long_call
3839 @itemx medium_call
3840 @itemx short_call
3841 @cindex @code{long_call} function attribute, ARC
3842 @cindex @code{medium_call} function attribute, ARC
3843 @cindex @code{short_call} function attribute, ARC
3844 @cindex indirect calls, ARC
3845 These attributes specify how a particular function is called.
3846 These attributes override the
3847 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3848 command-line switches and @code{#pragma long_calls} settings.
3850 For ARC, a function marked with the @code{long_call} attribute is
3851 always called using register-indirect jump-and-link instructions,
3852 thereby enabling the called function to be placed anywhere within the
3853 32-bit address space.  A function marked with the @code{medium_call}
3854 attribute will always be close enough to be called with an unconditional
3855 branch-and-link instruction, which has a 25-bit offset from
3856 the call site.  A function marked with the @code{short_call}
3857 attribute will always be close enough to be called with a conditional
3858 branch-and-link instruction, which has a 21-bit offset from
3859 the call site.
3861 @item jli_always
3862 @cindex @code{jli_always} function attribute, ARC
3863 Forces a particular function to be called using @code{jli}
3864 instruction.  The @code{jli} instruction makes use of a table stored
3865 into @code{.jlitab} section, which holds the location of the functions
3866 which are addressed using this instruction.
3868 @item jli_fixed
3869 @cindex @code{jli_fixed} function attribute, ARC
3870 Identical like the above one, but the location of the function in the
3871 @code{jli} table is known and given as an attribute parameter.
3873 @item secure_call
3874 @cindex @code{secure_call} function attribute, ARC
3875 This attribute allows one to mark secure-code functions that are
3876 callable from normal mode.  The location of the secure call function
3877 into the @code{sjli} table needs to be passed as argument.
3879 @end table
3881 @node ARM Function Attributes
3882 @subsection ARM Function Attributes
3884 These function attributes are supported for ARM targets:
3886 @table @code
3887 @item interrupt
3888 @cindex @code{interrupt} function attribute, ARM
3889 Use this attribute to indicate
3890 that the specified function is an interrupt handler.  The compiler generates
3891 function entry and exit sequences suitable for use in an interrupt handler
3892 when this attribute is present.
3894 You can specify the kind of interrupt to be handled by
3895 adding an optional parameter to the interrupt attribute like this:
3897 @smallexample
3898 void f () __attribute__ ((interrupt ("IRQ")));
3899 @end smallexample
3901 @noindent
3902 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3903 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3905 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3906 may be called with a word-aligned stack pointer.
3908 @item isr
3909 @cindex @code{isr} function attribute, ARM
3910 Use this attribute on ARM to write Interrupt Service Routines. This is an
3911 alias to the @code{interrupt} attribute above.
3913 @item long_call
3914 @itemx short_call
3915 @cindex @code{long_call} function attribute, ARM
3916 @cindex @code{short_call} function attribute, ARM
3917 @cindex indirect calls, ARM
3918 These attributes specify how a particular function is called.
3919 These attributes override the
3920 @option{-mlong-calls} (@pxref{ARM Options})
3921 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3922 @code{long_call} attribute indicates that the function might be far
3923 away from the call site and require a different (more expensive)
3924 calling sequence.   The @code{short_call} attribute always places
3925 the offset to the function from the call site into the @samp{BL}
3926 instruction directly.
3928 @item naked
3929 @cindex @code{naked} function attribute, ARM
3930 This attribute allows the compiler to construct the
3931 requisite function declaration, while allowing the body of the
3932 function to be assembly code. The specified function will not have
3933 prologue/epilogue sequences generated by the compiler. Only basic
3934 @code{asm} statements can safely be included in naked functions
3935 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3936 basic @code{asm} and C code may appear to work, they cannot be
3937 depended upon to work reliably and are not supported.
3939 @item pcs
3940 @cindex @code{pcs} function attribute, ARM
3942 The @code{pcs} attribute can be used to control the calling convention
3943 used for a function on ARM.  The attribute takes an argument that specifies
3944 the calling convention to use.
3946 When compiling using the AAPCS ABI (or a variant of it) then valid
3947 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3948 order to use a variant other than @code{"aapcs"} then the compiler must
3949 be permitted to use the appropriate co-processor registers (i.e., the
3950 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3951 For example,
3953 @smallexample
3954 /* Argument passed in r0, and result returned in r0+r1.  */
3955 double f2d (float) __attribute__((pcs("aapcs")));
3956 @end smallexample
3958 Variadic functions always use the @code{"aapcs"} calling convention and
3959 the compiler rejects attempts to specify an alternative.
3961 @item target (@var{options})
3962 @cindex @code{target} function attribute
3963 As discussed in @ref{Common Function Attributes}, this attribute 
3964 allows specification of target-specific compilation options.
3966 On ARM, the following options are allowed:
3968 @table @samp
3969 @item thumb
3970 @cindex @code{target("thumb")} function attribute, ARM
3971 Force code generation in the Thumb (T16/T32) ISA, depending on the
3972 architecture level.
3974 @item arm
3975 @cindex @code{target("arm")} function attribute, ARM
3976 Force code generation in the ARM (A32) ISA.
3978 Functions from different modes can be inlined in the caller's mode.
3980 @item fpu=
3981 @cindex @code{target("fpu=")} function attribute, ARM
3982 Specifies the fpu for which to tune the performance of this function.
3983 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3984 command-line option.
3986 @item arch=
3987 @cindex @code{arch=} function attribute, ARM
3988 Specifies the architecture version and architectural extensions to use
3989 for this function.  The behavior and permissible arguments are the same as
3990 for the @option{-march=} command-line option.
3992 The above target attributes can be specified as follows:
3994 @smallexample
3995 __attribute__((target("arch=armv8-a+crc")))
3997 f (int a)
3999   return a + 5;
4001 @end smallexample
4003 Additionally, the architectural extension string may be specified on its
4004 own.  This can be used to turn on and off particular architectural extensions
4005 without having to specify a particular architecture version or core.  Example:
4007 @smallexample
4008 __attribute__((target("+crc+nocrypto")))
4010 foo (int a)
4012   return a + 5;
4014 @end smallexample
4016 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
4017 extension and disables the @code{crypto} extension for the function @code{foo}
4018 without modifying an existing @option{-march=} or @option{-mcpu} option.
4020 @end table
4022 @end table
4024 @node AVR Function Attributes
4025 @subsection AVR Function Attributes
4027 These function attributes are supported by the AVR back end:
4029 @table @code
4030 @item interrupt
4031 @cindex @code{interrupt} function attribute, AVR
4032 Use this attribute to indicate
4033 that the specified function is an interrupt handler.  The compiler generates
4034 function entry and exit sequences suitable for use in an interrupt handler
4035 when this attribute is present.
4037 On the AVR, the hardware globally disables interrupts when an
4038 interrupt is executed.  The first instruction of an interrupt handler
4039 declared with this attribute is a @code{SEI} instruction to
4040 re-enable interrupts.  See also the @code{signal} function attribute
4041 that does not insert a @code{SEI} instruction.  If both @code{signal} and
4042 @code{interrupt} are specified for the same function, @code{signal}
4043 is silently ignored.
4045 @item naked
4046 @cindex @code{naked} function attribute, AVR
4047 This attribute allows the compiler to construct the
4048 requisite function declaration, while allowing the body of the
4049 function to be assembly code. The specified function will not have
4050 prologue/epilogue sequences generated by the compiler. Only basic
4051 @code{asm} statements can safely be included in naked functions
4052 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4053 basic @code{asm} and C code may appear to work, they cannot be
4054 depended upon to work reliably and are not supported.
4056 @item no_gccisr
4057 @cindex @code{no_gccisr} function attribute, AVR
4058 Do not use @code{__gcc_isr} pseudo instructions in a function with
4059 the @code{interrupt} or @code{signal} attribute aka. interrupt
4060 service routine (ISR).
4061 Use this attribute if the preamble of the ISR prologue should always read
4062 @example
4063 push  __zero_reg__
4064 push  __tmp_reg__
4065 in    __tmp_reg__, __SREG__
4066 push  __tmp_reg__
4067 clr   __zero_reg__
4068 @end example
4069 and accordingly for the postamble of the epilogue --- no matter whether
4070 the mentioned registers are actually used in the ISR or not.
4071 Situations where you might want to use this attribute include:
4072 @itemize @bullet
4073 @item
4074 Code that (effectively) clobbers bits of @code{SREG} other than the
4075 @code{I}-flag by writing to the memory location of @code{SREG}.
4076 @item
4077 Code that uses inline assembler to jump to a different function which
4078 expects (parts of) the prologue code as outlined above to be present.
4079 @end itemize
4080 To disable @code{__gcc_isr} generation for the whole compilation unit,
4081 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4083 @item OS_main
4084 @itemx OS_task
4085 @cindex @code{OS_main} function attribute, AVR
4086 @cindex @code{OS_task} function attribute, AVR
4087 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4088 do not save/restore any call-saved register in their prologue/epilogue.
4090 The @code{OS_main} attribute can be used when there @emph{is
4091 guarantee} that interrupts are disabled at the time when the function
4092 is entered.  This saves resources when the stack pointer has to be
4093 changed to set up a frame for local variables.
4095 The @code{OS_task} attribute can be used when there is @emph{no
4096 guarantee} that interrupts are disabled at that time when the function
4097 is entered like for, e@.g@. task functions in a multi-threading operating
4098 system. In that case, changing the stack pointer register is
4099 guarded by save/clear/restore of the global interrupt enable flag.
4101 The differences to the @code{naked} function attribute are:
4102 @itemize @bullet
4103 @item @code{naked} functions do not have a return instruction whereas 
4104 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4105 @code{RETI} return instruction.
4106 @item @code{naked} functions do not set up a frame for local variables
4107 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4108 as needed.
4109 @end itemize
4111 @item signal
4112 @cindex @code{signal} function attribute, AVR
4113 Use this attribute on the AVR to indicate that the specified
4114 function is an interrupt handler.  The compiler generates function
4115 entry and exit sequences suitable for use in an interrupt handler when this
4116 attribute is present.
4118 See also the @code{interrupt} function attribute. 
4120 The AVR hardware globally disables interrupts when an interrupt is executed.
4121 Interrupt handler functions defined with the @code{signal} attribute
4122 do not re-enable interrupts.  It is save to enable interrupts in a
4123 @code{signal} handler.  This ``save'' only applies to the code
4124 generated by the compiler and not to the IRQ layout of the
4125 application which is responsibility of the application.
4127 If both @code{signal} and @code{interrupt} are specified for the same
4128 function, @code{signal} is silently ignored.
4129 @end table
4131 @node Blackfin Function Attributes
4132 @subsection Blackfin Function Attributes
4134 These function attributes are supported by the Blackfin back end:
4136 @table @code
4138 @item exception_handler
4139 @cindex @code{exception_handler} function attribute
4140 @cindex exception handler functions, Blackfin
4141 Use this attribute on the Blackfin to indicate that the specified function
4142 is an exception handler.  The compiler generates function entry and
4143 exit sequences suitable for use in an exception handler when this
4144 attribute is present.
4146 @item interrupt_handler
4147 @cindex @code{interrupt_handler} function attribute, Blackfin
4148 Use this attribute to
4149 indicate that the specified function is an interrupt handler.  The compiler
4150 generates function entry and exit sequences suitable for use in an
4151 interrupt handler when this attribute is present.
4153 @item kspisusp
4154 @cindex @code{kspisusp} function attribute, Blackfin
4155 @cindex User stack pointer in interrupts on the Blackfin
4156 When used together with @code{interrupt_handler}, @code{exception_handler}
4157 or @code{nmi_handler}, code is generated to load the stack pointer
4158 from the USP register in the function prologue.
4160 @item l1_text
4161 @cindex @code{l1_text} function attribute, Blackfin
4162 This attribute specifies a function to be placed into L1 Instruction
4163 SRAM@. The function is put into a specific section named @code{.l1.text}.
4164 With @option{-mfdpic}, function calls with a such function as the callee
4165 or caller uses inlined PLT.
4167 @item l2
4168 @cindex @code{l2} function attribute, Blackfin
4169 This attribute specifies a function to be placed into L2
4170 SRAM. The function is put into a specific section named
4171 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4172 an inlined PLT.
4174 @item longcall
4175 @itemx shortcall
4176 @cindex indirect calls, Blackfin
4177 @cindex @code{longcall} function attribute, Blackfin
4178 @cindex @code{shortcall} function attribute, Blackfin
4179 The @code{longcall} attribute
4180 indicates that the function might be far away from the call site and
4181 require a different (more expensive) calling sequence.  The
4182 @code{shortcall} attribute indicates that the function is always close
4183 enough for the shorter calling sequence to be used.  These attributes
4184 override the @option{-mlongcall} switch.
4186 @item nesting
4187 @cindex @code{nesting} function attribute, Blackfin
4188 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4189 Use this attribute together with @code{interrupt_handler},
4190 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4191 entry code should enable nested interrupts or exceptions.
4193 @item nmi_handler
4194 @cindex @code{nmi_handler} function attribute, Blackfin
4195 @cindex NMI handler functions on the Blackfin processor
4196 Use this attribute on the Blackfin to indicate that the specified function
4197 is an NMI handler.  The compiler generates function entry and
4198 exit sequences suitable for use in an NMI handler when this
4199 attribute is present.
4201 @item saveall
4202 @cindex @code{saveall} function attribute, Blackfin
4203 @cindex save all registers on the Blackfin
4204 Use this attribute to indicate that
4205 all registers except the stack pointer should be saved in the prologue
4206 regardless of whether they are used or not.
4207 @end table
4209 @node CR16 Function Attributes
4210 @subsection CR16 Function Attributes
4212 These function attributes are supported by the CR16 back end:
4214 @table @code
4215 @item interrupt
4216 @cindex @code{interrupt} function attribute, CR16
4217 Use this attribute to indicate
4218 that the specified function is an interrupt handler.  The compiler generates
4219 function entry and exit sequences suitable for use in an interrupt handler
4220 when this attribute is present.
4221 @end table
4223 @node C-SKY Function Attributes
4224 @subsection C-SKY Function Attributes
4226 These function attributes are supported by the C-SKY back end:
4228 @table @code
4229 @item interrupt
4230 @itemx isr
4231 @cindex @code{interrupt} function attribute, C-SKY
4232 @cindex @code{isr} function attribute, C-SKY
4233 Use these attributes to indicate that the specified function
4234 is an interrupt handler.
4235 The compiler generates function entry and exit sequences suitable for
4236 use in an interrupt handler when either of these attributes are present.
4238 Use of these options requires the @option{-mistack} command-line option
4239 to enable support for the necessary interrupt stack instructions.  They
4240 are ignored with a warning otherwise.  @xref{C-SKY Options}.
4242 @item naked
4243 @cindex @code{naked} function attribute, C-SKY
4244 This attribute allows the compiler to construct the
4245 requisite function declaration, while allowing the body of the
4246 function to be assembly code. The specified function will not have
4247 prologue/epilogue sequences generated by the compiler. Only basic
4248 @code{asm} statements can safely be included in naked functions
4249 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4250 basic @code{asm} and C code may appear to work, they cannot be
4251 depended upon to work reliably and are not supported.
4252 @end table
4255 @node Epiphany Function Attributes
4256 @subsection Epiphany Function Attributes
4258 These function attributes are supported by the Epiphany back end:
4260 @table @code
4261 @item disinterrupt
4262 @cindex @code{disinterrupt} function attribute, Epiphany
4263 This attribute causes the compiler to emit
4264 instructions to disable interrupts for the duration of the given
4265 function.
4267 @item forwarder_section
4268 @cindex @code{forwarder_section} function attribute, Epiphany
4269 This attribute modifies the behavior of an interrupt handler.
4270 The interrupt handler may be in external memory which cannot be
4271 reached by a branch instruction, so generate a local memory trampoline
4272 to transfer control.  The single parameter identifies the section where
4273 the trampoline is placed.
4275 @item interrupt
4276 @cindex @code{interrupt} function attribute, Epiphany
4277 Use this attribute to indicate
4278 that the specified function is an interrupt handler.  The compiler generates
4279 function entry and exit sequences suitable for use in an interrupt handler
4280 when this attribute is present.  It may also generate
4281 a special section with code to initialize the interrupt vector table.
4283 On Epiphany targets one or more optional parameters can be added like this:
4285 @smallexample
4286 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4287 @end smallexample
4289 Permissible values for these parameters are: @w{@code{reset}},
4290 @w{@code{software_exception}}, @w{@code{page_miss}},
4291 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4292 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4293 Multiple parameters indicate that multiple entries in the interrupt
4294 vector table should be initialized for this function, i.e.@: for each
4295 parameter @w{@var{name}}, a jump to the function is emitted in
4296 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4297 entirely, in which case no interrupt vector table entry is provided.
4299 Note that interrupts are enabled inside the function
4300 unless the @code{disinterrupt} attribute is also specified.
4302 The following examples are all valid uses of these attributes on
4303 Epiphany targets:
4304 @smallexample
4305 void __attribute__ ((interrupt)) universal_handler ();
4306 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4307 void __attribute__ ((interrupt ("dma0, dma1"))) 
4308   universal_dma_handler ();
4309 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4310   fast_timer_handler ();
4311 void __attribute__ ((interrupt ("dma0, dma1"), 
4312                      forwarder_section ("tramp")))
4313   external_dma_handler ();
4314 @end smallexample
4316 @item long_call
4317 @itemx short_call
4318 @cindex @code{long_call} function attribute, Epiphany
4319 @cindex @code{short_call} function attribute, Epiphany
4320 @cindex indirect calls, Epiphany
4321 These attributes specify how a particular function is called.
4322 These attributes override the
4323 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4324 command-line switch and @code{#pragma long_calls} settings.
4325 @end table
4328 @node H8/300 Function Attributes
4329 @subsection H8/300 Function Attributes
4331 These function attributes are available for H8/300 targets:
4333 @table @code
4334 @item function_vector
4335 @cindex @code{function_vector} function attribute, H8/300
4336 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4337 that the specified function should be called through the function vector.
4338 Calling a function through the function vector reduces code size; however,
4339 the function vector has a limited size (maximum 128 entries on the H8/300
4340 and 64 entries on the H8/300H and H8S)
4341 and shares space with the interrupt vector.
4343 @item interrupt_handler
4344 @cindex @code{interrupt_handler} function attribute, H8/300
4345 Use this attribute on the H8/300, H8/300H, and H8S to
4346 indicate that the specified function is an interrupt handler.  The compiler
4347 generates function entry and exit sequences suitable for use in an
4348 interrupt handler when this attribute is present.
4350 @item saveall
4351 @cindex @code{saveall} function attribute, H8/300
4352 @cindex save all registers on the H8/300, H8/300H, and H8S
4353 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4354 all registers except the stack pointer should be saved in the prologue
4355 regardless of whether they are used or not.
4356 @end table
4358 @node IA-64 Function Attributes
4359 @subsection IA-64 Function Attributes
4361 These function attributes are supported on IA-64 targets:
4363 @table @code
4364 @item syscall_linkage
4365 @cindex @code{syscall_linkage} function attribute, IA-64
4366 This attribute is used to modify the IA-64 calling convention by marking
4367 all input registers as live at all function exits.  This makes it possible
4368 to restart a system call after an interrupt without having to save/restore
4369 the input registers.  This also prevents kernel data from leaking into
4370 application code.
4372 @item version_id
4373 @cindex @code{version_id} function attribute, IA-64
4374 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4375 symbol to contain a version string, thus allowing for function level
4376 versioning.  HP-UX system header files may use function level versioning
4377 for some system calls.
4379 @smallexample
4380 extern int foo () __attribute__((version_id ("20040821")));
4381 @end smallexample
4383 @noindent
4384 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4385 @end table
4387 @node M32C Function Attributes
4388 @subsection M32C Function Attributes
4390 These function attributes are supported by the M32C back end:
4392 @table @code
4393 @item bank_switch
4394 @cindex @code{bank_switch} function attribute, M32C
4395 When added to an interrupt handler with the M32C port, causes the
4396 prologue and epilogue to use bank switching to preserve the registers
4397 rather than saving them on the stack.
4399 @item fast_interrupt
4400 @cindex @code{fast_interrupt} function attribute, M32C
4401 Use this attribute on the M32C port to indicate that the specified
4402 function is a fast interrupt handler.  This is just like the
4403 @code{interrupt} attribute, except that @code{freit} is used to return
4404 instead of @code{reit}.
4406 @item function_vector
4407 @cindex @code{function_vector} function attribute, M16C/M32C
4408 On M16C/M32C targets, the @code{function_vector} attribute declares a
4409 special page subroutine call function. Use of this attribute reduces
4410 the code size by 2 bytes for each call generated to the
4411 subroutine. The argument to the attribute is the vector number entry
4412 from the special page vector table which contains the 16 low-order
4413 bits of the subroutine's entry address. Each vector table has special
4414 page number (18 to 255) that is used in @code{jsrs} instructions.
4415 Jump addresses of the routines are generated by adding 0x0F0000 (in
4416 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4417 2-byte addresses set in the vector table. Therefore you need to ensure
4418 that all the special page vector routines should get mapped within the
4419 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4420 (for M32C).
4422 In the following example 2 bytes are saved for each call to
4423 function @code{foo}.
4425 @smallexample
4426 void foo (void) __attribute__((function_vector(0x18)));
4427 void foo (void)
4431 void bar (void)
4433     foo();
4435 @end smallexample
4437 If functions are defined in one file and are called in another file,
4438 then be sure to write this declaration in both files.
4440 This attribute is ignored for R8C target.
4442 @item interrupt
4443 @cindex @code{interrupt} function attribute, M32C
4444 Use this attribute to indicate
4445 that the specified function is an interrupt handler.  The compiler generates
4446 function entry and exit sequences suitable for use in an interrupt handler
4447 when this attribute is present.
4448 @end table
4450 @node M32R/D Function Attributes
4451 @subsection M32R/D Function Attributes
4453 These function attributes are supported by the M32R/D back end:
4455 @table @code
4456 @item interrupt
4457 @cindex @code{interrupt} function attribute, M32R/D
4458 Use this attribute to indicate
4459 that the specified function is an interrupt handler.  The compiler generates
4460 function entry and exit sequences suitable for use in an interrupt handler
4461 when this attribute is present.
4463 @item model (@var{model-name})
4464 @cindex @code{model} function attribute, M32R/D
4465 @cindex function addressability on the M32R/D
4467 On the M32R/D, use this attribute to set the addressability of an
4468 object, and of the code generated for a function.  The identifier
4469 @var{model-name} is one of @code{small}, @code{medium}, or
4470 @code{large}, representing each of the code models.
4472 Small model objects live in the lower 16MB of memory (so that their
4473 addresses can be loaded with the @code{ld24} instruction), and are
4474 callable with the @code{bl} instruction.
4476 Medium model objects may live anywhere in the 32-bit address space (the
4477 compiler generates @code{seth/add3} instructions to load their addresses),
4478 and are callable with the @code{bl} instruction.
4480 Large model objects may live anywhere in the 32-bit address space (the
4481 compiler generates @code{seth/add3} instructions to load their addresses),
4482 and may not be reachable with the @code{bl} instruction (the compiler
4483 generates the much slower @code{seth/add3/jl} instruction sequence).
4484 @end table
4486 @node m68k Function Attributes
4487 @subsection m68k Function Attributes
4489 These function attributes are supported by the m68k back end:
4491 @table @code
4492 @item interrupt
4493 @itemx interrupt_handler
4494 @cindex @code{interrupt} function attribute, m68k
4495 @cindex @code{interrupt_handler} function attribute, m68k
4496 Use this attribute to
4497 indicate that the specified function is an interrupt handler.  The compiler
4498 generates function entry and exit sequences suitable for use in an
4499 interrupt handler when this attribute is present.  Either name may be used.
4501 @item interrupt_thread
4502 @cindex @code{interrupt_thread} function attribute, fido
4503 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4504 that the specified function is an interrupt handler that is designed
4505 to run as a thread.  The compiler omits generate prologue/epilogue
4506 sequences and replaces the return instruction with a @code{sleep}
4507 instruction.  This attribute is available only on fido.
4508 @end table
4510 @node MCORE Function Attributes
4511 @subsection MCORE Function Attributes
4513 These function attributes are supported by the MCORE back end:
4515 @table @code
4516 @item naked
4517 @cindex @code{naked} function attribute, MCORE
4518 This attribute allows the compiler to construct the
4519 requisite function declaration, while allowing the body of the
4520 function to be assembly code. The specified function will not have
4521 prologue/epilogue sequences generated by the compiler. Only basic
4522 @code{asm} statements can safely be included in naked functions
4523 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4524 basic @code{asm} and C code may appear to work, they cannot be
4525 depended upon to work reliably and are not supported.
4526 @end table
4528 @node MeP Function Attributes
4529 @subsection MeP Function Attributes
4531 These function attributes are supported by the MeP back end:
4533 @table @code
4534 @item disinterrupt
4535 @cindex @code{disinterrupt} function attribute, MeP
4536 On MeP targets, this attribute causes the compiler to emit
4537 instructions to disable interrupts for the duration of the given
4538 function.
4540 @item interrupt
4541 @cindex @code{interrupt} function attribute, MeP
4542 Use this attribute to indicate
4543 that the specified function is an interrupt handler.  The compiler generates
4544 function entry and exit sequences suitable for use in an interrupt handler
4545 when this attribute is present.
4547 @item near
4548 @cindex @code{near} function attribute, MeP
4549 This attribute causes the compiler to assume the called
4550 function is close enough to use the normal calling convention,
4551 overriding the @option{-mtf} command-line option.
4553 @item far
4554 @cindex @code{far} function attribute, MeP
4555 On MeP targets this causes the compiler to use a calling convention
4556 that assumes the called function is too far away for the built-in
4557 addressing modes.
4559 @item vliw
4560 @cindex @code{vliw} function attribute, MeP
4561 The @code{vliw} attribute tells the compiler to emit
4562 instructions in VLIW mode instead of core mode.  Note that this
4563 attribute is not allowed unless a VLIW coprocessor has been configured
4564 and enabled through command-line options.
4565 @end table
4567 @node MicroBlaze Function Attributes
4568 @subsection MicroBlaze Function Attributes
4570 These function attributes are supported on MicroBlaze targets:
4572 @table @code
4573 @item save_volatiles
4574 @cindex @code{save_volatiles} function attribute, MicroBlaze
4575 Use this attribute to indicate that the function is
4576 an interrupt handler.  All volatile registers (in addition to non-volatile
4577 registers) are saved in the function prologue.  If the function is a leaf
4578 function, only volatiles used by the function are saved.  A normal function
4579 return is generated instead of a return from interrupt.
4581 @item break_handler
4582 @cindex @code{break_handler} function attribute, MicroBlaze
4583 @cindex break handler functions
4584 Use this attribute to indicate that
4585 the specified function is a break handler.  The compiler generates function
4586 entry and exit sequences suitable for use in an break handler when this
4587 attribute is present. The return from @code{break_handler} is done through
4588 the @code{rtbd} instead of @code{rtsd}.
4590 @smallexample
4591 void f () __attribute__ ((break_handler));
4592 @end smallexample
4594 @item interrupt_handler
4595 @itemx fast_interrupt 
4596 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4597 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4598 These attributes indicate that the specified function is an interrupt
4599 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4600 used in low-latency interrupt mode, and @code{interrupt_handler} for
4601 interrupts that do not use low-latency handlers.  In both cases, GCC
4602 emits appropriate prologue code and generates a return from the handler
4603 using @code{rtid} instead of @code{rtsd}.
4604 @end table
4606 @node Microsoft Windows Function Attributes
4607 @subsection Microsoft Windows Function Attributes
4609 The following attributes are available on Microsoft Windows and Symbian OS
4610 targets.
4612 @table @code
4613 @item dllexport
4614 @cindex @code{dllexport} function attribute
4615 @cindex @code{__declspec(dllexport)}
4616 On Microsoft Windows targets and Symbian OS targets the
4617 @code{dllexport} attribute causes the compiler to provide a global
4618 pointer to a pointer in a DLL, so that it can be referenced with the
4619 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4620 name is formed by combining @code{_imp__} and the function or variable
4621 name.
4623 You can use @code{__declspec(dllexport)} as a synonym for
4624 @code{__attribute__ ((dllexport))} for compatibility with other
4625 compilers.
4627 On systems that support the @code{visibility} attribute, this
4628 attribute also implies ``default'' visibility.  It is an error to
4629 explicitly specify any other visibility.
4631 GCC's default behavior is to emit all inline functions with the
4632 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4633 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4634 ignore the attribute for inlined functions unless the 
4635 @option{-fkeep-inline-functions} flag is used instead.
4637 The attribute is ignored for undefined symbols.
4639 When applied to C++ classes, the attribute marks defined non-inlined
4640 member functions and static data members as exports.  Static consts
4641 initialized in-class are not marked unless they are also defined
4642 out-of-class.
4644 For Microsoft Windows targets there are alternative methods for
4645 including the symbol in the DLL's export table such as using a
4646 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4647 the @option{--export-all} linker flag.
4649 @item dllimport
4650 @cindex @code{dllimport} function attribute
4651 @cindex @code{__declspec(dllimport)}
4652 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4653 attribute causes the compiler to reference a function or variable via
4654 a global pointer to a pointer that is set up by the DLL exporting the
4655 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4656 targets, the pointer name is formed by combining @code{_imp__} and the
4657 function or variable name.
4659 You can use @code{__declspec(dllimport)} as a synonym for
4660 @code{__attribute__ ((dllimport))} for compatibility with other
4661 compilers.
4663 On systems that support the @code{visibility} attribute, this
4664 attribute also implies ``default'' visibility.  It is an error to
4665 explicitly specify any other visibility.
4667 Currently, the attribute is ignored for inlined functions.  If the
4668 attribute is applied to a symbol @emph{definition}, an error is reported.
4669 If a symbol previously declared @code{dllimport} is later defined, the
4670 attribute is ignored in subsequent references, and a warning is emitted.
4671 The attribute is also overridden by a subsequent declaration as
4672 @code{dllexport}.
4674 When applied to C++ classes, the attribute marks non-inlined
4675 member functions and static data members as imports.  However, the
4676 attribute is ignored for virtual methods to allow creation of vtables
4677 using thunks.
4679 On the SH Symbian OS target the @code{dllimport} attribute also has
4680 another affect---it can cause the vtable and run-time type information
4681 for a class to be exported.  This happens when the class has a
4682 dllimported constructor or a non-inline, non-pure virtual function
4683 and, for either of those two conditions, the class also has an inline
4684 constructor or destructor and has a key function that is defined in
4685 the current translation unit.
4687 For Microsoft Windows targets the use of the @code{dllimport}
4688 attribute on functions is not necessary, but provides a small
4689 performance benefit by eliminating a thunk in the DLL@.  The use of the
4690 @code{dllimport} attribute on imported variables can be avoided by passing the
4691 @option{--enable-auto-import} switch to the GNU linker.  As with
4692 functions, using the attribute for a variable eliminates a thunk in
4693 the DLL@.
4695 One drawback to using this attribute is that a pointer to a
4696 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4697 address. However, a pointer to a @emph{function} with the
4698 @code{dllimport} attribute can be used as a constant initializer; in
4699 this case, the address of a stub function in the import lib is
4700 referenced.  On Microsoft Windows targets, the attribute can be disabled
4701 for functions by setting the @option{-mnop-fun-dllimport} flag.
4702 @end table
4704 @node MIPS Function Attributes
4705 @subsection MIPS Function Attributes
4707 These function attributes are supported by the MIPS back end:
4709 @table @code
4710 @item interrupt
4711 @cindex @code{interrupt} function attribute, MIPS
4712 Use this attribute to indicate that the specified function is an interrupt
4713 handler.  The compiler generates function entry and exit sequences suitable
4714 for use in an interrupt handler when this attribute is present.
4715 An optional argument is supported for the interrupt attribute which allows
4716 the interrupt mode to be described.  By default GCC assumes the external
4717 interrupt controller (EIC) mode is in use, this can be explicitly set using
4718 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4719 Priority Level (IPL) is copied to the current IPL which has the effect of only
4720 enabling higher priority interrupts.  To use vectored interrupt mode use
4721 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4722 the behavior of the non-masked interrupt support and GCC will arrange to mask
4723 all interrupts from sw0 up to and including the specified interrupt vector.
4725 You can use the following attributes to modify the behavior
4726 of an interrupt handler:
4727 @table @code
4728 @item use_shadow_register_set
4729 @cindex @code{use_shadow_register_set} function attribute, MIPS
4730 Assume that the handler uses a shadow register set, instead of
4731 the main general-purpose registers.  An optional argument @code{intstack} is
4732 supported to indicate that the shadow register set contains a valid stack
4733 pointer.
4735 @item keep_interrupts_masked
4736 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4737 Keep interrupts masked for the whole function.  Without this attribute,
4738 GCC tries to reenable interrupts for as much of the function as it can.
4740 @item use_debug_exception_return
4741 @cindex @code{use_debug_exception_return} function attribute, MIPS
4742 Return using the @code{deret} instruction.  Interrupt handlers that don't
4743 have this attribute return using @code{eret} instead.
4744 @end table
4746 You can use any combination of these attributes, as shown below:
4747 @smallexample
4748 void __attribute__ ((interrupt)) v0 ();
4749 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4750 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4751 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4752 void __attribute__ ((interrupt, use_shadow_register_set,
4753                      keep_interrupts_masked)) v4 ();
4754 void __attribute__ ((interrupt, use_shadow_register_set,
4755                      use_debug_exception_return)) v5 ();
4756 void __attribute__ ((interrupt, keep_interrupts_masked,
4757                      use_debug_exception_return)) v6 ();
4758 void __attribute__ ((interrupt, use_shadow_register_set,
4759                      keep_interrupts_masked,
4760                      use_debug_exception_return)) v7 ();
4761 void __attribute__ ((interrupt("eic"))) v8 ();
4762 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4763 @end smallexample
4765 @item long_call
4766 @itemx short_call
4767 @itemx near
4768 @itemx far
4769 @cindex indirect calls, MIPS
4770 @cindex @code{long_call} function attribute, MIPS
4771 @cindex @code{short_call} function attribute, MIPS
4772 @cindex @code{near} function attribute, MIPS
4773 @cindex @code{far} function attribute, MIPS
4774 These attributes specify how a particular function is called on MIPS@.
4775 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4776 command-line switch.  The @code{long_call} and @code{far} attributes are
4777 synonyms, and cause the compiler to always call
4778 the function by first loading its address into a register, and then using
4779 the contents of that register.  The @code{short_call} and @code{near}
4780 attributes are synonyms, and have the opposite
4781 effect; they specify that non-PIC calls should be made using the more
4782 efficient @code{jal} instruction.
4784 @item mips16
4785 @itemx nomips16
4786 @cindex @code{mips16} function attribute, MIPS
4787 @cindex @code{nomips16} function attribute, MIPS
4789 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4790 function attributes to locally select or turn off MIPS16 code generation.
4791 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4792 while MIPS16 code generation is disabled for functions with the
4793 @code{nomips16} attribute.  These attributes override the
4794 @option{-mips16} and @option{-mno-mips16} options on the command line
4795 (@pxref{MIPS Options}).
4797 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4798 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4799 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4800 may interact badly with some GCC extensions such as @code{__builtin_apply}
4801 (@pxref{Constructing Calls}).
4803 @item micromips, MIPS
4804 @itemx nomicromips, MIPS
4805 @cindex @code{micromips} function attribute
4806 @cindex @code{nomicromips} function attribute
4808 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4809 function attributes to locally select or turn off microMIPS code generation.
4810 A function with the @code{micromips} attribute is emitted as microMIPS code,
4811 while microMIPS code generation is disabled for functions with the
4812 @code{nomicromips} attribute.  These attributes override the
4813 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4814 (@pxref{MIPS Options}).
4816 When compiling files containing mixed microMIPS and non-microMIPS code, the
4817 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4818 command line,
4819 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4820 may interact badly with some GCC extensions such as @code{__builtin_apply}
4821 (@pxref{Constructing Calls}).
4823 @item nocompression
4824 @cindex @code{nocompression} function attribute, MIPS
4825 On MIPS targets, you can use the @code{nocompression} function attribute
4826 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4827 overrides the @option{-mips16} and @option{-mmicromips} options on the
4828 command line (@pxref{MIPS Options}).
4829 @end table
4831 @node MSP430 Function Attributes
4832 @subsection MSP430 Function Attributes
4834 These function attributes are supported by the MSP430 back end:
4836 @table @code
4837 @item critical
4838 @cindex @code{critical} function attribute, MSP430
4839 Critical functions disable interrupts upon entry and restore the
4840 previous interrupt state upon exit.  Critical functions cannot also
4841 have the @code{naked} or @code{reentrant} attributes.  They can have
4842 the @code{interrupt} attribute.
4844 @item interrupt
4845 @cindex @code{interrupt} function attribute, MSP430
4846 Use this attribute to indicate
4847 that the specified function is an interrupt handler.  The compiler generates
4848 function entry and exit sequences suitable for use in an interrupt handler
4849 when this attribute is present.
4851 You can provide an argument to the interrupt
4852 attribute which specifies a name or number.  If the argument is a
4853 number it indicates the slot in the interrupt vector table (0 - 31) to
4854 which this handler should be assigned.  If the argument is a name it
4855 is treated as a symbolic name for the vector slot.  These names should
4856 match up with appropriate entries in the linker script.  By default
4857 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4858 @code{reset} for vector 31 are recognized.
4860 @item naked
4861 @cindex @code{naked} function attribute, MSP430
4862 This attribute allows the compiler to construct the
4863 requisite function declaration, while allowing the body of the
4864 function to be assembly code. The specified function will not have
4865 prologue/epilogue sequences generated by the compiler. Only basic
4866 @code{asm} statements can safely be included in naked functions
4867 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4868 basic @code{asm} and C code may appear to work, they cannot be
4869 depended upon to work reliably and are not supported.
4871 @item reentrant
4872 @cindex @code{reentrant} function attribute, MSP430
4873 Reentrant functions disable interrupts upon entry and enable them
4874 upon exit.  Reentrant functions cannot also have the @code{naked}
4875 or @code{critical} attributes.  They can have the @code{interrupt}
4876 attribute.
4878 @item wakeup
4879 @cindex @code{wakeup} function attribute, MSP430
4880 This attribute only applies to interrupt functions.  It is silently
4881 ignored if applied to a non-interrupt function.  A wakeup interrupt
4882 function will rouse the processor from any low-power state that it
4883 might be in when the function exits.
4885 @item lower
4886 @itemx upper
4887 @itemx either
4888 @cindex @code{lower} function attribute, MSP430
4889 @cindex @code{upper} function attribute, MSP430
4890 @cindex @code{either} function attribute, MSP430
4891 On the MSP430 target these attributes can be used to specify whether
4892 the function or variable should be placed into low memory, high
4893 memory, or the placement should be left to the linker to decide.  The
4894 attributes are only significant if compiling for the MSP430X
4895 architecture.
4897 The attributes work in conjunction with a linker script that has been
4898 augmented to specify where to place sections with a @code{.lower} and
4899 a @code{.upper} prefix.  So, for example, as well as placing the
4900 @code{.data} section, the script also specifies the placement of a
4901 @code{.lower.data} and a @code{.upper.data} section.  The intention
4902 is that @code{lower} sections are placed into a small but easier to
4903 access memory region and the upper sections are placed into a larger, but
4904 slower to access, region.
4906 The @code{either} attribute is special.  It tells the linker to place
4907 the object into the corresponding @code{lower} section if there is
4908 room for it.  If there is insufficient room then the object is placed
4909 into the corresponding @code{upper} section instead.  Note that the
4910 placement algorithm is not very sophisticated.  It does not attempt to
4911 find an optimal packing of the @code{lower} sections.  It just makes
4912 one pass over the objects and does the best that it can.  Using the
4913 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4914 options can help the packing, however, since they produce smaller,
4915 easier to pack regions.
4916 @end table
4918 @node NDS32 Function Attributes
4919 @subsection NDS32 Function Attributes
4921 These function attributes are supported by the NDS32 back end:
4923 @table @code
4924 @item exception
4925 @cindex @code{exception} function attribute
4926 @cindex exception handler functions, NDS32
4927 Use this attribute on the NDS32 target to indicate that the specified function
4928 is an exception handler.  The compiler will generate corresponding sections
4929 for use in an exception handler.
4931 @item interrupt
4932 @cindex @code{interrupt} function attribute, NDS32
4933 On NDS32 target, this attribute indicates that the specified function
4934 is an interrupt handler.  The compiler generates corresponding sections
4935 for use in an interrupt handler.  You can use the following attributes
4936 to modify the behavior:
4937 @table @code
4938 @item nested
4939 @cindex @code{nested} function attribute, NDS32
4940 This interrupt service routine is interruptible.
4941 @item not_nested
4942 @cindex @code{not_nested} function attribute, NDS32
4943 This interrupt service routine is not interruptible.
4944 @item nested_ready
4945 @cindex @code{nested_ready} function attribute, NDS32
4946 This interrupt service routine is interruptible after @code{PSW.GIE}
4947 (global interrupt enable) is set.  This allows interrupt service routine to
4948 finish some short critical code before enabling interrupts.
4949 @item save_all
4950 @cindex @code{save_all} function attribute, NDS32
4951 The system will help save all registers into stack before entering
4952 interrupt handler.
4953 @item partial_save
4954 @cindex @code{partial_save} function attribute, NDS32
4955 The system will help save caller registers into stack before entering
4956 interrupt handler.
4957 @end table
4959 @item naked
4960 @cindex @code{naked} function attribute, NDS32
4961 This attribute allows the compiler to construct the
4962 requisite function declaration, while allowing the body of the
4963 function to be assembly code. The specified function will not have
4964 prologue/epilogue sequences generated by the compiler. Only basic
4965 @code{asm} statements can safely be included in naked functions
4966 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4967 basic @code{asm} and C code may appear to work, they cannot be
4968 depended upon to work reliably and are not supported.
4970 @item reset
4971 @cindex @code{reset} function attribute, NDS32
4972 @cindex reset handler functions
4973 Use this attribute on the NDS32 target to indicate that the specified function
4974 is a reset handler.  The compiler will generate corresponding sections
4975 for use in a reset handler.  You can use the following attributes
4976 to provide extra exception handling:
4977 @table @code
4978 @item nmi
4979 @cindex @code{nmi} function attribute, NDS32
4980 Provide a user-defined function to handle NMI exception.
4981 @item warm
4982 @cindex @code{warm} function attribute, NDS32
4983 Provide a user-defined function to handle warm reset exception.
4984 @end table
4985 @end table
4987 @node Nios II Function Attributes
4988 @subsection Nios II Function Attributes
4990 These function attributes are supported by the Nios II back end:
4992 @table @code
4993 @item target (@var{options})
4994 @cindex @code{target} function attribute
4995 As discussed in @ref{Common Function Attributes}, this attribute 
4996 allows specification of target-specific compilation options.
4998 When compiling for Nios II, the following options are allowed:
5000 @table @samp
5001 @item custom-@var{insn}=@var{N}
5002 @itemx no-custom-@var{insn}
5003 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
5004 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
5005 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
5006 custom instruction with encoding @var{N} when generating code that uses 
5007 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
5008 the custom instruction @var{insn}.
5009 These target attributes correspond to the
5010 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
5011 command-line options, and support the same set of @var{insn} keywords.
5012 @xref{Nios II Options}, for more information.
5014 @item custom-fpu-cfg=@var{name}
5015 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
5016 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
5017 command-line option, to select a predefined set of custom instructions
5018 named @var{name}.
5019 @xref{Nios II Options}, for more information.
5020 @end table
5021 @end table
5023 @node Nvidia PTX Function Attributes
5024 @subsection Nvidia PTX Function Attributes
5026 These function attributes are supported by the Nvidia PTX back end:
5028 @table @code
5029 @item kernel
5030 @cindex @code{kernel} attribute, Nvidia PTX
5031 This attribute indicates that the corresponding function should be compiled
5032 as a kernel function, which can be invoked from the host via the CUDA RT 
5033 library.
5034 By default functions are only callable only from other PTX functions.
5036 Kernel functions must have @code{void} return type.
5037 @end table
5039 @node PowerPC Function Attributes
5040 @subsection PowerPC Function Attributes
5042 These function attributes are supported by the PowerPC back end:
5044 @table @code
5045 @item longcall
5046 @itemx shortcall
5047 @cindex indirect calls, PowerPC
5048 @cindex @code{longcall} function attribute, PowerPC
5049 @cindex @code{shortcall} function attribute, PowerPC
5050 The @code{longcall} attribute
5051 indicates that the function might be far away from the call site and
5052 require a different (more expensive) calling sequence.  The
5053 @code{shortcall} attribute indicates that the function is always close
5054 enough for the shorter calling sequence to be used.  These attributes
5055 override both the @option{-mlongcall} switch and
5056 the @code{#pragma longcall} setting.
5058 @xref{RS/6000 and PowerPC Options}, for more information on whether long
5059 calls are necessary.
5061 @item target (@var{options})
5062 @cindex @code{target} function attribute
5063 As discussed in @ref{Common Function Attributes}, this attribute 
5064 allows specification of target-specific compilation options.
5066 On the PowerPC, the following options are allowed:
5068 @table @samp
5069 @item altivec
5070 @itemx no-altivec
5071 @cindex @code{target("altivec")} function attribute, PowerPC
5072 Generate code that uses (does not use) AltiVec instructions.  In
5073 32-bit code, you cannot enable AltiVec instructions unless
5074 @option{-mabi=altivec} is used on the command line.
5076 @item cmpb
5077 @itemx no-cmpb
5078 @cindex @code{target("cmpb")} function attribute, PowerPC
5079 Generate code that uses (does not use) the compare bytes instruction
5080 implemented on the POWER6 processor and other processors that support
5081 the PowerPC V2.05 architecture.
5083 @item dlmzb
5084 @itemx no-dlmzb
5085 @cindex @code{target("dlmzb")} function attribute, PowerPC
5086 Generate code that uses (does not use) the string-search @samp{dlmzb}
5087 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
5088 generated by default when targeting those processors.
5090 @item fprnd
5091 @itemx no-fprnd
5092 @cindex @code{target("fprnd")} function attribute, PowerPC
5093 Generate code that uses (does not use) the FP round to integer
5094 instructions implemented on the POWER5+ processor and other processors
5095 that support the PowerPC V2.03 architecture.
5097 @item hard-dfp
5098 @itemx no-hard-dfp
5099 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5100 Generate code that uses (does not use) the decimal floating-point
5101 instructions implemented on some POWER processors.
5103 @item isel
5104 @itemx no-isel
5105 @cindex @code{target("isel")} function attribute, PowerPC
5106 Generate code that uses (does not use) ISEL instruction.
5108 @item mfcrf
5109 @itemx no-mfcrf
5110 @cindex @code{target("mfcrf")} function attribute, PowerPC
5111 Generate code that uses (does not use) the move from condition
5112 register field instruction implemented on the POWER4 processor and
5113 other processors that support the PowerPC V2.01 architecture.
5115 @item mfpgpr
5116 @itemx no-mfpgpr
5117 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5118 Generate code that uses (does not use) the FP move to/from general
5119 purpose register instructions implemented on the POWER6X processor and
5120 other processors that support the extended PowerPC V2.05 architecture.
5122 @item mulhw
5123 @itemx no-mulhw
5124 @cindex @code{target("mulhw")} function attribute, PowerPC
5125 Generate code that uses (does not use) the half-word multiply and
5126 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5127 These instructions are generated by default when targeting those
5128 processors.
5130 @item multiple
5131 @itemx no-multiple
5132 @cindex @code{target("multiple")} function attribute, PowerPC
5133 Generate code that uses (does not use) the load multiple word
5134 instructions and the store multiple word instructions.
5136 @item update
5137 @itemx no-update
5138 @cindex @code{target("update")} function attribute, PowerPC
5139 Generate code that uses (does not use) the load or store instructions
5140 that update the base register to the address of the calculated memory
5141 location.
5143 @item popcntb
5144 @itemx no-popcntb
5145 @cindex @code{target("popcntb")} function attribute, PowerPC
5146 Generate code that uses (does not use) the popcount and double-precision
5147 FP reciprocal estimate instruction implemented on the POWER5
5148 processor and other processors that support the PowerPC V2.02
5149 architecture.
5151 @item popcntd
5152 @itemx no-popcntd
5153 @cindex @code{target("popcntd")} function attribute, PowerPC
5154 Generate code that uses (does not use) the popcount instruction
5155 implemented on the POWER7 processor and other processors that support
5156 the PowerPC V2.06 architecture.
5158 @item powerpc-gfxopt
5159 @itemx no-powerpc-gfxopt
5160 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5161 Generate code that uses (does not use) the optional PowerPC
5162 architecture instructions in the Graphics group, including
5163 floating-point select.
5165 @item powerpc-gpopt
5166 @itemx no-powerpc-gpopt
5167 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5168 Generate code that uses (does not use) the optional PowerPC
5169 architecture instructions in the General Purpose group, including
5170 floating-point square root.
5172 @item recip-precision
5173 @itemx no-recip-precision
5174 @cindex @code{target("recip-precision")} function attribute, PowerPC
5175 Assume (do not assume) that the reciprocal estimate instructions
5176 provide higher-precision estimates than is mandated by the PowerPC
5177 ABI.
5179 @item string
5180 @itemx no-string
5181 @cindex @code{target("string")} function attribute, PowerPC
5182 Generate code that uses (does not use) the load string instructions
5183 and the store string word instructions to save multiple registers and
5184 do small block moves.
5186 @item vsx
5187 @itemx no-vsx
5188 @cindex @code{target("vsx")} function attribute, PowerPC
5189 Generate code that uses (does not use) vector/scalar (VSX)
5190 instructions, and also enable the use of built-in functions that allow
5191 more direct access to the VSX instruction set.  In 32-bit code, you
5192 cannot enable VSX or AltiVec instructions unless
5193 @option{-mabi=altivec} is used on the command line.
5195 @item friz
5196 @itemx no-friz
5197 @cindex @code{target("friz")} function attribute, PowerPC
5198 Generate (do not generate) the @code{friz} instruction when the
5199 @option{-funsafe-math-optimizations} option is used to optimize
5200 rounding a floating-point value to 64-bit integer and back to floating
5201 point.  The @code{friz} instruction does not return the same value if
5202 the floating-point number is too large to fit in an integer.
5204 @item avoid-indexed-addresses
5205 @itemx no-avoid-indexed-addresses
5206 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5207 Generate code that tries to avoid (not avoid) the use of indexed load
5208 or store instructions.
5210 @item paired
5211 @itemx no-paired
5212 @cindex @code{target("paired")} function attribute, PowerPC
5213 Generate code that uses (does not use) the generation of PAIRED simd
5214 instructions.
5216 @item longcall
5217 @itemx no-longcall
5218 @cindex @code{target("longcall")} function attribute, PowerPC
5219 Generate code that assumes (does not assume) that all calls are far
5220 away so that a longer more expensive calling sequence is required.
5222 @item cpu=@var{CPU}
5223 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5224 Specify the architecture to generate code for when compiling the
5225 function.  If you select the @code{target("cpu=power7")} attribute when
5226 generating 32-bit code, VSX and AltiVec instructions are not generated
5227 unless you use the @option{-mabi=altivec} option on the command line.
5229 @item tune=@var{TUNE}
5230 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5231 Specify the architecture to tune for when compiling the function.  If
5232 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5233 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5234 compilation tunes for the @var{CPU} architecture, and not the
5235 default tuning specified on the command line.
5236 @end table
5238 On the PowerPC, the inliner does not inline a
5239 function that has different target options than the caller, unless the
5240 callee has a subset of the target options of the caller.
5241 @end table
5243 @node RISC-V Function Attributes
5244 @subsection RISC-V Function Attributes
5246 These function attributes are supported by the RISC-V back end:
5248 @table @code
5249 @item naked
5250 @cindex @code{naked} function attribute, RISC-V
5251 This attribute allows the compiler to construct the
5252 requisite function declaration, while allowing the body of the
5253 function to be assembly code. The specified function will not have
5254 prologue/epilogue sequences generated by the compiler. Only basic
5255 @code{asm} statements can safely be included in naked functions
5256 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5257 basic @code{asm} and C code may appear to work, they cannot be
5258 depended upon to work reliably and are not supported.
5260 @item interrupt
5261 @cindex @code{interrupt} function attribute, RISC-V
5262 Use this attribute to indicate that the specified function is an interrupt
5263 handler.  The compiler generates function entry and exit sequences suitable
5264 for use in an interrupt handler when this attribute is present.
5266 You can specify the kind of interrupt to be handled by adding an optional
5267 parameter to the interrupt attribute like this:
5269 @smallexample
5270 void f (void) __attribute__ ((interrupt ("user")));
5271 @end smallexample
5273 Permissible values for this parameter are @code{user}, @code{supervisor},
5274 and @code{machine}.  If there is no parameter, then it defaults to
5275 @code{machine}.
5276 @end table
5278 @node RL78 Function Attributes
5279 @subsection RL78 Function Attributes
5281 These function attributes are supported by the RL78 back end:
5283 @table @code
5284 @item interrupt
5285 @itemx brk_interrupt
5286 @cindex @code{interrupt} function attribute, RL78
5287 @cindex @code{brk_interrupt} function attribute, RL78
5288 These attributes indicate
5289 that the specified function is an interrupt handler.  The compiler generates
5290 function entry and exit sequences suitable for use in an interrupt handler
5291 when this attribute is present.
5293 Use @code{brk_interrupt} instead of @code{interrupt} for
5294 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5295 that must end with @code{RETB} instead of @code{RETI}).
5297 @item naked
5298 @cindex @code{naked} function attribute, RL78
5299 This attribute allows the compiler to construct the
5300 requisite function declaration, while allowing the body of the
5301 function to be assembly code. The specified function will not have
5302 prologue/epilogue sequences generated by the compiler. Only basic
5303 @code{asm} statements can safely be included in naked functions
5304 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5305 basic @code{asm} and C code may appear to work, they cannot be
5306 depended upon to work reliably and are not supported.
5307 @end table
5309 @node RX Function Attributes
5310 @subsection RX Function Attributes
5312 These function attributes are supported by the RX back end:
5314 @table @code
5315 @item fast_interrupt
5316 @cindex @code{fast_interrupt} function attribute, RX
5317 Use this attribute on the RX port to indicate that the specified
5318 function is a fast interrupt handler.  This is just like the
5319 @code{interrupt} attribute, except that @code{freit} is used to return
5320 instead of @code{reit}.
5322 @item interrupt
5323 @cindex @code{interrupt} function attribute, RX
5324 Use this attribute to indicate
5325 that the specified function is an interrupt handler.  The compiler generates
5326 function entry and exit sequences suitable for use in an interrupt handler
5327 when this attribute is present.
5329 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5330 to the attribute, as well as naming an alternate table name.
5331 Parameters are handled sequentially, so one handler can be assigned to
5332 multiple entries in multiple tables.  One may also pass the magic
5333 string @code{"$default"} which causes the function to be used for any
5334 unfilled slots in the current table.
5336 This example shows a simple assignment of a function to one vector in
5337 the default table (note that preprocessor macros may be used for
5338 chip-specific symbolic vector names):
5339 @smallexample
5340 void __attribute__ ((interrupt (5))) txd1_handler ();
5341 @end smallexample
5343 This example assigns a function to two slots in the default table
5344 (using preprocessor macros defined elsewhere) and makes it the default
5345 for the @code{dct} table:
5346 @smallexample
5347 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5348         txd1_handler ();
5349 @end smallexample
5351 @item naked
5352 @cindex @code{naked} function attribute, RX
5353 This attribute allows the compiler to construct the
5354 requisite function declaration, while allowing the body of the
5355 function to be assembly code. The specified function will not have
5356 prologue/epilogue sequences generated by the compiler. Only basic
5357 @code{asm} statements can safely be included in naked functions
5358 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5359 basic @code{asm} and C code may appear to work, they cannot be
5360 depended upon to work reliably and are not supported.
5362 @item vector
5363 @cindex @code{vector} function attribute, RX
5364 This RX attribute is similar to the @code{interrupt} attribute, including its
5365 parameters, but does not make the function an interrupt-handler type
5366 function (i.e.@: it retains the normal C function calling ABI).  See the
5367 @code{interrupt} attribute for a description of its arguments.
5368 @end table
5370 @node S/390 Function Attributes
5371 @subsection S/390 Function Attributes
5373 These function attributes are supported on the S/390:
5375 @table @code
5376 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5377 @cindex @code{hotpatch} function attribute, S/390
5379 On S/390 System z targets, you can use this function attribute to
5380 make GCC generate a ``hot-patching'' function prologue.  If the
5381 @option{-mhotpatch=} command-line option is used at the same time,
5382 the @code{hotpatch} attribute takes precedence.  The first of the
5383 two arguments specifies the number of halfwords to be added before
5384 the function label.  A second argument can be used to specify the
5385 number of halfwords to be added after the function label.  For
5386 both arguments the maximum allowed value is 1000000.
5388 If both arguments are zero, hotpatching is disabled.
5390 @item target (@var{options})
5391 @cindex @code{target} function attribute
5392 As discussed in @ref{Common Function Attributes}, this attribute
5393 allows specification of target-specific compilation options.
5395 On S/390, the following options are supported:
5397 @table @samp
5398 @item arch=
5399 @item tune=
5400 @item stack-guard=
5401 @item stack-size=
5402 @item branch-cost=
5403 @item warn-framesize=
5404 @item backchain
5405 @itemx no-backchain
5406 @item hard-dfp
5407 @itemx no-hard-dfp
5408 @item hard-float
5409 @itemx soft-float
5410 @item htm
5411 @itemx no-htm
5412 @item vx
5413 @itemx no-vx
5414 @item packed-stack
5415 @itemx no-packed-stack
5416 @item small-exec
5417 @itemx no-small-exec
5418 @item mvcle
5419 @itemx no-mvcle
5420 @item warn-dynamicstack
5421 @itemx no-warn-dynamicstack
5422 @end table
5424 The options work exactly like the S/390 specific command line
5425 options (without the prefix @option{-m}) except that they do not
5426 change any feature macros.  For example,
5428 @smallexample
5429 @code{target("no-vx")}
5430 @end smallexample
5432 does not undefine the @code{__VEC__} macro.
5433 @end table
5435 @node SH Function Attributes
5436 @subsection SH Function Attributes
5438 These function attributes are supported on the SH family of processors:
5440 @table @code
5441 @item function_vector
5442 @cindex @code{function_vector} function attribute, SH
5443 @cindex calling functions through the function vector on SH2A
5444 On SH2A targets, this attribute declares a function to be called using the
5445 TBR relative addressing mode.  The argument to this attribute is the entry
5446 number of the same function in a vector table containing all the TBR
5447 relative addressable functions.  For correct operation the TBR must be setup
5448 accordingly to point to the start of the vector table before any functions with
5449 this attribute are invoked.  Usually a good place to do the initialization is
5450 the startup routine.  The TBR relative vector table can have at max 256 function
5451 entries.  The jumps to these functions are generated using a SH2A specific,
5452 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5453 from GNU binutils version 2.7 or later for this attribute to work correctly.
5455 In an application, for a function being called once, this attribute
5456 saves at least 8 bytes of code; and if other successive calls are being
5457 made to the same function, it saves 2 bytes of code per each of these
5458 calls.
5460 @item interrupt_handler
5461 @cindex @code{interrupt_handler} function attribute, SH
5462 Use this attribute to
5463 indicate that the specified function is an interrupt handler.  The compiler
5464 generates function entry and exit sequences suitable for use in an
5465 interrupt handler when this attribute is present.
5467 @item nosave_low_regs
5468 @cindex @code{nosave_low_regs} function attribute, SH
5469 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5470 function should not save and restore registers R0..R7.  This can be used on SH3*
5471 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5472 interrupt handlers.
5474 @item renesas
5475 @cindex @code{renesas} function attribute, SH
5476 On SH targets this attribute specifies that the function or struct follows the
5477 Renesas ABI.
5479 @item resbank
5480 @cindex @code{resbank} function attribute, SH
5481 On the SH2A target, this attribute enables the high-speed register
5482 saving and restoration using a register bank for @code{interrupt_handler}
5483 routines.  Saving to the bank is performed automatically after the CPU
5484 accepts an interrupt that uses a register bank.
5486 The nineteen 32-bit registers comprising general register R0 to R14,
5487 control register GBR, and system registers MACH, MACL, and PR and the
5488 vector table address offset are saved into a register bank.  Register
5489 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5490 from the bank is executed by issuing a RESBANK instruction.
5492 @item sp_switch
5493 @cindex @code{sp_switch} function attribute, SH
5494 Use this attribute on the SH to indicate an @code{interrupt_handler}
5495 function should switch to an alternate stack.  It expects a string
5496 argument that names a global variable holding the address of the
5497 alternate stack.
5499 @smallexample
5500 void *alt_stack;
5501 void f () __attribute__ ((interrupt_handler,
5502                           sp_switch ("alt_stack")));
5503 @end smallexample
5505 @item trap_exit
5506 @cindex @code{trap_exit} function attribute, SH
5507 Use this attribute on the SH for an @code{interrupt_handler} to return using
5508 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5509 argument specifying the trap number to be used.
5511 @item trapa_handler
5512 @cindex @code{trapa_handler} function attribute, SH
5513 On SH targets this function attribute is similar to @code{interrupt_handler}
5514 but it does not save and restore all registers.
5515 @end table
5517 @node SPU Function Attributes
5518 @subsection SPU Function Attributes
5520 These function attributes are supported by the SPU back end:
5522 @table @code
5523 @item naked
5524 @cindex @code{naked} function attribute, SPU
5525 This attribute allows the compiler to construct the
5526 requisite function declaration, while allowing the body of the
5527 function to be assembly code. The specified function will not have
5528 prologue/epilogue sequences generated by the compiler. Only basic
5529 @code{asm} statements can safely be included in naked functions
5530 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5531 basic @code{asm} and C code may appear to work, they cannot be
5532 depended upon to work reliably and are not supported.
5533 @end table
5535 @node Symbian OS Function Attributes
5536 @subsection Symbian OS Function Attributes
5538 @xref{Microsoft Windows Function Attributes}, for discussion of the
5539 @code{dllexport} and @code{dllimport} attributes.
5541 @node V850 Function Attributes
5542 @subsection V850 Function Attributes
5544 The V850 back end supports these function attributes:
5546 @table @code
5547 @item interrupt
5548 @itemx interrupt_handler
5549 @cindex @code{interrupt} function attribute, V850
5550 @cindex @code{interrupt_handler} function attribute, V850
5551 Use these attributes to indicate
5552 that the specified function is an interrupt handler.  The compiler generates
5553 function entry and exit sequences suitable for use in an interrupt handler
5554 when either attribute is present.
5555 @end table
5557 @node Visium Function Attributes
5558 @subsection Visium Function Attributes
5560 These function attributes are supported by the Visium back end:
5562 @table @code
5563 @item interrupt
5564 @cindex @code{interrupt} function attribute, Visium
5565 Use this attribute to indicate
5566 that the specified function is an interrupt handler.  The compiler generates
5567 function entry and exit sequences suitable for use in an interrupt handler
5568 when this attribute is present.
5569 @end table
5571 @node x86 Function Attributes
5572 @subsection x86 Function Attributes
5574 These function attributes are supported by the x86 back end:
5576 @table @code
5577 @item cdecl
5578 @cindex @code{cdecl} function attribute, x86-32
5579 @cindex functions that pop the argument stack on x86-32
5580 @opindex mrtd
5581 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5582 assume that the calling function pops off the stack space used to
5583 pass arguments.  This is
5584 useful to override the effects of the @option{-mrtd} switch.
5586 @item fastcall
5587 @cindex @code{fastcall} function attribute, x86-32
5588 @cindex functions that pop the argument stack on x86-32
5589 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5590 pass the first argument (if of integral type) in the register ECX and
5591 the second argument (if of integral type) in the register EDX@.  Subsequent
5592 and other typed arguments are passed on the stack.  The called function
5593 pops the arguments off the stack.  If the number of arguments is variable all
5594 arguments are pushed on the stack.
5596 @item thiscall
5597 @cindex @code{thiscall} function attribute, x86-32
5598 @cindex functions that pop the argument stack on x86-32
5599 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5600 pass the first argument (if of integral type) in the register ECX.
5601 Subsequent and other typed arguments are passed on the stack. The called
5602 function pops the arguments off the stack.
5603 If the number of arguments is variable all arguments are pushed on the
5604 stack.
5605 The @code{thiscall} attribute is intended for C++ non-static member functions.
5606 As a GCC extension, this calling convention can be used for C functions
5607 and for static member methods.
5609 @item ms_abi
5610 @itemx sysv_abi
5611 @cindex @code{ms_abi} function attribute, x86
5612 @cindex @code{sysv_abi} function attribute, x86
5614 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5615 to indicate which calling convention should be used for a function.  The
5616 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5617 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5618 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5619 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5621 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5622 requires the @option{-maccumulate-outgoing-args} option.
5624 @item callee_pop_aggregate_return (@var{number})
5625 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5627 On x86-32 targets, you can use this attribute to control how
5628 aggregates are returned in memory.  If the caller is responsible for
5629 popping the hidden pointer together with the rest of the arguments, specify
5630 @var{number} equal to zero.  If callee is responsible for popping the
5631 hidden pointer, specify @var{number} equal to one.  
5633 The default x86-32 ABI assumes that the callee pops the
5634 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5635 the compiler assumes that the
5636 caller pops the stack for hidden pointer.
5638 @item ms_hook_prologue
5639 @cindex @code{ms_hook_prologue} function attribute, x86
5641 On 32-bit and 64-bit x86 targets, you can use
5642 this function attribute to make GCC generate the ``hot-patching'' function
5643 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5644 and newer.
5646 @item naked
5647 @cindex @code{naked} function attribute, x86
5648 This attribute allows the compiler to construct the
5649 requisite function declaration, while allowing the body of the
5650 function to be assembly code. The specified function will not have
5651 prologue/epilogue sequences generated by the compiler. Only basic
5652 @code{asm} statements can safely be included in naked functions
5653 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5654 basic @code{asm} and C code may appear to work, they cannot be
5655 depended upon to work reliably and are not supported.
5657 @item regparm (@var{number})
5658 @cindex @code{regparm} function attribute, x86
5659 @cindex functions that are passed arguments in registers on x86-32
5660 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5661 pass arguments number one to @var{number} if they are of integral type
5662 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5663 take a variable number of arguments continue to be passed all of their
5664 arguments on the stack.
5666 Beware that on some ELF systems this attribute is unsuitable for
5667 global functions in shared libraries with lazy binding (which is the
5668 default).  Lazy binding sends the first call via resolving code in
5669 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5670 per the standard calling conventions.  Solaris 8 is affected by this.
5671 Systems with the GNU C Library version 2.1 or higher
5672 and FreeBSD are believed to be
5673 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5674 disabled with the linker or the loader if desired, to avoid the
5675 problem.)
5677 @item sseregparm
5678 @cindex @code{sseregparm} function attribute, x86
5679 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5680 causes the compiler to pass up to 3 floating-point arguments in
5681 SSE registers instead of on the stack.  Functions that take a
5682 variable number of arguments continue to pass all of their
5683 floating-point arguments on the stack.
5685 @item force_align_arg_pointer
5686 @cindex @code{force_align_arg_pointer} function attribute, x86
5687 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5688 applied to individual function definitions, generating an alternate
5689 prologue and epilogue that realigns the run-time stack if necessary.
5690 This supports mixing legacy codes that run with a 4-byte aligned stack
5691 with modern codes that keep a 16-byte stack for SSE compatibility.
5693 @item stdcall
5694 @cindex @code{stdcall} function attribute, x86-32
5695 @cindex functions that pop the argument stack on x86-32
5696 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5697 assume that the called function pops off the stack space used to
5698 pass arguments, unless it takes a variable number of arguments.
5700 @item no_caller_saved_registers
5701 @cindex @code{no_caller_saved_registers} function attribute, x86
5702 Use this attribute to indicate that the specified function has no
5703 caller-saved registers. That is, all registers are callee-saved. For
5704 example, this attribute can be used for a function called from an
5705 interrupt handler. The compiler generates proper function entry and
5706 exit sequences to save and restore any modified registers, except for
5707 the EFLAGS register.  Since GCC doesn't preserve SSE, MMX nor x87
5708 states, the GCC option @option{-mgeneral-regs-only} should be used to
5709 compile functions with @code{no_caller_saved_registers} attribute.
5711 @item interrupt
5712 @cindex @code{interrupt} function attribute, x86
5713 Use this attribute to indicate that the specified function is an
5714 interrupt handler or an exception handler (depending on parameters passed
5715 to the function, explained further).  The compiler generates function
5716 entry and exit sequences suitable for use in an interrupt handler when
5717 this attribute is present.  The @code{IRET} instruction, instead of the
5718 @code{RET} instruction, is used to return from interrupt handlers.  All
5719 registers, except for the EFLAGS register which is restored by the
5720 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5721 doesn't preserve SSE, MMX nor x87 states, the GCC option
5722 @option{-mgeneral-regs-only} should be used to compile interrupt and
5723 exception handlers.
5725 Any interruptible-without-stack-switch code must be compiled with
5726 @option{-mno-red-zone} since interrupt handlers can and will, because
5727 of the hardware design, touch the red zone.
5729 An interrupt handler must be declared with a mandatory pointer
5730 argument:
5732 @smallexample
5733 struct interrupt_frame;
5735 __attribute__ ((interrupt))
5736 void
5737 f (struct interrupt_frame *frame)
5740 @end smallexample
5742 @noindent
5743 and you must define @code{struct interrupt_frame} as described in the
5744 processor's manual.
5746 Exception handlers differ from interrupt handlers because the system
5747 pushes an error code on the stack.  An exception handler declaration is
5748 similar to that for an interrupt handler, but with a different mandatory
5749 function signature.  The compiler arranges to pop the error code off the
5750 stack before the @code{IRET} instruction.
5752 @smallexample
5753 #ifdef __x86_64__
5754 typedef unsigned long long int uword_t;
5755 #else
5756 typedef unsigned int uword_t;
5757 #endif
5759 struct interrupt_frame;
5761 __attribute__ ((interrupt))
5762 void
5763 f (struct interrupt_frame *frame, uword_t error_code)
5765   ...
5767 @end smallexample
5769 Exception handlers should only be used for exceptions that push an error
5770 code; you should use an interrupt handler in other cases.  The system
5771 will crash if the wrong kind of handler is used.
5773 @item target (@var{options})
5774 @cindex @code{target} function attribute
5775 As discussed in @ref{Common Function Attributes}, this attribute 
5776 allows specification of target-specific compilation options.
5778 On the x86, the following options are allowed:
5779 @table @samp
5780 @item abm
5781 @itemx no-abm
5782 @cindex @code{target("abm")} function attribute, x86
5783 Enable/disable the generation of the advanced bit instructions.
5785 @item aes
5786 @itemx no-aes
5787 @cindex @code{target("aes")} function attribute, x86
5788 Enable/disable the generation of the AES instructions.
5790 @item default
5791 @cindex @code{target("default")} function attribute, x86
5792 @xref{Function Multiversioning}, where it is used to specify the
5793 default function version.
5795 @item mmx
5796 @itemx no-mmx
5797 @cindex @code{target("mmx")} function attribute, x86
5798 Enable/disable the generation of the MMX instructions.
5800 @item pclmul
5801 @itemx no-pclmul
5802 @cindex @code{target("pclmul")} function attribute, x86
5803 Enable/disable the generation of the PCLMUL instructions.
5805 @item popcnt
5806 @itemx no-popcnt
5807 @cindex @code{target("popcnt")} function attribute, x86
5808 Enable/disable the generation of the POPCNT instruction.
5810 @item sse
5811 @itemx no-sse
5812 @cindex @code{target("sse")} function attribute, x86
5813 Enable/disable the generation of the SSE instructions.
5815 @item sse2
5816 @itemx no-sse2
5817 @cindex @code{target("sse2")} function attribute, x86
5818 Enable/disable the generation of the SSE2 instructions.
5820 @item sse3
5821 @itemx no-sse3
5822 @cindex @code{target("sse3")} function attribute, x86
5823 Enable/disable the generation of the SSE3 instructions.
5825 @item sse4
5826 @itemx no-sse4
5827 @cindex @code{target("sse4")} function attribute, x86
5828 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5829 and SSE4.2).
5831 @item sse4.1
5832 @itemx no-sse4.1
5833 @cindex @code{target("sse4.1")} function attribute, x86
5834 Enable/disable the generation of the sse4.1 instructions.
5836 @item sse4.2
5837 @itemx no-sse4.2
5838 @cindex @code{target("sse4.2")} function attribute, x86
5839 Enable/disable the generation of the sse4.2 instructions.
5841 @item sse4a
5842 @itemx no-sse4a
5843 @cindex @code{target("sse4a")} function attribute, x86
5844 Enable/disable the generation of the SSE4A instructions.
5846 @item fma4
5847 @itemx no-fma4
5848 @cindex @code{target("fma4")} function attribute, x86
5849 Enable/disable the generation of the FMA4 instructions.
5851 @item xop
5852 @itemx no-xop
5853 @cindex @code{target("xop")} function attribute, x86
5854 Enable/disable the generation of the XOP instructions.
5856 @item lwp
5857 @itemx no-lwp
5858 @cindex @code{target("lwp")} function attribute, x86
5859 Enable/disable the generation of the LWP instructions.
5861 @item ssse3
5862 @itemx no-ssse3
5863 @cindex @code{target("ssse3")} function attribute, x86
5864 Enable/disable the generation of the SSSE3 instructions.
5866 @item cld
5867 @itemx no-cld
5868 @cindex @code{target("cld")} function attribute, x86
5869 Enable/disable the generation of the CLD before string moves.
5871 @item fancy-math-387
5872 @itemx no-fancy-math-387
5873 @cindex @code{target("fancy-math-387")} function attribute, x86
5874 Enable/disable the generation of the @code{sin}, @code{cos}, and
5875 @code{sqrt} instructions on the 387 floating-point unit.
5877 @item ieee-fp
5878 @itemx no-ieee-fp
5879 @cindex @code{target("ieee-fp")} function attribute, x86
5880 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5882 @item inline-all-stringops
5883 @itemx no-inline-all-stringops
5884 @cindex @code{target("inline-all-stringops")} function attribute, x86
5885 Enable/disable inlining of string operations.
5887 @item inline-stringops-dynamically
5888 @itemx no-inline-stringops-dynamically
5889 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5890 Enable/disable the generation of the inline code to do small string
5891 operations and calling the library routines for large operations.
5893 @item align-stringops
5894 @itemx no-align-stringops
5895 @cindex @code{target("align-stringops")} function attribute, x86
5896 Do/do not align destination of inlined string operations.
5898 @item recip
5899 @itemx no-recip
5900 @cindex @code{target("recip")} function attribute, x86
5901 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5902 instructions followed an additional Newton-Raphson step instead of
5903 doing a floating-point division.
5905 @item arch=@var{ARCH}
5906 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5907 Specify the architecture to generate code for in compiling the function.
5909 @item tune=@var{TUNE}
5910 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5911 Specify the architecture to tune for in compiling the function.
5913 @item fpmath=@var{FPMATH}
5914 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5915 Specify which floating-point unit to use.  You must specify the
5916 @code{target("fpmath=sse,387")} option as
5917 @code{target("fpmath=sse+387")} because the comma would separate
5918 different options.
5920 @item indirect_branch("@var{choice}")
5921 @cindex @code{indirect_branch} function attribute, x86
5922 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5923 to convert indirect call and jump with @var{choice}.  @samp{keep}
5924 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
5925 call and jump to call and return thunk.  @samp{thunk-inline} converts
5926 indirect call and jump to inlined call and return thunk.
5927 @samp{thunk-extern} converts indirect call and jump to external call
5928 and return thunk provided in a separate object file.
5930 @item function_return("@var{choice}")
5931 @cindex @code{function_return} function attribute, x86
5932 On x86 targets, the @code{function_return} attribute causes the compiler
5933 to convert function return with @var{choice}.  @samp{keep} keeps function
5934 return unmodified.  @samp{thunk} converts function return to call and
5935 return thunk.  @samp{thunk-inline} converts function return to inlined
5936 call and return thunk.  @samp{thunk-extern} converts function return to
5937 external call and return thunk provided in a separate object file.
5939 @item nocf_check
5940 @cindex @code{nocf_check} function attribute
5941 The @code{nocf_check} attribute on a function is used to inform the
5942 compiler that the function's prologue should not be instrumented when
5943 compiled with the @option{-fcf-protection=branch} option.  The
5944 compiler assumes that the function's address is a valid target for a
5945 control-flow transfer.
5947 The @code{nocf_check} attribute on a type of pointer to function is
5948 used to inform the compiler that a call through the pointer should
5949 not be instrumented when compiled with the
5950 @option{-fcf-protection=branch} option.  The compiler assumes
5951 that the function's address from the pointer is a valid target for
5952 a control-flow transfer.  A direct function call through a function
5953 name is assumed to be a safe call thus direct calls are not
5954 instrumented by the compiler.
5956 The @code{nocf_check} attribute is applied to an object's type.
5957 In case of assignment of a function address or a function pointer to
5958 another pointer, the attribute is not carried over from the right-hand
5959 object's type; the type of left-hand object stays unchanged.  The
5960 compiler checks for @code{nocf_check} attribute mismatch and reports
5961 a warning in case of mismatch.
5963 @smallexample
5965 int foo (void) __attribute__(nocf_check);
5966 void (*foo1)(void) __attribute__(nocf_check);
5967 void (*foo2)(void);
5969 /* foo's address is assumed to be valid.  */
5971 foo (void) 
5973   /* This call site is not checked for control-flow 
5974      validity.  */
5975   (*foo1)();
5977   /* A warning is issued about attribute mismatch.  */
5978   foo1 = foo2; 
5980   /* This call site is still not checked.  */
5981   (*foo1)();
5983   /* This call site is checked.  */
5984   (*foo2)();
5986   /* A warning is issued about attribute mismatch.  */
5987   foo2 = foo1; 
5989   /* This call site is still checked.  */
5990   (*foo2)();
5992   return 0;
5994 @end smallexample
5996 @item indirect_return
5997 @cindex @code{indirect_return} function attribute, x86
5999 The @code{indirect_return} attribute can be applied to a function,
6000 as well as variable or type of function pointer to inform the
6001 compiler that the function may return via indirect branch.
6003 @end table
6005 On the x86, the inliner does not inline a
6006 function that has different target options than the caller, unless the
6007 callee has a subset of the target options of the caller.  For example
6008 a function declared with @code{target("sse3")} can inline a function
6009 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
6010 @end table
6012 @node Xstormy16 Function Attributes
6013 @subsection Xstormy16 Function Attributes
6015 These function attributes are supported by the Xstormy16 back end:
6017 @table @code
6018 @item interrupt
6019 @cindex @code{interrupt} function attribute, Xstormy16
6020 Use this attribute to indicate
6021 that the specified function is an interrupt handler.  The compiler generates
6022 function entry and exit sequences suitable for use in an interrupt handler
6023 when this attribute is present.
6024 @end table
6026 @node Variable Attributes
6027 @section Specifying Attributes of Variables
6028 @cindex attribute of variables
6029 @cindex variable attributes
6031 The keyword @code{__attribute__} allows you to specify special
6032 attributes of variables or structure fields.  This keyword is followed
6033 by an attribute specification inside double parentheses.  Some
6034 attributes are currently defined generically for variables.
6035 Other attributes are defined for variables on particular target
6036 systems.  Other attributes are available for functions
6037 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
6038 enumerators (@pxref{Enumerator Attributes}), statements
6039 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6040 Other front ends might define more attributes
6041 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
6043 @xref{Attribute Syntax}, for details of the exact syntax for using
6044 attributes.
6046 @menu
6047 * Common Variable Attributes::
6048 * ARC Variable Attributes::
6049 * AVR Variable Attributes::
6050 * Blackfin Variable Attributes::
6051 * H8/300 Variable Attributes::
6052 * IA-64 Variable Attributes::
6053 * M32R/D Variable Attributes::
6054 * MeP Variable Attributes::
6055 * Microsoft Windows Variable Attributes::
6056 * MSP430 Variable Attributes::
6057 * Nvidia PTX Variable Attributes::
6058 * PowerPC Variable Attributes::
6059 * RL78 Variable Attributes::
6060 * SPU Variable Attributes::
6061 * V850 Variable Attributes::
6062 * x86 Variable Attributes::
6063 * Xstormy16 Variable Attributes::
6064 @end menu
6066 @node Common Variable Attributes
6067 @subsection Common Variable Attributes
6069 The following attributes are supported on most targets.
6071 @table @code
6072 @cindex @code{aligned} variable attribute
6073 @item aligned
6074 @itemx aligned (@var{alignment})
6075 The @code{aligned} attribute specifies a minimum alignment for the variable
6076 or structure field, measured in bytes.  When specified, @var{alignment} must
6077 be an integer constant power of 2.  Specifying no @var{alignment} argument
6078 implies the maximum alignment for the target, which is often, but by no
6079 means always, 8 or 16 bytes.
6081 For example, the declaration:
6083 @smallexample
6084 int x __attribute__ ((aligned (16))) = 0;
6085 @end smallexample
6087 @noindent
6088 causes the compiler to allocate the global variable @code{x} on a
6089 16-byte boundary.  On a 68040, this could be used in conjunction with
6090 an @code{asm} expression to access the @code{move16} instruction which
6091 requires 16-byte aligned operands.
6093 You can also specify the alignment of structure fields.  For example, to
6094 create a double-word aligned @code{int} pair, you could write:
6096 @smallexample
6097 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6098 @end smallexample
6100 @noindent
6101 This is an alternative to creating a union with a @code{double} member,
6102 which forces the union to be double-word aligned.
6104 As in the preceding examples, you can explicitly specify the alignment
6105 (in bytes) that you wish the compiler to use for a given variable or
6106 structure field.  Alternatively, you can leave out the alignment factor
6107 and just ask the compiler to align a variable or field to the
6108 default alignment for the target architecture you are compiling for.
6109 The default alignment is sufficient for all scalar types, but may not be
6110 enough for all vector types on a target that supports vector operations.
6111 The default alignment is fixed for a particular target ABI.
6113 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6114 which is the largest alignment ever used for any data type on the
6115 target machine you are compiling for.  For example, you could write:
6117 @smallexample
6118 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6119 @end smallexample
6121 The compiler automatically sets the alignment for the declared
6122 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
6123 often make copy operations more efficient, because the compiler can
6124 use whatever instructions copy the biggest chunks of memory when
6125 performing copies to or from the variables or fields that you have
6126 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
6127 may change depending on command-line options.
6129 When used on a struct, or struct member, the @code{aligned} attribute can
6130 only increase the alignment; in order to decrease it, the @code{packed}
6131 attribute must be specified as well.  When used as part of a typedef, the
6132 @code{aligned} attribute can both increase and decrease alignment, and
6133 specifying the @code{packed} attribute generates a warning.
6135 Note that the effectiveness of @code{aligned} attributes may be limited
6136 by inherent limitations in your linker.  On many systems, the linker is
6137 only able to arrange for variables to be aligned up to a certain maximum
6138 alignment.  (For some linkers, the maximum supported alignment may
6139 be very very small.)  If your linker is only able to align variables
6140 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6141 in an @code{__attribute__} still only provides you with 8-byte
6142 alignment.  See your linker documentation for further information.
6144 The @code{aligned} attribute can also be used for functions
6145 (@pxref{Common Function Attributes}.)
6147 @cindex @code{warn_if_not_aligned} variable attribute
6148 @item warn_if_not_aligned (@var{alignment})
6149 This attribute specifies a threshold for the structure field, measured
6150 in bytes.  If the structure field is aligned below the threshold, a
6151 warning will be issued.  For example, the declaration:
6153 @smallexample
6154 struct foo
6156   int i1;
6157   int i2;
6158   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6160 @end smallexample
6162 @noindent
6163 causes the compiler to issue an warning on @code{struct foo}, like
6164 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6165 The compiler also issues a warning, like @samp{warning: 'x' offset
6166 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6167 the misaligned offset:
6169 @smallexample
6170 struct foo
6172   int i1;
6173   int i2;
6174   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6175 @} __attribute__((aligned(16)));
6176 @end smallexample
6178 This warning can be disabled by @option{-Wno-if-not-aligned}.
6179 The @code{warn_if_not_aligned} attribute can also be used for types
6180 (@pxref{Common Type Attributes}.)
6182 @item cleanup (@var{cleanup_function})
6183 @cindex @code{cleanup} variable attribute
6184 The @code{cleanup} attribute runs a function when the variable goes
6185 out of scope.  This attribute can only be applied to auto function
6186 scope variables; it may not be applied to parameters or variables
6187 with static storage duration.  The function must take one parameter,
6188 a pointer to a type compatible with the variable.  The return value
6189 of the function (if any) is ignored.
6191 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6192 is run during the stack unwinding that happens during the
6193 processing of the exception.  Note that the @code{cleanup} attribute
6194 does not allow the exception to be caught, only to perform an action.
6195 It is undefined what happens if @var{cleanup_function} does not
6196 return normally.
6198 @item common
6199 @itemx nocommon
6200 @cindex @code{common} variable attribute
6201 @cindex @code{nocommon} variable attribute
6202 @opindex fcommon
6203 @opindex fno-common
6204 The @code{common} attribute requests GCC to place a variable in
6205 ``common'' storage.  The @code{nocommon} attribute requests the
6206 opposite---to allocate space for it directly.
6208 These attributes override the default chosen by the
6209 @option{-fno-common} and @option{-fcommon} flags respectively.
6211 @item copy
6212 @itemx copy (@var{variable})
6213 @cindex @code{copy} variable attribute
6214 The @code{copy} attribute applies the set of attributes with which
6215 @var{variable} has been declared to the declaration of the variable
6216 to which the attribute is applied.  The attribute is designed for
6217 libraries that define aliases that are expected to specify the same
6218 set of attributes as the aliased symbols.  The @code{copy} attribute
6219 can be used with variables, functions or types.  However, the kind
6220 of symbol to which the attribute is applied (either varible or
6221 function) must match the kind of symbol to which the argument refers.
6222 The @code{copy} attribute copies only syntaxtic and semantic attributes
6223 but attributes that affect a symbol's linkage or visibility such as
6224 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
6225 attribute is also not copied.  @xref{Common Function Attributes}.
6226 @xref{Common Type Attributes}.
6228 @item deprecated
6229 @itemx deprecated (@var{msg})
6230 @cindex @code{deprecated} variable attribute
6231 The @code{deprecated} attribute results in a warning if the variable
6232 is used anywhere in the source file.  This is useful when identifying
6233 variables that are expected to be removed in a future version of a
6234 program.  The warning also includes the location of the declaration
6235 of the deprecated variable, to enable users to easily find further
6236 information about why the variable is deprecated, or what they should
6237 do instead.  Note that the warning only occurs for uses:
6239 @smallexample
6240 extern int old_var __attribute__ ((deprecated));
6241 extern int old_var;
6242 int new_fn () @{ return old_var; @}
6243 @end smallexample
6245 @noindent
6246 results in a warning on line 3 but not line 2.  The optional @var{msg}
6247 argument, which must be a string, is printed in the warning if
6248 present.
6250 The @code{deprecated} attribute can also be used for functions and
6251 types (@pxref{Common Function Attributes},
6252 @pxref{Common Type Attributes}).
6254 The message attached to the attribute is affected by the setting of
6255 the @option{-fmessage-length} option.
6257 @item mode (@var{mode})
6258 @cindex @code{mode} variable attribute
6259 This attribute specifies the data type for the declaration---whichever
6260 type corresponds to the mode @var{mode}.  This in effect lets you
6261 request an integer or floating-point type according to its width.
6263 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6264 for a list of the possible keywords for @var{mode}.
6265 You may also specify a mode of @code{byte} or @code{__byte__} to
6266 indicate the mode corresponding to a one-byte integer, @code{word} or
6267 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6268 or @code{__pointer__} for the mode used to represent pointers.
6270 @item nonstring
6271 @cindex @code{nonstring} variable attribute
6272 The @code{nonstring} variable attribute specifies that an object or member
6273 declaration with type array of @code{char}, @code{signed char}, or
6274 @code{unsigned char}, or pointer to such a type is intended to store
6275 character arrays that do not necessarily contain a terminating @code{NUL}.
6276 This is useful in detecting uses of such arrays or pointers with functions
6277 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6278 an array or pointer is used as an argument to a bounded string manipulation
6279 function such as @code{strncpy}.  For example, without the attribute, GCC
6280 will issue a warning for the @code{strncpy} call below because it may
6281 truncate the copy without appending the terminating @code{NUL} character.
6282 Using the attribute makes it possible to suppress the warning.  However,
6283 when the array is declared with the attribute the call to @code{strlen} is
6284 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6285 string the call is undefined.  To copy, compare, of search non-string
6286 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6287 and other functions that operate on arrays of bytes.  In addition,
6288 calling @code{strnlen} and @code{strndup} with such arrays is safe
6289 provided a suitable bound is specified, and not diagnosed.
6291 @smallexample
6292 struct Data
6294   char name [32] __attribute__ ((nonstring));
6297 int f (struct Data *pd, const char *s)
6299   strncpy (pd->name, s, sizeof pd->name);
6300   @dots{}
6301   return strlen (pd->name);   // unsafe, gets a warning
6303 @end smallexample
6305 @item packed
6306 @cindex @code{packed} variable attribute
6307 The @code{packed} attribute specifies that a structure member should have
6308 the smallest possible alignment---one bit for a bit-field and one byte
6309 otherwise, unless a larger value is specified with the @code{aligned}
6310 attribute.  The attribute does not apply to non-member objects.
6312 For example in the structure below, the member array @code{x} is packed
6313 so that it immediately follows @code{a} with no intervening padding:
6315 @smallexample
6316 struct foo
6318   char a;
6319   int x[2] __attribute__ ((packed));
6321 @end smallexample
6323 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6324 @code{packed} attribute on bit-fields of type @code{char}.  This has
6325 been fixed in GCC 4.4 but the change can lead to differences in the
6326 structure layout.  See the documentation of
6327 @option{-Wpacked-bitfield-compat} for more information.
6329 @item section ("@var{section-name}")
6330 @cindex @code{section} variable attribute
6331 Normally, the compiler places the objects it generates in sections like
6332 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6333 or you need certain particular variables to appear in special sections,
6334 for example to map to special hardware.  The @code{section}
6335 attribute specifies that a variable (or function) lives in a particular
6336 section.  For example, this small program uses several specific section names:
6338 @smallexample
6339 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6340 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6341 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6342 int init_data __attribute__ ((section ("INITDATA")));
6344 main()
6346   /* @r{Initialize stack pointer} */
6347   init_sp (stack + sizeof (stack));
6349   /* @r{Initialize initialized data} */
6350   memcpy (&init_data, &data, &edata - &data);
6352   /* @r{Turn on the serial ports} */
6353   init_duart (&a);
6354   init_duart (&b);
6356 @end smallexample
6358 @noindent
6359 Use the @code{section} attribute with
6360 @emph{global} variables and not @emph{local} variables,
6361 as shown in the example.
6363 You may use the @code{section} attribute with initialized or
6364 uninitialized global variables but the linker requires
6365 each object be defined once, with the exception that uninitialized
6366 variables tentatively go in the @code{common} (or @code{bss}) section
6367 and can be multiply ``defined''.  Using the @code{section} attribute
6368 changes what section the variable goes into and may cause the
6369 linker to issue an error if an uninitialized variable has multiple
6370 definitions.  You can force a variable to be initialized with the
6371 @option{-fno-common} flag or the @code{nocommon} attribute.
6373 Some file formats do not support arbitrary sections so the @code{section}
6374 attribute is not available on all platforms.
6375 If you need to map the entire contents of a module to a particular
6376 section, consider using the facilities of the linker instead.
6378 @item tls_model ("@var{tls_model}")
6379 @cindex @code{tls_model} variable attribute
6380 The @code{tls_model} attribute sets thread-local storage model
6381 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6382 overriding @option{-ftls-model=} command-line switch on a per-variable
6383 basis.
6384 The @var{tls_model} argument should be one of @code{global-dynamic},
6385 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6387 Not all targets support this attribute.
6389 @item unused
6390 @cindex @code{unused} variable attribute
6391 This attribute, attached to a variable, means that the variable is meant
6392 to be possibly unused.  GCC does not produce a warning for this
6393 variable.
6395 @item used
6396 @cindex @code{used} variable attribute
6397 This attribute, attached to a variable with static storage, means that
6398 the variable must be emitted even if it appears that the variable is not
6399 referenced.
6401 When applied to a static data member of a C++ class template, the
6402 attribute also means that the member is instantiated if the
6403 class itself is instantiated.
6405 @item vector_size (@var{bytes})
6406 @cindex @code{vector_size} variable attribute
6407 This attribute specifies the vector size for the variable, measured in
6408 bytes.  For example, the declaration:
6410 @smallexample
6411 int foo __attribute__ ((vector_size (16)));
6412 @end smallexample
6414 @noindent
6415 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6416 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6417 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6419 This attribute is only applicable to integral and float scalars,
6420 although arrays, pointers, and function return values are allowed in
6421 conjunction with this construct.
6423 Aggregates with this attribute are invalid, even if they are of the same
6424 size as a corresponding scalar.  For example, the declaration:
6426 @smallexample
6427 struct S @{ int a; @};
6428 struct S  __attribute__ ((vector_size (16))) foo;
6429 @end smallexample
6431 @noindent
6432 is invalid even if the size of the structure is the same as the size of
6433 the @code{int}.
6435 @item visibility ("@var{visibility_type}")
6436 @cindex @code{visibility} variable attribute
6437 This attribute affects the linkage of the declaration to which it is attached.
6438 The @code{visibility} attribute is described in
6439 @ref{Common Function Attributes}.
6441 @item weak
6442 @cindex @code{weak} variable attribute
6443 The @code{weak} attribute is described in
6444 @ref{Common Function Attributes}.
6446 @end table
6448 @node ARC Variable Attributes
6449 @subsection ARC Variable Attributes
6451 @table @code
6452 @item aux
6453 @cindex @code{aux} variable attribute, ARC
6454 The @code{aux} attribute is used to directly access the ARC's
6455 auxiliary register space from C.  The auxilirary register number is
6456 given via attribute argument.
6458 @end table
6460 @node AVR Variable Attributes
6461 @subsection AVR Variable Attributes
6463 @table @code
6464 @item progmem
6465 @cindex @code{progmem} variable attribute, AVR
6466 The @code{progmem} attribute is used on the AVR to place read-only
6467 data in the non-volatile program memory (flash). The @code{progmem}
6468 attribute accomplishes this by putting respective variables into a
6469 section whose name starts with @code{.progmem}.
6471 This attribute works similar to the @code{section} attribute
6472 but adds additional checking.
6474 @table @asis
6475 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6476 @code{progmem} affects the location
6477 of the data but not how this data is accessed.
6478 In order to read data located with the @code{progmem} attribute
6479 (inline) assembler must be used.
6480 @smallexample
6481 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6482 #include <avr/pgmspace.h> 
6484 /* Locate var in flash memory */
6485 const int var[2] PROGMEM = @{ 1, 2 @};
6487 int read_var (int i)
6489     /* Access var[] by accessor macro from avr/pgmspace.h */
6490     return (int) pgm_read_word (& var[i]);
6492 @end smallexample
6494 AVR is a Harvard architecture processor and data and read-only data
6495 normally resides in the data memory (RAM).
6497 See also the @ref{AVR Named Address Spaces} section for
6498 an alternate way to locate and access data in flash memory.
6500 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6501 On such devices, there is no need for attribute @code{progmem} or
6502 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6503 Just use standard C / C++.  The compiler will generate @code{LD*}
6504 instructions.  As flash memory is visible in the RAM address range,
6505 and the default linker script does @emph{not} locate @code{.rodata} in
6506 RAM, no special features are needed in order not to waste RAM for
6507 read-only data or to read from flash.  You might even get slightly better
6508 performance by
6509 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6510 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6511 an overview.
6513 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6514 The compiler adds @code{0x4000}
6515 to the addresses of objects and declarations in @code{progmem} and locates
6516 the objects in flash memory, namely in section @code{.progmem.data}.
6517 The offset is needed because the flash memory is visible in the RAM
6518 address space starting at address @code{0x4000}.
6520 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6521 no special functions or macros are needed.
6523 @smallexample
6524 /* var is located in flash memory */
6525 extern const int var[2] __attribute__((progmem));
6527 int read_var (int i)
6529     return var[i];
6531 @end smallexample
6533 Please notice that on these devices, there is no need for @code{progmem}
6534 at all.
6536 @end table
6538 @item io
6539 @itemx io (@var{addr})
6540 @cindex @code{io} variable attribute, AVR
6541 Variables with the @code{io} attribute are used to address
6542 memory-mapped peripherals in the io address range.
6543 If an address is specified, the variable
6544 is assigned that address, and the value is interpreted as an
6545 address in the data address space.
6546 Example:
6548 @smallexample
6549 volatile int porta __attribute__((io (0x22)));
6550 @end smallexample
6552 The address specified in the address in the data address range.
6554 Otherwise, the variable it is not assigned an address, but the
6555 compiler will still use in/out instructions where applicable,
6556 assuming some other module assigns an address in the io address range.
6557 Example:
6559 @smallexample
6560 extern volatile int porta __attribute__((io));
6561 @end smallexample
6563 @item io_low
6564 @itemx io_low (@var{addr})
6565 @cindex @code{io_low} variable attribute, AVR
6566 This is like the @code{io} attribute, but additionally it informs the
6567 compiler that the object lies in the lower half of the I/O area,
6568 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6569 instructions.
6571 @item address
6572 @itemx address (@var{addr})
6573 @cindex @code{address} variable attribute, AVR
6574 Variables with the @code{address} attribute are used to address
6575 memory-mapped peripherals that may lie outside the io address range.
6577 @smallexample
6578 volatile int porta __attribute__((address (0x600)));
6579 @end smallexample
6581 @item absdata
6582 @cindex @code{absdata} variable attribute, AVR
6583 Variables in static storage and with the @code{absdata} attribute can
6584 be accessed by the @code{LDS} and @code{STS} instructions which take
6585 absolute addresses.
6587 @itemize @bullet
6588 @item
6589 This attribute is only supported for the reduced AVR Tiny core
6590 like ATtiny40.
6592 @item
6593 You must make sure that respective data is located in the
6594 address range @code{0x40}@dots{}@code{0xbf} accessible by
6595 @code{LDS} and @code{STS}.  One way to achieve this as an
6596 appropriate linker description file.
6598 @item
6599 If the location does not fit the address range of @code{LDS}
6600 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6601 warning like
6602 @quotation
6603 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6604 @end quotation
6606 @end itemize
6608 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6610 @end table
6612 @node Blackfin Variable Attributes
6613 @subsection Blackfin Variable Attributes
6615 Three attributes are currently defined for the Blackfin.
6617 @table @code
6618 @item l1_data
6619 @itemx l1_data_A
6620 @itemx l1_data_B
6621 @cindex @code{l1_data} variable attribute, Blackfin
6622 @cindex @code{l1_data_A} variable attribute, Blackfin
6623 @cindex @code{l1_data_B} variable attribute, Blackfin
6624 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6625 Variables with @code{l1_data} attribute are put into the specific section
6626 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6627 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6628 attribute are put into the specific section named @code{.l1.data.B}.
6630 @item l2
6631 @cindex @code{l2} variable attribute, Blackfin
6632 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6633 Variables with @code{l2} attribute are put into the specific section
6634 named @code{.l2.data}.
6635 @end table
6637 @node H8/300 Variable Attributes
6638 @subsection H8/300 Variable Attributes
6640 These variable attributes are available for H8/300 targets:
6642 @table @code
6643 @item eightbit_data
6644 @cindex @code{eightbit_data} variable attribute, H8/300
6645 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6646 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6647 variable should be placed into the eight-bit data section.
6648 The compiler generates more efficient code for certain operations
6649 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6650 256 bytes of data.
6652 You must use GAS and GLD from GNU binutils version 2.7 or later for
6653 this attribute to work correctly.
6655 @item tiny_data
6656 @cindex @code{tiny_data} variable attribute, H8/300
6657 @cindex tiny data section on the H8/300H and H8S
6658 Use this attribute on the H8/300H and H8S to indicate that the specified
6659 variable should be placed into the tiny data section.
6660 The compiler generates more efficient code for loads and stores
6661 on data in the tiny data section.  Note the tiny data area is limited to
6662 slightly under 32KB of data.
6664 @end table
6666 @node IA-64 Variable Attributes
6667 @subsection IA-64 Variable Attributes
6669 The IA-64 back end supports the following variable attribute:
6671 @table @code
6672 @item model (@var{model-name})
6673 @cindex @code{model} variable attribute, IA-64
6675 On IA-64, use this attribute to set the addressability of an object.
6676 At present, the only supported identifier for @var{model-name} is
6677 @code{small}, indicating addressability via ``small'' (22-bit)
6678 addresses (so that their addresses can be loaded with the @code{addl}
6679 instruction).  Caveat: such addressing is by definition not position
6680 independent and hence this attribute must not be used for objects
6681 defined by shared libraries.
6683 @end table
6685 @node M32R/D Variable Attributes
6686 @subsection M32R/D Variable Attributes
6688 One attribute is currently defined for the M32R/D@.
6690 @table @code
6691 @item model (@var{model-name})
6692 @cindex @code{model-name} variable attribute, M32R/D
6693 @cindex variable addressability on the M32R/D
6694 Use this attribute on the M32R/D to set the addressability of an object.
6695 The identifier @var{model-name} is one of @code{small}, @code{medium},
6696 or @code{large}, representing each of the code models.
6698 Small model objects live in the lower 16MB of memory (so that their
6699 addresses can be loaded with the @code{ld24} instruction).
6701 Medium and large model objects may live anywhere in the 32-bit address space
6702 (the compiler generates @code{seth/add3} instructions to load their
6703 addresses).
6704 @end table
6706 @node MeP Variable Attributes
6707 @subsection MeP Variable Attributes
6709 The MeP target has a number of addressing modes and busses.  The
6710 @code{near} space spans the standard memory space's first 16 megabytes
6711 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6712 The @code{based} space is a 128-byte region in the memory space that
6713 is addressed relative to the @code{$tp} register.  The @code{tiny}
6714 space is a 65536-byte region relative to the @code{$gp} register.  In
6715 addition to these memory regions, the MeP target has a separate 16-bit
6716 control bus which is specified with @code{cb} attributes.
6718 @table @code
6720 @item based
6721 @cindex @code{based} variable attribute, MeP
6722 Any variable with the @code{based} attribute is assigned to the
6723 @code{.based} section, and is accessed with relative to the
6724 @code{$tp} register.
6726 @item tiny
6727 @cindex @code{tiny} variable attribute, MeP
6728 Likewise, the @code{tiny} attribute assigned variables to the
6729 @code{.tiny} section, relative to the @code{$gp} register.
6731 @item near
6732 @cindex @code{near} variable attribute, MeP
6733 Variables with the @code{near} attribute are assumed to have addresses
6734 that fit in a 24-bit addressing mode.  This is the default for large
6735 variables (@code{-mtiny=4} is the default) but this attribute can
6736 override @code{-mtiny=} for small variables, or override @code{-ml}.
6738 @item far
6739 @cindex @code{far} variable attribute, MeP
6740 Variables with the @code{far} attribute are addressed using a full
6741 32-bit address.  Since this covers the entire memory space, this
6742 allows modules to make no assumptions about where variables might be
6743 stored.
6745 @item io
6746 @cindex @code{io} variable attribute, MeP
6747 @itemx io (@var{addr})
6748 Variables with the @code{io} attribute are used to address
6749 memory-mapped peripherals.  If an address is specified, the variable
6750 is assigned that address, else it is not assigned an address (it is
6751 assumed some other module assigns an address).  Example:
6753 @smallexample
6754 int timer_count __attribute__((io(0x123)));
6755 @end smallexample
6757 @item cb
6758 @itemx cb (@var{addr})
6759 @cindex @code{cb} variable attribute, MeP
6760 Variables with the @code{cb} attribute are used to access the control
6761 bus, using special instructions.  @code{addr} indicates the control bus
6762 address.  Example:
6764 @smallexample
6765 int cpu_clock __attribute__((cb(0x123)));
6766 @end smallexample
6768 @end table
6770 @node Microsoft Windows Variable Attributes
6771 @subsection Microsoft Windows Variable Attributes
6773 You can use these attributes on Microsoft Windows targets.
6774 @ref{x86 Variable Attributes} for additional Windows compatibility
6775 attributes available on all x86 targets.
6777 @table @code
6778 @item dllimport
6779 @itemx dllexport
6780 @cindex @code{dllimport} variable attribute
6781 @cindex @code{dllexport} variable attribute
6782 The @code{dllimport} and @code{dllexport} attributes are described in
6783 @ref{Microsoft Windows Function Attributes}.
6785 @item selectany
6786 @cindex @code{selectany} variable attribute
6787 The @code{selectany} attribute causes an initialized global variable to
6788 have link-once semantics.  When multiple definitions of the variable are
6789 encountered by the linker, the first is selected and the remainder are
6790 discarded.  Following usage by the Microsoft compiler, the linker is told
6791 @emph{not} to warn about size or content differences of the multiple
6792 definitions.
6794 Although the primary usage of this attribute is for POD types, the
6795 attribute can also be applied to global C++ objects that are initialized
6796 by a constructor.  In this case, the static initialization and destruction
6797 code for the object is emitted in each translation defining the object,
6798 but the calls to the constructor and destructor are protected by a
6799 link-once guard variable.
6801 The @code{selectany} attribute is only available on Microsoft Windows
6802 targets.  You can use @code{__declspec (selectany)} as a synonym for
6803 @code{__attribute__ ((selectany))} for compatibility with other
6804 compilers.
6806 @item shared
6807 @cindex @code{shared} variable attribute
6808 On Microsoft Windows, in addition to putting variable definitions in a named
6809 section, the section can also be shared among all running copies of an
6810 executable or DLL@.  For example, this small program defines shared data
6811 by putting it in a named section @code{shared} and marking the section
6812 shareable:
6814 @smallexample
6815 int foo __attribute__((section ("shared"), shared)) = 0;
6818 main()
6820   /* @r{Read and write foo.  All running
6821      copies see the same value.}  */
6822   return 0;
6824 @end smallexample
6826 @noindent
6827 You may only use the @code{shared} attribute along with @code{section}
6828 attribute with a fully-initialized global definition because of the way
6829 linkers work.  See @code{section} attribute for more information.
6831 The @code{shared} attribute is only available on Microsoft Windows@.
6833 @end table
6835 @node MSP430 Variable Attributes
6836 @subsection MSP430 Variable Attributes
6838 @table @code
6839 @item noinit
6840 @cindex @code{noinit} variable attribute, MSP430 
6841 Any data with the @code{noinit} attribute will not be initialised by
6842 the C runtime startup code, or the program loader.  Not initialising
6843 data in this way can reduce program startup times.
6845 @item persistent
6846 @cindex @code{persistent} variable attribute, MSP430 
6847 Any variable with the @code{persistent} attribute will not be
6848 initialised by the C runtime startup code.  Instead its value will be
6849 set once, when the application is loaded, and then never initialised
6850 again, even if the processor is reset or the program restarts.
6851 Persistent data is intended to be placed into FLASH RAM, where its
6852 value will be retained across resets.  The linker script being used to
6853 create the application should ensure that persistent data is correctly
6854 placed.
6856 @item lower
6857 @itemx upper
6858 @itemx either
6859 @cindex @code{lower} variable attribute, MSP430 
6860 @cindex @code{upper} variable attribute, MSP430 
6861 @cindex @code{either} variable attribute, MSP430 
6862 These attributes are the same as the MSP430 function attributes of the
6863 same name (@pxref{MSP430 Function Attributes}).  
6864 These attributes can be applied to both functions and variables.
6865 @end table
6867 @node Nvidia PTX Variable Attributes
6868 @subsection Nvidia PTX Variable Attributes
6870 These variable attributes are supported by the Nvidia PTX back end:
6872 @table @code
6873 @item shared
6874 @cindex @code{shared} attribute, Nvidia PTX
6875 Use this attribute to place a variable in the @code{.shared} memory space.
6876 This memory space is private to each cooperative thread array; only threads
6877 within one thread block refer to the same instance of the variable.
6878 The runtime does not initialize variables in this memory space.
6879 @end table
6881 @node PowerPC Variable Attributes
6882 @subsection PowerPC Variable Attributes
6884 Three attributes currently are defined for PowerPC configurations:
6885 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6887 @cindex @code{ms_struct} variable attribute, PowerPC
6888 @cindex @code{gcc_struct} variable attribute, PowerPC
6889 For full documentation of the struct attributes please see the
6890 documentation in @ref{x86 Variable Attributes}.
6892 @cindex @code{altivec} variable attribute, PowerPC
6893 For documentation of @code{altivec} attribute please see the
6894 documentation in @ref{PowerPC Type Attributes}.
6896 @node RL78 Variable Attributes
6897 @subsection RL78 Variable Attributes
6899 @cindex @code{saddr} variable attribute, RL78
6900 The RL78 back end supports the @code{saddr} variable attribute.  This
6901 specifies placement of the corresponding variable in the SADDR area,
6902 which can be accessed more efficiently than the default memory region.
6904 @node SPU Variable Attributes
6905 @subsection SPU Variable Attributes
6907 @cindex @code{spu_vector} variable attribute, SPU
6908 The SPU supports the @code{spu_vector} attribute for variables.  For
6909 documentation of this attribute please see the documentation in
6910 @ref{SPU Type Attributes}.
6912 @node V850 Variable Attributes
6913 @subsection V850 Variable Attributes
6915 These variable attributes are supported by the V850 back end:
6917 @table @code
6919 @item sda
6920 @cindex @code{sda} variable attribute, V850
6921 Use this attribute to explicitly place a variable in the small data area,
6922 which can hold up to 64 kilobytes.
6924 @item tda
6925 @cindex @code{tda} variable attribute, V850
6926 Use this attribute to explicitly place a variable in the tiny data area,
6927 which can hold up to 256 bytes in total.
6929 @item zda
6930 @cindex @code{zda} variable attribute, V850
6931 Use this attribute to explicitly place a variable in the first 32 kilobytes
6932 of memory.
6933 @end table
6935 @node x86 Variable Attributes
6936 @subsection x86 Variable Attributes
6938 Two attributes are currently defined for x86 configurations:
6939 @code{ms_struct} and @code{gcc_struct}.
6941 @table @code
6942 @item ms_struct
6943 @itemx gcc_struct
6944 @cindex @code{ms_struct} variable attribute, x86
6945 @cindex @code{gcc_struct} variable attribute, x86
6947 If @code{packed} is used on a structure, or if bit-fields are used,
6948 it may be that the Microsoft ABI lays out the structure differently
6949 than the way GCC normally does.  Particularly when moving packed
6950 data between functions compiled with GCC and the native Microsoft compiler
6951 (either via function call or as data in a file), it may be necessary to access
6952 either format.
6954 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6955 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6956 command-line options, respectively;
6957 see @ref{x86 Options}, for details of how structure layout is affected.
6958 @xref{x86 Type Attributes}, for information about the corresponding
6959 attributes on types.
6961 @end table
6963 @node Xstormy16 Variable Attributes
6964 @subsection Xstormy16 Variable Attributes
6966 One attribute is currently defined for xstormy16 configurations:
6967 @code{below100}.
6969 @table @code
6970 @item below100
6971 @cindex @code{below100} variable attribute, Xstormy16
6973 If a variable has the @code{below100} attribute (@code{BELOW100} is
6974 allowed also), GCC places the variable in the first 0x100 bytes of
6975 memory and use special opcodes to access it.  Such variables are
6976 placed in either the @code{.bss_below100} section or the
6977 @code{.data_below100} section.
6979 @end table
6981 @node Type Attributes
6982 @section Specifying Attributes of Types
6983 @cindex attribute of types
6984 @cindex type attributes
6986 The keyword @code{__attribute__} allows you to specify special
6987 attributes of types.  Some type attributes apply only to @code{struct}
6988 and @code{union} types, while others can apply to any type defined
6989 via a @code{typedef} declaration.  Other attributes are defined for
6990 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6991 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6992 statements (@pxref{Statement Attributes}), and for
6993 variables (@pxref{Variable Attributes}).
6995 The @code{__attribute__} keyword is followed by an attribute specification
6996 inside double parentheses.  
6998 You may specify type attributes in an enum, struct or union type
6999 declaration or definition by placing them immediately after the
7000 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
7001 syntax is to place them just past the closing curly brace of the
7002 definition.
7004 You can also include type attributes in a @code{typedef} declaration.
7005 @xref{Attribute Syntax}, for details of the exact syntax for using
7006 attributes.
7008 @menu
7009 * Common Type Attributes::
7010 * ARC Type Attributes::
7011 * ARM Type Attributes::
7012 * MeP Type Attributes::
7013 * PowerPC Type Attributes::
7014 * SPU Type Attributes::
7015 * x86 Type Attributes::
7016 @end menu
7018 @node Common Type Attributes
7019 @subsection Common Type Attributes
7021 The following type attributes are supported on most targets.
7023 @table @code
7024 @cindex @code{aligned} type attribute
7025 @item aligned
7026 @itemx aligned (@var{alignment})
7027 The @code{aligned} attribute specifies a minimum alignment (in bytes) for
7028 variables of the specified type.  When specified, @var{alignment} must be
7029 a power of 2.  Specifying no @var{alignment} argument implies the maximum
7030 alignment for the target, which is often, but by no means always, 8 or 16
7031 bytes.  For example, the declarations:
7033 @smallexample
7034 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
7035 typedef int more_aligned_int __attribute__ ((aligned (8)));
7036 @end smallexample
7038 @noindent
7039 force the compiler to ensure (as far as it can) that each variable whose
7040 type is @code{struct S} or @code{more_aligned_int} is allocated and
7041 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
7042 variables of type @code{struct S} aligned to 8-byte boundaries allows
7043 the compiler to use the @code{ldd} and @code{std} (doubleword load and
7044 store) instructions when copying one variable of type @code{struct S} to
7045 another, thus improving run-time efficiency.
7047 Note that the alignment of any given @code{struct} or @code{union} type
7048 is required by the ISO C standard to be at least a perfect multiple of
7049 the lowest common multiple of the alignments of all of the members of
7050 the @code{struct} or @code{union} in question.  This means that you @emph{can}
7051 effectively adjust the alignment of a @code{struct} or @code{union}
7052 type by attaching an @code{aligned} attribute to any one of the members
7053 of such a type, but the notation illustrated in the example above is a
7054 more obvious, intuitive, and readable way to request the compiler to
7055 adjust the alignment of an entire @code{struct} or @code{union} type.
7057 As in the preceding example, you can explicitly specify the alignment
7058 (in bytes) that you wish the compiler to use for a given @code{struct}
7059 or @code{union} type.  Alternatively, you can leave out the alignment factor
7060 and just ask the compiler to align a type to the maximum
7061 useful alignment for the target machine you are compiling for.  For
7062 example, you could write:
7064 @smallexample
7065 struct S @{ short f[3]; @} __attribute__ ((aligned));
7066 @end smallexample
7068 Whenever you leave out the alignment factor in an @code{aligned}
7069 attribute specification, the compiler automatically sets the alignment
7070 for the type to the largest alignment that is ever used for any data
7071 type on the target machine you are compiling for.  Doing this can often
7072 make copy operations more efficient, because the compiler can use
7073 whatever instructions copy the biggest chunks of memory when performing
7074 copies to or from the variables that have types that you have aligned
7075 this way.
7077 In the example above, if the size of each @code{short} is 2 bytes, then
7078 the size of the entire @code{struct S} type is 6 bytes.  The smallest
7079 power of two that is greater than or equal to that is 8, so the
7080 compiler sets the alignment for the entire @code{struct S} type to 8
7081 bytes.
7083 Note that although you can ask the compiler to select a time-efficient
7084 alignment for a given type and then declare only individual stand-alone
7085 objects of that type, the compiler's ability to select a time-efficient
7086 alignment is primarily useful only when you plan to create arrays of
7087 variables having the relevant (efficiently aligned) type.  If you
7088 declare or use arrays of variables of an efficiently-aligned type, then
7089 it is likely that your program also does pointer arithmetic (or
7090 subscripting, which amounts to the same thing) on pointers to the
7091 relevant type, and the code that the compiler generates for these
7092 pointer arithmetic operations is often more efficient for
7093 efficiently-aligned types than for other types.
7095 Note that the effectiveness of @code{aligned} attributes may be limited
7096 by inherent limitations in your linker.  On many systems, the linker is
7097 only able to arrange for variables to be aligned up to a certain maximum
7098 alignment.  (For some linkers, the maximum supported alignment may
7099 be very very small.)  If your linker is only able to align variables
7100 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
7101 in an @code{__attribute__} still only provides you with 8-byte
7102 alignment.  See your linker documentation for further information.
7104 When used on a struct, or struct member, the @code{aligned} attribute can
7105 only increase the alignment; in order to decrease it, the @code{packed}
7106 attribute must be specified as well.  When used as part of a typedef, the
7107 @code{aligned} attribute can both increase and decrease alignment, and
7108 specifying the @code{packed} attribute generates a warning.
7110 @cindex @code{warn_if_not_aligned} type attribute
7111 @item warn_if_not_aligned (@var{alignment})
7112 This attribute specifies a threshold for the structure field, measured
7113 in bytes.  If the structure field is aligned below the threshold, a
7114 warning will be issued.  For example, the declaration:
7116 @smallexample
7117 typedef unsigned long long __u64
7118    __attribute__((aligned(4),warn_if_not_aligned(8)));
7120 struct foo
7122   int i1;
7123   int i2;
7124   __u64 x;
7126 @end smallexample
7128 @noindent
7129 causes the compiler to issue an warning on @code{struct foo}, like
7130 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7131 It is used to define @code{struct foo} in such a way that
7132 @code{struct foo} has the same layout and the structure field @code{x}
7133 has the same alignment when @code{__u64} is aligned at either 4 or
7134 8 bytes.  Align @code{struct foo} to 8 bytes:
7136 @smallexample
7137 struct foo
7139   int i1;
7140   int i2;
7141   __u64 x;
7142 @} __attribute__((aligned(8)));
7143 @end smallexample
7145 @noindent
7146 silences the warning.  The compiler also issues a warning, like
7147 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7148 when the structure field has the misaligned offset:
7150 @smallexample
7151 struct foo
7153   int i1;
7154   int i2;
7155   int i3;
7156   __u64 x;
7157 @} __attribute__((aligned(8)));
7158 @end smallexample
7160 This warning can be disabled by @option{-Wno-if-not-aligned}.
7162 @item copy
7163 @itemx copy (@var{expression})
7164 @cindex @code{copy} type attribute
7165 The @code{copy} attribute applies the set of attributes with which
7166 the type of the @var{expression} has been declared to the declaration
7167 of the type to which the attribute is applied.  The attribute is
7168 designed for libraries that define aliases that are expected to
7169 specify the same set of attributes as the aliased symbols.
7170 The @code{copy} attribute can be used with types, variables, or
7171 functions.  However, the kind of symbol to which the attribute is
7172 applied (either varible or function) must match the kind of symbol
7173 to which the argument refers.
7174 The @code{copy} attribute copies only syntaxtic and semantic attributes
7175 but attributes that affect a symbol's linkage or visibility such as
7176 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
7177 attribute is also not copied.  @xref{Common Function Attributes}.
7178 @xref{Common Variable Attributes}.
7180 For example, suppose @code{struct A} below is defined in some third
7181 partly library header to have the alignment requirement @code{N} and
7182 to force a warning whenever a variable of the type is not so aligned
7183 due to attribute @code{packed}.  Specifying the @code{copy} attribute
7184 on the definition on the unrelated @code{struct B} has the effect of
7185 copying all relevant attributes from the type referenced by the pointer
7186 expression to @code{struct B}.
7188 @smallexample
7189 struct __attribute__ ((aligned (N), warn_if_not_aligned (N)))
7190 A @{ /* @r{@dots{}} */ @};
7191 struct __attribute__ ((copy ( (struct A *)0)) B @{ /* @r{@dots{}} */ @};
7192 @end smallexample
7194 @item deprecated
7195 @itemx deprecated (@var{msg})
7196 @cindex @code{deprecated} type attribute
7197 The @code{deprecated} attribute results in a warning if the type
7198 is used anywhere in the source file.  This is useful when identifying
7199 types that are expected to be removed in a future version of a program.
7200 If possible, the warning also includes the location of the declaration
7201 of the deprecated type, to enable users to easily find further
7202 information about why the type is deprecated, or what they should do
7203 instead.  Note that the warnings only occur for uses and then only
7204 if the type is being applied to an identifier that itself is not being
7205 declared as deprecated.
7207 @smallexample
7208 typedef int T1 __attribute__ ((deprecated));
7209 T1 x;
7210 typedef T1 T2;
7211 T2 y;
7212 typedef T1 T3 __attribute__ ((deprecated));
7213 T3 z __attribute__ ((deprecated));
7214 @end smallexample
7216 @noindent
7217 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7218 warning is issued for line 4 because T2 is not explicitly
7219 deprecated.  Line 5 has no warning because T3 is explicitly
7220 deprecated.  Similarly for line 6.  The optional @var{msg}
7221 argument, which must be a string, is printed in the warning if
7222 present.  Control characters in the string will be replaced with
7223 escape sequences, and if the @option{-fmessage-length} option is set
7224 to 0 (its default value) then any newline characters will be ignored.
7226 The @code{deprecated} attribute can also be used for functions and
7227 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7229 The message attached to the attribute is affected by the setting of
7230 the @option{-fmessage-length} option.
7232 @item designated_init
7233 @cindex @code{designated_init} type attribute
7234 This attribute may only be applied to structure types.  It indicates
7235 that any initialization of an object of this type must use designated
7236 initializers rather than positional initializers.  The intent of this
7237 attribute is to allow the programmer to indicate that a structure's
7238 layout may change, and that therefore relying on positional
7239 initialization will result in future breakage.
7241 GCC emits warnings based on this attribute by default; use
7242 @option{-Wno-designated-init} to suppress them.
7244 @item may_alias
7245 @cindex @code{may_alias} type attribute
7246 Accesses through pointers to types with this attribute are not subject
7247 to type-based alias analysis, but are instead assumed to be able to alias
7248 any other type of objects.
7249 In the context of section 6.5 paragraph 7 of the C99 standard,
7250 an lvalue expression
7251 dereferencing such a pointer is treated like having a character type.
7252 See @option{-fstrict-aliasing} for more information on aliasing issues.
7253 This extension exists to support some vector APIs, in which pointers to
7254 one vector type are permitted to alias pointers to a different vector type.
7256 Note that an object of a type with this attribute does not have any
7257 special semantics.
7259 Example of use:
7261 @smallexample
7262 typedef short __attribute__((__may_alias__)) short_a;
7265 main (void)
7267   int a = 0x12345678;
7268   short_a *b = (short_a *) &a;
7270   b[1] = 0;
7272   if (a == 0x12345678)
7273     abort();
7275   exit(0);
7277 @end smallexample
7279 @noindent
7280 If you replaced @code{short_a} with @code{short} in the variable
7281 declaration, the above program would abort when compiled with
7282 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7283 above.
7285 @item mode (@var{mode})
7286 @cindex @code{mode} type attribute
7287 This attribute specifies the data type for the declaration---whichever
7288 type corresponds to the mode @var{mode}.  This in effect lets you
7289 request an integer or floating-point type according to its width.
7291 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7292 for a list of the possible keywords for @var{mode}.
7293 You may also specify a mode of @code{byte} or @code{__byte__} to
7294 indicate the mode corresponding to a one-byte integer, @code{word} or
7295 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7296 or @code{__pointer__} for the mode used to represent pointers.
7298 @item packed
7299 @cindex @code{packed} type attribute
7300 This attribute, attached to @code{struct} or @code{union} type
7301 definition, specifies that each member (other than zero-width bit-fields)
7302 of the structure or union is placed to minimize the memory required.  When
7303 attached to an @code{enum} definition, it indicates that the smallest
7304 integral type should be used.
7306 @opindex fshort-enums
7307 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7308 types is equivalent to specifying the @code{packed} attribute on each
7309 of the structure or union members.  Specifying the @option{-fshort-enums}
7310 flag on the command line is equivalent to specifying the @code{packed}
7311 attribute on all @code{enum} definitions.
7313 In the following example @code{struct my_packed_struct}'s members are
7314 packed closely together, but the internal layout of its @code{s} member
7315 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7316 be packed too.
7318 @smallexample
7319 struct my_unpacked_struct
7320  @{
7321     char c;
7322     int i;
7323  @};
7325 struct __attribute__ ((__packed__)) my_packed_struct
7326   @{
7327      char c;
7328      int  i;
7329      struct my_unpacked_struct s;
7330   @};
7331 @end smallexample
7333 You may only specify the @code{packed} attribute attribute on the definition
7334 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7335 that does not also define the enumerated type, structure or union.
7337 @item scalar_storage_order ("@var{endianness}")
7338 @cindex @code{scalar_storage_order} type attribute
7339 When attached to a @code{union} or a @code{struct}, this attribute sets
7340 the storage order, aka endianness, of the scalar fields of the type, as
7341 well as the array fields whose component is scalar.  The supported
7342 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
7343 has no effects on fields which are themselves a @code{union}, a @code{struct}
7344 or an array whose component is a @code{union} or a @code{struct}, and it is
7345 possible for these fields to have a different scalar storage order than the
7346 enclosing type.
7348 This attribute is supported only for targets that use a uniform default
7349 scalar storage order (fortunately, most of them), i.e.@: targets that store
7350 the scalars either all in big-endian or all in little-endian.
7352 Additional restrictions are enforced for types with the reverse scalar
7353 storage order with regard to the scalar storage order of the target:
7355 @itemize
7356 @item Taking the address of a scalar field of a @code{union} or a
7357 @code{struct} with reverse scalar storage order is not permitted and yields
7358 an error.
7359 @item Taking the address of an array field, whose component is scalar, of
7360 a @code{union} or a @code{struct} with reverse scalar storage order is
7361 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7362 is specified.
7363 @item Taking the address of a @code{union} or a @code{struct} with reverse
7364 scalar storage order is permitted.
7365 @end itemize
7367 These restrictions exist because the storage order attribute is lost when
7368 the address of a scalar or the address of an array with scalar component is
7369 taken, so storing indirectly through this address generally does not work.
7370 The second case is nevertheless allowed to be able to perform a block copy
7371 from or to the array.
7373 Moreover, the use of type punning or aliasing to toggle the storage order
7374 is not supported; that is to say, a given scalar object cannot be accessed
7375 through distinct types that assign a different storage order to it.
7377 @item transparent_union
7378 @cindex @code{transparent_union} type attribute
7380 This attribute, attached to a @code{union} type definition, indicates
7381 that any function parameter having that union type causes calls to that
7382 function to be treated in a special way.
7384 First, the argument corresponding to a transparent union type can be of
7385 any type in the union; no cast is required.  Also, if the union contains
7386 a pointer type, the corresponding argument can be a null pointer
7387 constant or a void pointer expression; and if the union contains a void
7388 pointer type, the corresponding argument can be any pointer expression.
7389 If the union member type is a pointer, qualifiers like @code{const} on
7390 the referenced type must be respected, just as with normal pointer
7391 conversions.
7393 Second, the argument is passed to the function using the calling
7394 conventions of the first member of the transparent union, not the calling
7395 conventions of the union itself.  All members of the union must have the
7396 same machine representation; this is necessary for this argument passing
7397 to work properly.
7399 Transparent unions are designed for library functions that have multiple
7400 interfaces for compatibility reasons.  For example, suppose the
7401 @code{wait} function must accept either a value of type @code{int *} to
7402 comply with POSIX, or a value of type @code{union wait *} to comply with
7403 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7404 @code{wait} would accept both kinds of arguments, but it would also
7405 accept any other pointer type and this would make argument type checking
7406 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7407 as follows:
7409 @smallexample
7410 typedef union __attribute__ ((__transparent_union__))
7411   @{
7412     int *__ip;
7413     union wait *__up;
7414   @} wait_status_ptr_t;
7416 pid_t wait (wait_status_ptr_t);
7417 @end smallexample
7419 @noindent
7420 This interface allows either @code{int *} or @code{union wait *}
7421 arguments to be passed, using the @code{int *} calling convention.
7422 The program can call @code{wait} with arguments of either type:
7424 @smallexample
7425 int w1 () @{ int w; return wait (&w); @}
7426 int w2 () @{ union wait w; return wait (&w); @}
7427 @end smallexample
7429 @noindent
7430 With this interface, @code{wait}'s implementation might look like this:
7432 @smallexample
7433 pid_t wait (wait_status_ptr_t p)
7435   return waitpid (-1, p.__ip, 0);
7437 @end smallexample
7439 @item unused
7440 @cindex @code{unused} type attribute
7441 When attached to a type (including a @code{union} or a @code{struct}),
7442 this attribute means that variables of that type are meant to appear
7443 possibly unused.  GCC does not produce a warning for any variables of
7444 that type, even if the variable appears to do nothing.  This is often
7445 the case with lock or thread classes, which are usually defined and then
7446 not referenced, but contain constructors and destructors that have
7447 nontrivial bookkeeping functions.
7449 @item visibility
7450 @cindex @code{visibility} type attribute
7451 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7452 applied to class, struct, union and enum types.  Unlike other type
7453 attributes, the attribute must appear between the initial keyword and
7454 the name of the type; it cannot appear after the body of the type.
7456 Note that the type visibility is applied to vague linkage entities
7457 associated with the class (vtable, typeinfo node, etc.).  In
7458 particular, if a class is thrown as an exception in one shared object
7459 and caught in another, the class must have default visibility.
7460 Otherwise the two shared objects are unable to use the same
7461 typeinfo node and exception handling will break.
7463 @end table
7465 To specify multiple attributes, separate them by commas within the
7466 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7467 packed))}.
7469 @node ARC Type Attributes
7470 @subsection ARC Type Attributes
7472 @cindex @code{uncached} type attribute, ARC
7473 Declaring objects with @code{uncached} allows you to exclude
7474 data-cache participation in load and store operations on those objects
7475 without involving the additional semantic implications of
7476 @code{volatile}.  The @code{.di} instruction suffix is used for all
7477 loads and stores of data declared @code{uncached}.
7479 @node ARM Type Attributes
7480 @subsection ARM Type Attributes
7482 @cindex @code{notshared} type attribute, ARM
7483 On those ARM targets that support @code{dllimport} (such as Symbian
7484 OS), you can use the @code{notshared} attribute to indicate that the
7485 virtual table and other similar data for a class should not be
7486 exported from a DLL@.  For example:
7488 @smallexample
7489 class __declspec(notshared) C @{
7490 public:
7491   __declspec(dllimport) C();
7492   virtual void f();
7495 __declspec(dllexport)
7496 C::C() @{@}
7497 @end smallexample
7499 @noindent
7500 In this code, @code{C::C} is exported from the current DLL, but the
7501 virtual table for @code{C} is not exported.  (You can use
7502 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7503 most Symbian OS code uses @code{__declspec}.)
7505 @node MeP Type Attributes
7506 @subsection MeP Type Attributes
7508 @cindex @code{based} type attribute, MeP
7509 @cindex @code{tiny} type attribute, MeP
7510 @cindex @code{near} type attribute, MeP
7511 @cindex @code{far} type attribute, MeP
7512 Many of the MeP variable attributes may be applied to types as well.
7513 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7514 @code{far} attributes may be applied to either.  The @code{io} and
7515 @code{cb} attributes may not be applied to types.
7517 @node PowerPC Type Attributes
7518 @subsection PowerPC Type Attributes
7520 Three attributes currently are defined for PowerPC configurations:
7521 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7523 @cindex @code{ms_struct} type attribute, PowerPC
7524 @cindex @code{gcc_struct} type attribute, PowerPC
7525 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7526 attributes please see the documentation in @ref{x86 Type Attributes}.
7528 @cindex @code{altivec} type attribute, PowerPC
7529 The @code{altivec} attribute allows one to declare AltiVec vector data
7530 types supported by the AltiVec Programming Interface Manual.  The
7531 attribute requires an argument to specify one of three vector types:
7532 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7533 and @code{bool__} (always followed by unsigned).
7535 @smallexample
7536 __attribute__((altivec(vector__)))
7537 __attribute__((altivec(pixel__))) unsigned short
7538 __attribute__((altivec(bool__))) unsigned
7539 @end smallexample
7541 These attributes mainly are intended to support the @code{__vector},
7542 @code{__pixel}, and @code{__bool} AltiVec keywords.
7544 @node SPU Type Attributes
7545 @subsection SPU Type Attributes
7547 @cindex @code{spu_vector} type attribute, SPU
7548 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7549 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7550 Language Extensions Specification.  It is intended to support the
7551 @code{__vector} keyword.
7553 @node x86 Type Attributes
7554 @subsection x86 Type Attributes
7556 Two attributes are currently defined for x86 configurations:
7557 @code{ms_struct} and @code{gcc_struct}.
7559 @table @code
7561 @item ms_struct
7562 @itemx gcc_struct
7563 @cindex @code{ms_struct} type attribute, x86
7564 @cindex @code{gcc_struct} type attribute, x86
7566 If @code{packed} is used on a structure, or if bit-fields are used
7567 it may be that the Microsoft ABI packs them differently
7568 than GCC normally packs them.  Particularly when moving packed
7569 data between functions compiled with GCC and the native Microsoft compiler
7570 (either via function call or as data in a file), it may be necessary to access
7571 either format.
7573 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7574 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7575 command-line options, respectively;
7576 see @ref{x86 Options}, for details of how structure layout is affected.
7577 @xref{x86 Variable Attributes}, for information about the corresponding
7578 attributes on variables.
7580 @end table
7582 @node Label Attributes
7583 @section Label Attributes
7584 @cindex Label Attributes
7586 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7587 details of the exact syntax for using attributes.  Other attributes are 
7588 available for functions (@pxref{Function Attributes}), variables 
7589 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7590 statements (@pxref{Statement Attributes}), and for types
7591 (@pxref{Type Attributes}).
7593 This example uses the @code{cold} label attribute to indicate the 
7594 @code{ErrorHandling} branch is unlikely to be taken and that the
7595 @code{ErrorHandling} label is unused:
7597 @smallexample
7599    asm goto ("some asm" : : : : NoError);
7601 /* This branch (the fall-through from the asm) is less commonly used */
7602 ErrorHandling: 
7603    __attribute__((cold, unused)); /* Semi-colon is required here */
7604    printf("error\n");
7605    return 0;
7607 NoError:
7608    printf("no error\n");
7609    return 1;
7610 @end smallexample
7612 @table @code
7613 @item unused
7614 @cindex @code{unused} label attribute
7615 This feature is intended for program-generated code that may contain 
7616 unused labels, but which is compiled with @option{-Wall}.  It is
7617 not normally appropriate to use in it human-written code, though it
7618 could be useful in cases where the code that jumps to the label is
7619 contained within an @code{#ifdef} conditional.
7621 @item hot
7622 @cindex @code{hot} label attribute
7623 The @code{hot} attribute on a label is used to inform the compiler that
7624 the path following the label is more likely than paths that are not so
7625 annotated.  This attribute is used in cases where @code{__builtin_expect}
7626 cannot be used, for instance with computed goto or @code{asm goto}.
7628 @item cold
7629 @cindex @code{cold} label attribute
7630 The @code{cold} attribute on labels is used to inform the compiler that
7631 the path following the label is unlikely to be executed.  This attribute
7632 is used in cases where @code{__builtin_expect} cannot be used, for instance
7633 with computed goto or @code{asm goto}.
7635 @end table
7637 @node Enumerator Attributes
7638 @section Enumerator Attributes
7639 @cindex Enumerator Attributes
7641 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7642 details of the exact syntax for using attributes.  Other attributes are
7643 available for functions (@pxref{Function Attributes}), variables
7644 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7645 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7647 This example uses the @code{deprecated} enumerator attribute to indicate the
7648 @code{oldval} enumerator is deprecated:
7650 @smallexample
7651 enum E @{
7652   oldval __attribute__((deprecated)),
7653   newval
7657 fn (void)
7659   return oldval;
7661 @end smallexample
7663 @table @code
7664 @item deprecated
7665 @cindex @code{deprecated} enumerator attribute
7666 The @code{deprecated} attribute results in a warning if the enumerator
7667 is used anywhere in the source file.  This is useful when identifying
7668 enumerators that are expected to be removed in a future version of a
7669 program.  The warning also includes the location of the declaration
7670 of the deprecated enumerator, to enable users to easily find further
7671 information about why the enumerator is deprecated, or what they should
7672 do instead.  Note that the warnings only occurs for uses.
7674 @end table
7676 @node Statement Attributes
7677 @section Statement Attributes
7678 @cindex Statement Attributes
7680 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7681 for details of the exact syntax for using attributes.  Other attributes are
7682 available for functions (@pxref{Function Attributes}), variables
7683 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7684 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7686 This example uses the @code{fallthrough} statement attribute to indicate that
7687 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7689 @smallexample
7690 switch (cond)
7691   @{
7692   case 1:
7693     bar (1);
7694     __attribute__((fallthrough));
7695   case 2:
7696     @dots{}
7697   @}
7698 @end smallexample
7700 @table @code
7701 @item fallthrough
7702 @cindex @code{fallthrough} statement attribute
7703 The @code{fallthrough} attribute with a null statement serves as a
7704 fallthrough statement.  It hints to the compiler that a statement
7705 that falls through to another case label, or user-defined label
7706 in a switch statement is intentional and thus the
7707 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7708 fallthrough attribute may appear at most once in each attribute
7709 list, and may not be mixed with other attributes.  It can only
7710 be used in a switch statement (the compiler will issue an error
7711 otherwise), after a preceding statement and before a logically
7712 succeeding case label, or user-defined label.
7714 @end table
7716 @node Attribute Syntax
7717 @section Attribute Syntax
7718 @cindex attribute syntax
7720 This section describes the syntax with which @code{__attribute__} may be
7721 used, and the constructs to which attribute specifiers bind, for the C
7722 language.  Some details may vary for C++ and Objective-C@.  Because of
7723 infelicities in the grammar for attributes, some forms described here
7724 may not be successfully parsed in all cases.
7726 There are some problems with the semantics of attributes in C++.  For
7727 example, there are no manglings for attributes, although they may affect
7728 code generation, so problems may arise when attributed types are used in
7729 conjunction with templates or overloading.  Similarly, @code{typeid}
7730 does not distinguish between types with different attributes.  Support
7731 for attributes in C++ may be restricted in future to attributes on
7732 declarations only, but not on nested declarators.
7734 @xref{Function Attributes}, for details of the semantics of attributes
7735 applying to functions.  @xref{Variable Attributes}, for details of the
7736 semantics of attributes applying to variables.  @xref{Type Attributes},
7737 for details of the semantics of attributes applying to structure, union
7738 and enumerated types.
7739 @xref{Label Attributes}, for details of the semantics of attributes 
7740 applying to labels.
7741 @xref{Enumerator Attributes}, for details of the semantics of attributes
7742 applying to enumerators.
7743 @xref{Statement Attributes}, for details of the semantics of attributes
7744 applying to statements.
7746 An @dfn{attribute specifier} is of the form
7747 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7748 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7749 each attribute is one of the following:
7751 @itemize @bullet
7752 @item
7753 Empty.  Empty attributes are ignored.
7755 @item
7756 An attribute name
7757 (which may be an identifier such as @code{unused}, or a reserved
7758 word such as @code{const}).
7760 @item
7761 An attribute name followed by a parenthesized list of
7762 parameters for the attribute.
7763 These parameters take one of the following forms:
7765 @itemize @bullet
7766 @item
7767 An identifier.  For example, @code{mode} attributes use this form.
7769 @item
7770 An identifier followed by a comma and a non-empty comma-separated list
7771 of expressions.  For example, @code{format} attributes use this form.
7773 @item
7774 A possibly empty comma-separated list of expressions.  For example,
7775 @code{format_arg} attributes use this form with the list being a single
7776 integer constant expression, and @code{alias} attributes use this form
7777 with the list being a single string constant.
7778 @end itemize
7779 @end itemize
7781 An @dfn{attribute specifier list} is a sequence of one or more attribute
7782 specifiers, not separated by any other tokens.
7784 You may optionally specify attribute names with @samp{__}
7785 preceding and following the name.
7786 This allows you to use them in header files without
7787 being concerned about a possible macro of the same name.  For example,
7788 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7791 @subsubheading Label Attributes
7793 In GNU C, an attribute specifier list may appear after the colon following a
7794 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7795 attributes on labels if the attribute specifier is immediately
7796 followed by a semicolon (i.e., the label applies to an empty
7797 statement).  If the semicolon is missing, C++ label attributes are
7798 ambiguous, as it is permissible for a declaration, which could begin
7799 with an attribute list, to be labelled in C++.  Declarations cannot be
7800 labelled in C90 or C99, so the ambiguity does not arise there.
7802 @subsubheading Enumerator Attributes
7804 In GNU C, an attribute specifier list may appear as part of an enumerator.
7805 The attribute goes after the enumeration constant, before @code{=}, if
7806 present.  The optional attribute in the enumerator appertains to the
7807 enumeration constant.  It is not possible to place the attribute after
7808 the constant expression, if present.
7810 @subsubheading Statement Attributes
7811 In GNU C, an attribute specifier list may appear as part of a null
7812 statement.  The attribute goes before the semicolon.
7814 @subsubheading Type Attributes
7816 An attribute specifier list may appear as part of a @code{struct},
7817 @code{union} or @code{enum} specifier.  It may go either immediately
7818 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7819 the closing brace.  The former syntax is preferred.
7820 Where attribute specifiers follow the closing brace, they are considered
7821 to relate to the structure, union or enumerated type defined, not to any
7822 enclosing declaration the type specifier appears in, and the type
7823 defined is not complete until after the attribute specifiers.
7824 @c Otherwise, there would be the following problems: a shift/reduce
7825 @c conflict between attributes binding the struct/union/enum and
7826 @c binding to the list of specifiers/qualifiers; and "aligned"
7827 @c attributes could use sizeof for the structure, but the size could be
7828 @c changed later by "packed" attributes.
7831 @subsubheading All other attributes
7833 Otherwise, an attribute specifier appears as part of a declaration,
7834 counting declarations of unnamed parameters and type names, and relates
7835 to that declaration (which may be nested in another declaration, for
7836 example in the case of a parameter declaration), or to a particular declarator
7837 within a declaration.  Where an
7838 attribute specifier is applied to a parameter declared as a function or
7839 an array, it should apply to the function or array rather than the
7840 pointer to which the parameter is implicitly converted, but this is not
7841 yet correctly implemented.
7843 Any list of specifiers and qualifiers at the start of a declaration may
7844 contain attribute specifiers, whether or not such a list may in that
7845 context contain storage class specifiers.  (Some attributes, however,
7846 are essentially in the nature of storage class specifiers, and only make
7847 sense where storage class specifiers may be used; for example,
7848 @code{section}.)  There is one necessary limitation to this syntax: the
7849 first old-style parameter declaration in a function definition cannot
7850 begin with an attribute specifier, because such an attribute applies to
7851 the function instead by syntax described below (which, however, is not
7852 yet implemented in this case).  In some other cases, attribute
7853 specifiers are permitted by this grammar but not yet supported by the
7854 compiler.  All attribute specifiers in this place relate to the
7855 declaration as a whole.  In the obsolescent usage where a type of
7856 @code{int} is implied by the absence of type specifiers, such a list of
7857 specifiers and qualifiers may be an attribute specifier list with no
7858 other specifiers or qualifiers.
7860 At present, the first parameter in a function prototype must have some
7861 type specifier that is not an attribute specifier; this resolves an
7862 ambiguity in the interpretation of @code{void f(int
7863 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7864 the parentheses of a function declarator contain only attributes then
7865 those attributes are ignored, rather than yielding an error or warning
7866 or implying a single parameter of type int, but this is subject to
7867 change.
7869 An attribute specifier list may appear immediately before a declarator
7870 (other than the first) in a comma-separated list of declarators in a
7871 declaration of more than one identifier using a single list of
7872 specifiers and qualifiers.  Such attribute specifiers apply
7873 only to the identifier before whose declarator they appear.  For
7874 example, in
7876 @smallexample
7877 __attribute__((noreturn)) void d0 (void),
7878     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7879      d2 (void);
7880 @end smallexample
7882 @noindent
7883 the @code{noreturn} attribute applies to all the functions
7884 declared; the @code{format} attribute only applies to @code{d1}.
7886 An attribute specifier list may appear immediately before the comma,
7887 @code{=} or semicolon terminating the declaration of an identifier other
7888 than a function definition.  Such attribute specifiers apply
7889 to the declared object or function.  Where an
7890 assembler name for an object or function is specified (@pxref{Asm
7891 Labels}), the attribute must follow the @code{asm}
7892 specification.
7894 An attribute specifier list may, in future, be permitted to appear after
7895 the declarator in a function definition (before any old-style parameter
7896 declarations or the function body).
7898 Attribute specifiers may be mixed with type qualifiers appearing inside
7899 the @code{[]} of a parameter array declarator, in the C99 construct by
7900 which such qualifiers are applied to the pointer to which the array is
7901 implicitly converted.  Such attribute specifiers apply to the pointer,
7902 not to the array, but at present this is not implemented and they are
7903 ignored.
7905 An attribute specifier list may appear at the start of a nested
7906 declarator.  At present, there are some limitations in this usage: the
7907 attributes correctly apply to the declarator, but for most individual
7908 attributes the semantics this implies are not implemented.
7909 When attribute specifiers follow the @code{*} of a pointer
7910 declarator, they may be mixed with any type qualifiers present.
7911 The following describes the formal semantics of this syntax.  It makes the
7912 most sense if you are familiar with the formal specification of
7913 declarators in the ISO C standard.
7915 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7916 D1}, where @code{T} contains declaration specifiers that specify a type
7917 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7918 contains an identifier @var{ident}.  The type specified for @var{ident}
7919 for derived declarators whose type does not include an attribute
7920 specifier is as in the ISO C standard.
7922 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7923 and the declaration @code{T D} specifies the type
7924 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7925 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7926 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7928 If @code{D1} has the form @code{*
7929 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7930 declaration @code{T D} specifies the type
7931 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7932 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7933 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7934 @var{ident}.
7936 For example,
7938 @smallexample
7939 void (__attribute__((noreturn)) ****f) (void);
7940 @end smallexample
7942 @noindent
7943 specifies the type ``pointer to pointer to pointer to pointer to
7944 non-returning function returning @code{void}''.  As another example,
7946 @smallexample
7947 char *__attribute__((aligned(8))) *f;
7948 @end smallexample
7950 @noindent
7951 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7952 Note again that this does not work with most attributes; for example,
7953 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7954 is not yet supported.
7956 For compatibility with existing code written for compiler versions that
7957 did not implement attributes on nested declarators, some laxity is
7958 allowed in the placing of attributes.  If an attribute that only applies
7959 to types is applied to a declaration, it is treated as applying to
7960 the type of that declaration.  If an attribute that only applies to
7961 declarations is applied to the type of a declaration, it is treated
7962 as applying to that declaration; and, for compatibility with code
7963 placing the attributes immediately before the identifier declared, such
7964 an attribute applied to a function return type is treated as
7965 applying to the function type, and such an attribute applied to an array
7966 element type is treated as applying to the array type.  If an
7967 attribute that only applies to function types is applied to a
7968 pointer-to-function type, it is treated as applying to the pointer
7969 target type; if such an attribute is applied to a function return type
7970 that is not a pointer-to-function type, it is treated as applying
7971 to the function type.
7973 @node Function Prototypes
7974 @section Prototypes and Old-Style Function Definitions
7975 @cindex function prototype declarations
7976 @cindex old-style function definitions
7977 @cindex promotion of formal parameters
7979 GNU C extends ISO C to allow a function prototype to override a later
7980 old-style non-prototype definition.  Consider the following example:
7982 @smallexample
7983 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7984 #ifdef __STDC__
7985 #define P(x) x
7986 #else
7987 #define P(x) ()
7988 #endif
7990 /* @r{Prototype function declaration.}  */
7991 int isroot P((uid_t));
7993 /* @r{Old-style function definition.}  */
7995 isroot (x)   /* @r{??? lossage here ???} */
7996      uid_t x;
7998   return x == 0;
8000 @end smallexample
8002 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
8003 not allow this example, because subword arguments in old-style
8004 non-prototype definitions are promoted.  Therefore in this example the
8005 function definition's argument is really an @code{int}, which does not
8006 match the prototype argument type of @code{short}.
8008 This restriction of ISO C makes it hard to write code that is portable
8009 to traditional C compilers, because the programmer does not know
8010 whether the @code{uid_t} type is @code{short}, @code{int}, or
8011 @code{long}.  Therefore, in cases like these GNU C allows a prototype
8012 to override a later old-style definition.  More precisely, in GNU C, a
8013 function prototype argument type overrides the argument type specified
8014 by a later old-style definition if the former type is the same as the
8015 latter type before promotion.  Thus in GNU C the above example is
8016 equivalent to the following:
8018 @smallexample
8019 int isroot (uid_t);
8022 isroot (uid_t x)
8024   return x == 0;
8026 @end smallexample
8028 @noindent
8029 GNU C++ does not support old-style function definitions, so this
8030 extension is irrelevant.
8032 @node C++ Comments
8033 @section C++ Style Comments
8034 @cindex @code{//}
8035 @cindex C++ comments
8036 @cindex comments, C++ style
8038 In GNU C, you may use C++ style comments, which start with @samp{//} and
8039 continue until the end of the line.  Many other C implementations allow
8040 such comments, and they are included in the 1999 C standard.  However,
8041 C++ style comments are not recognized if you specify an @option{-std}
8042 option specifying a version of ISO C before C99, or @option{-ansi}
8043 (equivalent to @option{-std=c90}).
8045 @node Dollar Signs
8046 @section Dollar Signs in Identifier Names
8047 @cindex $
8048 @cindex dollar signs in identifier names
8049 @cindex identifier names, dollar signs in
8051 In GNU C, you may normally use dollar signs in identifier names.
8052 This is because many traditional C implementations allow such identifiers.
8053 However, dollar signs in identifiers are not supported on a few target
8054 machines, typically because the target assembler does not allow them.
8056 @node Character Escapes
8057 @section The Character @key{ESC} in Constants
8059 You can use the sequence @samp{\e} in a string or character constant to
8060 stand for the ASCII character @key{ESC}.
8062 @node Alignment
8063 @section Determining the Alignment of Functions, Types or Variables
8064 @cindex alignment
8065 @cindex type alignment
8066 @cindex variable alignment
8068 The keyword @code{__alignof__} determines the alignment requirement of
8069 a function, object, or a type, or the minimum alignment usually required
8070 by a type.  Its syntax is just like @code{sizeof} and C11 @code{_Alignof}.
8072 For example, if the target machine requires a @code{double} value to be
8073 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
8074 This is true on many RISC machines.  On more traditional machine
8075 designs, @code{__alignof__ (double)} is 4 or even 2.
8077 Some machines never actually require alignment; they allow references to any
8078 data type even at an odd address.  For these machines, @code{__alignof__}
8079 reports the smallest alignment that GCC gives the data type, usually as
8080 mandated by the target ABI.
8082 If the operand of @code{__alignof__} is an lvalue rather than a type,
8083 its value is the required alignment for its type, taking into account
8084 any minimum alignment specified by attribute @code{aligned}
8085 (@pxref{Common Variable Attributes}).  For example, after this
8086 declaration:
8088 @smallexample
8089 struct foo @{ int x; char y; @} foo1;
8090 @end smallexample
8092 @noindent
8093 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
8094 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
8095 It is an error to ask for the alignment of an incomplete type other
8096 than @code{void}.
8098 If the operand of the @code{__alignof__} expression is a function,
8099 the expression evaluates to the alignment of the function which may
8100 be specified by attribute @code{aligned} (@pxref{Common Function Attributes}).
8102 @node Inline
8103 @section An Inline Function is As Fast As a Macro
8104 @cindex inline functions
8105 @cindex integrating function code
8106 @cindex open coding
8107 @cindex macros, inline alternative
8109 By declaring a function inline, you can direct GCC to make
8110 calls to that function faster.  One way GCC can achieve this is to
8111 integrate that function's code into the code for its callers.  This
8112 makes execution faster by eliminating the function-call overhead; in
8113 addition, if any of the actual argument values are constant, their
8114 known values may permit simplifications at compile time so that not
8115 all of the inline function's code needs to be included.  The effect on
8116 code size is less predictable; object code may be larger or smaller
8117 with function inlining, depending on the particular case.  You can
8118 also direct GCC to try to integrate all ``simple enough'' functions
8119 into their callers with the option @option{-finline-functions}.
8121 GCC implements three different semantics of declaring a function
8122 inline.  One is available with @option{-std=gnu89} or
8123 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
8124 on all inline declarations, another when
8125 @option{-std=c99},
8126 @option{-std=gnu99} or an option for a later C version is used
8127 (without @option{-fgnu89-inline}), and the third
8128 is used when compiling C++.
8130 To declare a function inline, use the @code{inline} keyword in its
8131 declaration, like this:
8133 @smallexample
8134 static inline int
8135 inc (int *a)
8137   return (*a)++;
8139 @end smallexample
8141 If you are writing a header file to be included in ISO C90 programs, write
8142 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
8144 The three types of inlining behave similarly in two important cases:
8145 when the @code{inline} keyword is used on a @code{static} function,
8146 like the example above, and when a function is first declared without
8147 using the @code{inline} keyword and then is defined with
8148 @code{inline}, like this:
8150 @smallexample
8151 extern int inc (int *a);
8152 inline int
8153 inc (int *a)
8155   return (*a)++;
8157 @end smallexample
8159 In both of these common cases, the program behaves the same as if you
8160 had not used the @code{inline} keyword, except for its speed.
8162 @cindex inline functions, omission of
8163 @opindex fkeep-inline-functions
8164 When a function is both inline and @code{static}, if all calls to the
8165 function are integrated into the caller, and the function's address is
8166 never used, then the function's own assembler code is never referenced.
8167 In this case, GCC does not actually output assembler code for the
8168 function, unless you specify the option @option{-fkeep-inline-functions}.
8169 If there is a nonintegrated call, then the function is compiled to
8170 assembler code as usual.  The function must also be compiled as usual if
8171 the program refers to its address, because that cannot be inlined.
8173 @opindex Winline
8174 Note that certain usages in a function definition can make it unsuitable
8175 for inline substitution.  Among these usages are: variadic functions,
8176 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8177 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8178 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8179 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
8180 function marked @code{inline} could not be substituted, and gives the
8181 reason for the failure.
8183 @cindex automatic @code{inline} for C++ member fns
8184 @cindex @code{inline} automatic for C++ member fns
8185 @cindex member fns, automatically @code{inline}
8186 @cindex C++ member fns, automatically @code{inline}
8187 @opindex fno-default-inline
8188 As required by ISO C++, GCC considers member functions defined within
8189 the body of a class to be marked inline even if they are
8190 not explicitly declared with the @code{inline} keyword.  You can
8191 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8192 Options,,Options Controlling C++ Dialect}.
8194 GCC does not inline any functions when not optimizing unless you specify
8195 the @samp{always_inline} attribute for the function, like this:
8197 @smallexample
8198 /* @r{Prototype.}  */
8199 inline void foo (const char) __attribute__((always_inline));
8200 @end smallexample
8202 The remainder of this section is specific to GNU C90 inlining.
8204 @cindex non-static inline function
8205 When an inline function is not @code{static}, then the compiler must assume
8206 that there may be calls from other source files; since a global symbol can
8207 be defined only once in any program, the function must not be defined in
8208 the other source files, so the calls therein cannot be integrated.
8209 Therefore, a non-@code{static} inline function is always compiled on its
8210 own in the usual fashion.
8212 If you specify both @code{inline} and @code{extern} in the function
8213 definition, then the definition is used only for inlining.  In no case
8214 is the function compiled on its own, not even if you refer to its
8215 address explicitly.  Such an address becomes an external reference, as
8216 if you had only declared the function, and had not defined it.
8218 This combination of @code{inline} and @code{extern} has almost the
8219 effect of a macro.  The way to use it is to put a function definition in
8220 a header file with these keywords, and put another copy of the
8221 definition (lacking @code{inline} and @code{extern}) in a library file.
8222 The definition in the header file causes most calls to the function
8223 to be inlined.  If any uses of the function remain, they refer to
8224 the single copy in the library.
8226 @node Volatiles
8227 @section When is a Volatile Object Accessed?
8228 @cindex accessing volatiles
8229 @cindex volatile read
8230 @cindex volatile write
8231 @cindex volatile access
8233 C has the concept of volatile objects.  These are normally accessed by
8234 pointers and used for accessing hardware or inter-thread
8235 communication.  The standard encourages compilers to refrain from
8236 optimizations concerning accesses to volatile objects, but leaves it
8237 implementation defined as to what constitutes a volatile access.  The
8238 minimum requirement is that at a sequence point all previous accesses
8239 to volatile objects have stabilized and no subsequent accesses have
8240 occurred.  Thus an implementation is free to reorder and combine
8241 volatile accesses that occur between sequence points, but cannot do
8242 so for accesses across a sequence point.  The use of volatile does
8243 not allow you to violate the restriction on updating objects multiple
8244 times between two sequence points.
8246 Accesses to non-volatile objects are not ordered with respect to
8247 volatile accesses.  You cannot use a volatile object as a memory
8248 barrier to order a sequence of writes to non-volatile memory.  For
8249 instance:
8251 @smallexample
8252 int *ptr = @var{something};
8253 volatile int vobj;
8254 *ptr = @var{something};
8255 vobj = 1;
8256 @end smallexample
8258 @noindent
8259 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8260 that the write to @var{*ptr} occurs by the time the update
8261 of @var{vobj} happens.  If you need this guarantee, you must use
8262 a stronger memory barrier such as:
8264 @smallexample
8265 int *ptr = @var{something};
8266 volatile int vobj;
8267 *ptr = @var{something};
8268 asm volatile ("" : : : "memory");
8269 vobj = 1;
8270 @end smallexample
8272 A scalar volatile object is read when it is accessed in a void context:
8274 @smallexample
8275 volatile int *src = @var{somevalue};
8276 *src;
8277 @end smallexample
8279 Such expressions are rvalues, and GCC implements this as a
8280 read of the volatile object being pointed to.
8282 Assignments are also expressions and have an rvalue.  However when
8283 assigning to a scalar volatile, the volatile object is not reread,
8284 regardless of whether the assignment expression's rvalue is used or
8285 not.  If the assignment's rvalue is used, the value is that assigned
8286 to the volatile object.  For instance, there is no read of @var{vobj}
8287 in all the following cases:
8289 @smallexample
8290 int obj;
8291 volatile int vobj;
8292 vobj = @var{something};
8293 obj = vobj = @var{something};
8294 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8295 obj = (@var{something}, vobj = @var{anotherthing});
8296 @end smallexample
8298 If you need to read the volatile object after an assignment has
8299 occurred, you must use a separate expression with an intervening
8300 sequence point.
8302 As bit-fields are not individually addressable, volatile bit-fields may
8303 be implicitly read when written to, or when adjacent bit-fields are
8304 accessed.  Bit-field operations may be optimized such that adjacent
8305 bit-fields are only partially accessed, if they straddle a storage unit
8306 boundary.  For these reasons it is unwise to use volatile bit-fields to
8307 access hardware.
8309 @node Using Assembly Language with C
8310 @section How to Use Inline Assembly Language in C Code
8311 @cindex @code{asm} keyword
8312 @cindex assembly language in C
8313 @cindex inline assembly language
8314 @cindex mixing assembly language and C
8316 The @code{asm} keyword allows you to embed assembler instructions
8317 within C code.  GCC provides two forms of inline @code{asm}
8318 statements.  A @dfn{basic @code{asm}} statement is one with no
8319 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8320 statement (@pxref{Extended Asm}) includes one or more operands.  
8321 The extended form is preferred for mixing C and assembly language
8322 within a function, but to include assembly language at
8323 top level you must use basic @code{asm}.
8325 You can also use the @code{asm} keyword to override the assembler name
8326 for a C symbol, or to place a C variable in a specific register.
8328 @menu
8329 * Basic Asm::          Inline assembler without operands.
8330 * Extended Asm::       Inline assembler with operands.
8331 * Constraints::        Constraints for @code{asm} operands
8332 * Asm Labels::         Specifying the assembler name to use for a C symbol.
8333 * Explicit Register Variables::  Defining variables residing in specified 
8334                        registers.
8335 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
8336 @end menu
8338 @node Basic Asm
8339 @subsection Basic Asm --- Assembler Instructions Without Operands
8340 @cindex basic @code{asm}
8341 @cindex assembly language in C, basic
8343 A basic @code{asm} statement has the following syntax:
8345 @example
8346 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8347 @end example
8349 The @code{asm} keyword is a GNU extension.
8350 When writing code that can be compiled with @option{-ansi} and the
8351 various @option{-std} options, use @code{__asm__} instead of 
8352 @code{asm} (@pxref{Alternate Keywords}).
8354 @subsubheading Qualifiers
8355 @table @code
8356 @item volatile
8357 The optional @code{volatile} qualifier has no effect. 
8358 All basic @code{asm} blocks are implicitly volatile.
8359 @end table
8361 @subsubheading Parameters
8362 @table @var
8364 @item AssemblerInstructions
8365 This is a literal string that specifies the assembler code. The string can 
8366 contain any instructions recognized by the assembler, including directives. 
8367 GCC does not parse the assembler instructions themselves and 
8368 does not know what they mean or even whether they are valid assembler input. 
8370 You may place multiple assembler instructions together in a single @code{asm} 
8371 string, separated by the characters normally used in assembly code for the 
8372 system. A combination that works in most places is a newline to break the 
8373 line, plus a tab character (written as @samp{\n\t}).
8374 Some assemblers allow semicolons as a line separator. However, 
8375 note that some assembler dialects use semicolons to start a comment. 
8376 @end table
8378 @subsubheading Remarks
8379 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8380 smaller, safer, and more efficient code, and in most cases it is a
8381 better solution than basic @code{asm}.  However, there are two
8382 situations where only basic @code{asm} can be used:
8384 @itemize @bullet
8385 @item
8386 Extended @code{asm} statements have to be inside a C
8387 function, so to write inline assembly language at file scope (``top-level''),
8388 outside of C functions, you must use basic @code{asm}.
8389 You can use this technique to emit assembler directives,
8390 define assembly language macros that can be invoked elsewhere in the file,
8391 or write entire functions in assembly language.
8393 @item
8394 Functions declared
8395 with the @code{naked} attribute also require basic @code{asm}
8396 (@pxref{Function Attributes}).
8397 @end itemize
8399 Safely accessing C data and calling functions from basic @code{asm} is more 
8400 complex than it may appear. To access C data, it is better to use extended 
8401 @code{asm}.
8403 Do not expect a sequence of @code{asm} statements to remain perfectly 
8404 consecutive after compilation. If certain instructions need to remain 
8405 consecutive in the output, put them in a single multi-instruction @code{asm}
8406 statement. Note that GCC's optimizers can move @code{asm} statements 
8407 relative to other code, including across jumps.
8409 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8410 GCC does not know about these jumps, and therefore cannot take 
8411 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8412 labels are only supported in extended @code{asm}.
8414 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8415 assembly code when optimizing. This can lead to unexpected duplicate 
8416 symbol errors during compilation if your assembly code defines symbols or 
8417 labels.
8419 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8420 making it a potential source of incompatibilities between compilers.  These
8421 incompatibilities may not produce compiler warnings/errors.
8423 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8424 means there is no way to communicate to the compiler what is happening
8425 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8426 discard them as unreferenced.  It also does not know about side effects of
8427 the assembler code, such as modifications to memory or registers.  Unlike
8428 some compilers, GCC assumes that no changes to general purpose registers
8429 occur.  This assumption may change in a future release.
8431 To avoid complications from future changes to the semantics and the
8432 compatibility issues between compilers, consider replacing basic @code{asm}
8433 with extended @code{asm}.  See
8434 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8435 from basic asm to extended asm} for information about how to perform this
8436 conversion.
8438 The compiler copies the assembler instructions in a basic @code{asm} 
8439 verbatim to the assembly language output file, without 
8440 processing dialects or any of the @samp{%} operators that are available with
8441 extended @code{asm}. This results in minor differences between basic 
8442 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8443 registers you might use @samp{%eax} in basic @code{asm} and
8444 @samp{%%eax} in extended @code{asm}.
8446 On targets such as x86 that support multiple assembler dialects,
8447 all basic @code{asm} blocks use the assembler dialect specified by the 
8448 @option{-masm} command-line option (@pxref{x86 Options}).  
8449 Basic @code{asm} provides no
8450 mechanism to provide different assembler strings for different dialects.
8452 For basic @code{asm} with non-empty assembler string GCC assumes
8453 the assembler block does not change any general purpose registers,
8454 but it may read or write any globally accessible variable.
8456 Here is an example of basic @code{asm} for i386:
8458 @example
8459 /* Note that this code will not compile with -masm=intel */
8460 #define DebugBreak() asm("int $3")
8461 @end example
8463 @node Extended Asm
8464 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8465 @cindex extended @code{asm}
8466 @cindex assembly language in C, extended
8468 With extended @code{asm} you can read and write C variables from 
8469 assembler and perform jumps from assembler code to C labels.  
8470 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8471 the operand parameters after the assembler template:
8473 @example
8474 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
8475                  : @var{OutputOperands} 
8476                  @r{[} : @var{InputOperands}
8477                  @r{[} : @var{Clobbers} @r{]} @r{]})
8479 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
8480                       : 
8481                       : @var{InputOperands}
8482                       : @var{Clobbers}
8483                       : @var{GotoLabels})
8484 @end example
8486 The @code{asm} keyword is a GNU extension.
8487 When writing code that can be compiled with @option{-ansi} and the
8488 various @option{-std} options, use @code{__asm__} instead of 
8489 @code{asm} (@pxref{Alternate Keywords}).
8491 @subsubheading Qualifiers
8492 @table @code
8494 @item volatile
8495 The typical use of extended @code{asm} statements is to manipulate input 
8496 values to produce output values. However, your @code{asm} statements may 
8497 also produce side effects. If so, you may need to use the @code{volatile} 
8498 qualifier to disable certain optimizations. @xref{Volatile}.
8500 @item goto
8501 This qualifier informs the compiler that the @code{asm} statement may 
8502 perform a jump to one of the labels listed in the @var{GotoLabels}.
8503 @xref{GotoLabels}.
8504 @end table
8506 @subsubheading Parameters
8507 @table @var
8508 @item AssemblerTemplate
8509 This is a literal string that is the template for the assembler code. It is a 
8510 combination of fixed text and tokens that refer to the input, output, 
8511 and goto parameters. @xref{AssemblerTemplate}.
8513 @item OutputOperands
8514 A comma-separated list of the C variables modified by the instructions in the 
8515 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8517 @item InputOperands
8518 A comma-separated list of C expressions read by the instructions in the 
8519 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8521 @item Clobbers
8522 A comma-separated list of registers or other values changed by the 
8523 @var{AssemblerTemplate}, beyond those listed as outputs.
8524 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8526 @item GotoLabels
8527 When you are using the @code{goto} form of @code{asm}, this section contains 
8528 the list of all C labels to which the code in the 
8529 @var{AssemblerTemplate} may jump. 
8530 @xref{GotoLabels}.
8532 @code{asm} statements may not perform jumps into other @code{asm} statements,
8533 only to the listed @var{GotoLabels}.
8534 GCC's optimizers do not know about other jumps; therefore they cannot take 
8535 account of them when deciding how to optimize.
8536 @end table
8538 The total number of input + output + goto operands is limited to 30.
8540 @subsubheading Remarks
8541 The @code{asm} statement allows you to include assembly instructions directly 
8542 within C code. This may help you to maximize performance in time-sensitive 
8543 code or to access assembly instructions that are not readily available to C 
8544 programs.
8546 Note that extended @code{asm} statements must be inside a function. Only 
8547 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8548 Functions declared with the @code{naked} attribute also require basic 
8549 @code{asm} (@pxref{Function Attributes}).
8551 While the uses of @code{asm} are many and varied, it may help to think of an 
8552 @code{asm} statement as a series of low-level instructions that convert input 
8553 parameters to output parameters. So a simple (if not particularly useful) 
8554 example for i386 using @code{asm} might look like this:
8556 @example
8557 int src = 1;
8558 int dst;   
8560 asm ("mov %1, %0\n\t"
8561     "add $1, %0"
8562     : "=r" (dst) 
8563     : "r" (src));
8565 printf("%d\n", dst);
8566 @end example
8568 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8570 @anchor{Volatile}
8571 @subsubsection Volatile
8572 @cindex volatile @code{asm}
8573 @cindex @code{asm} volatile
8575 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8576 there is no need for the output variables. Also, the optimizers may move 
8577 code out of loops if they believe that the code will always return the same 
8578 result (i.e.@: none of its input values change between calls). Using the 
8579 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8580 that have no output operands, including @code{asm goto} statements, 
8581 are implicitly volatile.
8583 This i386 code demonstrates a case that does not use (or require) the 
8584 @code{volatile} qualifier. If it is performing assertion checking, this code 
8585 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8586 unreferenced by any code. As a result, the optimizers can discard the 
8587 @code{asm} statement, which in turn removes the need for the entire 
8588 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8589 isn't needed you allow the optimizers to produce the most efficient code 
8590 possible.
8592 @example
8593 void DoCheck(uint32_t dwSomeValue)
8595    uint32_t dwRes;
8597    // Assumes dwSomeValue is not zero.
8598    asm ("bsfl %1,%0"
8599      : "=r" (dwRes)
8600      : "r" (dwSomeValue)
8601      : "cc");
8603    assert(dwRes > 3);
8605 @end example
8607 The next example shows a case where the optimizers can recognize that the input 
8608 (@code{dwSomeValue}) never changes during the execution of the function and can 
8609 therefore move the @code{asm} outside the loop to produce more efficient code. 
8610 Again, using @code{volatile} disables this type of optimization.
8612 @example
8613 void do_print(uint32_t dwSomeValue)
8615    uint32_t dwRes;
8617    for (uint32_t x=0; x < 5; x++)
8618    @{
8619       // Assumes dwSomeValue is not zero.
8620       asm ("bsfl %1,%0"
8621         : "=r" (dwRes)
8622         : "r" (dwSomeValue)
8623         : "cc");
8625       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8626    @}
8628 @end example
8630 The following example demonstrates a case where you need to use the 
8631 @code{volatile} qualifier. 
8632 It uses the x86 @code{rdtsc} instruction, which reads 
8633 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8634 the optimizers might assume that the @code{asm} block will always return the 
8635 same value and therefore optimize away the second call.
8637 @example
8638 uint64_t msr;
8640 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8641         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8642         "or %%rdx, %0"        // 'Or' in the lower bits.
8643         : "=a" (msr)
8644         : 
8645         : "rdx");
8647 printf("msr: %llx\n", msr);
8649 // Do other work...
8651 // Reprint the timestamp
8652 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8653         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8654         "or %%rdx, %0"        // 'Or' in the lower bits.
8655         : "=a" (msr)
8656         : 
8657         : "rdx");
8659 printf("msr: %llx\n", msr);
8660 @end example
8662 GCC's optimizers do not treat this code like the non-volatile code in the 
8663 earlier examples. They do not move it out of loops or omit it on the 
8664 assumption that the result from a previous call is still valid.
8666 Note that the compiler can move even volatile @code{asm} instructions relative 
8667 to other code, including across jump instructions. For example, on many 
8668 targets there is a system register that controls the rounding mode of 
8669 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8670 following PowerPC example, does not work reliably.
8672 @example
8673 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8674 sum = x + y;
8675 @end example
8677 The compiler may move the addition back before the volatile @code{asm}. To 
8678 make it work as expected, add an artificial dependency to the @code{asm} by 
8679 referencing a variable in the subsequent code, for example: 
8681 @example
8682 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8683 sum = x + y;
8684 @end example
8686 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8687 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8688 errors during compilation if your asm code defines symbols or labels. 
8689 Using @samp{%=} 
8690 (@pxref{AssemblerTemplate}) may help resolve this problem.
8692 @anchor{AssemblerTemplate}
8693 @subsubsection Assembler Template
8694 @cindex @code{asm} assembler template
8696 An assembler template is a literal string containing assembler instructions.
8697 The compiler replaces tokens in the template that refer 
8698 to inputs, outputs, and goto labels,
8699 and then outputs the resulting string to the assembler. The 
8700 string can contain any instructions recognized by the assembler, including 
8701 directives. GCC does not parse the assembler instructions 
8702 themselves and does not know what they mean or even whether they are valid 
8703 assembler input. However, it does count the statements 
8704 (@pxref{Size of an asm}).
8706 You may place multiple assembler instructions together in a single @code{asm} 
8707 string, separated by the characters normally used in assembly code for the 
8708 system. A combination that works in most places is a newline to break the 
8709 line, plus a tab character to move to the instruction field (written as 
8710 @samp{\n\t}). 
8711 Some assemblers allow semicolons as a line separator. However, note 
8712 that some assembler dialects use semicolons to start a comment. 
8714 Do not expect a sequence of @code{asm} statements to remain perfectly 
8715 consecutive after compilation, even when you are using the @code{volatile} 
8716 qualifier. If certain instructions need to remain consecutive in the output, 
8717 put them in a single multi-instruction asm statement.
8719 Accessing data from C programs without using input/output operands (such as 
8720 by using global symbols directly from the assembler template) may not work as 
8721 expected. Similarly, calling functions directly from an assembler template 
8722 requires a detailed understanding of the target assembler and ABI.
8724 Since GCC does not parse the assembler template,
8725 it has no visibility of any 
8726 symbols it references. This may result in GCC discarding those symbols as 
8727 unreferenced unless they are also listed as input, output, or goto operands.
8729 @subsubheading Special format strings
8731 In addition to the tokens described by the input, output, and goto operands, 
8732 these tokens have special meanings in the assembler template:
8734 @table @samp
8735 @item %% 
8736 Outputs a single @samp{%} into the assembler code.
8738 @item %= 
8739 Outputs a number that is unique to each instance of the @code{asm} 
8740 statement in the entire compilation. This option is useful when creating local 
8741 labels and referring to them multiple times in a single template that 
8742 generates multiple assembler instructions. 
8744 @item %@{
8745 @itemx %|
8746 @itemx %@}
8747 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8748 into the assembler code.  When unescaped, these characters have special
8749 meaning to indicate multiple assembler dialects, as described below.
8750 @end table
8752 @subsubheading Multiple assembler dialects in @code{asm} templates
8754 On targets such as x86, GCC supports multiple assembler dialects.
8755 The @option{-masm} option controls which dialect GCC uses as its 
8756 default for inline assembler. The target-specific documentation for the 
8757 @option{-masm} option contains the list of supported dialects, as well as the 
8758 default dialect if the option is not specified. This information may be 
8759 important to understand, since assembler code that works correctly when 
8760 compiled using one dialect will likely fail if compiled using another.
8761 @xref{x86 Options}.
8763 If your code needs to support multiple assembler dialects (for example, if 
8764 you are writing public headers that need to support a variety of compilation 
8765 options), use constructs of this form:
8767 @example
8768 @{ dialect0 | dialect1 | dialect2... @}
8769 @end example
8771 This construct outputs @code{dialect0} 
8772 when using dialect #0 to compile the code, 
8773 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8774 braces than the number of dialects the compiler supports, the construct 
8775 outputs nothing.
8777 For example, if an x86 compiler supports two dialects
8778 (@samp{att}, @samp{intel}), an 
8779 assembler template such as this:
8781 @example
8782 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8783 @end example
8785 @noindent
8786 is equivalent to one of
8788 @example
8789 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8790 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8791 @end example
8793 Using that same compiler, this code:
8795 @example
8796 "xchg@{l@}\t@{%%@}ebx, %1"
8797 @end example
8799 @noindent
8800 corresponds to either
8802 @example
8803 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8804 "xchg\tebx, %1"                    @r{/* intel dialect */}
8805 @end example
8807 There is no support for nesting dialect alternatives.
8809 @anchor{OutputOperands}
8810 @subsubsection Output Operands
8811 @cindex @code{asm} output operands
8813 An @code{asm} statement has zero or more output operands indicating the names
8814 of C variables modified by the assembler code.
8816 In this i386 example, @code{old} (referred to in the template string as 
8817 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8818 (@code{%2}) is an input:
8820 @example
8821 bool old;
8823 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8824          "sbb %0,%0"      // Use the CF to calculate old.
8825    : "=r" (old), "+rm" (*Base)
8826    : "Ir" (Offset)
8827    : "cc");
8829 return old;
8830 @end example
8832 Operands are separated by commas.  Each operand has this format:
8834 @example
8835 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8836 @end example
8838 @table @var
8839 @item asmSymbolicName
8840 Specifies a symbolic name for the operand.
8841 Reference the name in the assembler template 
8842 by enclosing it in square brackets 
8843 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8844 that contains the definition. Any valid C variable name is acceptable, 
8845 including names already defined in the surrounding code. No two operands 
8846 within the same @code{asm} statement can use the same symbolic name.
8848 When not using an @var{asmSymbolicName}, use the (zero-based) position
8849 of the operand 
8850 in the list of operands in the assembler template. For example if there are 
8851 three output operands, use @samp{%0} in the template to refer to the first, 
8852 @samp{%1} for the second, and @samp{%2} for the third. 
8854 @item constraint
8855 A string constant specifying constraints on the placement of the operand; 
8856 @xref{Constraints}, for details.
8858 Output constraints must begin with either @samp{=} (a variable overwriting an 
8859 existing value) or @samp{+} (when reading and writing). When using 
8860 @samp{=}, do not assume the location contains the existing value
8861 on entry to the @code{asm}, except 
8862 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8864 After the prefix, there must be one or more additional constraints 
8865 (@pxref{Constraints}) that describe where the value resides. Common 
8866 constraints include @samp{r} for register and @samp{m} for memory. 
8867 When you list more than one possible location (for example, @code{"=rm"}),
8868 the compiler chooses the most efficient one based on the current context. 
8869 If you list as many alternates as the @code{asm} statement allows, you permit 
8870 the optimizers to produce the best possible code. 
8871 If you must use a specific register, but your Machine Constraints do not
8872 provide sufficient control to select the specific register you want, 
8873 local register variables may provide a solution (@pxref{Local Register 
8874 Variables}).
8876 @item cvariablename
8877 Specifies a C lvalue expression to hold the output, typically a variable name.
8878 The enclosing parentheses are a required part of the syntax.
8880 @end table
8882 When the compiler selects the registers to use to 
8883 represent the output operands, it does not use any of the clobbered registers 
8884 (@pxref{Clobbers and Scratch Registers}).
8886 Output operand expressions must be lvalues. The compiler cannot check whether 
8887 the operands have data types that are reasonable for the instruction being 
8888 executed. For output expressions that are not directly addressable (for 
8889 example a bit-field), the constraint must allow a register. In that case, GCC 
8890 uses the register as the output of the @code{asm}, and then stores that 
8891 register into the output. 
8893 Operands using the @samp{+} constraint modifier count as two operands 
8894 (that is, both as input and output) towards the total maximum of 30 operands
8895 per @code{asm} statement.
8897 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8898 operands that must not overlap an input.  Otherwise, 
8899 GCC may allocate the output operand in the same register as an unrelated 
8900 input operand, on the assumption that the assembler code consumes its 
8901 inputs before producing outputs. This assumption may be false if the assembler 
8902 code actually consists of more than one instruction.
8904 The same problem can occur if one output parameter (@var{a}) allows a register 
8905 constraint and another output parameter (@var{b}) allows a memory constraint.
8906 The code generated by GCC to access the memory address in @var{b} can contain
8907 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8908 registers to be inputs to the asm. As above, GCC assumes that such input
8909 registers are consumed before any outputs are written. This assumption may 
8910 result in incorrect behavior if the asm writes to @var{a} before using 
8911 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8912 ensures that modifying @var{a} does not affect the address referenced by 
8913 @var{b}. Otherwise, the location of @var{b} 
8914 is undefined if @var{a} is modified before using @var{b}.
8916 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8917 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8918 dependent. The list of supported modifiers for x86 is found at 
8919 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8921 If the C code that follows the @code{asm} makes no use of any of the output 
8922 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8923 optimizers from discarding the @code{asm} statement as unneeded 
8924 (see @ref{Volatile}).
8926 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8927 references the first output operand as @code{%0} (were there a second, it 
8928 would be @code{%1}, etc). The number of the first input operand is one greater 
8929 than that of the last output operand. In this i386 example, that makes 
8930 @code{Mask} referenced as @code{%1}:
8932 @example
8933 uint32_t Mask = 1234;
8934 uint32_t Index;
8936   asm ("bsfl %1, %0"
8937      : "=r" (Index)
8938      : "r" (Mask)
8939      : "cc");
8940 @end example
8942 That code overwrites the variable @code{Index} (@samp{=}),
8943 placing the value in a register (@samp{r}).
8944 Using the generic @samp{r} constraint instead of a constraint for a specific 
8945 register allows the compiler to pick the register to use, which can result 
8946 in more efficient code. This may not be possible if an assembler instruction 
8947 requires a specific register.
8949 The following i386 example uses the @var{asmSymbolicName} syntax.
8950 It produces the 
8951 same result as the code above, but some may consider it more readable or more 
8952 maintainable since reordering index numbers is not necessary when adding or 
8953 removing operands. The names @code{aIndex} and @code{aMask}
8954 are only used in this example to emphasize which 
8955 names get used where.
8956 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8958 @example
8959 uint32_t Mask = 1234;
8960 uint32_t Index;
8962   asm ("bsfl %[aMask], %[aIndex]"
8963      : [aIndex] "=r" (Index)
8964      : [aMask] "r" (Mask)
8965      : "cc");
8966 @end example
8968 Here are some more examples of output operands.
8970 @example
8971 uint32_t c = 1;
8972 uint32_t d;
8973 uint32_t *e = &c;
8975 asm ("mov %[e], %[d]"
8976    : [d] "=rm" (d)
8977    : [e] "rm" (*e));
8978 @end example
8980 Here, @code{d} may either be in a register or in memory. Since the compiler 
8981 might already have the current value of the @code{uint32_t} location
8982 pointed to by @code{e}
8983 in a register, you can enable it to choose the best location
8984 for @code{d} by specifying both constraints.
8986 @anchor{FlagOutputOperands}
8987 @subsubsection Flag Output Operands
8988 @cindex @code{asm} flag output operands
8990 Some targets have a special register that holds the ``flags'' for the
8991 result of an operation or comparison.  Normally, the contents of that
8992 register are either unmodifed by the asm, or the asm is considered to
8993 clobber the contents.
8995 On some targets, a special form of output operand exists by which
8996 conditions in the flags register may be outputs of the asm.  The set of
8997 conditions supported are target specific, but the general rule is that
8998 the output variable must be a scalar integer, and the value is boolean.
8999 When supported, the target defines the preprocessor symbol
9000 @code{__GCC_ASM_FLAG_OUTPUTS__}.
9002 Because of the special nature of the flag output operands, the constraint
9003 may not include alternatives.
9005 Most often, the target has only one flags register, and thus is an implied
9006 operand of many instructions.  In this case, the operand should not be
9007 referenced within the assembler template via @code{%0} etc, as there's
9008 no corresponding text in the assembly language.
9010 @table @asis
9011 @item x86 family
9012 The flag output constraints for the x86 family are of the form
9013 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
9014 conditions defined in the ISA manual for @code{j@var{cc}} or
9015 @code{set@var{cc}}.
9017 @table @code
9018 @item a
9019 ``above'' or unsigned greater than
9020 @item ae
9021 ``above or equal'' or unsigned greater than or equal
9022 @item b
9023 ``below'' or unsigned less than
9024 @item be
9025 ``below or equal'' or unsigned less than or equal
9026 @item c
9027 carry flag set
9028 @item e
9029 @itemx z
9030 ``equal'' or zero flag set
9031 @item g
9032 signed greater than
9033 @item ge
9034 signed greater than or equal
9035 @item l
9036 signed less than
9037 @item le
9038 signed less than or equal
9039 @item o
9040 overflow flag set
9041 @item p
9042 parity flag set
9043 @item s
9044 sign flag set
9045 @item na
9046 @itemx nae
9047 @itemx nb
9048 @itemx nbe
9049 @itemx nc
9050 @itemx ne
9051 @itemx ng
9052 @itemx nge
9053 @itemx nl
9054 @itemx nle
9055 @itemx no
9056 @itemx np
9057 @itemx ns
9058 @itemx nz
9059 ``not'' @var{flag}, or inverted versions of those above
9060 @end table
9062 @end table
9064 @anchor{InputOperands}
9065 @subsubsection Input Operands
9066 @cindex @code{asm} input operands
9067 @cindex @code{asm} expressions
9069 Input operands make values from C variables and expressions available to the 
9070 assembly code.
9072 Operands are separated by commas.  Each operand has this format:
9074 @example
9075 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
9076 @end example
9078 @table @var
9079 @item asmSymbolicName
9080 Specifies a symbolic name for the operand.
9081 Reference the name in the assembler template 
9082 by enclosing it in square brackets 
9083 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
9084 that contains the definition. Any valid C variable name is acceptable, 
9085 including names already defined in the surrounding code. No two operands 
9086 within the same @code{asm} statement can use the same symbolic name.
9088 When not using an @var{asmSymbolicName}, use the (zero-based) position
9089 of the operand 
9090 in the list of operands in the assembler template. For example if there are
9091 two output operands and three inputs,
9092 use @samp{%2} in the template to refer to the first input operand,
9093 @samp{%3} for the second, and @samp{%4} for the third. 
9095 @item constraint
9096 A string constant specifying constraints on the placement of the operand; 
9097 @xref{Constraints}, for details.
9099 Input constraint strings may not begin with either @samp{=} or @samp{+}.
9100 When you list more than one possible location (for example, @samp{"irm"}), 
9101 the compiler chooses the most efficient one based on the current context.
9102 If you must use a specific register, but your Machine Constraints do not
9103 provide sufficient control to select the specific register you want, 
9104 local register variables may provide a solution (@pxref{Local Register 
9105 Variables}).
9107 Input constraints can also be digits (for example, @code{"0"}). This indicates 
9108 that the specified input must be in the same place as the output constraint 
9109 at the (zero-based) index in the output constraint list. 
9110 When using @var{asmSymbolicName} syntax for the output operands,
9111 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
9113 @item cexpression
9114 This is the C variable or expression being passed to the @code{asm} statement 
9115 as input.  The enclosing parentheses are a required part of the syntax.
9117 @end table
9119 When the compiler selects the registers to use to represent the input 
9120 operands, it does not use any of the clobbered registers
9121 (@pxref{Clobbers and Scratch Registers}).
9123 If there are no output operands but there are input operands, place two 
9124 consecutive colons where the output operands would go:
9126 @example
9127 __asm__ ("some instructions"
9128    : /* No outputs. */
9129    : "r" (Offset / 8));
9130 @end example
9132 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
9133 (except for inputs tied to outputs). The compiler assumes that on exit from 
9134 the @code{asm} statement these operands contain the same values as they 
9135 had before executing the statement. 
9136 It is @emph{not} possible to use clobbers
9137 to inform the compiler that the values in these inputs are changing. One 
9138 common work-around is to tie the changing input variable to an output variable 
9139 that never gets used. Note, however, that if the code that follows the 
9140 @code{asm} statement makes no use of any of the output operands, the GCC 
9141 optimizers may discard the @code{asm} statement as unneeded 
9142 (see @ref{Volatile}).
9144 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
9145 instead of simply @samp{%2}). Typically these qualifiers are hardware 
9146 dependent. The list of supported modifiers for x86 is found at 
9147 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9149 In this example using the fictitious @code{combine} instruction, the 
9150 constraint @code{"0"} for input operand 1 says that it must occupy the same 
9151 location as output operand 0. Only input operands may use numbers in 
9152 constraints, and they must each refer to an output operand. Only a number (or 
9153 the symbolic assembler name) in the constraint can guarantee that one operand 
9154 is in the same place as another. The mere fact that @code{foo} is the value of 
9155 both operands is not enough to guarantee that they are in the same place in 
9156 the generated assembler code.
9158 @example
9159 asm ("combine %2, %0" 
9160    : "=r" (foo) 
9161    : "0" (foo), "g" (bar));
9162 @end example
9164 Here is an example using symbolic names.
9166 @example
9167 asm ("cmoveq %1, %2, %[result]" 
9168    : [result] "=r"(result) 
9169    : "r" (test), "r" (new), "[result]" (old));
9170 @end example
9172 @anchor{Clobbers and Scratch Registers}
9173 @subsubsection Clobbers and Scratch Registers
9174 @cindex @code{asm} clobbers
9175 @cindex @code{asm} scratch registers
9177 While the compiler is aware of changes to entries listed in the output 
9178 operands, the inline @code{asm} code may modify more than just the outputs. For 
9179 example, calculations may require additional registers, or the processor may 
9180 overwrite a register as a side effect of a particular assembler instruction. 
9181 In order to inform the compiler of these changes, list them in the clobber 
9182 list. Clobber list items are either register names or the special clobbers 
9183 (listed below). Each clobber list item is a string constant 
9184 enclosed in double quotes and separated by commas.
9186 Clobber descriptions may not in any way overlap with an input or output 
9187 operand. For example, you may not have an operand describing a register class 
9188 with one member when listing that register in the clobber list. Variables 
9189 declared to live in specific registers (@pxref{Explicit Register 
9190 Variables}) and used 
9191 as @code{asm} input or output operands must have no part mentioned in the 
9192 clobber description. In particular, there is no way to specify that input 
9193 operands get modified without also specifying them as output operands.
9195 When the compiler selects which registers to use to represent input and output 
9196 operands, it does not use any of the clobbered registers. As a result, 
9197 clobbered registers are available for any use in the assembler code.
9199 Here is a realistic example for the VAX showing the use of clobbered 
9200 registers: 
9202 @example
9203 asm volatile ("movc3 %0, %1, %2"
9204                    : /* No outputs. */
9205                    : "g" (from), "g" (to), "g" (count)
9206                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9207 @end example
9209 Also, there are two special clobber arguments:
9211 @table @code
9212 @item "cc"
9213 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
9214 register. On some machines, GCC represents the condition codes as a specific 
9215 hardware register; @code{"cc"} serves to name this register.
9216 On other machines, condition code handling is different, 
9217 and specifying @code{"cc"} has no effect. But 
9218 it is valid no matter what the target.
9220 @item "memory"
9221 The @code{"memory"} clobber tells the compiler that the assembly code
9222 performs memory 
9223 reads or writes to items other than those listed in the input and output 
9224 operands (for example, accessing the memory pointed to by one of the input 
9225 parameters). To ensure memory contains correct values, GCC may need to flush 
9226 specific register values to memory before executing the @code{asm}. Further, 
9227 the compiler does not assume that any values read from memory before an 
9228 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
9229 needed.  
9230 Using the @code{"memory"} clobber effectively forms a read/write
9231 memory barrier for the compiler.
9233 Note that this clobber does not prevent the @emph{processor} from doing 
9234 speculative reads past the @code{asm} statement. To prevent that, you need 
9235 processor-specific fence instructions.
9237 @end table
9239 Flushing registers to memory has performance implications and may be
9240 an issue for time-sensitive code.  You can provide better information
9241 to GCC to avoid this, as shown in the following examples.  At a
9242 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9243 need to be flushed.
9245 Here is a fictitious sum of squares instruction, that takes two
9246 pointers to floating point values in memory and produces a floating
9247 point register output.
9248 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9249 parameters, once to specify memory accessed, and once to specify a
9250 base register used by the @code{asm}.  You won't normally be wasting a
9251 register by doing this as GCC can use the same register for both
9252 purposes.  However, it would be foolish to use both @code{%1} and
9253 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9254 same.  In fact, @code{%3} may well not be a register.  It might be a
9255 symbolic memory reference to the object pointed to by @code{x}.
9257 @smallexample
9258 asm ("sumsq %0, %1, %2"
9259      : "+f" (result)
9260      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9261 @end smallexample
9263 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9264 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9265 must be specified as input/output because the @code{asm} modifies
9266 them.
9268 @smallexample
9269 asm ("vecmul %0, %1, %2"
9270      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9271      : "m" (*x), "m" (*y));
9272 @end smallexample
9274 An x86 example where the string memory argument is of unknown length.
9276 @smallexample
9277 asm("repne scasb"
9278     : "=c" (count), "+D" (p)
9279     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9280 @end smallexample
9282 If you know the above will only be reading a ten byte array then you
9283 could instead use a memory input like:
9284 @code{"m" (*(const char (*)[10]) p)}.
9286 Here is an example of a PowerPC vector scale implemented in assembly,
9287 complete with vector and condition code clobbers, and some initialized
9288 offset registers that are unchanged by the @code{asm}.
9290 @smallexample
9291 void
9292 dscal (size_t n, double *x, double alpha)
9294   asm ("/* lots of asm here */"
9295        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9296        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9297          "b" (80), "b" (96), "b" (112)
9298        : "cr0",
9299          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9300          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9302 @end smallexample
9304 Rather than allocating fixed registers via clobbers to provide scratch
9305 registers for an @code{asm} statement, an alternative is to define a
9306 variable and make it an early-clobber output as with @code{a2} and
9307 @code{a3} in the example below.  This gives the compiler register
9308 allocator more freedom.  You can also define a variable and make it an
9309 output tied to an input as with @code{a0} and @code{a1}, tied
9310 respectively to @code{ap} and @code{lda}.  Of course, with tied
9311 outputs your @code{asm} can't use the input value after modifying the
9312 output register since they are one and the same register.  What's
9313 more, if you omit the early-clobber on the output, it is possible that
9314 GCC might allocate the same register to another of the inputs if GCC
9315 could prove they had the same value on entry to the @code{asm}.  This
9316 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
9317 might conceivably be known to have the value 16 and without an
9318 early-clobber share the same register as @code{%11}.  On the other
9319 hand, @code{ap} can't be the same as any of the other inputs, so an
9320 early-clobber on @code{a0} is not needed.  It is also not desirable in
9321 this case.  An early-clobber on @code{a0} would cause GCC to allocate
9322 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9323 input.  Note that tying an input to an output is the way to set up an
9324 initialized temporary register modified by an @code{asm} statement.
9325 An input not tied to an output is assumed by GCC to be unchanged, for
9326 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9327 use that register in following code if the value 16 happened to be
9328 needed.  You can even use a normal @code{asm} output for a scratch if
9329 all inputs that might share the same register are consumed before the
9330 scratch is used.  The VSX registers clobbered by the @code{asm}
9331 statement could have used this technique except for GCC's limit on the
9332 number of @code{asm} parameters.
9334 @smallexample
9335 static void
9336 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9337                   const double *x, double *y, double alpha)
9339   double *a0;
9340   double *a1;
9341   double *a2;
9342   double *a3;
9344   __asm__
9345     (
9346      /* lots of asm here */
9347      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9348      "#a0=%3 a1=%4 a2=%5 a3=%6"
9349      :
9350        "+m" (*(double (*)[n]) y),
9351        "+&r" (n),       // 1
9352        "+b" (y),        // 2
9353        "=b" (a0),       // 3
9354        "=&b" (a1),      // 4
9355        "=&b" (a2),      // 5
9356        "=&b" (a3)       // 6
9357      :
9358        "m" (*(const double (*)[n]) x),
9359        "m" (*(const double (*)[]) ap),
9360        "d" (alpha),     // 9
9361        "r" (x),         // 10
9362        "b" (16),        // 11
9363        "3" (ap),        // 12
9364        "4" (lda)        // 13
9365      :
9366        "cr0",
9367        "vs32","vs33","vs34","vs35","vs36","vs37",
9368        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9369      );
9371 @end smallexample
9373 @anchor{GotoLabels}
9374 @subsubsection Goto Labels
9375 @cindex @code{asm} goto labels
9377 @code{asm goto} allows assembly code to jump to one or more C labels.  The
9378 @var{GotoLabels} section in an @code{asm goto} statement contains 
9379 a comma-separated 
9380 list of all C labels to which the assembler code may jump. GCC assumes that 
9381 @code{asm} execution falls through to the next statement (if this is not the 
9382 case, consider using the @code{__builtin_unreachable} intrinsic after the 
9383 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
9384 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
9385 Attributes}).
9387 An @code{asm goto} statement cannot have outputs.
9388 This is due to an internal restriction of 
9389 the compiler: control transfer instructions cannot have outputs. 
9390 If the assembler code does modify anything, use the @code{"memory"} clobber 
9391 to force the 
9392 optimizers to flush all register values to memory and reload them if 
9393 necessary after the @code{asm} statement.
9395 Also note that an @code{asm goto} statement is always implicitly
9396 considered volatile.
9398 To reference a label in the assembler template,
9399 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9400 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9401 operands.  For example, if the @code{asm} has three inputs and references two 
9402 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9404 Alternately, you can reference labels using the actual C label name enclosed
9405 in brackets.  For example, to reference a label named @code{carry}, you can
9406 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9407 section when using this approach.
9409 Here is an example of @code{asm goto} for i386:
9411 @example
9412 asm goto (
9413     "btl %1, %0\n\t"
9414     "jc %l2"
9415     : /* No outputs. */
9416     : "r" (p1), "r" (p2) 
9417     : "cc" 
9418     : carry);
9420 return 0;
9422 carry:
9423 return 1;
9424 @end example
9426 The following example shows an @code{asm goto} that uses a memory clobber.
9428 @example
9429 int frob(int x)
9431   int y;
9432   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9433             : /* No outputs. */
9434             : "r"(x), "r"(&y)
9435             : "r5", "memory" 
9436             : error);
9437   return y;
9438 error:
9439   return -1;
9441 @end example
9443 @anchor{x86Operandmodifiers}
9444 @subsubsection x86 Operand Modifiers
9446 References to input, output, and goto operands in the assembler template
9447 of extended @code{asm} statements can use 
9448 modifiers to affect the way the operands are formatted in 
9449 the code output to the assembler. For example, the 
9450 following code uses the @samp{h} and @samp{b} modifiers for x86:
9452 @example
9453 uint16_t  num;
9454 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9455 @end example
9457 @noindent
9458 These modifiers generate this assembler code:
9460 @example
9461 xchg %ah, %al
9462 @end example
9464 The rest of this discussion uses the following code for illustrative purposes.
9466 @example
9467 int main()
9469    int iInt = 1;
9471 top:
9473    asm volatile goto ("some assembler instructions here"
9474    : /* No outputs. */
9475    : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9476    : /* No clobbers. */
9477    : top);
9479 @end example
9481 With no modifiers, this is what the output from the operands would be
9482 for the @samp{att} and @samp{intel} dialects of assembler:
9484 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9485 @headitem Operand @tab @samp{att} @tab @samp{intel}
9486 @item @code{%0}
9487 @tab @code{%eax}
9488 @tab @code{eax}
9489 @item @code{%1}
9490 @tab @code{$2}
9491 @tab @code{2}
9492 @item @code{%3}
9493 @tab @code{$.L3}
9494 @tab @code{OFFSET FLAT:.L3}
9495 @end multitable
9497 The table below shows the list of supported modifiers and their effects.
9499 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9500 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9501 @item @code{a}
9502 @tab Print an absolute memory reference.
9503 @tab @code{%A0}
9504 @tab @code{*%rax}
9505 @tab @code{rax}
9506 @item @code{b}
9507 @tab Print the QImode name of the register.
9508 @tab @code{%b0}
9509 @tab @code{%al}
9510 @tab @code{al}
9511 @item @code{c}
9512 @tab Require a constant operand and print the constant expression with no punctuation.
9513 @tab @code{%c1}
9514 @tab @code{2}
9515 @tab @code{2}
9516 @item @code{E}
9517 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9518 Otherwise mode is unspecified (VOIDmode).
9519 @tab @code{%E1}
9520 @tab @code{%(rax)}
9521 @tab @code{[rax]}
9522 @item @code{h}
9523 @tab Print the QImode name for a ``high'' register.
9524 @tab @code{%h0}
9525 @tab @code{%ah}
9526 @tab @code{ah}
9527 @item @code{H}
9528 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9529 high 8 bytes of SSE values. For a memref in (%rax), it generates
9530 @tab @code{%H0}
9531 @tab @code{8(%rax)}
9532 @tab @code{8[rax]}
9533 @item @code{k}
9534 @tab Print the SImode name of the register.
9535 @tab @code{%k0}
9536 @tab @code{%eax}
9537 @tab @code{eax}
9538 @item @code{l}
9539 @tab Print the label name with no punctuation.
9540 @tab @code{%l3}
9541 @tab @code{.L3}
9542 @tab @code{.L3}
9543 @item @code{p}
9544 @tab Print raw symbol name (without syntax-specific prefixes).
9545 @tab @code{%p2}
9546 @tab @code{42}
9547 @tab @code{42}
9548 @item @code{P}
9549 @tab If used for a function, print the PLT suffix and generate PIC code.
9550 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9551 foo(). If used for a constant, drop all syntax-specific prefixes and
9552 issue the bare constant. See @code{p} above.
9553 @item @code{q}
9554 @tab Print the DImode name of the register.
9555 @tab @code{%q0}
9556 @tab @code{%rax}
9557 @tab @code{rax}
9558 @item @code{w}
9559 @tab Print the HImode name of the register.
9560 @tab @code{%w0}
9561 @tab @code{%ax}
9562 @tab @code{ax}
9563 @item @code{z}
9564 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9565 @tab @code{%z0}
9566 @tab @code{l}
9567 @tab 
9568 @end multitable
9570 @code{V} is a special modifier which prints the name of the full integer
9571 register without @code{%}.
9573 @anchor{x86floatingpointasmoperands}
9574 @subsubsection x86 Floating-Point @code{asm} Operands
9576 On x86 targets, there are several rules on the usage of stack-like registers
9577 in the operands of an @code{asm}.  These rules apply only to the operands
9578 that are stack-like registers:
9580 @enumerate
9581 @item
9582 Given a set of input registers that die in an @code{asm}, it is
9583 necessary to know which are implicitly popped by the @code{asm}, and
9584 which must be explicitly popped by GCC@.
9586 An input register that is implicitly popped by the @code{asm} must be
9587 explicitly clobbered, unless it is constrained to match an
9588 output operand.
9590 @item
9591 For any input register that is implicitly popped by an @code{asm}, it is
9592 necessary to know how to adjust the stack to compensate for the pop.
9593 If any non-popped input is closer to the top of the reg-stack than
9594 the implicitly popped register, it would not be possible to know what the
9595 stack looked like---it's not clear how the rest of the stack ``slides
9596 up''.
9598 All implicitly popped input registers must be closer to the top of
9599 the reg-stack than any input that is not implicitly popped.
9601 It is possible that if an input dies in an @code{asm}, the compiler might
9602 use the input register for an output reload.  Consider this example:
9604 @smallexample
9605 asm ("foo" : "=t" (a) : "f" (b));
9606 @end smallexample
9608 @noindent
9609 This code says that input @code{b} is not popped by the @code{asm}, and that
9610 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9611 deeper after the @code{asm} than it was before.  But, it is possible that
9612 reload may think that it can use the same register for both the input and
9613 the output.
9615 To prevent this from happening,
9616 if any input operand uses the @samp{f} constraint, all output register
9617 constraints must use the @samp{&} early-clobber modifier.
9619 The example above is correctly written as:
9621 @smallexample
9622 asm ("foo" : "=&t" (a) : "f" (b));
9623 @end smallexample
9625 @item
9626 Some operands need to be in particular places on the stack.  All
9627 output operands fall in this category---GCC has no other way to
9628 know which registers the outputs appear in unless you indicate
9629 this in the constraints.
9631 Output operands must specifically indicate which register an output
9632 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9633 constraints must select a class with a single register.
9635 @item
9636 Output operands may not be ``inserted'' between existing stack registers.
9637 Since no 387 opcode uses a read/write operand, all output operands
9638 are dead before the @code{asm}, and are pushed by the @code{asm}.
9639 It makes no sense to push anywhere but the top of the reg-stack.
9641 Output operands must start at the top of the reg-stack: output
9642 operands may not ``skip'' a register.
9644 @item
9645 Some @code{asm} statements may need extra stack space for internal
9646 calculations.  This can be guaranteed by clobbering stack registers
9647 unrelated to the inputs and outputs.
9649 @end enumerate
9651 This @code{asm}
9652 takes one input, which is internally popped, and produces two outputs.
9654 @smallexample
9655 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9656 @end smallexample
9658 @noindent
9659 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9660 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9661 for the compiler to know that @code{fyl2xp1} pops both inputs.
9663 @smallexample
9664 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9665 @end smallexample
9667 @lowersections
9668 @include md.texi
9669 @raisesections
9671 @node Asm Labels
9672 @subsection Controlling Names Used in Assembler Code
9673 @cindex assembler names for identifiers
9674 @cindex names used in assembler code
9675 @cindex identifiers, names in assembler code
9677 You can specify the name to be used in the assembler code for a C
9678 function or variable by writing the @code{asm} (or @code{__asm__})
9679 keyword after the declarator.
9680 It is up to you to make sure that the assembler names you choose do not
9681 conflict with any other assembler symbols, or reference registers.
9683 @subsubheading Assembler names for data:
9685 This sample shows how to specify the assembler name for data:
9687 @smallexample
9688 int foo asm ("myfoo") = 2;
9689 @end smallexample
9691 @noindent
9692 This specifies that the name to be used for the variable @code{foo} in
9693 the assembler code should be @samp{myfoo} rather than the usual
9694 @samp{_foo}.
9696 On systems where an underscore is normally prepended to the name of a C
9697 variable, this feature allows you to define names for the
9698 linker that do not start with an underscore.
9700 GCC does not support using this feature with a non-static local variable 
9701 since such variables do not have assembler names.  If you are
9702 trying to put the variable in a particular register, see 
9703 @ref{Explicit Register Variables}.
9705 @subsubheading Assembler names for functions:
9707 To specify the assembler name for functions, write a declaration for the 
9708 function before its definition and put @code{asm} there, like this:
9710 @smallexample
9711 int func (int x, int y) asm ("MYFUNC");
9712      
9713 int func (int x, int y)
9715    /* @r{@dots{}} */
9716 @end smallexample
9718 @noindent
9719 This specifies that the name to be used for the function @code{func} in
9720 the assembler code should be @code{MYFUNC}.
9722 @node Explicit Register Variables
9723 @subsection Variables in Specified Registers
9724 @anchor{Explicit Reg Vars}
9725 @cindex explicit register variables
9726 @cindex variables in specified registers
9727 @cindex specified registers
9729 GNU C allows you to associate specific hardware registers with C 
9730 variables.  In almost all cases, allowing the compiler to assign
9731 registers produces the best code.  However under certain unusual
9732 circumstances, more precise control over the variable storage is 
9733 required.
9735 Both global and local variables can be associated with a register.  The
9736 consequences of performing this association are very different between
9737 the two, as explained in the sections below.
9739 @menu
9740 * Global Register Variables::   Variables declared at global scope.
9741 * Local Register Variables::    Variables declared within a function.
9742 @end menu
9744 @node Global Register Variables
9745 @subsubsection Defining Global Register Variables
9746 @anchor{Global Reg Vars}
9747 @cindex global register variables
9748 @cindex registers, global variables in
9749 @cindex registers, global allocation
9751 You can define a global register variable and associate it with a specified 
9752 register like this:
9754 @smallexample
9755 register int *foo asm ("r12");
9756 @end smallexample
9758 @noindent
9759 Here @code{r12} is the name of the register that should be used. Note that 
9760 this is the same syntax used for defining local register variables, but for 
9761 a global variable the declaration appears outside a function. The 
9762 @code{register} keyword is required, and cannot be combined with 
9763 @code{static}. The register name must be a valid register name for the
9764 target platform.
9766 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9767 the outcome may be contrary to expectations.  In  particular, using the
9768 @code{volatile} qualifier does not fully prevent the compiler from
9769 optimizing accesses to the register.
9771 Registers are a scarce resource on most systems and allowing the 
9772 compiler to manage their usage usually results in the best code. However, 
9773 under special circumstances it can make sense to reserve some globally.
9774 For example this may be useful in programs such as programming language 
9775 interpreters that have a couple of global variables that are accessed 
9776 very often.
9778 After defining a global register variable, for the current compilation
9779 unit:
9781 @itemize @bullet
9782 @item If the register is a call-saved register, call ABI is affected:
9783 the register will not be restored in function epilogue sequences after
9784 the variable has been assigned.  Therefore, functions cannot safely
9785 return to callers that assume standard ABI.
9786 @item Conversely, if the register is a call-clobbered register, making
9787 calls to functions that use standard ABI may lose contents of the variable.
9788 Such calls may be created by the compiler even if none are evident in
9789 the original program, for example when libgcc functions are used to
9790 make up for unavailable instructions.
9791 @item Accesses to the variable may be optimized as usual and the register
9792 remains available for allocation and use in any computations, provided that
9793 observable values of the variable are not affected.
9794 @item If the variable is referenced in inline assembly, the type of access
9795 must be provided to the compiler via constraints (@pxref{Constraints}).
9796 Accesses from basic asms are not supported.
9797 @end itemize
9799 Note that these points @emph{only} apply to code that is compiled with the
9800 definition. The behavior of code that is merely linked in (for example 
9801 code from libraries) is not affected.
9803 If you want to recompile source files that do not actually use your global 
9804 register variable so they do not use the specified register for any other 
9805 purpose, you need not actually add the global register declaration to 
9806 their source code. It suffices to specify the compiler option 
9807 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9808 register.
9810 @subsubheading Declaring the variable
9812 Global register variables can not have initial values, because an
9813 executable file has no means to supply initial contents for a register.
9815 When selecting a register, choose one that is normally saved and 
9816 restored by function calls on your machine. This ensures that code
9817 which is unaware of this reservation (such as library routines) will 
9818 restore it before returning.
9820 On machines with register windows, be sure to choose a global
9821 register that is not affected magically by the function call mechanism.
9823 @subsubheading Using the variable
9825 @cindex @code{qsort}, and global register variables
9826 When calling routines that are not aware of the reservation, be 
9827 cautious if those routines call back into code which uses them. As an 
9828 example, if you call the system library version of @code{qsort}, it may 
9829 clobber your registers during execution, but (if you have selected 
9830 appropriate registers) it will restore them before returning. However 
9831 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9832 function. As a result, global values will not reliably be available to 
9833 the comparison function unless the @code{qsort} function itself is rebuilt.
9835 Similarly, it is not safe to access the global register variables from signal
9836 handlers or from more than one thread of control. Unless you recompile 
9837 them specially for the task at hand, the system library routines may 
9838 temporarily use the register for other things.  Furthermore, since the register
9839 is not reserved exclusively for the variable, accessing it from handlers of
9840 asynchronous signals may observe unrelated temporary values residing in the
9841 register.
9843 @cindex register variable after @code{longjmp}
9844 @cindex global register after @code{longjmp}
9845 @cindex value after @code{longjmp}
9846 @findex longjmp
9847 @findex setjmp
9848 On most machines, @code{longjmp} restores to each global register
9849 variable the value it had at the time of the @code{setjmp}. On some
9850 machines, however, @code{longjmp} does not change the value of global
9851 register variables. To be portable, the function that called @code{setjmp}
9852 should make other arrangements to save the values of the global register
9853 variables, and to restore them in a @code{longjmp}. This way, the same
9854 thing happens regardless of what @code{longjmp} does.
9856 @node Local Register Variables
9857 @subsubsection Specifying Registers for Local Variables
9858 @anchor{Local Reg Vars}
9859 @cindex local variables, specifying registers
9860 @cindex specifying registers for local variables
9861 @cindex registers for local variables
9863 You can define a local register variable and associate it with a specified 
9864 register like this:
9866 @smallexample
9867 register int *foo asm ("r12");
9868 @end smallexample
9870 @noindent
9871 Here @code{r12} is the name of the register that should be used.  Note
9872 that this is the same syntax used for defining global register variables, 
9873 but for a local variable the declaration appears within a function.  The 
9874 @code{register} keyword is required, and cannot be combined with 
9875 @code{static}.  The register name must be a valid register name for the
9876 target platform.
9878 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9879 the outcome may be contrary to expectations. In particular, when the
9880 @code{const} qualifier is used, the compiler may substitute the
9881 variable with its initializer in @code{asm} statements, which may cause
9882 the corresponding operand to appear in a different register.
9884 As with global register variables, it is recommended that you choose 
9885 a register that is normally saved and restored by function calls on your 
9886 machine, so that calls to library routines will not clobber it.
9888 The only supported use for this feature is to specify registers
9889 for input and output operands when calling Extended @code{asm} 
9890 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9891 particular machine don't provide sufficient control to select the desired 
9892 register.  To force an operand into a register, create a local variable 
9893 and specify the register name after the variable's declaration.  Then use 
9894 the local variable for the @code{asm} operand and specify any constraint 
9895 letter that matches the register:
9897 @smallexample
9898 register int *p1 asm ("r0") = @dots{};
9899 register int *p2 asm ("r1") = @dots{};
9900 register int *result asm ("r0");
9901 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9902 @end smallexample
9904 @emph{Warning:} In the above example, be aware that a register (for example 
9905 @code{r0}) can be call-clobbered by subsequent code, including function 
9906 calls and library calls for arithmetic operators on other variables (for 
9907 example the initialization of @code{p2}).  In this case, use temporary 
9908 variables for expressions between the register assignments:
9910 @smallexample
9911 int t1 = @dots{};
9912 register int *p1 asm ("r0") = @dots{};
9913 register int *p2 asm ("r1") = t1;
9914 register int *result asm ("r0");
9915 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9916 @end smallexample
9918 Defining a register variable does not reserve the register.  Other than
9919 when invoking the Extended @code{asm}, the contents of the specified 
9920 register are not guaranteed.  For this reason, the following uses 
9921 are explicitly @emph{not} supported.  If they appear to work, it is only 
9922 happenstance, and may stop working as intended due to (seemingly) 
9923 unrelated changes in surrounding code, or even minor changes in the 
9924 optimization of a future version of gcc:
9926 @itemize @bullet
9927 @item Passing parameters to or from Basic @code{asm}
9928 @item Passing parameters to or from Extended @code{asm} without using input 
9929 or output operands.
9930 @item Passing parameters to or from routines written in assembler (or
9931 other languages) using non-standard calling conventions.
9932 @end itemize
9934 Some developers use Local Register Variables in an attempt to improve 
9935 gcc's allocation of registers, especially in large functions.  In this 
9936 case the register name is essentially a hint to the register allocator.
9937 While in some instances this can generate better code, improvements are
9938 subject to the whims of the allocator/optimizers.  Since there are no
9939 guarantees that your improvements won't be lost, this usage of Local
9940 Register Variables is discouraged.
9942 On the MIPS platform, there is related use for local register variables 
9943 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9944 Defining coprocessor specifics for MIPS targets, gccint, 
9945 GNU Compiler Collection (GCC) Internals}).
9947 @node Size of an asm
9948 @subsection Size of an @code{asm}
9950 Some targets require that GCC track the size of each instruction used
9951 in order to generate correct code.  Because the final length of the
9952 code produced by an @code{asm} statement is only known by the
9953 assembler, GCC must make an estimate as to how big it will be.  It
9954 does this by counting the number of instructions in the pattern of the
9955 @code{asm} and multiplying that by the length of the longest
9956 instruction supported by that processor.  (When working out the number
9957 of instructions, it assumes that any occurrence of a newline or of
9958 whatever statement separator character is supported by the assembler --
9959 typically @samp{;} --- indicates the end of an instruction.)
9961 Normally, GCC's estimate is adequate to ensure that correct
9962 code is generated, but it is possible to confuse the compiler if you use
9963 pseudo instructions or assembler macros that expand into multiple real
9964 instructions, or if you use assembler directives that expand to more
9965 space in the object file than is needed for a single instruction.
9966 If this happens then the assembler may produce a diagnostic saying that
9967 a label is unreachable.
9969 @node Alternate Keywords
9970 @section Alternate Keywords
9971 @cindex alternate keywords
9972 @cindex keywords, alternate
9974 @option{-ansi} and the various @option{-std} options disable certain
9975 keywords.  This causes trouble when you want to use GNU C extensions, or
9976 a general-purpose header file that should be usable by all programs,
9977 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9978 @code{inline} are not available in programs compiled with
9979 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9980 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9981 ISO C99 keyword
9982 @code{restrict} is only available when @option{-std=gnu99} (which will
9983 eventually be the default) or @option{-std=c99} (or the equivalent
9984 @option{-std=iso9899:1999}), or an option for a later standard
9985 version, is used.
9987 The way to solve these problems is to put @samp{__} at the beginning and
9988 end of each problematical keyword.  For example, use @code{__asm__}
9989 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9991 Other C compilers won't accept these alternative keywords; if you want to
9992 compile with another compiler, you can define the alternate keywords as
9993 macros to replace them with the customary keywords.  It looks like this:
9995 @smallexample
9996 #ifndef __GNUC__
9997 #define __asm__ asm
9998 #endif
9999 @end smallexample
10001 @findex __extension__
10002 @opindex pedantic
10003 @option{-pedantic} and other options cause warnings for many GNU C extensions.
10004 You can
10005 prevent such warnings within one expression by writing
10006 @code{__extension__} before the expression.  @code{__extension__} has no
10007 effect aside from this.
10009 @node Incomplete Enums
10010 @section Incomplete @code{enum} Types
10012 You can define an @code{enum} tag without specifying its possible values.
10013 This results in an incomplete type, much like what you get if you write
10014 @code{struct foo} without describing the elements.  A later declaration
10015 that does specify the possible values completes the type.
10017 You cannot allocate variables or storage using the type while it is
10018 incomplete.  However, you can work with pointers to that type.
10020 This extension may not be very useful, but it makes the handling of
10021 @code{enum} more consistent with the way @code{struct} and @code{union}
10022 are handled.
10024 This extension is not supported by GNU C++.
10026 @node Function Names
10027 @section Function Names as Strings
10028 @cindex @code{__func__} identifier
10029 @cindex @code{__FUNCTION__} identifier
10030 @cindex @code{__PRETTY_FUNCTION__} identifier
10032 GCC provides three magic constants that hold the name of the current
10033 function as a string.  In C++11 and later modes, all three are treated
10034 as constant expressions and can be used in @code{constexpr} constexts.
10035 The first of these constants is @code{__func__}, which is part of
10036 the C99 standard:
10038 The identifier @code{__func__} is implicitly declared by the translator
10039 as if, immediately following the opening brace of each function
10040 definition, the declaration
10042 @smallexample
10043 static const char __func__[] = "function-name";
10044 @end smallexample
10046 @noindent
10047 appeared, where function-name is the name of the lexically-enclosing
10048 function.  This name is the unadorned name of the function.  As an
10049 extension, at file (or, in C++, namespace scope), @code{__func__}
10050 evaluates to the empty string.
10052 @code{__FUNCTION__} is another name for @code{__func__}, provided for
10053 backward compatibility with old versions of GCC.
10055 In C, @code{__PRETTY_FUNCTION__} is yet another name for
10056 @code{__func__}, except that at file (or, in C++, namespace scope),
10057 it evaluates to the string @code{"top level"}.  In addition, in C++,
10058 @code{__PRETTY_FUNCTION__} contains the signature of the function as
10059 well as its bare name.  For example, this program:
10061 @smallexample
10062 extern "C" int printf (const char *, ...);
10064 class a @{
10065  public:
10066   void sub (int i)
10067     @{
10068       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
10069       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
10070     @}
10074 main (void)
10076   a ax;
10077   ax.sub (0);
10078   return 0;
10080 @end smallexample
10082 @noindent
10083 gives this output:
10085 @smallexample
10086 __FUNCTION__ = sub
10087 __PRETTY_FUNCTION__ = void a::sub(int)
10088 @end smallexample
10090 These identifiers are variables, not preprocessor macros, and may not
10091 be used to initialize @code{char} arrays or be concatenated with string
10092 literals.
10094 @node Return Address
10095 @section Getting the Return or Frame Address of a Function
10097 These functions may be used to get information about the callers of a
10098 function.
10100 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
10101 This function returns the return address of the current function, or of
10102 one of its callers.  The @var{level} argument is number of frames to
10103 scan up the call stack.  A value of @code{0} yields the return address
10104 of the current function, a value of @code{1} yields the return address
10105 of the caller of the current function, and so forth.  When inlining
10106 the expected behavior is that the function returns the address of
10107 the function that is returned to.  To work around this behavior use
10108 the @code{noinline} function attribute.
10110 The @var{level} argument must be a constant integer.
10112 On some machines it may be impossible to determine the return address of
10113 any function other than the current one; in such cases, or when the top
10114 of the stack has been reached, this function returns @code{0} or a
10115 random value.  In addition, @code{__builtin_frame_address} may be used
10116 to determine if the top of the stack has been reached.
10118 Additional post-processing of the returned value may be needed, see
10119 @code{__builtin_extract_return_addr}.
10121 Calling this function with a nonzero argument can have unpredictable
10122 effects, including crashing the calling program.  As a result, calls
10123 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10124 option is in effect.  Such calls should only be made in debugging
10125 situations.
10126 @end deftypefn
10128 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
10129 The address as returned by @code{__builtin_return_address} may have to be fed
10130 through this function to get the actual encoded address.  For example, on the
10131 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
10132 platforms an offset has to be added for the true next instruction to be
10133 executed.
10135 If no fixup is needed, this function simply passes through @var{addr}.
10136 @end deftypefn
10138 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10139 This function does the reverse of @code{__builtin_extract_return_addr}.
10140 @end deftypefn
10142 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10143 This function is similar to @code{__builtin_return_address}, but it
10144 returns the address of the function frame rather than the return address
10145 of the function.  Calling @code{__builtin_frame_address} with a value of
10146 @code{0} yields the frame address of the current function, a value of
10147 @code{1} yields the frame address of the caller of the current function,
10148 and so forth.
10150 The frame is the area on the stack that holds local variables and saved
10151 registers.  The frame address is normally the address of the first word
10152 pushed on to the stack by the function.  However, the exact definition
10153 depends upon the processor and the calling convention.  If the processor
10154 has a dedicated frame pointer register, and the function has a frame,
10155 then @code{__builtin_frame_address} returns the value of the frame
10156 pointer register.
10158 On some machines it may be impossible to determine the frame address of
10159 any function other than the current one; in such cases, or when the top
10160 of the stack has been reached, this function returns @code{0} if
10161 the first frame pointer is properly initialized by the startup code.
10163 Calling this function with a nonzero argument can have unpredictable
10164 effects, including crashing the calling program.  As a result, calls
10165 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10166 option is in effect.  Such calls should only be made in debugging
10167 situations.
10168 @end deftypefn
10170 @node Vector Extensions
10171 @section Using Vector Instructions through Built-in Functions
10173 On some targets, the instruction set contains SIMD vector instructions which
10174 operate on multiple values contained in one large register at the same time.
10175 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10176 this way.
10178 The first step in using these extensions is to provide the necessary data
10179 types.  This should be done using an appropriate @code{typedef}:
10181 @smallexample
10182 typedef int v4si __attribute__ ((vector_size (16)));
10183 @end smallexample
10185 @noindent
10186 The @code{int} type specifies the base type, while the attribute specifies
10187 the vector size for the variable, measured in bytes.  For example, the
10188 declaration above causes the compiler to set the mode for the @code{v4si}
10189 type to be 16 bytes wide and divided into @code{int} sized units.  For
10190 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10191 corresponding mode of @code{foo} is @acronym{V4SI}.
10193 The @code{vector_size} attribute is only applicable to integral and
10194 float scalars, although arrays, pointers, and function return values
10195 are allowed in conjunction with this construct. Only sizes that are
10196 a power of two are currently allowed.
10198 All the basic integer types can be used as base types, both as signed
10199 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10200 @code{long long}.  In addition, @code{float} and @code{double} can be
10201 used to build floating-point vector types.
10203 Specifying a combination that is not valid for the current architecture
10204 causes GCC to synthesize the instructions using a narrower mode.
10205 For example, if you specify a variable of type @code{V4SI} and your
10206 architecture does not allow for this specific SIMD type, GCC
10207 produces code that uses 4 @code{SIs}.
10209 The types defined in this manner can be used with a subset of normal C
10210 operations.  Currently, GCC allows using the following operators
10211 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10213 The operations behave like C++ @code{valarrays}.  Addition is defined as
10214 the addition of the corresponding elements of the operands.  For
10215 example, in the code below, each of the 4 elements in @var{a} is
10216 added to the corresponding 4 elements in @var{b} and the resulting
10217 vector is stored in @var{c}.
10219 @smallexample
10220 typedef int v4si __attribute__ ((vector_size (16)));
10222 v4si a, b, c;
10224 c = a + b;
10225 @end smallexample
10227 Subtraction, multiplication, division, and the logical operations
10228 operate in a similar manner.  Likewise, the result of using the unary
10229 minus or complement operators on a vector type is a vector whose
10230 elements are the negative or complemented values of the corresponding
10231 elements in the operand.
10233 It is possible to use shifting operators @code{<<}, @code{>>} on
10234 integer-type vectors. The operation is defined as following: @code{@{a0,
10235 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10236 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10237 elements. 
10239 For convenience, it is allowed to use a binary vector operation
10240 where one operand is a scalar. In that case the compiler transforms
10241 the scalar operand into a vector where each element is the scalar from
10242 the operation. The transformation happens only if the scalar could be
10243 safely converted to the vector-element type.
10244 Consider the following code.
10246 @smallexample
10247 typedef int v4si __attribute__ ((vector_size (16)));
10249 v4si a, b, c;
10250 long l;
10252 a = b + 1;    /* a = b + @{1,1,1,1@}; */
10253 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
10255 a = l + a;    /* Error, cannot convert long to int. */
10256 @end smallexample
10258 Vectors can be subscripted as if the vector were an array with
10259 the same number of elements and base type.  Out of bound accesses
10260 invoke undefined behavior at run time.  Warnings for out of bound
10261 accesses for vector subscription can be enabled with
10262 @option{-Warray-bounds}.
10264 Vector comparison is supported with standard comparison
10265 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10266 vector expressions of integer-type or real-type. Comparison between
10267 integer-type vectors and real-type vectors are not supported.  The
10268 result of the comparison is a vector of the same width and number of
10269 elements as the comparison operands with a signed integral element
10270 type.
10272 Vectors are compared element-wise producing 0 when comparison is false
10273 and -1 (constant of the appropriate type where all bits are set)
10274 otherwise. Consider the following example.
10276 @smallexample
10277 typedef int v4si __attribute__ ((vector_size (16)));
10279 v4si a = @{1,2,3,4@};
10280 v4si b = @{3,2,1,4@};
10281 v4si c;
10283 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
10284 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
10285 @end smallexample
10287 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10288 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10289 integer vector with the same number of elements of the same size as @code{b}
10290 and @code{c}, computes all three arguments and creates a vector
10291 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
10292 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10293 As in the case of binary operations, this syntax is also accepted when
10294 one of @code{b} or @code{c} is a scalar that is then transformed into a
10295 vector. If both @code{b} and @code{c} are scalars and the type of
10296 @code{true?b:c} has the same size as the element type of @code{a}, then
10297 @code{b} and @code{c} are converted to a vector type whose elements have
10298 this type and with the same number of elements as @code{a}.
10300 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10301 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10302 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10303 For mixed operations between a scalar @code{s} and a vector @code{v},
10304 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10305 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10307 @findex __builtin_shuffle
10308 Vector shuffling is available using functions
10309 @code{__builtin_shuffle (vec, mask)} and
10310 @code{__builtin_shuffle (vec0, vec1, mask)}.
10311 Both functions construct a permutation of elements from one or two
10312 vectors and return a vector of the same type as the input vector(s).
10313 The @var{mask} is an integral vector with the same width (@var{W})
10314 and element count (@var{N}) as the output vector.
10316 The elements of the input vectors are numbered in memory ordering of
10317 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
10318 elements of @var{mask} are considered modulo @var{N} in the single-operand
10319 case and modulo @math{2*@var{N}} in the two-operand case.
10321 Consider the following example,
10323 @smallexample
10324 typedef int v4si __attribute__ ((vector_size (16)));
10326 v4si a = @{1,2,3,4@};
10327 v4si b = @{5,6,7,8@};
10328 v4si mask1 = @{0,1,1,3@};
10329 v4si mask2 = @{0,4,2,5@};
10330 v4si res;
10332 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
10333 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
10334 @end smallexample
10336 Note that @code{__builtin_shuffle} is intentionally semantically
10337 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10339 You can declare variables and use them in function calls and returns, as
10340 well as in assignments and some casts.  You can specify a vector type as
10341 a return type for a function.  Vector types can also be used as function
10342 arguments.  It is possible to cast from one vector type to another,
10343 provided they are of the same size (in fact, you can also cast vectors
10344 to and from other datatypes of the same size).
10346 You cannot operate between vectors of different lengths or different
10347 signedness without a cast.
10349 @node Offsetof
10350 @section Support for @code{offsetof}
10351 @findex __builtin_offsetof
10353 GCC implements for both C and C++ a syntactic extension to implement
10354 the @code{offsetof} macro.
10356 @smallexample
10357 primary:
10358         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10360 offsetof_member_designator:
10361           @code{identifier}
10362         | offsetof_member_designator "." @code{identifier}
10363         | offsetof_member_designator "[" @code{expr} "]"
10364 @end smallexample
10366 This extension is sufficient such that
10368 @smallexample
10369 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
10370 @end smallexample
10372 @noindent
10373 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
10374 may be dependent.  In either case, @var{member} may consist of a single
10375 identifier, or a sequence of member accesses and array references.
10377 @node __sync Builtins
10378 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10380 The following built-in functions
10381 are intended to be compatible with those described
10382 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10383 section 7.4.  As such, they depart from normal GCC practice by not using
10384 the @samp{__builtin_} prefix and also by being overloaded so that they
10385 work on multiple types.
10387 The definition given in the Intel documentation allows only for the use of
10388 the types @code{int}, @code{long}, @code{long long} or their unsigned
10389 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10390 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10391 Operations on pointer arguments are performed as if the operands were
10392 of the @code{uintptr_t} type.  That is, they are not scaled by the size
10393 of the type to which the pointer points.
10395 These functions are implemented in terms of the @samp{__atomic}
10396 builtins (@pxref{__atomic Builtins}).  They should not be used for new
10397 code which should use the @samp{__atomic} builtins instead.
10399 Not all operations are supported by all target processors.  If a particular
10400 operation cannot be implemented on the target processor, a warning is
10401 generated and a call to an external function is generated.  The external
10402 function carries the same name as the built-in version,
10403 with an additional suffix
10404 @samp{_@var{n}} where @var{n} is the size of the data type.
10406 @c ??? Should we have a mechanism to suppress this warning?  This is almost
10407 @c useful for implementing the operation under the control of an external
10408 @c mutex.
10410 In most cases, these built-in functions are considered a @dfn{full barrier}.
10411 That is,
10412 no memory operand is moved across the operation, either forward or
10413 backward.  Further, instructions are issued as necessary to prevent the
10414 processor from speculating loads across the operation and from queuing stores
10415 after the operation.
10417 All of the routines are described in the Intel documentation to take
10418 ``an optional list of variables protected by the memory barrier''.  It's
10419 not clear what is meant by that; it could mean that @emph{only} the
10420 listed variables are protected, or it could mean a list of additional
10421 variables to be protected.  The list is ignored by GCC which treats it as
10422 empty.  GCC interprets an empty list as meaning that all globally
10423 accessible variables should be protected.
10425 @table @code
10426 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10427 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10428 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10429 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10430 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10431 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10432 @findex __sync_fetch_and_add
10433 @findex __sync_fetch_and_sub
10434 @findex __sync_fetch_and_or
10435 @findex __sync_fetch_and_and
10436 @findex __sync_fetch_and_xor
10437 @findex __sync_fetch_and_nand
10438 These built-in functions perform the operation suggested by the name, and
10439 returns the value that had previously been in memory.  That is, operations
10440 on integer operands have the following semantics.  Operations on pointer
10441 arguments are performed as if the operands were of the @code{uintptr_t}
10442 type.  That is, they are not scaled by the size of the type to which
10443 the pointer points.
10445 @smallexample
10446 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10447 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
10448 @end smallexample
10450 The object pointed to by the first argument must be of integer or pointer
10451 type.  It must not be a boolean type.
10453 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10454 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10456 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10457 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10458 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10459 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10460 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10461 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10462 @findex __sync_add_and_fetch
10463 @findex __sync_sub_and_fetch
10464 @findex __sync_or_and_fetch
10465 @findex __sync_and_and_fetch
10466 @findex __sync_xor_and_fetch
10467 @findex __sync_nand_and_fetch
10468 These built-in functions perform the operation suggested by the name, and
10469 return the new value.  That is, operations on integer operands have
10470 the following semantics.  Operations on pointer operands are performed as
10471 if the operand's type were @code{uintptr_t}.
10473 @smallexample
10474 @{ *ptr @var{op}= value; return *ptr; @}
10475 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10476 @end smallexample
10478 The same constraints on arguments apply as for the corresponding
10479 @code{__sync_op_and_fetch} built-in functions.
10481 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10482 as @code{*ptr = ~(*ptr & value)} instead of
10483 @code{*ptr = ~*ptr & value}.
10485 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10486 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10487 @findex __sync_bool_compare_and_swap
10488 @findex __sync_val_compare_and_swap
10489 These built-in functions perform an atomic compare and swap.
10490 That is, if the current
10491 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10492 @code{*@var{ptr}}.
10494 The ``bool'' version returns true if the comparison is successful and
10495 @var{newval} is written.  The ``val'' version returns the contents
10496 of @code{*@var{ptr}} before the operation.
10498 @item __sync_synchronize (...)
10499 @findex __sync_synchronize
10500 This built-in function issues a full memory barrier.
10502 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10503 @findex __sync_lock_test_and_set
10504 This built-in function, as described by Intel, is not a traditional test-and-set
10505 operation, but rather an atomic exchange operation.  It writes @var{value}
10506 into @code{*@var{ptr}}, and returns the previous contents of
10507 @code{*@var{ptr}}.
10509 Many targets have only minimal support for such locks, and do not support
10510 a full exchange operation.  In this case, a target may support reduced
10511 functionality here by which the @emph{only} valid value to store is the
10512 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10513 is implementation defined.
10515 This built-in function is not a full barrier,
10516 but rather an @dfn{acquire barrier}.
10517 This means that references after the operation cannot move to (or be
10518 speculated to) before the operation, but previous memory stores may not
10519 be globally visible yet, and previous memory loads may not yet be
10520 satisfied.
10522 @item void __sync_lock_release (@var{type} *ptr, ...)
10523 @findex __sync_lock_release
10524 This built-in function releases the lock acquired by
10525 @code{__sync_lock_test_and_set}.
10526 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10528 This built-in function is not a full barrier,
10529 but rather a @dfn{release barrier}.
10530 This means that all previous memory stores are globally visible, and all
10531 previous memory loads have been satisfied, but following memory reads
10532 are not prevented from being speculated to before the barrier.
10533 @end table
10535 @node __atomic Builtins
10536 @section Built-in Functions for Memory Model Aware Atomic Operations
10538 The following built-in functions approximately match the requirements
10539 for the C++11 memory model.  They are all
10540 identified by being prefixed with @samp{__atomic} and most are
10541 overloaded so that they work with multiple types.
10543 These functions are intended to replace the legacy @samp{__sync}
10544 builtins.  The main difference is that the memory order that is requested
10545 is a parameter to the functions.  New code should always use the
10546 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10548 Note that the @samp{__atomic} builtins assume that programs will
10549 conform to the C++11 memory model.  In particular, they assume
10550 that programs are free of data races.  See the C++11 standard for
10551 detailed requirements.
10553 The @samp{__atomic} builtins can be used with any integral scalar or
10554 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10555 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10556 supported by the architecture.
10558 The four non-arithmetic functions (load, store, exchange, and 
10559 compare_exchange) all have a generic version as well.  This generic
10560 version works on any data type.  It uses the lock-free built-in function
10561 if the specific data type size makes that possible; otherwise, an
10562 external call is left to be resolved at run time.  This external call is
10563 the same format with the addition of a @samp{size_t} parameter inserted
10564 as the first parameter indicating the size of the object being pointed to.
10565 All objects must be the same size.
10567 There are 6 different memory orders that can be specified.  These map
10568 to the C++11 memory orders with the same names, see the C++11 standard
10569 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10570 on atomic synchronization} for detailed definitions.  Individual
10571 targets may also support additional memory orders for use on specific
10572 architectures.  Refer to the target documentation for details of
10573 these.
10575 An atomic operation can both constrain code motion and
10576 be mapped to hardware instructions for synchronization between threads
10577 (e.g., a fence).  To which extent this happens is controlled by the
10578 memory orders, which are listed here in approximately ascending order of
10579 strength.  The description of each memory order is only meant to roughly
10580 illustrate the effects and is not a specification; see the C++11
10581 memory model for precise semantics.
10583 @table  @code
10584 @item __ATOMIC_RELAXED
10585 Implies no inter-thread ordering constraints.
10586 @item __ATOMIC_CONSUME
10587 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10588 memory order because of a deficiency in C++11's semantics for
10589 @code{memory_order_consume}.
10590 @item __ATOMIC_ACQUIRE
10591 Creates an inter-thread happens-before constraint from the release (or
10592 stronger) semantic store to this acquire load.  Can prevent hoisting
10593 of code to before the operation.
10594 @item __ATOMIC_RELEASE
10595 Creates an inter-thread happens-before constraint to acquire (or stronger)
10596 semantic loads that read from this release store.  Can prevent sinking
10597 of code to after the operation.
10598 @item __ATOMIC_ACQ_REL
10599 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10600 @code{__ATOMIC_RELEASE}.
10601 @item __ATOMIC_SEQ_CST
10602 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10603 @end table
10605 Note that in the C++11 memory model, @emph{fences} (e.g.,
10606 @samp{__atomic_thread_fence}) take effect in combination with other
10607 atomic operations on specific memory locations (e.g., atomic loads);
10608 operations on specific memory locations do not necessarily affect other
10609 operations in the same way.
10611 Target architectures are encouraged to provide their own patterns for
10612 each of the atomic built-in functions.  If no target is provided, the original
10613 non-memory model set of @samp{__sync} atomic built-in functions are
10614 used, along with any required synchronization fences surrounding it in
10615 order to achieve the proper behavior.  Execution in this case is subject
10616 to the same restrictions as those built-in functions.
10618 If there is no pattern or mechanism to provide a lock-free instruction
10619 sequence, a call is made to an external routine with the same parameters
10620 to be resolved at run time.
10622 When implementing patterns for these built-in functions, the memory order
10623 parameter can be ignored as long as the pattern implements the most
10624 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10625 orders execute correctly with this memory order but they may not execute as
10626 efficiently as they could with a more appropriate implementation of the
10627 relaxed requirements.
10629 Note that the C++11 standard allows for the memory order parameter to be
10630 determined at run time rather than at compile time.  These built-in
10631 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10632 than invoke a runtime library call or inline a switch statement.  This is
10633 standard compliant, safe, and the simplest approach for now.
10635 The memory order parameter is a signed int, but only the lower 16 bits are
10636 reserved for the memory order.  The remainder of the signed int is reserved
10637 for target use and should be 0.  Use of the predefined atomic values
10638 ensures proper usage.
10640 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10641 This built-in function implements an atomic load operation.  It returns the
10642 contents of @code{*@var{ptr}}.
10644 The valid memory order variants are
10645 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10646 and @code{__ATOMIC_CONSUME}.
10648 @end deftypefn
10650 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10651 This is the generic version of an atomic load.  It returns the
10652 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10654 @end deftypefn
10656 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10657 This built-in function implements an atomic store operation.  It writes 
10658 @code{@var{val}} into @code{*@var{ptr}}.  
10660 The valid memory order variants are
10661 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10663 @end deftypefn
10665 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10666 This is the generic version of an atomic store.  It stores the value
10667 of @code{*@var{val}} into @code{*@var{ptr}}.
10669 @end deftypefn
10671 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10672 This built-in function implements an atomic exchange operation.  It writes
10673 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10674 @code{*@var{ptr}}.
10676 The valid memory order variants are
10677 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10678 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10680 @end deftypefn
10682 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10683 This is the generic version of an atomic exchange.  It stores the
10684 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10685 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10687 @end deftypefn
10689 @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)
10690 This built-in function implements an atomic compare and exchange operation.
10691 This compares the contents of @code{*@var{ptr}} with the contents of
10692 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10693 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10694 equal, the operation is a @emph{read} and the current contents of
10695 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
10696 for weak compare_exchange, which may fail spuriously, and false for
10697 the strong variation, which never fails spuriously.  Many targets
10698 only offer the strong variation and ignore the parameter.  When in doubt, use
10699 the strong variation.
10701 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10702 and memory is affected according to the
10703 memory order specified by @var{success_memorder}.  There are no
10704 restrictions on what memory order can be used here.
10706 Otherwise, false is returned and memory is affected according
10707 to @var{failure_memorder}. This memory order cannot be
10708 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10709 stronger order than that specified by @var{success_memorder}.
10711 @end deftypefn
10713 @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)
10714 This built-in function implements the generic version of
10715 @code{__atomic_compare_exchange}.  The function is virtually identical to
10716 @code{__atomic_compare_exchange_n}, except the desired value is also a
10717 pointer.
10719 @end deftypefn
10721 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10722 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10723 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10724 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10725 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10726 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10727 These built-in functions perform the operation suggested by the name, and
10728 return the result of the operation.  Operations on pointer arguments are
10729 performed as if the operands were of the @code{uintptr_t} type.  That is,
10730 they are not scaled by the size of the type to which the pointer points.
10732 @smallexample
10733 @{ *ptr @var{op}= val; return *ptr; @}
10734 @end smallexample
10736 The object pointed to by the first argument must be of integer or pointer
10737 type.  It must not be a boolean type.  All memory orders are valid.
10739 @end deftypefn
10741 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10742 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10743 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10744 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10745 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10746 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10747 These built-in functions perform the operation suggested by the name, and
10748 return the value that had previously been in @code{*@var{ptr}}.  Operations
10749 on pointer arguments are performed as if the operands were of
10750 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10751 the type to which the pointer points.
10753 @smallexample
10754 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10755 @end smallexample
10757 The same constraints on arguments apply as for the corresponding
10758 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10760 @end deftypefn
10762 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10764 This built-in function performs an atomic test-and-set operation on
10765 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10766 defined nonzero ``set'' value and the return value is @code{true} if and only
10767 if the previous contents were ``set''.
10768 It should be only used for operands of type @code{bool} or @code{char}. For 
10769 other types only part of the value may be set.
10771 All memory orders are valid.
10773 @end deftypefn
10775 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10777 This built-in function performs an atomic clear operation on
10778 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10779 It should be only used for operands of type @code{bool} or @code{char} and 
10780 in conjunction with @code{__atomic_test_and_set}.
10781 For other types it may only clear partially. If the type is not @code{bool}
10782 prefer using @code{__atomic_store}.
10784 The valid memory order variants are
10785 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10786 @code{__ATOMIC_RELEASE}.
10788 @end deftypefn
10790 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10792 This built-in function acts as a synchronization fence between threads
10793 based on the specified memory order.
10795 All memory orders are valid.
10797 @end deftypefn
10799 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10801 This built-in function acts as a synchronization fence between a thread
10802 and signal handlers based in the same thread.
10804 All memory orders are valid.
10806 @end deftypefn
10808 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10810 This built-in function returns true if objects of @var{size} bytes always
10811 generate lock-free atomic instructions for the target architecture.
10812 @var{size} must resolve to a compile-time constant and the result also
10813 resolves to a compile-time constant.
10815 @var{ptr} is an optional pointer to the object that may be used to determine
10816 alignment.  A value of 0 indicates typical alignment should be used.  The 
10817 compiler may also ignore this parameter.
10819 @smallexample
10820 if (__atomic_always_lock_free (sizeof (long long), 0))
10821 @end smallexample
10823 @end deftypefn
10825 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10827 This built-in function returns true if objects of @var{size} bytes always
10828 generate lock-free atomic instructions for the target architecture.  If
10829 the built-in function is not known to be lock-free, a call is made to a
10830 runtime routine named @code{__atomic_is_lock_free}.
10832 @var{ptr} is an optional pointer to the object that may be used to determine
10833 alignment.  A value of 0 indicates typical alignment should be used.  The 
10834 compiler may also ignore this parameter.
10835 @end deftypefn
10837 @node Integer Overflow Builtins
10838 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10840 The following built-in functions allow performing simple arithmetic operations
10841 together with checking whether the operations overflowed.
10843 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10844 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10845 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10846 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10847 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10848 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10849 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10851 These built-in functions promote the first two operands into infinite precision signed
10852 type and perform addition on those promoted operands.  The result is then
10853 cast to the type the third pointer argument points to and stored there.
10854 If the stored result is equal to the infinite precision result, the built-in
10855 functions return false, otherwise they return true.  As the addition is
10856 performed in infinite signed precision, these built-in functions have fully defined
10857 behavior for all argument values.
10859 The first built-in function allows arbitrary integral types for operands and
10860 the result type must be pointer to some integral type other than enumerated or
10861 boolean type, the rest of the built-in functions have explicit integer types.
10863 The compiler will attempt to use hardware instructions to implement
10864 these built-in functions where possible, like conditional jump on overflow
10865 after addition, conditional jump on carry etc.
10867 @end deftypefn
10869 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10870 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10871 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10872 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10873 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10874 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10875 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10877 These built-in functions are similar to the add overflow checking built-in
10878 functions above, except they perform subtraction, subtract the second argument
10879 from the first one, instead of addition.
10881 @end deftypefn
10883 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10884 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10885 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10886 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10887 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10888 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10889 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10891 These built-in functions are similar to the add overflow checking built-in
10892 functions above, except they perform multiplication, instead of addition.
10894 @end deftypefn
10896 The following built-in functions allow checking if simple arithmetic operation
10897 would overflow.
10899 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10900 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10901 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10903 These built-in functions are similar to @code{__builtin_add_overflow},
10904 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10905 they don't store the result of the arithmetic operation anywhere and the
10906 last argument is not a pointer, but some expression with integral type other
10907 than enumerated or boolean type.
10909 The built-in functions promote the first two operands into infinite precision signed type
10910 and perform addition on those promoted operands. The result is then
10911 cast to the type of the third argument.  If the cast result is equal to the infinite
10912 precision result, the built-in functions return false, otherwise they return true.
10913 The value of the third argument is ignored, just the side effects in the third argument
10914 are evaluated, and no integral argument promotions are performed on the last argument.
10915 If the third argument is a bit-field, the type used for the result cast has the
10916 precision and signedness of the given bit-field, rather than precision and signedness
10917 of the underlying type.
10919 For example, the following macro can be used to portably check, at
10920 compile-time, whether or not adding two constant integers will overflow,
10921 and perform the addition only when it is known to be safe and not to trigger
10922 a @option{-Woverflow} warning.
10924 @smallexample
10925 #define INT_ADD_OVERFLOW_P(a, b) \
10926    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10928 enum @{
10929     A = INT_MAX, B = 3,
10930     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10931     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10933 @end smallexample
10935 The compiler will attempt to use hardware instructions to implement
10936 these built-in functions where possible, like conditional jump on overflow
10937 after addition, conditional jump on carry etc.
10939 @end deftypefn
10941 @node x86 specific memory model extensions for transactional memory
10942 @section x86-Specific Memory Model Extensions for Transactional Memory
10944 The x86 architecture supports additional memory ordering flags
10945 to mark critical sections for hardware lock elision. 
10946 These must be specified in addition to an existing memory order to
10947 atomic intrinsics.
10949 @table @code
10950 @item __ATOMIC_HLE_ACQUIRE
10951 Start lock elision on a lock variable.
10952 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10953 @item __ATOMIC_HLE_RELEASE
10954 End lock elision on a lock variable.
10955 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10956 @end table
10958 When a lock acquire fails, it is required for good performance to abort
10959 the transaction quickly. This can be done with a @code{_mm_pause}.
10961 @smallexample
10962 #include <immintrin.h> // For _mm_pause
10964 int lockvar;
10966 /* Acquire lock with lock elision */
10967 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10968     _mm_pause(); /* Abort failed transaction */
10970 /* Free lock with lock elision */
10971 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10972 @end smallexample
10974 @node Object Size Checking
10975 @section Object Size Checking Built-in Functions
10976 @findex __builtin_object_size
10977 @findex __builtin___memcpy_chk
10978 @findex __builtin___mempcpy_chk
10979 @findex __builtin___memmove_chk
10980 @findex __builtin___memset_chk
10981 @findex __builtin___strcpy_chk
10982 @findex __builtin___stpcpy_chk
10983 @findex __builtin___strncpy_chk
10984 @findex __builtin___strcat_chk
10985 @findex __builtin___strncat_chk
10986 @findex __builtin___sprintf_chk
10987 @findex __builtin___snprintf_chk
10988 @findex __builtin___vsprintf_chk
10989 @findex __builtin___vsnprintf_chk
10990 @findex __builtin___printf_chk
10991 @findex __builtin___vprintf_chk
10992 @findex __builtin___fprintf_chk
10993 @findex __builtin___vfprintf_chk
10995 GCC implements a limited buffer overflow protection mechanism that can
10996 prevent some buffer overflow attacks by determining the sizes of objects
10997 into which data is about to be written and preventing the writes when
10998 the size isn't sufficient.  The built-in functions described below yield
10999 the best results when used together and when optimization is enabled.
11000 For example, to detect object sizes across function boundaries or to
11001 follow pointer assignments through non-trivial control flow they rely
11002 on various optimization passes enabled with @option{-O2}.  However, to
11003 a limited extent, they can be used without optimization as well.
11005 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
11006 is a built-in construct that returns a constant number of bytes from
11007 @var{ptr} to the end of the object @var{ptr} pointer points to
11008 (if known at compile time).  @code{__builtin_object_size} never evaluates
11009 its arguments for side effects.  If there are any side effects in them, it
11010 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11011 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
11012 point to and all of them are known at compile time, the returned number
11013 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
11014 0 and minimum if nonzero.  If it is not possible to determine which objects
11015 @var{ptr} points to at compile time, @code{__builtin_object_size} should
11016 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11017 for @var{type} 2 or 3.
11019 @var{type} is an integer constant from 0 to 3.  If the least significant
11020 bit is clear, objects are whole variables, if it is set, a closest
11021 surrounding subobject is considered the object a pointer points to.
11022 The second bit determines if maximum or minimum of remaining bytes
11023 is computed.
11025 @smallexample
11026 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
11027 char *p = &var.buf1[1], *q = &var.b;
11029 /* Here the object p points to is var.  */
11030 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
11031 /* The subobject p points to is var.buf1.  */
11032 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
11033 /* The object q points to is var.  */
11034 assert (__builtin_object_size (q, 0)
11035         == (char *) (&var + 1) - (char *) &var.b);
11036 /* The subobject q points to is var.b.  */
11037 assert (__builtin_object_size (q, 1) == sizeof (var.b));
11038 @end smallexample
11039 @end deftypefn
11041 There are built-in functions added for many common string operation
11042 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
11043 built-in is provided.  This built-in has an additional last argument,
11044 which is the number of bytes remaining in the object the @var{dest}
11045 argument points to or @code{(size_t) -1} if the size is not known.
11047 The built-in functions are optimized into the normal string functions
11048 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
11049 it is known at compile time that the destination object will not
11050 be overflowed.  If the compiler can determine at compile time that the
11051 object will always be overflowed, it issues a warning.
11053 The intended use can be e.g.@:
11055 @smallexample
11056 #undef memcpy
11057 #define bos0(dest) __builtin_object_size (dest, 0)
11058 #define memcpy(dest, src, n) \
11059   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
11061 char *volatile p;
11062 char buf[10];
11063 /* It is unknown what object p points to, so this is optimized
11064    into plain memcpy - no checking is possible.  */
11065 memcpy (p, "abcde", n);
11066 /* Destination is known and length too.  It is known at compile
11067    time there will be no overflow.  */
11068 memcpy (&buf[5], "abcde", 5);
11069 /* Destination is known, but the length is not known at compile time.
11070    This will result in __memcpy_chk call that can check for overflow
11071    at run time.  */
11072 memcpy (&buf[5], "abcde", n);
11073 /* Destination is known and it is known at compile time there will
11074    be overflow.  There will be a warning and __memcpy_chk call that
11075    will abort the program at run time.  */
11076 memcpy (&buf[6], "abcde", 5);
11077 @end smallexample
11079 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
11080 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
11081 @code{strcat} and @code{strncat}.
11083 There are also checking built-in functions for formatted output functions.
11084 @smallexample
11085 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
11086 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11087                               const char *fmt, ...);
11088 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
11089                               va_list ap);
11090 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11091                                const char *fmt, va_list ap);
11092 @end smallexample
11094 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
11095 etc.@: functions and can contain implementation specific flags on what
11096 additional security measures the checking function might take, such as
11097 handling @code{%n} differently.
11099 The @var{os} argument is the object size @var{s} points to, like in the
11100 other built-in functions.  There is a small difference in the behavior
11101 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
11102 optimized into the non-checking functions only if @var{flag} is 0, otherwise
11103 the checking function is called with @var{os} argument set to
11104 @code{(size_t) -1}.
11106 In addition to this, there are checking built-in functions
11107 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
11108 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
11109 These have just one additional argument, @var{flag}, right before
11110 format string @var{fmt}.  If the compiler is able to optimize them to
11111 @code{fputc} etc.@: functions, it does, otherwise the checking function
11112 is called and the @var{flag} argument passed to it.
11114 @node Other Builtins
11115 @section Other Built-in Functions Provided by GCC
11116 @cindex built-in functions
11117 @findex __builtin_alloca
11118 @findex __builtin_alloca_with_align
11119 @findex __builtin_alloca_with_align_and_max
11120 @findex __builtin_call_with_static_chain
11121 @findex __builtin_extend_pointer
11122 @findex __builtin_fpclassify
11123 @findex __builtin_isfinite
11124 @findex __builtin_isnormal
11125 @findex __builtin_isgreater
11126 @findex __builtin_isgreaterequal
11127 @findex __builtin_isinf_sign
11128 @findex __builtin_isless
11129 @findex __builtin_islessequal
11130 @findex __builtin_islessgreater
11131 @findex __builtin_isunordered
11132 @findex __builtin_powi
11133 @findex __builtin_powif
11134 @findex __builtin_powil
11135 @findex __builtin_speculation_safe_value
11136 @findex _Exit
11137 @findex _exit
11138 @findex abort
11139 @findex abs
11140 @findex acos
11141 @findex acosf
11142 @findex acosh
11143 @findex acoshf
11144 @findex acoshl
11145 @findex acosl
11146 @findex alloca
11147 @findex asin
11148 @findex asinf
11149 @findex asinh
11150 @findex asinhf
11151 @findex asinhl
11152 @findex asinl
11153 @findex atan
11154 @findex atan2
11155 @findex atan2f
11156 @findex atan2l
11157 @findex atanf
11158 @findex atanh
11159 @findex atanhf
11160 @findex atanhl
11161 @findex atanl
11162 @findex bcmp
11163 @findex bzero
11164 @findex cabs
11165 @findex cabsf
11166 @findex cabsl
11167 @findex cacos
11168 @findex cacosf
11169 @findex cacosh
11170 @findex cacoshf
11171 @findex cacoshl
11172 @findex cacosl
11173 @findex calloc
11174 @findex carg
11175 @findex cargf
11176 @findex cargl
11177 @findex casin
11178 @findex casinf
11179 @findex casinh
11180 @findex casinhf
11181 @findex casinhl
11182 @findex casinl
11183 @findex catan
11184 @findex catanf
11185 @findex catanh
11186 @findex catanhf
11187 @findex catanhl
11188 @findex catanl
11189 @findex cbrt
11190 @findex cbrtf
11191 @findex cbrtl
11192 @findex ccos
11193 @findex ccosf
11194 @findex ccosh
11195 @findex ccoshf
11196 @findex ccoshl
11197 @findex ccosl
11198 @findex ceil
11199 @findex ceilf
11200 @findex ceill
11201 @findex cexp
11202 @findex cexpf
11203 @findex cexpl
11204 @findex cimag
11205 @findex cimagf
11206 @findex cimagl
11207 @findex clog
11208 @findex clogf
11209 @findex clogl
11210 @findex clog10
11211 @findex clog10f
11212 @findex clog10l
11213 @findex conj
11214 @findex conjf
11215 @findex conjl
11216 @findex copysign
11217 @findex copysignf
11218 @findex copysignl
11219 @findex cos
11220 @findex cosf
11221 @findex cosh
11222 @findex coshf
11223 @findex coshl
11224 @findex cosl
11225 @findex cpow
11226 @findex cpowf
11227 @findex cpowl
11228 @findex cproj
11229 @findex cprojf
11230 @findex cprojl
11231 @findex creal
11232 @findex crealf
11233 @findex creall
11234 @findex csin
11235 @findex csinf
11236 @findex csinh
11237 @findex csinhf
11238 @findex csinhl
11239 @findex csinl
11240 @findex csqrt
11241 @findex csqrtf
11242 @findex csqrtl
11243 @findex ctan
11244 @findex ctanf
11245 @findex ctanh
11246 @findex ctanhf
11247 @findex ctanhl
11248 @findex ctanl
11249 @findex dcgettext
11250 @findex dgettext
11251 @findex drem
11252 @findex dremf
11253 @findex dreml
11254 @findex erf
11255 @findex erfc
11256 @findex erfcf
11257 @findex erfcl
11258 @findex erff
11259 @findex erfl
11260 @findex exit
11261 @findex exp
11262 @findex exp10
11263 @findex exp10f
11264 @findex exp10l
11265 @findex exp2
11266 @findex exp2f
11267 @findex exp2l
11268 @findex expf
11269 @findex expl
11270 @findex expm1
11271 @findex expm1f
11272 @findex expm1l
11273 @findex fabs
11274 @findex fabsf
11275 @findex fabsl
11276 @findex fdim
11277 @findex fdimf
11278 @findex fdiml
11279 @findex ffs
11280 @findex floor
11281 @findex floorf
11282 @findex floorl
11283 @findex fma
11284 @findex fmaf
11285 @findex fmal
11286 @findex fmax
11287 @findex fmaxf
11288 @findex fmaxl
11289 @findex fmin
11290 @findex fminf
11291 @findex fminl
11292 @findex fmod
11293 @findex fmodf
11294 @findex fmodl
11295 @findex fprintf
11296 @findex fprintf_unlocked
11297 @findex fputs
11298 @findex fputs_unlocked
11299 @findex frexp
11300 @findex frexpf
11301 @findex frexpl
11302 @findex fscanf
11303 @findex gamma
11304 @findex gammaf
11305 @findex gammal
11306 @findex gamma_r
11307 @findex gammaf_r
11308 @findex gammal_r
11309 @findex gettext
11310 @findex hypot
11311 @findex hypotf
11312 @findex hypotl
11313 @findex ilogb
11314 @findex ilogbf
11315 @findex ilogbl
11316 @findex imaxabs
11317 @findex index
11318 @findex isalnum
11319 @findex isalpha
11320 @findex isascii
11321 @findex isblank
11322 @findex iscntrl
11323 @findex isdigit
11324 @findex isgraph
11325 @findex islower
11326 @findex isprint
11327 @findex ispunct
11328 @findex isspace
11329 @findex isupper
11330 @findex iswalnum
11331 @findex iswalpha
11332 @findex iswblank
11333 @findex iswcntrl
11334 @findex iswdigit
11335 @findex iswgraph
11336 @findex iswlower
11337 @findex iswprint
11338 @findex iswpunct
11339 @findex iswspace
11340 @findex iswupper
11341 @findex iswxdigit
11342 @findex isxdigit
11343 @findex j0
11344 @findex j0f
11345 @findex j0l
11346 @findex j1
11347 @findex j1f
11348 @findex j1l
11349 @findex jn
11350 @findex jnf
11351 @findex jnl
11352 @findex labs
11353 @findex ldexp
11354 @findex ldexpf
11355 @findex ldexpl
11356 @findex lgamma
11357 @findex lgammaf
11358 @findex lgammal
11359 @findex lgamma_r
11360 @findex lgammaf_r
11361 @findex lgammal_r
11362 @findex llabs
11363 @findex llrint
11364 @findex llrintf
11365 @findex llrintl
11366 @findex llround
11367 @findex llroundf
11368 @findex llroundl
11369 @findex log
11370 @findex log10
11371 @findex log10f
11372 @findex log10l
11373 @findex log1p
11374 @findex log1pf
11375 @findex log1pl
11376 @findex log2
11377 @findex log2f
11378 @findex log2l
11379 @findex logb
11380 @findex logbf
11381 @findex logbl
11382 @findex logf
11383 @findex logl
11384 @findex lrint
11385 @findex lrintf
11386 @findex lrintl
11387 @findex lround
11388 @findex lroundf
11389 @findex lroundl
11390 @findex malloc
11391 @findex memchr
11392 @findex memcmp
11393 @findex memcpy
11394 @findex mempcpy
11395 @findex memset
11396 @findex modf
11397 @findex modff
11398 @findex modfl
11399 @findex nearbyint
11400 @findex nearbyintf
11401 @findex nearbyintl
11402 @findex nextafter
11403 @findex nextafterf
11404 @findex nextafterl
11405 @findex nexttoward
11406 @findex nexttowardf
11407 @findex nexttowardl
11408 @findex pow
11409 @findex pow10
11410 @findex pow10f
11411 @findex pow10l
11412 @findex powf
11413 @findex powl
11414 @findex printf
11415 @findex printf_unlocked
11416 @findex putchar
11417 @findex puts
11418 @findex remainder
11419 @findex remainderf
11420 @findex remainderl
11421 @findex remquo
11422 @findex remquof
11423 @findex remquol
11424 @findex rindex
11425 @findex rint
11426 @findex rintf
11427 @findex rintl
11428 @findex round
11429 @findex roundf
11430 @findex roundl
11431 @findex scalb
11432 @findex scalbf
11433 @findex scalbl
11434 @findex scalbln
11435 @findex scalblnf
11436 @findex scalblnf
11437 @findex scalbn
11438 @findex scalbnf
11439 @findex scanfnl
11440 @findex signbit
11441 @findex signbitf
11442 @findex signbitl
11443 @findex signbitd32
11444 @findex signbitd64
11445 @findex signbitd128
11446 @findex significand
11447 @findex significandf
11448 @findex significandl
11449 @findex sin
11450 @findex sincos
11451 @findex sincosf
11452 @findex sincosl
11453 @findex sinf
11454 @findex sinh
11455 @findex sinhf
11456 @findex sinhl
11457 @findex sinl
11458 @findex snprintf
11459 @findex sprintf
11460 @findex sqrt
11461 @findex sqrtf
11462 @findex sqrtl
11463 @findex sscanf
11464 @findex stpcpy
11465 @findex stpncpy
11466 @findex strcasecmp
11467 @findex strcat
11468 @findex strchr
11469 @findex strcmp
11470 @findex strcpy
11471 @findex strcspn
11472 @findex strdup
11473 @findex strfmon
11474 @findex strftime
11475 @findex strlen
11476 @findex strncasecmp
11477 @findex strncat
11478 @findex strncmp
11479 @findex strncpy
11480 @findex strndup
11481 @findex strnlen
11482 @findex strpbrk
11483 @findex strrchr
11484 @findex strspn
11485 @findex strstr
11486 @findex tan
11487 @findex tanf
11488 @findex tanh
11489 @findex tanhf
11490 @findex tanhl
11491 @findex tanl
11492 @findex tgamma
11493 @findex tgammaf
11494 @findex tgammal
11495 @findex toascii
11496 @findex tolower
11497 @findex toupper
11498 @findex towlower
11499 @findex towupper
11500 @findex trunc
11501 @findex truncf
11502 @findex truncl
11503 @findex vfprintf
11504 @findex vfscanf
11505 @findex vprintf
11506 @findex vscanf
11507 @findex vsnprintf
11508 @findex vsprintf
11509 @findex vsscanf
11510 @findex y0
11511 @findex y0f
11512 @findex y0l
11513 @findex y1
11514 @findex y1f
11515 @findex y1l
11516 @findex yn
11517 @findex ynf
11518 @findex ynl
11520 GCC provides a large number of built-in functions other than the ones
11521 mentioned above.  Some of these are for internal use in the processing
11522 of exceptions or variable-length argument lists and are not
11523 documented here because they may change from time to time; we do not
11524 recommend general use of these functions.
11526 The remaining functions are provided for optimization purposes.
11528 With the exception of built-ins that have library equivalents such as
11529 the standard C library functions discussed below, or that expand to
11530 library calls, GCC built-in functions are always expanded inline and
11531 thus do not have corresponding entry points and their address cannot
11532 be obtained.  Attempting to use them in an expression other than
11533 a function call results in a compile-time error.
11535 @opindex fno-builtin
11536 GCC includes built-in versions of many of the functions in the standard
11537 C library.  These functions come in two forms: one whose names start with
11538 the @code{__builtin_} prefix, and the other without.  Both forms have the
11539 same type (including prototype), the same address (when their address is
11540 taken), and the same meaning as the C library functions even if you specify
11541 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11542 functions are only optimized in certain cases; if they are not optimized in
11543 a particular case, a call to the library function is emitted.
11545 @opindex ansi
11546 @opindex std
11547 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11548 @option{-std=c99} or @option{-std=c11}), the functions
11549 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11550 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11551 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11552 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11553 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11554 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11555 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11556 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11557 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11558 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11559 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11560 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11561 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11562 @code{significandl}, @code{significand}, @code{sincosf},
11563 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11564 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11565 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
11566 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11567 @code{yn}
11568 may be handled as built-in functions.
11569 All these functions have corresponding versions
11570 prefixed with @code{__builtin_}, which may be used even in strict C90
11571 mode.
11573 The ISO C99 functions
11574 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11575 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11576 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11577 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11578 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11579 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11580 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11581 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11582 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11583 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11584 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11585 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11586 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11587 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11588 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11589 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11590 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11591 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11592 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11593 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11594 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11595 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11596 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11597 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11598 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11599 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11600 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11601 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11602 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11603 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11604 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11605 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11606 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11607 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11608 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11609 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11610 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11611 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11612 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11613 are handled as built-in functions
11614 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11616 There are also built-in versions of the ISO C99 functions
11617 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11618 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11619 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11620 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11621 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11622 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11623 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11624 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11625 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11626 that are recognized in any mode since ISO C90 reserves these names for
11627 the purpose to which ISO C99 puts them.  All these functions have
11628 corresponding versions prefixed with @code{__builtin_}.
11630 There are also built-in functions @code{__builtin_fabsf@var{n}},
11631 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11632 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11633 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11634 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11635 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11637 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11638 @code{clog10l} which names are reserved by ISO C99 for future use.
11639 All these functions have versions prefixed with @code{__builtin_}.
11641 The ISO C94 functions
11642 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11643 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11644 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11645 @code{towupper}
11646 are handled as built-in functions
11647 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11649 The ISO C90 functions
11650 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11651 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11652 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11653 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11654 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11655 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11656 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11657 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11658 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11659 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11660 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11661 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11662 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11663 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11664 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11665 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11666 are all recognized as built-in functions unless
11667 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11668 is specified for an individual function).  All of these functions have
11669 corresponding versions prefixed with @code{__builtin_}.
11671 GCC provides built-in versions of the ISO C99 floating-point comparison
11672 macros that avoid raising exceptions for unordered operands.  They have
11673 the same names as the standard macros ( @code{isgreater},
11674 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11675 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11676 prefixed.  We intend for a library implementor to be able to simply
11677 @code{#define} each standard macro to its built-in equivalent.
11678 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11679 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11680 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11681 built-in functions appear both with and without the @code{__builtin_} prefix.
11683 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11684 The @code{__builtin_alloca} function must be called at block scope.
11685 The function allocates an object @var{size} bytes large on the stack
11686 of the calling function.  The object is aligned on the default stack
11687 alignment boundary for the target determined by the
11688 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11689 function returns a pointer to the first byte of the allocated object.
11690 The lifetime of the allocated object ends just before the calling
11691 function returns to its caller.   This is so even when
11692 @code{__builtin_alloca} is called within a nested block.
11694 For example, the following function allocates eight objects of @code{n}
11695 bytes each on the stack, storing a pointer to each in consecutive elements
11696 of the array @code{a}.  It then passes the array to function @code{g}
11697 which can safely use the storage pointed to by each of the array elements.
11699 @smallexample
11700 void f (unsigned n)
11702   void *a [8];
11703   for (int i = 0; i != 8; ++i)
11704     a [i] = __builtin_alloca (n);
11706   g (a, n);   // @r{safe}
11708 @end smallexample
11710 Since the @code{__builtin_alloca} function doesn't validate its argument
11711 it is the responsibility of its caller to make sure the argument doesn't
11712 cause it to exceed the stack size limit.
11713 The @code{__builtin_alloca} function is provided to make it possible to
11714 allocate on the stack arrays of bytes with an upper bound that may be
11715 computed at run time.  Since C99 Variable Length Arrays offer
11716 similar functionality under a portable, more convenient, and safer
11717 interface they are recommended instead, in both C99 and C++ programs
11718 where GCC provides them as an extension.
11719 @xref{Variable Length}, for details.
11721 @end deftypefn
11723 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11724 The @code{__builtin_alloca_with_align} function must be called at block
11725 scope.  The function allocates an object @var{size} bytes large on
11726 the stack of the calling function.  The allocated object is aligned on
11727 the boundary specified by the argument @var{alignment} whose unit is given
11728 in bits (not bytes).  The @var{size} argument must be positive and not
11729 exceed the stack size limit.  The @var{alignment} argument must be a constant
11730 integer expression that evaluates to a power of 2 greater than or equal to
11731 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11732 with other values are rejected with an error indicating the valid bounds.
11733 The function returns a pointer to the first byte of the allocated object.
11734 The lifetime of the allocated object ends at the end of the block in which
11735 the function was called.  The allocated storage is released no later than
11736 just before the calling function returns to its caller, but may be released
11737 at the end of the block in which the function was called.
11739 For example, in the following function the call to @code{g} is unsafe
11740 because when @code{overalign} is non-zero, the space allocated by
11741 @code{__builtin_alloca_with_align} may have been released at the end
11742 of the @code{if} statement in which it was called.
11744 @smallexample
11745 void f (unsigned n, bool overalign)
11747   void *p;
11748   if (overalign)
11749     p = __builtin_alloca_with_align (n, 64 /* bits */);
11750   else
11751     p = __builtin_alloc (n);
11753   g (p, n);   // @r{unsafe}
11755 @end smallexample
11757 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11758 @var{size} argument it is the responsibility of its caller to make sure
11759 the argument doesn't cause it to exceed the stack size limit.
11760 The @code{__builtin_alloca_with_align} function is provided to make
11761 it possible to allocate on the stack overaligned arrays of bytes with
11762 an upper bound that may be computed at run time.  Since C99
11763 Variable Length Arrays offer the same functionality under
11764 a portable, more convenient, and safer interface they are recommended
11765 instead, in both C99 and C++ programs where GCC provides them as
11766 an extension.  @xref{Variable Length}, for details.
11768 @end deftypefn
11770 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11771 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11772 specifying an upper bound for @var{size} in case its value cannot be computed
11773 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11774 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11775 expression, it has no effect on code generation and no attempt is made to
11776 check its compatibility with @var{size}.
11778 @end deftypefn
11780 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
11782 This built-in function can be used to help mitigate against unsafe
11783 speculative execution.  @var{type} may be any integral type or any
11784 pointer type.
11786 @enumerate
11787 @item
11788 If the CPU is not speculatively executing the code, then @var{val}
11789 is returned.
11790 @item
11791 If the CPU is executing speculatively then either:
11792 @itemize
11793 @item
11794 The function may cause execution to pause until it is known that the
11795 code is no-longer being executed speculatively (in which case
11796 @var{val} can be returned, as above); or
11797 @item
11798 The function may use target-dependent speculation tracking state to cause
11799 @var{failval} to be returned when it is known that speculative
11800 execution has incorrectly predicted a conditional branch operation.
11801 @end itemize
11802 @end enumerate
11804 The second argument, @var{failval}, is optional and defaults to zero
11805 if omitted.
11807 GCC defines the preprocessor macro
11808 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
11809 updated to support this builtin.
11811 The built-in function can be used where a variable appears to be used in a
11812 safe way, but the CPU, due to speculative execution may temporarily ignore
11813 the bounds checks.  Consider, for example, the following function:
11815 @smallexample
11816 int array[500];
11817 int f (unsigned untrusted_index)
11819   if (untrusted_index < 500)
11820     return array[untrusted_index];
11821   return 0;
11823 @end smallexample
11825 If the function is called repeatedly with @code{untrusted_index} less
11826 than the limit of 500, then a branch predictor will learn that the
11827 block of code that returns a value stored in @code{array} will be
11828 executed.  If the function is subsequently called with an
11829 out-of-range value it will still try to execute that block of code
11830 first until the CPU determines that the prediction was incorrect
11831 (the CPU will unwind any incorrect operations at that point).
11832 However, depending on how the result of the function is used, it might be
11833 possible to leave traces in the cache that can reveal what was stored
11834 at the out-of-bounds location.  The built-in function can be used to
11835 provide some protection against leaking data in this way by changing
11836 the code to:
11838 @smallexample
11839 int array[500];
11840 int f (unsigned untrusted_index)
11842   if (untrusted_index < 500)
11843     return array[__builtin_speculation_safe_value (untrusted_index)];
11844   return 0;
11846 @end smallexample
11848 The built-in function will either cause execution to stall until the
11849 conditional branch has been fully resolved, or it may permit
11850 speculative execution to continue, but using 0 instead of
11851 @code{untrusted_value} if that exceeds the limit.
11853 If accessing any memory location is potentially unsafe when speculative
11854 execution is incorrect, then the code can be rewritten as
11856 @smallexample
11857 int array[500];
11858 int f (unsigned untrusted_index)
11860   if (untrusted_index < 500)
11861     return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
11862   return 0;
11864 @end smallexample
11866 which will cause a @code{NULL} pointer to be used for the unsafe case.
11868 @end deftypefn
11870 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11872 You can use the built-in function @code{__builtin_types_compatible_p} to
11873 determine whether two types are the same.
11875 This built-in function returns 1 if the unqualified versions of the
11876 types @var{type1} and @var{type2} (which are types, not expressions) are
11877 compatible, 0 otherwise.  The result of this built-in function can be
11878 used in integer constant expressions.
11880 This built-in function ignores top level qualifiers (e.g., @code{const},
11881 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11882 int}.
11884 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11885 hand, @code{int} and @code{char *} are not compatible, even if the size
11886 of their types, on the particular architecture are the same.  Also, the
11887 amount of pointer indirection is taken into account when determining
11888 similarity.  Consequently, @code{short *} is not similar to
11889 @code{short **}.  Furthermore, two types that are typedefed are
11890 considered compatible if their underlying types are compatible.
11892 An @code{enum} type is not considered to be compatible with another
11893 @code{enum} type even if both are compatible with the same integer
11894 type; this is what the C standard specifies.
11895 For example, @code{enum @{foo, bar@}} is not similar to
11896 @code{enum @{hot, dog@}}.
11898 You typically use this function in code whose execution varies
11899 depending on the arguments' types.  For example:
11901 @smallexample
11902 #define foo(x)                                                  \
11903   (@{                                                           \
11904     typeof (x) tmp = (x);                                       \
11905     if (__builtin_types_compatible_p (typeof (x), long double)) \
11906       tmp = foo_long_double (tmp);                              \
11907     else if (__builtin_types_compatible_p (typeof (x), double)) \
11908       tmp = foo_double (tmp);                                   \
11909     else if (__builtin_types_compatible_p (typeof (x), float))  \
11910       tmp = foo_float (tmp);                                    \
11911     else                                                        \
11912       abort ();                                                 \
11913     tmp;                                                        \
11914   @})
11915 @end smallexample
11917 @emph{Note:} This construct is only available for C@.
11919 @end deftypefn
11921 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11923 The @var{call_exp} expression must be a function call, and the
11924 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11925 is passed to the function call in the target's static chain location.
11926 The result of builtin is the result of the function call.
11928 @emph{Note:} This builtin is only available for C@.
11929 This builtin can be used to call Go closures from C.
11931 @end deftypefn
11933 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11935 You can use the built-in function @code{__builtin_choose_expr} to
11936 evaluate code depending on the value of a constant expression.  This
11937 built-in function returns @var{exp1} if @var{const_exp}, which is an
11938 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11940 This built-in function is analogous to the @samp{? :} operator in C,
11941 except that the expression returned has its type unaltered by promotion
11942 rules.  Also, the built-in function does not evaluate the expression
11943 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11944 @var{exp2} is not evaluated even if it has side effects.
11946 This built-in function can return an lvalue if the chosen argument is an
11947 lvalue.
11949 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11950 type.  Similarly, if @var{exp2} is returned, its return type is the same
11951 as @var{exp2}.
11953 Example:
11955 @smallexample
11956 #define foo(x)                                                    \
11957   __builtin_choose_expr (                                         \
11958     __builtin_types_compatible_p (typeof (x), double),            \
11959     foo_double (x),                                               \
11960     __builtin_choose_expr (                                       \
11961       __builtin_types_compatible_p (typeof (x), float),           \
11962       foo_float (x),                                              \
11963       /* @r{The void expression results in a compile-time error}  \
11964          @r{when assigning the result to something.}  */          \
11965       (void)0))
11966 @end smallexample
11968 @emph{Note:} This construct is only available for C@.  Furthermore, the
11969 unused expression (@var{exp1} or @var{exp2} depending on the value of
11970 @var{const_exp}) may still generate syntax errors.  This may change in
11971 future revisions.
11973 @end deftypefn
11975 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11977 The built-in function @code{__builtin_tgmath}, available only for C
11978 and Objective-C, calls a function determined according to the rules of
11979 @code{<tgmath.h>} macros.  It is intended to be used in
11980 implementations of that header, so that expansions of macros from that
11981 header only expand each of their arguments once, to avoid problems
11982 when calls to such macros are nested inside the arguments of other
11983 calls to such macros; in addition, it results in better diagnostics
11984 for invalid calls to @code{<tgmath.h>} macros than implementations
11985 using other GNU C language features.  For example, the @code{pow}
11986 type-generic macro might be defined as:
11988 @smallexample
11989 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11990                                     cpowf, cpow, cpowl, a, b)
11991 @end smallexample
11993 The arguments to @code{__builtin_tgmath} are at least two pointers to
11994 functions, followed by the arguments to the type-generic macro (which
11995 will be passed as arguments to the selected function).  All the
11996 pointers to functions must be pointers to prototyped functions, none
11997 of which may have variable arguments, and all of which must have the
11998 same number of parameters; the number of parameters of the first
11999 function determines how many arguments to @code{__builtin_tgmath} are
12000 interpreted as function pointers, and how many as the arguments to the
12001 called function.
12003 The types of the specified functions must all be different, but
12004 related to each other in the same way as a set of functions that may
12005 be selected between by a macro in @code{<tgmath.h>}.  This means that
12006 the functions are parameterized by a floating-point type @var{t},
12007 different for each such function.  The function return types may all
12008 be the same type, or they may be @var{t} for each function, or they
12009 may be the real type corresponding to @var{t} for each function (if
12010 some of the types @var{t} are complex).  Likewise, for each parameter
12011 position, the type of the parameter in that position may always be the
12012 same type, or may be @var{t} for each function (this case must apply
12013 for at least one parameter position), or may be the real type
12014 corresponding to @var{t} for each function.
12016 The standard rules for @code{<tgmath.h>} macros are used to find a
12017 common type @var{u} from the types of the arguments for parameters
12018 whose types vary between the functions; complex integer types (a GNU
12019 extension) are treated like @code{_Complex double} for this purpose
12020 (or @code{_Complex _Float64} if all the function return types are the
12021 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
12022 If the function return types vary, or are all the same integer type,
12023 the function called is the one for which @var{t} is @var{u}, and it is
12024 an error if there is no such function.  If the function return types
12025 are all the same floating-point type, the type-generic macro is taken
12026 to be one of those from TS 18661 that rounds the result to a narrower
12027 type; if there is a function for which @var{t} is @var{u}, it is
12028 called, and otherwise the first function, if any, for which @var{t}
12029 has at least the range and precision of @var{u} is called, and it is
12030 an error if there is no such function.
12032 @end deftypefn
12034 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
12036 The built-in function @code{__builtin_complex} is provided for use in
12037 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
12038 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
12039 real binary floating-point type, and the result has the corresponding
12040 complex type with real and imaginary parts @var{real} and @var{imag}.
12041 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
12042 infinities, NaNs and negative zeros are involved.
12044 @end deftypefn
12046 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
12047 You can use the built-in function @code{__builtin_constant_p} to
12048 determine if a value is known to be constant at compile time and hence
12049 that GCC can perform constant-folding on expressions involving that
12050 value.  The argument of the function is the value to test.  The function
12051 returns the integer 1 if the argument is known to be a compile-time
12052 constant and 0 if it is not known to be a compile-time constant.  A
12053 return of 0 does not indicate that the value is @emph{not} a constant,
12054 but merely that GCC cannot prove it is a constant with the specified
12055 value of the @option{-O} option.
12057 You typically use this function in an embedded application where
12058 memory is a critical resource.  If you have some complex calculation,
12059 you may want it to be folded if it involves constants, but need to call
12060 a function if it does not.  For example:
12062 @smallexample
12063 #define Scale_Value(X)      \
12064   (__builtin_constant_p (X) \
12065   ? ((X) * SCALE + OFFSET) : Scale (X))
12066 @end smallexample
12068 You may use this built-in function in either a macro or an inline
12069 function.  However, if you use it in an inlined function and pass an
12070 argument of the function as the argument to the built-in, GCC 
12071 never returns 1 when you call the inline function with a string constant
12072 or compound literal (@pxref{Compound Literals}) and does not return 1
12073 when you pass a constant numeric value to the inline function unless you
12074 specify the @option{-O} option.
12076 You may also use @code{__builtin_constant_p} in initializers for static
12077 data.  For instance, you can write
12079 @smallexample
12080 static const int table[] = @{
12081    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
12082    /* @r{@dots{}} */
12084 @end smallexample
12086 @noindent
12087 This is an acceptable initializer even if @var{EXPRESSION} is not a
12088 constant expression, including the case where
12089 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
12090 folded to a constant but @var{EXPRESSION} contains operands that are
12091 not otherwise permitted in a static initializer (for example,
12092 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
12093 built-in in this case, because it has no opportunity to perform
12094 optimization.
12095 @end deftypefn
12097 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
12098 @opindex fprofile-arcs
12099 You may use @code{__builtin_expect} to provide the compiler with
12100 branch prediction information.  In general, you should prefer to
12101 use actual profile feedback for this (@option{-fprofile-arcs}), as
12102 programmers are notoriously bad at predicting how their programs
12103 actually perform.  However, there are applications in which this
12104 data is hard to collect.
12106 The return value is the value of @var{exp}, which should be an integral
12107 expression.  The semantics of the built-in are that it is expected that
12108 @var{exp} == @var{c}.  For example:
12110 @smallexample
12111 if (__builtin_expect (x, 0))
12112   foo ();
12113 @end smallexample
12115 @noindent
12116 indicates that we do not expect to call @code{foo}, since
12117 we expect @code{x} to be zero.  Since you are limited to integral
12118 expressions for @var{exp}, you should use constructions such as
12120 @smallexample
12121 if (__builtin_expect (ptr != NULL, 1))
12122   foo (*ptr);
12123 @end smallexample
12125 @noindent
12126 when testing pointer or floating-point values.
12128 For the purposes of branch prediction optimizations, the probability that
12129 a @code{__builtin_expect} expression is true is controlled by GCC's
12130 @code{builtin-expect-probability} parameter, which defaults to 90%.  
12131 You can also use @code{__builtin_expect_with_probability} to explicitly 
12132 assign a probability value to individual expressions.
12133 @end deftypefn
12135 @deftypefn {Built-in Function} long __builtin_expect_with_probability
12136 (long @var{exp}, long @var{c}, double @var{probability})
12138 This function has the same semantics as @code{__builtin_expect},
12139 but the caller provides the expected probability that @var{exp} == @var{c}.
12140 The last argument, @var{probability}, is a floating-point value in the
12141 range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
12142 constant floating-point expression.
12143 @end deftypefn
12145 @deftypefn {Built-in Function} void __builtin_trap (void)
12146 This function causes the program to exit abnormally.  GCC implements
12147 this function by using a target-dependent mechanism (such as
12148 intentionally executing an illegal instruction) or by calling
12149 @code{abort}.  The mechanism used may vary from release to release so
12150 you should not rely on any particular implementation.
12151 @end deftypefn
12153 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12154 If control flow reaches the point of the @code{__builtin_unreachable},
12155 the program is undefined.  It is useful in situations where the
12156 compiler cannot deduce the unreachability of the code.
12158 One such case is immediately following an @code{asm} statement that
12159 either never terminates, or one that transfers control elsewhere
12160 and never returns.  In this example, without the
12161 @code{__builtin_unreachable}, GCC issues a warning that control
12162 reaches the end of a non-void function.  It also generates code
12163 to return after the @code{asm}.
12165 @smallexample
12166 int f (int c, int v)
12168   if (c)
12169     @{
12170       return v;
12171     @}
12172   else
12173     @{
12174       asm("jmp error_handler");
12175       __builtin_unreachable ();
12176     @}
12178 @end smallexample
12180 @noindent
12181 Because the @code{asm} statement unconditionally transfers control out
12182 of the function, control never reaches the end of the function
12183 body.  The @code{__builtin_unreachable} is in fact unreachable and
12184 communicates this fact to the compiler.
12186 Another use for @code{__builtin_unreachable} is following a call a
12187 function that never returns but that is not declared
12188 @code{__attribute__((noreturn))}, as in this example:
12190 @smallexample
12191 void function_that_never_returns (void);
12193 int g (int c)
12195   if (c)
12196     @{
12197       return 1;
12198     @}
12199   else
12200     @{
12201       function_that_never_returns ();
12202       __builtin_unreachable ();
12203     @}
12205 @end smallexample
12207 @end deftypefn
12209 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12210 This function returns its first argument, and allows the compiler
12211 to assume that the returned pointer is at least @var{align} bytes
12212 aligned.  This built-in can have either two or three arguments,
12213 if it has three, the third argument should have integer type, and
12214 if it is nonzero means misalignment offset.  For example:
12216 @smallexample
12217 void *x = __builtin_assume_aligned (arg, 16);
12218 @end smallexample
12220 @noindent
12221 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12222 16-byte aligned, while:
12224 @smallexample
12225 void *x = __builtin_assume_aligned (arg, 32, 8);
12226 @end smallexample
12228 @noindent
12229 means that the compiler can assume for @code{x}, set to @code{arg}, that
12230 @code{(char *) x - 8} is 32-byte aligned.
12231 @end deftypefn
12233 @deftypefn {Built-in Function} int __builtin_LINE ()
12234 This function is the equivalent of the preprocessor @code{__LINE__}
12235 macro and returns a constant integer expression that evaluates to
12236 the line number of the invocation of the built-in.  When used as a C++
12237 default argument for a function @var{F}, it returns the line number
12238 of the call to @var{F}.
12239 @end deftypefn
12241 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12242 This function is the equivalent of the @code{__FUNCTION__} symbol
12243 and returns an address constant pointing to the name of the function
12244 from which the built-in was invoked, or the empty string if
12245 the invocation is not at function scope.  When used as a C++ default
12246 argument for a function @var{F}, it returns the name of @var{F}'s
12247 caller or the empty string if the call was not made at function
12248 scope.
12249 @end deftypefn
12251 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12252 This function is the equivalent of the preprocessor @code{__FILE__}
12253 macro and returns an address constant pointing to the file name
12254 containing the invocation of the built-in, or the empty string if
12255 the invocation is not at function scope.  When used as a C++ default
12256 argument for a function @var{F}, it returns the file name of the call
12257 to @var{F} or the empty string if the call was not made at function
12258 scope.
12260 For example, in the following, each call to function @code{foo} will
12261 print a line similar to @code{"file.c:123: foo: message"} with the name
12262 of the file and the line number of the @code{printf} call, the name of
12263 the function @code{foo}, followed by the word @code{message}.
12265 @smallexample
12266 const char*
12267 function (const char *func = __builtin_FUNCTION ())
12269   return func;
12272 void foo (void)
12274   printf ("%s:%i: %s: message\n", file (), line (), function ());
12276 @end smallexample
12278 @end deftypefn
12280 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12281 This function is used to flush the processor's instruction cache for
12282 the region of memory between @var{begin} inclusive and @var{end}
12283 exclusive.  Some targets require that the instruction cache be
12284 flushed, after modifying memory containing code, in order to obtain
12285 deterministic behavior.
12287 If the target does not require instruction cache flushes,
12288 @code{__builtin___clear_cache} has no effect.  Otherwise either
12289 instructions are emitted in-line to clear the instruction cache or a
12290 call to the @code{__clear_cache} function in libgcc is made.
12291 @end deftypefn
12293 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12294 This function is used to minimize cache-miss latency by moving data into
12295 a cache before it is accessed.
12296 You can insert calls to @code{__builtin_prefetch} into code for which
12297 you know addresses of data in memory that is likely to be accessed soon.
12298 If the target supports them, data prefetch instructions are generated.
12299 If the prefetch is done early enough before the access then the data will
12300 be in the cache by the time it is accessed.
12302 The value of @var{addr} is the address of the memory to prefetch.
12303 There are two optional arguments, @var{rw} and @var{locality}.
12304 The value of @var{rw} is a compile-time constant one or zero; one
12305 means that the prefetch is preparing for a write to the memory address
12306 and zero, the default, means that the prefetch is preparing for a read.
12307 The value @var{locality} must be a compile-time constant integer between
12308 zero and three.  A value of zero means that the data has no temporal
12309 locality, so it need not be left in the cache after the access.  A value
12310 of three means that the data has a high degree of temporal locality and
12311 should be left in all levels of cache possible.  Values of one and two
12312 mean, respectively, a low or moderate degree of temporal locality.  The
12313 default is three.
12315 @smallexample
12316 for (i = 0; i < n; i++)
12317   @{
12318     a[i] = a[i] + b[i];
12319     __builtin_prefetch (&a[i+j], 1, 1);
12320     __builtin_prefetch (&b[i+j], 0, 1);
12321     /* @r{@dots{}} */
12322   @}
12323 @end smallexample
12325 Data prefetch does not generate faults if @var{addr} is invalid, but
12326 the address expression itself must be valid.  For example, a prefetch
12327 of @code{p->next} does not fault if @code{p->next} is not a valid
12328 address, but evaluation faults if @code{p} is not a valid address.
12330 If the target does not support data prefetch, the address expression
12331 is evaluated if it includes side effects but no other code is generated
12332 and GCC does not issue a warning.
12333 @end deftypefn
12335 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12336 Returns a positive infinity, if supported by the floating-point format,
12337 else @code{DBL_MAX}.  This function is suitable for implementing the
12338 ISO C macro @code{HUGE_VAL}.
12339 @end deftypefn
12341 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12342 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12343 @end deftypefn
12345 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12346 Similar to @code{__builtin_huge_val}, except the return
12347 type is @code{long double}.
12348 @end deftypefn
12350 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12351 Similar to @code{__builtin_huge_val}, except the return type is
12352 @code{_Float@var{n}}.
12353 @end deftypefn
12355 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12356 Similar to @code{__builtin_huge_val}, except the return type is
12357 @code{_Float@var{n}x}.
12358 @end deftypefn
12360 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12361 This built-in implements the C99 fpclassify functionality.  The first
12362 five int arguments should be the target library's notion of the
12363 possible FP classes and are used for return values.  They must be
12364 constant values and they must appear in this order: @code{FP_NAN},
12365 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12366 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
12367 to classify.  GCC treats the last argument as type-generic, which
12368 means it does not do default promotion from float to double.
12369 @end deftypefn
12371 @deftypefn {Built-in Function} double __builtin_inf (void)
12372 Similar to @code{__builtin_huge_val}, except a warning is generated
12373 if the target floating-point format does not support infinities.
12374 @end deftypefn
12376 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12377 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12378 @end deftypefn
12380 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12381 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12382 @end deftypefn
12384 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12385 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12386 @end deftypefn
12388 @deftypefn {Built-in Function} float __builtin_inff (void)
12389 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12390 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12391 @end deftypefn
12393 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12394 Similar to @code{__builtin_inf}, except the return
12395 type is @code{long double}.
12396 @end deftypefn
12398 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12399 Similar to @code{__builtin_inf}, except the return
12400 type is @code{_Float@var{n}}.
12401 @end deftypefn
12403 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12404 Similar to @code{__builtin_inf}, except the return
12405 type is @code{_Float@var{n}x}.
12406 @end deftypefn
12408 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12409 Similar to @code{isinf}, except the return value is -1 for
12410 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12411 Note while the parameter list is an
12412 ellipsis, this function only accepts exactly one floating-point
12413 argument.  GCC treats this parameter as type-generic, which means it
12414 does not do default promotion from float to double.
12415 @end deftypefn
12417 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12418 This is an implementation of the ISO C99 function @code{nan}.
12420 Since ISO C99 defines this function in terms of @code{strtod}, which we
12421 do not implement, a description of the parsing is in order.  The string
12422 is parsed as by @code{strtol}; that is, the base is recognized by
12423 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12424 in the significand such that the least significant bit of the number
12425 is at the least significant bit of the significand.  The number is
12426 truncated to fit the significand field provided.  The significand is
12427 forced to be a quiet NaN@.
12429 This function, if given a string literal all of which would have been
12430 consumed by @code{strtol}, is evaluated early enough that it is considered a
12431 compile-time constant.
12432 @end deftypefn
12434 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12435 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12436 @end deftypefn
12438 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12439 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12440 @end deftypefn
12442 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12443 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12444 @end deftypefn
12446 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12447 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12448 @end deftypefn
12450 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12451 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12452 @end deftypefn
12454 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12455 Similar to @code{__builtin_nan}, except the return type is
12456 @code{_Float@var{n}}.
12457 @end deftypefn
12459 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12460 Similar to @code{__builtin_nan}, except the return type is
12461 @code{_Float@var{n}x}.
12462 @end deftypefn
12464 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12465 Similar to @code{__builtin_nan}, except the significand is forced
12466 to be a signaling NaN@.  The @code{nans} function is proposed by
12467 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12468 @end deftypefn
12470 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12471 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12472 @end deftypefn
12474 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12475 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12476 @end deftypefn
12478 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12479 Similar to @code{__builtin_nans}, except the return type is
12480 @code{_Float@var{n}}.
12481 @end deftypefn
12483 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12484 Similar to @code{__builtin_nans}, except the return type is
12485 @code{_Float@var{n}x}.
12486 @end deftypefn
12488 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12489 Returns one plus the index of the least significant 1-bit of @var{x}, or
12490 if @var{x} is zero, returns zero.
12491 @end deftypefn
12493 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12494 Returns the number of leading 0-bits in @var{x}, starting at the most
12495 significant bit position.  If @var{x} is 0, the result is undefined.
12496 @end deftypefn
12498 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12499 Returns the number of trailing 0-bits in @var{x}, starting at the least
12500 significant bit position.  If @var{x} is 0, the result is undefined.
12501 @end deftypefn
12503 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12504 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12505 number of bits following the most significant bit that are identical
12506 to it.  There are no special cases for 0 or other values. 
12507 @end deftypefn
12509 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12510 Returns the number of 1-bits in @var{x}.
12511 @end deftypefn
12513 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12514 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12515 modulo 2.
12516 @end deftypefn
12518 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12519 Similar to @code{__builtin_ffs}, except the argument type is
12520 @code{long}.
12521 @end deftypefn
12523 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12524 Similar to @code{__builtin_clz}, except the argument type is
12525 @code{unsigned long}.
12526 @end deftypefn
12528 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12529 Similar to @code{__builtin_ctz}, except the argument type is
12530 @code{unsigned long}.
12531 @end deftypefn
12533 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12534 Similar to @code{__builtin_clrsb}, except the argument type is
12535 @code{long}.
12536 @end deftypefn
12538 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12539 Similar to @code{__builtin_popcount}, except the argument type is
12540 @code{unsigned long}.
12541 @end deftypefn
12543 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12544 Similar to @code{__builtin_parity}, except the argument type is
12545 @code{unsigned long}.
12546 @end deftypefn
12548 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12549 Similar to @code{__builtin_ffs}, except the argument type is
12550 @code{long long}.
12551 @end deftypefn
12553 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12554 Similar to @code{__builtin_clz}, except the argument type is
12555 @code{unsigned long long}.
12556 @end deftypefn
12558 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12559 Similar to @code{__builtin_ctz}, except the argument type is
12560 @code{unsigned long long}.
12561 @end deftypefn
12563 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12564 Similar to @code{__builtin_clrsb}, except the argument type is
12565 @code{long long}.
12566 @end deftypefn
12568 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12569 Similar to @code{__builtin_popcount}, except the argument type is
12570 @code{unsigned long long}.
12571 @end deftypefn
12573 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12574 Similar to @code{__builtin_parity}, except the argument type is
12575 @code{unsigned long long}.
12576 @end deftypefn
12578 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12579 Returns the first argument raised to the power of the second.  Unlike the
12580 @code{pow} function no guarantees about precision and rounding are made.
12581 @end deftypefn
12583 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12584 Similar to @code{__builtin_powi}, except the argument and return types
12585 are @code{float}.
12586 @end deftypefn
12588 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12589 Similar to @code{__builtin_powi}, except the argument and return types
12590 are @code{long double}.
12591 @end deftypefn
12593 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12594 Returns @var{x} with the order of the bytes reversed; for example,
12595 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12596 exactly 8 bits.
12597 @end deftypefn
12599 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12600 Similar to @code{__builtin_bswap16}, except the argument and return types
12601 are 32 bit.
12602 @end deftypefn
12604 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12605 Similar to @code{__builtin_bswap32}, except the argument and return types
12606 are 64 bit.
12607 @end deftypefn
12609 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12610 On targets where the user visible pointer size is smaller than the size
12611 of an actual hardware address this function returns the extended user
12612 pointer.  Targets where this is true included ILP32 mode on x86_64 or
12613 Aarch64.  This function is mainly useful when writing inline assembly
12614 code.
12615 @end deftypefn
12617 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12618 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12619 0, 1 or 2.
12620 @end deftypefn
12622 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12623 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12624 0, 1 or 2.
12625 @end deftypefn
12627 @node Target Builtins
12628 @section Built-in Functions Specific to Particular Target Machines
12630 On some target machines, GCC supports many built-in functions specific
12631 to those machines.  Generally these generate calls to specific machine
12632 instructions, but allow the compiler to schedule those calls.
12634 @menu
12635 * AArch64 Built-in Functions::
12636 * Alpha Built-in Functions::
12637 * Altera Nios II Built-in Functions::
12638 * ARC Built-in Functions::
12639 * ARC SIMD Built-in Functions::
12640 * ARM iWMMXt Built-in Functions::
12641 * ARM C Language Extensions (ACLE)::
12642 * ARM Floating Point Status and Control Intrinsics::
12643 * ARM ARMv8-M Security Extensions::
12644 * AVR Built-in Functions::
12645 * Blackfin Built-in Functions::
12646 * FR-V Built-in Functions::
12647 * MIPS DSP Built-in Functions::
12648 * MIPS Paired-Single Support::
12649 * MIPS Loongson Built-in Functions::
12650 * MIPS SIMD Architecture (MSA) Support::
12651 * Other MIPS Built-in Functions::
12652 * MSP430 Built-in Functions::
12653 * NDS32 Built-in Functions::
12654 * picoChip Built-in Functions::
12655 * Basic PowerPC Built-in Functions::
12656 * PowerPC AltiVec/VSX Built-in Functions::
12657 * PowerPC Hardware Transactional Memory Built-in Functions::
12658 * PowerPC Atomic Memory Operation Functions::
12659 * RX Built-in Functions::
12660 * S/390 System z Built-in Functions::
12661 * SH Built-in Functions::
12662 * SPARC VIS Built-in Functions::
12663 * SPU Built-in Functions::
12664 * TI C6X Built-in Functions::
12665 * TILE-Gx Built-in Functions::
12666 * TILEPro Built-in Functions::
12667 * x86 Built-in Functions::
12668 * x86 transactional memory intrinsics::
12669 * x86 control-flow protection intrinsics::
12670 @end menu
12672 @node AArch64 Built-in Functions
12673 @subsection AArch64 Built-in Functions
12675 These built-in functions are available for the AArch64 family of
12676 processors.
12677 @smallexample
12678 unsigned int __builtin_aarch64_get_fpcr ()
12679 void __builtin_aarch64_set_fpcr (unsigned int)
12680 unsigned int __builtin_aarch64_get_fpsr ()
12681 void __builtin_aarch64_set_fpsr (unsigned int)
12682 @end smallexample
12684 @node Alpha Built-in Functions
12685 @subsection Alpha Built-in Functions
12687 These built-in functions are available for the Alpha family of
12688 processors, depending on the command-line switches used.
12690 The following built-in functions are always available.  They
12691 all generate the machine instruction that is part of the name.
12693 @smallexample
12694 long __builtin_alpha_implver (void)
12695 long __builtin_alpha_rpcc (void)
12696 long __builtin_alpha_amask (long)
12697 long __builtin_alpha_cmpbge (long, long)
12698 long __builtin_alpha_extbl (long, long)
12699 long __builtin_alpha_extwl (long, long)
12700 long __builtin_alpha_extll (long, long)
12701 long __builtin_alpha_extql (long, long)
12702 long __builtin_alpha_extwh (long, long)
12703 long __builtin_alpha_extlh (long, long)
12704 long __builtin_alpha_extqh (long, long)
12705 long __builtin_alpha_insbl (long, long)
12706 long __builtin_alpha_inswl (long, long)
12707 long __builtin_alpha_insll (long, long)
12708 long __builtin_alpha_insql (long, long)
12709 long __builtin_alpha_inswh (long, long)
12710 long __builtin_alpha_inslh (long, long)
12711 long __builtin_alpha_insqh (long, long)
12712 long __builtin_alpha_mskbl (long, long)
12713 long __builtin_alpha_mskwl (long, long)
12714 long __builtin_alpha_mskll (long, long)
12715 long __builtin_alpha_mskql (long, long)
12716 long __builtin_alpha_mskwh (long, long)
12717 long __builtin_alpha_msklh (long, long)
12718 long __builtin_alpha_mskqh (long, long)
12719 long __builtin_alpha_umulh (long, long)
12720 long __builtin_alpha_zap (long, long)
12721 long __builtin_alpha_zapnot (long, long)
12722 @end smallexample
12724 The following built-in functions are always with @option{-mmax}
12725 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12726 later.  They all generate the machine instruction that is part
12727 of the name.
12729 @smallexample
12730 long __builtin_alpha_pklb (long)
12731 long __builtin_alpha_pkwb (long)
12732 long __builtin_alpha_unpkbl (long)
12733 long __builtin_alpha_unpkbw (long)
12734 long __builtin_alpha_minub8 (long, long)
12735 long __builtin_alpha_minsb8 (long, long)
12736 long __builtin_alpha_minuw4 (long, long)
12737 long __builtin_alpha_minsw4 (long, long)
12738 long __builtin_alpha_maxub8 (long, long)
12739 long __builtin_alpha_maxsb8 (long, long)
12740 long __builtin_alpha_maxuw4 (long, long)
12741 long __builtin_alpha_maxsw4 (long, long)
12742 long __builtin_alpha_perr (long, long)
12743 @end smallexample
12745 The following built-in functions are always with @option{-mcix}
12746 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12747 later.  They all generate the machine instruction that is part
12748 of the name.
12750 @smallexample
12751 long __builtin_alpha_cttz (long)
12752 long __builtin_alpha_ctlz (long)
12753 long __builtin_alpha_ctpop (long)
12754 @end smallexample
12756 The following built-in functions are available on systems that use the OSF/1
12757 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12758 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12759 @code{rdval} and @code{wrval}.
12761 @smallexample
12762 void *__builtin_thread_pointer (void)
12763 void __builtin_set_thread_pointer (void *)
12764 @end smallexample
12766 @node Altera Nios II Built-in Functions
12767 @subsection Altera Nios II Built-in Functions
12769 These built-in functions are available for the Altera Nios II
12770 family of processors.
12772 The following built-in functions are always available.  They
12773 all generate the machine instruction that is part of the name.
12775 @example
12776 int __builtin_ldbio (volatile const void *)
12777 int __builtin_ldbuio (volatile const void *)
12778 int __builtin_ldhio (volatile const void *)
12779 int __builtin_ldhuio (volatile const void *)
12780 int __builtin_ldwio (volatile const void *)
12781 void __builtin_stbio (volatile void *, int)
12782 void __builtin_sthio (volatile void *, int)
12783 void __builtin_stwio (volatile void *, int)
12784 void __builtin_sync (void)
12785 int __builtin_rdctl (int) 
12786 int __builtin_rdprs (int, int)
12787 void __builtin_wrctl (int, int)
12788 void __builtin_flushd (volatile void *)
12789 void __builtin_flushda (volatile void *)
12790 int __builtin_wrpie (int);
12791 void __builtin_eni (int);
12792 int __builtin_ldex (volatile const void *)
12793 int __builtin_stex (volatile void *, int)
12794 int __builtin_ldsex (volatile const void *)
12795 int __builtin_stsex (volatile void *, int)
12796 @end example
12798 The following built-in functions are always available.  They
12799 all generate a Nios II Custom Instruction. The name of the
12800 function represents the types that the function takes and
12801 returns. The letter before the @code{n} is the return type
12802 or void if absent. The @code{n} represents the first parameter
12803 to all the custom instructions, the custom instruction number.
12804 The two letters after the @code{n} represent the up to two
12805 parameters to the function.
12807 The letters represent the following data types:
12808 @table @code
12809 @item <no letter>
12810 @code{void} for return type and no parameter for parameter types.
12812 @item i
12813 @code{int} for return type and parameter type
12815 @item f
12816 @code{float} for return type and parameter type
12818 @item p
12819 @code{void *} for return type and parameter type
12821 @end table
12823 And the function names are:
12824 @example
12825 void __builtin_custom_n (void)
12826 void __builtin_custom_ni (int)
12827 void __builtin_custom_nf (float)
12828 void __builtin_custom_np (void *)
12829 void __builtin_custom_nii (int, int)
12830 void __builtin_custom_nif (int, float)
12831 void __builtin_custom_nip (int, void *)
12832 void __builtin_custom_nfi (float, int)
12833 void __builtin_custom_nff (float, float)
12834 void __builtin_custom_nfp (float, void *)
12835 void __builtin_custom_npi (void *, int)
12836 void __builtin_custom_npf (void *, float)
12837 void __builtin_custom_npp (void *, void *)
12838 int __builtin_custom_in (void)
12839 int __builtin_custom_ini (int)
12840 int __builtin_custom_inf (float)
12841 int __builtin_custom_inp (void *)
12842 int __builtin_custom_inii (int, int)
12843 int __builtin_custom_inif (int, float)
12844 int __builtin_custom_inip (int, void *)
12845 int __builtin_custom_infi (float, int)
12846 int __builtin_custom_inff (float, float)
12847 int __builtin_custom_infp (float, void *)
12848 int __builtin_custom_inpi (void *, int)
12849 int __builtin_custom_inpf (void *, float)
12850 int __builtin_custom_inpp (void *, void *)
12851 float __builtin_custom_fn (void)
12852 float __builtin_custom_fni (int)
12853 float __builtin_custom_fnf (float)
12854 float __builtin_custom_fnp (void *)
12855 float __builtin_custom_fnii (int, int)
12856 float __builtin_custom_fnif (int, float)
12857 float __builtin_custom_fnip (int, void *)
12858 float __builtin_custom_fnfi (float, int)
12859 float __builtin_custom_fnff (float, float)
12860 float __builtin_custom_fnfp (float, void *)
12861 float __builtin_custom_fnpi (void *, int)
12862 float __builtin_custom_fnpf (void *, float)
12863 float __builtin_custom_fnpp (void *, void *)
12864 void * __builtin_custom_pn (void)
12865 void * __builtin_custom_pni (int)
12866 void * __builtin_custom_pnf (float)
12867 void * __builtin_custom_pnp (void *)
12868 void * __builtin_custom_pnii (int, int)
12869 void * __builtin_custom_pnif (int, float)
12870 void * __builtin_custom_pnip (int, void *)
12871 void * __builtin_custom_pnfi (float, int)
12872 void * __builtin_custom_pnff (float, float)
12873 void * __builtin_custom_pnfp (float, void *)
12874 void * __builtin_custom_pnpi (void *, int)
12875 void * __builtin_custom_pnpf (void *, float)
12876 void * __builtin_custom_pnpp (void *, void *)
12877 @end example
12879 @node ARC Built-in Functions
12880 @subsection ARC Built-in Functions
12882 The following built-in functions are provided for ARC targets.  The
12883 built-ins generate the corresponding assembly instructions.  In the
12884 examples given below, the generated code often requires an operand or
12885 result to be in a register.  Where necessary further code will be
12886 generated to ensure this is true, but for brevity this is not
12887 described in each case.
12889 @emph{Note:} Using a built-in to generate an instruction not supported
12890 by a target may cause problems. At present the compiler is not
12891 guaranteed to detect such misuse, and as a result an internal compiler
12892 error may be generated.
12894 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12895 Return 1 if @var{val} is known to have the byte alignment given
12896 by @var{alignval}, otherwise return 0.
12897 Note that this is different from
12898 @smallexample
12899 __alignof__(*(char *)@var{val}) >= alignval
12900 @end smallexample
12901 because __alignof__ sees only the type of the dereference, whereas
12902 __builtin_arc_align uses alignment information from the pointer
12903 as well as from the pointed-to type.
12904 The information available will depend on optimization level.
12905 @end deftypefn
12907 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12908 Generates
12909 @example
12911 @end example
12912 @end deftypefn
12914 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12915 The operand is the number of a register to be read.  Generates:
12916 @example
12917 mov  @var{dest}, r@var{regno}
12918 @end example
12919 where the value in @var{dest} will be the result returned from the
12920 built-in.
12921 @end deftypefn
12923 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12924 The first operand is the number of a register to be written, the
12925 second operand is a compile time constant to write into that
12926 register.  Generates:
12927 @example
12928 mov  r@var{regno}, @var{val}
12929 @end example
12930 @end deftypefn
12932 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12933 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12934 Generates:
12935 @example
12936 divaw  @var{dest}, @var{a}, @var{b}
12937 @end example
12938 where the value in @var{dest} will be the result returned from the
12939 built-in.
12940 @end deftypefn
12942 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12943 Generates
12944 @example
12945 flag  @var{a}
12946 @end example
12947 @end deftypefn
12949 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12950 The operand, @var{auxv}, is the address of an auxiliary register and
12951 must be a compile time constant.  Generates:
12952 @example
12953 lr  @var{dest}, [@var{auxr}]
12954 @end example
12955 Where the value in @var{dest} will be the result returned from the
12956 built-in.
12957 @end deftypefn
12959 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12960 Only available with @option{-mmul64}.  Generates:
12961 @example
12962 mul64  @var{a}, @var{b}
12963 @end example
12964 @end deftypefn
12966 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12967 Only available with @option{-mmul64}.  Generates:
12968 @example
12969 mulu64  @var{a}, @var{b}
12970 @end example
12971 @end deftypefn
12973 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12974 Generates:
12975 @example
12977 @end example
12978 @end deftypefn
12980 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12981 Only valid if the @samp{norm} instruction is available through the
12982 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12983 Generates:
12984 @example
12985 norm  @var{dest}, @var{src}
12986 @end example
12987 Where the value in @var{dest} will be the result returned from the
12988 built-in.
12989 @end deftypefn
12991 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12992 Only valid if the @samp{normw} instruction is available through the
12993 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12994 Generates:
12995 @example
12996 normw  @var{dest}, @var{src}
12997 @end example
12998 Where the value in @var{dest} will be the result returned from the
12999 built-in.
13000 @end deftypefn
13002 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
13003 Generates:
13004 @example
13005 rtie
13006 @end example
13007 @end deftypefn
13009 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
13010 Generates:
13011 @example
13012 sleep  @var{a}
13013 @end example
13014 @end deftypefn
13016 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
13017 The first argument, @var{auxv}, is the address of an auxiliary
13018 register, the second argument, @var{val}, is a compile time constant
13019 to be written to the register.  Generates:
13020 @example
13021 sr  @var{auxr}, [@var{val}]
13022 @end example
13023 @end deftypefn
13025 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
13026 Only valid with @option{-mswap}.  Generates:
13027 @example
13028 swap  @var{dest}, @var{src}
13029 @end example
13030 Where the value in @var{dest} will be the result returned from the
13031 built-in.
13032 @end deftypefn
13034 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
13035 Generates:
13036 @example
13038 @end example
13039 @end deftypefn
13041 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
13042 Only available with @option{-mcpu=ARC700}.  Generates:
13043 @example
13044 sync
13045 @end example
13046 @end deftypefn
13048 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
13049 Only available with @option{-mcpu=ARC700}.  Generates:
13050 @example
13051 trap_s  @var{c}
13052 @end example
13053 @end deftypefn
13055 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
13056 Only available with @option{-mcpu=ARC700}.  Generates:
13057 @example
13058 unimp_s
13059 @end example
13060 @end deftypefn
13062 The instructions generated by the following builtins are not
13063 considered as candidates for scheduling.  They are not moved around by
13064 the compiler during scheduling, and thus can be expected to appear
13065 where they are put in the C code:
13066 @example
13067 __builtin_arc_brk()
13068 __builtin_arc_core_read()
13069 __builtin_arc_core_write()
13070 __builtin_arc_flag()
13071 __builtin_arc_lr()
13072 __builtin_arc_sleep()
13073 __builtin_arc_sr()
13074 __builtin_arc_swi()
13075 @end example
13077 @node ARC SIMD Built-in Functions
13078 @subsection ARC SIMD Built-in Functions
13080 SIMD builtins provided by the compiler can be used to generate the
13081 vector instructions.  This section describes the available builtins
13082 and their usage in programs.  With the @option{-msimd} option, the
13083 compiler provides 128-bit vector types, which can be specified using
13084 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
13085 can be included to use the following predefined types:
13086 @example
13087 typedef int __v4si   __attribute__((vector_size(16)));
13088 typedef short __v8hi __attribute__((vector_size(16)));
13089 @end example
13091 These types can be used to define 128-bit variables.  The built-in
13092 functions listed in the following section can be used on these
13093 variables to generate the vector operations.
13095 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
13096 @file{arc-simd.h} also provides equivalent macros called
13097 @code{_@var{someinsn}} that can be used for programming ease and
13098 improved readability.  The following macros for DMA control are also
13099 provided:
13100 @example
13101 #define _setup_dma_in_channel_reg _vdiwr
13102 #define _setup_dma_out_channel_reg _vdowr
13103 @end example
13105 The following is a complete list of all the SIMD built-ins provided
13106 for ARC, grouped by calling signature.
13108 The following take two @code{__v8hi} arguments and return a
13109 @code{__v8hi} result:
13110 @example
13111 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
13112 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
13113 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
13114 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
13115 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
13116 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
13117 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
13118 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
13119 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
13120 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
13121 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
13122 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
13123 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
13124 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
13125 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
13126 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
13127 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
13128 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
13129 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
13130 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
13131 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
13132 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13133 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13134 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13135 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13136 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13137 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13138 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13139 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13140 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13141 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13142 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13143 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13144 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13145 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13146 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13147 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13148 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13149 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13150 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13151 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13152 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13153 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13154 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13155 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13156 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13157 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13158 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13159 @end example
13161 The following take one @code{__v8hi} and one @code{int} argument and return a
13162 @code{__v8hi} result:
13164 @example
13165 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13166 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13167 __v8hi __builtin_arc_vbminw (__v8hi, int)
13168 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13169 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13170 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13171 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13172 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13173 @end example
13175 The following take one @code{__v8hi} argument and one @code{int} argument which
13176 must be a 3-bit compile time constant indicating a register number
13177 I0-I7.  They return a @code{__v8hi} result.
13178 @example
13179 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13180 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13181 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13182 @end example
13184 The following take one @code{__v8hi} argument and one @code{int}
13185 argument which must be a 6-bit compile time constant.  They return a
13186 @code{__v8hi} result.
13187 @example
13188 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13189 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13190 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13191 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13192 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13193 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13194 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13195 @end example
13197 The following take one @code{__v8hi} argument and one @code{int} argument which
13198 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13199 result.
13200 @example
13201 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13202 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13203 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13204 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13205 @end example
13207 The following take two @code{int} arguments, the second of which which
13208 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13209 result:
13210 @example
13211 __v8hi __builtin_arc_vmovaw (int, const int)
13212 __v8hi __builtin_arc_vmovw (int, const int)
13213 __v8hi __builtin_arc_vmovzw (int, const int)
13214 @end example
13216 The following take a single @code{__v8hi} argument and return a
13217 @code{__v8hi} result:
13218 @example
13219 __v8hi __builtin_arc_vabsaw (__v8hi)
13220 __v8hi __builtin_arc_vabsw (__v8hi)
13221 __v8hi __builtin_arc_vaddsuw (__v8hi)
13222 __v8hi __builtin_arc_vexch1 (__v8hi)
13223 __v8hi __builtin_arc_vexch2 (__v8hi)
13224 __v8hi __builtin_arc_vexch4 (__v8hi)
13225 __v8hi __builtin_arc_vsignw (__v8hi)
13226 __v8hi __builtin_arc_vupbaw (__v8hi)
13227 __v8hi __builtin_arc_vupbw (__v8hi)
13228 __v8hi __builtin_arc_vupsbaw (__v8hi)
13229 __v8hi __builtin_arc_vupsbw (__v8hi)
13230 @end example
13232 The following take two @code{int} arguments and return no result:
13233 @example
13234 void __builtin_arc_vdirun (int, int)
13235 void __builtin_arc_vdorun (int, int)
13236 @end example
13238 The following take two @code{int} arguments and return no result.  The
13239 first argument must a 3-bit compile time constant indicating one of
13240 the DR0-DR7 DMA setup channels:
13241 @example
13242 void __builtin_arc_vdiwr (const int, int)
13243 void __builtin_arc_vdowr (const int, int)
13244 @end example
13246 The following take an @code{int} argument and return no result:
13247 @example
13248 void __builtin_arc_vendrec (int)
13249 void __builtin_arc_vrec (int)
13250 void __builtin_arc_vrecrun (int)
13251 void __builtin_arc_vrun (int)
13252 @end example
13254 The following take a @code{__v8hi} argument and two @code{int}
13255 arguments and return a @code{__v8hi} result.  The second argument must
13256 be a 3-bit compile time constants, indicating one the registers I0-I7,
13257 and the third argument must be an 8-bit compile time constant.
13259 @emph{Note:} Although the equivalent hardware instructions do not take
13260 an SIMD register as an operand, these builtins overwrite the relevant
13261 bits of the @code{__v8hi} register provided as the first argument with
13262 the value loaded from the @code{[Ib, u8]} location in the SDM.
13264 @example
13265 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13266 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13267 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13268 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13269 @end example
13271 The following take two @code{int} arguments and return a @code{__v8hi}
13272 result.  The first argument must be a 3-bit compile time constants,
13273 indicating one the registers I0-I7, and the second argument must be an
13274 8-bit compile time constant.
13276 @example
13277 __v8hi __builtin_arc_vld128 (const int, const int)
13278 __v8hi __builtin_arc_vld64w (const int, const int)
13279 @end example
13281 The following take a @code{__v8hi} argument and two @code{int}
13282 arguments and return no result.  The second argument must be a 3-bit
13283 compile time constants, indicating one the registers I0-I7, and the
13284 third argument must be an 8-bit compile time constant.
13286 @example
13287 void __builtin_arc_vst128 (__v8hi, const int, const int)
13288 void __builtin_arc_vst64 (__v8hi, const int, const int)
13289 @end example
13291 The following take a @code{__v8hi} argument and three @code{int}
13292 arguments and return no result.  The second argument must be a 3-bit
13293 compile-time constant, identifying the 16-bit sub-register to be
13294 stored, the third argument must be a 3-bit compile time constants,
13295 indicating one the registers I0-I7, and the fourth argument must be an
13296 8-bit compile time constant.
13298 @example
13299 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13300 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13301 @end example
13303 @node ARM iWMMXt Built-in Functions
13304 @subsection ARM iWMMXt Built-in Functions
13306 These built-in functions are available for the ARM family of
13307 processors when the @option{-mcpu=iwmmxt} switch is used:
13309 @smallexample
13310 typedef int v2si __attribute__ ((vector_size (8)));
13311 typedef short v4hi __attribute__ ((vector_size (8)));
13312 typedef char v8qi __attribute__ ((vector_size (8)));
13314 int __builtin_arm_getwcgr0 (void)
13315 void __builtin_arm_setwcgr0 (int)
13316 int __builtin_arm_getwcgr1 (void)
13317 void __builtin_arm_setwcgr1 (int)
13318 int __builtin_arm_getwcgr2 (void)
13319 void __builtin_arm_setwcgr2 (int)
13320 int __builtin_arm_getwcgr3 (void)
13321 void __builtin_arm_setwcgr3 (int)
13322 int __builtin_arm_textrmsb (v8qi, int)
13323 int __builtin_arm_textrmsh (v4hi, int)
13324 int __builtin_arm_textrmsw (v2si, int)
13325 int __builtin_arm_textrmub (v8qi, int)
13326 int __builtin_arm_textrmuh (v4hi, int)
13327 int __builtin_arm_textrmuw (v2si, int)
13328 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13329 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13330 v2si __builtin_arm_tinsrw (v2si, int, int)
13331 long long __builtin_arm_tmia (long long, int, int)
13332 long long __builtin_arm_tmiabb (long long, int, int)
13333 long long __builtin_arm_tmiabt (long long, int, int)
13334 long long __builtin_arm_tmiaph (long long, int, int)
13335 long long __builtin_arm_tmiatb (long long, int, int)
13336 long long __builtin_arm_tmiatt (long long, int, int)
13337 int __builtin_arm_tmovmskb (v8qi)
13338 int __builtin_arm_tmovmskh (v4hi)
13339 int __builtin_arm_tmovmskw (v2si)
13340 long long __builtin_arm_waccb (v8qi)
13341 long long __builtin_arm_wacch (v4hi)
13342 long long __builtin_arm_waccw (v2si)
13343 v8qi __builtin_arm_waddb (v8qi, v8qi)
13344 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13345 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13346 v4hi __builtin_arm_waddh (v4hi, v4hi)
13347 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13348 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13349 v2si __builtin_arm_waddw (v2si, v2si)
13350 v2si __builtin_arm_waddwss (v2si, v2si)
13351 v2si __builtin_arm_waddwus (v2si, v2si)
13352 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13353 long long __builtin_arm_wand(long long, long long)
13354 long long __builtin_arm_wandn (long long, long long)
13355 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13356 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13357 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13358 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13359 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13360 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13361 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13362 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13363 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13364 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13365 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13366 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13367 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13368 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13369 long long __builtin_arm_wmacsz (v4hi, v4hi)
13370 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13371 long long __builtin_arm_wmacuz (v4hi, v4hi)
13372 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13373 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13374 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13375 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13376 v2si __builtin_arm_wmaxsw (v2si, v2si)
13377 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13378 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13379 v2si __builtin_arm_wmaxuw (v2si, v2si)
13380 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13381 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13382 v2si __builtin_arm_wminsw (v2si, v2si)
13383 v8qi __builtin_arm_wminub (v8qi, v8qi)
13384 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13385 v2si __builtin_arm_wminuw (v2si, v2si)
13386 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13387 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13388 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13389 long long __builtin_arm_wor (long long, long long)
13390 v2si __builtin_arm_wpackdss (long long, long long)
13391 v2si __builtin_arm_wpackdus (long long, long long)
13392 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13393 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13394 v4hi __builtin_arm_wpackwss (v2si, v2si)
13395 v4hi __builtin_arm_wpackwus (v2si, v2si)
13396 long long __builtin_arm_wrord (long long, long long)
13397 long long __builtin_arm_wrordi (long long, int)
13398 v4hi __builtin_arm_wrorh (v4hi, long long)
13399 v4hi __builtin_arm_wrorhi (v4hi, int)
13400 v2si __builtin_arm_wrorw (v2si, long long)
13401 v2si __builtin_arm_wrorwi (v2si, int)
13402 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13403 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13404 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13405 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13406 v4hi __builtin_arm_wshufh (v4hi, int)
13407 long long __builtin_arm_wslld (long long, long long)
13408 long long __builtin_arm_wslldi (long long, int)
13409 v4hi __builtin_arm_wsllh (v4hi, long long)
13410 v4hi __builtin_arm_wsllhi (v4hi, int)
13411 v2si __builtin_arm_wsllw (v2si, long long)
13412 v2si __builtin_arm_wsllwi (v2si, int)
13413 long long __builtin_arm_wsrad (long long, long long)
13414 long long __builtin_arm_wsradi (long long, int)
13415 v4hi __builtin_arm_wsrah (v4hi, long long)
13416 v4hi __builtin_arm_wsrahi (v4hi, int)
13417 v2si __builtin_arm_wsraw (v2si, long long)
13418 v2si __builtin_arm_wsrawi (v2si, int)
13419 long long __builtin_arm_wsrld (long long, long long)
13420 long long __builtin_arm_wsrldi (long long, int)
13421 v4hi __builtin_arm_wsrlh (v4hi, long long)
13422 v4hi __builtin_arm_wsrlhi (v4hi, int)
13423 v2si __builtin_arm_wsrlw (v2si, long long)
13424 v2si __builtin_arm_wsrlwi (v2si, int)
13425 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13426 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13427 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13428 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13429 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13430 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13431 v2si __builtin_arm_wsubw (v2si, v2si)
13432 v2si __builtin_arm_wsubwss (v2si, v2si)
13433 v2si __builtin_arm_wsubwus (v2si, v2si)
13434 v4hi __builtin_arm_wunpckehsb (v8qi)
13435 v2si __builtin_arm_wunpckehsh (v4hi)
13436 long long __builtin_arm_wunpckehsw (v2si)
13437 v4hi __builtin_arm_wunpckehub (v8qi)
13438 v2si __builtin_arm_wunpckehuh (v4hi)
13439 long long __builtin_arm_wunpckehuw (v2si)
13440 v4hi __builtin_arm_wunpckelsb (v8qi)
13441 v2si __builtin_arm_wunpckelsh (v4hi)
13442 long long __builtin_arm_wunpckelsw (v2si)
13443 v4hi __builtin_arm_wunpckelub (v8qi)
13444 v2si __builtin_arm_wunpckeluh (v4hi)
13445 long long __builtin_arm_wunpckeluw (v2si)
13446 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13447 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13448 v2si __builtin_arm_wunpckihw (v2si, v2si)
13449 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13450 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13451 v2si __builtin_arm_wunpckilw (v2si, v2si)
13452 long long __builtin_arm_wxor (long long, long long)
13453 long long __builtin_arm_wzero ()
13454 @end smallexample
13457 @node ARM C Language Extensions (ACLE)
13458 @subsection ARM C Language Extensions (ACLE)
13460 GCC implements extensions for C as described in the ARM C Language
13461 Extensions (ACLE) specification, which can be found at
13462 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13464 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13465 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13466 intrinsics can be found at
13467 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13468 The built-in intrinsics for the Advanced SIMD extension are available when
13469 NEON is enabled.
13471 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13472 back ends support CRC32 intrinsics and the ARM back end supports the
13473 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13474 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13475 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13476 intrinsics yet.
13478 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13479 availability of extensions.
13481 @node ARM Floating Point Status and Control Intrinsics
13482 @subsection ARM Floating Point Status and Control Intrinsics
13484 These built-in functions are available for the ARM family of
13485 processors with floating-point unit.
13487 @smallexample
13488 unsigned int __builtin_arm_get_fpscr ()
13489 void __builtin_arm_set_fpscr (unsigned int)
13490 @end smallexample
13492 @node ARM ARMv8-M Security Extensions
13493 @subsection ARM ARMv8-M Security Extensions
13495 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13496 Security Extensions: Requirements on Development Tools Engineering
13497 Specification, which can be found at
13498 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13500 As part of the Security Extensions GCC implements two new function attributes:
13501 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13503 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13504 is used here to mean any function pointer type.
13506 @smallexample
13507 cmse_address_info_t cmse_TT (void *)
13508 cmse_address_info_t cmse_TT_fptr (FPTR)
13509 cmse_address_info_t cmse_TTT (void *)
13510 cmse_address_info_t cmse_TTT_fptr (FPTR)
13511 cmse_address_info_t cmse_TTA (void *)
13512 cmse_address_info_t cmse_TTA_fptr (FPTR)
13513 cmse_address_info_t cmse_TTAT (void *)
13514 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13515 void * cmse_check_address_range (void *, size_t, int)
13516 typeof(p) cmse_nsfptr_create (FPTR p)
13517 intptr_t cmse_is_nsfptr (FPTR)
13518 int cmse_nonsecure_caller (void)
13519 @end smallexample
13521 @node AVR Built-in Functions
13522 @subsection AVR Built-in Functions
13524 For each built-in function for AVR, there is an equally named,
13525 uppercase built-in macro defined. That way users can easily query if
13526 or if not a specific built-in is implemented or not. For example, if
13527 @code{__builtin_avr_nop} is available the macro
13528 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13530 @table @code
13532 @item void __builtin_avr_nop (void)
13533 @itemx void __builtin_avr_sei (void)
13534 @itemx void __builtin_avr_cli (void)
13535 @itemx void __builtin_avr_sleep (void)
13536 @itemx void __builtin_avr_wdr (void)
13537 @itemx unsigned char __builtin_avr_swap (unsigned char)
13538 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13539 @itemx int __builtin_avr_fmuls (char, char)
13540 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13541 These built-in functions map to the respective machine
13542 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13543 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13544 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13545 as library call if no hardware multiplier is available.
13547 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13548 Delay execution for @var{ticks} cycles. Note that this
13549 built-in does not take into account the effect of interrupts that
13550 might increase delay time. @var{ticks} must be a compile-time
13551 integer constant; delays with a variable number of cycles are not supported.
13553 @item char __builtin_avr_flash_segment (const __memx void*)
13554 This built-in takes a byte address to the 24-bit
13555 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13556 the number of the flash segment (the 64 KiB chunk) where the address
13557 points to.  Counting starts at @code{0}.
13558 If the address does not point to flash memory, return @code{-1}.
13560 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13561 Insert bits from @var{bits} into @var{val} and return the resulting
13562 value. The nibbles of @var{map} determine how the insertion is
13563 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13564 @enumerate
13565 @item If @var{X} is @code{0xf},
13566 then the @var{n}-th bit of @var{val} is returned unaltered.
13568 @item If X is in the range 0@dots{}7,
13569 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13571 @item If X is in the range 8@dots{}@code{0xe},
13572 then the @var{n}-th result bit is undefined.
13573 @end enumerate
13575 @noindent
13576 One typical use case for this built-in is adjusting input and
13577 output values to non-contiguous port layouts. Some examples:
13579 @smallexample
13580 // same as val, bits is unused
13581 __builtin_avr_insert_bits (0xffffffff, bits, val)
13582 @end smallexample
13584 @smallexample
13585 // same as bits, val is unused
13586 __builtin_avr_insert_bits (0x76543210, bits, val)
13587 @end smallexample
13589 @smallexample
13590 // same as rotating bits by 4
13591 __builtin_avr_insert_bits (0x32107654, bits, 0)
13592 @end smallexample
13594 @smallexample
13595 // high nibble of result is the high nibble of val
13596 // low nibble of result is the low nibble of bits
13597 __builtin_avr_insert_bits (0xffff3210, bits, val)
13598 @end smallexample
13600 @smallexample
13601 // reverse the bit order of bits
13602 __builtin_avr_insert_bits (0x01234567, bits, 0)
13603 @end smallexample
13605 @item void __builtin_avr_nops (unsigned count)
13606 Insert @var{count} @code{NOP} instructions.
13607 The number of instructions must be a compile-time integer constant.
13609 @end table
13611 @noindent
13612 There are many more AVR-specific built-in functions that are used to
13613 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13614 section 7.18a.6.  You don't need to use these built-ins directly.
13615 Instead, use the declarations as supplied by the @code{stdfix.h} header
13616 with GNU-C99:
13618 @smallexample
13619 #include <stdfix.h>
13621 // Re-interpret the bit representation of unsigned 16-bit
13622 // integer @var{uval} as Q-format 0.16 value.
13623 unsigned fract get_bits (uint_ur_t uval)
13625     return urbits (uval);
13627 @end smallexample
13629 @node Blackfin Built-in Functions
13630 @subsection Blackfin Built-in Functions
13632 Currently, there are two Blackfin-specific built-in functions.  These are
13633 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13634 using inline assembly; by using these built-in functions the compiler can
13635 automatically add workarounds for hardware errata involving these
13636 instructions.  These functions are named as follows:
13638 @smallexample
13639 void __builtin_bfin_csync (void)
13640 void __builtin_bfin_ssync (void)
13641 @end smallexample
13643 @node FR-V Built-in Functions
13644 @subsection FR-V Built-in Functions
13646 GCC provides many FR-V-specific built-in functions.  In general,
13647 these functions are intended to be compatible with those described
13648 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13649 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13650 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13651 pointer rather than by value.
13653 Most of the functions are named after specific FR-V instructions.
13654 Such functions are said to be ``directly mapped'' and are summarized
13655 here in tabular form.
13657 @menu
13658 * Argument Types::
13659 * Directly-mapped Integer Functions::
13660 * Directly-mapped Media Functions::
13661 * Raw read/write Functions::
13662 * Other Built-in Functions::
13663 @end menu
13665 @node Argument Types
13666 @subsubsection Argument Types
13668 The arguments to the built-in functions can be divided into three groups:
13669 register numbers, compile-time constants and run-time values.  In order
13670 to make this classification clear at a glance, the arguments and return
13671 values are given the following pseudo types:
13673 @multitable @columnfractions .20 .30 .15 .35
13674 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13675 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13676 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13677 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13678 @item @code{uw2} @tab @code{unsigned long long} @tab No
13679 @tab an unsigned doubleword
13680 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13681 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13682 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13683 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13684 @end multitable
13686 These pseudo types are not defined by GCC, they are simply a notational
13687 convenience used in this manual.
13689 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13690 and @code{sw2} are evaluated at run time.  They correspond to
13691 register operands in the underlying FR-V instructions.
13693 @code{const} arguments represent immediate operands in the underlying
13694 FR-V instructions.  They must be compile-time constants.
13696 @code{acc} arguments are evaluated at compile time and specify the number
13697 of an accumulator register.  For example, an @code{acc} argument of 2
13698 selects the ACC2 register.
13700 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13701 number of an IACC register.  See @pxref{Other Built-in Functions}
13702 for more details.
13704 @node Directly-mapped Integer Functions
13705 @subsubsection Directly-Mapped Integer Functions
13707 The functions listed below map directly to FR-V I-type instructions.
13709 @multitable @columnfractions .45 .32 .23
13710 @item Function prototype @tab Example usage @tab Assembly output
13711 @item @code{sw1 __ADDSS (sw1, sw1)}
13712 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13713 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13714 @item @code{sw1 __SCAN (sw1, sw1)}
13715 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13716 @tab @code{SCAN @var{a},@var{b},@var{c}}
13717 @item @code{sw1 __SCUTSS (sw1)}
13718 @tab @code{@var{b} = __SCUTSS (@var{a})}
13719 @tab @code{SCUTSS @var{a},@var{b}}
13720 @item @code{sw1 __SLASS (sw1, sw1)}
13721 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13722 @tab @code{SLASS @var{a},@var{b},@var{c}}
13723 @item @code{void __SMASS (sw1, sw1)}
13724 @tab @code{__SMASS (@var{a}, @var{b})}
13725 @tab @code{SMASS @var{a},@var{b}}
13726 @item @code{void __SMSSS (sw1, sw1)}
13727 @tab @code{__SMSSS (@var{a}, @var{b})}
13728 @tab @code{SMSSS @var{a},@var{b}}
13729 @item @code{void __SMU (sw1, sw1)}
13730 @tab @code{__SMU (@var{a}, @var{b})}
13731 @tab @code{SMU @var{a},@var{b}}
13732 @item @code{sw2 __SMUL (sw1, sw1)}
13733 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13734 @tab @code{SMUL @var{a},@var{b},@var{c}}
13735 @item @code{sw1 __SUBSS (sw1, sw1)}
13736 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13737 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13738 @item @code{uw2 __UMUL (uw1, uw1)}
13739 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13740 @tab @code{UMUL @var{a},@var{b},@var{c}}
13741 @end multitable
13743 @node Directly-mapped Media Functions
13744 @subsubsection Directly-Mapped Media Functions
13746 The functions listed below map directly to FR-V M-type instructions.
13748 @multitable @columnfractions .45 .32 .23
13749 @item Function prototype @tab Example usage @tab Assembly output
13750 @item @code{uw1 __MABSHS (sw1)}
13751 @tab @code{@var{b} = __MABSHS (@var{a})}
13752 @tab @code{MABSHS @var{a},@var{b}}
13753 @item @code{void __MADDACCS (acc, acc)}
13754 @tab @code{__MADDACCS (@var{b}, @var{a})}
13755 @tab @code{MADDACCS @var{a},@var{b}}
13756 @item @code{sw1 __MADDHSS (sw1, sw1)}
13757 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13758 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13759 @item @code{uw1 __MADDHUS (uw1, uw1)}
13760 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13761 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13762 @item @code{uw1 __MAND (uw1, uw1)}
13763 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13764 @tab @code{MAND @var{a},@var{b},@var{c}}
13765 @item @code{void __MASACCS (acc, acc)}
13766 @tab @code{__MASACCS (@var{b}, @var{a})}
13767 @tab @code{MASACCS @var{a},@var{b}}
13768 @item @code{uw1 __MAVEH (uw1, uw1)}
13769 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13770 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13771 @item @code{uw2 __MBTOH (uw1)}
13772 @tab @code{@var{b} = __MBTOH (@var{a})}
13773 @tab @code{MBTOH @var{a},@var{b}}
13774 @item @code{void __MBTOHE (uw1 *, uw1)}
13775 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13776 @tab @code{MBTOHE @var{a},@var{b}}
13777 @item @code{void __MCLRACC (acc)}
13778 @tab @code{__MCLRACC (@var{a})}
13779 @tab @code{MCLRACC @var{a}}
13780 @item @code{void __MCLRACCA (void)}
13781 @tab @code{__MCLRACCA ()}
13782 @tab @code{MCLRACCA}
13783 @item @code{uw1 __Mcop1 (uw1, uw1)}
13784 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13785 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13786 @item @code{uw1 __Mcop2 (uw1, uw1)}
13787 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13788 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13789 @item @code{uw1 __MCPLHI (uw2, const)}
13790 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13791 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13792 @item @code{uw1 __MCPLI (uw2, const)}
13793 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13794 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13795 @item @code{void __MCPXIS (acc, sw1, sw1)}
13796 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13797 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13798 @item @code{void __MCPXIU (acc, uw1, uw1)}
13799 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13800 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13801 @item @code{void __MCPXRS (acc, sw1, sw1)}
13802 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13803 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13804 @item @code{void __MCPXRU (acc, uw1, uw1)}
13805 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13806 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13807 @item @code{uw1 __MCUT (acc, uw1)}
13808 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13809 @tab @code{MCUT @var{a},@var{b},@var{c}}
13810 @item @code{uw1 __MCUTSS (acc, sw1)}
13811 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13812 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13813 @item @code{void __MDADDACCS (acc, acc)}
13814 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13815 @tab @code{MDADDACCS @var{a},@var{b}}
13816 @item @code{void __MDASACCS (acc, acc)}
13817 @tab @code{__MDASACCS (@var{b}, @var{a})}
13818 @tab @code{MDASACCS @var{a},@var{b}}
13819 @item @code{uw2 __MDCUTSSI (acc, const)}
13820 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13821 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13822 @item @code{uw2 __MDPACKH (uw2, uw2)}
13823 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13824 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13825 @item @code{uw2 __MDROTLI (uw2, const)}
13826 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13827 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13828 @item @code{void __MDSUBACCS (acc, acc)}
13829 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13830 @tab @code{MDSUBACCS @var{a},@var{b}}
13831 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13832 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13833 @tab @code{MDUNPACKH @var{a},@var{b}}
13834 @item @code{uw2 __MEXPDHD (uw1, const)}
13835 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13836 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13837 @item @code{uw1 __MEXPDHW (uw1, const)}
13838 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13839 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13840 @item @code{uw1 __MHDSETH (uw1, const)}
13841 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13842 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13843 @item @code{sw1 __MHDSETS (const)}
13844 @tab @code{@var{b} = __MHDSETS (@var{a})}
13845 @tab @code{MHDSETS #@var{a},@var{b}}
13846 @item @code{uw1 __MHSETHIH (uw1, const)}
13847 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13848 @tab @code{MHSETHIH #@var{a},@var{b}}
13849 @item @code{sw1 __MHSETHIS (sw1, const)}
13850 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13851 @tab @code{MHSETHIS #@var{a},@var{b}}
13852 @item @code{uw1 __MHSETLOH (uw1, const)}
13853 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13854 @tab @code{MHSETLOH #@var{a},@var{b}}
13855 @item @code{sw1 __MHSETLOS (sw1, const)}
13856 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13857 @tab @code{MHSETLOS #@var{a},@var{b}}
13858 @item @code{uw1 __MHTOB (uw2)}
13859 @tab @code{@var{b} = __MHTOB (@var{a})}
13860 @tab @code{MHTOB @var{a},@var{b}}
13861 @item @code{void __MMACHS (acc, sw1, sw1)}
13862 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13863 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13864 @item @code{void __MMACHU (acc, uw1, uw1)}
13865 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13866 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13867 @item @code{void __MMRDHS (acc, sw1, sw1)}
13868 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13869 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13870 @item @code{void __MMRDHU (acc, uw1, uw1)}
13871 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13872 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13873 @item @code{void __MMULHS (acc, sw1, sw1)}
13874 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13875 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13876 @item @code{void __MMULHU (acc, uw1, uw1)}
13877 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13878 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13879 @item @code{void __MMULXHS (acc, sw1, sw1)}
13880 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13881 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13882 @item @code{void __MMULXHU (acc, uw1, uw1)}
13883 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13884 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13885 @item @code{uw1 __MNOT (uw1)}
13886 @tab @code{@var{b} = __MNOT (@var{a})}
13887 @tab @code{MNOT @var{a},@var{b}}
13888 @item @code{uw1 __MOR (uw1, uw1)}
13889 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13890 @tab @code{MOR @var{a},@var{b},@var{c}}
13891 @item @code{uw1 __MPACKH (uh, uh)}
13892 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13893 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13894 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13895 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13896 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13897 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13898 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13899 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13900 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13901 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13902 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13903 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13904 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13905 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13906 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13907 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13908 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13909 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13910 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13911 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13912 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13913 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13914 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13915 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13916 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13917 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13918 @item @code{void __MQMACHS (acc, sw2, sw2)}
13919 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13920 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13921 @item @code{void __MQMACHU (acc, uw2, uw2)}
13922 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13923 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13924 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13925 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13926 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13927 @item @code{void __MQMULHS (acc, sw2, sw2)}
13928 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13929 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13930 @item @code{void __MQMULHU (acc, uw2, uw2)}
13931 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13932 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13933 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13934 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13935 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13936 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13937 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13938 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13939 @item @code{sw2 __MQSATHS (sw2, sw2)}
13940 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13941 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13942 @item @code{uw2 __MQSLLHI (uw2, int)}
13943 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13944 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13945 @item @code{sw2 __MQSRAHI (sw2, int)}
13946 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13947 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13948 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13949 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13950 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13951 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13952 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13953 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13954 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13955 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13956 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13957 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13958 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13959 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13960 @item @code{uw1 __MRDACC (acc)}
13961 @tab @code{@var{b} = __MRDACC (@var{a})}
13962 @tab @code{MRDACC @var{a},@var{b}}
13963 @item @code{uw1 __MRDACCG (acc)}
13964 @tab @code{@var{b} = __MRDACCG (@var{a})}
13965 @tab @code{MRDACCG @var{a},@var{b}}
13966 @item @code{uw1 __MROTLI (uw1, const)}
13967 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13968 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13969 @item @code{uw1 __MROTRI (uw1, const)}
13970 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13971 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13972 @item @code{sw1 __MSATHS (sw1, sw1)}
13973 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13974 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13975 @item @code{uw1 __MSATHU (uw1, uw1)}
13976 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13977 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13978 @item @code{uw1 __MSLLHI (uw1, const)}
13979 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13980 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13981 @item @code{sw1 __MSRAHI (sw1, const)}
13982 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13983 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13984 @item @code{uw1 __MSRLHI (uw1, const)}
13985 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13986 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13987 @item @code{void __MSUBACCS (acc, acc)}
13988 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13989 @tab @code{MSUBACCS @var{a},@var{b}}
13990 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13991 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13992 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13993 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13994 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13995 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13996 @item @code{void __MTRAP (void)}
13997 @tab @code{__MTRAP ()}
13998 @tab @code{MTRAP}
13999 @item @code{uw2 __MUNPACKH (uw1)}
14000 @tab @code{@var{b} = __MUNPACKH (@var{a})}
14001 @tab @code{MUNPACKH @var{a},@var{b}}
14002 @item @code{uw1 __MWCUT (uw2, uw1)}
14003 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
14004 @tab @code{MWCUT @var{a},@var{b},@var{c}}
14005 @item @code{void __MWTACC (acc, uw1)}
14006 @tab @code{__MWTACC (@var{b}, @var{a})}
14007 @tab @code{MWTACC @var{a},@var{b}}
14008 @item @code{void __MWTACCG (acc, uw1)}
14009 @tab @code{__MWTACCG (@var{b}, @var{a})}
14010 @tab @code{MWTACCG @var{a},@var{b}}
14011 @item @code{uw1 __MXOR (uw1, uw1)}
14012 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
14013 @tab @code{MXOR @var{a},@var{b},@var{c}}
14014 @end multitable
14016 @node Raw read/write Functions
14017 @subsubsection Raw Read/Write Functions
14019 This sections describes built-in functions related to read and write
14020 instructions to access memory.  These functions generate
14021 @code{membar} instructions to flush the I/O load and stores where
14022 appropriate, as described in Fujitsu's manual described above.
14024 @table @code
14026 @item unsigned char __builtin_read8 (void *@var{data})
14027 @item unsigned short __builtin_read16 (void *@var{data})
14028 @item unsigned long __builtin_read32 (void *@var{data})
14029 @item unsigned long long __builtin_read64 (void *@var{data})
14031 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
14032 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
14033 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
14034 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
14035 @end table
14037 @node Other Built-in Functions
14038 @subsubsection Other Built-in Functions
14040 This section describes built-in functions that are not named after
14041 a specific FR-V instruction.
14043 @table @code
14044 @item sw2 __IACCreadll (iacc @var{reg})
14045 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
14046 for future expansion and must be 0.
14048 @item sw1 __IACCreadl (iacc @var{reg})
14049 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
14050 Other values of @var{reg} are rejected as invalid.
14052 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
14053 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
14054 is reserved for future expansion and must be 0.
14056 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
14057 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
14058 is 1.  Other values of @var{reg} are rejected as invalid.
14060 @item void __data_prefetch0 (const void *@var{x})
14061 Use the @code{dcpl} instruction to load the contents of address @var{x}
14062 into the data cache.
14064 @item void __data_prefetch (const void *@var{x})
14065 Use the @code{nldub} instruction to load the contents of address @var{x}
14066 into the data cache.  The instruction is issued in slot I1@.
14067 @end table
14069 @node MIPS DSP Built-in Functions
14070 @subsection MIPS DSP Built-in Functions
14072 The MIPS DSP Application-Specific Extension (ASE) includes new
14073 instructions that are designed to improve the performance of DSP and
14074 media applications.  It provides instructions that operate on packed
14075 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
14077 GCC supports MIPS DSP operations using both the generic
14078 vector extensions (@pxref{Vector Extensions}) and a collection of
14079 MIPS-specific built-in functions.  Both kinds of support are
14080 enabled by the @option{-mdsp} command-line option.
14082 Revision 2 of the ASE was introduced in the second half of 2006.
14083 This revision adds extra instructions to the original ASE, but is
14084 otherwise backwards-compatible with it.  You can select revision 2
14085 using the command-line option @option{-mdspr2}; this option implies
14086 @option{-mdsp}.
14088 The SCOUNT and POS bits of the DSP control register are global.  The
14089 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
14090 POS bits.  During optimization, the compiler does not delete these
14091 instructions and it does not delete calls to functions containing
14092 these instructions.
14094 At present, GCC only provides support for operations on 32-bit
14095 vectors.  The vector type associated with 8-bit integer data is
14096 usually called @code{v4i8}, the vector type associated with Q7
14097 is usually called @code{v4q7}, the vector type associated with 16-bit
14098 integer data is usually called @code{v2i16}, and the vector type
14099 associated with Q15 is usually called @code{v2q15}.  They can be
14100 defined in C as follows:
14102 @smallexample
14103 typedef signed char v4i8 __attribute__ ((vector_size(4)));
14104 typedef signed char v4q7 __attribute__ ((vector_size(4)));
14105 typedef short v2i16 __attribute__ ((vector_size(4)));
14106 typedef short v2q15 __attribute__ ((vector_size(4)));
14107 @end smallexample
14109 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
14110 initialized in the same way as aggregates.  For example:
14112 @smallexample
14113 v4i8 a = @{1, 2, 3, 4@};
14114 v4i8 b;
14115 b = (v4i8) @{5, 6, 7, 8@};
14117 v2q15 c = @{0x0fcb, 0x3a75@};
14118 v2q15 d;
14119 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
14120 @end smallexample
14122 @emph{Note:} The CPU's endianness determines the order in which values
14123 are packed.  On little-endian targets, the first value is the least
14124 significant and the last value is the most significant.  The opposite
14125 order applies to big-endian targets.  For example, the code above
14126 sets the lowest byte of @code{a} to @code{1} on little-endian targets
14127 and @code{4} on big-endian targets.
14129 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
14130 representation.  As shown in this example, the integer representation
14131 of a Q7 value can be obtained by multiplying the fractional value by
14132 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
14133 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
14134 @code{0x1.0p31}.
14136 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14137 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
14138 and @code{c} and @code{d} are @code{v2q15} values.
14140 @multitable @columnfractions .50 .50
14141 @item C code @tab MIPS instruction
14142 @item @code{a + b} @tab @code{addu.qb}
14143 @item @code{c + d} @tab @code{addq.ph}
14144 @item @code{a - b} @tab @code{subu.qb}
14145 @item @code{c - d} @tab @code{subq.ph}
14146 @end multitable
14148 The table below lists the @code{v2i16} operation for which
14149 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
14150 @code{v2i16} values.
14152 @multitable @columnfractions .50 .50
14153 @item C code @tab MIPS instruction
14154 @item @code{e * f} @tab @code{mul.ph}
14155 @end multitable
14157 It is easier to describe the DSP built-in functions if we first define
14158 the following types:
14160 @smallexample
14161 typedef int q31;
14162 typedef int i32;
14163 typedef unsigned int ui32;
14164 typedef long long a64;
14165 @end smallexample
14167 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14168 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14169 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
14170 @code{long long}, but we use @code{a64} to indicate values that are
14171 placed in one of the four DSP accumulators (@code{$ac0},
14172 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14174 Also, some built-in functions prefer or require immediate numbers as
14175 parameters, because the corresponding DSP instructions accept both immediate
14176 numbers and register operands, or accept immediate numbers only.  The
14177 immediate parameters are listed as follows.
14179 @smallexample
14180 imm0_3: 0 to 3.
14181 imm0_7: 0 to 7.
14182 imm0_15: 0 to 15.
14183 imm0_31: 0 to 31.
14184 imm0_63: 0 to 63.
14185 imm0_255: 0 to 255.
14186 imm_n32_31: -32 to 31.
14187 imm_n512_511: -512 to 511.
14188 @end smallexample
14190 The following built-in functions map directly to a particular MIPS DSP
14191 instruction.  Please refer to the architecture specification
14192 for details on what each instruction does.
14194 @smallexample
14195 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14196 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14197 q31 __builtin_mips_addq_s_w (q31, q31)
14198 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14199 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14200 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14201 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14202 q31 __builtin_mips_subq_s_w (q31, q31)
14203 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14204 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14205 i32 __builtin_mips_addsc (i32, i32)
14206 i32 __builtin_mips_addwc (i32, i32)
14207 i32 __builtin_mips_modsub (i32, i32)
14208 i32 __builtin_mips_raddu_w_qb (v4i8)
14209 v2q15 __builtin_mips_absq_s_ph (v2q15)
14210 q31 __builtin_mips_absq_s_w (q31)
14211 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14212 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14213 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14214 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14215 q31 __builtin_mips_preceq_w_phl (v2q15)
14216 q31 __builtin_mips_preceq_w_phr (v2q15)
14217 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14218 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14219 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14220 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14221 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14222 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14223 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14224 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14225 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14226 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14227 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14228 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14229 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14230 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14231 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14232 q31 __builtin_mips_shll_s_w (q31, i32)
14233 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14234 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14235 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14236 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14237 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14238 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14239 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14240 q31 __builtin_mips_shra_r_w (q31, i32)
14241 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14242 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14243 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14244 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14245 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14246 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14247 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14248 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14249 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14250 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14251 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14252 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14253 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14254 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14255 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14256 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14257 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14258 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14259 i32 __builtin_mips_bitrev (i32)
14260 i32 __builtin_mips_insv (i32, i32)
14261 v4i8 __builtin_mips_repl_qb (imm0_255)
14262 v4i8 __builtin_mips_repl_qb (i32)
14263 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14264 v2q15 __builtin_mips_repl_ph (i32)
14265 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14266 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14267 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14268 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14269 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14270 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14271 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14272 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14273 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14274 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14275 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14276 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14277 i32 __builtin_mips_extr_w (a64, imm0_31)
14278 i32 __builtin_mips_extr_w (a64, i32)
14279 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14280 i32 __builtin_mips_extr_s_h (a64, i32)
14281 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14282 i32 __builtin_mips_extr_rs_w (a64, i32)
14283 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14284 i32 __builtin_mips_extr_r_w (a64, i32)
14285 i32 __builtin_mips_extp (a64, imm0_31)
14286 i32 __builtin_mips_extp (a64, i32)
14287 i32 __builtin_mips_extpdp (a64, imm0_31)
14288 i32 __builtin_mips_extpdp (a64, i32)
14289 a64 __builtin_mips_shilo (a64, imm_n32_31)
14290 a64 __builtin_mips_shilo (a64, i32)
14291 a64 __builtin_mips_mthlip (a64, i32)
14292 void __builtin_mips_wrdsp (i32, imm0_63)
14293 i32 __builtin_mips_rddsp (imm0_63)
14294 i32 __builtin_mips_lbux (void *, i32)
14295 i32 __builtin_mips_lhx (void *, i32)
14296 i32 __builtin_mips_lwx (void *, i32)
14297 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14298 i32 __builtin_mips_bposge32 (void)
14299 a64 __builtin_mips_madd (a64, i32, i32);
14300 a64 __builtin_mips_maddu (a64, ui32, ui32);
14301 a64 __builtin_mips_msub (a64, i32, i32);
14302 a64 __builtin_mips_msubu (a64, ui32, ui32);
14303 a64 __builtin_mips_mult (i32, i32);
14304 a64 __builtin_mips_multu (ui32, ui32);
14305 @end smallexample
14307 The following built-in functions map directly to a particular MIPS DSP REV 2
14308 instruction.  Please refer to the architecture specification
14309 for details on what each instruction does.
14311 @smallexample
14312 v4q7 __builtin_mips_absq_s_qb (v4q7);
14313 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14314 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14315 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14316 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14317 i32 __builtin_mips_append (i32, i32, imm0_31);
14318 i32 __builtin_mips_balign (i32, i32, imm0_3);
14319 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14320 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14321 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14322 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14323 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14324 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14325 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14326 q31 __builtin_mips_mulq_rs_w (q31, q31);
14327 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14328 q31 __builtin_mips_mulq_s_w (q31, q31);
14329 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14330 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14331 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14332 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14333 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14334 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14335 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14336 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14337 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14338 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14339 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14340 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14341 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14342 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14343 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14344 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14345 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14346 q31 __builtin_mips_addqh_w (q31, q31);
14347 q31 __builtin_mips_addqh_r_w (q31, q31);
14348 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14349 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14350 q31 __builtin_mips_subqh_w (q31, q31);
14351 q31 __builtin_mips_subqh_r_w (q31, q31);
14352 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14353 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14354 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14355 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14356 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14357 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14358 @end smallexample
14361 @node MIPS Paired-Single Support
14362 @subsection MIPS Paired-Single Support
14364 The MIPS64 architecture includes a number of instructions that
14365 operate on pairs of single-precision floating-point values.
14366 Each pair is packed into a 64-bit floating-point register,
14367 with one element being designated the ``upper half'' and
14368 the other being designated the ``lower half''.
14370 GCC supports paired-single operations using both the generic
14371 vector extensions (@pxref{Vector Extensions}) and a collection of
14372 MIPS-specific built-in functions.  Both kinds of support are
14373 enabled by the @option{-mpaired-single} command-line option.
14375 The vector type associated with paired-single values is usually
14376 called @code{v2sf}.  It can be defined in C as follows:
14378 @smallexample
14379 typedef float v2sf __attribute__ ((vector_size (8)));
14380 @end smallexample
14382 @code{v2sf} values are initialized in the same way as aggregates.
14383 For example:
14385 @smallexample
14386 v2sf a = @{1.5, 9.1@};
14387 v2sf b;
14388 float e, f;
14389 b = (v2sf) @{e, f@};
14390 @end smallexample
14392 @emph{Note:} The CPU's endianness determines which value is stored in
14393 the upper half of a register and which value is stored in the lower half.
14394 On little-endian targets, the first value is the lower one and the second
14395 value is the upper one.  The opposite order applies to big-endian targets.
14396 For example, the code above sets the lower half of @code{a} to
14397 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14399 @node MIPS Loongson Built-in Functions
14400 @subsection MIPS Loongson Built-in Functions
14402 GCC provides intrinsics to access the SIMD instructions provided by the
14403 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
14404 available after inclusion of the @code{loongson.h} header file,
14405 operate on the following 64-bit vector types:
14407 @itemize
14408 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14409 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14410 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14411 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14412 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14413 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14414 @end itemize
14416 The intrinsics provided are listed below; each is named after the
14417 machine instruction to which it corresponds, with suffixes added as
14418 appropriate to distinguish intrinsics that expand to the same machine
14419 instruction yet have different argument types.  Refer to the architecture
14420 documentation for a description of the functionality of each
14421 instruction.
14423 @smallexample
14424 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14425 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14426 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14427 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14428 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14429 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14430 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14431 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14432 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14433 uint64_t paddd_u (uint64_t s, uint64_t t);
14434 int64_t paddd_s (int64_t s, int64_t t);
14435 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14436 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14437 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14438 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14439 uint64_t pandn_ud (uint64_t s, uint64_t t);
14440 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14441 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14442 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14443 int64_t pandn_sd (int64_t s, int64_t t);
14444 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14445 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14446 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14447 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14448 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14449 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14450 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14451 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14452 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14453 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14454 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14455 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14456 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14457 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14458 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14459 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14460 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14461 uint16x4_t pextrh_u (uint16x4_t s, int field);
14462 int16x4_t pextrh_s (int16x4_t s, int field);
14463 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14464 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14465 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14466 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14467 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14468 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14469 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14470 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14471 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14472 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14473 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14474 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14475 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14476 uint8x8_t pmovmskb_u (uint8x8_t s);
14477 int8x8_t pmovmskb_s (int8x8_t s);
14478 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14479 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14480 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14481 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14482 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14483 uint16x4_t biadd (uint8x8_t s);
14484 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14485 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14486 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14487 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14488 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14489 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14490 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14491 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14492 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14493 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14494 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14495 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14496 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14497 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14498 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14499 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14500 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14501 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14502 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14503 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14504 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14505 uint64_t psubd_u (uint64_t s, uint64_t t);
14506 int64_t psubd_s (int64_t s, int64_t t);
14507 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14508 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14509 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14510 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14511 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14512 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14513 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14514 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14515 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14516 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14517 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14518 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14519 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14520 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14521 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14522 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14523 @end smallexample
14525 @menu
14526 * Paired-Single Arithmetic::
14527 * Paired-Single Built-in Functions::
14528 * MIPS-3D Built-in Functions::
14529 @end menu
14531 @node Paired-Single Arithmetic
14532 @subsubsection Paired-Single Arithmetic
14534 The table below lists the @code{v2sf} operations for which hardware
14535 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14536 values and @code{x} is an integral value.
14538 @multitable @columnfractions .50 .50
14539 @item C code @tab MIPS instruction
14540 @item @code{a + b} @tab @code{add.ps}
14541 @item @code{a - b} @tab @code{sub.ps}
14542 @item @code{-a} @tab @code{neg.ps}
14543 @item @code{a * b} @tab @code{mul.ps}
14544 @item @code{a * b + c} @tab @code{madd.ps}
14545 @item @code{a * b - c} @tab @code{msub.ps}
14546 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14547 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14548 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14549 @end multitable
14551 Note that the multiply-accumulate instructions can be disabled
14552 using the command-line option @code{-mno-fused-madd}.
14554 @node Paired-Single Built-in Functions
14555 @subsubsection Paired-Single Built-in Functions
14557 The following paired-single functions map directly to a particular
14558 MIPS instruction.  Please refer to the architecture specification
14559 for details on what each instruction does.
14561 @table @code
14562 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14563 Pair lower lower (@code{pll.ps}).
14565 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14566 Pair upper lower (@code{pul.ps}).
14568 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14569 Pair lower upper (@code{plu.ps}).
14571 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14572 Pair upper upper (@code{puu.ps}).
14574 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14575 Convert pair to paired single (@code{cvt.ps.s}).
14577 @item float __builtin_mips_cvt_s_pl (v2sf)
14578 Convert pair lower to single (@code{cvt.s.pl}).
14580 @item float __builtin_mips_cvt_s_pu (v2sf)
14581 Convert pair upper to single (@code{cvt.s.pu}).
14583 @item v2sf __builtin_mips_abs_ps (v2sf)
14584 Absolute value (@code{abs.ps}).
14586 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14587 Align variable (@code{alnv.ps}).
14589 @emph{Note:} The value of the third parameter must be 0 or 4
14590 modulo 8, otherwise the result is unpredictable.  Please read the
14591 instruction description for details.
14592 @end table
14594 The following multi-instruction functions are also available.
14595 In each case, @var{cond} can be any of the 16 floating-point conditions:
14596 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14597 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14598 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14600 @table @code
14601 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14602 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14603 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14604 @code{movt.ps}/@code{movf.ps}).
14606 The @code{movt} functions return the value @var{x} computed by:
14608 @smallexample
14609 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14610 mov.ps @var{x},@var{c}
14611 movt.ps @var{x},@var{d},@var{cc}
14612 @end smallexample
14614 The @code{movf} functions are similar but use @code{movf.ps} instead
14615 of @code{movt.ps}.
14617 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14618 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14619 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14620 @code{bc1t}/@code{bc1f}).
14622 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14623 and return either the upper or lower half of the result.  For example:
14625 @smallexample
14626 v2sf a, b;
14627 if (__builtin_mips_upper_c_eq_ps (a, b))
14628   upper_halves_are_equal ();
14629 else
14630   upper_halves_are_unequal ();
14632 if (__builtin_mips_lower_c_eq_ps (a, b))
14633   lower_halves_are_equal ();
14634 else
14635   lower_halves_are_unequal ();
14636 @end smallexample
14637 @end table
14639 @node MIPS-3D Built-in Functions
14640 @subsubsection MIPS-3D Built-in Functions
14642 The MIPS-3D Application-Specific Extension (ASE) includes additional
14643 paired-single instructions that are designed to improve the performance
14644 of 3D graphics operations.  Support for these instructions is controlled
14645 by the @option{-mips3d} command-line option.
14647 The functions listed below map directly to a particular MIPS-3D
14648 instruction.  Please refer to the architecture specification for
14649 more details on what each instruction does.
14651 @table @code
14652 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14653 Reduction add (@code{addr.ps}).
14655 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14656 Reduction multiply (@code{mulr.ps}).
14658 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14659 Convert paired single to paired word (@code{cvt.pw.ps}).
14661 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14662 Convert paired word to paired single (@code{cvt.ps.pw}).
14664 @item float __builtin_mips_recip1_s (float)
14665 @itemx double __builtin_mips_recip1_d (double)
14666 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14667 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14669 @item float __builtin_mips_recip2_s (float, float)
14670 @itemx double __builtin_mips_recip2_d (double, double)
14671 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14672 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14674 @item float __builtin_mips_rsqrt1_s (float)
14675 @itemx double __builtin_mips_rsqrt1_d (double)
14676 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14677 Reduced-precision reciprocal square root (sequence step 1)
14678 (@code{rsqrt1.@var{fmt}}).
14680 @item float __builtin_mips_rsqrt2_s (float, float)
14681 @itemx double __builtin_mips_rsqrt2_d (double, double)
14682 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14683 Reduced-precision reciprocal square root (sequence step 2)
14684 (@code{rsqrt2.@var{fmt}}).
14685 @end table
14687 The following multi-instruction functions are also available.
14688 In each case, @var{cond} can be any of the 16 floating-point conditions:
14689 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14690 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14691 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14693 @table @code
14694 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14695 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14696 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14697 @code{bc1t}/@code{bc1f}).
14699 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14700 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14701 For example:
14703 @smallexample
14704 float a, b;
14705 if (__builtin_mips_cabs_eq_s (a, b))
14706   true ();
14707 else
14708   false ();
14709 @end smallexample
14711 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14712 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14713 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14714 @code{bc1t}/@code{bc1f}).
14716 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14717 and return either the upper or lower half of the result.  For example:
14719 @smallexample
14720 v2sf a, b;
14721 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14722   upper_halves_are_equal ();
14723 else
14724   upper_halves_are_unequal ();
14726 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14727   lower_halves_are_equal ();
14728 else
14729   lower_halves_are_unequal ();
14730 @end smallexample
14732 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14733 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14734 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14735 @code{movt.ps}/@code{movf.ps}).
14737 The @code{movt} functions return the value @var{x} computed by:
14739 @smallexample
14740 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14741 mov.ps @var{x},@var{c}
14742 movt.ps @var{x},@var{d},@var{cc}
14743 @end smallexample
14745 The @code{movf} functions are similar but use @code{movf.ps} instead
14746 of @code{movt.ps}.
14748 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14749 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14750 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14751 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14752 Comparison of two paired-single values
14753 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14754 @code{bc1any2t}/@code{bc1any2f}).
14756 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14757 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
14758 result is true and the @code{all} forms return true if both results are true.
14759 For example:
14761 @smallexample
14762 v2sf a, b;
14763 if (__builtin_mips_any_c_eq_ps (a, b))
14764   one_is_true ();
14765 else
14766   both_are_false ();
14768 if (__builtin_mips_all_c_eq_ps (a, b))
14769   both_are_true ();
14770 else
14771   one_is_false ();
14772 @end smallexample
14774 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14775 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14776 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14777 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14778 Comparison of four paired-single values
14779 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14780 @code{bc1any4t}/@code{bc1any4f}).
14782 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14783 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14784 The @code{any} forms return true if any of the four results are true
14785 and the @code{all} forms return true if all four results are true.
14786 For example:
14788 @smallexample
14789 v2sf a, b, c, d;
14790 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14791   some_are_true ();
14792 else
14793   all_are_false ();
14795 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14796   all_are_true ();
14797 else
14798   some_are_false ();
14799 @end smallexample
14800 @end table
14802 @node MIPS SIMD Architecture (MSA) Support
14803 @subsection MIPS SIMD Architecture (MSA) Support
14805 @menu
14806 * MIPS SIMD Architecture Built-in Functions::
14807 @end menu
14809 GCC provides intrinsics to access the SIMD instructions provided by the
14810 MSA MIPS SIMD Architecture.  The interface is made available by including
14811 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14812 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14813 @code{__msa_*}.
14815 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14816 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14817 data elements.  The following vectors typedefs are included in @code{msa.h}:
14818 @itemize
14819 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14820 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14821 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14822 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14823 @item @code{v4i32}, a vector of four signed 32-bit integers;
14824 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14825 @item @code{v2i64}, a vector of two signed 64-bit integers;
14826 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14827 @item @code{v4f32}, a vector of four 32-bit floats;
14828 @item @code{v2f64}, a vector of two 64-bit doubles.
14829 @end itemize
14831 Instructions and corresponding built-ins may have additional restrictions and/or
14832 input/output values manipulated:
14833 @itemize
14834 @item @code{imm0_1}, an integer literal in range 0 to 1;
14835 @item @code{imm0_3}, an integer literal in range 0 to 3;
14836 @item @code{imm0_7}, an integer literal in range 0 to 7;
14837 @item @code{imm0_15}, an integer literal in range 0 to 15;
14838 @item @code{imm0_31}, an integer literal in range 0 to 31;
14839 @item @code{imm0_63}, an integer literal in range 0 to 63;
14840 @item @code{imm0_255}, an integer literal in range 0 to 255;
14841 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14842 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14843 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14844 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14845 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14846 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14847 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14848 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14849 @item @code{imm1_4}, an integer literal in range 1 to 4;
14850 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14851 @end itemize
14853 @smallexample
14855 typedef int i32;
14856 #if __LONG_MAX__ == __LONG_LONG_MAX__
14857 typedef long i64;
14858 #else
14859 typedef long long i64;
14860 #endif
14862 typedef unsigned int u32;
14863 #if __LONG_MAX__ == __LONG_LONG_MAX__
14864 typedef unsigned long u64;
14865 #else
14866 typedef unsigned long long u64;
14867 #endif
14869 typedef double f64;
14870 typedef float f32;
14872 @end smallexample
14874 @node MIPS SIMD Architecture Built-in Functions
14875 @subsubsection MIPS SIMD Architecture Built-in Functions
14877 The intrinsics provided are listed below; each is named after the
14878 machine instruction.
14880 @smallexample
14881 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14882 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14883 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14884 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14886 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14887 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14888 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14889 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14891 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14892 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14893 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14894 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14896 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14897 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14898 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14899 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14901 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14902 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14903 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14904 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14906 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14907 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14908 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14909 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14911 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14913 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14915 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14916 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14917 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14918 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14920 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14921 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14922 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14923 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14925 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14926 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14927 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14928 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14930 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14931 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14932 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14933 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14935 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14936 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14937 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14938 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14940 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14941 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14942 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14943 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14945 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14946 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14947 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14948 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14950 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14951 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14952 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14953 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14955 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14956 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14957 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14958 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14960 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14961 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14962 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14963 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14965 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14966 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14967 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14968 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14970 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14971 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14972 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14973 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14975 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14977 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14979 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14981 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14983 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14984 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14985 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14986 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14988 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14989 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14990 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14991 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14993 i32 __builtin_msa_bnz_b (v16u8);
14994 i32 __builtin_msa_bnz_h (v8u16);
14995 i32 __builtin_msa_bnz_w (v4u32);
14996 i32 __builtin_msa_bnz_d (v2u64);
14998 i32 __builtin_msa_bnz_v (v16u8);
15000 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
15002 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
15004 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
15005 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
15006 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
15007 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
15009 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
15010 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
15011 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
15012 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
15014 i32 __builtin_msa_bz_b (v16u8);
15015 i32 __builtin_msa_bz_h (v8u16);
15016 i32 __builtin_msa_bz_w (v4u32);
15017 i32 __builtin_msa_bz_d (v2u64);
15019 i32 __builtin_msa_bz_v (v16u8);
15021 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
15022 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
15023 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
15024 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
15026 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
15027 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
15028 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
15029 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
15031 i32 __builtin_msa_cfcmsa (imm0_31);
15033 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
15034 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
15035 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
15036 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
15038 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
15039 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
15040 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
15041 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
15043 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
15044 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
15045 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
15046 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
15048 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
15049 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
15050 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
15051 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
15053 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
15054 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
15055 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
15056 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
15058 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
15059 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
15060 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
15061 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
15063 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
15064 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
15065 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
15066 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
15068 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
15069 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
15070 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
15071 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
15073 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
15074 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
15075 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
15076 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
15078 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
15079 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
15080 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
15081 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
15083 void __builtin_msa_ctcmsa (imm0_31, i32);
15085 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
15086 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
15087 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
15088 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
15090 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
15091 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
15092 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
15093 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
15095 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
15096 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
15097 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
15099 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
15100 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
15101 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
15103 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
15104 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
15105 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
15107 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
15108 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
15109 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
15111 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
15112 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
15113 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
15115 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
15116 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
15117 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
15119 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
15120 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
15122 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
15123 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
15125 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
15126 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
15128 v4i32 __builtin_msa_fclass_w (v4f32);
15129 v2i64 __builtin_msa_fclass_d (v2f64);
15131 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
15132 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15134 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15135 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15137 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15138 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15140 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15141 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15143 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15144 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15146 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15147 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15149 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15150 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15152 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15153 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15155 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15156 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15158 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15159 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15161 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15162 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15164 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15165 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15167 v4f32 __builtin_msa_fexupl_w (v8i16);
15168 v2f64 __builtin_msa_fexupl_d (v4f32);
15170 v4f32 __builtin_msa_fexupr_w (v8i16);
15171 v2f64 __builtin_msa_fexupr_d (v4f32);
15173 v4f32 __builtin_msa_ffint_s_w (v4i32);
15174 v2f64 __builtin_msa_ffint_s_d (v2i64);
15176 v4f32 __builtin_msa_ffint_u_w (v4u32);
15177 v2f64 __builtin_msa_ffint_u_d (v2u64);
15179 v4f32 __builtin_msa_ffql_w (v8i16);
15180 v2f64 __builtin_msa_ffql_d (v4i32);
15182 v4f32 __builtin_msa_ffqr_w (v8i16);
15183 v2f64 __builtin_msa_ffqr_d (v4i32);
15185 v16i8 __builtin_msa_fill_b (i32);
15186 v8i16 __builtin_msa_fill_h (i32);
15187 v4i32 __builtin_msa_fill_w (i32);
15188 v2i64 __builtin_msa_fill_d (i64);
15190 v4f32 __builtin_msa_flog2_w (v4f32);
15191 v2f64 __builtin_msa_flog2_d (v2f64);
15193 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15194 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15196 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15197 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15199 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15200 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15202 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15203 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15205 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15206 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15208 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15209 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15211 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15212 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15214 v4f32 __builtin_msa_frint_w (v4f32);
15215 v2f64 __builtin_msa_frint_d (v2f64);
15217 v4f32 __builtin_msa_frcp_w (v4f32);
15218 v2f64 __builtin_msa_frcp_d (v2f64);
15220 v4f32 __builtin_msa_frsqrt_w (v4f32);
15221 v2f64 __builtin_msa_frsqrt_d (v2f64);
15223 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15224 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15226 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15227 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15229 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15230 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15232 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15233 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15235 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15236 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15238 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15239 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15241 v4f32 __builtin_msa_fsqrt_w (v4f32);
15242 v2f64 __builtin_msa_fsqrt_d (v2f64);
15244 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15245 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15247 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15248 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15250 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15251 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15253 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15254 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15256 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15257 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15259 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15260 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15262 v4i32 __builtin_msa_ftint_s_w (v4f32);
15263 v2i64 __builtin_msa_ftint_s_d (v2f64);
15265 v4u32 __builtin_msa_ftint_u_w (v4f32);
15266 v2u64 __builtin_msa_ftint_u_d (v2f64);
15268 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15269 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15271 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15272 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15274 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15275 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15277 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15278 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15279 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15281 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15282 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15283 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15285 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15286 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15287 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15289 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15290 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15291 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15293 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15294 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15295 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15296 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15298 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15299 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15300 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15301 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15303 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15304 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15305 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15306 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15308 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15309 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15310 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15311 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15313 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15314 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15315 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15316 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15318 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15319 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15320 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15321 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15323 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15324 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15325 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15326 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15328 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15329 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15330 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15331 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15333 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15334 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15336 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15337 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15339 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15340 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15341 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15342 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15344 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15345 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15346 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15347 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15349 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15350 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15351 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15352 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15354 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15355 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15356 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15357 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15359 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15360 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15361 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15362 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15364 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15365 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15366 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15367 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15369 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15370 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15371 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15372 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15374 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15375 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15376 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15377 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15379 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15380 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15381 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15382 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15384 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15385 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15386 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15387 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15389 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15390 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15391 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15392 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15394 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15395 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15396 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15397 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15399 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15400 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15401 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15402 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15404 v16i8 __builtin_msa_move_v (v16i8);
15406 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15407 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15409 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15410 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15412 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15413 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15414 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15415 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15417 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15418 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15420 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15421 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15423 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15424 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15425 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15426 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15428 v16i8 __builtin_msa_nloc_b (v16i8);
15429 v8i16 __builtin_msa_nloc_h (v8i16);
15430 v4i32 __builtin_msa_nloc_w (v4i32);
15431 v2i64 __builtin_msa_nloc_d (v2i64);
15433 v16i8 __builtin_msa_nlzc_b (v16i8);
15434 v8i16 __builtin_msa_nlzc_h (v8i16);
15435 v4i32 __builtin_msa_nlzc_w (v4i32);
15436 v2i64 __builtin_msa_nlzc_d (v2i64);
15438 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15440 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15442 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15444 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15446 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15447 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15448 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15449 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15451 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15452 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15453 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15454 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15456 v16i8 __builtin_msa_pcnt_b (v16i8);
15457 v8i16 __builtin_msa_pcnt_h (v8i16);
15458 v4i32 __builtin_msa_pcnt_w (v4i32);
15459 v2i64 __builtin_msa_pcnt_d (v2i64);
15461 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15462 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15463 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15464 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15466 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15467 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15468 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15469 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15471 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15472 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15473 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15475 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15476 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15477 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15478 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15480 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15481 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15482 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15483 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15485 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15486 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15487 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15488 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15490 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15491 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15492 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15493 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15495 v16i8 __builtin_msa_splat_b (v16i8, i32);
15496 v8i16 __builtin_msa_splat_h (v8i16, i32);
15497 v4i32 __builtin_msa_splat_w (v4i32, i32);
15498 v2i64 __builtin_msa_splat_d (v2i64, i32);
15500 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15501 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15502 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15503 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15505 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15506 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15507 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15508 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15510 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15511 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15512 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15513 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15515 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15516 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15517 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15518 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15520 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15521 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15522 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15523 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15525 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15526 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15527 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15528 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15530 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15531 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15532 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15533 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15535 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15536 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15537 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15538 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15540 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15541 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15542 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15543 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15545 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15546 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15547 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15548 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15550 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15551 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15552 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15553 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15555 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15556 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15557 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15558 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15560 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15561 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15562 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15563 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15565 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15566 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15567 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15568 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15570 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15571 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15572 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15573 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15575 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15576 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15577 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15578 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15580 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15581 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15582 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15583 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15585 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15587 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15588 @end smallexample
15590 @node Other MIPS Built-in Functions
15591 @subsection Other MIPS Built-in Functions
15593 GCC provides other MIPS-specific built-in functions:
15595 @table @code
15596 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15597 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15598 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15599 when this function is available.
15601 @item unsigned int __builtin_mips_get_fcsr (void)
15602 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15603 Get and set the contents of the floating-point control and status register
15604 (FPU control register 31).  These functions are only available in hard-float
15605 code but can be called in both MIPS16 and non-MIPS16 contexts.
15607 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15608 register except the condition codes, which GCC assumes are preserved.
15609 @end table
15611 @node MSP430 Built-in Functions
15612 @subsection MSP430 Built-in Functions
15614 GCC provides a couple of special builtin functions to aid in the
15615 writing of interrupt handlers in C.
15617 @table @code
15618 @item __bic_SR_register_on_exit (int @var{mask})
15619 This clears the indicated bits in the saved copy of the status register
15620 currently residing on the stack.  This only works inside interrupt
15621 handlers and the changes to the status register will only take affect
15622 once the handler returns.
15624 @item __bis_SR_register_on_exit (int @var{mask})
15625 This sets the indicated bits in the saved copy of the status register
15626 currently residing on the stack.  This only works inside interrupt
15627 handlers and the changes to the status register will only take affect
15628 once the handler returns.
15630 @item __delay_cycles (long long @var{cycles})
15631 This inserts an instruction sequence that takes exactly @var{cycles}
15632 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15633 may use jumps, loops, or no-ops, and does not interfere with any other
15634 instructions.  Note that @var{cycles} must be a compile-time constant
15635 integer - that is, you must pass a number, not a variable that may be
15636 optimized to a constant later.  The number of cycles delayed by this
15637 builtin is exact.
15638 @end table
15640 @node NDS32 Built-in Functions
15641 @subsection NDS32 Built-in Functions
15643 These built-in functions are available for the NDS32 target:
15645 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15646 Insert an ISYNC instruction into the instruction stream where
15647 @var{addr} is an instruction address for serialization.
15648 @end deftypefn
15650 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15651 Insert an ISB instruction into the instruction stream.
15652 @end deftypefn
15654 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15655 Return the content of a system register which is mapped by @var{sr}.
15656 @end deftypefn
15658 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15659 Return the content of a user space register which is mapped by @var{usr}.
15660 @end deftypefn
15662 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15663 Move the @var{value} to a system register which is mapped by @var{sr}.
15664 @end deftypefn
15666 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15667 Move the @var{value} to a user space register which is mapped by @var{usr}.
15668 @end deftypefn
15670 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15671 Enable global interrupt.
15672 @end deftypefn
15674 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15675 Disable global interrupt.
15676 @end deftypefn
15678 @node picoChip Built-in Functions
15679 @subsection picoChip Built-in Functions
15681 GCC provides an interface to selected machine instructions from the
15682 picoChip instruction set.
15684 @table @code
15685 @item int __builtin_sbc (int @var{value})
15686 Sign bit count.  Return the number of consecutive bits in @var{value}
15687 that have the same value as the sign bit.  The result is the number of
15688 leading sign bits minus one, giving the number of redundant sign bits in
15689 @var{value}.
15691 @item int __builtin_byteswap (int @var{value})
15692 Byte swap.  Return the result of swapping the upper and lower bytes of
15693 @var{value}.
15695 @item int __builtin_brev (int @var{value})
15696 Bit reversal.  Return the result of reversing the bits in
15697 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15698 and so on.
15700 @item int __builtin_adds (int @var{x}, int @var{y})
15701 Saturating addition.  Return the result of adding @var{x} and @var{y},
15702 storing the value 32767 if the result overflows.
15704 @item int __builtin_subs (int @var{x}, int @var{y})
15705 Saturating subtraction.  Return the result of subtracting @var{y} from
15706 @var{x}, storing the value @minus{}32768 if the result overflows.
15708 @item void __builtin_halt (void)
15709 Halt.  The processor stops execution.  This built-in is useful for
15710 implementing assertions.
15712 @end table
15714 @node Basic PowerPC Built-in Functions
15715 @subsection Basic PowerPC Built-in Functions
15717 @menu
15718 * Basic PowerPC Built-in Functions Available on all Configurations::
15719 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15720 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15721 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15722 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15723 @end menu
15725 This section describes PowerPC built-in functions that do not require
15726 the inclusion of any special header files to declare prototypes or
15727 provide macro definitions.  The sections that follow describe
15728 additional PowerPC built-in functions.
15730 @node Basic PowerPC Built-in Functions Available on all Configurations
15731 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15733 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15734 This function is a @code{nop} on the PowerPC platform and is included solely
15735 to maintain API compatibility with the x86 builtins.
15736 @end deftypefn
15738 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15739 This function returns a value of @code{1} if the run-time CPU is of type
15740 @var{cpuname} and returns @code{0} otherwise
15742 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15743 which exports the hardware capability bits.  GCC defines the macro
15744 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15745 built-in function is fully supported.
15747 If GCC was configured to use a GLIBC before 2.23, the built-in
15748 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15749 issues a warning.
15751 The following CPU names can be detected:
15753 @table @samp
15754 @item power9
15755 IBM POWER9 Server CPU.
15756 @item power8
15757 IBM POWER8 Server CPU.
15758 @item power7
15759 IBM POWER7 Server CPU.
15760 @item power6x
15761 IBM POWER6 Server CPU (RAW mode).
15762 @item power6
15763 IBM POWER6 Server CPU (Architected mode).
15764 @item power5+
15765 IBM POWER5+ Server CPU.
15766 @item power5
15767 IBM POWER5 Server CPU.
15768 @item ppc970
15769 IBM 970 Server CPU (ie, Apple G5).
15770 @item power4
15771 IBM POWER4 Server CPU.
15772 @item ppca2
15773 IBM A2 64-bit Embedded CPU
15774 @item ppc476
15775 IBM PowerPC 476FP 32-bit Embedded CPU.
15776 @item ppc464
15777 IBM PowerPC 464 32-bit Embedded CPU.
15778 @item ppc440
15779 PowerPC 440 32-bit Embedded CPU.
15780 @item ppc405
15781 PowerPC 405 32-bit Embedded CPU.
15782 @item ppc-cell-be
15783 IBM PowerPC Cell Broadband Engine Architecture CPU.
15784 @end table
15786 Here is an example:
15787 @smallexample
15788 #ifdef __BUILTIN_CPU_SUPPORTS__
15789   if (__builtin_cpu_is ("power8"))
15790     @{
15791        do_power8 (); // POWER8 specific implementation.
15792     @}
15793   else
15794 #endif
15795     @{
15796        do_generic (); // Generic implementation.
15797     @}
15798 @end smallexample
15799 @end deftypefn
15801 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15802 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15803 feature @var{feature} and returns @code{0} otherwise.
15805 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15806 newer which exports the hardware capability bits.  GCC defines the
15807 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15808 @code{__builtin_cpu_supports} built-in function is fully supported.
15810 If GCC was configured to use a GLIBC before 2.23, the built-in
15811 function @code{__builtin_cpu_suports} always returns a 0 and the
15812 compiler issues a warning.
15814 The following features can be
15815 detected:
15817 @table @samp
15818 @item 4xxmac
15819 4xx CPU has a Multiply Accumulator.
15820 @item altivec
15821 CPU has a SIMD/Vector Unit.
15822 @item arch_2_05
15823 CPU supports ISA 2.05 (eg, POWER6)
15824 @item arch_2_06
15825 CPU supports ISA 2.06 (eg, POWER7)
15826 @item arch_2_07
15827 CPU supports ISA 2.07 (eg, POWER8)
15828 @item arch_3_00
15829 CPU supports ISA 3.0 (eg, POWER9)
15830 @item archpmu
15831 CPU supports the set of compatible performance monitoring events.
15832 @item booke
15833 CPU supports the Embedded ISA category.
15834 @item cellbe
15835 CPU has a CELL broadband engine.
15836 @item darn
15837 CPU supports the @code{darn} (deliver a random number) instruction.
15838 @item dfp
15839 CPU has a decimal floating point unit.
15840 @item dscr
15841 CPU supports the data stream control register.
15842 @item ebb
15843 CPU supports event base branching.
15844 @item efpdouble
15845 CPU has a SPE double precision floating point unit.
15846 @item efpsingle
15847 CPU has a SPE single precision floating point unit.
15848 @item fpu
15849 CPU has a floating point unit.
15850 @item htm
15851 CPU has hardware transaction memory instructions.
15852 @item htm-nosc
15853 Kernel aborts hardware transactions when a syscall is made.
15854 @item htm-no-suspend
15855 CPU supports hardware transaction memory but does not support the
15856 @code{tsuspend.} instruction.
15857 @item ic_snoop
15858 CPU supports icache snooping capabilities.
15859 @item ieee128
15860 CPU supports 128-bit IEEE binary floating point instructions.
15861 @item isel
15862 CPU supports the integer select instruction.
15863 @item mmu
15864 CPU has a memory management unit.
15865 @item notb
15866 CPU does not have a timebase (eg, 601 and 403gx).
15867 @item pa6t
15868 CPU supports the PA Semi 6T CORE ISA.
15869 @item power4
15870 CPU supports ISA 2.00 (eg, POWER4)
15871 @item power5
15872 CPU supports ISA 2.02 (eg, POWER5)
15873 @item power5+
15874 CPU supports ISA 2.03 (eg, POWER5+)
15875 @item power6x
15876 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15877 @item ppc32
15878 CPU supports 32-bit mode execution.
15879 @item ppc601
15880 CPU supports the old POWER ISA (eg, 601)
15881 @item ppc64
15882 CPU supports 64-bit mode execution.
15883 @item ppcle
15884 CPU supports a little-endian mode that uses address swizzling.
15885 @item scv
15886 Kernel supports system call vectored.
15887 @item smt
15888 CPU support simultaneous multi-threading.
15889 @item spe
15890 CPU has a signal processing extension unit.
15891 @item tar
15892 CPU supports the target address register.
15893 @item true_le
15894 CPU supports true little-endian mode.
15895 @item ucache
15896 CPU has unified I/D cache.
15897 @item vcrypto
15898 CPU supports the vector cryptography instructions.
15899 @item vsx
15900 CPU supports the vector-scalar extension.
15901 @end table
15903 Here is an example:
15904 @smallexample
15905 #ifdef __BUILTIN_CPU_SUPPORTS__
15906   if (__builtin_cpu_supports ("fpu"))
15907     @{
15908        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15909     @}
15910   else
15911 #endif
15912     @{
15913        dst = __fadd (src1, src2); // Software FP addition function.
15914     @}
15915 @end smallexample
15916 @end deftypefn
15918 The following built-in functions are also available on all PowerPC
15919 processors:
15920 @smallexample
15921 uint64_t __builtin_ppc_get_timebase ();
15922 unsigned long __builtin_ppc_mftb ();
15923 double __builtin_unpack_ibm128 (__ibm128, int);
15924 __ibm128 __builtin_pack_ibm128 (double, double);
15925 double __builtin_mffs (void);
15926 void __builtin_mtfsb0 (const int);
15927 void __builtin_mtfsb1 (const int);
15928 void __builtin_set_fpscr_rn (int);
15929 @end smallexample
15931 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15932 functions generate instructions to read the Time Base Register.  The
15933 @code{__builtin_ppc_get_timebase} function may generate multiple
15934 instructions and always returns the 64 bits of the Time Base Register.
15935 The @code{__builtin_ppc_mftb} function always generates one instruction and
15936 returns the Time Base Register value as an unsigned long, throwing away
15937 the most significant word on 32-bit environments.  The @code{__builtin_mffs}
15938 return the value of the FPSCR register.  Note, ISA 3.0 supports the
15939 @code{__builtin_mffsl()} which permits software to read the control and
15940 non-sticky status bits in the FSPCR without the higher latency associated with
15941 accessing the sticky status bits.  The
15942 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
15943 as an argument.  The valid bit range is between 0 and 31.  The builtins map to
15944 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
15945 add 32.  Hence these instructions only modify the FPSCR[32:63] bits by
15946 changing the specified bit to a zero or one respectively.  The
15947 @code{__builtin_set_fpscr_rn} builtin allows changing both of the floating
15948 point rounding mode bits.  The argument is a 2-bit value.  The argument can
15949 either be a const int or stored in a variable. The builtin uses the ISA 3.0
15950 instruction @code{mffscrn} if available, otherwise it reads the FPSCR, masks
15951 the current rounding mode bits out and OR's in the new value.
15953 @node Basic PowerPC Built-in Functions Available on ISA 2.05
15954 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
15956 The basic built-in functions described in this section are
15957 available on the PowerPC family of processors starting with ISA 2.05
15958 or later.  Unless specific options are explicitly disabled on the
15959 command line, specifying option @option{-mcpu=power6} has the effect of
15960 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
15961 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
15962 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
15963 @option{-mrecip-precision} options.  Specify the
15964 @option{-maltivec} and @option{-mfpgpr} options explicitly in
15965 combination with the above options if they are desired.
15967 The following functions require option @option{-mcmpb}.
15968 @smallexample
15969 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15970 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15971 @end smallexample
15973 The @code{__builtin_cmpb} function
15974 performs a byte-wise compare on the contents of its two arguments,
15975 returning the result of the byte-wise comparison as the returned
15976 value.  For each byte comparison, the corresponding byte of the return
15977 value holds 0xff if the input bytes are equal and 0 if the input bytes
15978 are not equal.  If either of the arguments to this built-in function
15979 is wider than 32 bits, the function call expands into the form that
15980 expects @code{unsigned long long int} arguments
15981 which is only available on 64-bit targets.
15983 The following built-in functions are available
15984 when hardware decimal floating point
15985 (@option{-mhard-dfp}) is available:
15986 @smallexample
15987 void __builtin_set_fpscr_drn(int);
15988 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15989 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15990 _Decimal64 __builtin_denbcd (int, _Decimal64);
15991 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15992 _Decimal64 __builtin_diex (long long, _Decimal64);
15993 _Decimal128 _builtin_diexq (long long, _Decimal128);
15994 _Decimal64 __builtin_dscli (_Decimal64, int);
15995 _Decimal128 __builtin_dscliq (_Decimal128, int);
15996 _Decimal64 __builtin_dscri (_Decimal64, int);
15997 _Decimal128 __builtin_dscriq (_Decimal128, int);
15998 long long __builtin_dxex (_Decimal64);
15999 long long __builtin_dxexq (_Decimal128);
16000 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
16001 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
16003 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
16004 floating point rounding mode bits.  The argument is a 3-bit value.  The
16005 argument can either be a const int or the value can be stored in a variable.
16006 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
16007 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
16008 mode bits out and OR's in the new value.
16010 @end smallexample
16012 The following functions require @option{-mhard-float},
16013 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
16015 @smallexample
16016 double __builtin_recipdiv (double, double);
16017 float __builtin_recipdivf (float, float);
16018 double __builtin_rsqrt (double);
16019 float __builtin_rsqrtf (float);
16020 @end smallexample
16022 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
16023 @code{__builtin_rsqrtf} functions generate multiple instructions to
16024 implement the reciprocal sqrt functionality using reciprocal sqrt
16025 estimate instructions.
16027 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
16028 functions generate multiple instructions to implement division using
16029 the reciprocal estimate instructions.
16031 The following functions require @option{-mhard-float} and
16032 @option{-mmultiple} options.
16034 The @code{__builtin_unpack_longdouble} function takes a
16035 @code{long double} argument and a compile time constant of 0 or 1.  If
16036 the constant is 0, the first @code{double} within the
16037 @code{long double} is returned, otherwise the second @code{double}
16038 is returned.  The @code{__builtin_unpack_longdouble} function is only
16039 available if @code{long double} uses the IBM extended double
16040 representation.
16042 The @code{__builtin_pack_longdouble} function takes two @code{double}
16043 arguments and returns a @code{long double} value that combines the two
16044 arguments.  The @code{__builtin_pack_longdouble} function is only
16045 available if @code{long double} uses the IBM extended double
16046 representation.
16048 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
16049 argument and a compile time constant of 0 or 1.  If the constant is 0,
16050 the first @code{double} within the @code{__ibm128} is returned,
16051 otherwise the second @code{double} is returned.
16053 The @code{__builtin_pack_ibm128} function takes two @code{double}
16054 arguments and returns a @code{__ibm128} value that combines the two
16055 arguments.
16057 Additional built-in functions are available for the 64-bit PowerPC
16058 family of processors, for efficient use of 128-bit floating point
16059 (@code{__float128}) values.
16061 @node Basic PowerPC Built-in Functions Available on ISA 2.06
16062 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
16064 The basic built-in functions described in this section are
16065 available on the PowerPC family of processors starting with ISA 2.05
16066 or later.  Unless specific options are explicitly disabled on the
16067 command line, specifying option @option{-mcpu=power7} has the effect of
16068 enabling all the same options as for @option{-mcpu=power6} in
16069 addition to the @option{-maltivec}, @option{-mpopcntd}, and
16070 @option{-mvsx} options.
16072 The following basic built-in functions require @option{-mpopcntd}:
16073 @smallexample
16074 unsigned int __builtin_addg6s (unsigned int, unsigned int);
16075 long long __builtin_bpermd (long long, long long);
16076 unsigned int __builtin_cbcdtd (unsigned int);
16077 unsigned int __builtin_cdtbcd (unsigned int);
16078 long long __builtin_divde (long long, long long);
16079 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
16080 int __builtin_divwe (int, int);
16081 unsigned int __builtin_divweu (unsigned int, unsigned int);
16082 vector __int128 __builtin_pack_vector_int128 (long long, long long);
16083 void __builtin_rs6000_speculation_barrier (void);
16084 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
16085 @end smallexample
16087 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
16088 require a 64-bit environment.
16090 The following basic built-in functions, which are also supported on
16091 x86 targets, require @option{-mfloat128}.
16092 @smallexample
16093 __float128 __builtin_fabsq (__float128);
16094 __float128 __builtin_copysignq (__float128, __float128);
16095 __float128 __builtin_infq (void);
16096 __float128 __builtin_huge_valq (void);
16097 __float128 __builtin_nanq (void);
16098 __float128 __builtin_nansq (void);
16100 __float128 __builtin_sqrtf128 (__float128);
16101 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
16102 @end smallexample
16104 @node Basic PowerPC Built-in Functions Available on ISA 2.07
16105 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
16107 The basic built-in functions described in this section are
16108 available on the PowerPC family of processors starting with ISA 2.07
16109 or later.  Unless specific options are explicitly disabled on the
16110 command line, specifying option @option{-mcpu=power8} has the effect of
16111 enabling all the same options as for @option{-mcpu=power7} in
16112 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
16113 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
16114 @option{-mquad-memory-atomic} options.
16116 This section intentionally empty.
16118 @node Basic PowerPC Built-in Functions Available on ISA 3.0
16119 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
16121 The basic built-in functions described in this section are
16122 available on the PowerPC family of processors starting with ISA 3.0
16123 or later.  Unless specific options are explicitly disabled on the
16124 command line, specifying option @option{-mcpu=power9} has the effect of
16125 enabling all the same options as for @option{-mcpu=power8} in
16126 addition to the @option{-misel} option.
16128 The following built-in functions are available on Linux 64-bit systems
16129 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
16131 @table @code
16132 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
16133 Perform a 128-bit IEEE floating point add using round to odd as the
16134 rounding mode.
16135 @findex __builtin_addf128_round_to_odd
16137 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
16138 Perform a 128-bit IEEE floating point subtract using round to odd as
16139 the rounding mode.
16140 @findex __builtin_subf128_round_to_odd
16142 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
16143 Perform a 128-bit IEEE floating point multiply using round to odd as
16144 the rounding mode.
16145 @findex __builtin_mulf128_round_to_odd
16147 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
16148 Perform a 128-bit IEEE floating point divide using round to odd as
16149 the rounding mode.
16150 @findex __builtin_divf128_round_to_odd
16152 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
16153 Perform a 128-bit IEEE floating point square root using round to odd
16154 as the rounding mode.
16155 @findex __builtin_sqrtf128_round_to_odd
16157 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
16158 Perform a 128-bit IEEE floating point fused multiply and add operation
16159 using round to odd as the rounding mode.
16160 @findex __builtin_fmaf128_round_to_odd
16162 @item double __builtin_truncf128_round_to_odd (__float128)
16163 Convert a 128-bit IEEE floating point value to @code{double} using
16164 round to odd as the rounding mode.
16165 @findex __builtin_truncf128_round_to_odd
16166 @end table
16168 The following additional built-in functions are also available for the
16169 PowerPC family of processors, starting with ISA 3.0 or later:
16170 @smallexample
16171 long long __builtin_darn (void);
16172 long long __builtin_darn_raw (void);
16173 int __builtin_darn_32 (void);
16174 @end smallexample
16176 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16177 functions require a
16178 64-bit environment supporting ISA 3.0 or later.
16179 The @code{__builtin_darn} function provides a 64-bit conditioned
16180 random number.  The @code{__builtin_darn_raw} function provides a
16181 64-bit raw random number.  The @code{__builtin_darn_32} function
16182 provides a 32-bit conditioned random number.
16184 The following additional built-in functions are also available for the
16185 PowerPC family of processors, starting with ISA 3.0 or later:
16187 @smallexample
16188 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
16189 int __builtin_byte_in_range (unsigned char u, unsigned int range);
16190 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
16192 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
16193 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
16194 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
16195 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
16197 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
16198 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
16199 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
16200 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
16202 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
16203 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
16204 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
16205 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
16207 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
16208 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
16209 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
16210 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
16212 double __builtin_mffsl(void);
16214 @end smallexample
16215 The @code{__builtin_byte_in_set} function requires a
16216 64-bit environment supporting ISA 3.0 or later.  This function returns
16217 a non-zero value if and only if its @code{u} argument exactly equals one of
16218 the eight bytes contained within its 64-bit @code{set} argument.
16220 The @code{__builtin_byte_in_range} and
16221 @code{__builtin_byte_in_either_range} require an environment
16222 supporting ISA 3.0 or later.  For these two functions, the
16223 @code{range} argument is encoded as 4 bytes, organized as
16224 @code{hi_1:lo_1:hi_2:lo_2}.
16225 The @code{__builtin_byte_in_range} function returns a
16226 non-zero value if and only if its @code{u} argument is within the
16227 range bounded between @code{lo_2} and @code{hi_2} inclusive.
16228 The @code{__builtin_byte_in_either_range} function returns non-zero if
16229 and only if its @code{u} argument is within either the range bounded
16230 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16231 between @code{lo_2} and @code{hi_2} inclusive.
16233 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16234 if and only if the number of signficant digits of its @code{value} argument
16235 is less than its @code{comparison} argument.  The
16236 @code{__builtin_dfp_dtstsfi_lt_dd} and
16237 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16238 require that the type of the @code{value} argument be
16239 @code{__Decimal64} and @code{__Decimal128} respectively.
16241 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16242 if and only if the number of signficant digits of its @code{value} argument
16243 is greater than its @code{comparison} argument.  The
16244 @code{__builtin_dfp_dtstsfi_gt_dd} and
16245 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16246 require that the type of the @code{value} argument be
16247 @code{__Decimal64} and @code{__Decimal128} respectively.
16249 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16250 if and only if the number of signficant digits of its @code{value} argument
16251 equals its @code{comparison} argument.  The
16252 @code{__builtin_dfp_dtstsfi_eq_dd} and
16253 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16254 require that the type of the @code{value} argument be
16255 @code{__Decimal64} and @code{__Decimal128} respectively.
16257 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16258 if and only if its @code{value} argument has an undefined number of
16259 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16260 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16261 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16262 require that the type of the @code{value} argument be
16263 @code{__Decimal64} and @code{__Decimal128} respectively.
16265 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
16266 the FPSCR.  The instruction is a lower latency version of the @code{mffs}
16267 instruction.  If the @code{mffsl} instruction is not available, then the
16268 builtin uses the older @code{mffs} instruction to read the FPSCR.
16271 @node PowerPC AltiVec/VSX Built-in Functions
16272 @subsection PowerPC AltiVec/VSX Built-in Functions
16274 GCC provides an interface for the PowerPC family of processors to access
16275 the AltiVec operations described in Motorola's AltiVec Programming
16276 Interface Manual.  The interface is made available by including
16277 @code{<altivec.h>} and using @option{-maltivec} and
16278 @option{-mabi=altivec}.  The interface supports the following vector
16279 types.
16281 @smallexample
16282 vector unsigned char
16283 vector signed char
16284 vector bool char
16286 vector unsigned short
16287 vector signed short
16288 vector bool short
16289 vector pixel
16291 vector unsigned int
16292 vector signed int
16293 vector bool int
16294 vector float
16295 @end smallexample
16297 GCC's implementation of the high-level language interface available from
16298 C and C++ code differs from Motorola's documentation in several ways.
16300 @itemize @bullet
16302 @item
16303 A vector constant is a list of constant expressions within curly braces.
16305 @item
16306 A vector initializer requires no cast if the vector constant is of the
16307 same type as the variable it is initializing.
16309 @item
16310 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16311 vector type is the default signedness of the base type.  The default
16312 varies depending on the operating system, so a portable program should
16313 always specify the signedness.
16315 @item
16316 Compiling with @option{-maltivec} adds keywords @code{__vector},
16317 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16318 @code{bool}.  When compiling ISO C, the context-sensitive substitution
16319 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16320 disabled.  To use them, you must include @code{<altivec.h>} instead.
16322 @item
16323 GCC allows using a @code{typedef} name as the type specifier for a
16324 vector type.
16326 @item
16327 For C, overloaded functions are implemented with macros so the following
16328 does not work:
16330 @smallexample
16331   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16332 @end smallexample
16334 @noindent
16335 Since @code{vec_add} is a macro, the vector constant in the example
16336 is treated as four separate arguments.  Wrap the entire argument in
16337 parentheses for this to work.
16338 @end itemize
16340 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16341 Internally, GCC uses built-in functions to achieve the functionality in
16342 the aforementioned header file, but they are not supported and are
16343 subject to change without notice.
16345 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16346 which may be found at
16347 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16348 Appendix A of this document lists the vector API interfaces that must be
16349 provided by compliant compilers.  Programmers should preferentially use
16350 the interfaces described therein.  However, historically GCC has provided
16351 additional interfaces for access to vector instructions.  These are
16352 briefly described below.
16354 @menu
16355 * PowerPC AltiVec Built-in Functions on ISA 2.05::
16356 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
16357 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
16358 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
16359 @end menu
16361 @node PowerPC AltiVec Built-in Functions on ISA 2.05
16362 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
16364 The following interfaces are supported for the generic and specific
16365 AltiVec operations and the AltiVec predicates.  In cases where there
16366 is a direct mapping between generic and specific operations, only the
16367 generic names are shown here, although the specific operations can also
16368 be used.
16370 Arguments that are documented as @code{const int} require literal
16371 integral values within the range required for that operation.
16373 @smallexample
16374 vector signed char vec_abs (vector signed char);
16375 vector signed short vec_abs (vector signed short);
16376 vector signed int vec_abs (vector signed int);
16377 vector float vec_abs (vector float);
16379 vector signed char vec_abss (vector signed char);
16380 vector signed short vec_abss (vector signed short);
16381 vector signed int vec_abss (vector signed int);
16383 vector signed char vec_add (vector bool char, vector signed char);
16384 vector signed char vec_add (vector signed char, vector bool char);
16385 vector signed char vec_add (vector signed char, vector signed char);
16386 vector unsigned char vec_add (vector bool char, vector unsigned char);
16387 vector unsigned char vec_add (vector unsigned char, vector bool char);
16388 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
16389 vector signed short vec_add (vector bool short, vector signed short);
16390 vector signed short vec_add (vector signed short, vector bool short);
16391 vector signed short vec_add (vector signed short, vector signed short);
16392 vector unsigned short vec_add (vector bool short, vector unsigned short);
16393 vector unsigned short vec_add (vector unsigned short, vector bool short);
16394 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
16395 vector signed int vec_add (vector bool int, vector signed int);
16396 vector signed int vec_add (vector signed int, vector bool int);
16397 vector signed int vec_add (vector signed int, vector signed int);
16398 vector unsigned int vec_add (vector bool int, vector unsigned int);
16399 vector unsigned int vec_add (vector unsigned int, vector bool int);
16400 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16401 vector float vec_add (vector float, vector float);
16403 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16405 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16406 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16407 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
16408 vector signed char vec_adds (vector bool char, vector signed char);
16409 vector signed char vec_adds (vector signed char, vector bool char);
16410 vector signed char vec_adds (vector signed char, vector signed char);
16411 vector unsigned short vec_adds (vector bool short, vector unsigned short);
16412 vector unsigned short vec_adds (vector unsigned short, vector bool short);
16413 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
16414 vector signed short vec_adds (vector bool short, vector signed short);
16415 vector signed short vec_adds (vector signed short, vector bool short);
16416 vector signed short vec_adds (vector signed short, vector signed short);
16417 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16418 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16419 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16420 vector signed int vec_adds (vector bool int, vector signed int);
16421 vector signed int vec_adds (vector signed int, vector bool int);
16422 vector signed int vec_adds (vector signed int, vector signed int);
16424 int vec_all_eq (vector signed char, vector bool char);
16425 int vec_all_eq (vector signed char, vector signed char);
16426 int vec_all_eq (vector unsigned char, vector bool char);
16427 int vec_all_eq (vector unsigned char, vector unsigned char);
16428 int vec_all_eq (vector bool char, vector bool char);
16429 int vec_all_eq (vector bool char, vector unsigned char);
16430 int vec_all_eq (vector bool char, vector signed char);
16431 int vec_all_eq (vector signed short, vector bool short);
16432 int vec_all_eq (vector signed short, vector signed short);
16433 int vec_all_eq (vector unsigned short, vector bool short);
16434 int vec_all_eq (vector unsigned short, vector unsigned short);
16435 int vec_all_eq (vector bool short, vector bool short);
16436 int vec_all_eq (vector bool short, vector unsigned short);
16437 int vec_all_eq (vector bool short, vector signed short);
16438 int vec_all_eq (vector pixel, vector pixel);
16439 int vec_all_eq (vector signed int, vector bool int);
16440 int vec_all_eq (vector signed int, vector signed int);
16441 int vec_all_eq (vector unsigned int, vector bool int);
16442 int vec_all_eq (vector unsigned int, vector unsigned int);
16443 int vec_all_eq (vector bool int, vector bool int);
16444 int vec_all_eq (vector bool int, vector unsigned int);
16445 int vec_all_eq (vector bool int, vector signed int);
16446 int vec_all_eq (vector float, vector float);
16448 int vec_all_ge (vector bool char, vector unsigned char);
16449 int vec_all_ge (vector unsigned char, vector bool char);
16450 int vec_all_ge (vector unsigned char, vector unsigned char);
16451 int vec_all_ge (vector bool char, vector signed char);
16452 int vec_all_ge (vector signed char, vector bool char);
16453 int vec_all_ge (vector signed char, vector signed char);
16454 int vec_all_ge (vector bool short, vector unsigned short);
16455 int vec_all_ge (vector unsigned short, vector bool short);
16456 int vec_all_ge (vector unsigned short, vector unsigned short);
16457 int vec_all_ge (vector signed short, vector signed short);
16458 int vec_all_ge (vector bool short, vector signed short);
16459 int vec_all_ge (vector signed short, vector bool short);
16460 int vec_all_ge (vector bool int, vector unsigned int);
16461 int vec_all_ge (vector unsigned int, vector bool int);
16462 int vec_all_ge (vector unsigned int, vector unsigned int);
16463 int vec_all_ge (vector bool int, vector signed int);
16464 int vec_all_ge (vector signed int, vector bool int);
16465 int vec_all_ge (vector signed int, vector signed int);
16466 int vec_all_ge (vector float, vector float);
16468 int vec_all_gt (vector bool char, vector unsigned char);
16469 int vec_all_gt (vector unsigned char, vector bool char);
16470 int vec_all_gt (vector unsigned char, vector unsigned char);
16471 int vec_all_gt (vector bool char, vector signed char);
16472 int vec_all_gt (vector signed char, vector bool char);
16473 int vec_all_gt (vector signed char, vector signed char);
16474 int vec_all_gt (vector bool short, vector unsigned short);
16475 int vec_all_gt (vector unsigned short, vector bool short);
16476 int vec_all_gt (vector unsigned short, vector unsigned short);
16477 int vec_all_gt (vector bool short, vector signed short);
16478 int vec_all_gt (vector signed short, vector bool short);
16479 int vec_all_gt (vector signed short, vector signed short);
16480 int vec_all_gt (vector bool int, vector unsigned int);
16481 int vec_all_gt (vector unsigned int, vector bool int);
16482 int vec_all_gt (vector unsigned int, vector unsigned int);
16483 int vec_all_gt (vector bool int, vector signed int);
16484 int vec_all_gt (vector signed int, vector bool int);
16485 int vec_all_gt (vector signed int, vector signed int);
16486 int vec_all_gt (vector float, vector float);
16488 int vec_all_in (vector float, vector float);
16490 int vec_all_le (vector bool char, vector unsigned char);
16491 int vec_all_le (vector unsigned char, vector bool char);
16492 int vec_all_le (vector unsigned char, vector unsigned char);
16493 int vec_all_le (vector bool char, vector signed char);
16494 int vec_all_le (vector signed char, vector bool char);
16495 int vec_all_le (vector signed char, vector signed char);
16496 int vec_all_le (vector bool short, vector unsigned short);
16497 int vec_all_le (vector unsigned short, vector bool short);
16498 int vec_all_le (vector unsigned short, vector unsigned short);
16499 int vec_all_le (vector bool short, vector signed short);
16500 int vec_all_le (vector signed short, vector bool short);
16501 int vec_all_le (vector signed short, vector signed short);
16502 int vec_all_le (vector bool int, vector unsigned int);
16503 int vec_all_le (vector unsigned int, vector bool int);
16504 int vec_all_le (vector unsigned int, vector unsigned int);
16505 int vec_all_le (vector bool int, vector signed int);
16506 int vec_all_le (vector signed int, vector bool int);
16507 int vec_all_le (vector signed int, vector signed int);
16508 int vec_all_le (vector float, vector float);
16510 int vec_all_lt (vector bool char, vector unsigned char);
16511 int vec_all_lt (vector unsigned char, vector bool char);
16512 int vec_all_lt (vector unsigned char, vector unsigned char);
16513 int vec_all_lt (vector bool char, vector signed char);
16514 int vec_all_lt (vector signed char, vector bool char);
16515 int vec_all_lt (vector signed char, vector signed char);
16516 int vec_all_lt (vector bool short, vector unsigned short);
16517 int vec_all_lt (vector unsigned short, vector bool short);
16518 int vec_all_lt (vector unsigned short, vector unsigned short);
16519 int vec_all_lt (vector bool short, vector signed short);
16520 int vec_all_lt (vector signed short, vector bool short);
16521 int vec_all_lt (vector signed short, vector signed short);
16522 int vec_all_lt (vector bool int, vector unsigned int);
16523 int vec_all_lt (vector unsigned int, vector bool int);
16524 int vec_all_lt (vector unsigned int, vector unsigned int);
16525 int vec_all_lt (vector bool int, vector signed int);
16526 int vec_all_lt (vector signed int, vector bool int);
16527 int vec_all_lt (vector signed int, vector signed int);
16528 int vec_all_lt (vector float, vector float);
16530 int vec_all_nan (vector float);
16532 int vec_all_ne (vector signed char, vector bool char);
16533 int vec_all_ne (vector signed char, vector signed char);
16534 int vec_all_ne (vector unsigned char, vector bool char);
16535 int vec_all_ne (vector unsigned char, vector unsigned char);
16536 int vec_all_ne (vector bool char, vector bool char);
16537 int vec_all_ne (vector bool char, vector unsigned char);
16538 int vec_all_ne (vector bool char, vector signed char);
16539 int vec_all_ne (vector signed short, vector bool short);
16540 int vec_all_ne (vector signed short, vector signed short);
16541 int vec_all_ne (vector unsigned short, vector bool short);
16542 int vec_all_ne (vector unsigned short, vector unsigned short);
16543 int vec_all_ne (vector bool short, vector bool short);
16544 int vec_all_ne (vector bool short, vector unsigned short);
16545 int vec_all_ne (vector bool short, vector signed short);
16546 int vec_all_ne (vector pixel, vector pixel);
16547 int vec_all_ne (vector signed int, vector bool int);
16548 int vec_all_ne (vector signed int, vector signed int);
16549 int vec_all_ne (vector unsigned int, vector bool int);
16550 int vec_all_ne (vector unsigned int, vector unsigned int);
16551 int vec_all_ne (vector bool int, vector bool int);
16552 int vec_all_ne (vector bool int, vector unsigned int);
16553 int vec_all_ne (vector bool int, vector signed int);
16554 int vec_all_ne (vector float, vector float);
16556 int vec_all_nge (vector float, vector float);
16558 int vec_all_ngt (vector float, vector float);
16560 int vec_all_nle (vector float, vector float);
16562 int vec_all_nlt (vector float, vector float);
16564 int vec_all_numeric (vector float);
16566 vector float vec_and (vector float, vector float);
16567 vector float vec_and (vector float, vector bool int);
16568 vector float vec_and (vector bool int, vector float);
16569 vector bool int vec_and (vector bool int, vector bool int);
16570 vector signed int vec_and (vector bool int, vector signed int);
16571 vector signed int vec_and (vector signed int, vector bool int);
16572 vector signed int vec_and (vector signed int, vector signed int);
16573 vector unsigned int vec_and (vector bool int, vector unsigned int);
16574 vector unsigned int vec_and (vector unsigned int, vector bool int);
16575 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16576 vector bool short vec_and (vector bool short, vector bool short);
16577 vector signed short vec_and (vector bool short, vector signed short);
16578 vector signed short vec_and (vector signed short, vector bool short);
16579 vector signed short vec_and (vector signed short, vector signed short);
16580 vector unsigned short vec_and (vector bool short, vector unsigned short);
16581 vector unsigned short vec_and (vector unsigned short, vector bool short);
16582 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
16583 vector signed char vec_and (vector bool char, vector signed char);
16584 vector bool char vec_and (vector bool char, vector bool char);
16585 vector signed char vec_and (vector signed char, vector bool char);
16586 vector signed char vec_and (vector signed char, vector signed char);
16587 vector unsigned char vec_and (vector bool char, vector unsigned char);
16588 vector unsigned char vec_and (vector unsigned char, vector bool char);
16589 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
16591 vector float vec_andc (vector float, vector float);
16592 vector float vec_andc (vector float, vector bool int);
16593 vector float vec_andc (vector bool int, vector float);
16594 vector bool int vec_andc (vector bool int, vector bool int);
16595 vector signed int vec_andc (vector bool int, vector signed int);
16596 vector signed int vec_andc (vector signed int, vector bool int);
16597 vector signed int vec_andc (vector signed int, vector signed int);
16598 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16599 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16600 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16601 vector bool short vec_andc (vector bool short, vector bool short);
16602 vector signed short vec_andc (vector bool short, vector signed short);
16603 vector signed short vec_andc (vector signed short, vector bool short);
16604 vector signed short vec_andc (vector signed short, vector signed short);
16605 vector unsigned short vec_andc (vector bool short, vector unsigned short);
16606 vector unsigned short vec_andc (vector unsigned short, vector bool short);
16607 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
16608 vector signed char vec_andc (vector bool char, vector signed char);
16609 vector bool char vec_andc (vector bool char, vector bool char);
16610 vector signed char vec_andc (vector signed char, vector bool char);
16611 vector signed char vec_andc (vector signed char, vector signed char);
16612 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16613 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16614 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
16616 int vec_any_eq (vector signed char, vector bool char);
16617 int vec_any_eq (vector signed char, vector signed char);
16618 int vec_any_eq (vector unsigned char, vector bool char);
16619 int vec_any_eq (vector unsigned char, vector unsigned char);
16620 int vec_any_eq (vector bool char, vector bool char);
16621 int vec_any_eq (vector bool char, vector unsigned char);
16622 int vec_any_eq (vector bool char, vector signed char);
16623 int vec_any_eq (vector signed short, vector bool short);
16624 int vec_any_eq (vector signed short, vector signed short);
16625 int vec_any_eq (vector unsigned short, vector bool short);
16626 int vec_any_eq (vector unsigned short, vector unsigned short);
16627 int vec_any_eq (vector bool short, vector bool short);
16628 int vec_any_eq (vector bool short, vector unsigned short);
16629 int vec_any_eq (vector bool short, vector signed short);
16630 int vec_any_eq (vector pixel, vector pixel);
16631 int vec_any_eq (vector signed int, vector bool int);
16632 int vec_any_eq (vector signed int, vector signed int);
16633 int vec_any_eq (vector unsigned int, vector bool int);
16634 int vec_any_eq (vector unsigned int, vector unsigned int);
16635 int vec_any_eq (vector bool int, vector bool int);
16636 int vec_any_eq (vector bool int, vector unsigned int);
16637 int vec_any_eq (vector bool int, vector signed int);
16638 int vec_any_eq (vector float, vector float);
16640 int vec_any_ge (vector signed char, vector bool char);
16641 int vec_any_ge (vector unsigned char, vector bool char);
16642 int vec_any_ge (vector unsigned char, vector unsigned char);
16643 int vec_any_ge (vector signed char, vector signed char);
16644 int vec_any_ge (vector bool char, vector unsigned char);
16645 int vec_any_ge (vector bool char, vector signed char);
16646 int vec_any_ge (vector unsigned short, vector bool short);
16647 int vec_any_ge (vector unsigned short, vector unsigned short);
16648 int vec_any_ge (vector signed short, vector signed short);
16649 int vec_any_ge (vector signed short, vector bool short);
16650 int vec_any_ge (vector bool short, vector unsigned short);
16651 int vec_any_ge (vector bool short, vector signed short);
16652 int vec_any_ge (vector signed int, vector bool int);
16653 int vec_any_ge (vector unsigned int, vector bool int);
16654 int vec_any_ge (vector unsigned int, vector unsigned int);
16655 int vec_any_ge (vector signed int, vector signed int);
16656 int vec_any_ge (vector bool int, vector unsigned int);
16657 int vec_any_ge (vector bool int, vector signed int);
16658 int vec_any_ge (vector float, vector float);
16660 int vec_any_gt (vector bool char, vector unsigned char);
16661 int vec_any_gt (vector unsigned char, vector bool char);
16662 int vec_any_gt (vector unsigned char, vector unsigned char);
16663 int vec_any_gt (vector bool char, vector signed char);
16664 int vec_any_gt (vector signed char, vector bool char);
16665 int vec_any_gt (vector signed char, vector signed char);
16666 int vec_any_gt (vector bool short, vector unsigned short);
16667 int vec_any_gt (vector unsigned short, vector bool short);
16668 int vec_any_gt (vector unsigned short, vector unsigned short);
16669 int vec_any_gt (vector bool short, vector signed short);
16670 int vec_any_gt (vector signed short, vector bool short);
16671 int vec_any_gt (vector signed short, vector signed short);
16672 int vec_any_gt (vector bool int, vector unsigned int);
16673 int vec_any_gt (vector unsigned int, vector bool int);
16674 int vec_any_gt (vector unsigned int, vector unsigned int);
16675 int vec_any_gt (vector bool int, vector signed int);
16676 int vec_any_gt (vector signed int, vector bool int);
16677 int vec_any_gt (vector signed int, vector signed int);
16678 int vec_any_gt (vector float, vector float);
16680 int vec_any_le (vector bool char, vector unsigned char);
16681 int vec_any_le (vector unsigned char, vector bool char);
16682 int vec_any_le (vector unsigned char, vector unsigned char);
16683 int vec_any_le (vector bool char, vector signed char);
16684 int vec_any_le (vector signed char, vector bool char);
16685 int vec_any_le (vector signed char, vector signed char);
16686 int vec_any_le (vector bool short, vector unsigned short);
16687 int vec_any_le (vector unsigned short, vector bool short);
16688 int vec_any_le (vector unsigned short, vector unsigned short);
16689 int vec_any_le (vector bool short, vector signed short);
16690 int vec_any_le (vector signed short, vector bool short);
16691 int vec_any_le (vector signed short, vector signed short);
16692 int vec_any_le (vector bool int, vector unsigned int);
16693 int vec_any_le (vector unsigned int, vector bool int);
16694 int vec_any_le (vector unsigned int, vector unsigned int);
16695 int vec_any_le (vector bool int, vector signed int);
16696 int vec_any_le (vector signed int, vector bool int);
16697 int vec_any_le (vector signed int, vector signed int);
16698 int vec_any_le (vector float, vector float);
16700 int vec_any_lt (vector bool char, vector unsigned char);
16701 int vec_any_lt (vector unsigned char, vector bool char);
16702 int vec_any_lt (vector unsigned char, vector unsigned char);
16703 int vec_any_lt (vector bool char, vector signed char);
16704 int vec_any_lt (vector signed char, vector bool char);
16705 int vec_any_lt (vector signed char, vector signed char);
16706 int vec_any_lt (vector bool short, vector unsigned short);
16707 int vec_any_lt (vector unsigned short, vector bool short);
16708 int vec_any_lt (vector unsigned short, vector unsigned short);
16709 int vec_any_lt (vector bool short, vector signed short);
16710 int vec_any_lt (vector signed short, vector bool short);
16711 int vec_any_lt (vector signed short, vector signed short);
16712 int vec_any_lt (vector bool int, vector unsigned int);
16713 int vec_any_lt (vector unsigned int, vector bool int);
16714 int vec_any_lt (vector unsigned int, vector unsigned int);
16715 int vec_any_lt (vector bool int, vector signed int);
16716 int vec_any_lt (vector signed int, vector bool int);
16717 int vec_any_lt (vector signed int, vector signed int);
16718 int vec_any_lt (vector float, vector float);
16720 int vec_any_nan (vector float);
16722 int vec_any_ne (vector signed char, vector bool char);
16723 int vec_any_ne (vector signed char, vector signed char);
16724 int vec_any_ne (vector unsigned char, vector bool char);
16725 int vec_any_ne (vector unsigned char, vector unsigned char);
16726 int vec_any_ne (vector bool char, vector bool char);
16727 int vec_any_ne (vector bool char, vector unsigned char);
16728 int vec_any_ne (vector bool char, vector signed char);
16729 int vec_any_ne (vector signed short, vector bool short);
16730 int vec_any_ne (vector signed short, vector signed short);
16731 int vec_any_ne (vector unsigned short, vector bool short);
16732 int vec_any_ne (vector unsigned short, vector unsigned short);
16733 int vec_any_ne (vector bool short, vector bool short);
16734 int vec_any_ne (vector bool short, vector unsigned short);
16735 int vec_any_ne (vector bool short, vector signed short);
16736 int vec_any_ne (vector pixel, vector pixel);
16737 int vec_any_ne (vector signed int, vector bool int);
16738 int vec_any_ne (vector signed int, vector signed int);
16739 int vec_any_ne (vector unsigned int, vector bool int);
16740 int vec_any_ne (vector unsigned int, vector unsigned int);
16741 int vec_any_ne (vector bool int, vector bool int);
16742 int vec_any_ne (vector bool int, vector unsigned int);
16743 int vec_any_ne (vector bool int, vector signed int);
16744 int vec_any_ne (vector float, vector float);
16746 int vec_any_nge (vector float, vector float);
16748 int vec_any_ngt (vector float, vector float);
16750 int vec_any_nle (vector float, vector float);
16752 int vec_any_nlt (vector float, vector float);
16754 int vec_any_numeric (vector float);
16756 int vec_any_out (vector float, vector float);
16758 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
16759 vector signed char vec_avg (vector signed char, vector signed char);
16760 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
16761 vector signed short vec_avg (vector signed short, vector signed short);
16762 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16763 vector signed int vec_avg (vector signed int, vector signed int);
16765 vector float vec_ceil (vector float);
16767 vector signed int vec_cmpb (vector float, vector float);
16769 vector bool char vec_cmpeq (vector bool char, vector bool char);
16770 vector bool short vec_cmpeq (vector bool short, vector bool short);
16771 vector bool int vec_cmpeq (vector bool int, vector bool int);
16772 vector bool char vec_cmpeq (vector signed char, vector signed char);
16773 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16774 vector bool short vec_cmpeq (vector signed short, vector signed short);
16775 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
16776 vector bool int vec_cmpeq (vector signed int, vector signed int);
16777 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16778 vector bool int vec_cmpeq (vector float, vector float);
16780 vector bool int vec_cmpge (vector float, vector float);
16782 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16783 vector bool char vec_cmpgt (vector signed char, vector signed char);
16784 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
16785 vector bool short vec_cmpgt (vector signed short, vector signed short);
16786 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16787 vector bool int vec_cmpgt (vector signed int, vector signed int);
16788 vector bool int vec_cmpgt (vector float, vector float);
16790 vector bool int vec_cmple (vector float, vector float);
16792 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16793 vector bool char vec_cmplt (vector signed char, vector signed char);
16794 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
16795 vector bool short vec_cmplt (vector signed short, vector signed short);
16796 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16797 vector bool int vec_cmplt (vector signed int, vector signed int);
16798 vector bool int vec_cmplt (vector float, vector float);
16800 vector float vec_cpsgn (vector float, vector float);
16802 vector float vec_ctf (vector unsigned int, const int);
16803 vector float vec_ctf (vector signed int, const int);
16805 vector signed int vec_cts (vector float, const int);
16807 vector unsigned int vec_ctu (vector float, const int);
16809 void vec_dss (const int);
16811 void vec_dssall (void);
16813 void vec_dst (const vector unsigned char *, int, const int);
16814 void vec_dst (const vector signed char *, int, const int);
16815 void vec_dst (const vector bool char *, int, const int);
16816 void vec_dst (const vector unsigned short *, int, const int);
16817 void vec_dst (const vector signed short *, int, const int);
16818 void vec_dst (const vector bool short *, int, const int);
16819 void vec_dst (const vector pixel *, int, const int);
16820 void vec_dst (const vector unsigned int *, int, const int);
16821 void vec_dst (const vector signed int *, int, const int);
16822 void vec_dst (const vector bool int *, int, const int);
16823 void vec_dst (const vector float *, int, const int);
16824 void vec_dst (const unsigned char *, int, const int);
16825 void vec_dst (const signed char *, int, const int);
16826 void vec_dst (const unsigned short *, int, const int);
16827 void vec_dst (const short *, int, const int);
16828 void vec_dst (const unsigned int *, int, const int);
16829 void vec_dst (const int *, int, const int);
16830 void vec_dst (const float *, int, const int);
16832 void vec_dstst (const vector unsigned char *, int, const int);
16833 void vec_dstst (const vector signed char *, int, const int);
16834 void vec_dstst (const vector bool char *, int, const int);
16835 void vec_dstst (const vector unsigned short *, int, const int);
16836 void vec_dstst (const vector signed short *, int, const int);
16837 void vec_dstst (const vector bool short *, int, const int);
16838 void vec_dstst (const vector pixel *, int, const int);
16839 void vec_dstst (const vector unsigned int *, int, const int);
16840 void vec_dstst (const vector signed int *, int, const int);
16841 void vec_dstst (const vector bool int *, int, const int);
16842 void vec_dstst (const vector float *, int, const int);
16843 void vec_dstst (const unsigned char *, int, const int);
16844 void vec_dstst (const signed char *, int, const int);
16845 void vec_dstst (const unsigned short *, int, const int);
16846 void vec_dstst (const short *, int, const int);
16847 void vec_dstst (const unsigned int *, int, const int);
16848 void vec_dstst (const int *, int, const int);
16849 void vec_dstst (const unsigned long *, int, const int);
16850 void vec_dstst (const long *, int, const int);
16851 void vec_dstst (const float *, int, const int);
16853 void vec_dststt (const vector unsigned char *, int, const int);
16854 void vec_dststt (const vector signed char *, int, const int);
16855 void vec_dststt (const vector bool char *, int, const int);
16856 void vec_dststt (const vector unsigned short *, int, const int);
16857 void vec_dststt (const vector signed short *, int, const int);
16858 void vec_dststt (const vector bool short *, int, const int);
16859 void vec_dststt (const vector pixel *, int, const int);
16860 void vec_dststt (const vector unsigned int *, int, const int);
16861 void vec_dststt (const vector signed int *, int, const int);
16862 void vec_dststt (const vector bool int *, int, const int);
16863 void vec_dststt (const vector float *, int, const int);
16864 void vec_dststt (const unsigned char *, int, const int);
16865 void vec_dststt (const signed char *, int, const int);
16866 void vec_dststt (const unsigned short *, int, const int);
16867 void vec_dststt (const short *, int, const int);
16868 void vec_dststt (const unsigned int *, int, const int);
16869 void vec_dststt (const int *, int, const int);
16870 void vec_dststt (const float *, int, const int);
16872 void vec_dstt (const vector unsigned char *, int, const int);
16873 void vec_dstt (const vector signed char *, int, const int);
16874 void vec_dstt (const vector bool char *, int, const int);
16875 void vec_dstt (const vector unsigned short *, int, const int);
16876 void vec_dstt (const vector signed short *, int, const int);
16877 void vec_dstt (const vector bool short *, int, const int);
16878 void vec_dstt (const vector pixel *, int, const int);
16879 void vec_dstt (const vector unsigned int *, int, const int);
16880 void vec_dstt (const vector signed int *, int, const int);
16881 void vec_dstt (const vector bool int *, int, const int);
16882 void vec_dstt (const vector float *, int, const int);
16883 void vec_dstt (const unsigned char *, int, const int);
16884 void vec_dstt (const signed char *, int, const int);
16885 void vec_dstt (const unsigned short *, int, const int);
16886 void vec_dstt (const short *, int, const int);
16887 void vec_dstt (const unsigned int *, int, const int);
16888 void vec_dstt (const int *, int, const int);
16889 void vec_dstt (const float *, int, const int);
16891 vector float vec_expte (vector float);
16893 vector float vec_floor (vector float);
16895 vector float vec_ld (int, const vector float *);
16896 vector float vec_ld (int, const float *);
16897 vector bool int vec_ld (int, const vector bool int *);
16898 vector signed int vec_ld (int, const vector signed int *);
16899 vector signed int vec_ld (int, const int *);
16900 vector unsigned int vec_ld (int, const vector unsigned int *);
16901 vector unsigned int vec_ld (int, const unsigned int *);
16902 vector bool short vec_ld (int, const vector bool short *);
16903 vector pixel vec_ld (int, const vector pixel *);
16904 vector signed short vec_ld (int, const vector signed short *);
16905 vector signed short vec_ld (int, const short *);
16906 vector unsigned short vec_ld (int, const vector unsigned short *);
16907 vector unsigned short vec_ld (int, const unsigned short *);
16908 vector bool char vec_ld (int, const vector bool char *);
16909 vector signed char vec_ld (int, const vector signed char *);
16910 vector signed char vec_ld (int, const signed char *);
16911 vector unsigned char vec_ld (int, const vector unsigned char *);
16912 vector unsigned char vec_ld (int, const unsigned char *);
16914 vector signed char vec_lde (int, const signed char *);
16915 vector unsigned char vec_lde (int, const unsigned char *);
16916 vector signed short vec_lde (int, const short *);
16917 vector unsigned short vec_lde (int, const unsigned short *);
16918 vector float vec_lde (int, const float *);
16919 vector signed int vec_lde (int, const int *);
16920 vector unsigned int vec_lde (int, const unsigned int *);
16922 vector float vec_ldl (int, const vector float *);
16923 vector float vec_ldl (int, const float *);
16924 vector bool int vec_ldl (int, const vector bool int *);
16925 vector signed int vec_ldl (int, const vector signed int *);
16926 vector signed int vec_ldl (int, const int *);
16927 vector unsigned int vec_ldl (int, const vector unsigned int *);
16928 vector unsigned int vec_ldl (int, const unsigned int *);
16929 vector bool short vec_ldl (int, const vector bool short *);
16930 vector pixel vec_ldl (int, const vector pixel *);
16931 vector signed short vec_ldl (int, const vector signed short *);
16932 vector signed short vec_ldl (int, const short *);
16933 vector unsigned short vec_ldl (int, const vector unsigned short *);
16934 vector unsigned short vec_ldl (int, const unsigned short *);
16935 vector bool char vec_ldl (int, const vector bool char *);
16936 vector signed char vec_ldl (int, const vector signed char *);
16937 vector signed char vec_ldl (int, const signed char *);
16938 vector unsigned char vec_ldl (int, const vector unsigned char *);
16939 vector unsigned char vec_ldl (int, const unsigned char *);
16941 vector float vec_loge (vector float);
16943 vector signed char vec_lvebx (int, char *);
16944 vector unsigned char vec_lvebx (int, unsigned char *);
16946 vector signed short vec_lvehx (int, short *);
16947 vector unsigned short vec_lvehx (int, unsigned short *);
16949 vector float vec_lvewx (int, float *);
16950 vector signed int vec_lvewx (int, int *);
16951 vector unsigned int vec_lvewx (int, unsigned int *);
16953 vector unsigned char vec_lvsl (int, const unsigned char *);
16954 vector unsigned char vec_lvsl (int, const signed char *);
16955 vector unsigned char vec_lvsl (int, const unsigned short *);
16956 vector unsigned char vec_lvsl (int, const short *);
16957 vector unsigned char vec_lvsl (int, const unsigned int *);
16958 vector unsigned char vec_lvsl (int, const int *);
16959 vector unsigned char vec_lvsl (int, const float *);
16961 vector unsigned char vec_lvsr (int, const unsigned char *);
16962 vector unsigned char vec_lvsr (int, const signed char *);
16963 vector unsigned char vec_lvsr (int, const unsigned short *);
16964 vector unsigned char vec_lvsr (int, const short *);
16965 vector unsigned char vec_lvsr (int, const unsigned int *);
16966 vector unsigned char vec_lvsr (int, const int *);
16967 vector unsigned char vec_lvsr (int, const float *);
16969 vector float vec_madd (vector float, vector float, vector float);
16971 vector signed short vec_madds (vector signed short, vector signed short,
16972                                vector signed short);
16974 vector unsigned char vec_max (vector bool char, vector unsigned char);
16975 vector unsigned char vec_max (vector unsigned char, vector bool char);
16976 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
16977 vector signed char vec_max (vector bool char, vector signed char);
16978 vector signed char vec_max (vector signed char, vector bool char);
16979 vector signed char vec_max (vector signed char, vector signed char);
16980 vector unsigned short vec_max (vector bool short, vector unsigned short);
16981 vector unsigned short vec_max (vector unsigned short, vector bool short);
16982 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
16983 vector signed short vec_max (vector bool short, vector signed short);
16984 vector signed short vec_max (vector signed short, vector bool short);
16985 vector signed short vec_max (vector signed short, vector signed short);
16986 vector unsigned int vec_max (vector bool int, vector unsigned int);
16987 vector unsigned int vec_max (vector unsigned int, vector bool int);
16988 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16989 vector signed int vec_max (vector bool int, vector signed int);
16990 vector signed int vec_max (vector signed int, vector bool int);
16991 vector signed int vec_max (vector signed int, vector signed int);
16992 vector float vec_max (vector float, vector float);
16994 vector bool char vec_mergeh (vector bool char, vector bool char);
16995 vector signed char vec_mergeh (vector signed char, vector signed char);
16996 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
16997 vector bool short vec_mergeh (vector bool short, vector bool short);
16998 vector pixel vec_mergeh (vector pixel, vector pixel);
16999 vector signed short vec_mergeh (vector signed short, vector signed short);
17000 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
17001 vector float vec_mergeh (vector float, vector float);
17002 vector bool int vec_mergeh (vector bool int, vector bool int);
17003 vector signed int vec_mergeh (vector signed int, vector signed int);
17004 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
17006 vector bool char vec_mergel (vector bool char, vector bool char);
17007 vector signed char vec_mergel (vector signed char, vector signed char);
17008 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
17009 vector bool short vec_mergel (vector bool short, vector bool short);
17010 vector pixel vec_mergel (vector pixel, vector pixel);
17011 vector signed short vec_mergel (vector signed short, vector signed short);
17012 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
17013 vector float vec_mergel (vector float, vector float);
17014 vector bool int vec_mergel (vector bool int, vector bool int);
17015 vector signed int vec_mergel (vector signed int, vector signed int);
17016 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
17018 vector unsigned short vec_mfvscr (void);
17020 vector unsigned char vec_min (vector bool char, vector unsigned char);
17021 vector unsigned char vec_min (vector unsigned char, vector bool char);
17022 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
17023 vector signed char vec_min (vector bool char, vector signed char);
17024 vector signed char vec_min (vector signed char, vector bool char);
17025 vector signed char vec_min (vector signed char, vector signed char);
17026 vector unsigned short vec_min (vector bool short, vector unsigned short);
17027 vector unsigned short vec_min (vector unsigned short, vector bool short);
17028 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
17029 vector signed short vec_min (vector bool short, vector signed short);
17030 vector signed short vec_min (vector signed short, vector bool short);
17031 vector signed short vec_min (vector signed short, vector signed short);
17032 vector unsigned int vec_min (vector bool int, vector unsigned int);
17033 vector unsigned int vec_min (vector unsigned int, vector bool int);
17034 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
17035 vector signed int vec_min (vector bool int, vector signed int);
17036 vector signed int vec_min (vector signed int, vector bool int);
17037 vector signed int vec_min (vector signed int, vector signed int);
17038 vector float vec_min (vector float, vector float);
17040 vector signed short vec_mladd (vector signed short, vector signed short,
17041                                vector signed short);
17042 vector signed short vec_mladd (vector signed short, vector unsigned short,
17043                                vector unsigned short);
17044 vector signed short vec_mladd (vector unsigned short, vector signed short,
17045                                vector signed short);
17046 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
17047                                  vector unsigned short);
17049 vector signed short vec_mradds (vector signed short, vector signed short,
17050                                 vector signed short);
17052 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
17053                               vector unsigned int);
17054 vector signed int vec_msum (vector signed char, vector unsigned char,
17055                             vector signed int);
17056 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
17057                               vector unsigned int);
17058 vector signed int vec_msum (vector signed short, vector signed short,
17059                             vector signed int);
17061 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
17062                                vector unsigned int);
17063 vector signed int vec_msums (vector signed short, vector signed short,
17064                              vector signed int);
17066 void vec_mtvscr (vector signed int);
17067 void vec_mtvscr (vector unsigned int);
17068 void vec_mtvscr (vector bool int);
17069 void vec_mtvscr (vector signed short);
17070 void vec_mtvscr (vector unsigned short);
17071 void vec_mtvscr (vector bool short);
17072 void vec_mtvscr (vector pixel);
17073 void vec_mtvscr (vector signed char);
17074 void vec_mtvscr (vector unsigned char);
17075 void vec_mtvscr (vector bool char);
17077 vector float vec_mul (vector float, vector float);
17079 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
17080 vector signed short vec_mule (vector signed char, vector signed char);
17081 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
17082 vector signed int vec_mule (vector signed short, vector signed short);
17084 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
17085 vector signed short vec_mulo (vector signed char, vector signed char);
17086 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
17087 vector signed int vec_mulo (vector signed short, vector signed short);
17089 vector signed char vec_nabs (vector signed char);
17090 vector signed short vec_nabs (vector signed short);
17091 vector signed int vec_nabs (vector signed int);
17092 vector float vec_nabs (vector float);
17094 vector float vec_nmsub (vector float, vector float, vector float);
17096 vector float vec_nor (vector float, vector float);
17097 vector signed int vec_nor (vector signed int, vector signed int);
17098 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17099 vector bool int vec_nor (vector bool int, vector bool int);
17100 vector signed short vec_nor (vector signed short, vector signed short);
17101 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
17102 vector bool short vec_nor (vector bool short, vector bool short);
17103 vector signed char vec_nor (vector signed char, vector signed char);
17104 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
17105 vector bool char vec_nor (vector bool char, vector bool char);
17107 vector float vec_or (vector float, vector float);
17108 vector float vec_or (vector float, vector bool int);
17109 vector float vec_or (vector bool int, vector float);
17110 vector bool int vec_or (vector bool int, vector bool int);
17111 vector signed int vec_or (vector bool int, vector signed int);
17112 vector signed int vec_or (vector signed int, vector bool int);
17113 vector signed int vec_or (vector signed int, vector signed int);
17114 vector unsigned int vec_or (vector bool int, vector unsigned int);
17115 vector unsigned int vec_or (vector unsigned int, vector bool int);
17116 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17117 vector bool short vec_or (vector bool short, vector bool short);
17118 vector signed short vec_or (vector bool short, vector signed short);
17119 vector signed short vec_or (vector signed short, vector bool short);
17120 vector signed short vec_or (vector signed short, vector signed short);
17121 vector unsigned short vec_or (vector bool short, vector unsigned short);
17122 vector unsigned short vec_or (vector unsigned short, vector bool short);
17123 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
17124 vector signed char vec_or (vector bool char, vector signed char);
17125 vector bool char vec_or (vector bool char, vector bool char);
17126 vector signed char vec_or (vector signed char, vector bool char);
17127 vector signed char vec_or (vector signed char, vector signed char);
17128 vector unsigned char vec_or (vector bool char, vector unsigned char);
17129 vector unsigned char vec_or (vector unsigned char, vector bool char);
17130 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
17132 vector signed char vec_pack (vector signed short, vector signed short);
17133 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
17134 vector bool char vec_pack (vector bool short, vector bool short);
17135 vector signed short vec_pack (vector signed int, vector signed int);
17136 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
17137 vector bool short vec_pack (vector bool int, vector bool int);
17139 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17141 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
17142 vector signed char vec_packs (vector signed short, vector signed short);
17143 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
17144 vector signed short vec_packs (vector signed int, vector signed int);
17146 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
17147 vector unsigned char vec_packsu (vector signed short, vector signed short);
17148 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
17149 vector unsigned short vec_packsu (vector signed int, vector signed int);
17151 vector float vec_perm (vector float, vector float, vector unsigned char);
17152 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
17153 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
17154                               vector unsigned char);
17155 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
17156 vector signed short vec_perm (vector signed short, vector signed short,
17157                               vector unsigned char);
17158 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
17159                                 vector unsigned char);
17160 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
17161 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
17162 vector signed char vec_perm (vector signed char, vector signed char,
17163                              vector unsigned char);
17164 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
17165                                vector unsigned char);
17166 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
17168 vector float vec_re (vector float);
17170 vector bool char vec_reve (vector bool char);
17171 vector signed char vec_reve (vector signed char);
17172 vector unsigned char vec_reve (vector unsigned char);
17173 vector bool int vec_reve (vector bool int);
17174 vector signed int vec_reve (vector signed int);
17175 vector unsigned int vec_reve (vector unsigned int);
17176 vector bool short vec_reve (vector bool short);
17177 vector signed short vec_reve (vector signed short);
17178 vector unsigned short vec_reve (vector unsigned short);
17180 vector signed char vec_rl (vector signed char, vector unsigned char);
17181 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
17182 vector signed short vec_rl (vector signed short, vector unsigned short);
17183 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
17184 vector signed int vec_rl (vector signed int, vector unsigned int);
17185 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17187 vector float vec_round (vector float);
17189 vector float vec_rsqrt (vector float);
17191 vector float vec_rsqrte (vector float);
17193 vector float vec_sel (vector float, vector float, vector bool int);
17194 vector float vec_sel (vector float, vector float, vector unsigned int);
17195 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
17196 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
17197 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
17198 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
17199                              vector unsigned int);
17200 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
17201 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
17202 vector signed short vec_sel (vector signed short, vector signed short,
17203                              vector bool short);
17204 vector signed short vec_sel (vector signed short, vector signed short,
17205                              vector unsigned short);
17206 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17207                                vector bool short);
17208 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17209                                vector unsigned short);
17210 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
17211 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
17212 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
17213 vector signed char vec_sel (vector signed char, vector signed char,
17214                             vector unsigned char);
17215 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17216                               vector bool char);
17217 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17218                               vector unsigned char);
17219 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
17220 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
17222 vector signed char vec_sl (vector signed char, vector unsigned char);
17223 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
17224 vector signed short vec_sl (vector signed short, vector unsigned short);
17225 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
17226 vector signed int vec_sl (vector signed int, vector unsigned int);
17227 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17229 vector float vec_sld (vector float, vector float, const int);
17230 vector signed int vec_sld (vector signed int, vector signed int, const int);
17231 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
17232 vector bool int vec_sld (vector bool int, vector bool int, const int);
17233 vector signed short vec_sld (vector signed short, vector signed short, const int);
17234 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
17235 vector bool short vec_sld (vector bool short, vector bool short, const int);
17236 vector pixel vec_sld (vector pixel, vector pixel, const int);
17237 vector signed char vec_sld (vector signed char, vector signed char, const int);
17238 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
17239 vector bool char vec_sld (vector bool char, vector bool char, const int);
17241 vector signed int vec_sll (vector signed int, vector unsigned int);
17242 vector signed int vec_sll (vector signed int, vector unsigned short);
17243 vector signed int vec_sll (vector signed int, vector unsigned char);
17244 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
17245 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
17246 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
17247 vector bool int vec_sll (vector bool int, vector unsigned int);
17248 vector bool int vec_sll (vector bool int, vector unsigned short);
17249 vector bool int vec_sll (vector bool int, vector unsigned char);
17250 vector signed short vec_sll (vector signed short, vector unsigned int);
17251 vector signed short vec_sll (vector signed short, vector unsigned short);
17252 vector signed short vec_sll (vector signed short, vector unsigned char);
17253 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
17254 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
17255 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
17256 vector bool short vec_sll (vector bool short, vector unsigned int);
17257 vector bool short vec_sll (vector bool short, vector unsigned short);
17258 vector bool short vec_sll (vector bool short, vector unsigned char);
17259 vector pixel vec_sll (vector pixel, vector unsigned int);
17260 vector pixel vec_sll (vector pixel, vector unsigned short);
17261 vector pixel vec_sll (vector pixel, vector unsigned char);
17262 vector signed char vec_sll (vector signed char, vector unsigned int);
17263 vector signed char vec_sll (vector signed char, vector unsigned short);
17264 vector signed char vec_sll (vector signed char, vector unsigned char);
17265 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
17266 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
17267 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
17268 vector bool char vec_sll (vector bool char, vector unsigned int);
17269 vector bool char vec_sll (vector bool char, vector unsigned short);
17270 vector bool char vec_sll (vector bool char, vector unsigned char);
17272 vector float vec_slo (vector float, vector signed char);
17273 vector float vec_slo (vector float, vector unsigned char);
17274 vector signed int vec_slo (vector signed int, vector signed char);
17275 vector signed int vec_slo (vector signed int, vector unsigned char);
17276 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17277 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17278 vector signed short vec_slo (vector signed short, vector signed char);
17279 vector signed short vec_slo (vector signed short, vector unsigned char);
17280 vector unsigned short vec_slo (vector unsigned short, vector signed char);
17281 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
17282 vector pixel vec_slo (vector pixel, vector signed char);
17283 vector pixel vec_slo (vector pixel, vector unsigned char);
17284 vector signed char vec_slo (vector signed char, vector signed char);
17285 vector signed char vec_slo (vector signed char, vector unsigned char);
17286 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17287 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
17289 vector signed char vec_splat (vector signed char, const int);
17290 vector unsigned char vec_splat (vector unsigned char, const int);
17291 vector bool char vec_splat (vector bool char, const int);
17292 vector signed short vec_splat (vector signed short, const int);
17293 vector unsigned short vec_splat (vector unsigned short, const int);
17294 vector bool short vec_splat (vector bool short, const int);
17295 vector pixel vec_splat (vector pixel, const int);
17296 vector float vec_splat (vector float, const int);
17297 vector signed int vec_splat (vector signed int, const int);
17298 vector unsigned int vec_splat (vector unsigned int, const int);
17299 vector bool int vec_splat (vector bool int, const int);
17301 vector signed short vec_splat_s16 (const int);
17303 vector signed int vec_splat_s32 (const int);
17305 vector signed char vec_splat_s8 (const int);
17307 vector unsigned short vec_splat_u16 (const int);
17309 vector unsigned int vec_splat_u32 (const int);
17311 vector unsigned char vec_splat_u8 (const int);
17313 vector signed char vec_splats (signed char);
17314 vector unsigned char vec_splats (unsigned char);
17315 vector signed short vec_splats (signed short);
17316 vector unsigned short vec_splats (unsigned short);
17317 vector signed int vec_splats (signed int);
17318 vector unsigned int vec_splats (unsigned int);
17319 vector float vec_splats (float);
17321 vector signed char vec_sr (vector signed char, vector unsigned char);
17322 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
17323 vector signed short vec_sr (vector signed short, vector unsigned short);
17324 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
17325 vector signed int vec_sr (vector signed int, vector unsigned int);
17326 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17328 vector signed char vec_sra (vector signed char, vector unsigned char);
17329 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
17330 vector signed short vec_sra (vector signed short, vector unsigned short);
17331 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
17332 vector signed int vec_sra (vector signed int, vector unsigned int);
17333 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17335 vector signed int vec_srl (vector signed int, vector unsigned int);
17336 vector signed int vec_srl (vector signed int, vector unsigned short);
17337 vector signed int vec_srl (vector signed int, vector unsigned char);
17338 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17339 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
17340 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17341 vector bool int vec_srl (vector bool int, vector unsigned int);
17342 vector bool int vec_srl (vector bool int, vector unsigned short);
17343 vector bool int vec_srl (vector bool int, vector unsigned char);
17344 vector signed short vec_srl (vector signed short, vector unsigned int);
17345 vector signed short vec_srl (vector signed short, vector unsigned short);
17346 vector signed short vec_srl (vector signed short, vector unsigned char);
17347 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
17348 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
17349 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
17350 vector bool short vec_srl (vector bool short, vector unsigned int);
17351 vector bool short vec_srl (vector bool short, vector unsigned short);
17352 vector bool short vec_srl (vector bool short, vector unsigned char);
17353 vector pixel vec_srl (vector pixel, vector unsigned int);
17354 vector pixel vec_srl (vector pixel, vector unsigned short);
17355 vector pixel vec_srl (vector pixel, vector unsigned char);
17356 vector signed char vec_srl (vector signed char, vector unsigned int);
17357 vector signed char vec_srl (vector signed char, vector unsigned short);
17358 vector signed char vec_srl (vector signed char, vector unsigned char);
17359 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
17360 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
17361 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
17362 vector bool char vec_srl (vector bool char, vector unsigned int);
17363 vector bool char vec_srl (vector bool char, vector unsigned short);
17364 vector bool char vec_srl (vector bool char, vector unsigned char);
17366 vector float vec_sro (vector float, vector signed char);
17367 vector float vec_sro (vector float, vector unsigned char);
17368 vector signed int vec_sro (vector signed int, vector signed char);
17369 vector signed int vec_sro (vector signed int, vector unsigned char);
17370 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17371 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17372 vector signed short vec_sro (vector signed short, vector signed char);
17373 vector signed short vec_sro (vector signed short, vector unsigned char);
17374 vector unsigned short vec_sro (vector unsigned short, vector signed char);
17375 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
17376 vector pixel vec_sro (vector pixel, vector signed char);
17377 vector pixel vec_sro (vector pixel, vector unsigned char);
17378 vector signed char vec_sro (vector signed char, vector signed char);
17379 vector signed char vec_sro (vector signed char, vector unsigned char);
17380 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17381 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
17383 void vec_st (vector float, int, vector float *);
17384 void vec_st (vector float, int, float *);
17385 void vec_st (vector signed int, int, vector signed int *);
17386 void vec_st (vector signed int, int, int *);
17387 void vec_st (vector unsigned int, int, vector unsigned int *);
17388 void vec_st (vector unsigned int, int, unsigned int *);
17389 void vec_st (vector bool int, int, vector bool int *);
17390 void vec_st (vector bool int, int, unsigned int *);
17391 void vec_st (vector bool int, int, int *);
17392 void vec_st (vector signed short, int, vector signed short *);
17393 void vec_st (vector signed short, int, short *);
17394 void vec_st (vector unsigned short, int, vector unsigned short *);
17395 void vec_st (vector unsigned short, int, unsigned short *);
17396 void vec_st (vector bool short, int, vector bool short *);
17397 void vec_st (vector bool short, int, unsigned short *);
17398 void vec_st (vector pixel, int, vector pixel *);
17399 void vec_st (vector bool short, int, short *);
17400 void vec_st (vector signed char, int, vector signed char *);
17401 void vec_st (vector signed char, int, signed char *);
17402 void vec_st (vector unsigned char, int, vector unsigned char *);
17403 void vec_st (vector unsigned char, int, unsigned char *);
17404 void vec_st (vector bool char, int, vector bool char *);
17405 void vec_st (vector bool char, int, unsigned char *);
17406 void vec_st (vector bool char, int, signed char *);
17408 void vec_ste (vector signed char, int, signed char *);
17409 void vec_ste (vector unsigned char, int, unsigned char *);
17410 void vec_ste (vector bool char, int, signed char *);
17411 void vec_ste (vector bool char, int, unsigned char *);
17412 void vec_ste (vector signed short, int, short *);
17413 void vec_ste (vector unsigned short, int, unsigned short *);
17414 void vec_ste (vector bool short, int, short *);
17415 void vec_ste (vector bool short, int, unsigned short *);
17416 void vec_ste (vector pixel, int, short *);
17417 void vec_ste (vector pixel, int, unsigned short *);
17418 void vec_ste (vector float, int, float *);
17419 void vec_ste (vector signed int, int, int *);
17420 void vec_ste (vector unsigned int, int, unsigned int *);
17421 void vec_ste (vector bool int, int, int *);
17422 void vec_ste (vector bool int, int, unsigned int *);
17424 void vec_stl (vector float, int, vector float *);
17425 void vec_stl (vector float, int, float *);
17426 void vec_stl (vector signed int, int, vector signed int *);
17427 void vec_stl (vector signed int, int, int *);
17428 void vec_stl (vector unsigned int, int, vector unsigned int *);
17429 void vec_stl (vector unsigned int, int, unsigned int *);
17430 void vec_stl (vector bool int, int, vector bool int *);
17431 void vec_stl (vector bool int, int, unsigned int *);
17432 void vec_stl (vector bool int, int, int *);
17433 void vec_stl (vector signed short, int, vector signed short *);
17434 void vec_stl (vector signed short, int, short *);
17435 void vec_stl (vector unsigned short, int, vector unsigned short *);
17436 void vec_stl (vector unsigned short, int, unsigned short *);
17437 void vec_stl (vector bool short, int, vector bool short *);
17438 void vec_stl (vector bool short, int, unsigned short *);
17439 void vec_stl (vector bool short, int, short *);
17440 void vec_stl (vector pixel, int, vector pixel *);
17441 void vec_stl (vector signed char, int, vector signed char *);
17442 void vec_stl (vector signed char, int, signed char *);
17443 void vec_stl (vector unsigned char, int, vector unsigned char *);
17444 void vec_stl (vector unsigned char, int, unsigned char *);
17445 void vec_stl (vector bool char, int, vector bool char *);
17446 void vec_stl (vector bool char, int, unsigned char *);
17447 void vec_stl (vector bool char, int, signed char *);
17449 void vec_stvebx (vector signed char, int, signed char *);
17450 void vec_stvebx (vector unsigned char, int, unsigned char *);
17451 void vec_stvebx (vector bool char, int, signed char *);
17452 void vec_stvebx (vector bool char, int, unsigned char *);
17454 void vec_stvehx (vector signed short, int, short *);
17455 void vec_stvehx (vector unsigned short, int, unsigned short *);
17456 void vec_stvehx (vector bool short, int, short *);
17457 void vec_stvehx (vector bool short, int, unsigned short *);
17459 void vec_stvewx (vector float, int, float *);
17460 void vec_stvewx (vector signed int, int, int *);
17461 void vec_stvewx (vector unsigned int, int, unsigned int *);
17462 void vec_stvewx (vector bool int, int, int *);
17463 void vec_stvewx (vector bool int, int, unsigned int *);
17465 vector signed char vec_sub (vector bool char, vector signed char);
17466 vector signed char vec_sub (vector signed char, vector bool char);
17467 vector signed char vec_sub (vector signed char, vector signed char);
17468 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17469 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17470 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
17471 vector signed short vec_sub (vector bool short, vector signed short);
17472 vector signed short vec_sub (vector signed short, vector bool short);
17473 vector signed short vec_sub (vector signed short, vector signed short);
17474 vector unsigned short vec_sub (vector bool short, vector unsigned short);
17475 vector unsigned short vec_sub (vector unsigned short, vector bool short);
17476 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
17477 vector signed int vec_sub (vector bool int, vector signed int);
17478 vector signed int vec_sub (vector signed int, vector bool int);
17479 vector signed int vec_sub (vector signed int, vector signed int);
17480 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17481 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17482 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17483 vector float vec_sub (vector float, vector float);
17485 vector signed int vec_subc (vector signed int, vector signed int);
17486 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17488 vector signed int vec_sube (vector signed int, vector signed int,
17489                             vector signed int);
17490 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17491                               vector unsigned int);
17493 vector signed int vec_subec (vector signed int, vector signed int,
17494                              vector signed int);
17495 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17496                                vector unsigned int);
17498 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17499 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17500 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
17501 vector signed char vec_subs (vector bool char, vector signed char);
17502 vector signed char vec_subs (vector signed char, vector bool char);
17503 vector signed char vec_subs (vector signed char, vector signed char);
17504 vector unsigned short vec_subs (vector bool short, vector unsigned short);
17505 vector unsigned short vec_subs (vector unsigned short, vector bool short);
17506 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
17507 vector signed short vec_subs (vector bool short, vector signed short);
17508 vector signed short vec_subs (vector signed short, vector bool short);
17509 vector signed short vec_subs (vector signed short, vector signed short);
17510 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17511 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17512 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17513 vector signed int vec_subs (vector bool int, vector signed int);
17514 vector signed int vec_subs (vector signed int, vector bool int);
17515 vector signed int vec_subs (vector signed int, vector signed int);
17517 vector signed int vec_sum2s (vector signed int, vector signed int);
17519 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
17520 vector signed int vec_sum4s (vector signed char, vector signed int);
17521 vector signed int vec_sum4s (vector signed short, vector signed int);
17523 vector signed int vec_sums (vector signed int, vector signed int);
17525 vector float vec_trunc (vector float);
17527 vector signed short vec_unpackh (vector signed char);
17528 vector bool short vec_unpackh (vector bool char);
17529 vector signed int vec_unpackh (vector signed short);
17530 vector bool int vec_unpackh (vector bool short);
17531 vector unsigned int vec_unpackh (vector pixel);
17533 vector signed short vec_unpackl (vector signed char);
17534 vector bool short vec_unpackl (vector bool char);
17535 vector unsigned int vec_unpackl (vector pixel);
17536 vector signed int vec_unpackl (vector signed short);
17537 vector bool int vec_unpackl (vector bool short);
17539 vector float vec_vaddfp (vector float, vector float);
17541 vector signed char vec_vaddsbs (vector bool char, vector signed char);
17542 vector signed char vec_vaddsbs (vector signed char, vector bool char);
17543 vector signed char vec_vaddsbs (vector signed char, vector signed char);
17545 vector signed short vec_vaddshs (vector bool short, vector signed short);
17546 vector signed short vec_vaddshs (vector signed short, vector bool short);
17547 vector signed short vec_vaddshs (vector signed short, vector signed short);
17549 vector signed int vec_vaddsws (vector bool int, vector signed int);
17550 vector signed int vec_vaddsws (vector signed int, vector bool int);
17551 vector signed int vec_vaddsws (vector signed int, vector signed int);
17553 vector signed char vec_vaddubm (vector bool char, vector signed char);
17554 vector signed char vec_vaddubm (vector signed char, vector bool char);
17555 vector signed char vec_vaddubm (vector signed char, vector signed char);
17556 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
17557 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
17558 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
17560 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
17561 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
17562 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
17564 vector signed short vec_vadduhm (vector bool short, vector signed short);
17565 vector signed short vec_vadduhm (vector signed short, vector bool short);
17566 vector signed short vec_vadduhm (vector signed short, vector signed short);
17567 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
17568 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
17569 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
17571 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
17572 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
17573 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
17575 vector signed int vec_vadduwm (vector bool int, vector signed int);
17576 vector signed int vec_vadduwm (vector signed int, vector bool int);
17577 vector signed int vec_vadduwm (vector signed int, vector signed int);
17578 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
17579 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
17580 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
17582 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
17583 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
17584 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
17586 vector signed char vec_vavgsb (vector signed char, vector signed char);
17588 vector signed short vec_vavgsh (vector signed short, vector signed short);
17590 vector signed int vec_vavgsw (vector signed int, vector signed int);
17592 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
17594 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
17596 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
17598 vector float vec_vcfsx (vector signed int, const int);
17600 vector float vec_vcfux (vector unsigned int, const int);
17602 vector bool int vec_vcmpeqfp (vector float, vector float);
17604 vector bool char vec_vcmpequb (vector signed char, vector signed char);
17605 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
17607 vector bool short vec_vcmpequh (vector signed short, vector signed short);
17608 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
17610 vector bool int vec_vcmpequw (vector signed int, vector signed int);
17611 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
17613 vector bool int vec_vcmpgtfp (vector float, vector float);
17615 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
17617 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
17619 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
17621 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
17623 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
17625 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
17627 vector float vec_vmaxfp (vector float, vector float);
17629 vector signed char vec_vmaxsb (vector bool char, vector signed char);
17630 vector signed char vec_vmaxsb (vector signed char, vector bool char);
17631 vector signed char vec_vmaxsb (vector signed char, vector signed char);
17633 vector signed short vec_vmaxsh (vector bool short, vector signed short);
17634 vector signed short vec_vmaxsh (vector signed short, vector bool short);
17635 vector signed short vec_vmaxsh (vector signed short, vector signed short);
17637 vector signed int vec_vmaxsw (vector bool int, vector signed int);
17638 vector signed int vec_vmaxsw (vector signed int, vector bool int);
17639 vector signed int vec_vmaxsw (vector signed int, vector signed int);
17641 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
17642 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
17643 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
17645 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
17646 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
17647 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
17649 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
17650 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
17651 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
17653 vector float vec_vminfp (vector float, vector float);
17655 vector signed char vec_vminsb (vector bool char, vector signed char);
17656 vector signed char vec_vminsb (vector signed char, vector bool char);
17657 vector signed char vec_vminsb (vector signed char, vector signed char);
17659 vector signed short vec_vminsh (vector bool short, vector signed short);
17660 vector signed short vec_vminsh (vector signed short, vector bool short);
17661 vector signed short vec_vminsh (vector signed short, vector signed short);
17663 vector signed int vec_vminsw (vector bool int, vector signed int);
17664 vector signed int vec_vminsw (vector signed int, vector bool int);
17665 vector signed int vec_vminsw (vector signed int, vector signed int);
17667 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
17668 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
17669 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
17671 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
17672 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
17673 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
17675 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
17676 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
17677 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
17679 vector bool char vec_vmrghb (vector bool char, vector bool char);
17680 vector signed char vec_vmrghb (vector signed char, vector signed char);
17681 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
17683 vector bool short vec_vmrghh (vector bool short, vector bool short);
17684 vector signed short vec_vmrghh (vector signed short, vector signed short);
17685 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
17686 vector pixel vec_vmrghh (vector pixel, vector pixel);
17688 vector float vec_vmrghw (vector float, vector float);
17689 vector bool int vec_vmrghw (vector bool int, vector bool int);
17690 vector signed int vec_vmrghw (vector signed int, vector signed int);
17691 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
17693 vector bool char vec_vmrglb (vector bool char, vector bool char);
17694 vector signed char vec_vmrglb (vector signed char, vector signed char);
17695 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
17697 vector bool short vec_vmrglh (vector bool short, vector bool short);
17698 vector signed short vec_vmrglh (vector signed short, vector signed short);
17699 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
17700 vector pixel vec_vmrglh (vector pixel, vector pixel);
17702 vector float vec_vmrglw (vector float, vector float);
17703 vector signed int vec_vmrglw (vector signed int, vector signed int);
17704 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
17705 vector bool int vec_vmrglw (vector bool int, vector bool int);
17707 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
17708                                 vector signed int);
17710 vector signed int vec_vmsumshm (vector signed short, vector signed short,
17711                                 vector signed int);
17713 vector signed int vec_vmsumshs (vector signed short, vector signed short,
17714                                 vector signed int);
17716 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
17717                                   vector unsigned int);
17719 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
17720                                   vector unsigned int);
17722 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
17723                                   vector unsigned int);
17725 vector signed short vec_vmulesb (vector signed char, vector signed char);
17727 vector signed int vec_vmulesh (vector signed short, vector signed short);
17729 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
17731 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
17733 vector signed short vec_vmulosb (vector signed char, vector signed char);
17735 vector signed int vec_vmulosh (vector signed short, vector signed short);
17737 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
17739 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
17741 vector signed char vec_vpkshss (vector signed short, vector signed short);
17743 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
17745 vector signed short vec_vpkswss (vector signed int, vector signed int);
17747 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
17749 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17750 vector signed char vec_vpkuhum (vector signed short, vector signed short);
17751 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
17753 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
17755 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17756 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17757 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
17759 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
17761 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17762 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
17764 vector signed short vec_vrlh (vector signed short, vector unsigned short);
17765 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
17767 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17768 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17770 vector signed char vec_vslb (vector signed char, vector unsigned char);
17771 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
17773 vector signed short vec_vslh (vector signed short, vector unsigned short);
17774 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
17776 vector signed int vec_vslw (vector signed int, vector unsigned int);
17777 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17779 vector signed char vec_vspltb (vector signed char, const int);
17780 vector unsigned char vec_vspltb (vector unsigned char, const int);
17781 vector bool char vec_vspltb (vector bool char, const int);
17783 vector bool short vec_vsplth (vector bool short, const int);
17784 vector signed short vec_vsplth (vector signed short, const int);
17785 vector unsigned short vec_vsplth (vector unsigned short, const int);
17786 vector pixel vec_vsplth (vector pixel, const int);
17788 vector float vec_vspltw (vector float, const int);
17789 vector signed int vec_vspltw (vector signed int, const int);
17790 vector unsigned int vec_vspltw (vector unsigned int, const int);
17791 vector bool int vec_vspltw (vector bool int, const int);
17793 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17794 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
17796 vector signed short vec_vsrah (vector signed short, vector unsigned short);
17797 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
17799 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17800 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
17802 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17803 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
17805 vector signed short vec_vsrh (vector signed short, vector unsigned short);
17806 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
17808 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17809 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17811 vector float vec_vsubfp (vector float, vector float);
17813 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17814 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17815 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17817 vector signed short vec_vsubshs (vector bool short, vector signed short);
17818 vector signed short vec_vsubshs (vector signed short, vector bool short);
17819 vector signed short vec_vsubshs (vector signed short, vector signed short);
17821 vector signed int vec_vsubsws (vector bool int, vector signed int);
17822 vector signed int vec_vsubsws (vector signed int, vector bool int);
17823 vector signed int vec_vsubsws (vector signed int, vector signed int);
17825 vector signed char vec_vsububm (vector bool char, vector signed char);
17826 vector signed char vec_vsububm (vector signed char, vector bool char);
17827 vector signed char vec_vsububm (vector signed char, vector signed char);
17828 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
17829 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
17830 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
17832 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
17833 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
17834 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
17836 vector signed short vec_vsubuhm (vector bool short, vector signed short);
17837 vector signed short vec_vsubuhm (vector signed short, vector bool short);
17838 vector signed short vec_vsubuhm (vector signed short, vector signed short);
17839 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
17840 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
17841 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
17843 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
17844 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
17845 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
17847 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17848 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17849 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17850 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17851 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17852 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
17854 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17855 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17856 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
17858 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17860 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17862 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
17864 vector unsigned int vec_vupkhpx (vector pixel);
17866 vector bool short vec_vupkhsb (vector bool char);
17867 vector signed short vec_vupkhsb (vector signed char);
17869 vector bool int vec_vupkhsh (vector bool short);
17870 vector signed int vec_vupkhsh (vector signed short);
17872 vector unsigned int vec_vupklpx (vector pixel);
17874 vector bool short vec_vupklsb (vector bool char);
17875 vector signed short vec_vupklsb (vector signed char);
17877 vector bool int vec_vupklsh (vector bool short);
17878 vector signed int vec_vupklsh (vector signed short);
17880 vector float vec_xor (vector float, vector float);
17881 vector float vec_xor (vector float, vector bool int);
17882 vector float vec_xor (vector bool int, vector float);
17883 vector bool int vec_xor (vector bool int, vector bool int);
17884 vector signed int vec_xor (vector bool int, vector signed int);
17885 vector signed int vec_xor (vector signed int, vector bool int);
17886 vector signed int vec_xor (vector signed int, vector signed int);
17887 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17888 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17889 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17890 vector bool short vec_xor (vector bool short, vector bool short);
17891 vector signed short vec_xor (vector bool short, vector signed short);
17892 vector signed short vec_xor (vector signed short, vector bool short);
17893 vector signed short vec_xor (vector signed short, vector signed short);
17894 vector unsigned short vec_xor (vector bool short, vector unsigned short);
17895 vector unsigned short vec_xor (vector unsigned short, vector bool short);
17896 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
17897 vector signed char vec_xor (vector bool char, vector signed char);
17898 vector bool char vec_xor (vector bool char, vector bool char);
17899 vector signed char vec_xor (vector signed char, vector bool char);
17900 vector signed char vec_xor (vector signed char, vector signed char);
17901 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17902 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17903 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
17904 @end smallexample
17906 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
17907 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
17909 The AltiVec built-in functions described in this section are
17910 available on the PowerPC family of processors starting with ISA 2.06
17911 or later.  These are normally enabled by adding @option{-mvsx} to the
17912 command line.
17914 When @option{-mvsx} is used, the following additional vector types are
17915 implemented.
17917 @smallexample
17918 vector unsigned __int128
17919 vector signed __int128
17920 vector unsigned long long int
17921 vector signed long long int
17922 vector double
17923 @end smallexample
17925 The long long types are only implemented for 64-bit code generation.
17927 @smallexample
17929 vector bool long long vec_and (vector bool long long int, vector bool long long);
17931 vector double vec_ctf (vector unsigned long, const int);
17932 vector double vec_ctf (vector signed long, const int);
17934 vector signed long vec_cts (vector double, const int);
17936 vector unsigned long vec_ctu (vector double, const int);
17938 void vec_dst (const unsigned long *, int, const int);
17939 void vec_dst (const long *, int, const int);
17941 void vec_dststt (const unsigned long *, int, const int);
17942 void vec_dststt (const long *, int, const int);
17944 void vec_dstt (const unsigned long *, int, const int);
17945 void vec_dstt (const long *, int, const int);
17947 vector unsigned char vec_lvsl (int, const unsigned long *);
17948 vector unsigned char vec_lvsl (int, const long *);
17950 vector unsigned char vec_lvsr (int, const unsigned long *);
17951 vector unsigned char vec_lvsr (int, const long *);
17953 vector double vec_mul (vector double, vector double);
17954 vector long vec_mul (vector long, vector long);
17955 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17957 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
17958 vector signed long long vec_mule (vector signed int, vector signed int);
17960 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
17961 vector signed long long vec_mulo (vector signed int, vector signed int);
17963 vector double vec_nabs (vector double);
17965 vector bool long long vec_reve (vector bool long long);
17966 vector signed long long vec_reve (vector signed long long);
17967 vector unsigned long long vec_reve (vector unsigned long long);
17968 vector double vec_sld (vector double, vector double, const int);
17970 vector bool long long int vec_sld (vector bool long long int,
17971                                    vector bool long long int, const int);
17972 vector long long int vec_sld (vector long long int, vector  long long int, const int);
17973 vector unsigned long long int vec_sld (vector unsigned long long int,
17974                                        vector unsigned long long int, const int);
17976 vector long long int vec_sll (vector long long int, vector unsigned char);
17977 vector unsigned long long int vec_sll (vector unsigned long long int,
17978                                        vector unsigned char);
17980 vector signed long long vec_slo (vector signed long long, vector signed char);
17981 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17982 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17983 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17985 vector signed long vec_splat (vector signed long, const int);
17986 vector unsigned long vec_splat (vector unsigned long, const int);
17988 vector long long int vec_srl (vector long long int, vector unsigned char);
17989 vector unsigned long long int vec_srl (vector unsigned long long int,
17990                                        vector unsigned char);
17992 vector long long int vec_sro (vector long long int, vector char);
17993 vector long long int vec_sro (vector long long int, vector unsigned char);
17994 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
17995 vector unsigned long long int vec_sro (vector unsigned long long int,
17996                                        vector unsigned char);
17998 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
17999 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
18001 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
18002                                  vector signed __int128);
18003 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
18004                                    vector unsigned __int128);
18006 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
18007                                   vector signed __int128);
18008 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
18009                                     vector unsigned __int128);
18011 vector double vec_unpackh (vector float);
18013 vector double vec_unpackl (vector float);
18015 vector double vec_doublee (vector float);
18016 vector double vec_doublee (vector signed int);
18017 vector double vec_doublee (vector unsigned int);
18019 vector double vec_doubleo (vector float);
18020 vector double vec_doubleo (vector signed int);
18021 vector double vec_doubleo (vector unsigned int);
18023 vector double vec_doubleh (vector float);
18024 vector double vec_doubleh (vector signed int);
18025 vector double vec_doubleh (vector unsigned int);
18027 vector double vec_doublel (vector float);
18028 vector double vec_doublel (vector signed int);
18029 vector double vec_doublel (vector unsigned int);
18031 vector float vec_float (vector signed int);
18032 vector float vec_float (vector unsigned int);
18034 vector float vec_float2 (vector signed long long, vector signed long long);
18035 vector float vec_float2 (vector unsigned long long, vector signed long long);
18037 vector float vec_floate (vector double);
18038 vector float vec_floate (vector signed long long);
18039 vector float vec_floate (vector unsigned long long);
18041 vector float vec_floato (vector double);
18042 vector float vec_floato (vector signed long long);
18043 vector float vec_floato (vector unsigned long long);
18045 vector signed long long vec_signed (vector double);
18046 vector signed int vec_signed (vector float);
18048 vector signed int vec_signede (vector double);
18050 vector signed int vec_signedo (vector double);
18052 vector signed char vec_sldw (vector signed char, vector signed char, const int);
18053 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
18054 vector signed short vec_sldw (vector signed short, vector signed short, const int);
18055 vector unsigned short vec_sldw (vector unsigned short,
18056                                 vector unsigned short, const int);
18057 vector signed int vec_sldw (vector signed int, vector signed int, const int);
18058 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
18059 vector signed long long vec_sldw (vector signed long long,
18060                                   vector signed long long, const int);
18061 vector unsigned long long vec_sldw (vector unsigned long long,
18062                                     vector unsigned long long, const int);
18064 vector signed long long vec_unsigned (vector double);
18065 vector signed int vec_unsigned (vector float);
18067 vector signed int vec_unsignede (vector double);
18069 vector signed int vec_unsignedo (vector double);
18071 vector double vec_abs (vector double);
18072 vector double vec_add (vector double, vector double);
18073 vector double vec_and (vector double, vector double);
18074 vector double vec_and (vector double, vector bool long);
18075 vector double vec_and (vector bool long, vector double);
18076 vector long vec_and (vector long, vector long);
18077 vector long vec_and (vector long, vector bool long);
18078 vector long vec_and (vector bool long, vector long);
18079 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18080 vector unsigned long vec_and (vector unsigned long, vector bool long);
18081 vector unsigned long vec_and (vector bool long, vector unsigned long);
18082 vector double vec_andc (vector double, vector double);
18083 vector double vec_andc (vector double, vector bool long);
18084 vector double vec_andc (vector bool long, vector double);
18085 vector long vec_andc (vector long, vector long);
18086 vector long vec_andc (vector long, vector bool long);
18087 vector long vec_andc (vector bool long, vector long);
18088 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18089 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18090 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18091 vector double vec_ceil (vector double);
18092 vector bool long vec_cmpeq (vector double, vector double);
18093 vector bool long vec_cmpge (vector double, vector double);
18094 vector bool long vec_cmpgt (vector double, vector double);
18095 vector bool long vec_cmple (vector double, vector double);
18096 vector bool long vec_cmplt (vector double, vector double);
18097 vector double vec_cpsgn (vector double, vector double);
18098 vector float vec_div (vector float, vector float);
18099 vector double vec_div (vector double, vector double);
18100 vector long vec_div (vector long, vector long);
18101 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18102 vector double vec_floor (vector double);
18103 vector __int128 vec_ld (int, const vector __int128 *);
18104 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18105 vector __int128 vec_ld (int, const __int128 *);
18106 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18107 vector double vec_ld (int, const vector double *);
18108 vector double vec_ld (int, const double *);
18109 vector double vec_ldl (int, const vector double *);
18110 vector double vec_ldl (int, const double *);
18111 vector unsigned char vec_lvsl (int, const double *);
18112 vector unsigned char vec_lvsr (int, const double *);
18113 vector double vec_madd (vector double, vector double, vector double);
18114 vector double vec_max (vector double, vector double);
18115 vector signed long vec_mergeh (vector signed long, vector signed long);
18116 vector signed long vec_mergeh (vector signed long, vector bool long);
18117 vector signed long vec_mergeh (vector bool long, vector signed long);
18118 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18119 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18120 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18121 vector signed long vec_mergel (vector signed long, vector signed long);
18122 vector signed long vec_mergel (vector signed long, vector bool long);
18123 vector signed long vec_mergel (vector bool long, vector signed long);
18124 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18125 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18126 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18127 vector double vec_min (vector double, vector double);
18128 vector float vec_msub (vector float, vector float, vector float);
18129 vector double vec_msub (vector double, vector double, vector double);
18130 vector float vec_nearbyint (vector float);
18131 vector double vec_nearbyint (vector double);
18132 vector float vec_nmadd (vector float, vector float, vector float);
18133 vector double vec_nmadd (vector double, vector double, vector double);
18134 vector double vec_nmsub (vector double, vector double, vector double);
18135 vector double vec_nor (vector double, vector double);
18136 vector long vec_nor (vector long, vector long);
18137 vector long vec_nor (vector long, vector bool long);
18138 vector long vec_nor (vector bool long, vector long);
18139 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18140 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18141 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18142 vector double vec_or (vector double, vector double);
18143 vector double vec_or (vector double, vector bool long);
18144 vector double vec_or (vector bool long, vector double);
18145 vector long vec_or (vector long, vector long);
18146 vector long vec_or (vector long, vector bool long);
18147 vector long vec_or (vector bool long, vector long);
18148 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18149 vector unsigned long vec_or (vector unsigned long, vector bool long);
18150 vector unsigned long vec_or (vector bool long, vector unsigned long);
18151 vector double vec_perm (vector double, vector double, vector unsigned char);
18152 vector long vec_perm (vector long, vector long, vector unsigned char);
18153 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18154                                vector unsigned char);
18155 vector bool char vec_permxor (vector bool char, vector bool char,
18156                               vector bool char);
18157 vector unsigned char vec_permxor (vector signed char, vector signed char,
18158                                   vector signed char);
18159 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
18160                                   vector unsigned char);
18161 vector double vec_rint (vector double);
18162 vector double vec_recip (vector double, vector double);
18163 vector double vec_rsqrt (vector double);
18164 vector double vec_rsqrte (vector double);
18165 vector double vec_sel (vector double, vector double, vector bool long);
18166 vector double vec_sel (vector double, vector double, vector unsigned long);
18167 vector long vec_sel (vector long, vector long, vector long);
18168 vector long vec_sel (vector long, vector long, vector unsigned long);
18169 vector long vec_sel (vector long, vector long, vector bool long);
18170 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18171                               vector long);
18172 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18173                               vector unsigned long);
18174 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18175                               vector bool long);
18176 vector double vec_splats (double);
18177 vector signed long vec_splats (signed long);
18178 vector unsigned long vec_splats (unsigned long);
18179 vector float vec_sqrt (vector float);
18180 vector double vec_sqrt (vector double);
18181 void vec_st (vector double, int, vector double *);
18182 void vec_st (vector double, int, double *);
18183 vector double vec_sub (vector double, vector double);
18184 vector double vec_trunc (vector double);
18185 vector double vec_xl (int, vector double *);
18186 vector double vec_xl (int, double *);
18187 vector long long vec_xl (int, vector long long *);
18188 vector long long vec_xl (int, long long *);
18189 vector unsigned long long vec_xl (int, vector unsigned long long *);
18190 vector unsigned long long vec_xl (int, unsigned long long *);
18191 vector float vec_xl (int, vector float *);
18192 vector float vec_xl (int, float *);
18193 vector int vec_xl (int, vector int *);
18194 vector int vec_xl (int, int *);
18195 vector unsigned int vec_xl (int, vector unsigned int *);
18196 vector unsigned int vec_xl (int, unsigned int *);
18197 vector double vec_xor (vector double, vector double);
18198 vector double vec_xor (vector double, vector bool long);
18199 vector double vec_xor (vector bool long, vector double);
18200 vector long vec_xor (vector long, vector long);
18201 vector long vec_xor (vector long, vector bool long);
18202 vector long vec_xor (vector bool long, vector long);
18203 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18204 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18205 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18206 void vec_xst (vector double, int, vector double *);
18207 void vec_xst (vector double, int, double *);
18208 void vec_xst (vector long long, int, vector long long *);
18209 void vec_xst (vector long long, int, long long *);
18210 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18211 void vec_xst (vector unsigned long long, int, unsigned long long *);
18212 void vec_xst (vector float, int, vector float *);
18213 void vec_xst (vector float, int, float *);
18214 void vec_xst (vector int, int, vector int *);
18215 void vec_xst (vector int, int, int *);
18216 void vec_xst (vector unsigned int, int, vector unsigned int *);
18217 void vec_xst (vector unsigned int, int, unsigned int *);
18218 int vec_all_eq (vector double, vector double);
18219 int vec_all_ge (vector double, vector double);
18220 int vec_all_gt (vector double, vector double);
18221 int vec_all_le (vector double, vector double);
18222 int vec_all_lt (vector double, vector double);
18223 int vec_all_nan (vector double);
18224 int vec_all_ne (vector double, vector double);
18225 int vec_all_nge (vector double, vector double);
18226 int vec_all_ngt (vector double, vector double);
18227 int vec_all_nle (vector double, vector double);
18228 int vec_all_nlt (vector double, vector double);
18229 int vec_all_numeric (vector double);
18230 int vec_any_eq (vector double, vector double);
18231 int vec_any_ge (vector double, vector double);
18232 int vec_any_gt (vector double, vector double);
18233 int vec_any_le (vector double, vector double);
18234 int vec_any_lt (vector double, vector double);
18235 int vec_any_nan (vector double);
18236 int vec_any_ne (vector double, vector double);
18237 int vec_any_nge (vector double, vector double);
18238 int vec_any_ngt (vector double, vector double);
18239 int vec_any_nle (vector double, vector double);
18240 int vec_any_nlt (vector double, vector double);
18241 int vec_any_numeric (vector double);
18243 vector double vec_vsx_ld (int, const vector double *);
18244 vector double vec_vsx_ld (int, const double *);
18245 vector float vec_vsx_ld (int, const vector float *);
18246 vector float vec_vsx_ld (int, const float *);
18247 vector bool int vec_vsx_ld (int, const vector bool int *);
18248 vector signed int vec_vsx_ld (int, const vector signed int *);
18249 vector signed int vec_vsx_ld (int, const int *);
18250 vector signed int vec_vsx_ld (int, const long *);
18251 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18252 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18253 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18254 vector bool short vec_vsx_ld (int, const vector bool short *);
18255 vector pixel vec_vsx_ld (int, const vector pixel *);
18256 vector signed short vec_vsx_ld (int, const vector signed short *);
18257 vector signed short vec_vsx_ld (int, const short *);
18258 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18259 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18260 vector bool char vec_vsx_ld (int, const vector bool char *);
18261 vector signed char vec_vsx_ld (int, const vector signed char *);
18262 vector signed char vec_vsx_ld (int, const signed char *);
18263 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18264 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18266 void vec_vsx_st (vector double, int, vector double *);
18267 void vec_vsx_st (vector double, int, double *);
18268 void vec_vsx_st (vector float, int, vector float *);
18269 void vec_vsx_st (vector float, int, float *);
18270 void vec_vsx_st (vector signed int, int, vector signed int *);
18271 void vec_vsx_st (vector signed int, int, int *);
18272 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18273 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18274 void vec_vsx_st (vector bool int, int, vector bool int *);
18275 void vec_vsx_st (vector bool int, int, unsigned int *);
18276 void vec_vsx_st (vector bool int, int, int *);
18277 void vec_vsx_st (vector signed short, int, vector signed short *);
18278 void vec_vsx_st (vector signed short, int, short *);
18279 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18280 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18281 void vec_vsx_st (vector bool short, int, vector bool short *);
18282 void vec_vsx_st (vector bool short, int, unsigned short *);
18283 void vec_vsx_st (vector pixel, int, vector pixel *);
18284 void vec_vsx_st (vector pixel, int, unsigned short *);
18285 void vec_vsx_st (vector pixel, int, short *);
18286 void vec_vsx_st (vector bool short, int, short *);
18287 void vec_vsx_st (vector signed char, int, vector signed char *);
18288 void vec_vsx_st (vector signed char, int, signed char *);
18289 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18290 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18291 void vec_vsx_st (vector bool char, int, vector bool char *);
18292 void vec_vsx_st (vector bool char, int, unsigned char *);
18293 void vec_vsx_st (vector bool char, int, signed char *);
18295 vector double vec_xxpermdi (vector double, vector double, const int);
18296 vector float vec_xxpermdi (vector float, vector float, const int);
18297 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18298 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18299                                         vector unsigned long long, const int);
18300 vector int vec_xxpermdi (vector int, vector int, const int);
18301 vector unsigned int vec_xxpermdi (vector unsigned int,
18302                                   vector unsigned int, const int);
18303 vector short vec_xxpermdi (vector short, vector short, const int);
18304 vector unsigned short vec_xxpermdi (vector unsigned short,
18305                                     vector unsigned short, const int);
18306 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18307                                  const int);
18308 vector unsigned char vec_xxpermdi (vector unsigned char,
18309                                    vector unsigned char, const int);
18311 vector double vec_xxsldi (vector double, vector double, int);
18312 vector float vec_xxsldi (vector float, vector float, int);
18313 vector long long vec_xxsldi (vector long long, vector long long, int);
18314 vector unsigned long long vec_xxsldi (vector unsigned long long,
18315                                       vector unsigned long long, int);
18316 vector int vec_xxsldi (vector int, vector int, int);
18317 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18318 vector short vec_xxsldi (vector short, vector short, int);
18319 vector unsigned short vec_xxsldi (vector unsigned short,
18320                                   vector unsigned short, int);
18321 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18322 vector unsigned char vec_xxsldi (vector unsigned char,
18323                                  vector unsigned char, int);
18324 @end smallexample
18326 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18327 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18328 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
18329 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18330 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18332 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
18333 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
18335 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18336 instruction set are available, the following additional functions are
18337 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
18338 can use @var{vector long} instead of @var{vector long long},
18339 @var{vector bool long} instead of @var{vector bool long long}, and
18340 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18342 @smallexample
18343 vector signed char vec_neg (vector signed char);
18344 vector signed short vec_neg (vector signed short);
18345 vector signed int vec_neg (vector signed int);
18346 vector signed long long vec_neg (vector signed long long);
18347 vector float  char vec_neg (vector float);
18348 vector double vec_neg (vector double);
18350 vector signed int vec_signed2 (vector double, vector double);
18352 vector signed int vec_unsigned2 (vector double, vector double);
18354 vector long long vec_abs (vector long long);
18356 vector long long vec_add (vector long long, vector long long);
18357 vector unsigned long long vec_add (vector unsigned long long,
18358                                    vector unsigned long long);
18360 int vec_all_eq (vector long long, vector long long);
18361 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18362 int vec_all_ge (vector long long, vector long long);
18363 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18364 int vec_all_gt (vector long long, vector long long);
18365 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18366 int vec_all_le (vector long long, vector long long);
18367 int vec_all_le (vector unsigned long long, vector unsigned long long);
18368 int vec_all_lt (vector long long, vector long long);
18369 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18370 int vec_all_ne (vector long long, vector long long);
18371 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18373 int vec_any_eq (vector long long, vector long long);
18374 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18375 int vec_any_ge (vector long long, vector long long);
18376 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18377 int vec_any_gt (vector long long, vector long long);
18378 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18379 int vec_any_le (vector long long, vector long long);
18380 int vec_any_le (vector unsigned long long, vector unsigned long long);
18381 int vec_any_lt (vector long long, vector long long);
18382 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18383 int vec_any_ne (vector long long, vector long long);
18384 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18386 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18388 vector long long vec_eqv (vector long long, vector long long);
18389 vector long long vec_eqv (vector bool long long, vector long long);
18390 vector long long vec_eqv (vector long long, vector bool long long);
18391 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
18392 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
18393 vector unsigned long long vec_eqv (vector unsigned long long,
18394                                    vector bool long long);
18395 vector int vec_eqv (vector int, vector int);
18396 vector int vec_eqv (vector bool int, vector int);
18397 vector int vec_eqv (vector int, vector bool int);
18398 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18399 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
18400 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
18401 vector short vec_eqv (vector short, vector short);
18402 vector short vec_eqv (vector bool short, vector short);
18403 vector short vec_eqv (vector short, vector bool short);
18404 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18405 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
18406 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
18407 vector signed char vec_eqv (vector signed char, vector signed char);
18408 vector signed char vec_eqv (vector bool signed char, vector signed char);
18409 vector signed char vec_eqv (vector signed char, vector bool signed char);
18410 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18411 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18412 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18414 vector long long vec_max (vector long long, vector long long);
18415 vector unsigned long long vec_max (vector unsigned long long,
18416                                    vector unsigned long long);
18418 vector signed int vec_mergee (vector signed int, vector signed int);
18419 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18420 vector bool int vec_mergee (vector bool int, vector bool int);
18422 vector signed int vec_mergeo (vector signed int, vector signed int);
18423 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18424 vector bool int vec_mergeo (vector bool int, vector bool int);
18426 vector long long vec_min (vector long long, vector long long);
18427 vector unsigned long long vec_min (vector unsigned long long,
18428                                    vector unsigned long long);
18430 vector signed long long vec_nabs (vector signed long long);
18432 vector long long vec_nand (vector long long, vector long long);
18433 vector long long vec_nand (vector bool long long, vector long long);
18434 vector long long vec_nand (vector long long, vector bool long long);
18435 vector unsigned long long vec_nand (vector unsigned long long,
18436                                     vector unsigned long long);
18437 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
18438 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
18439 vector int vec_nand (vector int, vector int);
18440 vector int vec_nand (vector bool int, vector int);
18441 vector int vec_nand (vector int, vector bool int);
18442 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18443 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
18444 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
18445 vector short vec_nand (vector short, vector short);
18446 vector short vec_nand (vector bool short, vector short);
18447 vector short vec_nand (vector short, vector bool short);
18448 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18449 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
18450 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
18451 vector signed char vec_nand (vector signed char, vector signed char);
18452 vector signed char vec_nand (vector bool signed char, vector signed char);
18453 vector signed char vec_nand (vector signed char, vector bool signed char);
18454 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18455 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18456 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18458 vector long long vec_orc (vector long long, vector long long);
18459 vector long long vec_orc (vector bool long long, vector long long);
18460 vector long long vec_orc (vector long long, vector bool long long);
18461 vector unsigned long long vec_orc (vector unsigned long long,
18462                                    vector unsigned long long);
18463 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
18464 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
18465 vector int vec_orc (vector int, vector int);
18466 vector int vec_orc (vector bool int, vector int);
18467 vector int vec_orc (vector int, vector bool int);
18468 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18469 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
18470 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
18471 vector short vec_orc (vector short, vector short);
18472 vector short vec_orc (vector bool short, vector short);
18473 vector short vec_orc (vector short, vector bool short);
18474 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18475 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
18476 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
18477 vector signed char vec_orc (vector signed char, vector signed char);
18478 vector signed char vec_orc (vector bool signed char, vector signed char);
18479 vector signed char vec_orc (vector signed char, vector bool signed char);
18480 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18481 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18482 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18484 vector int vec_pack (vector long long, vector long long);
18485 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
18486 vector bool int vec_pack (vector bool long long, vector bool long long);
18487 vector float vec_pack (vector double, vector double);
18489 vector int vec_packs (vector long long, vector long long);
18490 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
18492 vector unsigned char vec_packsu (vector signed short, vector signed short)
18493 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
18494 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18495 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
18496 vector unsigned int vec_packsu (vector long long, vector long long);
18497 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
18498 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
18500 vector unsigned char vec_popcnt (vector signed char);
18501 vector unsigned char vec_popcnt (vector unsigned char);
18502 vector unsigned short vec_popcnt (vector signed short);
18503 vector unsigned short vec_popcnt (vector unsigned short);
18504 vector unsigned int vec_popcnt (vector signed int);
18505 vector unsigned int vec_popcnt (vector unsigned int);
18506 vector unsigned long long vec_popcnt (vector signed long long);
18507 vector unsigned long long vec_popcnt (vector unsigned long long);
18509 vector long long vec_rl (vector long long, vector unsigned long long);
18510 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
18512 vector long long vec_sl (vector long long, vector unsigned long long);
18513 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
18515 vector long long vec_sr (vector long long, vector unsigned long long);
18516 vector unsigned long long char vec_sr (vector unsigned long long,
18517                                        vector unsigned long long);
18519 vector long long vec_sra (vector long long, vector unsigned long long);
18520 vector unsigned long long vec_sra (vector unsigned long long,
18521                                    vector unsigned long long);
18523 vector long long vec_sub (vector long long, vector long long);
18524 vector unsigned long long vec_sub (vector unsigned long long,
18525                                    vector unsigned long long);
18527 vector long long vec_unpackh (vector int);
18528 vector unsigned long long vec_unpackh (vector unsigned int);
18530 vector long long vec_unpackl (vector int);
18531 vector unsigned long long vec_unpackl (vector unsigned int);
18533 vector long long vec_vaddudm (vector long long, vector long long);
18534 vector long long vec_vaddudm (vector bool long long, vector long long);
18535 vector long long vec_vaddudm (vector long long, vector bool long long);
18536 vector unsigned long long vec_vaddudm (vector unsigned long long,
18537                                        vector unsigned long long);
18538 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18539                                        vector unsigned long long);
18540 vector unsigned long long vec_vaddudm (vector unsigned long long,
18541                                        vector bool unsigned long long);
18543 vector long long vec_vbpermq (vector signed char, vector signed char);
18544 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18546 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18547 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
18548 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
18550 vector long long vec_cntlz (vector long long);
18551 vector unsigned long long vec_cntlz (vector unsigned long long);
18552 vector int vec_cntlz (vector int);
18553 vector unsigned int vec_cntlz (vector int);
18554 vector short vec_cntlz (vector short);
18555 vector unsigned short vec_cntlz (vector unsigned short);
18556 vector signed char vec_cntlz (vector signed char);
18557 vector unsigned char vec_cntlz (vector unsigned char);
18559 vector long long vec_vclz (vector long long);
18560 vector unsigned long long vec_vclz (vector unsigned long long);
18561 vector int vec_vclz (vector int);
18562 vector unsigned int vec_vclz (vector int);
18563 vector short vec_vclz (vector short);
18564 vector unsigned short vec_vclz (vector unsigned short);
18565 vector signed char vec_vclz (vector signed char);
18566 vector unsigned char vec_vclz (vector unsigned char);
18568 vector signed char vec_vclzb (vector signed char);
18569 vector unsigned char vec_vclzb (vector unsigned char);
18571 vector long long vec_vclzd (vector long long);
18572 vector unsigned long long vec_vclzd (vector unsigned long long);
18574 vector short vec_vclzh (vector short);
18575 vector unsigned short vec_vclzh (vector unsigned short);
18577 vector int vec_vclzw (vector int);
18578 vector unsigned int vec_vclzw (vector int);
18580 vector signed char vec_vgbbd (vector signed char);
18581 vector unsigned char vec_vgbbd (vector unsigned char);
18583 vector long long vec_vmaxsd (vector long long, vector long long);
18585 vector unsigned long long vec_vmaxud (vector unsigned long long,
18586                                       unsigned vector long long);
18588 vector long long vec_vminsd (vector long long, vector long long);
18590 vector unsigned long long vec_vminud (vector long long, vector long long);
18592 vector int vec_vpksdss (vector long long, vector long long);
18593 vector unsigned int vec_vpksdss (vector long long, vector long long);
18595 vector unsigned int vec_vpkudus (vector unsigned long long,
18596                                  vector unsigned long long);
18598 vector int vec_vpkudum (vector long long, vector long long);
18599 vector unsigned int vec_vpkudum (vector unsigned long long,
18600                                  vector unsigned long long);
18601 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18603 vector long long vec_vpopcnt (vector long long);
18604 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18605 vector int vec_vpopcnt (vector int);
18606 vector unsigned int vec_vpopcnt (vector int);
18607 vector short vec_vpopcnt (vector short);
18608 vector unsigned short vec_vpopcnt (vector unsigned short);
18609 vector signed char vec_vpopcnt (vector signed char);
18610 vector unsigned char vec_vpopcnt (vector unsigned char);
18612 vector signed char vec_vpopcntb (vector signed char);
18613 vector unsigned char vec_vpopcntb (vector unsigned char);
18615 vector long long vec_vpopcntd (vector long long);
18616 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18618 vector short vec_vpopcnth (vector short);
18619 vector unsigned short vec_vpopcnth (vector unsigned short);
18621 vector int vec_vpopcntw (vector int);
18622 vector unsigned int vec_vpopcntw (vector int);
18624 vector long long vec_vrld (vector long long, vector unsigned long long);
18625 vector unsigned long long vec_vrld (vector unsigned long long,
18626                                     vector unsigned long long);
18628 vector long long vec_vsld (vector long long, vector unsigned long long);
18629 vector long long vec_vsld (vector unsigned long long,
18630                            vector unsigned long long);
18632 vector long long vec_vsrad (vector long long, vector unsigned long long);
18633 vector unsigned long long vec_vsrad (vector unsigned long long,
18634                                      vector unsigned long long);
18636 vector long long vec_vsrd (vector long long, vector unsigned long long);
18637 vector unsigned long long char vec_vsrd (vector unsigned long long,
18638                                          vector unsigned long long);
18640 vector long long vec_vsubudm (vector long long, vector long long);
18641 vector long long vec_vsubudm (vector bool long long, vector long long);
18642 vector long long vec_vsubudm (vector long long, vector bool long long);
18643 vector unsigned long long vec_vsubudm (vector unsigned long long,
18644                                        vector unsigned long long);
18645 vector unsigned long long vec_vsubudm (vector bool long long,
18646                                        vector unsigned long long);
18647 vector unsigned long long vec_vsubudm (vector unsigned long long,
18648                                        vector bool long long);
18650 vector long long vec_vupkhsw (vector int);
18651 vector unsigned long long vec_vupkhsw (vector unsigned int);
18653 vector long long vec_vupklsw (vector int);
18654 vector unsigned long long vec_vupklsw (vector int);
18655 @end smallexample
18657 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18658 instruction set are available, the following additional functions are
18659 available for 64-bit targets.  New vector types
18660 (@var{vector __int128} and @var{vector __uint128}) are available
18661 to hold the @var{__int128} and @var{__uint128} types to use these
18662 builtins.
18664 The normal vector extract, and set operations work on
18665 @var{vector __int128} and @var{vector __uint128} types,
18666 but the index value must be 0.
18668 @smallexample
18669 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
18670 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
18672 vector __int128 vec_vadduqm (vector __int128, vector __int128);
18673 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
18675 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
18676                                 vector __int128);
18677 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
18678                                  vector __uint128);
18680 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
18681                                 vector __int128);
18682 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
18683                                  vector __uint128);
18685 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
18686                                 vector __int128);
18687 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
18688                                  vector __uint128);
18690 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
18691                                 vector __int128);
18692 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
18693                                  vector __uint128);
18695 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
18696 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
18698 __int128 vec_vsubuqm (__int128, __int128);
18699 __uint128 vec_vsubuqm (__uint128, __uint128);
18701 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
18702 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
18703 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
18704 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
18705 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
18706 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
18707 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
18708 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
18709 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
18710 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
18711 @end smallexample
18713 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
18714 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
18716 The following additional built-in functions are also available for the
18717 PowerPC family of processors, starting with ISA 3.0
18718 (@option{-mcpu=power9}) or later:
18719 @smallexample
18720 unsigned int scalar_extract_exp (double source);
18721 unsigned long long int scalar_extract_exp (__ieee128 source);
18723 unsigned long long int scalar_extract_sig (double source);
18724 unsigned __int128 scalar_extract_sig (__ieee128 source);
18726 double scalar_insert_exp (unsigned long long int significand,
18727                           unsigned long long int exponent);
18728 double scalar_insert_exp (double significand, unsigned long long int exponent);
18730 ieee_128 scalar_insert_exp (unsigned __int128 significand,
18731                             unsigned long long int exponent);
18732 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18734 int scalar_cmp_exp_gt (double arg1, double arg2);
18735 int scalar_cmp_exp_lt (double arg1, double arg2);
18736 int scalar_cmp_exp_eq (double arg1, double arg2);
18737 int scalar_cmp_exp_unordered (double arg1, double arg2);
18739 bool scalar_test_data_class (float source, const int condition);
18740 bool scalar_test_data_class (double source, const int condition);
18741 bool scalar_test_data_class (__ieee128 source, const int condition);
18743 bool scalar_test_neg (float source);
18744 bool scalar_test_neg (double source);
18745 bool scalar_test_neg (__ieee128 source);
18746 @end smallexample
18748 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18749 functions require a 64-bit environment supporting ISA 3.0 or later.
18750 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18751 functions return the significand and the biased exponent value
18752 respectively of their @code{source} arguments.
18753 When supplied with a 64-bit @code{source} argument, the
18754 result returned by @code{scalar_extract_sig} has
18755 the @code{0x0010000000000000} bit set if the
18756 function's @code{source} argument is in normalized form.
18757 Otherwise, this bit is set to 0.
18758 When supplied with a 128-bit @code{source} argument, the
18759 @code{0x00010000000000000000000000000000} bit of the result is
18760 treated similarly.
18761 Note that the sign of the significand is not represented in the result
18762 returned from the @code{scalar_extract_sig} function.  Use the
18763 @code{scalar_test_neg} function to test the sign of its @code{double}
18764 argument.
18766 The @code{scalar_insert_exp}
18767 functions require a 64-bit environment supporting ISA 3.0 or later.
18768 When supplied with a 64-bit first argument, the
18769 @code{scalar_insert_exp} built-in function returns a double-precision
18770 floating point value that is constructed by assembling the values of its
18771 @code{significand} and @code{exponent} arguments.  The sign of the
18772 result is copied from the most significant bit of the
18773 @code{significand} argument.  The significand and exponent components
18774 of the result are composed of the least significant 11 bits of the
18775 @code{exponent} argument and the least significant 52 bits of the
18776 @code{significand} argument respectively.
18778 When supplied with a 128-bit first argument, the
18779 @code{scalar_insert_exp} built-in function returns a quad-precision
18780 ieee floating point value.  The sign bit of the result is copied from
18781 the most significant bit of the @code{significand} argument.
18782 The significand and exponent components of the result are composed of
18783 the least significant 15 bits of the @code{exponent} argument and the
18784 least significant 112 bits of the @code{significand} argument respectively.
18786 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18787 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18788 functions return a non-zero value if @code{arg1} is greater than, less
18789 than, equal to, or not comparable to @code{arg2} respectively.  The
18790 arguments are not comparable if one or the other equals NaN (not a
18791 number). 
18793 The @code{scalar_test_data_class} built-in function returns 1
18794 if any of the condition tests enabled by the value of the
18795 @code{condition} variable are true, and 0 otherwise.  The
18796 @code{condition} argument must be a compile-time constant integer with
18797 value not exceeding 127.  The
18798 @code{condition} argument is encoded as a bitmask with each bit
18799 enabling the testing of a different condition, as characterized by the
18800 following:
18801 @smallexample
18802 0x40    Test for NaN
18803 0x20    Test for +Infinity
18804 0x10    Test for -Infinity
18805 0x08    Test for +Zero
18806 0x04    Test for -Zero
18807 0x02    Test for +Denormal
18808 0x01    Test for -Denormal
18809 @end smallexample
18811 The @code{scalar_test_neg} built-in function returns 1 if its
18812 @code{source} argument holds a negative value, 0 otherwise.
18814 The following built-in functions are also available for the PowerPC family
18815 of processors, starting with ISA 3.0 or later
18816 (@option{-mcpu=power9}).  These string functions are described
18817 separately in order to group the descriptions closer to the function
18818 prototypes:
18819 @smallexample
18820 int vec_all_nez (vector signed char, vector signed char);
18821 int vec_all_nez (vector unsigned char, vector unsigned char);
18822 int vec_all_nez (vector signed short, vector signed short);
18823 int vec_all_nez (vector unsigned short, vector unsigned short);
18824 int vec_all_nez (vector signed int, vector signed int);
18825 int vec_all_nez (vector unsigned int, vector unsigned int);
18827 int vec_any_eqz (vector signed char, vector signed char);
18828 int vec_any_eqz (vector unsigned char, vector unsigned char);
18829 int vec_any_eqz (vector signed short, vector signed short);
18830 int vec_any_eqz (vector unsigned short, vector unsigned short);
18831 int vec_any_eqz (vector signed int, vector signed int);
18832 int vec_any_eqz (vector unsigned int, vector unsigned int);
18834 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
18835 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
18836 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
18837 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
18838 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
18839 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
18841 vector signed char vec_cnttz (vector signed char);
18842 vector unsigned char vec_cnttz (vector unsigned char);
18843 vector signed short vec_cnttz (vector signed short);
18844 vector unsigned short vec_cnttz (vector unsigned short);
18845 vector signed int vec_cnttz (vector signed int);
18846 vector unsigned int vec_cnttz (vector unsigned int);
18847 vector signed long long vec_cnttz (vector signed long long);
18848 vector unsigned long long vec_cnttz (vector unsigned long long);
18850 signed int vec_cntlz_lsbb (vector signed char);
18851 signed int vec_cntlz_lsbb (vector unsigned char);
18853 signed int vec_cnttz_lsbb (vector signed char);
18854 signed int vec_cnttz_lsbb (vector unsigned char);
18856 unsigned int vec_first_match_index (vector signed char, vector signed char);
18857 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
18858 unsigned int vec_first_match_index (vector signed int, vector signed int);
18859 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
18860 unsigned int vec_first_match_index (vector signed short, vector signed short);
18861 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
18862 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
18863 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
18864 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
18865 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
18866 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
18867 unsigned int vec_first_match_or_eos_index (vector unsigned short,
18868                                            vector unsigned short);
18869 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
18870 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
18871 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
18872 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
18873 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
18874 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
18875 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
18876 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
18877                                               vector unsigned char);
18878 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
18879 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
18880 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
18881 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
18882                                               vector unsigned short);
18884 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
18886 vector signed char vec_xl_be (signed long long, signed char *);
18887 vector unsigned char vec_xl_be (signed long long, unsigned char *);
18888 vector signed int vec_xl_be (signed long long, signed int *);
18889 vector unsigned int vec_xl_be (signed long long, unsigned int *);
18890 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
18891 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
18892 vector signed long long vec_xl_be (signed long long, signed long long *);
18893 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
18894 vector signed short vec_xl_be (signed long long, signed short *);
18895 vector unsigned short vec_xl_be (signed long long, unsigned short *);
18896 vector double vec_xl_be (signed long long, double *);
18897 vector float vec_xl_be (signed long long, float *);
18899 vector signed char vec_xl_len (signed char *addr, size_t len);
18900 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
18901 vector signed int vec_xl_len (signed int *addr, size_t len);
18902 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
18903 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
18904 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
18905 vector signed long long vec_xl_len (signed long long *addr, size_t len);
18906 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
18907 vector signed short vec_xl_len (signed short *addr, size_t len);
18908 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
18909 vector double vec_xl_len (double *addr, size_t len);
18910 vector float vec_xl_len (float *addr, size_t len);
18912 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
18914 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
18915 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
18916 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
18917 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
18918 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
18919 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
18920 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
18921 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
18922 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
18923 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
18924 void vec_xst_len (vector double data, double *addr, size_t len);
18925 void vec_xst_len (vector float data, float *addr, size_t len);
18927 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
18929 signed char vec_xlx (unsigned int index, vector signed char data);
18930 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
18931 signed short vec_xlx (unsigned int index, vector signed short data);
18932 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
18933 signed int vec_xlx (unsigned int index, vector signed int data);
18934 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
18935 float vec_xlx (unsigned int index, vector float data);
18937 signed char vec_xrx (unsigned int index, vector signed char data);
18938 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
18939 signed short vec_xrx (unsigned int index, vector signed short data);
18940 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
18941 signed int vec_xrx (unsigned int index, vector signed int data);
18942 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
18943 float vec_xrx (unsigned int index, vector float data);
18944 @end smallexample
18946 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
18947 perform pairwise comparisons between the elements at the same
18948 positions within their two vector arguments.
18949 The @code{vec_all_nez} function returns a
18950 non-zero value if and only if all pairwise comparisons are not
18951 equal and no element of either vector argument contains a zero.
18952 The @code{vec_any_eqz} function returns a
18953 non-zero value if and only if at least one pairwise comparison is equal
18954 or if at least one element of either vector argument contains a zero.
18955 The @code{vec_cmpnez} function returns a vector of the same type as
18956 its two arguments, within which each element consists of all ones to
18957 denote that either the corresponding elements of the incoming arguments are
18958 not equal or that at least one of the corresponding elements contains
18959 zero.  Otherwise, the element of the returned vector contains all zeros.
18961 The @code{vec_cntlz_lsbb} function returns the count of the number of
18962 consecutive leading byte elements (starting from position 0 within the
18963 supplied vector argument) for which the least-significant bit
18964 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
18965 the number of consecutive trailing byte elements (starting from
18966 position 15 and counting backwards within the supplied vector
18967 argument) for which the least-significant bit equals zero.
18969 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
18970 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
18971 function loads a variable length vector from memory.  The
18972 @code{vec_xst_len} function stores a variable length vector to memory.
18973 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
18974 @code{addr} argument represents the memory address to or from which
18975 data will be transferred, and the
18976 @code{len} argument represents the number of bytes to be
18977 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
18978 If this expression's value is not a multiple of the vector element's
18979 size, the behavior of this function is undefined.
18980 In the case that the underlying computer is configured to run in
18981 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
18982 the corresponding vector.  In little-endian mode, the data transfer
18983 moves bytes @code{(16 - len)} to @code{15} of the corresponding
18984 vector.  For the load function, any bytes of the result vector that
18985 are not loaded from memory are set to zero.
18986 The value of the @code{addr} argument need not be aligned on a
18987 multiple of the vector's element size.
18989 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
18990 element selected by the @code{index} argument from the vector
18991 represented by the @code{data} argument.  The @code{index} argument
18992 always specifies a byte offset, regardless of the size of the vector
18993 element.  With @code{vec_xlx}, @code{index} is the offset of the first
18994 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
18995 represents the last byte of the element to be extracted, measured
18996 from the right end of the vector.  In other words, the last byte of
18997 the element to be extracted is found at position @code{(15 - index)}.
18998 There is no requirement that @code{index} be a multiple of the vector
18999 element size.  However, if the size of the vector element added to
19000 @code{index} is greater than 15, the content of the returned value is
19001 undefined.
19003 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19004 are available:
19006 @smallexample
19007 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
19009 vector bool char vec_cmpne (vector bool char, vector bool char);
19010 vector bool char vec_cmpne (vector signed char, vector signed char);
19011 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19012 vector bool int vec_cmpne (vector bool int, vector bool int);
19013 vector bool int vec_cmpne (vector signed int, vector signed int);
19014 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19015 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19016 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
19017 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
19018 vector bool short vec_cmpne (vector bool short, vector bool short);
19019 vector bool short vec_cmpne (vector signed short, vector signed short);
19020 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19021 vector bool long long vec_cmpne (vector double, vector double);
19022 vector bool int vec_cmpne (vector float, vector float);
19024 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19025 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19027 vector long long vec_vctz (vector long long);
19028 vector unsigned long long vec_vctz (vector unsigned long long);
19029 vector int vec_vctz (vector int);
19030 vector unsigned int vec_vctz (vector int);
19031 vector short vec_vctz (vector short);
19032 vector unsigned short vec_vctz (vector unsigned short);
19033 vector signed char vec_vctz (vector signed char);
19034 vector unsigned char vec_vctz (vector unsigned char);
19036 vector signed char vec_vctzb (vector signed char);
19037 vector unsigned char vec_vctzb (vector unsigned char);
19039 vector long long vec_vctzd (vector long long);
19040 vector unsigned long long vec_vctzd (vector unsigned long long);
19042 vector short vec_vctzh (vector short);
19043 vector unsigned short vec_vctzh (vector unsigned short);
19045 vector int vec_vctzw (vector int);
19046 vector unsigned int vec_vctzw (vector int);
19048 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19050 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19051                                    const int);
19052 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19053                                    const int);
19055 vector unsigned int vec_parity_lsbb (vector signed int);
19056 vector unsigned int vec_parity_lsbb (vector unsigned int);
19057 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19058 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19059 vector unsigned long long vec_parity_lsbb (vector signed long long);
19060 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19062 vector int vec_vprtyb (vector int);
19063 vector unsigned int vec_vprtyb (vector unsigned int);
19064 vector long long vec_vprtyb (vector long long);
19065 vector unsigned long long vec_vprtyb (vector unsigned long long);
19067 vector int vec_vprtybw (vector int);
19068 vector unsigned int vec_vprtybw (vector unsigned int);
19070 vector long long vec_vprtybd (vector long long);
19071 vector unsigned long long vec_vprtybd (vector unsigned long long);
19072 @end smallexample
19074 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19075 are available:
19077 @smallexample
19078 vector long vec_vprtyb (vector long);
19079 vector unsigned long vec_vprtyb (vector unsigned long);
19080 vector __int128 vec_vprtyb (vector __int128);
19081 vector __uint128 vec_vprtyb (vector __uint128);
19083 vector long vec_vprtybd (vector long);
19084 vector unsigned long vec_vprtybd (vector unsigned long);
19086 vector __int128 vec_vprtybq (vector __int128);
19087 vector __uint128 vec_vprtybd (vector __uint128);
19088 @end smallexample
19090 The following built-in vector functions are available for the PowerPC family
19091 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19092 @smallexample
19093 __vector unsigned char
19094 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19095 __vector unsigned char
19096 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19097 @end smallexample
19099 The @code{vec_slv} and @code{vec_srv} functions operate on
19100 all of the bytes of their @code{src} and @code{shift_distance}
19101 arguments in parallel.  The behavior of the @code{vec_slv} is as if
19102 there existed a temporary array of 17 unsigned characters
19103 @code{slv_array} within which elements 0 through 15 are the same as
19104 the entries in the @code{src} array and element 16 equals 0.  The
19105 result returned from the @code{vec_slv} function is a
19106 @code{__vector} of 16 unsigned characters within which element
19107 @code{i} is computed using the C expression
19108 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19109 shift_distance[i]))},
19110 with this resulting value coerced to the @code{unsigned char} type.
19111 The behavior of the @code{vec_srv} is as if
19112 there existed a temporary array of 17 unsigned characters
19113 @code{srv_array} within which element 0 equals zero and
19114 elements 1 through 16 equal the elements 0 through 15 of
19115 the @code{src} array.  The
19116 result returned from the @code{vec_srv} function is a
19117 @code{__vector} of 16 unsigned characters within which element
19118 @code{i} is computed using the C expression
19119 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19120 (0x07 & shift_distance[i]))},
19121 with this resulting value coerced to the @code{unsigned char} type.
19123 The following built-in functions are available for the PowerPC family
19124 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19125 @smallexample
19126 __vector unsigned char
19127 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19128 __vector unsigned short
19129 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19130 __vector unsigned int
19131 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19133 __vector unsigned char
19134 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19135 __vector unsigned short
19136 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19137 __vector unsigned int
19138 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19139 @end smallexample
19141 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19142 @code{vec_absdw} built-in functions each computes the absolute
19143 differences of the pairs of vector elements supplied in its two vector
19144 arguments, placing the absolute differences into the corresponding
19145 elements of the vector result.
19147 The following built-in functions are available for the PowerPC family
19148 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19149 @smallexample
19150 __vector unsigned int vec_extract_exp (__vector float source);
19151 __vector unsigned long long int vec_extract_exp (__vector double source);
19153 __vector unsigned int vec_extract_sig (__vector float source);
19154 __vector unsigned long long int vec_extract_sig (__vector double source);
19156 __vector float vec_insert_exp (__vector unsigned int significands,
19157                                __vector unsigned int exponents);
19158 __vector float vec_insert_exp (__vector unsigned float significands,
19159                                __vector unsigned int exponents);
19160 __vector double vec_insert_exp (__vector unsigned long long int significands,
19161                                 __vector unsigned long long int exponents);
19162 __vector double vec_insert_exp (__vector unsigned double significands,
19163                                 __vector unsigned long long int exponents);
19165 __vector bool int vec_test_data_class (__vector float source, const int condition);
19166 __vector bool long long int vec_test_data_class (__vector double source,
19167                                                  const int condition);
19168 @end smallexample
19170 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19171 functions return vectors representing the significands and biased
19172 exponent values of their @code{source} arguments respectively.
19173 Within the result vector returned by @code{vec_extract_sig}, the
19174 @code{0x800000} bit of each vector element returned when the
19175 function's @code{source} argument is of type @code{float} is set to 1
19176 if the corresponding floating point value is in normalized form.
19177 Otherwise, this bit is set to 0.  When the @code{source} argument is
19178 of type @code{double}, the @code{0x10000000000000} bit within each of
19179 the result vector's elements is set according to the same rules.
19180 Note that the sign of the significand is not represented in the result
19181 returned from the @code{vec_extract_sig} function.  To extract the
19182 sign bits, use the
19183 @code{vec_cpsgn} function, which returns a new vector within which all
19184 of the sign bits of its second argument vector are overwritten with the
19185 sign bits copied from the coresponding elements of its first argument
19186 vector, and all other (non-sign) bits of the second argument vector
19187 are copied unchanged into the result vector.
19189 The @code{vec_insert_exp} built-in functions return a vector of
19190 single- or double-precision floating
19191 point values constructed by assembling the values of their
19192 @code{significands} and @code{exponents} arguments into the
19193 corresponding elements of the returned vector.
19194 The sign of each
19195 element of the result is copied from the most significant bit of the
19196 corresponding entry within the @code{significands} argument.
19197 Note that the relevant
19198 bits of the @code{significands} argument are the same, for both integer
19199 and floating point types.
19201 significand and exponent components of each element of the result are
19202 composed of the least significant bits of the corresponding
19203 @code{significands} element and the least significant bits of the
19204 corresponding @code{exponents} element.
19206 The @code{vec_test_data_class} built-in function returns a vector
19207 representing the results of testing the @code{source} vector for the
19208 condition selected by the @code{condition} argument.  The
19209 @code{condition} argument must be a compile-time constant integer with
19210 value not exceeding 127.  The
19211 @code{condition} argument is encoded as a bitmask with each bit
19212 enabling the testing of a different condition, as characterized by the
19213 following:
19214 @smallexample
19215 0x40    Test for NaN
19216 0x20    Test for +Infinity
19217 0x10    Test for -Infinity
19218 0x08    Test for +Zero
19219 0x04    Test for -Zero
19220 0x02    Test for +Denormal
19221 0x01    Test for -Denormal
19222 @end smallexample
19224 If any of the enabled test conditions is true, the corresponding entry
19225 in the result vector is -1.  Otherwise (all of the enabled test
19226 conditions are false), the corresponding entry of the result vector is 0.
19228 The following built-in functions are available for the PowerPC family
19229 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19230 @smallexample
19231 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19232                               vector unsigned int);
19233 vector unsigned long long vec_rlmi (vector unsigned long long,
19234                                     vector unsigned long long,
19235                                     vector unsigned long long);
19236 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19237                               vector unsigned int);
19238 vector unsigned long long vec_rlnm (vector unsigned long long,
19239                                     vector unsigned long long,
19240                                     vector unsigned long long);
19241 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19242 vector unsigned long long vec_vrlnm (vector unsigned long long,
19243                                      vector unsigned long long);
19244 @end smallexample
19246 The result of @code{vec_rlmi} is obtained by rotating each element of
19247 the first argument vector left and inserting it under mask into the
19248 second argument vector.  The third argument vector contains the mask
19249 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19250 count in bits 27:31, of each element.
19252 The result of @code{vec_rlnm} is obtained by rotating each element of
19253 the first argument vector left and ANDing it with a mask specified by
19254 the second and third argument vectors.  The second argument vector
19255 contains the shift count for each element in the low-order byte.  The
19256 third argument vector contains the mask end for each element in the
19257 low-order byte, with the mask begin in the next higher byte.
19259 The result of @code{vec_vrlnm} is obtained by rotating each element
19260 of the first argument vector left and ANDing it with a mask.  The
19261 second argument vector contains the mask  beginning in bits 11:15,
19262 the mask end in bits 19:23, and the shift count in bits 27:31,
19263 of each element.
19265 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19266 are available:
19267 @smallexample
19268 vector signed bool char vec_revb (vector signed char);
19269 vector signed char vec_revb (vector signed char);
19270 vector unsigned char vec_revb (vector unsigned char);
19271 vector bool short vec_revb (vector bool short);
19272 vector short vec_revb (vector short);
19273 vector unsigned short vec_revb (vector unsigned short);
19274 vector bool int vec_revb (vector bool int);
19275 vector int vec_revb (vector int);
19276 vector unsigned int vec_revb (vector unsigned int);
19277 vector float vec_revb (vector float);
19278 vector bool long long vec_revb (vector bool long long);
19279 vector long long vec_revb (vector long long);
19280 vector unsigned long long vec_revb (vector unsigned long long);
19281 vector double vec_revb (vector double);
19282 @end smallexample
19284 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19285 are available:
19286 @smallexample
19287 vector long vec_revb (vector long);
19288 vector unsigned long vec_revb (vector unsigned long);
19289 vector __int128 vec_revb (vector __int128);
19290 vector __uint128 vec_revb (vector __uint128);
19291 @end smallexample
19293 The @code{vec_revb} built-in function reverses the bytes on an element
19294 by element basis.  A vector of @code{vector unsigned char} or
19295 @code{vector signed char} reverses the bytes in the whole word.
19297 If the cryptographic instructions are enabled (@option{-mcrypto} or
19298 @option{-mcpu=power8}), the following builtins are enabled.
19300 @smallexample
19301 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19303 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19304                                                     vector unsigned long long);
19306 vector unsigned long long __builtin_crypto_vcipherlast
19307                                      (vector unsigned long long,
19308                                       vector unsigned long long);
19310 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19311                                                      vector unsigned long long);
19313 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
19314                                                          vector unsigned long long);
19316 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19317                                                 vector unsigned char,
19318                                                 vector unsigned char);
19320 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19321                                                  vector unsigned short,
19322                                                  vector unsigned short);
19324 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19325                                                vector unsigned int,
19326                                                vector unsigned int);
19328 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19329                                                      vector unsigned long long,
19330                                                      vector unsigned long long);
19332 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19333                                                vector unsigned char);
19335 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19336                                                 vector unsigned short);
19338 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19339                                               vector unsigned int);
19341 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19342                                                     vector unsigned long long);
19344 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
19345                                                        int, int);
19347 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
19348 @end smallexample
19350 The second argument to @var{__builtin_crypto_vshasigmad} and
19351 @var{__builtin_crypto_vshasigmaw} must be a constant
19352 integer that is 0 or 1.  The third argument to these built-in functions
19353 must be a constant integer in the range of 0 to 15.
19355 If the ISA 3.0 instruction set additions 
19356 are enabled (@option{-mcpu=power9}), the following additional
19357 functions are available for both 32-bit and 64-bit targets.
19358 @smallexample
19359 vector short vec_xl (int, vector short *);
19360 vector short vec_xl (int, short *);
19361 vector unsigned short vec_xl (int, vector unsigned short *);
19362 vector unsigned short vec_xl (int, unsigned short *);
19363 vector char vec_xl (int, vector char *);
19364 vector char vec_xl (int, char *);
19365 vector unsigned char vec_xl (int, vector unsigned char *);
19366 vector unsigned char vec_xl (int, unsigned char *);
19368 void vec_xst (vector short, int, vector short *);
19369 void vec_xst (vector short, int, short *);
19370 void vec_xst (vector unsigned short, int, vector unsigned short *);
19371 void vec_xst (vector unsigned short, int, unsigned short *);
19372 void vec_xst (vector char, int, vector char *);
19373 void vec_xst (vector char, int, char *);
19374 void vec_xst (vector unsigned char, int, vector unsigned char *);
19375 void vec_xst (vector unsigned char, int, unsigned char *);
19376 @end smallexample
19377 @node PowerPC Hardware Transactional Memory Built-in Functions
19378 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19379 GCC provides two interfaces for accessing the Hardware Transactional
19380 Memory (HTM) instructions available on some of the PowerPC family
19381 of processors (eg, POWER8).  The two interfaces come in a low level
19382 interface, consisting of built-in functions specific to PowerPC and a
19383 higher level interface consisting of inline functions that are common
19384 between PowerPC and S/390.
19386 @subsubsection PowerPC HTM Low Level Built-in Functions
19388 The following low level built-in functions are available with
19389 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19390 They all generate the machine instruction that is part of the name.
19392 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19393 the full 4-bit condition register value set by their associated hardware
19394 instruction.  The header file @code{htmintrin.h} defines some macros that can
19395 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
19396 returns a simple true or false value depending on whether a transaction was
19397 successfully started or not.  The arguments of the builtins match exactly the
19398 type and order of the associated hardware instruction's operands, except for
19399 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19400 Refer to the ISA manual for a description of each instruction's operands.
19402 @smallexample
19403 unsigned int __builtin_tbegin (unsigned int)
19404 unsigned int __builtin_tend (unsigned int)
19406 unsigned int __builtin_tabort (unsigned int)
19407 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19408 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19409 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19410 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19412 unsigned int __builtin_tcheck (void)
19413 unsigned int __builtin_treclaim (unsigned int)
19414 unsigned int __builtin_trechkpt (void)
19415 unsigned int __builtin_tsr (unsigned int)
19416 @end smallexample
19418 In addition to the above HTM built-ins, we have added built-ins for
19419 some common extended mnemonics of the HTM instructions:
19421 @smallexample
19422 unsigned int __builtin_tendall (void)
19423 unsigned int __builtin_tresume (void)
19424 unsigned int __builtin_tsuspend (void)
19425 @end smallexample
19427 Note that the semantics of the above HTM builtins are required to mimic
19428 the locking semantics used for critical sections.  Builtins that are used
19429 to create a new transaction or restart a suspended transaction must have
19430 lock acquisition like semantics while those builtins that end or suspend a
19431 transaction must have lock release like semantics.  Specifically, this must
19432 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19433 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19434 that returns 0, and lock release is as-if an execution of
19435 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19436 implicit implementation-defined lock used for all transactions.  The HTM
19437 instructions associated with with the builtins inherently provide the
19438 correct acquisition and release hardware barriers required.  However,
19439 the compiler must also be prohibited from moving loads and stores across
19440 the builtins in a way that would violate their semantics.  This has been
19441 accomplished by adding memory barriers to the associated HTM instructions
19442 (which is a conservative approach to provide acquire and release semantics).
19443 Earlier versions of the compiler did not treat the HTM instructions as
19444 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19445 be used to determine whether the current compiler treats HTM instructions
19446 as memory barriers or not.  This allows the user to explicitly add memory
19447 barriers to their code when using an older version of the compiler.
19449 The following set of built-in functions are available to gain access
19450 to the HTM specific special purpose registers.
19452 @smallexample
19453 unsigned long __builtin_get_texasr (void)
19454 unsigned long __builtin_get_texasru (void)
19455 unsigned long __builtin_get_tfhar (void)
19456 unsigned long __builtin_get_tfiar (void)
19458 void __builtin_set_texasr (unsigned long);
19459 void __builtin_set_texasru (unsigned long);
19460 void __builtin_set_tfhar (unsigned long);
19461 void __builtin_set_tfiar (unsigned long);
19462 @end smallexample
19464 Example usage of these low level built-in functions may look like:
19466 @smallexample
19467 #include <htmintrin.h>
19469 int num_retries = 10;
19471 while (1)
19472   @{
19473     if (__builtin_tbegin (0))
19474       @{
19475         /* Transaction State Initiated.  */
19476         if (is_locked (lock))
19477           __builtin_tabort (0);
19478         ... transaction code...
19479         __builtin_tend (0);
19480         break;
19481       @}
19482     else
19483       @{
19484         /* Transaction State Failed.  Use locks if the transaction
19485            failure is "persistent" or we've tried too many times.  */
19486         if (num_retries-- <= 0
19487             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19488           @{
19489             acquire_lock (lock);
19490             ... non transactional fallback path...
19491             release_lock (lock);
19492             break;
19493           @}
19494       @}
19495   @}
19496 @end smallexample
19498 One final built-in function has been added that returns the value of
19499 the 2-bit Transaction State field of the Machine Status Register (MSR)
19500 as stored in @code{CR0}.
19502 @smallexample
19503 unsigned long __builtin_ttest (void)
19504 @end smallexample
19506 This built-in can be used to determine the current transaction state
19507 using the following code example:
19509 @smallexample
19510 #include <htmintrin.h>
19512 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19514 if (tx_state == _HTM_TRANSACTIONAL)
19515   @{
19516     /* Code to use in transactional state.  */
19517   @}
19518 else if (tx_state == _HTM_NONTRANSACTIONAL)
19519   @{
19520     /* Code to use in non-transactional state.  */
19521   @}
19522 else if (tx_state == _HTM_SUSPENDED)
19523   @{
19524     /* Code to use in transaction suspended state.  */
19525   @}
19526 @end smallexample
19528 @subsubsection PowerPC HTM High Level Inline Functions
19530 The following high level HTM interface is made available by including
19531 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19532 where CPU is `power8' or later.  This interface is common between PowerPC
19533 and S/390, allowing users to write one HTM source implementation that
19534 can be compiled and executed on either system.
19536 @smallexample
19537 long __TM_simple_begin (void)
19538 long __TM_begin (void* const TM_buff)
19539 long __TM_end (void)
19540 void __TM_abort (void)
19541 void __TM_named_abort (unsigned char const code)
19542 void __TM_resume (void)
19543 void __TM_suspend (void)
19545 long __TM_is_user_abort (void* const TM_buff)
19546 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19547 long __TM_is_illegal (void* const TM_buff)
19548 long __TM_is_footprint_exceeded (void* const TM_buff)
19549 long __TM_nesting_depth (void* const TM_buff)
19550 long __TM_is_nested_too_deep(void* const TM_buff)
19551 long __TM_is_conflict(void* const TM_buff)
19552 long __TM_is_failure_persistent(void* const TM_buff)
19553 long __TM_failure_address(void* const TM_buff)
19554 long long __TM_failure_code(void* const TM_buff)
19555 @end smallexample
19557 Using these common set of HTM inline functions, we can create
19558 a more portable version of the HTM example in the previous
19559 section that will work on either PowerPC or S/390:
19561 @smallexample
19562 #include <htmxlintrin.h>
19564 int num_retries = 10;
19565 TM_buff_type TM_buff;
19567 while (1)
19568   @{
19569     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19570       @{
19571         /* Transaction State Initiated.  */
19572         if (is_locked (lock))
19573           __TM_abort ();
19574         ... transaction code...
19575         __TM_end ();
19576         break;
19577       @}
19578     else
19579       @{
19580         /* Transaction State Failed.  Use locks if the transaction
19581            failure is "persistent" or we've tried too many times.  */
19582         if (num_retries-- <= 0
19583             || __TM_is_failure_persistent (TM_buff))
19584           @{
19585             acquire_lock (lock);
19586             ... non transactional fallback path...
19587             release_lock (lock);
19588             break;
19589           @}
19590       @}
19591   @}
19592 @end smallexample
19594 @node PowerPC Atomic Memory Operation Functions
19595 @subsection PowerPC Atomic Memory Operation Functions
19596 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19597 instructions.  GCC provides support for these instructions in 64-bit
19598 environments.  All of the functions are declared in the include file
19599 @code{amo.h}.
19601 The functions supported are:
19603 @smallexample
19604 #include <amo.h>
19606 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19607 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19608 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19609 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19610 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19611 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19612 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19614 int32_t amo_lwat_sadd (int32_t *, int32_t);
19615 int32_t amo_lwat_smax (int32_t *, int32_t);
19616 int32_t amo_lwat_smin (int32_t *, int32_t);
19617 int32_t amo_lwat_sswap (int32_t *, int32_t);
19619 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19620 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19621 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19622 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19623 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19624 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19625 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19627 int64_t amo_ldat_sadd (int64_t *, int64_t);
19628 int64_t amo_ldat_smax (int64_t *, int64_t);
19629 int64_t amo_ldat_smin (int64_t *, int64_t);
19630 int64_t amo_ldat_sswap (int64_t *, int64_t);
19632 void amo_stwat_add (uint32_t *, uint32_t);
19633 void amo_stwat_xor (uint32_t *, uint32_t);
19634 void amo_stwat_ior (uint32_t *, uint32_t);
19635 void amo_stwat_and (uint32_t *, uint32_t);
19636 void amo_stwat_umax (uint32_t *, uint32_t);
19637 void amo_stwat_umin (uint32_t *, uint32_t);
19639 void amo_stwat_sadd (int32_t *, int32_t);
19640 void amo_stwat_smax (int32_t *, int32_t);
19641 void amo_stwat_smin (int32_t *, int32_t);
19643 void amo_stdat_add (uint64_t *, uint64_t);
19644 void amo_stdat_xor (uint64_t *, uint64_t);
19645 void amo_stdat_ior (uint64_t *, uint64_t);
19646 void amo_stdat_and (uint64_t *, uint64_t);
19647 void amo_stdat_umax (uint64_t *, uint64_t);
19648 void amo_stdat_umin (uint64_t *, uint64_t);
19650 void amo_stdat_sadd (int64_t *, int64_t);
19651 void amo_stdat_smax (int64_t *, int64_t);
19652 void amo_stdat_smin (int64_t *, int64_t);
19653 @end smallexample
19655 @node RX Built-in Functions
19656 @subsection RX Built-in Functions
19657 GCC supports some of the RX instructions which cannot be expressed in
19658 the C programming language via the use of built-in functions.  The
19659 following functions are supported:
19661 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19662 Generates the @code{brk} machine instruction.
19663 @end deftypefn
19665 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19666 Generates the @code{clrpsw} machine instruction to clear the specified
19667 bit in the processor status word.
19668 @end deftypefn
19670 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19671 Generates the @code{int} machine instruction to generate an interrupt
19672 with the specified value.
19673 @end deftypefn
19675 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19676 Generates the @code{machi} machine instruction to add the result of
19677 multiplying the top 16 bits of the two arguments into the
19678 accumulator.
19679 @end deftypefn
19681 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19682 Generates the @code{maclo} machine instruction to add the result of
19683 multiplying the bottom 16 bits of the two arguments into the
19684 accumulator.
19685 @end deftypefn
19687 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19688 Generates the @code{mulhi} machine instruction to place the result of
19689 multiplying the top 16 bits of the two arguments into the
19690 accumulator.
19691 @end deftypefn
19693 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19694 Generates the @code{mullo} machine instruction to place the result of
19695 multiplying the bottom 16 bits of the two arguments into the
19696 accumulator.
19697 @end deftypefn
19699 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19700 Generates the @code{mvfachi} machine instruction to read the top
19701 32 bits of the accumulator.
19702 @end deftypefn
19704 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19705 Generates the @code{mvfacmi} machine instruction to read the middle
19706 32 bits of the accumulator.
19707 @end deftypefn
19709 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19710 Generates the @code{mvfc} machine instruction which reads the control
19711 register specified in its argument and returns its value.
19712 @end deftypefn
19714 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19715 Generates the @code{mvtachi} machine instruction to set the top
19716 32 bits of the accumulator.
19717 @end deftypefn
19719 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19720 Generates the @code{mvtaclo} machine instruction to set the bottom
19721 32 bits of the accumulator.
19722 @end deftypefn
19724 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19725 Generates the @code{mvtc} machine instruction which sets control
19726 register number @code{reg} to @code{val}.
19727 @end deftypefn
19729 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19730 Generates the @code{mvtipl} machine instruction set the interrupt
19731 priority level.
19732 @end deftypefn
19734 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19735 Generates the @code{racw} machine instruction to round the accumulator
19736 according to the specified mode.
19737 @end deftypefn
19739 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19740 Generates the @code{revw} machine instruction which swaps the bytes in
19741 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19742 and also bits 16--23 occupy bits 24--31 and vice versa.
19743 @end deftypefn
19745 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19746 Generates the @code{rmpa} machine instruction which initiates a
19747 repeated multiply and accumulate sequence.
19748 @end deftypefn
19750 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19751 Generates the @code{round} machine instruction which returns the
19752 floating-point argument rounded according to the current rounding mode
19753 set in the floating-point status word register.
19754 @end deftypefn
19756 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19757 Generates the @code{sat} machine instruction which returns the
19758 saturated value of the argument.
19759 @end deftypefn
19761 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19762 Generates the @code{setpsw} machine instruction to set the specified
19763 bit in the processor status word.
19764 @end deftypefn
19766 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19767 Generates the @code{wait} machine instruction.
19768 @end deftypefn
19770 @node S/390 System z Built-in Functions
19771 @subsection S/390 System z Built-in Functions
19772 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19773 Generates the @code{tbegin} machine instruction starting a
19774 non-constrained hardware transaction.  If the parameter is non-NULL the
19775 memory area is used to store the transaction diagnostic buffer and
19776 will be passed as first operand to @code{tbegin}.  This buffer can be
19777 defined using the @code{struct __htm_tdb} C struct defined in
19778 @code{htmintrin.h} and must reside on a double-word boundary.  The
19779 second tbegin operand is set to @code{0xff0c}. This enables
19780 save/restore of all GPRs and disables aborts for FPR and AR
19781 manipulations inside the transaction body.  The condition code set by
19782 the tbegin instruction is returned as integer value.  The tbegin
19783 instruction by definition overwrites the content of all FPRs.  The
19784 compiler will generate code which saves and restores the FPRs.  For
19785 soft-float code it is recommended to used the @code{*_nofloat}
19786 variant.  In order to prevent a TDB from being written it is required
19787 to pass a constant zero value as parameter.  Passing a zero value
19788 through a variable is not sufficient.  Although modifications of
19789 access registers inside the transaction will not trigger an
19790 transaction abort it is not supported to actually modify them.  Access
19791 registers do not get saved when entering a transaction. They will have
19792 undefined state when reaching the abort code.
19793 @end deftypefn
19795 Macros for the possible return codes of tbegin are defined in the
19796 @code{htmintrin.h} header file:
19798 @table @code
19799 @item _HTM_TBEGIN_STARTED
19800 @code{tbegin} has been executed as part of normal processing.  The
19801 transaction body is supposed to be executed.
19802 @item _HTM_TBEGIN_INDETERMINATE
19803 The transaction was aborted due to an indeterminate condition which
19804 might be persistent.
19805 @item _HTM_TBEGIN_TRANSIENT
19806 The transaction aborted due to a transient failure.  The transaction
19807 should be re-executed in that case.
19808 @item _HTM_TBEGIN_PERSISTENT
19809 The transaction aborted due to a persistent failure.  Re-execution
19810 under same circumstances will not be productive.
19811 @end table
19813 @defmac _HTM_FIRST_USER_ABORT_CODE
19814 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19815 specifies the first abort code which can be used for
19816 @code{__builtin_tabort}.  Values below this threshold are reserved for
19817 machine use.
19818 @end defmac
19820 @deftp {Data type} {struct __htm_tdb}
19821 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19822 the structure of the transaction diagnostic block as specified in the
19823 Principles of Operation manual chapter 5-91.
19824 @end deftp
19826 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19827 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19828 Using this variant in code making use of FPRs will leave the FPRs in
19829 undefined state when entering the transaction abort handler code.
19830 @end deftypefn
19832 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19833 In addition to @code{__builtin_tbegin} a loop for transient failures
19834 is generated.  If tbegin returns a condition code of 2 the transaction
19835 will be retried as often as specified in the second argument.  The
19836 perform processor assist instruction is used to tell the CPU about the
19837 number of fails so far.
19838 @end deftypefn
19840 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19841 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19842 restores.  Using this variant in code making use of FPRs will leave
19843 the FPRs in undefined state when entering the transaction abort
19844 handler code.
19845 @end deftypefn
19847 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19848 Generates the @code{tbeginc} machine instruction starting a constrained
19849 hardware transaction.  The second operand is set to @code{0xff08}.
19850 @end deftypefn
19852 @deftypefn {Built-in Function} int __builtin_tend (void)
19853 Generates the @code{tend} machine instruction finishing a transaction
19854 and making the changes visible to other threads.  The condition code
19855 generated by tend is returned as integer value.
19856 @end deftypefn
19858 @deftypefn {Built-in Function} void __builtin_tabort (int)
19859 Generates the @code{tabort} machine instruction with the specified
19860 abort code.  Abort codes from 0 through 255 are reserved and will
19861 result in an error message.
19862 @end deftypefn
19864 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19865 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19866 integer parameter is loaded into rX and a value of zero is loaded into
19867 rY.  The integer parameter specifies the number of times the
19868 transaction repeatedly aborted.
19869 @end deftypefn
19871 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19872 Generates the @code{etnd} machine instruction.  The current nesting
19873 depth is returned as integer value.  For a nesting depth of 0 the code
19874 is not executed as part of an transaction.
19875 @end deftypefn
19877 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19879 Generates the @code{ntstg} machine instruction.  The second argument
19880 is written to the first arguments location.  The store operation will
19881 not be rolled-back in case of an transaction abort.
19882 @end deftypefn
19884 @node SH Built-in Functions
19885 @subsection SH Built-in Functions
19886 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19887 families of processors:
19889 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19890 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
19891 used by system code that manages threads and execution contexts.  The compiler
19892 normally does not generate code that modifies the contents of @samp{GBR} and
19893 thus the value is preserved across function calls.  Changing the @samp{GBR}
19894 value in user code must be done with caution, since the compiler might use
19895 @samp{GBR} in order to access thread local variables.
19897 @end deftypefn
19899 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19900 Returns the value that is currently set in the @samp{GBR} register.
19901 Memory loads and stores that use the thread pointer as a base address are
19902 turned into @samp{GBR} based displacement loads and stores, if possible.
19903 For example:
19904 @smallexample
19905 struct my_tcb
19907    int a, b, c, d, e;
19910 int get_tcb_value (void)
19912   // Generate @samp{mov.l @@(8,gbr),r0} instruction
19913   return ((my_tcb*)__builtin_thread_pointer ())->c;
19916 @end smallexample
19917 @end deftypefn
19919 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19920 Returns the value that is currently set in the @samp{FPSCR} register.
19921 @end deftypefn
19923 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19924 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19925 preserving the current values of the FR, SZ and PR bits.
19926 @end deftypefn
19928 @node SPARC VIS Built-in Functions
19929 @subsection SPARC VIS Built-in Functions
19931 GCC supports SIMD operations on the SPARC using both the generic vector
19932 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19933 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
19934 switch, the VIS extension is exposed as the following built-in functions:
19936 @smallexample
19937 typedef int v1si __attribute__ ((vector_size (4)));
19938 typedef int v2si __attribute__ ((vector_size (8)));
19939 typedef short v4hi __attribute__ ((vector_size (8)));
19940 typedef short v2hi __attribute__ ((vector_size (4)));
19941 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19942 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19944 void __builtin_vis_write_gsr (int64_t);
19945 int64_t __builtin_vis_read_gsr (void);
19947 void * __builtin_vis_alignaddr (void *, long);
19948 void * __builtin_vis_alignaddrl (void *, long);
19949 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19950 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19951 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19952 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19954 v4hi __builtin_vis_fexpand (v4qi);
19956 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19957 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19958 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19959 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19960 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19961 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19962 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19964 v4qi __builtin_vis_fpack16 (v4hi);
19965 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19966 v2hi __builtin_vis_fpackfix (v2si);
19967 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19969 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19971 long __builtin_vis_edge8 (void *, void *);
19972 long __builtin_vis_edge8l (void *, void *);
19973 long __builtin_vis_edge16 (void *, void *);
19974 long __builtin_vis_edge16l (void *, void *);
19975 long __builtin_vis_edge32 (void *, void *);
19976 long __builtin_vis_edge32l (void *, void *);
19978 long __builtin_vis_fcmple16 (v4hi, v4hi);
19979 long __builtin_vis_fcmple32 (v2si, v2si);
19980 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19981 long __builtin_vis_fcmpne32 (v2si, v2si);
19982 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19983 long __builtin_vis_fcmpgt32 (v2si, v2si);
19984 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19985 long __builtin_vis_fcmpeq32 (v2si, v2si);
19987 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19988 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19989 v2si __builtin_vis_fpadd32 (v2si, v2si);
19990 v1si __builtin_vis_fpadd32s (v1si, v1si);
19991 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19992 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19993 v2si __builtin_vis_fpsub32 (v2si, v2si);
19994 v1si __builtin_vis_fpsub32s (v1si, v1si);
19996 long __builtin_vis_array8 (long, long);
19997 long __builtin_vis_array16 (long, long);
19998 long __builtin_vis_array32 (long, long);
19999 @end smallexample
20001 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20002 functions also become available:
20004 @smallexample
20005 long __builtin_vis_bmask (long, long);
20006 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20007 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20008 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20009 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20011 long __builtin_vis_edge8n (void *, void *);
20012 long __builtin_vis_edge8ln (void *, void *);
20013 long __builtin_vis_edge16n (void *, void *);
20014 long __builtin_vis_edge16ln (void *, void *);
20015 long __builtin_vis_edge32n (void *, void *);
20016 long __builtin_vis_edge32ln (void *, void *);
20017 @end smallexample
20019 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20020 functions also become available:
20022 @smallexample
20023 void __builtin_vis_cmask8 (long);
20024 void __builtin_vis_cmask16 (long);
20025 void __builtin_vis_cmask32 (long);
20027 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20029 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20030 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20031 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20032 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20033 v2si __builtin_vis_fsll16 (v2si, v2si);
20034 v2si __builtin_vis_fslas16 (v2si, v2si);
20035 v2si __builtin_vis_fsrl16 (v2si, v2si);
20036 v2si __builtin_vis_fsra16 (v2si, v2si);
20038 long __builtin_vis_pdistn (v8qi, v8qi);
20040 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20042 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20043 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20045 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20046 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20047 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20048 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20049 v2si __builtin_vis_fpadds32 (v2si, v2si);
20050 v1si __builtin_vis_fpadds32s (v1si, v1si);
20051 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20052 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20054 long __builtin_vis_fucmple8 (v8qi, v8qi);
20055 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20056 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20057 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20059 float __builtin_vis_fhadds (float, float);
20060 double __builtin_vis_fhaddd (double, double);
20061 float __builtin_vis_fhsubs (float, float);
20062 double __builtin_vis_fhsubd (double, double);
20063 float __builtin_vis_fnhadds (float, float);
20064 double __builtin_vis_fnhaddd (double, double);
20066 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20067 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20068 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20069 @end smallexample
20071 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20072 functions also become available:
20074 @smallexample
20075 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20076 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20077 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20078 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20080 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20081 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20082 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20083 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20085 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20086 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20087 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20088 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20089 long __builtin_vis_fpcmpule32 (v2si, v2si);
20090 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20092 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20093 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20094 v2si __builtin_vis_fpmax32 (v2si, v2si);
20096 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20097 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20098 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20101 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20102 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20103 v2si __builtin_vis_fpmin32 (v2si, v2si);
20105 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20106 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20107 v2si __builtin_vis_fpminu32 (v2si, v2si);
20108 @end smallexample
20110 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20111 built-in functions also become available:
20113 @smallexample
20114 v8qi __builtin_vis_dictunpack8 (double, int);
20115 v4hi __builtin_vis_dictunpack16 (double, int);
20116 v2si __builtin_vis_dictunpack32 (double, int);
20118 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20119 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20120 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20121 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20123 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20124 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20125 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20126 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20128 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20129 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20130 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20131 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20133 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20134 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20135 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20136 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20137 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20138 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20140 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20141 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20142 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20144 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20145 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20146 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20147 @end smallexample
20149 @node SPU Built-in Functions
20150 @subsection SPU Built-in Functions
20152 GCC provides extensions for the SPU processor as described in the
20153 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
20154 implementation differs in several ways.
20156 @itemize @bullet
20158 @item
20159 The optional extension of specifying vector constants in parentheses is
20160 not supported.
20162 @item
20163 A vector initializer requires no cast if the vector constant is of the
20164 same type as the variable it is initializing.
20166 @item
20167 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20168 vector type is the default signedness of the base type.  The default
20169 varies depending on the operating system, so a portable program should
20170 always specify the signedness.
20172 @item
20173 By default, the keyword @code{__vector} is added. The macro
20174 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20175 undefined.
20177 @item
20178 GCC allows using a @code{typedef} name as the type specifier for a
20179 vector type.
20181 @item
20182 For C, overloaded functions are implemented with macros so the following
20183 does not work:
20185 @smallexample
20186   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20187 @end smallexample
20189 @noindent
20190 Since @code{spu_add} is a macro, the vector constant in the example
20191 is treated as four separate arguments.  Wrap the entire argument in
20192 parentheses for this to work.
20194 @item
20195 The extended version of @code{__builtin_expect} is not supported.
20197 @end itemize
20199 @emph{Note:} Only the interface described in the aforementioned
20200 specification is supported. Internally, GCC uses built-in functions to
20201 implement the required functionality, but these are not supported and
20202 are subject to change without notice.
20204 @node TI C6X Built-in Functions
20205 @subsection TI C6X Built-in Functions
20207 GCC provides intrinsics to access certain instructions of the TI C6X
20208 processors.  These intrinsics, listed below, are available after
20209 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
20210 to C6X instructions.
20212 @smallexample
20214 int _sadd (int, int)
20215 int _ssub (int, int)
20216 int _sadd2 (int, int)
20217 int _ssub2 (int, int)
20218 long long _mpy2 (int, int)
20219 long long _smpy2 (int, int)
20220 int _add4 (int, int)
20221 int _sub4 (int, int)
20222 int _saddu4 (int, int)
20224 int _smpy (int, int)
20225 int _smpyh (int, int)
20226 int _smpyhl (int, int)
20227 int _smpylh (int, int)
20229 int _sshl (int, int)
20230 int _subc (int, int)
20232 int _avg2 (int, int)
20233 int _avgu4 (int, int)
20235 int _clrr (int, int)
20236 int _extr (int, int)
20237 int _extru (int, int)
20238 int _abs (int)
20239 int _abs2 (int)
20241 @end smallexample
20243 @node TILE-Gx Built-in Functions
20244 @subsection TILE-Gx Built-in Functions
20246 GCC provides intrinsics to access every instruction of the TILE-Gx
20247 processor.  The intrinsics are of the form:
20249 @smallexample
20251 unsigned long long __insn_@var{op} (...)
20253 @end smallexample
20255 Where @var{op} is the name of the instruction.  Refer to the ISA manual
20256 for the complete list of instructions.
20258 GCC also provides intrinsics to directly access the network registers.
20259 The intrinsics are:
20261 @smallexample
20263 unsigned long long __tile_idn0_receive (void)
20264 unsigned long long __tile_idn1_receive (void)
20265 unsigned long long __tile_udn0_receive (void)
20266 unsigned long long __tile_udn1_receive (void)
20267 unsigned long long __tile_udn2_receive (void)
20268 unsigned long long __tile_udn3_receive (void)
20269 void __tile_idn_send (unsigned long long)
20270 void __tile_udn_send (unsigned long long)
20272 @end smallexample
20274 The intrinsic @code{void __tile_network_barrier (void)} is used to
20275 guarantee that no network operations before it are reordered with
20276 those after it.
20278 @node TILEPro Built-in Functions
20279 @subsection TILEPro Built-in Functions
20281 GCC provides intrinsics to access every instruction of the TILEPro
20282 processor.  The intrinsics are of the form:
20284 @smallexample
20286 unsigned __insn_@var{op} (...)
20288 @end smallexample
20290 @noindent
20291 where @var{op} is the name of the instruction.  Refer to the ISA manual
20292 for the complete list of instructions.
20294 GCC also provides intrinsics to directly access the network registers.
20295 The intrinsics are:
20297 @smallexample
20299 unsigned __tile_idn0_receive (void)
20300 unsigned __tile_idn1_receive (void)
20301 unsigned __tile_sn_receive (void)
20302 unsigned __tile_udn0_receive (void)
20303 unsigned __tile_udn1_receive (void)
20304 unsigned __tile_udn2_receive (void)
20305 unsigned __tile_udn3_receive (void)
20306 void __tile_idn_send (unsigned)
20307 void __tile_sn_send (unsigned)
20308 void __tile_udn_send (unsigned)
20310 @end smallexample
20312 The intrinsic @code{void __tile_network_barrier (void)} is used to
20313 guarantee that no network operations before it are reordered with
20314 those after it.
20316 @node x86 Built-in Functions
20317 @subsection x86 Built-in Functions
20319 These built-in functions are available for the x86-32 and x86-64 family
20320 of computers, depending on the command-line switches used.
20322 If you specify command-line switches such as @option{-msse},
20323 the compiler could use the extended instruction sets even if the built-ins
20324 are not used explicitly in the program.  For this reason, applications
20325 that perform run-time CPU detection must compile separate files for each
20326 supported architecture, using the appropriate flags.  In particular,
20327 the file containing the CPU detection code should be compiled without
20328 these options.
20330 The following machine modes are available for use with MMX built-in functions
20331 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20332 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20333 vector of eight 8-bit integers.  Some of the built-in functions operate on
20334 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20336 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20337 of two 32-bit floating-point values.
20339 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20340 floating-point values.  Some instructions use a vector of four 32-bit
20341 integers, these use @code{V4SI}.  Finally, some instructions operate on an
20342 entire vector register, interpreting it as a 128-bit integer, these use mode
20343 @code{TI}.
20345 The x86-32 and x86-64 family of processors use additional built-in
20346 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20347 floating point and @code{TC} 128-bit complex floating-point values.
20349 The following floating-point built-in functions are always available.  All
20350 of them implement the function that is part of the name.
20352 @smallexample
20353 __float128 __builtin_fabsq (__float128)
20354 __float128 __builtin_copysignq (__float128, __float128)
20355 @end smallexample
20357 The following built-in functions are always available.
20359 @table @code
20360 @item __float128 __builtin_infq (void)
20361 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20362 @findex __builtin_infq
20364 @item __float128 __builtin_huge_valq (void)
20365 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20366 @findex __builtin_huge_valq
20368 @item __float128 __builtin_nanq (void)
20369 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20370 @findex __builtin_nanq
20372 @item __float128 __builtin_nansq (void)
20373 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20374 @findex __builtin_nansq
20375 @end table
20377 The following built-in function is always available.
20379 @table @code
20380 @item void __builtin_ia32_pause (void)
20381 Generates the @code{pause} machine instruction with a compiler memory
20382 barrier.
20383 @end table
20385 The following built-in functions are always available and can be used to
20386 check the target platform type.
20388 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20389 This function runs the CPU detection code to check the type of CPU and the
20390 features supported.  This built-in function needs to be invoked along with the built-in functions
20391 to check CPU type and features, @code{__builtin_cpu_is} and
20392 @code{__builtin_cpu_supports}, only when used in a function that is
20393 executed before any constructors are called.  The CPU detection code is
20394 automatically executed in a very high priority constructor.
20396 For example, this function has to be used in @code{ifunc} resolvers that
20397 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20398 and @code{__builtin_cpu_supports}, or in constructors on targets that
20399 don't support constructor priority.
20400 @smallexample
20402 static void (*resolve_memcpy (void)) (void)
20404   // ifunc resolvers fire before constructors, explicitly call the init
20405   // function.
20406   __builtin_cpu_init ();
20407   if (__builtin_cpu_supports ("ssse3"))
20408     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20409   else
20410     return default_memcpy;
20413 void *memcpy (void *, const void *, size_t)
20414      __attribute__ ((ifunc ("resolve_memcpy")));
20415 @end smallexample
20417 @end deftypefn
20419 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20420 This function returns a positive integer if the run-time CPU
20421 is of type @var{cpuname}
20422 and returns @code{0} otherwise. The following CPU names can be detected:
20424 @table @samp
20425 @item amd
20426 AMD CPU.
20428 @item intel
20429 Intel CPU.
20431 @item atom
20432 Intel Atom CPU.
20434 @item slm
20435 Intel Silvermont CPU.
20437 @item core2
20438 Intel Core 2 CPU.
20440 @item corei7
20441 Intel Core i7 CPU.
20443 @item nehalem
20444 Intel Core i7 Nehalem CPU.
20446 @item westmere
20447 Intel Core i7 Westmere CPU.
20449 @item sandybridge
20450 Intel Core i7 Sandy Bridge CPU.
20452 @item ivybridge
20453 Intel Core i7 Ivy Bridge CPU.
20455 @item haswell
20456 Intel Core i7 Haswell CPU.
20458 @item broadwell
20459 Intel Core i7 Broadwell CPU.
20461 @item skylake
20462 Intel Core i7 Skylake CPU.
20464 @item skylake-avx512
20465 Intel Core i7 Skylake AVX512 CPU.
20467 @item cannonlake
20468 Intel Core i7 Cannon Lake CPU.
20470 @item icelake-client
20471 Intel Core i7 Ice Lake Client CPU.
20473 @item icelake-server
20474 Intel Core i7 Ice Lake Server CPU.
20476 @item bonnell
20477 Intel Atom Bonnell CPU.
20479 @item silvermont
20480 Intel Atom Silvermont CPU.
20482 @item goldmont
20483 Intel Atom Goldmont CPU.
20485 @item goldmont-plus
20486 Intel Atom Goldmont Plus CPU.
20488 @item tremont
20489 Intel Atom Tremont CPU.
20491 @item knl
20492 Intel Knights Landing CPU.
20494 @item knm
20495 Intel Knights Mill CPU.
20497 @item amdfam10h
20498 AMD Family 10h CPU.
20500 @item barcelona
20501 AMD Family 10h Barcelona CPU.
20503 @item shanghai
20504 AMD Family 10h Shanghai CPU.
20506 @item istanbul
20507 AMD Family 10h Istanbul CPU.
20509 @item btver1
20510 AMD Family 14h CPU.
20512 @item amdfam15h
20513 AMD Family 15h CPU.
20515 @item bdver1
20516 AMD Family 15h Bulldozer version 1.
20518 @item bdver2
20519 AMD Family 15h Bulldozer version 2.
20521 @item bdver3
20522 AMD Family 15h Bulldozer version 3.
20524 @item bdver4
20525 AMD Family 15h Bulldozer version 4.
20527 @item btver2
20528 AMD Family 16h CPU.
20530 @item amdfam17h
20531 AMD Family 17h CPU.
20533 @item znver1
20534 AMD Family 17h Zen version 1.
20536 @item znver2
20537 AMD Family 17h Zen version 2.
20538 @end table
20540 Here is an example:
20541 @smallexample
20542 if (__builtin_cpu_is ("corei7"))
20543   @{
20544      do_corei7 (); // Core i7 specific implementation.
20545   @}
20546 else
20547   @{
20548      do_generic (); // Generic implementation.
20549   @}
20550 @end smallexample
20551 @end deftypefn
20553 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20554 This function returns a positive integer if the run-time CPU
20555 supports @var{feature}
20556 and returns @code{0} otherwise. The following features can be detected:
20558 @table @samp
20559 @item cmov
20560 CMOV instruction.
20561 @item mmx
20562 MMX instructions.
20563 @item popcnt
20564 POPCNT instruction.
20565 @item sse
20566 SSE instructions.
20567 @item sse2
20568 SSE2 instructions.
20569 @item sse3
20570 SSE3 instructions.
20571 @item ssse3
20572 SSSE3 instructions.
20573 @item sse4.1
20574 SSE4.1 instructions.
20575 @item sse4.2
20576 SSE4.2 instructions.
20577 @item avx
20578 AVX instructions.
20579 @item avx2
20580 AVX2 instructions.
20581 @item sse4a
20582 SSE4A instructions.
20583 @item fma4
20584 FMA4 instructions.
20585 @item xop
20586 XOP instructions.
20587 @item fma
20588 FMA instructions.
20589 @item avx512f
20590 AVX512F instructions.
20591 @item bmi
20592 BMI instructions.
20593 @item bmi2
20594 BMI2 instructions.
20595 @item aes
20596 AES instructions.
20597 @item pclmul
20598 PCLMUL instructions.
20599 @item avx512vl
20600 AVX512VL instructions.
20601 @item avx512bw
20602 AVX512BW instructions.
20603 @item avx512dq
20604 AVX512DQ instructions.
20605 @item avx512cd
20606 AVX512CD instructions.
20607 @item avx512er
20608 AVX512ER instructions.
20609 @item avx512pf
20610 AVX512PF instructions.
20611 @item avx512vbmi
20612 AVX512VBMI instructions.
20613 @item avx512ifma
20614 AVX512IFMA instructions.
20615 @item avx5124vnniw
20616 AVX5124VNNIW instructions.
20617 @item avx5124fmaps
20618 AVX5124FMAPS instructions.
20619 @item avx512vpopcntdq
20620 AVX512VPOPCNTDQ instructions.
20621 @item avx512vbmi2
20622 AVX512VBMI2 instructions.
20623 @item gfni
20624 GFNI instructions.
20625 @item vpclmulqdq
20626 VPCLMULQDQ instructions.
20627 @item avx512vnni
20628 AVX512VNNI instructions.
20629 @item avx512bitalg
20630 AVX512BITALG instructions.
20631 @end table
20633 Here is an example:
20634 @smallexample
20635 if (__builtin_cpu_supports ("popcnt"))
20636   @{
20637      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20638   @}
20639 else
20640   @{
20641      count = generic_countbits (n); //generic implementation.
20642   @}
20643 @end smallexample
20644 @end deftypefn
20647 The following built-in functions are made available by @option{-mmmx}.
20648 All of them generate the machine instruction that is part of the name.
20650 @smallexample
20651 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20652 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20653 v2si __builtin_ia32_paddd (v2si, v2si)
20654 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20655 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20656 v2si __builtin_ia32_psubd (v2si, v2si)
20657 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20658 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20659 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20660 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20661 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20662 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20663 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20664 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20665 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20666 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20667 di __builtin_ia32_pand (di, di)
20668 di __builtin_ia32_pandn (di,di)
20669 di __builtin_ia32_por (di, di)
20670 di __builtin_ia32_pxor (di, di)
20671 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20672 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20673 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20674 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20675 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20676 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20677 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20678 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20679 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20680 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20681 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20682 v2si __builtin_ia32_punpckldq (v2si, v2si)
20683 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20684 v4hi __builtin_ia32_packssdw (v2si, v2si)
20685 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20687 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20688 v2si __builtin_ia32_pslld (v2si, v2si)
20689 v1di __builtin_ia32_psllq (v1di, v1di)
20690 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20691 v2si __builtin_ia32_psrld (v2si, v2si)
20692 v1di __builtin_ia32_psrlq (v1di, v1di)
20693 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20694 v2si __builtin_ia32_psrad (v2si, v2si)
20695 v4hi __builtin_ia32_psllwi (v4hi, int)
20696 v2si __builtin_ia32_pslldi (v2si, int)
20697 v1di __builtin_ia32_psllqi (v1di, int)
20698 v4hi __builtin_ia32_psrlwi (v4hi, int)
20699 v2si __builtin_ia32_psrldi (v2si, int)
20700 v1di __builtin_ia32_psrlqi (v1di, int)
20701 v4hi __builtin_ia32_psrawi (v4hi, int)
20702 v2si __builtin_ia32_psradi (v2si, int)
20704 @end smallexample
20706 The following built-in functions are made available either with
20707 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20708 the machine instruction that is part of the name.
20710 @smallexample
20711 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20712 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20713 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20714 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20715 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20716 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20717 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20718 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20719 int __builtin_ia32_pmovmskb (v8qi)
20720 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20721 void __builtin_ia32_movntq (di *, di)
20722 void __builtin_ia32_sfence (void)
20723 @end smallexample
20725 The following built-in functions are available when @option{-msse} is used.
20726 All of them generate the machine instruction that is part of the name.
20728 @smallexample
20729 int __builtin_ia32_comieq (v4sf, v4sf)
20730 int __builtin_ia32_comineq (v4sf, v4sf)
20731 int __builtin_ia32_comilt (v4sf, v4sf)
20732 int __builtin_ia32_comile (v4sf, v4sf)
20733 int __builtin_ia32_comigt (v4sf, v4sf)
20734 int __builtin_ia32_comige (v4sf, v4sf)
20735 int __builtin_ia32_ucomieq (v4sf, v4sf)
20736 int __builtin_ia32_ucomineq (v4sf, v4sf)
20737 int __builtin_ia32_ucomilt (v4sf, v4sf)
20738 int __builtin_ia32_ucomile (v4sf, v4sf)
20739 int __builtin_ia32_ucomigt (v4sf, v4sf)
20740 int __builtin_ia32_ucomige (v4sf, v4sf)
20741 v4sf __builtin_ia32_addps (v4sf, v4sf)
20742 v4sf __builtin_ia32_subps (v4sf, v4sf)
20743 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20744 v4sf __builtin_ia32_divps (v4sf, v4sf)
20745 v4sf __builtin_ia32_addss (v4sf, v4sf)
20746 v4sf __builtin_ia32_subss (v4sf, v4sf)
20747 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20748 v4sf __builtin_ia32_divss (v4sf, v4sf)
20749 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20750 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20751 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20752 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20753 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20754 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20755 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20756 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20757 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20758 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20759 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20760 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20761 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20762 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20763 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20764 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20765 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20766 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20767 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20768 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20769 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20770 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20771 v4sf __builtin_ia32_minps (v4sf, v4sf)
20772 v4sf __builtin_ia32_minss (v4sf, v4sf)
20773 v4sf __builtin_ia32_andps (v4sf, v4sf)
20774 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20775 v4sf __builtin_ia32_orps (v4sf, v4sf)
20776 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20777 v4sf __builtin_ia32_movss (v4sf, v4sf)
20778 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20779 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20780 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20781 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20782 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20783 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20784 v2si __builtin_ia32_cvtps2pi (v4sf)
20785 int __builtin_ia32_cvtss2si (v4sf)
20786 v2si __builtin_ia32_cvttps2pi (v4sf)
20787 int __builtin_ia32_cvttss2si (v4sf)
20788 v4sf __builtin_ia32_rcpps (v4sf)
20789 v4sf __builtin_ia32_rsqrtps (v4sf)
20790 v4sf __builtin_ia32_sqrtps (v4sf)
20791 v4sf __builtin_ia32_rcpss (v4sf)
20792 v4sf __builtin_ia32_rsqrtss (v4sf)
20793 v4sf __builtin_ia32_sqrtss (v4sf)
20794 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20795 void __builtin_ia32_movntps (float *, v4sf)
20796 int __builtin_ia32_movmskps (v4sf)
20797 @end smallexample
20799 The following built-in functions are available when @option{-msse} is used.
20801 @table @code
20802 @item v4sf __builtin_ia32_loadups (float *)
20803 Generates the @code{movups} machine instruction as a load from memory.
20804 @item void __builtin_ia32_storeups (float *, v4sf)
20805 Generates the @code{movups} machine instruction as a store to memory.
20806 @item v4sf __builtin_ia32_loadss (float *)
20807 Generates the @code{movss} machine instruction as a load from memory.
20808 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20809 Generates the @code{movhps} machine instruction as a load from memory.
20810 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20811 Generates the @code{movlps} machine instruction as a load from memory
20812 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20813 Generates the @code{movhps} machine instruction as a store to memory.
20814 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20815 Generates the @code{movlps} machine instruction as a store to memory.
20816 @end table
20818 The following built-in functions are available when @option{-msse2} is used.
20819 All of them generate the machine instruction that is part of the name.
20821 @smallexample
20822 int __builtin_ia32_comisdeq (v2df, v2df)
20823 int __builtin_ia32_comisdlt (v2df, v2df)
20824 int __builtin_ia32_comisdle (v2df, v2df)
20825 int __builtin_ia32_comisdgt (v2df, v2df)
20826 int __builtin_ia32_comisdge (v2df, v2df)
20827 int __builtin_ia32_comisdneq (v2df, v2df)
20828 int __builtin_ia32_ucomisdeq (v2df, v2df)
20829 int __builtin_ia32_ucomisdlt (v2df, v2df)
20830 int __builtin_ia32_ucomisdle (v2df, v2df)
20831 int __builtin_ia32_ucomisdgt (v2df, v2df)
20832 int __builtin_ia32_ucomisdge (v2df, v2df)
20833 int __builtin_ia32_ucomisdneq (v2df, v2df)
20834 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20835 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20836 v2df __builtin_ia32_cmplepd (v2df, v2df)
20837 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20838 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20839 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20840 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20841 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20842 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20843 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20844 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20845 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20846 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20847 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20848 v2df __builtin_ia32_cmplesd (v2df, v2df)
20849 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20850 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20851 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20852 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20853 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20854 v2di __builtin_ia32_paddq (v2di, v2di)
20855 v2di __builtin_ia32_psubq (v2di, v2di)
20856 v2df __builtin_ia32_addpd (v2df, v2df)
20857 v2df __builtin_ia32_subpd (v2df, v2df)
20858 v2df __builtin_ia32_mulpd (v2df, v2df)
20859 v2df __builtin_ia32_divpd (v2df, v2df)
20860 v2df __builtin_ia32_addsd (v2df, v2df)
20861 v2df __builtin_ia32_subsd (v2df, v2df)
20862 v2df __builtin_ia32_mulsd (v2df, v2df)
20863 v2df __builtin_ia32_divsd (v2df, v2df)
20864 v2df __builtin_ia32_minpd (v2df, v2df)
20865 v2df __builtin_ia32_maxpd (v2df, v2df)
20866 v2df __builtin_ia32_minsd (v2df, v2df)
20867 v2df __builtin_ia32_maxsd (v2df, v2df)
20868 v2df __builtin_ia32_andpd (v2df, v2df)
20869 v2df __builtin_ia32_andnpd (v2df, v2df)
20870 v2df __builtin_ia32_orpd (v2df, v2df)
20871 v2df __builtin_ia32_xorpd (v2df, v2df)
20872 v2df __builtin_ia32_movsd (v2df, v2df)
20873 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20874 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20875 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20876 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20877 v4si __builtin_ia32_paddd128 (v4si, v4si)
20878 v2di __builtin_ia32_paddq128 (v2di, v2di)
20879 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20880 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20881 v4si __builtin_ia32_psubd128 (v4si, v4si)
20882 v2di __builtin_ia32_psubq128 (v2di, v2di)
20883 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20884 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20885 v2di __builtin_ia32_pand128 (v2di, v2di)
20886 v2di __builtin_ia32_pandn128 (v2di, v2di)
20887 v2di __builtin_ia32_por128 (v2di, v2di)
20888 v2di __builtin_ia32_pxor128 (v2di, v2di)
20889 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20890 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20891 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20892 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20893 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20894 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20895 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20896 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20897 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20898 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20899 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20900 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20901 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20902 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20903 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20904 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20905 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20906 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20907 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20908 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20909 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20910 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20911 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20912 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20913 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20914 v2df __builtin_ia32_loadupd (double *)
20915 void __builtin_ia32_storeupd (double *, v2df)
20916 v2df __builtin_ia32_loadhpd (v2df, double const *)
20917 v2df __builtin_ia32_loadlpd (v2df, double const *)
20918 int __builtin_ia32_movmskpd (v2df)
20919 int __builtin_ia32_pmovmskb128 (v16qi)
20920 void __builtin_ia32_movnti (int *, int)
20921 void __builtin_ia32_movnti64 (long long int *, long long int)
20922 void __builtin_ia32_movntpd (double *, v2df)
20923 void __builtin_ia32_movntdq (v2df *, v2df)
20924 v4si __builtin_ia32_pshufd (v4si, int)
20925 v8hi __builtin_ia32_pshuflw (v8hi, int)
20926 v8hi __builtin_ia32_pshufhw (v8hi, int)
20927 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20928 v2df __builtin_ia32_sqrtpd (v2df)
20929 v2df __builtin_ia32_sqrtsd (v2df)
20930 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20931 v2df __builtin_ia32_cvtdq2pd (v4si)
20932 v4sf __builtin_ia32_cvtdq2ps (v4si)
20933 v4si __builtin_ia32_cvtpd2dq (v2df)
20934 v2si __builtin_ia32_cvtpd2pi (v2df)
20935 v4sf __builtin_ia32_cvtpd2ps (v2df)
20936 v4si __builtin_ia32_cvttpd2dq (v2df)
20937 v2si __builtin_ia32_cvttpd2pi (v2df)
20938 v2df __builtin_ia32_cvtpi2pd (v2si)
20939 int __builtin_ia32_cvtsd2si (v2df)
20940 int __builtin_ia32_cvttsd2si (v2df)
20941 long long __builtin_ia32_cvtsd2si64 (v2df)
20942 long long __builtin_ia32_cvttsd2si64 (v2df)
20943 v4si __builtin_ia32_cvtps2dq (v4sf)
20944 v2df __builtin_ia32_cvtps2pd (v4sf)
20945 v4si __builtin_ia32_cvttps2dq (v4sf)
20946 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20947 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20948 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20949 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20950 void __builtin_ia32_clflush (const void *)
20951 void __builtin_ia32_lfence (void)
20952 void __builtin_ia32_mfence (void)
20953 v16qi __builtin_ia32_loaddqu (const char *)
20954 void __builtin_ia32_storedqu (char *, v16qi)
20955 v1di __builtin_ia32_pmuludq (v2si, v2si)
20956 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20957 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20958 v4si __builtin_ia32_pslld128 (v4si, v4si)
20959 v2di __builtin_ia32_psllq128 (v2di, v2di)
20960 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20961 v4si __builtin_ia32_psrld128 (v4si, v4si)
20962 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20963 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20964 v4si __builtin_ia32_psrad128 (v4si, v4si)
20965 v2di __builtin_ia32_pslldqi128 (v2di, int)
20966 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20967 v4si __builtin_ia32_pslldi128 (v4si, int)
20968 v2di __builtin_ia32_psllqi128 (v2di, int)
20969 v2di __builtin_ia32_psrldqi128 (v2di, int)
20970 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20971 v4si __builtin_ia32_psrldi128 (v4si, int)
20972 v2di __builtin_ia32_psrlqi128 (v2di, int)
20973 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20974 v4si __builtin_ia32_psradi128 (v4si, int)
20975 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20976 v2di __builtin_ia32_movq128 (v2di)
20977 @end smallexample
20979 The following built-in functions are available when @option{-msse3} is used.
20980 All of them generate the machine instruction that is part of the name.
20982 @smallexample
20983 v2df __builtin_ia32_addsubpd (v2df, v2df)
20984 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20985 v2df __builtin_ia32_haddpd (v2df, v2df)
20986 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20987 v2df __builtin_ia32_hsubpd (v2df, v2df)
20988 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20989 v16qi __builtin_ia32_lddqu (char const *)
20990 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20991 v4sf __builtin_ia32_movshdup (v4sf)
20992 v4sf __builtin_ia32_movsldup (v4sf)
20993 void __builtin_ia32_mwait (unsigned int, unsigned int)
20994 @end smallexample
20996 The following built-in functions are available when @option{-mssse3} is used.
20997 All of them generate the machine instruction that is part of the name.
20999 @smallexample
21000 v2si __builtin_ia32_phaddd (v2si, v2si)
21001 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21002 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21003 v2si __builtin_ia32_phsubd (v2si, v2si)
21004 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21005 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21006 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21007 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21008 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21009 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21010 v2si __builtin_ia32_psignd (v2si, v2si)
21011 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21012 v1di __builtin_ia32_palignr (v1di, v1di, int)
21013 v8qi __builtin_ia32_pabsb (v8qi)
21014 v2si __builtin_ia32_pabsd (v2si)
21015 v4hi __builtin_ia32_pabsw (v4hi)
21016 @end smallexample
21018 The following built-in functions are available when @option{-mssse3} is used.
21019 All of them generate the machine instruction that is part of the name.
21021 @smallexample
21022 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21023 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21024 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21025 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21026 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21027 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21028 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21029 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21030 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21031 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21032 v4si __builtin_ia32_psignd128 (v4si, v4si)
21033 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21034 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21035 v16qi __builtin_ia32_pabsb128 (v16qi)
21036 v4si __builtin_ia32_pabsd128 (v4si)
21037 v8hi __builtin_ia32_pabsw128 (v8hi)
21038 @end smallexample
21040 The following built-in functions are available when @option{-msse4.1} is
21041 used.  All of them generate the machine instruction that is part of the
21042 name.
21044 @smallexample
21045 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21046 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21047 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21048 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21049 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21050 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21051 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21052 v2di __builtin_ia32_movntdqa (v2di *);
21053 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21054 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21055 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21056 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21057 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21058 v8hi __builtin_ia32_phminposuw128 (v8hi)
21059 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21060 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21061 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21062 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21063 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21064 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21065 v4si __builtin_ia32_pminud128 (v4si, v4si)
21066 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21067 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21068 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21069 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21070 v2di __builtin_ia32_pmovsxdq128 (v4si)
21071 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21072 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21073 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21074 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21075 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21076 v2di __builtin_ia32_pmovzxdq128 (v4si)
21077 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21078 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21079 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21080 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21081 int __builtin_ia32_ptestc128 (v2di, v2di)
21082 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21083 int __builtin_ia32_ptestz128 (v2di, v2di)
21084 v2df __builtin_ia32_roundpd (v2df, const int)
21085 v4sf __builtin_ia32_roundps (v4sf, const int)
21086 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21087 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21088 @end smallexample
21090 The following built-in functions are available when @option{-msse4.1} is
21091 used.
21093 @table @code
21094 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21095 Generates the @code{insertps} machine instruction.
21096 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21097 Generates the @code{pextrb} machine instruction.
21098 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21099 Generates the @code{pinsrb} machine instruction.
21100 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21101 Generates the @code{pinsrd} machine instruction.
21102 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21103 Generates the @code{pinsrq} machine instruction in 64bit mode.
21104 @end table
21106 The following built-in functions are changed to generate new SSE4.1
21107 instructions when @option{-msse4.1} is used.
21109 @table @code
21110 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
21111 Generates the @code{extractps} machine instruction.
21112 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
21113 Generates the @code{pextrd} machine instruction.
21114 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
21115 Generates the @code{pextrq} machine instruction in 64bit mode.
21116 @end table
21118 The following built-in functions are available when @option{-msse4.2} is
21119 used.  All of them generate the machine instruction that is part of the
21120 name.
21122 @smallexample
21123 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21124 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21125 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21126 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21127 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21128 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21129 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21130 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
21131 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
21132 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
21133 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
21134 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
21135 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
21136 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
21137 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
21138 @end smallexample
21140 The following built-in functions are available when @option{-msse4.2} is
21141 used.
21143 @table @code
21144 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
21145 Generates the @code{crc32b} machine instruction.
21146 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
21147 Generates the @code{crc32w} machine instruction.
21148 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
21149 Generates the @code{crc32l} machine instruction.
21150 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
21151 Generates the @code{crc32q} machine instruction.
21152 @end table
21154 The following built-in functions are changed to generate new SSE4.2
21155 instructions when @option{-msse4.2} is used.
21157 @table @code
21158 @item int __builtin_popcount (unsigned int)
21159 Generates the @code{popcntl} machine instruction.
21160 @item int __builtin_popcountl (unsigned long)
21161 Generates the @code{popcntl} or @code{popcntq} machine instruction,
21162 depending on the size of @code{unsigned long}.
21163 @item int __builtin_popcountll (unsigned long long)
21164 Generates the @code{popcntq} machine instruction.
21165 @end table
21167 The following built-in functions are available when @option{-mavx} is
21168 used. All of them generate the machine instruction that is part of the
21169 name.
21171 @smallexample
21172 v4df __builtin_ia32_addpd256 (v4df,v4df)
21173 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
21174 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
21175 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
21176 v4df __builtin_ia32_andnpd256 (v4df,v4df)
21177 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
21178 v4df __builtin_ia32_andpd256 (v4df,v4df)
21179 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
21180 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
21181 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
21182 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
21183 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
21184 v2df __builtin_ia32_cmppd (v2df,v2df,int)
21185 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
21186 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
21187 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
21188 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
21189 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
21190 v4df __builtin_ia32_cvtdq2pd256 (v4si)
21191 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
21192 v4si __builtin_ia32_cvtpd2dq256 (v4df)
21193 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
21194 v8si __builtin_ia32_cvtps2dq256 (v8sf)
21195 v4df __builtin_ia32_cvtps2pd256 (v4sf)
21196 v4si __builtin_ia32_cvttpd2dq256 (v4df)
21197 v8si __builtin_ia32_cvttps2dq256 (v8sf)
21198 v4df __builtin_ia32_divpd256 (v4df,v4df)
21199 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
21200 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
21201 v4df __builtin_ia32_haddpd256 (v4df,v4df)
21202 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
21203 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
21204 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
21205 v32qi __builtin_ia32_lddqu256 (pcchar)
21206 v32qi __builtin_ia32_loaddqu256 (pcchar)
21207 v4df __builtin_ia32_loadupd256 (pcdouble)
21208 v8sf __builtin_ia32_loadups256 (pcfloat)
21209 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
21210 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
21211 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
21212 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
21213 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
21214 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
21215 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
21216 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
21217 v4df __builtin_ia32_maxpd256 (v4df,v4df)
21218 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
21219 v4df __builtin_ia32_minpd256 (v4df,v4df)
21220 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
21221 v4df __builtin_ia32_movddup256 (v4df)
21222 int __builtin_ia32_movmskpd256 (v4df)
21223 int __builtin_ia32_movmskps256 (v8sf)
21224 v8sf __builtin_ia32_movshdup256 (v8sf)
21225 v8sf __builtin_ia32_movsldup256 (v8sf)
21226 v4df __builtin_ia32_mulpd256 (v4df,v4df)
21227 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
21228 v4df __builtin_ia32_orpd256 (v4df,v4df)
21229 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
21230 v2df __builtin_ia32_pd_pd256 (v4df)
21231 v4df __builtin_ia32_pd256_pd (v2df)
21232 v4sf __builtin_ia32_ps_ps256 (v8sf)
21233 v8sf __builtin_ia32_ps256_ps (v4sf)
21234 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21235 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21236 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21237 v8sf __builtin_ia32_rcpps256 (v8sf)
21238 v4df __builtin_ia32_roundpd256 (v4df,int)
21239 v8sf __builtin_ia32_roundps256 (v8sf,int)
21240 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21241 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21242 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21243 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21244 v4si __builtin_ia32_si_si256 (v8si)
21245 v8si __builtin_ia32_si256_si (v4si)
21246 v4df __builtin_ia32_sqrtpd256 (v4df)
21247 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21248 v8sf __builtin_ia32_sqrtps256 (v8sf)
21249 void __builtin_ia32_storedqu256 (pchar,v32qi)
21250 void __builtin_ia32_storeupd256 (pdouble,v4df)
21251 void __builtin_ia32_storeups256 (pfloat,v8sf)
21252 v4df __builtin_ia32_subpd256 (v4df,v4df)
21253 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21254 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21255 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21256 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21257 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21258 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21259 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21260 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21261 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21262 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21263 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21264 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21265 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21266 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21267 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21268 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21269 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21270 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21271 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21272 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21273 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21274 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21275 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21276 v2df __builtin_ia32_vpermilpd (v2df,int)
21277 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21278 v4sf __builtin_ia32_vpermilps (v4sf,int)
21279 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21280 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21281 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21282 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21283 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21284 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21285 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21286 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21287 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21288 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21289 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21290 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21291 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21292 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21293 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21294 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21295 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21296 void __builtin_ia32_vzeroall (void)
21297 void __builtin_ia32_vzeroupper (void)
21298 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21299 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21300 @end smallexample
21302 The following built-in functions are available when @option{-mavx2} is
21303 used. All of them generate the machine instruction that is part of the
21304 name.
21306 @smallexample
21307 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21308 v32qi __builtin_ia32_pabsb256 (v32qi)
21309 v16hi __builtin_ia32_pabsw256 (v16hi)
21310 v8si __builtin_ia32_pabsd256 (v8si)
21311 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21312 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21313 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21314 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21315 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21316 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21317 v8si __builtin_ia32_paddd256 (v8si,v8si)
21318 v4di __builtin_ia32_paddq256 (v4di,v4di)
21319 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21320 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21321 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21322 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21323 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21324 v4di __builtin_ia32_andsi256 (v4di,v4di)
21325 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21326 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21327 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21328 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21329 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21330 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21331 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21332 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21333 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21334 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21335 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21336 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21337 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21338 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21339 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21340 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21341 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21342 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21343 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21344 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21345 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21346 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21347 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21348 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21349 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21350 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21351 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21352 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21353 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21354 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21355 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21356 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21357 v8si __builtin_ia32_pminud256 (v8si,v8si)
21358 int __builtin_ia32_pmovmskb256 (v32qi)
21359 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21360 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21361 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21362 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21363 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21364 v4di __builtin_ia32_pmovsxdq256 (v4si)
21365 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21366 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21367 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21368 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21369 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21370 v4di __builtin_ia32_pmovzxdq256 (v4si)
21371 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21372 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21373 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21374 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21375 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21376 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21377 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21378 v4di __builtin_ia32_por256 (v4di,v4di)
21379 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21380 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21381 v8si __builtin_ia32_pshufd256 (v8si,int)
21382 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21383 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21384 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21385 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21386 v8si __builtin_ia32_psignd256 (v8si,v8si)
21387 v4di __builtin_ia32_pslldqi256 (v4di,int)
21388 v16hi __builtin_ia32_psllwi256 (16hi,int)
21389 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21390 v8si __builtin_ia32_pslldi256 (v8si,int)
21391 v8si __builtin_ia32_pslld256(v8si,v4si)
21392 v4di __builtin_ia32_psllqi256 (v4di,int)
21393 v4di __builtin_ia32_psllq256(v4di,v2di)
21394 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21395 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21396 v8si __builtin_ia32_psradi256 (v8si,int)
21397 v8si __builtin_ia32_psrad256 (v8si,v4si)
21398 v4di __builtin_ia32_psrldqi256 (v4di, int)
21399 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21400 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21401 v8si __builtin_ia32_psrldi256 (v8si,int)
21402 v8si __builtin_ia32_psrld256 (v8si,v4si)
21403 v4di __builtin_ia32_psrlqi256 (v4di,int)
21404 v4di __builtin_ia32_psrlq256(v4di,v2di)
21405 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21406 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21407 v8si __builtin_ia32_psubd256 (v8si,v8si)
21408 v4di __builtin_ia32_psubq256 (v4di,v4di)
21409 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21410 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21411 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21412 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21413 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21414 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21415 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21416 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21417 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21418 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21419 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21420 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21421 v4di __builtin_ia32_pxor256 (v4di,v4di)
21422 v4di __builtin_ia32_movntdqa256 (pv4di)
21423 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21424 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21425 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21426 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21427 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21428 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21429 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21430 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21431 v8si __builtin_ia32_pbroadcastd256 (v4si)
21432 v4di __builtin_ia32_pbroadcastq256 (v2di)
21433 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21434 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21435 v4si __builtin_ia32_pbroadcastd128 (v4si)
21436 v2di __builtin_ia32_pbroadcastq128 (v2di)
21437 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21438 v4df __builtin_ia32_permdf256 (v4df,int)
21439 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21440 v4di __builtin_ia32_permdi256 (v4di,int)
21441 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21442 v4di __builtin_ia32_extract128i256 (v4di,int)
21443 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21444 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21445 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21446 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21447 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21448 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21449 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21450 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21451 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21452 v8si __builtin_ia32_psllv8si (v8si,v8si)
21453 v4si __builtin_ia32_psllv4si (v4si,v4si)
21454 v4di __builtin_ia32_psllv4di (v4di,v4di)
21455 v2di __builtin_ia32_psllv2di (v2di,v2di)
21456 v8si __builtin_ia32_psrav8si (v8si,v8si)
21457 v4si __builtin_ia32_psrav4si (v4si,v4si)
21458 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21459 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21460 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21461 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21462 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21463 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21464 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21465 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21466 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21467 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21468 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21469 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21470 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21471 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21472 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21473 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21474 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21475 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21476 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21477 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21478 @end smallexample
21480 The following built-in functions are available when @option{-maes} is
21481 used.  All of them generate the machine instruction that is part of the
21482 name.
21484 @smallexample
21485 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21486 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21487 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21488 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21489 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21490 v2di __builtin_ia32_aesimc128 (v2di)
21491 @end smallexample
21493 The following built-in function is available when @option{-mpclmul} is
21494 used.
21496 @table @code
21497 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21498 Generates the @code{pclmulqdq} machine instruction.
21499 @end table
21501 The following built-in function is available when @option{-mfsgsbase} is
21502 used.  All of them generate the machine instruction that is part of the
21503 name.
21505 @smallexample
21506 unsigned int __builtin_ia32_rdfsbase32 (void)
21507 unsigned long long __builtin_ia32_rdfsbase64 (void)
21508 unsigned int __builtin_ia32_rdgsbase32 (void)
21509 unsigned long long __builtin_ia32_rdgsbase64 (void)
21510 void _writefsbase_u32 (unsigned int)
21511 void _writefsbase_u64 (unsigned long long)
21512 void _writegsbase_u32 (unsigned int)
21513 void _writegsbase_u64 (unsigned long long)
21514 @end smallexample
21516 The following built-in function is available when @option{-mrdrnd} is
21517 used.  All of them generate the machine instruction that is part of the
21518 name.
21520 @smallexample
21521 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21522 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21523 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21524 @end smallexample
21526 The following built-in function is available when @option{-mptwrite} is
21527 used.  All of them generate the machine instruction that is part of the
21528 name.
21530 @smallexample
21531 void __builtin_ia32_ptwrite32 (unsigned)
21532 void __builtin_ia32_ptwrite64 (unsigned long long)
21533 @end smallexample
21535 The following built-in functions are available when @option{-msse4a} is used.
21536 All of them generate the machine instruction that is part of the name.
21538 @smallexample
21539 void __builtin_ia32_movntsd (double *, v2df)
21540 void __builtin_ia32_movntss (float *, v4sf)
21541 v2di __builtin_ia32_extrq  (v2di, v16qi)
21542 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21543 v2di __builtin_ia32_insertq (v2di, v2di)
21544 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21545 @end smallexample
21547 The following built-in functions are available when @option{-mxop} is used.
21548 @smallexample
21549 v2df __builtin_ia32_vfrczpd (v2df)
21550 v4sf __builtin_ia32_vfrczps (v4sf)
21551 v2df __builtin_ia32_vfrczsd (v2df)
21552 v4sf __builtin_ia32_vfrczss (v4sf)
21553 v4df __builtin_ia32_vfrczpd256 (v4df)
21554 v8sf __builtin_ia32_vfrczps256 (v8sf)
21555 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21556 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21557 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21558 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21559 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21560 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21561 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21562 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21563 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21564 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21565 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21566 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21567 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21568 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21569 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21570 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21571 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21572 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21573 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21574 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21575 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21576 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21577 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21578 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21579 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21580 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21581 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21582 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21583 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21584 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21585 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21586 v4si __builtin_ia32_vpcomged (v4si, v4si)
21587 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21588 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21589 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21590 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21591 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21592 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21593 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21594 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21595 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21596 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21597 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21598 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21599 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21600 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21601 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21602 v4si __builtin_ia32_vpcomled (v4si, v4si)
21603 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21604 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21605 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21606 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21607 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21608 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21609 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21610 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21611 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21612 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21613 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21614 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21615 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21616 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21617 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21618 v4si __builtin_ia32_vpcomned (v4si, v4si)
21619 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21620 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21621 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21622 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21623 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21624 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21625 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21626 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21627 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21628 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21629 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21630 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21631 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21632 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21633 v4si __builtin_ia32_vphaddbd (v16qi)
21634 v2di __builtin_ia32_vphaddbq (v16qi)
21635 v8hi __builtin_ia32_vphaddbw (v16qi)
21636 v2di __builtin_ia32_vphadddq (v4si)
21637 v4si __builtin_ia32_vphaddubd (v16qi)
21638 v2di __builtin_ia32_vphaddubq (v16qi)
21639 v8hi __builtin_ia32_vphaddubw (v16qi)
21640 v2di __builtin_ia32_vphaddudq (v4si)
21641 v4si __builtin_ia32_vphadduwd (v8hi)
21642 v2di __builtin_ia32_vphadduwq (v8hi)
21643 v4si __builtin_ia32_vphaddwd (v8hi)
21644 v2di __builtin_ia32_vphaddwq (v8hi)
21645 v8hi __builtin_ia32_vphsubbw (v16qi)
21646 v2di __builtin_ia32_vphsubdq (v4si)
21647 v4si __builtin_ia32_vphsubwd (v8hi)
21648 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21649 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21650 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21651 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21652 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21653 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21654 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21655 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21656 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21657 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21658 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21659 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21660 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21661 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21662 v4si __builtin_ia32_vprotd (v4si, v4si)
21663 v2di __builtin_ia32_vprotq (v2di, v2di)
21664 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21665 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21666 v4si __builtin_ia32_vpshad (v4si, v4si)
21667 v2di __builtin_ia32_vpshaq (v2di, v2di)
21668 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21669 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21670 v4si __builtin_ia32_vpshld (v4si, v4si)
21671 v2di __builtin_ia32_vpshlq (v2di, v2di)
21672 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21673 @end smallexample
21675 The following built-in functions are available when @option{-mfma4} is used.
21676 All of them generate the machine instruction that is part of the name.
21678 @smallexample
21679 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21680 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21681 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21682 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21683 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21684 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21685 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21686 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21687 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21688 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21689 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21690 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21691 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21692 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21693 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21694 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21695 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21696 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21697 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21698 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21699 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21700 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21701 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21702 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21703 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21704 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21705 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21706 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21707 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21708 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21709 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21710 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21712 @end smallexample
21714 The following built-in functions are available when @option{-mlwp} is used.
21716 @smallexample
21717 void __builtin_ia32_llwpcb16 (void *);
21718 void __builtin_ia32_llwpcb32 (void *);
21719 void __builtin_ia32_llwpcb64 (void *);
21720 void * __builtin_ia32_llwpcb16 (void);
21721 void * __builtin_ia32_llwpcb32 (void);
21722 void * __builtin_ia32_llwpcb64 (void);
21723 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21724 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21725 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21726 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21727 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21728 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21729 @end smallexample
21731 The following built-in functions are available when @option{-mbmi} is used.
21732 All of them generate the machine instruction that is part of the name.
21733 @smallexample
21734 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21735 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21736 @end smallexample
21738 The following built-in functions are available when @option{-mbmi2} is used.
21739 All of them generate the machine instruction that is part of the name.
21740 @smallexample
21741 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21742 unsigned int _pdep_u32 (unsigned int, unsigned int)
21743 unsigned int _pext_u32 (unsigned int, unsigned int)
21744 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21745 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21746 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21747 @end smallexample
21749 The following built-in functions are available when @option{-mlzcnt} is used.
21750 All of them generate the machine instruction that is part of the name.
21751 @smallexample
21752 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21753 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21754 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21755 @end smallexample
21757 The following built-in functions are available when @option{-mfxsr} is used.
21758 All of them generate the machine instruction that is part of the name.
21759 @smallexample
21760 void __builtin_ia32_fxsave (void *)
21761 void __builtin_ia32_fxrstor (void *)
21762 void __builtin_ia32_fxsave64 (void *)
21763 void __builtin_ia32_fxrstor64 (void *)
21764 @end smallexample
21766 The following built-in functions are available when @option{-mxsave} is used.
21767 All of them generate the machine instruction that is part of the name.
21768 @smallexample
21769 void __builtin_ia32_xsave (void *, long long)
21770 void __builtin_ia32_xrstor (void *, long long)
21771 void __builtin_ia32_xsave64 (void *, long long)
21772 void __builtin_ia32_xrstor64 (void *, long long)
21773 @end smallexample
21775 The following built-in functions are available when @option{-mxsaveopt} is used.
21776 All of them generate the machine instruction that is part of the name.
21777 @smallexample
21778 void __builtin_ia32_xsaveopt (void *, long long)
21779 void __builtin_ia32_xsaveopt64 (void *, long long)
21780 @end smallexample
21782 The following built-in functions are available when @option{-mtbm} is used.
21783 Both of them generate the immediate form of the bextr machine instruction.
21784 @smallexample
21785 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21786                                         const unsigned int);
21787 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21788                                               const unsigned long long);
21789 @end smallexample
21792 The following built-in functions are available when @option{-m3dnow} is used.
21793 All of them generate the machine instruction that is part of the name.
21795 @smallexample
21796 void __builtin_ia32_femms (void)
21797 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21798 v2si __builtin_ia32_pf2id (v2sf)
21799 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21800 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21801 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21802 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21803 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21804 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21805 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21806 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21807 v2sf __builtin_ia32_pfrcp (v2sf)
21808 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21809 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21810 v2sf __builtin_ia32_pfrsqrt (v2sf)
21811 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21812 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21813 v2sf __builtin_ia32_pi2fd (v2si)
21814 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21815 @end smallexample
21817 The following built-in functions are available when @option{-m3dnowa} is used.
21818 All of them generate the machine instruction that is part of the name.
21820 @smallexample
21821 v2si __builtin_ia32_pf2iw (v2sf)
21822 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21823 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21824 v2sf __builtin_ia32_pi2fw (v2si)
21825 v2sf __builtin_ia32_pswapdsf (v2sf)
21826 v2si __builtin_ia32_pswapdsi (v2si)
21827 @end smallexample
21829 The following built-in functions are available when @option{-mrtm} is used
21830 They are used for restricted transactional memory. These are the internal
21831 low level functions. Normally the functions in 
21832 @ref{x86 transactional memory intrinsics} should be used instead.
21834 @smallexample
21835 int __builtin_ia32_xbegin ()
21836 void __builtin_ia32_xend ()
21837 void __builtin_ia32_xabort (status)
21838 int __builtin_ia32_xtest ()
21839 @end smallexample
21841 The following built-in functions are available when @option{-mmwaitx} is used.
21842 All of them generate the machine instruction that is part of the name.
21843 @smallexample
21844 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21845 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21846 @end smallexample
21848 The following built-in functions are available when @option{-mclzero} is used.
21849 All of them generate the machine instruction that is part of the name.
21850 @smallexample
21851 void __builtin_i32_clzero (void *)
21852 @end smallexample
21854 The following built-in functions are available when @option{-mpku} is used.
21855 They generate reads and writes to PKRU.
21856 @smallexample
21857 void __builtin_ia32_wrpkru (unsigned int)
21858 unsigned int __builtin_ia32_rdpkru ()
21859 @end smallexample
21861 The following built-in functions are available when @option{-mcet} or
21862 @option{-mshstk} option is used.  They support shadow stack
21863 machine instructions from Intel Control-flow Enforcement Technology (CET).
21864 Each built-in function generates the  machine instruction that is part
21865 of the function's name.  These are the internal low-level functions.
21866 Normally the functions in @ref{x86 control-flow protection intrinsics}
21867 should be used instead.
21869 @smallexample
21870 unsigned int __builtin_ia32_rdsspd (void)
21871 unsigned long long __builtin_ia32_rdsspq (void)
21872 void __builtin_ia32_incsspd (unsigned int)
21873 void __builtin_ia32_incsspq (unsigned long long)
21874 void __builtin_ia32_saveprevssp(void);
21875 void __builtin_ia32_rstorssp(void *);
21876 void __builtin_ia32_wrssd(unsigned int, void *);
21877 void __builtin_ia32_wrssq(unsigned long long, void *);
21878 void __builtin_ia32_wrussd(unsigned int, void *);
21879 void __builtin_ia32_wrussq(unsigned long long, void *);
21880 void __builtin_ia32_setssbsy(void);
21881 void __builtin_ia32_clrssbsy(void *);
21882 @end smallexample
21884 @node x86 transactional memory intrinsics
21885 @subsection x86 Transactional Memory Intrinsics
21887 These hardware transactional memory intrinsics for x86 allow you to use
21888 memory transactions with RTM (Restricted Transactional Memory).
21889 This support is enabled with the @option{-mrtm} option.
21890 For using HLE (Hardware Lock Elision) see 
21891 @ref{x86 specific memory model extensions for transactional memory} instead.
21893 A memory transaction commits all changes to memory in an atomic way,
21894 as visible to other threads. If the transaction fails it is rolled back
21895 and all side effects discarded.
21897 Generally there is no guarantee that a memory transaction ever succeeds
21898 and suitable fallback code always needs to be supplied.
21900 @deftypefn {RTM Function} {unsigned} _xbegin ()
21901 Start a RTM (Restricted Transactional Memory) transaction. 
21902 Returns @code{_XBEGIN_STARTED} when the transaction
21903 started successfully (note this is not 0, so the constant has to be 
21904 explicitly tested).  
21906 If the transaction aborts, all side effects
21907 are undone and an abort code encoded as a bit mask is returned.
21908 The following macros are defined:
21910 @table @code
21911 @item _XABORT_EXPLICIT
21912 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
21913 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21914 @item _XABORT_RETRY
21915 Transaction retry is possible.
21916 @item _XABORT_CONFLICT
21917 Transaction abort due to a memory conflict with another thread.
21918 @item _XABORT_CAPACITY
21919 Transaction abort due to the transaction using too much memory.
21920 @item _XABORT_DEBUG
21921 Transaction abort due to a debug trap.
21922 @item _XABORT_NESTED
21923 Transaction abort in an inner nested transaction.
21924 @end table
21926 There is no guarantee
21927 any transaction ever succeeds, so there always needs to be a valid
21928 fallback path.
21929 @end deftypefn
21931 @deftypefn {RTM Function} {void} _xend ()
21932 Commit the current transaction. When no transaction is active this faults.
21933 All memory side effects of the transaction become visible
21934 to other threads in an atomic manner.
21935 @end deftypefn
21937 @deftypefn {RTM Function} {int} _xtest ()
21938 Return a nonzero value if a transaction is currently active, otherwise 0.
21939 @end deftypefn
21941 @deftypefn {RTM Function} {void} _xabort (status)
21942 Abort the current transaction. When no transaction is active this is a no-op.
21943 The @var{status} is an 8-bit constant; its value is encoded in the return 
21944 value from @code{_xbegin}.
21945 @end deftypefn
21947 Here is an example showing handling for @code{_XABORT_RETRY}
21948 and a fallback path for other failures:
21950 @smallexample
21951 #include <immintrin.h>
21953 int n_tries, max_tries;
21954 unsigned status = _XABORT_EXPLICIT;
21957 for (n_tries = 0; n_tries < max_tries; n_tries++) 
21958   @{
21959     status = _xbegin ();
21960     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21961       break;
21962   @}
21963 if (status == _XBEGIN_STARTED) 
21964   @{
21965     ... transaction code...
21966     _xend ();
21967   @} 
21968 else 
21969   @{
21970     ... non-transactional fallback path...
21971   @}
21972 @end smallexample
21974 @noindent
21975 Note that, in most cases, the transactional and non-transactional code
21976 must synchronize together to ensure consistency.
21978 @node x86 control-flow protection intrinsics
21979 @subsection x86 Control-Flow Protection Intrinsics
21981 @deftypefn {CET Function} {ret_type} _get_ssp (void)
21982 Get the current value of shadow stack pointer if shadow stack support
21983 from Intel CET is enabled in the hardware or @code{0} otherwise.
21984 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
21985 and @code{unsigned int} for 32-bit targets.
21986 @end deftypefn
21988 @deftypefn {CET Function} void _inc_ssp (unsigned int)
21989 Increment the current shadow stack pointer by the size specified by the
21990 function argument.  The argument is masked to a byte value for security
21991 reasons, so to increment by more than 255 bytes you must call the function
21992 multiple times.
21993 @end deftypefn
21995 The shadow stack unwind code looks like:
21997 @smallexample
21998 #include <immintrin.h>
22000 /* Unwind the shadow stack for EH.  */
22001 #define _Unwind_Frames_Extra(x)       \
22002   do                                  \
22003     @{                                \
22004       _Unwind_Word ssp = _get_ssp (); \
22005       if (ssp != 0)                   \
22006         @{                            \
22007           _Unwind_Word tmp = (x);     \
22008           while (tmp > 255)           \
22009             @{                        \
22010               _inc_ssp (tmp);         \
22011               tmp -= 255;             \
22012             @}                        \
22013           _inc_ssp (tmp);             \
22014         @}                            \
22015     @}                                \
22016     while (0)
22017 @end smallexample
22019 @noindent
22020 This code runs unconditionally on all 64-bit processors.  For 32-bit
22021 processors the code runs on those that support multi-byte NOP instructions.
22023 @node Target Format Checks
22024 @section Format Checks Specific to Particular Target Machines
22026 For some target machines, GCC supports additional options to the
22027 format attribute
22028 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22030 @menu
22031 * Solaris Format Checks::
22032 * Darwin Format Checks::
22033 @end menu
22035 @node Solaris Format Checks
22036 @subsection Solaris Format Checks
22038 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22039 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
22040 conversions, and the two-argument @code{%b} conversion for displaying
22041 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
22043 @node Darwin Format Checks
22044 @subsection Darwin Format Checks
22046 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
22047 attribute context.  Declarations made with such attribution are parsed for correct syntax
22048 and format argument types.  However, parsing of the format string itself is currently undefined
22049 and is not carried out by this version of the compiler.
22051 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22052 also be used as format arguments.  Note that the relevant headers are only likely to be
22053 available on Darwin (OSX) installations.  On such installations, the XCode and system
22054 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22055 associated functions.
22057 @node Pragmas
22058 @section Pragmas Accepted by GCC
22059 @cindex pragmas
22060 @cindex @code{#pragma}
22062 GCC supports several types of pragmas, primarily in order to compile
22063 code originally written for other compilers.  Note that in general
22064 we do not recommend the use of pragmas; @xref{Function Attributes},
22065 for further explanation.
22067 The GNU C preprocessor recognizes several pragmas in addition to the
22068 compiler pragmas documented here.  Refer to the CPP manual for more
22069 information.
22071 @menu
22072 * AArch64 Pragmas::
22073 * ARM Pragmas::
22074 * M32C Pragmas::
22075 * MeP Pragmas::
22076 * RS/6000 and PowerPC Pragmas::
22077 * S/390 Pragmas::
22078 * Darwin Pragmas::
22079 * Solaris Pragmas::
22080 * Symbol-Renaming Pragmas::
22081 * Structure-Layout Pragmas::
22082 * Weak Pragmas::
22083 * Diagnostic Pragmas::
22084 * Visibility Pragmas::
22085 * Push/Pop Macro Pragmas::
22086 * Function Specific Option Pragmas::
22087 * Loop-Specific Pragmas::
22088 @end menu
22090 @node AArch64 Pragmas
22091 @subsection AArch64 Pragmas
22093 The pragmas defined by the AArch64 target correspond to the AArch64
22094 target function attributes.  They can be specified as below:
22095 @smallexample
22096 #pragma GCC target("string")
22097 @end smallexample
22099 where @code{@var{string}} can be any string accepted as an AArch64 target
22100 attribute.  @xref{AArch64 Function Attributes}, for more details
22101 on the permissible values of @code{string}.
22103 @node ARM Pragmas
22104 @subsection ARM Pragmas
22106 The ARM target defines pragmas for controlling the default addition of
22107 @code{long_call} and @code{short_call} attributes to functions.
22108 @xref{Function Attributes}, for information about the effects of these
22109 attributes.
22111 @table @code
22112 @item long_calls
22113 @cindex pragma, long_calls
22114 Set all subsequent functions to have the @code{long_call} attribute.
22116 @item no_long_calls
22117 @cindex pragma, no_long_calls
22118 Set all subsequent functions to have the @code{short_call} attribute.
22120 @item long_calls_off
22121 @cindex pragma, long_calls_off
22122 Do not affect the @code{long_call} or @code{short_call} attributes of
22123 subsequent functions.
22124 @end table
22126 @node M32C Pragmas
22127 @subsection M32C Pragmas
22129 @table @code
22130 @item GCC memregs @var{number}
22131 @cindex pragma, memregs
22132 Overrides the command-line option @code{-memregs=} for the current
22133 file.  Use with care!  This pragma must be before any function in the
22134 file, and mixing different memregs values in different objects may
22135 make them incompatible.  This pragma is useful when a
22136 performance-critical function uses a memreg for temporary values,
22137 as it may allow you to reduce the number of memregs used.
22139 @item ADDRESS @var{name} @var{address}
22140 @cindex pragma, address
22141 For any declared symbols matching @var{name}, this does three things
22142 to that symbol: it forces the symbol to be located at the given
22143 address (a number), it forces the symbol to be volatile, and it
22144 changes the symbol's scope to be static.  This pragma exists for
22145 compatibility with other compilers, but note that the common
22146 @code{1234H} numeric syntax is not supported (use @code{0x1234}
22147 instead).  Example:
22149 @smallexample
22150 #pragma ADDRESS port3 0x103
22151 char port3;
22152 @end smallexample
22154 @end table
22156 @node MeP Pragmas
22157 @subsection MeP Pragmas
22159 @table @code
22161 @item custom io_volatile (on|off)
22162 @cindex pragma, custom io_volatile
22163 Overrides the command-line option @code{-mio-volatile} for the current
22164 file.  Note that for compatibility with future GCC releases, this
22165 option should only be used once before any @code{io} variables in each
22166 file.
22168 @item GCC coprocessor available @var{registers}
22169 @cindex pragma, coprocessor available
22170 Specifies which coprocessor registers are available to the register
22171 allocator.  @var{registers} may be a single register, register range
22172 separated by ellipses, or comma-separated list of those.  Example:
22174 @smallexample
22175 #pragma GCC coprocessor available $c0...$c10, $c28
22176 @end smallexample
22178 @item GCC coprocessor call_saved @var{registers}
22179 @cindex pragma, coprocessor call_saved
22180 Specifies which coprocessor registers are to be saved and restored by
22181 any function using them.  @var{registers} may be a single register,
22182 register range separated by ellipses, or comma-separated list of
22183 those.  Example:
22185 @smallexample
22186 #pragma GCC coprocessor call_saved $c4...$c6, $c31
22187 @end smallexample
22189 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
22190 @cindex pragma, coprocessor subclass
22191 Creates and defines a register class.  These register classes can be
22192 used by inline @code{asm} constructs.  @var{registers} may be a single
22193 register, register range separated by ellipses, or comma-separated
22194 list of those.  Example:
22196 @smallexample
22197 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
22199 asm ("cpfoo %0" : "=B" (x));
22200 @end smallexample
22202 @item GCC disinterrupt @var{name} , @var{name} @dots{}
22203 @cindex pragma, disinterrupt
22204 For the named functions, the compiler adds code to disable interrupts
22205 for the duration of those functions.  If any functions so named 
22206 are not encountered in the source, a warning is emitted that the pragma is
22207 not used.  Examples:
22209 @smallexample
22210 #pragma disinterrupt foo
22211 #pragma disinterrupt bar, grill
22212 int foo () @{ @dots{} @}
22213 @end smallexample
22215 @item GCC call @var{name} , @var{name} @dots{}
22216 @cindex pragma, call
22217 For the named functions, the compiler always uses a register-indirect
22218 call model when calling the named functions.  Examples:
22220 @smallexample
22221 extern int foo ();
22222 #pragma call foo
22223 @end smallexample
22225 @end table
22227 @node RS/6000 and PowerPC Pragmas
22228 @subsection RS/6000 and PowerPC Pragmas
22230 The RS/6000 and PowerPC targets define one pragma for controlling
22231 whether or not the @code{longcall} attribute is added to function
22232 declarations by default.  This pragma overrides the @option{-mlongcall}
22233 option, but not the @code{longcall} and @code{shortcall} attributes.
22234 @xref{RS/6000 and PowerPC Options}, for more information about when long
22235 calls are and are not necessary.
22237 @table @code
22238 @item longcall (1)
22239 @cindex pragma, longcall
22240 Apply the @code{longcall} attribute to all subsequent function
22241 declarations.
22243 @item longcall (0)
22244 Do not apply the @code{longcall} attribute to subsequent function
22245 declarations.
22246 @end table
22248 @c Describe h8300 pragmas here.
22249 @c Describe sh pragmas here.
22250 @c Describe v850 pragmas here.
22252 @node S/390 Pragmas
22253 @subsection S/390 Pragmas
22255 The pragmas defined by the S/390 target correspond to the S/390
22256 target function attributes and some the additional options:
22258 @table @samp
22259 @item zvector
22260 @itemx no-zvector
22261 @end table
22263 Note that options of the pragma, unlike options of the target
22264 attribute, do change the value of preprocessor macros like
22265 @code{__VEC__}.  They can be specified as below:
22267 @smallexample
22268 #pragma GCC target("string[,string]...")
22269 #pragma GCC target("string"[,"string"]...)
22270 @end smallexample
22272 @node Darwin Pragmas
22273 @subsection Darwin Pragmas
22275 The following pragmas are available for all architectures running the
22276 Darwin operating system.  These are useful for compatibility with other
22277 Mac OS compilers.
22279 @table @code
22280 @item mark @var{tokens}@dots{}
22281 @cindex pragma, mark
22282 This pragma is accepted, but has no effect.
22284 @item options align=@var{alignment}
22285 @cindex pragma, options align
22286 This pragma sets the alignment of fields in structures.  The values of
22287 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22288 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
22289 properly; to restore the previous setting, use @code{reset} for the
22290 @var{alignment}.
22292 @item segment @var{tokens}@dots{}
22293 @cindex pragma, segment
22294 This pragma is accepted, but has no effect.
22296 @item unused (@var{var} [, @var{var}]@dots{})
22297 @cindex pragma, unused
22298 This pragma declares variables to be possibly unused.  GCC does not
22299 produce warnings for the listed variables.  The effect is similar to
22300 that of the @code{unused} attribute, except that this pragma may appear
22301 anywhere within the variables' scopes.
22302 @end table
22304 @node Solaris Pragmas
22305 @subsection Solaris Pragmas
22307 The Solaris target supports @code{#pragma redefine_extname}
22308 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
22309 @code{#pragma} directives for compatibility with the system compiler.
22311 @table @code
22312 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22313 @cindex pragma, align
22315 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22316 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22317 Attributes}).  Macro expansion occurs on the arguments to this pragma
22318 when compiling C and Objective-C@.  It does not currently occur when
22319 compiling C++, but this is a bug which may be fixed in a future
22320 release.
22322 @item fini (@var{function} [, @var{function}]...)
22323 @cindex pragma, fini
22325 This pragma causes each listed @var{function} to be called after
22326 main, or during shared module unloading, by adding a call to the
22327 @code{.fini} section.
22329 @item init (@var{function} [, @var{function}]...)
22330 @cindex pragma, init
22332 This pragma causes each listed @var{function} to be called during
22333 initialization (before @code{main}) or during shared module loading, by
22334 adding a call to the @code{.init} section.
22336 @end table
22338 @node Symbol-Renaming Pragmas
22339 @subsection Symbol-Renaming Pragmas
22341 GCC supports a @code{#pragma} directive that changes the name used in
22342 assembly for a given declaration. While this pragma is supported on all
22343 platforms, it is intended primarily to provide compatibility with the
22344 Solaris system headers. This effect can also be achieved using the asm
22345 labels extension (@pxref{Asm Labels}).
22347 @table @code
22348 @item redefine_extname @var{oldname} @var{newname}
22349 @cindex pragma, redefine_extname
22351 This pragma gives the C function @var{oldname} the assembly symbol
22352 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22353 is defined if this pragma is available (currently on all platforms).
22354 @end table
22356 This pragma and the asm labels extension interact in a complicated
22357 manner.  Here are some corner cases you may want to be aware of:
22359 @enumerate
22360 @item This pragma silently applies only to declarations with external
22361 linkage.  Asm labels do not have this restriction.
22363 @item In C++, this pragma silently applies only to declarations with
22364 ``C'' linkage.  Again, asm labels do not have this restriction.
22366 @item If either of the ways of changing the assembly name of a
22367 declaration are applied to a declaration whose assembly name has
22368 already been determined (either by a previous use of one of these
22369 features, or because the compiler needed the assembly name in order to
22370 generate code), and the new name is different, a warning issues and
22371 the name does not change.
22373 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22374 always the C-language name.
22375 @end enumerate
22377 @node Structure-Layout Pragmas
22378 @subsection Structure-Layout Pragmas
22380 For compatibility with Microsoft Windows compilers, GCC supports a
22381 set of @code{#pragma} directives that change the maximum alignment of
22382 members of structures (other than zero-width bit-fields), unions, and
22383 classes subsequently defined. The @var{n} value below always is required
22384 to be a small power of two and specifies the new alignment in bytes.
22386 @enumerate
22387 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22388 @item @code{#pragma pack()} sets the alignment to the one that was in
22389 effect when compilation started (see also command-line option
22390 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22391 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22392 setting on an internal stack and then optionally sets the new alignment.
22393 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22394 saved at the top of the internal stack (and removes that stack entry).
22395 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22396 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22397 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22398 @code{#pragma pack(pop)}.
22399 @end enumerate
22401 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22402 directive which lays out structures and unions subsequently defined as the
22403 documented @code{__attribute__ ((ms_struct))}.
22405 @enumerate
22406 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22407 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22408 @item @code{#pragma ms_struct reset} goes back to the default layout.
22409 @end enumerate
22411 Most targets also support the @code{#pragma scalar_storage_order} directive
22412 which lays out structures and unions subsequently defined as the documented
22413 @code{__attribute__ ((scalar_storage_order))}.
22415 @enumerate
22416 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22417 of the scalar fields to big-endian.
22418 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22419 of the scalar fields to little-endian.
22420 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22421 that was in effect when compilation started (see also command-line option
22422 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22423 @end enumerate
22425 @node Weak Pragmas
22426 @subsection Weak Pragmas
22428 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22429 directives for declaring symbols to be weak, and defining weak
22430 aliases.
22432 @table @code
22433 @item #pragma weak @var{symbol}
22434 @cindex pragma, weak
22435 This pragma declares @var{symbol} to be weak, as if the declaration
22436 had the attribute of the same name.  The pragma may appear before
22437 or after the declaration of @var{symbol}.  It is not an error for
22438 @var{symbol} to never be defined at all.
22440 @item #pragma weak @var{symbol1} = @var{symbol2}
22441 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22442 It is an error if @var{symbol2} is not defined in the current
22443 translation unit.
22444 @end table
22446 @node Diagnostic Pragmas
22447 @subsection Diagnostic Pragmas
22449 GCC allows the user to selectively enable or disable certain types of
22450 diagnostics, and change the kind of the diagnostic.  For example, a
22451 project's policy might require that all sources compile with
22452 @option{-Werror} but certain files might have exceptions allowing
22453 specific types of warnings.  Or, a project might selectively enable
22454 diagnostics and treat them as errors depending on which preprocessor
22455 macros are defined.
22457 @table @code
22458 @item #pragma GCC diagnostic @var{kind} @var{option}
22459 @cindex pragma, diagnostic
22461 Modifies the disposition of a diagnostic.  Note that not all
22462 diagnostics are modifiable; at the moment only warnings (normally
22463 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22464 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22465 are controllable and which option controls them.
22467 @var{kind} is @samp{error} to treat this diagnostic as an error,
22468 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22469 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22470 @var{option} is a double quoted string that matches the command-line
22471 option.
22473 @smallexample
22474 #pragma GCC diagnostic warning "-Wformat"
22475 #pragma GCC diagnostic error "-Wformat"
22476 #pragma GCC diagnostic ignored "-Wformat"
22477 @end smallexample
22479 Note that these pragmas override any command-line options.  GCC keeps
22480 track of the location of each pragma, and issues diagnostics according
22481 to the state as of that point in the source file.  Thus, pragmas occurring
22482 after a line do not affect diagnostics caused by that line.
22484 @item #pragma GCC diagnostic push
22485 @itemx #pragma GCC diagnostic pop
22487 Causes GCC to remember the state of the diagnostics as of each
22488 @code{push}, and restore to that point at each @code{pop}.  If a
22489 @code{pop} has no matching @code{push}, the command-line options are
22490 restored.
22492 @smallexample
22493 #pragma GCC diagnostic error "-Wuninitialized"
22494   foo(a);                       /* error is given for this one */
22495 #pragma GCC diagnostic push
22496 #pragma GCC diagnostic ignored "-Wuninitialized"
22497   foo(b);                       /* no diagnostic for this one */
22498 #pragma GCC diagnostic pop
22499   foo(c);                       /* error is given for this one */
22500 #pragma GCC diagnostic pop
22501   foo(d);                       /* depends on command-line options */
22502 @end smallexample
22504 @end table
22506 GCC also offers a simple mechanism for printing messages during
22507 compilation.
22509 @table @code
22510 @item #pragma message @var{string}
22511 @cindex pragma, diagnostic
22513 Prints @var{string} as a compiler message on compilation.  The message
22514 is informational only, and is neither a compilation warning nor an
22515 error.  Newlines can be included in the string by using the @samp{\n}
22516 escape sequence.
22518 @smallexample
22519 #pragma message "Compiling " __FILE__ "..."
22520 @end smallexample
22522 @var{string} may be parenthesized, and is printed with location
22523 information.  For example,
22525 @smallexample
22526 #define DO_PRAGMA(x) _Pragma (#x)
22527 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22529 TODO(Remember to fix this)
22530 @end smallexample
22532 @noindent
22533 prints @samp{/tmp/file.c:4: note: #pragma message:
22534 TODO - Remember to fix this}.
22536 @item #pragma GCC error @var{message}
22537 @cindex pragma, diagnostic
22538 Generates an error message.  This pragma @emph{is} considered to
22539 indicate an error in the compilation, and it will be treated as such.
22541 Newlines can be included in the string by using the @samp{\n}
22542 escape sequence.  They will be displayed as newlines even if the
22543 @option{-fmessage-length} option is set to zero.
22545 The error is only generated if the pragma is present in the code after
22546 pre-processing has been completed.  It does not matter however if the
22547 code containing the pragma is unreachable:
22549 @smallexample
22550 #if 0
22551 #pragma GCC error "this error is not seen"
22552 #endif
22553 void foo (void)
22555   return;
22556 #pragma GCC error "this error is seen"
22558 @end smallexample
22560 @item #pragma GCC warning @var{message}
22561 @cindex pragma, diagnostic
22562 This is just like @samp{pragma GCC error} except that a warning
22563 message is issued instead of an error message.  Unless
22564 @option{-Werror} is in effect, in which case this pragma will generate
22565 an error as well.
22567 @end table
22569 @node Visibility Pragmas
22570 @subsection Visibility Pragmas
22572 @table @code
22573 @item #pragma GCC visibility push(@var{visibility})
22574 @itemx #pragma GCC visibility pop
22575 @cindex pragma, visibility
22577 This pragma allows the user to set the visibility for multiple
22578 declarations without having to give each a visibility attribute
22579 (@pxref{Function Attributes}).
22581 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22582 declarations.  Class members and template specializations are not
22583 affected; if you want to override the visibility for a particular
22584 member or instantiation, you must use an attribute.
22586 @end table
22589 @node Push/Pop Macro Pragmas
22590 @subsection Push/Pop Macro Pragmas
22592 For compatibility with Microsoft Windows compilers, GCC supports
22593 @samp{#pragma push_macro(@var{"macro_name"})}
22594 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22596 @table @code
22597 @item #pragma push_macro(@var{"macro_name"})
22598 @cindex pragma, push_macro
22599 This pragma saves the value of the macro named as @var{macro_name} to
22600 the top of the stack for this macro.
22602 @item #pragma pop_macro(@var{"macro_name"})
22603 @cindex pragma, pop_macro
22604 This pragma sets the value of the macro named as @var{macro_name} to
22605 the value on top of the stack for this macro. If the stack for
22606 @var{macro_name} is empty, the value of the macro remains unchanged.
22607 @end table
22609 For example:
22611 @smallexample
22612 #define X  1
22613 #pragma push_macro("X")
22614 #undef X
22615 #define X -1
22616 #pragma pop_macro("X")
22617 int x [X];
22618 @end smallexample
22620 @noindent
22621 In this example, the definition of X as 1 is saved by @code{#pragma
22622 push_macro} and restored by @code{#pragma pop_macro}.
22624 @node Function Specific Option Pragmas
22625 @subsection Function Specific Option Pragmas
22627 @table @code
22628 @item #pragma GCC target (@var{string}, @dots{})
22629 @cindex pragma GCC target
22631 This pragma allows you to set target-specific options for functions
22632 defined later in the source file.  One or more strings can be
22633 specified.  Each function that is defined after this point is treated
22634 as if it had been declared with one @code{target(}@var{string}@code{)}
22635 attribute for each @var{string} argument.  The parentheses around
22636 the strings in the pragma are optional.  @xref{Function Attributes},
22637 for more information about the @code{target} attribute and the attribute
22638 syntax.
22640 The @code{#pragma GCC target} pragma is presently implemented for
22641 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22643 @item #pragma GCC optimize (@var{string}, @dots{})
22644 @cindex pragma GCC optimize
22646 This pragma allows you to set global optimization options for functions
22647 defined later in the source file.  One or more strings can be
22648 specified.  Each function that is defined after this point is treated
22649 as if it had been declared with one @code{optimize(}@var{string}@code{)}
22650 attribute for each @var{string} argument.  The parentheses around
22651 the strings in the pragma are optional.  @xref{Function Attributes},
22652 for more information about the @code{optimize} attribute and the attribute
22653 syntax.
22655 @item #pragma GCC push_options
22656 @itemx #pragma GCC pop_options
22657 @cindex pragma GCC push_options
22658 @cindex pragma GCC pop_options
22660 These pragmas maintain a stack of the current target and optimization
22661 options.  It is intended for include files where you temporarily want
22662 to switch to using a different @samp{#pragma GCC target} or
22663 @samp{#pragma GCC optimize} and then to pop back to the previous
22664 options.
22666 @item #pragma GCC reset_options
22667 @cindex pragma GCC reset_options
22669 This pragma clears the current @code{#pragma GCC target} and
22670 @code{#pragma GCC optimize} to use the default switches as specified
22671 on the command line.
22673 @end table
22675 @node Loop-Specific Pragmas
22676 @subsection Loop-Specific Pragmas
22678 @table @code
22679 @item #pragma GCC ivdep
22680 @cindex pragma GCC ivdep
22682 With this pragma, the programmer asserts that there are no loop-carried
22683 dependencies which would prevent consecutive iterations of
22684 the following loop from executing concurrently with SIMD
22685 (single instruction multiple data) instructions.
22687 For example, the compiler can only unconditionally vectorize the following
22688 loop with the pragma:
22690 @smallexample
22691 void foo (int n, int *a, int *b, int *c)
22693   int i, j;
22694 #pragma GCC ivdep
22695   for (i = 0; i < n; ++i)
22696     a[i] = b[i] + c[i];
22698 @end smallexample
22700 @noindent
22701 In this example, using the @code{restrict} qualifier had the same
22702 effect. In the following example, that would not be possible. Assume
22703 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22704 that it can unconditionally vectorize the following loop:
22706 @smallexample
22707 void ignore_vec_dep (int *a, int k, int c, int m)
22709 #pragma GCC ivdep
22710   for (int i = 0; i < m; i++)
22711     a[i] = a[i + k] * c;
22713 @end smallexample
22715 @item #pragma GCC unroll @var{n}
22716 @cindex pragma GCC unroll @var{n}
22718 You can use this pragma to control how many times a loop should be unrolled.
22719 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22720 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22721 @var{n} is an integer constant expression specifying the unrolling factor.
22722 The values of @math{0} and @math{1} block any unrolling of the loop.
22724 @end table
22726 @node Unnamed Fields
22727 @section Unnamed Structure and Union Fields
22728 @cindex @code{struct}
22729 @cindex @code{union}
22731 As permitted by ISO C11 and for compatibility with other compilers,
22732 GCC allows you to define
22733 a structure or union that contains, as fields, structures and unions
22734 without names.  For example:
22736 @smallexample
22737 struct @{
22738   int a;
22739   union @{
22740     int b;
22741     float c;
22742   @};
22743   int d;
22744 @} foo;
22745 @end smallexample
22747 @noindent
22748 In this example, you are able to access members of the unnamed
22749 union with code like @samp{foo.b}.  Note that only unnamed structs and
22750 unions are allowed, you may not have, for example, an unnamed
22751 @code{int}.
22753 You must never create such structures that cause ambiguous field definitions.
22754 For example, in this structure:
22756 @smallexample
22757 struct @{
22758   int a;
22759   struct @{
22760     int a;
22761   @};
22762 @} foo;
22763 @end smallexample
22765 @noindent
22766 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22767 The compiler gives errors for such constructs.
22769 @opindex fms-extensions
22770 Unless @option{-fms-extensions} is used, the unnamed field must be a
22771 structure or union definition without a tag (for example, @samp{struct
22772 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22773 also be a definition with a tag such as @samp{struct foo @{ int a;
22774 @};}, a reference to a previously defined structure or union such as
22775 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22776 previously defined structure or union type.
22778 @opindex fplan9-extensions
22779 The option @option{-fplan9-extensions} enables
22780 @option{-fms-extensions} as well as two other extensions.  First, a
22781 pointer to a structure is automatically converted to a pointer to an
22782 anonymous field for assignments and function calls.  For example:
22784 @smallexample
22785 struct s1 @{ int a; @};
22786 struct s2 @{ struct s1; @};
22787 extern void f1 (struct s1 *);
22788 void f2 (struct s2 *p) @{ f1 (p); @}
22789 @end smallexample
22791 @noindent
22792 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22793 converted into a pointer to the anonymous field.
22795 Second, when the type of an anonymous field is a @code{typedef} for a
22796 @code{struct} or @code{union}, code may refer to the field using the
22797 name of the @code{typedef}.
22799 @smallexample
22800 typedef struct @{ int a; @} s1;
22801 struct s2 @{ s1; @};
22802 s1 f1 (struct s2 *p) @{ return p->s1; @}
22803 @end smallexample
22805 These usages are only permitted when they are not ambiguous.
22807 @node Thread-Local
22808 @section Thread-Local Storage
22809 @cindex Thread-Local Storage
22810 @cindex @acronym{TLS}
22811 @cindex @code{__thread}
22813 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22814 are allocated such that there is one instance of the variable per extant
22815 thread.  The runtime model GCC uses to implement this originates
22816 in the IA-64 processor-specific ABI, but has since been migrated
22817 to other processors as well.  It requires significant support from
22818 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22819 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22820 is not available everywhere.
22822 At the user level, the extension is visible with a new storage
22823 class keyword: @code{__thread}.  For example:
22825 @smallexample
22826 __thread int i;
22827 extern __thread struct state s;
22828 static __thread char *p;
22829 @end smallexample
22831 The @code{__thread} specifier may be used alone, with the @code{extern}
22832 or @code{static} specifiers, but with no other storage class specifier.
22833 When used with @code{extern} or @code{static}, @code{__thread} must appear
22834 immediately after the other storage class specifier.
22836 The @code{__thread} specifier may be applied to any global, file-scoped
22837 static, function-scoped static, or static data member of a class.  It may
22838 not be applied to block-scoped automatic or non-static data member.
22840 When the address-of operator is applied to a thread-local variable, it is
22841 evaluated at run time and returns the address of the current thread's
22842 instance of that variable.  An address so obtained may be used by any
22843 thread.  When a thread terminates, any pointers to thread-local variables
22844 in that thread become invalid.
22846 No static initialization may refer to the address of a thread-local variable.
22848 In C++, if an initializer is present for a thread-local variable, it must
22849 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22850 standard.
22852 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22853 ELF Handling For Thread-Local Storage} for a detailed explanation of
22854 the four thread-local storage addressing models, and how the runtime
22855 is expected to function.
22857 @menu
22858 * C99 Thread-Local Edits::
22859 * C++98 Thread-Local Edits::
22860 @end menu
22862 @node C99 Thread-Local Edits
22863 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22865 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22866 that document the exact semantics of the language extension.
22868 @itemize @bullet
22869 @item
22870 @cite{5.1.2  Execution environments}
22872 Add new text after paragraph 1
22874 @quotation
22875 Within either execution environment, a @dfn{thread} is a flow of
22876 control within a program.  It is implementation defined whether
22877 or not there may be more than one thread associated with a program.
22878 It is implementation defined how threads beyond the first are
22879 created, the name and type of the function called at thread
22880 startup, and how threads may be terminated.  However, objects
22881 with thread storage duration shall be initialized before thread
22882 startup.
22883 @end quotation
22885 @item
22886 @cite{6.2.4  Storage durations of objects}
22888 Add new text before paragraph 3
22890 @quotation
22891 An object whose identifier is declared with the storage-class
22892 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22893 Its lifetime is the entire execution of the thread, and its
22894 stored value is initialized only once, prior to thread startup.
22895 @end quotation
22897 @item
22898 @cite{6.4.1  Keywords}
22900 Add @code{__thread}.
22902 @item
22903 @cite{6.7.1  Storage-class specifiers}
22905 Add @code{__thread} to the list of storage class specifiers in
22906 paragraph 1.
22908 Change paragraph 2 to
22910 @quotation
22911 With the exception of @code{__thread}, at most one storage-class
22912 specifier may be given [@dots{}].  The @code{__thread} specifier may
22913 be used alone, or immediately following @code{extern} or
22914 @code{static}.
22915 @end quotation
22917 Add new text after paragraph 6
22919 @quotation
22920 The declaration of an identifier for a variable that has
22921 block scope that specifies @code{__thread} shall also
22922 specify either @code{extern} or @code{static}.
22924 The @code{__thread} specifier shall be used only with
22925 variables.
22926 @end quotation
22927 @end itemize
22929 @node C++98 Thread-Local Edits
22930 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22932 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22933 that document the exact semantics of the language extension.
22935 @itemize @bullet
22936 @item
22937 @b{[intro.execution]}
22939 New text after paragraph 4
22941 @quotation
22942 A @dfn{thread} is a flow of control within the abstract machine.
22943 It is implementation defined whether or not there may be more than
22944 one thread.
22945 @end quotation
22947 New text after paragraph 7
22949 @quotation
22950 It is unspecified whether additional action must be taken to
22951 ensure when and whether side effects are visible to other threads.
22952 @end quotation
22954 @item
22955 @b{[lex.key]}
22957 Add @code{__thread}.
22959 @item
22960 @b{[basic.start.main]}
22962 Add after paragraph 5
22964 @quotation
22965 The thread that begins execution at the @code{main} function is called
22966 the @dfn{main thread}.  It is implementation defined how functions
22967 beginning threads other than the main thread are designated or typed.
22968 A function so designated, as well as the @code{main} function, is called
22969 a @dfn{thread startup function}.  It is implementation defined what
22970 happens if a thread startup function returns.  It is implementation
22971 defined what happens to other threads when any thread calls @code{exit}.
22972 @end quotation
22974 @item
22975 @b{[basic.start.init]}
22977 Add after paragraph 4
22979 @quotation
22980 The storage for an object of thread storage duration shall be
22981 statically initialized before the first statement of the thread startup
22982 function.  An object of thread storage duration shall not require
22983 dynamic initialization.
22984 @end quotation
22986 @item
22987 @b{[basic.start.term]}
22989 Add after paragraph 3
22991 @quotation
22992 The type of an object with thread storage duration shall not have a
22993 non-trivial destructor, nor shall it be an array type whose elements
22994 (directly or indirectly) have non-trivial destructors.
22995 @end quotation
22997 @item
22998 @b{[basic.stc]}
23000 Add ``thread storage duration'' to the list in paragraph 1.
23002 Change paragraph 2
23004 @quotation
23005 Thread, static, and automatic storage durations are associated with
23006 objects introduced by declarations [@dots{}].
23007 @end quotation
23009 Add @code{__thread} to the list of specifiers in paragraph 3.
23011 @item
23012 @b{[basic.stc.thread]}
23014 New section before @b{[basic.stc.static]}
23016 @quotation
23017 The keyword @code{__thread} applied to a non-local object gives the
23018 object thread storage duration.
23020 A local variable or class data member declared both @code{static}
23021 and @code{__thread} gives the variable or member thread storage
23022 duration.
23023 @end quotation
23025 @item
23026 @b{[basic.stc.static]}
23028 Change paragraph 1
23030 @quotation
23031 All objects that have neither thread storage duration, dynamic
23032 storage duration nor are local [@dots{}].
23033 @end quotation
23035 @item
23036 @b{[dcl.stc]}
23038 Add @code{__thread} to the list in paragraph 1.
23040 Change paragraph 1
23042 @quotation
23043 With the exception of @code{__thread}, at most one
23044 @var{storage-class-specifier} shall appear in a given
23045 @var{decl-specifier-seq}.  The @code{__thread} specifier may
23046 be used alone, or immediately following the @code{extern} or
23047 @code{static} specifiers.  [@dots{}]
23048 @end quotation
23050 Add after paragraph 5
23052 @quotation
23053 The @code{__thread} specifier can be applied only to the names of objects
23054 and to anonymous unions.
23055 @end quotation
23057 @item
23058 @b{[class.mem]}
23060 Add after paragraph 6
23062 @quotation
23063 Non-@code{static} members shall not be @code{__thread}.
23064 @end quotation
23065 @end itemize
23067 @node Binary constants
23068 @section Binary Constants using the @samp{0b} Prefix
23069 @cindex Binary constants using the @samp{0b} prefix
23071 Integer constants can be written as binary constants, consisting of a
23072 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23073 @samp{0B}.  This is particularly useful in environments that operate a
23074 lot on the bit level (like microcontrollers).
23076 The following statements are identical:
23078 @smallexample
23079 i =       42;
23080 i =     0x2a;
23081 i =      052;
23082 i = 0b101010;
23083 @end smallexample
23085 The type of these constants follows the same rules as for octal or
23086 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23087 can be applied.
23089 @node C++ Extensions
23090 @chapter Extensions to the C++ Language
23091 @cindex extensions, C++ language
23092 @cindex C++ language extensions
23094 The GNU compiler provides these extensions to the C++ language (and you
23095 can also use most of the C language extensions in your C++ programs).  If you
23096 want to write code that checks whether these features are available, you can
23097 test for the GNU compiler the same way as for C programs: check for a
23098 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
23099 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23100 Predefined Macros,cpp,The GNU C Preprocessor}).
23102 @menu
23103 * C++ Volatiles::       What constitutes an access to a volatile object.
23104 * Restricted Pointers:: C99 restricted pointers and references.
23105 * Vague Linkage::       Where G++ puts inlines, vtables and such.
23106 * C++ Interface::       You can use a single C++ header file for both
23107                         declarations and definitions.
23108 * Template Instantiation:: Methods for ensuring that exactly one copy of
23109                         each needed template instantiation is emitted.
23110 * Bound member functions:: You can extract a function pointer to the
23111                         method denoted by a @samp{->*} or @samp{.*} expression.
23112 * C++ Attributes::      Variable, function, and type attributes for C++ only.
23113 * Function Multiversioning::   Declaring multiple function versions.
23114 * Type Traits::         Compiler support for type traits.
23115 * C++ Concepts::        Improved support for generic programming.
23116 * Deprecated Features:: Things will disappear from G++.
23117 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
23118 @end menu
23120 @node C++ Volatiles
23121 @section When is a Volatile C++ Object Accessed?
23122 @cindex accessing volatiles
23123 @cindex volatile read
23124 @cindex volatile write
23125 @cindex volatile access
23127 The C++ standard differs from the C standard in its treatment of
23128 volatile objects.  It fails to specify what constitutes a volatile
23129 access, except to say that C++ should behave in a similar manner to C
23130 with respect to volatiles, where possible.  However, the different
23131 lvalueness of expressions between C and C++ complicate the behavior.
23132 G++ behaves the same as GCC for volatile access, @xref{C
23133 Extensions,,Volatiles}, for a description of GCC's behavior.
23135 The C and C++ language specifications differ when an object is
23136 accessed in a void context:
23138 @smallexample
23139 volatile int *src = @var{somevalue};
23140 *src;
23141 @end smallexample
23143 The C++ standard specifies that such expressions do not undergo lvalue
23144 to rvalue conversion, and that the type of the dereferenced object may
23145 be incomplete.  The C++ standard does not specify explicitly that it
23146 is lvalue to rvalue conversion that is responsible for causing an
23147 access.  There is reason to believe that it is, because otherwise
23148 certain simple expressions become undefined.  However, because it
23149 would surprise most programmers, G++ treats dereferencing a pointer to
23150 volatile object of complete type as GCC would do for an equivalent
23151 type in C@.  When the object has incomplete type, G++ issues a
23152 warning; if you wish to force an error, you must force a conversion to
23153 rvalue with, for instance, a static cast.
23155 When using a reference to volatile, G++ does not treat equivalent
23156 expressions as accesses to volatiles, but instead issues a warning that
23157 no volatile is accessed.  The rationale for this is that otherwise it
23158 becomes difficult to determine where volatile access occur, and not
23159 possible to ignore the return value from functions returning volatile
23160 references.  Again, if you wish to force a read, cast the reference to
23161 an rvalue.
23163 G++ implements the same behavior as GCC does when assigning to a
23164 volatile object---there is no reread of the assigned-to object, the
23165 assigned rvalue is reused.  Note that in C++ assignment expressions
23166 are lvalues, and if used as an lvalue, the volatile object is
23167 referred to.  For instance, @var{vref} refers to @var{vobj}, as
23168 expected, in the following example:
23170 @smallexample
23171 volatile int vobj;
23172 volatile int &vref = vobj = @var{something};
23173 @end smallexample
23175 @node Restricted Pointers
23176 @section Restricting Pointer Aliasing
23177 @cindex restricted pointers
23178 @cindex restricted references
23179 @cindex restricted this pointer
23181 As with the C front end, G++ understands the C99 feature of restricted pointers,
23182 specified with the @code{__restrict__}, or @code{__restrict} type
23183 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
23184 language flag, @code{restrict} is not a keyword in C++.
23186 In addition to allowing restricted pointers, you can specify restricted
23187 references, which indicate that the reference is not aliased in the local
23188 context.
23190 @smallexample
23191 void fn (int *__restrict__ rptr, int &__restrict__ rref)
23193   /* @r{@dots{}} */
23195 @end smallexample
23197 @noindent
23198 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
23199 @var{rref} refers to a (different) unaliased integer.
23201 You may also specify whether a member function's @var{this} pointer is
23202 unaliased by using @code{__restrict__} as a member function qualifier.
23204 @smallexample
23205 void T::fn () __restrict__
23207   /* @r{@dots{}} */
23209 @end smallexample
23211 @noindent
23212 Within the body of @code{T::fn}, @var{this} has the effective
23213 definition @code{T *__restrict__ const this}.  Notice that the
23214 interpretation of a @code{__restrict__} member function qualifier is
23215 different to that of @code{const} or @code{volatile} qualifier, in that it
23216 is applied to the pointer rather than the object.  This is consistent with
23217 other compilers that implement restricted pointers.
23219 As with all outermost parameter qualifiers, @code{__restrict__} is
23220 ignored in function definition matching.  This means you only need to
23221 specify @code{__restrict__} in a function definition, rather than
23222 in a function prototype as well.
23224 @node Vague Linkage
23225 @section Vague Linkage
23226 @cindex vague linkage
23228 There are several constructs in C++ that require space in the object
23229 file but are not clearly tied to a single translation unit.  We say that
23230 these constructs have ``vague linkage''.  Typically such constructs are
23231 emitted wherever they are needed, though sometimes we can be more
23232 clever.
23234 @table @asis
23235 @item Inline Functions
23236 Inline functions are typically defined in a header file which can be
23237 included in many different compilations.  Hopefully they can usually be
23238 inlined, but sometimes an out-of-line copy is necessary, if the address
23239 of the function is taken or if inlining fails.  In general, we emit an
23240 out-of-line copy in all translation units where one is needed.  As an
23241 exception, we only emit inline virtual functions with the vtable, since
23242 it always requires a copy.
23244 Local static variables and string constants used in an inline function
23245 are also considered to have vague linkage, since they must be shared
23246 between all inlined and out-of-line instances of the function.
23248 @item VTables
23249 @cindex vtable
23250 C++ virtual functions are implemented in most compilers using a lookup
23251 table, known as a vtable.  The vtable contains pointers to the virtual
23252 functions provided by a class, and each object of the class contains a
23253 pointer to its vtable (or vtables, in some multiple-inheritance
23254 situations).  If the class declares any non-inline, non-pure virtual
23255 functions, the first one is chosen as the ``key method'' for the class,
23256 and the vtable is only emitted in the translation unit where the key
23257 method is defined.
23259 @emph{Note:} If the chosen key method is later defined as inline, the
23260 vtable is still emitted in every translation unit that defines it.
23261 Make sure that any inline virtuals are declared inline in the class
23262 body, even if they are not defined there.
23264 @item @code{type_info} objects
23265 @cindex @code{type_info}
23266 @cindex RTTI
23267 C++ requires information about types to be written out in order to
23268 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23269 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23270 object is written out along with the vtable so that @samp{dynamic_cast}
23271 can determine the dynamic type of a class object at run time.  For all
23272 other types, we write out the @samp{type_info} object when it is used: when
23273 applying @samp{typeid} to an expression, throwing an object, or
23274 referring to a type in a catch clause or exception specification.
23276 @item Template Instantiations
23277 Most everything in this section also applies to template instantiations,
23278 but there are other options as well.
23279 @xref{Template Instantiation,,Where's the Template?}.
23281 @end table
23283 When used with GNU ld version 2.8 or later on an ELF system such as
23284 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23285 these constructs will be discarded at link time.  This is known as
23286 COMDAT support.
23288 On targets that don't support COMDAT, but do support weak symbols, GCC
23289 uses them.  This way one copy overrides all the others, but
23290 the unused copies still take up space in the executable.
23292 For targets that do not support either COMDAT or weak symbols,
23293 most entities with vague linkage are emitted as local symbols to
23294 avoid duplicate definition errors from the linker.  This does not happen
23295 for local statics in inlines, however, as having multiple copies
23296 almost certainly breaks things.
23298 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23299 another way to control placement of these constructs.
23301 @node C++ Interface
23302 @section C++ Interface and Implementation Pragmas
23304 @cindex interface and implementation headers, C++
23305 @cindex C++ interface and implementation headers
23306 @cindex pragmas, interface and implementation
23308 @code{#pragma interface} and @code{#pragma implementation} provide the
23309 user with a way of explicitly directing the compiler to emit entities
23310 with vague linkage (and debugging information) in a particular
23311 translation unit.
23313 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23314 by COMDAT support and the ``key method'' heuristic
23315 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
23316 program to grow due to unnecessary out-of-line copies of inline
23317 functions.
23319 @table @code
23320 @item #pragma interface
23321 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23322 @kindex #pragma interface
23323 Use this directive in @emph{header files} that define object classes, to save
23324 space in most of the object files that use those classes.  Normally,
23325 local copies of certain information (backup copies of inline member
23326 functions, debugging information, and the internal tables that implement
23327 virtual functions) must be kept in each object file that includes class
23328 definitions.  You can use this pragma to avoid such duplication.  When a
23329 header file containing @samp{#pragma interface} is included in a
23330 compilation, this auxiliary information is not generated (unless
23331 the main input source file itself uses @samp{#pragma implementation}).
23332 Instead, the object files contain references to be resolved at link
23333 time.
23335 The second form of this directive is useful for the case where you have
23336 multiple headers with the same name in different directories.  If you
23337 use this form, you must specify the same string to @samp{#pragma
23338 implementation}.
23340 @item #pragma implementation
23341 @itemx #pragma implementation "@var{objects}.h"
23342 @kindex #pragma implementation
23343 Use this pragma in a @emph{main input file}, when you want full output from
23344 included header files to be generated (and made globally visible).  The
23345 included header file, in turn, should use @samp{#pragma interface}.
23346 Backup copies of inline member functions, debugging information, and the
23347 internal tables used to implement virtual functions are all generated in
23348 implementation files.
23350 @cindex implied @code{#pragma implementation}
23351 @cindex @code{#pragma implementation}, implied
23352 @cindex naming convention, implementation headers
23353 If you use @samp{#pragma implementation} with no argument, it applies to
23354 an include file with the same basename@footnote{A file's @dfn{basename}
23355 is the name stripped of all leading path information and of trailing
23356 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23357 file.  For example, in @file{allclass.cc}, giving just
23358 @samp{#pragma implementation}
23359 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23361 Use the string argument if you want a single implementation file to
23362 include code from multiple header files.  (You must also use
23363 @samp{#include} to include the header file; @samp{#pragma
23364 implementation} only specifies how to use the file---it doesn't actually
23365 include it.)
23367 There is no way to split up the contents of a single header file into
23368 multiple implementation files.
23369 @end table
23371 @cindex inlining and C++ pragmas
23372 @cindex C++ pragmas, effect on inlining
23373 @cindex pragmas in C++, effect on inlining
23374 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23375 effect on function inlining.
23377 If you define a class in a header file marked with @samp{#pragma
23378 interface}, the effect on an inline function defined in that class is
23379 similar to an explicit @code{extern} declaration---the compiler emits
23380 no code at all to define an independent version of the function.  Its
23381 definition is used only for inlining with its callers.
23383 @opindex fno-implement-inlines
23384 Conversely, when you include the same header file in a main source file
23385 that declares it as @samp{#pragma implementation}, the compiler emits
23386 code for the function itself; this defines a version of the function
23387 that can be found via pointers (or by callers compiled without
23388 inlining).  If all calls to the function can be inlined, you can avoid
23389 emitting the function by compiling with @option{-fno-implement-inlines}.
23390 If any calls are not inlined, you will get linker errors.
23392 @node Template Instantiation
23393 @section Where's the Template?
23394 @cindex template instantiation
23396 C++ templates were the first language feature to require more
23397 intelligence from the environment than was traditionally found on a UNIX
23398 system.  Somehow the compiler and linker have to make sure that each
23399 template instance occurs exactly once in the executable if it is needed,
23400 and not at all otherwise.  There are two basic approaches to this
23401 problem, which are referred to as the Borland model and the Cfront model.
23403 @table @asis
23404 @item Borland model
23405 Borland C++ solved the template instantiation problem by adding the code
23406 equivalent of common blocks to their linker; the compiler emits template
23407 instances in each translation unit that uses them, and the linker
23408 collapses them together.  The advantage of this model is that the linker
23409 only has to consider the object files themselves; there is no external
23410 complexity to worry about.  The disadvantage is that compilation time
23411 is increased because the template code is being compiled repeatedly.
23412 Code written for this model tends to include definitions of all
23413 templates in the header file, since they must be seen to be
23414 instantiated.
23416 @item Cfront model
23417 The AT&T C++ translator, Cfront, solved the template instantiation
23418 problem by creating the notion of a template repository, an
23419 automatically maintained place where template instances are stored.  A
23420 more modern version of the repository works as follows: As individual
23421 object files are built, the compiler places any template definitions and
23422 instantiations encountered in the repository.  At link time, the link
23423 wrapper adds in the objects in the repository and compiles any needed
23424 instances that were not previously emitted.  The advantages of this
23425 model are more optimal compilation speed and the ability to use the
23426 system linker; to implement the Borland model a compiler vendor also
23427 needs to replace the linker.  The disadvantages are vastly increased
23428 complexity, and thus potential for error; for some code this can be
23429 just as transparent, but in practice it can been very difficult to build
23430 multiple programs in one directory and one program in multiple
23431 directories.  Code written for this model tends to separate definitions
23432 of non-inline member templates into a separate file, which should be
23433 compiled separately.
23434 @end table
23436 G++ implements the Borland model on targets where the linker supports it,
23437 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23438 Otherwise G++ implements neither automatic model.
23440 You have the following options for dealing with template instantiations:
23442 @enumerate
23443 @item
23444 Do nothing.  Code written for the Borland model works fine, but
23445 each translation unit contains instances of each of the templates it
23446 uses.  The duplicate instances will be discarded by the linker, but in
23447 a large program, this can lead to an unacceptable amount of code
23448 duplication in object files or shared libraries.
23450 Duplicate instances of a template can be avoided by defining an explicit
23451 instantiation in one object file, and preventing the compiler from doing
23452 implicit instantiations in any other object files by using an explicit
23453 instantiation declaration, using the @code{extern template} syntax:
23455 @smallexample
23456 extern template int max (int, int);
23457 @end smallexample
23459 This syntax is defined in the C++ 2011 standard, but has been supported by
23460 G++ and other compilers since well before 2011.
23462 Explicit instantiations can be used for the largest or most frequently
23463 duplicated instances, without having to know exactly which other instances
23464 are used in the rest of the program.  You can scatter the explicit
23465 instantiations throughout your program, perhaps putting them in the
23466 translation units where the instances are used or the translation units
23467 that define the templates themselves; you can put all of the explicit
23468 instantiations you need into one big file; or you can create small files
23469 like
23471 @smallexample
23472 #include "Foo.h"
23473 #include "Foo.cc"
23475 template class Foo<int>;
23476 template ostream& operator <<
23477                 (ostream&, const Foo<int>&);
23478 @end smallexample
23480 @noindent
23481 for each of the instances you need, and create a template instantiation
23482 library from those.
23484 This is the simplest option, but also offers flexibility and
23485 fine-grained control when necessary. It is also the most portable
23486 alternative and programs using this approach will work with most modern
23487 compilers.
23489 @item
23490 @opindex frepo
23491 Compile your template-using code with @option{-frepo}.  The compiler
23492 generates files with the extension @samp{.rpo} listing all of the
23493 template instantiations used in the corresponding object files that
23494 could be instantiated there; the link wrapper, @samp{collect2},
23495 then updates the @samp{.rpo} files to tell the compiler where to place
23496 those instantiations and rebuild any affected object files.  The
23497 link-time overhead is negligible after the first pass, as the compiler
23498 continues to place the instantiations in the same files.
23500 This can be a suitable option for application code written for the Borland
23501 model, as it usually just works.  Code written for the Cfront model 
23502 needs to be modified so that the template definitions are available at
23503 one or more points of instantiation; usually this is as simple as adding
23504 @code{#include <tmethods.cc>} to the end of each template header.
23506 For library code, if you want the library to provide all of the template
23507 instantiations it needs, just try to link all of its object files
23508 together; the link will fail, but cause the instantiations to be
23509 generated as a side effect.  Be warned, however, that this may cause
23510 conflicts if multiple libraries try to provide the same instantiations.
23511 For greater control, use explicit instantiation as described in the next
23512 option.
23514 @item
23515 @opindex fno-implicit-templates
23516 Compile your code with @option{-fno-implicit-templates} to disable the
23517 implicit generation of template instances, and explicitly instantiate
23518 all the ones you use.  This approach requires more knowledge of exactly
23519 which instances you need than do the others, but it's less
23520 mysterious and allows greater control if you want to ensure that only
23521 the intended instances are used.
23523 If you are using Cfront-model code, you can probably get away with not
23524 using @option{-fno-implicit-templates} when compiling files that don't
23525 @samp{#include} the member template definitions.
23527 If you use one big file to do the instantiations, you may want to
23528 compile it without @option{-fno-implicit-templates} so you get all of the
23529 instances required by your explicit instantiations (but not by any
23530 other files) without having to specify them as well.
23532 In addition to forward declaration of explicit instantiations
23533 (with @code{extern}), G++ has extended the template instantiation
23534 syntax to support instantiation of the compiler support data for a
23535 template class (i.e.@: the vtable) without instantiating any of its
23536 members (with @code{inline}), and instantiation of only the static data
23537 members of a template class, without the support data or member
23538 functions (with @code{static}):
23540 @smallexample
23541 inline template class Foo<int>;
23542 static template class Foo<int>;
23543 @end smallexample
23544 @end enumerate
23546 @node Bound member functions
23547 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23548 @cindex pmf
23549 @cindex pointer to member function
23550 @cindex bound pointer to member function
23552 In C++, pointer to member functions (PMFs) are implemented using a wide
23553 pointer of sorts to handle all the possible call mechanisms; the PMF
23554 needs to store information about how to adjust the @samp{this} pointer,
23555 and if the function pointed to is virtual, where to find the vtable, and
23556 where in the vtable to look for the member function.  If you are using
23557 PMFs in an inner loop, you should really reconsider that decision.  If
23558 that is not an option, you can extract the pointer to the function that
23559 would be called for a given object/PMF pair and call it directly inside
23560 the inner loop, to save a bit of time.
23562 Note that you still pay the penalty for the call through a
23563 function pointer; on most modern architectures, such a call defeats the
23564 branch prediction features of the CPU@.  This is also true of normal
23565 virtual function calls.
23567 The syntax for this extension is
23569 @smallexample
23570 extern A a;
23571 extern int (A::*fp)();
23572 typedef int (*fptr)(A *);
23574 fptr p = (fptr)(a.*fp);
23575 @end smallexample
23577 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23578 no object is needed to obtain the address of the function.  They can be
23579 converted to function pointers directly:
23581 @smallexample
23582 fptr p1 = (fptr)(&A::foo);
23583 @end smallexample
23585 @opindex Wno-pmf-conversions
23586 You must specify @option{-Wno-pmf-conversions} to use this extension.
23588 @node C++ Attributes
23589 @section C++-Specific Variable, Function, and Type Attributes
23591 Some attributes only make sense for C++ programs.
23593 @table @code
23594 @item abi_tag ("@var{tag}", ...)
23595 @cindex @code{abi_tag} function attribute
23596 @cindex @code{abi_tag} variable attribute
23597 @cindex @code{abi_tag} type attribute
23598 The @code{abi_tag} attribute can be applied to a function, variable, or class
23599 declaration.  It modifies the mangled name of the entity to
23600 incorporate the tag name, in order to distinguish the function or
23601 class from an earlier version with a different ABI; perhaps the class
23602 has changed size, or the function has a different return type that is
23603 not encoded in the mangled name.
23605 The attribute can also be applied to an inline namespace, but does not
23606 affect the mangled name of the namespace; in this case it is only used
23607 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23608 variables.  Tagging inline namespaces is generally preferable to
23609 tagging individual declarations, but the latter is sometimes
23610 necessary, such as when only certain members of a class need to be
23611 tagged.
23613 The argument can be a list of strings of arbitrary length.  The
23614 strings are sorted on output, so the order of the list is
23615 unimportant.
23617 A redeclaration of an entity must not add new ABI tags,
23618 since doing so would change the mangled name.
23620 The ABI tags apply to a name, so all instantiations and
23621 specializations of a template have the same tags.  The attribute will
23622 be ignored if applied to an explicit specialization or instantiation.
23624 The @option{-Wabi-tag} flag enables a warning about a class which does
23625 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23626 that needs to coexist with an earlier ABI, using this option can help
23627 to find all affected types that need to be tagged.
23629 When a type involving an ABI tag is used as the type of a variable or
23630 return type of a function where that tag is not already present in the
23631 signature of the function, the tag is automatically applied to the
23632 variable or function.  @option{-Wabi-tag} also warns about this
23633 situation; this warning can be avoided by explicitly tagging the
23634 variable or function or moving it into a tagged inline namespace.
23636 @item init_priority (@var{priority})
23637 @cindex @code{init_priority} variable attribute
23639 In Standard C++, objects defined at namespace scope are guaranteed to be
23640 initialized in an order in strict accordance with that of their definitions
23641 @emph{in a given translation unit}.  No guarantee is made for initializations
23642 across translation units.  However, GNU C++ allows users to control the
23643 order of initialization of objects defined at namespace scope with the
23644 @code{init_priority} attribute by specifying a relative @var{priority},
23645 a constant integral expression currently bounded between 101 and 65535
23646 inclusive.  Lower numbers indicate a higher priority.
23648 In the following example, @code{A} would normally be created before
23649 @code{B}, but the @code{init_priority} attribute reverses that order:
23651 @smallexample
23652 Some_Class  A  __attribute__ ((init_priority (2000)));
23653 Some_Class  B  __attribute__ ((init_priority (543)));
23654 @end smallexample
23656 @noindent
23657 Note that the particular values of @var{priority} do not matter; only their
23658 relative ordering.
23660 @item warn_unused
23661 @cindex @code{warn_unused} type attribute
23663 For C++ types with non-trivial constructors and/or destructors it is
23664 impossible for the compiler to determine whether a variable of this
23665 type is truly unused if it is not referenced. This type attribute
23666 informs the compiler that variables of this type should be warned
23667 about if they appear to be unused, just like variables of fundamental
23668 types.
23670 This attribute is appropriate for types which just represent a value,
23671 such as @code{std::string}; it is not appropriate for types which
23672 control a resource, such as @code{std::lock_guard}.
23674 This attribute is also accepted in C, but it is unnecessary because C
23675 does not have constructors or destructors.
23677 @end table
23679 @node Function Multiversioning
23680 @section Function Multiversioning
23681 @cindex function versions
23683 With the GNU C++ front end, for x86 targets, you may specify multiple
23684 versions of a function, where each function is specialized for a
23685 specific target feature.  At runtime, the appropriate version of the
23686 function is automatically executed depending on the characteristics of
23687 the execution platform.  Here is an example.
23689 @smallexample
23690 __attribute__ ((target ("default")))
23691 int foo ()
23693   // The default version of foo.
23694   return 0;
23697 __attribute__ ((target ("sse4.2")))
23698 int foo ()
23700   // foo version for SSE4.2
23701   return 1;
23704 __attribute__ ((target ("arch=atom")))
23705 int foo ()
23707   // foo version for the Intel ATOM processor
23708   return 2;
23711 __attribute__ ((target ("arch=amdfam10")))
23712 int foo ()
23714   // foo version for the AMD Family 0x10 processors.
23715   return 3;
23718 int main ()
23720   int (*p)() = &foo;
23721   assert ((*p) () == foo ());
23722   return 0;
23724 @end smallexample
23726 In the above example, four versions of function foo are created. The
23727 first version of foo with the target attribute "default" is the default
23728 version.  This version gets executed when no other target specific
23729 version qualifies for execution on a particular platform. A new version
23730 of foo is created by using the same function signature but with a
23731 different target string.  Function foo is called or a pointer to it is
23732 taken just like a regular function.  GCC takes care of doing the
23733 dispatching to call the right version at runtime.  Refer to the
23734 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23735 Function Multiversioning} for more details.
23737 @node Type Traits
23738 @section Type Traits
23740 The C++ front end implements syntactic extensions that allow
23741 compile-time determination of 
23742 various characteristics of a type (or of a
23743 pair of types).
23745 @table @code
23746 @item __has_nothrow_assign (type)
23747 If @code{type} is const qualified or is a reference type then the trait is
23748 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23749 is true, else if @code{type} is a cv class or union type with copy assignment
23750 operators that are known not to throw an exception then the trait is true,
23751 else it is false.  Requires: @code{type} shall be a complete type,
23752 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23754 @item __has_nothrow_copy (type)
23755 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23756 @code{type} is a cv class or union type with copy constructors that
23757 are known not to throw an exception then the trait is true, else it is false.
23758 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23759 @code{void}, or an array of unknown bound.
23761 @item __has_nothrow_constructor (type)
23762 If @code{__has_trivial_constructor (type)} is true then the trait is
23763 true, else if @code{type} is a cv class or union type (or array
23764 thereof) with a default constructor that is known not to throw an
23765 exception then the trait is true, else it is false.  Requires:
23766 @code{type} shall be a complete type, (possibly cv-qualified)
23767 @code{void}, or an array of unknown bound.
23769 @item __has_trivial_assign (type)
23770 If @code{type} is const qualified or is a reference type then the trait is
23771 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
23772 true, else if @code{type} is a cv class or union type with a trivial
23773 copy assignment ([class.copy]) then the trait is true, else it is
23774 false.  Requires: @code{type} shall be a complete type, (possibly
23775 cv-qualified) @code{void}, or an array of unknown bound.
23777 @item __has_trivial_copy (type)
23778 If @code{__is_pod (type)} is true or @code{type} is a reference type
23779 then the trait is true, else if @code{type} is a cv class or union type
23780 with a trivial copy constructor ([class.copy]) then the trait
23781 is true, else it is false.  Requires: @code{type} shall be a complete
23782 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23784 @item __has_trivial_constructor (type)
23785 If @code{__is_pod (type)} is true then the trait is true, else if
23786 @code{type} is a cv class or union type (or array thereof) with a
23787 trivial default constructor ([class.ctor]) then the trait is true,
23788 else it is false.  Requires: @code{type} shall be a complete
23789 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23791 @item __has_trivial_destructor (type)
23792 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23793 the trait is true, else if @code{type} is a cv class or union type (or
23794 array thereof) with a trivial destructor ([class.dtor]) then the trait
23795 is true, else it is false.  Requires: @code{type} shall be a complete
23796 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23798 @item __has_virtual_destructor (type)
23799 If @code{type} is a class type with a virtual destructor
23800 ([class.dtor]) then the trait is true, else it is false.  Requires:
23801 @code{type} shall be a complete type, (possibly cv-qualified)
23802 @code{void}, or an array of unknown bound.
23804 @item __is_abstract (type)
23805 If @code{type} is an abstract class ([class.abstract]) then the trait
23806 is true, else it is false.  Requires: @code{type} shall be a complete
23807 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23809 @item __is_base_of (base_type, derived_type)
23810 If @code{base_type} is a base class of @code{derived_type}
23811 ([class.derived]) then the trait is true, otherwise it is false.
23812 Top-level cv qualifications of @code{base_type} and
23813 @code{derived_type} are ignored.  For the purposes of this trait, a
23814 class type is considered is own base.  Requires: if @code{__is_class
23815 (base_type)} and @code{__is_class (derived_type)} are true and
23816 @code{base_type} and @code{derived_type} are not the same type
23817 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23818 type.  A diagnostic is produced if this requirement is not met.
23820 @item __is_class (type)
23821 If @code{type} is a cv class type, and not a union type
23822 ([basic.compound]) the trait is true, else it is false.
23824 @item __is_empty (type)
23825 If @code{__is_class (type)} is false then the trait is false.
23826 Otherwise @code{type} is considered empty if and only if: @code{type}
23827 has no non-static data members, or all non-static data members, if
23828 any, are bit-fields of length 0, and @code{type} has no virtual
23829 members, and @code{type} has no virtual base classes, and @code{type}
23830 has no base classes @code{base_type} for which
23831 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
23832 be a complete type, (possibly cv-qualified) @code{void}, or an array
23833 of unknown bound.
23835 @item __is_enum (type)
23836 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23837 true, else it is false.
23839 @item __is_literal_type (type)
23840 If @code{type} is a literal type ([basic.types]) the trait is
23841 true, else it is false.  Requires: @code{type} shall be a complete type,
23842 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23844 @item __is_pod (type)
23845 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23846 else it is false.  Requires: @code{type} shall be a complete type,
23847 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23849 @item __is_polymorphic (type)
23850 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23851 is true, else it is false.  Requires: @code{type} shall be a complete
23852 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23854 @item __is_standard_layout (type)
23855 If @code{type} is a standard-layout type ([basic.types]) the trait is
23856 true, else it is false.  Requires: @code{type} shall be a complete
23857 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23859 @item __is_trivial (type)
23860 If @code{type} is a trivial type ([basic.types]) the trait is
23861 true, else it is false.  Requires: @code{type} shall be a complete
23862 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23864 @item __is_union (type)
23865 If @code{type} is a cv union type ([basic.compound]) the trait is
23866 true, else it is false.
23868 @item __underlying_type (type)
23869 The underlying type of @code{type}.  Requires: @code{type} shall be
23870 an enumeration type ([dcl.enum]).
23872 @item __integer_pack (length)
23873 When used as the pattern of a pack expansion within a template
23874 definition, expands to a template argument pack containing integers
23875 from @code{0} to @code{length-1}.  This is provided for efficient
23876 implementation of @code{std::make_integer_sequence}.
23878 @end table
23881 @node C++ Concepts
23882 @section C++ Concepts
23884 C++ concepts provide much-improved support for generic programming. In
23885 particular, they allow the specification of constraints on template arguments.
23886 The constraints are used to extend the usual overloading and partial
23887 specialization capabilities of the language, allowing generic data structures
23888 and algorithms to be ``refined'' based on their properties rather than their
23889 type names.
23891 The following keywords are reserved for concepts.
23893 @table @code
23894 @item assumes
23895 States an expression as an assumption, and if possible, verifies that the
23896 assumption is valid. For example, @code{assume(n > 0)}.
23898 @item axiom
23899 Introduces an axiom definition. Axioms introduce requirements on values.
23901 @item forall
23902 Introduces a universally quantified object in an axiom. For example,
23903 @code{forall (int n) n + 0 == n}).
23905 @item concept
23906 Introduces a concept definition. Concepts are sets of syntactic and semantic
23907 requirements on types and their values.
23909 @item requires
23910 Introduces constraints on template arguments or requirements for a member
23911 function of a class template.
23913 @end table
23915 The front end also exposes a number of internal mechanism that can be used
23916 to simplify the writing of type traits. Note that some of these traits are
23917 likely to be removed in the future.
23919 @table @code
23920 @item __is_same (type1, type2)
23921 A binary type trait: true whenever the type arguments are the same.
23923 @end table
23926 @node Deprecated Features
23927 @section Deprecated Features
23929 In the past, the GNU C++ compiler was extended to experiment with new
23930 features, at a time when the C++ language was still evolving.  Now that
23931 the C++ standard is complete, some of those features are superseded by
23932 superior alternatives.  Using the old features might cause a warning in
23933 some cases that the feature will be dropped in the future.  In other
23934 cases, the feature might be gone already.
23936 G++ allows a virtual function returning @samp{void *} to be overridden
23937 by one returning a different pointer type.  This extension to the
23938 covariant return type rules is now deprecated and will be removed from a
23939 future version.
23941 The use of default arguments in function pointers, function typedefs
23942 and other places where they are not permitted by the standard is
23943 deprecated and will be removed from a future version of G++.
23945 G++ allows floating-point literals to appear in integral constant expressions,
23946 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23947 This extension is deprecated and will be removed from a future version.
23949 G++ allows static data members of const floating-point type to be declared
23950 with an initializer in a class definition. The standard only allows
23951 initializers for static members of const integral types and const
23952 enumeration types so this extension has been deprecated and will be removed
23953 from a future version.
23955 G++ allows attributes to follow a parenthesized direct initializer,
23956 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
23957 has been ignored since G++ 3.3 and is deprecated.
23959 G++ allows anonymous structs and unions to have members that are not
23960 public non-static data members (i.e.@: fields).  These extensions are
23961 deprecated.
23963 @node Backwards Compatibility
23964 @section Backwards Compatibility
23965 @cindex Backwards Compatibility
23966 @cindex ARM [Annotated C++ Reference Manual]
23968 Now that there is a definitive ISO standard C++, G++ has a specification
23969 to adhere to.  The C++ language evolved over time, and features that
23970 used to be acceptable in previous drafts of the standard, such as the ARM
23971 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
23972 compilation of C++ written to such drafts, G++ contains some backwards
23973 compatibilities.  @emph{All such backwards compatibility features are
23974 liable to disappear in future versions of G++.} They should be considered
23975 deprecated.   @xref{Deprecated Features}.
23977 @table @code
23979 @item Implicit C language
23980 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23981 scope to set the language.  On such systems, all system header files are
23982 implicitly scoped inside a C language scope.  Such headers must
23983 correctly prototype function argument types, there is no leeway for
23984 @code{()} to indicate an unspecified set of arguments.
23986 @end table
23988 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
23989 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr