[doc][13/14] Document AArch64 target attributes and pragmas
[official-gcc.git] / gcc / doc / extend.texi
blob2a47943574e4012e0150060edd9a9d5c257e9123
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax::    Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments::        C++ comments are recognized.
66 * Dollar Signs::        Dollar sign is allowed in identifiers.
67 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
68 * Alignment::           Inquiring about the alignment of a type or variable.
69 * Inline::              Defining inline functions (as fast as macros).
70 * Volatiles::           What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums::    @code{enum foo;}, with details to follow.
74 * Function Names::      Printable strings which are the name of the current
75                         function.
76 * Return Address::      Getting the return or frame address of a function.
77 * Vector Extensions::   Using vector instructions through built-in functions.
78 * Offsetof::            Special syntax for implementing @code{offsetof}.
79 * __sync Builtins::     Legacy built-in functions for atomic memory access.
80 * __atomic Builtins::   Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82                         arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85                         checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
88 * Other Builtins::      Other built-in functions.
89 * Target Builtins::     Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas::             Pragmas accepted by GCC.
92 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
93 * Thread-Local::        Per-thread variables.
94 * Binary constants::    Binary constants using the @samp{0b} prefix.
95 @end menu
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@.  This allows you to use loops, switches, and local variables
108 within an expression.
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces.  For
112 example:
114 @smallexample
115 (@{ int y = foo (); int z;
116    if (y > 0) z = y;
117    else z = - y;
118    z; @})
119 @end smallexample
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct.  (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once).  For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects.  In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
147 @smallexample
148 #define maxint(a,b) \
149   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression.  For instance, if @code{A} is a class, then
163 @smallexample
164         A a;
166         (@{a;@}).Foo ()
167 @end smallexample
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end.  This makes statement
177 expressions inside macros slightly different from function calls.  In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call.  In the statement expression case they are destroyed during
181 the statement expression.  For instance,
183 @smallexample
184 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
187 void foo ()
189   macro (X ());
190   function (X ());
192 @end smallexample
194 @noindent
195 has different places where temporaries are destroyed.  For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}.  In the @code{function} case that
198 temporary is destroyed when the function returns.
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++.  (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted.  Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression.  In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression.  For example,
220 @smallexample
221   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}.  If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope.  A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
239 A local label declaration looks like this:
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
245 @noindent
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself.  You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
259 The local label feature is useful for complex macros.  If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them.  However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function.  A
264 local label avoids this problem.  For example:
266 @smallexample
267 #define SEARCH(value, array, target)              \
268 do @{                                              \
269   __label__ found;                                \
270   typeof (target) _SEARCH_target = (target);      \
271   typeof (*(array)) *_SEARCH_array = (array);     \
272   int i, j;                                       \
273   int value;                                      \
274   for (i = 0; i < max; i++)                       \
275     for (j = 0; j < max; j++)                     \
276       if (_SEARCH_array[i][j] == _SEARCH_target)  \
277         @{ (value) = i; goto found; @}              \
278   (value) = -1;                                   \
279  found:;                                          \
280 @} while (0)
281 @end smallexample
283 This could also be written using a statement expression:
285 @smallexample
286 #define SEARCH(array, target)                     \
287 (@{                                                \
288   __label__ found;                                \
289   typeof (target) _SEARCH_target = (target);      \
290   typeof (*(array)) *_SEARCH_array = (array);     \
291   int i, j;                                       \
292   int value;                                      \
293   for (i = 0; i < max; i++)                       \
294     for (j = 0; j < max; j++)                     \
295       if (_SEARCH_array[i][j] == _SEARCH_target)  \
296         @{ value = i; goto found; @}                \
297   value = -1;                                     \
298  found:                                           \
299   value;                                          \
301 @end smallexample
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any.  @xref{Nested Functions}, for details.
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}.  The
315 value has type @code{void *}.  This value is a constant and can be used
316 wherever a constant of that type is valid.  For example:
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
324 To use these values, you need to be able to jump to one.  This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}.  For example,
330 @smallexample
331 goto *ptr;
332 @end smallexample
334 @noindent
335 Any expression of type @code{void *} is allowed.
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
344 @noindent
345 Then you can select a label with indexing, like this:
347 @smallexample
348 goto *array[i];
349 @end smallexample
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement.  The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen.  The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
369 An alternate way to write the above example is
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373                              &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned.  If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning.  If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
405 @smallexample
406 @group
407 foo (double a, double b)
409   double square (double z) @{ return z * z; @}
411   return square (a) + square (b);
413 @end group
414 @end smallexample
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition.  This is
418 called @dfn{lexical scoping}.  For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
425   int access (int *array, int index)
426     @{ return array[index + offset]; @}
427   int i;
428   /* @r{@dots{}} */
429   for (i = 0; i < size; i++)
430     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
432 @end group
433 @end smallexample
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
442 @smallexample
443 hack (int *array, int size)
445   void store (int index, int value)
446     @{ array[index] = value; @}
448   intermediate (store, size);
450 @end smallexample
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument.  If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose.  If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk.  If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}.  This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}).  Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well.  Here is an example:
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
481   __label__ failure;
482   int access (int *array, int index)
483     @{
484       if (index > size)
485         goto failure;
486       return array[index + offset];
487     @}
488   int i;
489   /* @r{@dots{}} */
490   for (i = 0; i < size; i++)
491     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492   /* @r{@dots{}} */
493   return 0;
495  /* @r{Control comes here from @code{access}
496     if it detects an error.}  */
497  failure:
498   return -1;
500 @end group
501 @end smallexample
503 A nested function always has no linkage.  Declaring one with
504 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
508 @smallexample
509 bar (int *array, int offset, int size)
511   __label__ failure;
512   auto int access (int *, int);
513   /* @r{@dots{}} */
514   int access (int *array, int index)
515     @{
516       if (index > size)
517         goto failure;
518       return array[index + offset];
519     @}
520   /* @r{@dots{}} */
522 @end smallexample
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language.  It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack.  Then it returns the
552 address of that block.
553 @end deftypefn
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}.  The data
566 is saved in a block of memory allocated on the stack.
568 It is not always simple to compute the proper value for @var{size}.  The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function.  You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function.  It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments.  This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable.  For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
595   int r = fprintf (f, "myprintf: ");
596   if (r < 0)
597     return r;
598   int s = fprintf (f, format, __builtin_va_arg_pack ());
599   if (s < 0)
600     return s;
601   return r + s;
603 @end smallexample
604 @end deftypefn
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function.  It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
619   if (__builtin_va_arg_pack_len () > 1)
620     warn_open_too_many_arguments ();
622   if (__builtin_constant_p (oflag))
623     @{
624       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625         @{
626           warn_open_missing_mode ();
627           return __open_2 (path, oflag);
628         @}
629       return open (path, oflag, __builtin_va_arg_pack ());
630     @}
632   if (__builtin_va_arg_pack_len () < 1)
633     return __open_2 (path, oflag);
635   return open (path, oflag, __builtin_va_arg_pack ());
637 #endif
638 @end smallexample
639 @end deftypefn
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type.  Here is an example with an expression:
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
662 Here is an example with a typename as the argument:
664 @smallexample
665 typeof (int *)
666 @end smallexample
668 @noindent
669 Here the type described is that of pointers to @code{int}.
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used.  For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
689 @smallexample
690 #define max(a,b) \
691   (@{ typeof (a) _a = (a); \
692       typeof (b) _b = (b); \
693     _a > _b ? _a : _b; @})
694 @end smallexample
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}.  Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
709 @noindent
710 Some more examples of the use of @code{typeof}:
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
720 @item
721 This declares @code{y} as an array of such values.
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
727 @item
728 This declares @code{y} as an array of pointers to characters:
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
734 @noindent
735 It is equivalent to the following traditional C declaration:
737 @smallexample
738 char *y[4];
739 @end smallexample
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
744 @smallexample
745 #define pointer(T)  typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
749 @noindent
750 Now the declaration can be rewritten this way:
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}.  In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer.  (In C++, you should use C++11
767 @code{auto} for this purpose.)  Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
770 @smallexample
771 #define max(a,b) \
772   (@{ __auto_type _a = (a); \
773       __auto_type _b = (b); \
774     _a > _b ? _a : _b; @})
775 @end smallexample
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro.  This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
798 The middle operand in a conditional expression may be omitted.  Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
802 Therefore, the expression
804 @smallexample
805 x ? : y
806 @end smallexample
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
812 This example is perfectly equivalent to
814 @smallexample
815 x ? x : y
816 @end smallexample
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful.  When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect.  Then repeating
824 the operand in the middle would perform the side effect twice.  Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer.  To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer.  To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines.  Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction.  Division and shifts are open-coded only on machines that
860 provide special support.  The operations that are not open-coded use
861 special library routines that come with GCC@.
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes.  If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}.  The best way to avoid such problems is to use prototypes.
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++.  GCC also supports complex integer data
879 types which are not part of ISO C99.  You can declare complex types
880 using the keyword @code{_Complex}.  As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}.  Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant.  This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
904 extract the imaginary part.  This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type.  This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
920 debug info format can represent this, so use of DWARF 2 is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}.  You can
925 examine and set these two fictitious variables with your debugger.
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{w} floating point suffix
933 @cindex @code{q} floating point suffix
934 @cindex @code{W} floating point suffix
935 @cindex @code{Q} floating point suffix
937 As an extension, GNU C supports additional floating
938 types, @code{__float80} and @code{__float128} to support 80-bit
939 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
940 Support for additional types includes the arithmetic operators:
941 add, subtract, multiply, divide; unary arithmetic operators;
942 relational operators; equality operators; and conversions to and from
943 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
944 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
945 for @code{_float128}.  You can declare complex types using the
946 corresponding internal complex type, @code{XCmode} for @code{__float80}
947 type and @code{TCmode} for @code{__float128} type:
949 @smallexample
950 typedef _Complex float __attribute__((mode(TC))) _Complex128;
951 typedef _Complex float __attribute__((mode(XC))) _Complex80;
952 @end smallexample
954 Not all targets support additional floating-point types.  @code{__float80}
955 and @code{__float128} types are supported on x86 and IA-64 targets.
956 The @code{__float128} type is supported on hppa HP-UX targets.
958 @node Half-Precision
959 @section Half-Precision Floating Point
960 @cindex half-precision floating point
961 @cindex @code{__fp16} data type
963 On ARM targets, GCC supports half-precision (16-bit) floating point via
964 the @code{__fp16} type.  You must enable this type explicitly
965 with the @option{-mfp16-format} command-line option in order to use it.
967 ARM supports two incompatible representations for half-precision
968 floating-point values.  You must choose one of the representations and
969 use it consistently in your program.
971 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
972 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
973 There are 11 bits of significand precision, approximately 3
974 decimal digits.
976 Specifying @option{-mfp16-format=alternative} selects the ARM
977 alternative format.  This representation is similar to the IEEE
978 format, but does not support infinities or NaNs.  Instead, the range
979 of exponents is extended, so that this format can represent normalized
980 values in the range of @math{2^{-14}} to 131008.
982 The @code{__fp16} type is a storage format only.  For purposes
983 of arithmetic and other operations, @code{__fp16} values in C or C++
984 expressions are automatically promoted to @code{float}.  In addition,
985 you cannot declare a function with a return value or parameters
986 of type @code{__fp16}.
988 Note that conversions from @code{double} to @code{__fp16}
989 involve an intermediate conversion to @code{float}.  Because
990 of rounding, this can sometimes produce a different result than a
991 direct conversion.
993 ARM provides hardware support for conversions between
994 @code{__fp16} and @code{float} values
995 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
996 code using these hardware instructions if you compile with
997 options to select an FPU that provides them;
998 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
999 in addition to the @option{-mfp16-format} option to select
1000 a half-precision format.
1002 Language-level support for the @code{__fp16} data type is
1003 independent of whether GCC generates code using hardware floating-point
1004 instructions.  In cases where hardware support is not specified, GCC
1005 implements conversions between @code{__fp16} and @code{float} values
1006 as library calls.
1008 @node Decimal Float
1009 @section Decimal Floating Types
1010 @cindex decimal floating types
1011 @cindex @code{_Decimal32} data type
1012 @cindex @code{_Decimal64} data type
1013 @cindex @code{_Decimal128} data type
1014 @cindex @code{df} integer suffix
1015 @cindex @code{dd} integer suffix
1016 @cindex @code{dl} integer suffix
1017 @cindex @code{DF} integer suffix
1018 @cindex @code{DD} integer suffix
1019 @cindex @code{DL} integer suffix
1021 As an extension, GNU C supports decimal floating types as
1022 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1023 floating types in GCC will evolve as the draft technical report changes.
1024 Calling conventions for any target might also change.  Not all targets
1025 support decimal floating types.
1027 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1028 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1029 @code{float}, @code{double}, and @code{long double} whose radix is not
1030 specified by the C standard but is usually two.
1032 Support for decimal floating types includes the arithmetic operators
1033 add, subtract, multiply, divide; unary arithmetic operators;
1034 relational operators; equality operators; and conversions to and from
1035 integer and other floating types.  Use a suffix @samp{df} or
1036 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1037 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1038 @code{_Decimal128}.
1040 GCC support of decimal float as specified by the draft technical report
1041 is incomplete:
1043 @itemize @bullet
1044 @item
1045 When the value of a decimal floating type cannot be represented in the
1046 integer type to which it is being converted, the result is undefined
1047 rather than the result value specified by the draft technical report.
1049 @item
1050 GCC does not provide the C library functionality associated with
1051 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1052 @file{wchar.h}, which must come from a separate C library implementation.
1053 Because of this the GNU C compiler does not define macro
1054 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1055 the technical report.
1056 @end itemize
1058 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1059 are supported by the DWARF 2 debug information format.
1061 @node Hex Floats
1062 @section Hex Floats
1063 @cindex hex floats
1065 ISO C99 supports floating-point numbers written not only in the usual
1066 decimal notation, such as @code{1.55e1}, but also numbers such as
1067 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1068 supports this in C90 mode (except in some cases when strictly
1069 conforming) and in C++.  In that format the
1070 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1071 mandatory.  The exponent is a decimal number that indicates the power of
1072 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1073 @tex
1074 $1 {15\over16}$,
1075 @end tex
1076 @ifnottex
1077 1 15/16,
1078 @end ifnottex
1079 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1080 is the same as @code{1.55e1}.
1082 Unlike for floating-point numbers in the decimal notation the exponent
1083 is always required in the hexadecimal notation.  Otherwise the compiler
1084 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1085 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1086 extension for floating-point constants of type @code{float}.
1088 @node Fixed-Point
1089 @section Fixed-Point Types
1090 @cindex fixed-point types
1091 @cindex @code{_Fract} data type
1092 @cindex @code{_Accum} data type
1093 @cindex @code{_Sat} data type
1094 @cindex @code{hr} fixed-suffix
1095 @cindex @code{r} fixed-suffix
1096 @cindex @code{lr} fixed-suffix
1097 @cindex @code{llr} fixed-suffix
1098 @cindex @code{uhr} fixed-suffix
1099 @cindex @code{ur} fixed-suffix
1100 @cindex @code{ulr} fixed-suffix
1101 @cindex @code{ullr} fixed-suffix
1102 @cindex @code{hk} fixed-suffix
1103 @cindex @code{k} fixed-suffix
1104 @cindex @code{lk} fixed-suffix
1105 @cindex @code{llk} fixed-suffix
1106 @cindex @code{uhk} fixed-suffix
1107 @cindex @code{uk} fixed-suffix
1108 @cindex @code{ulk} fixed-suffix
1109 @cindex @code{ullk} fixed-suffix
1110 @cindex @code{HR} fixed-suffix
1111 @cindex @code{R} fixed-suffix
1112 @cindex @code{LR} fixed-suffix
1113 @cindex @code{LLR} fixed-suffix
1114 @cindex @code{UHR} fixed-suffix
1115 @cindex @code{UR} fixed-suffix
1116 @cindex @code{ULR} fixed-suffix
1117 @cindex @code{ULLR} fixed-suffix
1118 @cindex @code{HK} fixed-suffix
1119 @cindex @code{K} fixed-suffix
1120 @cindex @code{LK} fixed-suffix
1121 @cindex @code{LLK} fixed-suffix
1122 @cindex @code{UHK} fixed-suffix
1123 @cindex @code{UK} fixed-suffix
1124 @cindex @code{ULK} fixed-suffix
1125 @cindex @code{ULLK} fixed-suffix
1127 As an extension, GNU C supports fixed-point types as
1128 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1129 types in GCC will evolve as the draft technical report changes.
1130 Calling conventions for any target might also change.  Not all targets
1131 support fixed-point types.
1133 The fixed-point types are
1134 @code{short _Fract},
1135 @code{_Fract},
1136 @code{long _Fract},
1137 @code{long long _Fract},
1138 @code{unsigned short _Fract},
1139 @code{unsigned _Fract},
1140 @code{unsigned long _Fract},
1141 @code{unsigned long long _Fract},
1142 @code{_Sat short _Fract},
1143 @code{_Sat _Fract},
1144 @code{_Sat long _Fract},
1145 @code{_Sat long long _Fract},
1146 @code{_Sat unsigned short _Fract},
1147 @code{_Sat unsigned _Fract},
1148 @code{_Sat unsigned long _Fract},
1149 @code{_Sat unsigned long long _Fract},
1150 @code{short _Accum},
1151 @code{_Accum},
1152 @code{long _Accum},
1153 @code{long long _Accum},
1154 @code{unsigned short _Accum},
1155 @code{unsigned _Accum},
1156 @code{unsigned long _Accum},
1157 @code{unsigned long long _Accum},
1158 @code{_Sat short _Accum},
1159 @code{_Sat _Accum},
1160 @code{_Sat long _Accum},
1161 @code{_Sat long long _Accum},
1162 @code{_Sat unsigned short _Accum},
1163 @code{_Sat unsigned _Accum},
1164 @code{_Sat unsigned long _Accum},
1165 @code{_Sat unsigned long long _Accum}.
1167 Fixed-point data values contain fractional and optional integral parts.
1168 The format of fixed-point data varies and depends on the target machine.
1170 Support for fixed-point types includes:
1171 @itemize @bullet
1172 @item
1173 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1174 @item
1175 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1176 @item
1177 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1178 @item
1179 binary shift operators (@code{<<}, @code{>>})
1180 @item
1181 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1182 @item
1183 equality operators (@code{==}, @code{!=})
1184 @item
1185 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1186 @code{<<=}, @code{>>=})
1187 @item
1188 conversions to and from integer, floating-point, or fixed-point types
1189 @end itemize
1191 Use a suffix in a fixed-point literal constant:
1192 @itemize
1193 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1194 @code{_Sat short _Fract}
1195 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1196 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1197 @code{_Sat long _Fract}
1198 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1199 @code{_Sat long long _Fract}
1200 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1201 @code{_Sat unsigned short _Fract}
1202 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1203 @code{_Sat unsigned _Fract}
1204 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1205 @code{_Sat unsigned long _Fract}
1206 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1207 and @code{_Sat unsigned long long _Fract}
1208 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1209 @code{_Sat short _Accum}
1210 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1211 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1212 @code{_Sat long _Accum}
1213 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1214 @code{_Sat long long _Accum}
1215 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1216 @code{_Sat unsigned short _Accum}
1217 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1218 @code{_Sat unsigned _Accum}
1219 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1220 @code{_Sat unsigned long _Accum}
1221 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1222 and @code{_Sat unsigned long long _Accum}
1223 @end itemize
1225 GCC support of fixed-point types as specified by the draft technical report
1226 is incomplete:
1228 @itemize @bullet
1229 @item
1230 Pragmas to control overflow and rounding behaviors are not implemented.
1231 @end itemize
1233 Fixed-point types are supported by the DWARF 2 debug information format.
1235 @node Named Address Spaces
1236 @section Named Address Spaces
1237 @cindex Named Address Spaces
1239 As an extension, GNU C supports named address spaces as
1240 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1241 address spaces in GCC will evolve as the draft technical report
1242 changes.  Calling conventions for any target might also change.  At
1243 present, only the AVR, SPU, M32C, and RL78 targets support address
1244 spaces other than the generic address space.
1246 Address space identifiers may be used exactly like any other C type
1247 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1248 document for more details.
1250 @anchor{AVR Named Address Spaces}
1251 @subsection AVR Named Address Spaces
1253 On the AVR target, there are several address spaces that can be used
1254 in order to put read-only data into the flash memory and access that
1255 data by means of the special instructions @code{LPM} or @code{ELPM}
1256 needed to read from flash.
1258 Per default, any data including read-only data is located in RAM
1259 (the generic address space) so that non-generic address spaces are
1260 needed to locate read-only data in flash memory
1261 @emph{and} to generate the right instructions to access this data
1262 without using (inline) assembler code.
1264 @table @code
1265 @item __flash
1266 @cindex @code{__flash} AVR Named Address Spaces
1267 The @code{__flash} qualifier locates data in the
1268 @code{.progmem.data} section. Data is read using the @code{LPM}
1269 instruction. Pointers to this address space are 16 bits wide.
1271 @item __flash1
1272 @itemx __flash2
1273 @itemx __flash3
1274 @itemx __flash4
1275 @itemx __flash5
1276 @cindex @code{__flash1} AVR Named Address Spaces
1277 @cindex @code{__flash2} AVR Named Address Spaces
1278 @cindex @code{__flash3} AVR Named Address Spaces
1279 @cindex @code{__flash4} AVR Named Address Spaces
1280 @cindex @code{__flash5} AVR Named Address Spaces
1281 These are 16-bit address spaces locating data in section
1282 @code{.progmem@var{N}.data} where @var{N} refers to
1283 address space @code{__flash@var{N}}.
1284 The compiler sets the @code{RAMPZ} segment register appropriately 
1285 before reading data by means of the @code{ELPM} instruction.
1287 @item __memx
1288 @cindex @code{__memx} AVR Named Address Spaces
1289 This is a 24-bit address space that linearizes flash and RAM:
1290 If the high bit of the address is set, data is read from
1291 RAM using the lower two bytes as RAM address.
1292 If the high bit of the address is clear, data is read from flash
1293 with @code{RAMPZ} set according to the high byte of the address.
1294 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1296 Objects in this address space are located in @code{.progmemx.data}.
1297 @end table
1299 @b{Example}
1301 @smallexample
1302 char my_read (const __flash char ** p)
1304     /* p is a pointer to RAM that points to a pointer to flash.
1305        The first indirection of p reads that flash pointer
1306        from RAM and the second indirection reads a char from this
1307        flash address.  */
1309     return **p;
1312 /* Locate array[] in flash memory */
1313 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1315 int i = 1;
1317 int main (void)
1319    /* Return 17 by reading from flash memory */
1320    return array[array[i]];
1322 @end smallexample
1324 @noindent
1325 For each named address space supported by avr-gcc there is an equally
1326 named but uppercase built-in macro defined. 
1327 The purpose is to facilitate testing if respective address space
1328 support is available or not:
1330 @smallexample
1331 #ifdef __FLASH
1332 const __flash int var = 1;
1334 int read_var (void)
1336     return var;
1338 #else
1339 #include <avr/pgmspace.h> /* From AVR-LibC */
1341 const int var PROGMEM = 1;
1343 int read_var (void)
1345     return (int) pgm_read_word (&var);
1347 #endif /* __FLASH */
1348 @end smallexample
1350 @noindent
1351 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1352 locates data in flash but
1353 accesses to these data read from generic address space, i.e.@:
1354 from RAM,
1355 so that you need special accessors like @code{pgm_read_byte}
1356 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1357 together with attribute @code{progmem}.
1359 @noindent
1360 @b{Limitations and caveats}
1362 @itemize
1363 @item
1364 Reading across the 64@tie{}KiB section boundary of
1365 the @code{__flash} or @code{__flash@var{N}} address spaces
1366 shows undefined behavior. The only address space that
1367 supports reading across the 64@tie{}KiB flash segment boundaries is
1368 @code{__memx}.
1370 @item
1371 If you use one of the @code{__flash@var{N}} address spaces
1372 you must arrange your linker script to locate the
1373 @code{.progmem@var{N}.data} sections according to your needs.
1375 @item
1376 Any data or pointers to the non-generic address spaces must
1377 be qualified as @code{const}, i.e.@: as read-only data.
1378 This still applies if the data in one of these address
1379 spaces like software version number or calibration lookup table are intended to
1380 be changed after load time by, say, a boot loader. In this case
1381 the right qualification is @code{const} @code{volatile} so that the compiler
1382 must not optimize away known values or insert them
1383 as immediates into operands of instructions.
1385 @item
1386 The following code initializes a variable @code{pfoo}
1387 located in static storage with a 24-bit address:
1388 @smallexample
1389 extern const __memx char foo;
1390 const __memx void *pfoo = &foo;
1391 @end smallexample
1393 @noindent
1394 Such code requires at least binutils 2.23, see
1395 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1397 @end itemize
1399 @subsection M32C Named Address Spaces
1400 @cindex @code{__far} M32C Named Address Spaces
1402 On the M32C target, with the R8C and M16C CPU variants, variables
1403 qualified with @code{__far} are accessed using 32-bit addresses in
1404 order to access memory beyond the first 64@tie{}Ki bytes.  If
1405 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1406 effect.
1408 @subsection RL78 Named Address Spaces
1409 @cindex @code{__far} RL78 Named Address Spaces
1411 On the RL78 target, variables qualified with @code{__far} are accessed
1412 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1413 addresses.  Non-far variables are assumed to appear in the topmost
1414 64@tie{}KiB of the address space.
1416 @subsection SPU Named Address Spaces
1417 @cindex @code{__ea} SPU Named Address Spaces
1419 On the SPU target variables may be declared as
1420 belonging to another address space by qualifying the type with the
1421 @code{__ea} address space identifier:
1423 @smallexample
1424 extern int __ea i;
1425 @end smallexample
1427 @noindent 
1428 The compiler generates special code to access the variable @code{i}.
1429 It may use runtime library
1430 support, or generate special machine instructions to access that address
1431 space.
1433 @node Zero Length
1434 @section Arrays of Length Zero
1435 @cindex arrays of length zero
1436 @cindex zero-length arrays
1437 @cindex length-zero arrays
1438 @cindex flexible array members
1440 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1441 last element of a structure that is really a header for a variable-length
1442 object:
1444 @smallexample
1445 struct line @{
1446   int length;
1447   char contents[0];
1450 struct line *thisline = (struct line *)
1451   malloc (sizeof (struct line) + this_length);
1452 thisline->length = this_length;
1453 @end smallexample
1455 In ISO C90, you would have to give @code{contents} a length of 1, which
1456 means either you waste space or complicate the argument to @code{malloc}.
1458 In ISO C99, you would use a @dfn{flexible array member}, which is
1459 slightly different in syntax and semantics:
1461 @itemize @bullet
1462 @item
1463 Flexible array members are written as @code{contents[]} without
1464 the @code{0}.
1466 @item
1467 Flexible array members have incomplete type, and so the @code{sizeof}
1468 operator may not be applied.  As a quirk of the original implementation
1469 of zero-length arrays, @code{sizeof} evaluates to zero.
1471 @item
1472 Flexible array members may only appear as the last member of a
1473 @code{struct} that is otherwise non-empty.
1475 @item
1476 A structure containing a flexible array member, or a union containing
1477 such a structure (possibly recursively), may not be a member of a
1478 structure or an element of an array.  (However, these uses are
1479 permitted by GCC as extensions.)
1480 @end itemize
1482 Non-empty initialization of zero-length
1483 arrays is treated like any case where there are more initializer
1484 elements than the array holds, in that a suitable warning about ``excess
1485 elements in array'' is given, and the excess elements (all of them, in
1486 this case) are ignored.
1488 GCC allows static initialization of flexible array members.
1489 This is equivalent to defining a new structure containing the original
1490 structure followed by an array of sufficient size to contain the data.
1491 E.g.@: in the following, @code{f1} is constructed as if it were declared
1492 like @code{f2}.
1494 @smallexample
1495 struct f1 @{
1496   int x; int y[];
1497 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1499 struct f2 @{
1500   struct f1 f1; int data[3];
1501 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1502 @end smallexample
1504 @noindent
1505 The convenience of this extension is that @code{f1} has the desired
1506 type, eliminating the need to consistently refer to @code{f2.f1}.
1508 This has symmetry with normal static arrays, in that an array of
1509 unknown size is also written with @code{[]}.
1511 Of course, this extension only makes sense if the extra data comes at
1512 the end of a top-level object, as otherwise we would be overwriting
1513 data at subsequent offsets.  To avoid undue complication and confusion
1514 with initialization of deeply nested arrays, we simply disallow any
1515 non-empty initialization except when the structure is the top-level
1516 object.  For example:
1518 @smallexample
1519 struct foo @{ int x; int y[]; @};
1520 struct bar @{ struct foo z; @};
1522 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1523 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1524 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1525 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1526 @end smallexample
1528 @node Empty Structures
1529 @section Structures with No Members
1530 @cindex empty structures
1531 @cindex zero-size structures
1533 GCC permits a C structure to have no members:
1535 @smallexample
1536 struct empty @{
1538 @end smallexample
1540 The structure has size zero.  In C++, empty structures are part
1541 of the language.  G++ treats empty structures as if they had a single
1542 member of type @code{char}.
1544 @node Variable Length
1545 @section Arrays of Variable Length
1546 @cindex variable-length arrays
1547 @cindex arrays of variable length
1548 @cindex VLAs
1550 Variable-length automatic arrays are allowed in ISO C99, and as an
1551 extension GCC accepts them in C90 mode and in C++.  These arrays are
1552 declared like any other automatic arrays, but with a length that is not
1553 a constant expression.  The storage is allocated at the point of
1554 declaration and deallocated when the block scope containing the declaration
1555 exits.  For
1556 example:
1558 @smallexample
1559 FILE *
1560 concat_fopen (char *s1, char *s2, char *mode)
1562   char str[strlen (s1) + strlen (s2) + 1];
1563   strcpy (str, s1);
1564   strcat (str, s2);
1565   return fopen (str, mode);
1567 @end smallexample
1569 @cindex scope of a variable length array
1570 @cindex variable-length array scope
1571 @cindex deallocating variable length arrays
1572 Jumping or breaking out of the scope of the array name deallocates the
1573 storage.  Jumping into the scope is not allowed; you get an error
1574 message for it.
1576 @cindex variable-length array in a structure
1577 As an extension, GCC accepts variable-length arrays as a member of
1578 a structure or a union.  For example:
1580 @smallexample
1581 void
1582 foo (int n)
1584   struct S @{ int x[n]; @};
1586 @end smallexample
1588 @cindex @code{alloca} vs variable-length arrays
1589 You can use the function @code{alloca} to get an effect much like
1590 variable-length arrays.  The function @code{alloca} is available in
1591 many other C implementations (but not in all).  On the other hand,
1592 variable-length arrays are more elegant.
1594 There are other differences between these two methods.  Space allocated
1595 with @code{alloca} exists until the containing @emph{function} returns.
1596 The space for a variable-length array is deallocated as soon as the array
1597 name's scope ends.  (If you use both variable-length arrays and
1598 @code{alloca} in the same function, deallocation of a variable-length array
1599 also deallocates anything more recently allocated with @code{alloca}.)
1601 You can also use variable-length arrays as arguments to functions:
1603 @smallexample
1604 struct entry
1605 tester (int len, char data[len][len])
1607   /* @r{@dots{}} */
1609 @end smallexample
1611 The length of an array is computed once when the storage is allocated
1612 and is remembered for the scope of the array in case you access it with
1613 @code{sizeof}.
1615 If you want to pass the array first and the length afterward, you can
1616 use a forward declaration in the parameter list---another GNU extension.
1618 @smallexample
1619 struct entry
1620 tester (int len; char data[len][len], int len)
1622   /* @r{@dots{}} */
1624 @end smallexample
1626 @cindex parameter forward declaration
1627 The @samp{int len} before the semicolon is a @dfn{parameter forward
1628 declaration}, and it serves the purpose of making the name @code{len}
1629 known when the declaration of @code{data} is parsed.
1631 You can write any number of such parameter forward declarations in the
1632 parameter list.  They can be separated by commas or semicolons, but the
1633 last one must end with a semicolon, which is followed by the ``real''
1634 parameter declarations.  Each forward declaration must match a ``real''
1635 declaration in parameter name and data type.  ISO C99 does not support
1636 parameter forward declarations.
1638 @node Variadic Macros
1639 @section Macros with a Variable Number of Arguments.
1640 @cindex variable number of arguments
1641 @cindex macro with variable arguments
1642 @cindex rest argument (in macro)
1643 @cindex variadic macros
1645 In the ISO C standard of 1999, a macro can be declared to accept a
1646 variable number of arguments much as a function can.  The syntax for
1647 defining the macro is similar to that of a function.  Here is an
1648 example:
1650 @smallexample
1651 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1652 @end smallexample
1654 @noindent
1655 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1656 such a macro, it represents the zero or more tokens until the closing
1657 parenthesis that ends the invocation, including any commas.  This set of
1658 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1659 wherever it appears.  See the CPP manual for more information.
1661 GCC has long supported variadic macros, and used a different syntax that
1662 allowed you to give a name to the variable arguments just like any other
1663 argument.  Here is an example:
1665 @smallexample
1666 #define debug(format, args...) fprintf (stderr, format, args)
1667 @end smallexample
1669 @noindent
1670 This is in all ways equivalent to the ISO C example above, but arguably
1671 more readable and descriptive.
1673 GNU CPP has two further variadic macro extensions, and permits them to
1674 be used with either of the above forms of macro definition.
1676 In standard C, you are not allowed to leave the variable argument out
1677 entirely; but you are allowed to pass an empty argument.  For example,
1678 this invocation is invalid in ISO C, because there is no comma after
1679 the string:
1681 @smallexample
1682 debug ("A message")
1683 @end smallexample
1685 GNU CPP permits you to completely omit the variable arguments in this
1686 way.  In the above examples, the compiler would complain, though since
1687 the expansion of the macro still has the extra comma after the format
1688 string.
1690 To help solve this problem, CPP behaves specially for variable arguments
1691 used with the token paste operator, @samp{##}.  If instead you write
1693 @smallexample
1694 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1695 @end smallexample
1697 @noindent
1698 and if the variable arguments are omitted or empty, the @samp{##}
1699 operator causes the preprocessor to remove the comma before it.  If you
1700 do provide some variable arguments in your macro invocation, GNU CPP
1701 does not complain about the paste operation and instead places the
1702 variable arguments after the comma.  Just like any other pasted macro
1703 argument, these arguments are not macro expanded.
1705 @node Escaped Newlines
1706 @section Slightly Looser Rules for Escaped Newlines
1707 @cindex escaped newlines
1708 @cindex newlines (escaped)
1710 The preprocessor treatment of escaped newlines is more relaxed 
1711 than that specified by the C90 standard, which requires the newline
1712 to immediately follow a backslash.  
1713 GCC's implementation allows whitespace in the form
1714 of spaces, horizontal and vertical tabs, and form feeds between the
1715 backslash and the subsequent newline.  The preprocessor issues a
1716 warning, but treats it as a valid escaped newline and combines the two
1717 lines to form a single logical line.  This works within comments and
1718 tokens, as well as between tokens.  Comments are @emph{not} treated as
1719 whitespace for the purposes of this relaxation, since they have not
1720 yet been replaced with spaces.
1722 @node Subscripting
1723 @section Non-Lvalue Arrays May Have Subscripts
1724 @cindex subscripting
1725 @cindex arrays, non-lvalue
1727 @cindex subscripting and function values
1728 In ISO C99, arrays that are not lvalues still decay to pointers, and
1729 may be subscripted, although they may not be modified or used after
1730 the next sequence point and the unary @samp{&} operator may not be
1731 applied to them.  As an extension, GNU C allows such arrays to be
1732 subscripted in C90 mode, though otherwise they do not decay to
1733 pointers outside C99 mode.  For example,
1734 this is valid in GNU C though not valid in C90:
1736 @smallexample
1737 @group
1738 struct foo @{int a[4];@};
1740 struct foo f();
1742 bar (int index)
1744   return f().a[index];
1746 @end group
1747 @end smallexample
1749 @node Pointer Arith
1750 @section Arithmetic on @code{void}- and Function-Pointers
1751 @cindex void pointers, arithmetic
1752 @cindex void, size of pointer to
1753 @cindex function pointers, arithmetic
1754 @cindex function, size of pointer to
1756 In GNU C, addition and subtraction operations are supported on pointers to
1757 @code{void} and on pointers to functions.  This is done by treating the
1758 size of a @code{void} or of a function as 1.
1760 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1761 and on function types, and returns 1.
1763 @opindex Wpointer-arith
1764 The option @option{-Wpointer-arith} requests a warning if these extensions
1765 are used.
1767 @node Pointers to Arrays
1768 @section Pointers to Arrays with Qualifiers Work as Expected
1769 @cindex pointers to arrays
1770 @cindex const qualifier
1772 In GNU C, pointers to arrays with qualifiers work similar to pointers
1773 to other qualified types. For example, a value of type @code{int (*)[5]}
1774 can be used to initialize a variable of type @code{const int (*)[5]}.
1775 These types are incompatible in ISO C because the @code{const} qualifier
1776 is formally attached to the element type of the array and not the
1777 array itself.
1779 @smallexample
1780 extern void
1781 transpose (int N, int M, double out[M][N], const double in[N][M]);
1782 double x[3][2];
1783 double y[2][3];
1784 @r{@dots{}}
1785 transpose(3, 2, y, x);
1786 @end smallexample
1788 @node Initializers
1789 @section Non-Constant Initializers
1790 @cindex initializers, non-constant
1791 @cindex non-constant initializers
1793 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1794 automatic variable are not required to be constant expressions in GNU C@.
1795 Here is an example of an initializer with run-time varying elements:
1797 @smallexample
1798 foo (float f, float g)
1800   float beat_freqs[2] = @{ f-g, f+g @};
1801   /* @r{@dots{}} */
1803 @end smallexample
1805 @node Compound Literals
1806 @section Compound Literals
1807 @cindex constructor expressions
1808 @cindex initializations in expressions
1809 @cindex structures, constructor expression
1810 @cindex expressions, constructor
1811 @cindex compound literals
1812 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1814 ISO C99 supports compound literals.  A compound literal looks like
1815 a cast containing an initializer.  Its value is an object of the
1816 type specified in the cast, containing the elements specified in
1817 the initializer; it is an lvalue.  As an extension, GCC supports
1818 compound literals in C90 mode and in C++, though the semantics are
1819 somewhat different in C++.
1821 Usually, the specified type is a structure.  Assume that
1822 @code{struct foo} and @code{structure} are declared as shown:
1824 @smallexample
1825 struct foo @{int a; char b[2];@} structure;
1826 @end smallexample
1828 @noindent
1829 Here is an example of constructing a @code{struct foo} with a compound literal:
1831 @smallexample
1832 structure = ((struct foo) @{x + y, 'a', 0@});
1833 @end smallexample
1835 @noindent
1836 This is equivalent to writing the following:
1838 @smallexample
1840   struct foo temp = @{x + y, 'a', 0@};
1841   structure = temp;
1843 @end smallexample
1845 You can also construct an array, though this is dangerous in C++, as
1846 explained below.  If all the elements of the compound literal are
1847 (made up of) simple constant expressions, suitable for use in
1848 initializers of objects of static storage duration, then the compound
1849 literal can be coerced to a pointer to its first element and used in
1850 such an initializer, as shown here:
1852 @smallexample
1853 char **foo = (char *[]) @{ "x", "y", "z" @};
1854 @end smallexample
1856 Compound literals for scalar types and union types are
1857 also allowed, but then the compound literal is equivalent
1858 to a cast.
1860 As a GNU extension, GCC allows initialization of objects with static storage
1861 duration by compound literals (which is not possible in ISO C99, because
1862 the initializer is not a constant).
1863 It is handled as if the object is initialized only with the bracket
1864 enclosed list if the types of the compound literal and the object match.
1865 The initializer list of the compound literal must be constant.
1866 If the object being initialized has array type of unknown size, the size is
1867 determined by compound literal size.
1869 @smallexample
1870 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1871 static int y[] = (int []) @{1, 2, 3@};
1872 static int z[] = (int [3]) @{1@};
1873 @end smallexample
1875 @noindent
1876 The above lines are equivalent to the following:
1877 @smallexample
1878 static struct foo x = @{1, 'a', 'b'@};
1879 static int y[] = @{1, 2, 3@};
1880 static int z[] = @{1, 0, 0@};
1881 @end smallexample
1883 In C, a compound literal designates an unnamed object with static or
1884 automatic storage duration.  In C++, a compound literal designates a
1885 temporary object, which only lives until the end of its
1886 full-expression.  As a result, well-defined C code that takes the
1887 address of a subobject of a compound literal can be undefined in C++,
1888 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1889 For instance, if the array compound literal example above appeared
1890 inside a function, any subsequent use of @samp{foo} in C++ has
1891 undefined behavior because the lifetime of the array ends after the
1892 declaration of @samp{foo}.  
1894 As an optimization, the C++ compiler sometimes gives array compound
1895 literals longer lifetimes: when the array either appears outside a
1896 function or has const-qualified type.  If @samp{foo} and its
1897 initializer had elements of @samp{char *const} type rather than
1898 @samp{char *}, or if @samp{foo} were a global variable, the array
1899 would have static storage duration.  But it is probably safest just to
1900 avoid the use of array compound literals in code compiled as C++.
1902 @node Designated Inits
1903 @section Designated Initializers
1904 @cindex initializers with labeled elements
1905 @cindex labeled elements in initializers
1906 @cindex case labels in initializers
1907 @cindex designated initializers
1909 Standard C90 requires the elements of an initializer to appear in a fixed
1910 order, the same as the order of the elements in the array or structure
1911 being initialized.
1913 In ISO C99 you can give the elements in any order, specifying the array
1914 indices or structure field names they apply to, and GNU C allows this as
1915 an extension in C90 mode as well.  This extension is not
1916 implemented in GNU C++.
1918 To specify an array index, write
1919 @samp{[@var{index}] =} before the element value.  For example,
1921 @smallexample
1922 int a[6] = @{ [4] = 29, [2] = 15 @};
1923 @end smallexample
1925 @noindent
1926 is equivalent to
1928 @smallexample
1929 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1930 @end smallexample
1932 @noindent
1933 The index values must be constant expressions, even if the array being
1934 initialized is automatic.
1936 An alternative syntax for this that has been obsolete since GCC 2.5 but
1937 GCC still accepts is to write @samp{[@var{index}]} before the element
1938 value, with no @samp{=}.
1940 To initialize a range of elements to the same value, write
1941 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1942 extension.  For example,
1944 @smallexample
1945 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1946 @end smallexample
1948 @noindent
1949 If the value in it has side-effects, the side-effects happen only once,
1950 not for each initialized field by the range initializer.
1952 @noindent
1953 Note that the length of the array is the highest value specified
1954 plus one.
1956 In a structure initializer, specify the name of a field to initialize
1957 with @samp{.@var{fieldname} =} before the element value.  For example,
1958 given the following structure,
1960 @smallexample
1961 struct point @{ int x, y; @};
1962 @end smallexample
1964 @noindent
1965 the following initialization
1967 @smallexample
1968 struct point p = @{ .y = yvalue, .x = xvalue @};
1969 @end smallexample
1971 @noindent
1972 is equivalent to
1974 @smallexample
1975 struct point p = @{ xvalue, yvalue @};
1976 @end smallexample
1978 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1979 @samp{@var{fieldname}:}, as shown here:
1981 @smallexample
1982 struct point p = @{ y: yvalue, x: xvalue @};
1983 @end smallexample
1985 Omitted field members are implicitly initialized the same as objects
1986 that have static storage duration.
1988 @cindex designators
1989 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1990 @dfn{designator}.  You can also use a designator (or the obsolete colon
1991 syntax) when initializing a union, to specify which element of the union
1992 should be used.  For example,
1994 @smallexample
1995 union foo @{ int i; double d; @};
1997 union foo f = @{ .d = 4 @};
1998 @end smallexample
2000 @noindent
2001 converts 4 to a @code{double} to store it in the union using
2002 the second element.  By contrast, casting 4 to type @code{union foo}
2003 stores it into the union as the integer @code{i}, since it is
2004 an integer.  (@xref{Cast to Union}.)
2006 You can combine this technique of naming elements with ordinary C
2007 initialization of successive elements.  Each initializer element that
2008 does not have a designator applies to the next consecutive element of the
2009 array or structure.  For example,
2011 @smallexample
2012 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2013 @end smallexample
2015 @noindent
2016 is equivalent to
2018 @smallexample
2019 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2020 @end smallexample
2022 Labeling the elements of an array initializer is especially useful
2023 when the indices are characters or belong to an @code{enum} type.
2024 For example:
2026 @smallexample
2027 int whitespace[256]
2028   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2029       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2030 @end smallexample
2032 @cindex designator lists
2033 You can also write a series of @samp{.@var{fieldname}} and
2034 @samp{[@var{index}]} designators before an @samp{=} to specify a
2035 nested subobject to initialize; the list is taken relative to the
2036 subobject corresponding to the closest surrounding brace pair.  For
2037 example, with the @samp{struct point} declaration above:
2039 @smallexample
2040 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2041 @end smallexample
2043 @noindent
2044 If the same field is initialized multiple times, it has the value from
2045 the last initialization.  If any such overridden initialization has
2046 side-effect, it is unspecified whether the side-effect happens or not.
2047 Currently, GCC discards them and issues a warning.
2049 @node Case Ranges
2050 @section Case Ranges
2051 @cindex case ranges
2052 @cindex ranges in case statements
2054 You can specify a range of consecutive values in a single @code{case} label,
2055 like this:
2057 @smallexample
2058 case @var{low} ... @var{high}:
2059 @end smallexample
2061 @noindent
2062 This has the same effect as the proper number of individual @code{case}
2063 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2065 This feature is especially useful for ranges of ASCII character codes:
2067 @smallexample
2068 case 'A' ... 'Z':
2069 @end smallexample
2071 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2072 it may be parsed wrong when you use it with integer values.  For example,
2073 write this:
2075 @smallexample
2076 case 1 ... 5:
2077 @end smallexample
2079 @noindent
2080 rather than this:
2082 @smallexample
2083 case 1...5:
2084 @end smallexample
2086 @node Cast to Union
2087 @section Cast to a Union Type
2088 @cindex cast to a union
2089 @cindex union, casting to a
2091 A cast to union type is similar to other casts, except that the type
2092 specified is a union type.  You can specify the type either with
2093 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2094 a constructor, not a cast, and hence does not yield an lvalue like
2095 normal casts.  (@xref{Compound Literals}.)
2097 The types that may be cast to the union type are those of the members
2098 of the union.  Thus, given the following union and variables:
2100 @smallexample
2101 union foo @{ int i; double d; @};
2102 int x;
2103 double y;
2104 @end smallexample
2106 @noindent
2107 both @code{x} and @code{y} can be cast to type @code{union foo}.
2109 Using the cast as the right-hand side of an assignment to a variable of
2110 union type is equivalent to storing in a member of the union:
2112 @smallexample
2113 union foo u;
2114 /* @r{@dots{}} */
2115 u = (union foo) x  @equiv{}  u.i = x
2116 u = (union foo) y  @equiv{}  u.d = y
2117 @end smallexample
2119 You can also use the union cast as a function argument:
2121 @smallexample
2122 void hack (union foo);
2123 /* @r{@dots{}} */
2124 hack ((union foo) x);
2125 @end smallexample
2127 @node Mixed Declarations
2128 @section Mixed Declarations and Code
2129 @cindex mixed declarations and code
2130 @cindex declarations, mixed with code
2131 @cindex code, mixed with declarations
2133 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2134 within compound statements.  As an extension, GNU C also allows this in
2135 C90 mode.  For example, you could do:
2137 @smallexample
2138 int i;
2139 /* @r{@dots{}} */
2140 i++;
2141 int j = i + 2;
2142 @end smallexample
2144 Each identifier is visible from where it is declared until the end of
2145 the enclosing block.
2147 @node Function Attributes
2148 @section Declaring Attributes of Functions
2149 @cindex function attributes
2150 @cindex declaring attributes of functions
2151 @cindex @code{volatile} applied to function
2152 @cindex @code{const} applied to function
2154 In GNU C, you can use function attributes to declare certain things
2155 about functions called in your program which help the compiler
2156 optimize calls and check your code more carefully.  For example, you
2157 can use attributes to declare that a function never returns
2158 (@code{noreturn}), returns a value depending only on its arguments
2159 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2161 You can also use attributes to control memory placement, code
2162 generation options or call/return conventions within the function
2163 being annotated.  Many of these attributes are target-specific.  For
2164 example, many targets support attributes for defining interrupt
2165 handler functions, which typically must follow special register usage
2166 and return conventions.
2168 Function attributes are introduced by the @code{__attribute__} keyword
2169 on a declaration, followed by an attribute specification inside double
2170 parentheses.  You can specify multiple attributes in a declaration by
2171 separating them by commas within the double parentheses or by
2172 immediately following an attribute declaration with another attribute
2173 declaration.  @xref{Attribute Syntax}, for the exact rules on
2174 attribute syntax and placement.
2176 GCC also supports attributes on
2177 variable declarations (@pxref{Variable Attributes}),
2178 labels (@pxref{Label Attributes}),
2179 enumerators (@pxref{Enumerator Attributes}),
2180 and types (@pxref{Type Attributes}).
2182 There is some overlap between the purposes of attributes and pragmas
2183 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2184 found convenient to use @code{__attribute__} to achieve a natural
2185 attachment of attributes to their corresponding declarations, whereas
2186 @code{#pragma} is of use for compatibility with other compilers
2187 or constructs that do not naturally form part of the grammar.
2189 In addition to the attributes documented here,
2190 GCC plugins may provide their own attributes.
2192 @menu
2193 * Common Function Attributes::
2194 * AArch64 Function Attributes::
2195 * ARC Function Attributes::
2196 * ARM Function Attributes::
2197 * AVR Function Attributes::
2198 * Blackfin Function Attributes::
2199 * CR16 Function Attributes::
2200 * Epiphany Function Attributes::
2201 * H8/300 Function Attributes::
2202 * IA-64 Function Attributes::
2203 * M32C Function Attributes::
2204 * M32R/D Function Attributes::
2205 * m68k Function Attributes::
2206 * MCORE Function Attributes::
2207 * MeP Function Attributes::
2208 * MicroBlaze Function Attributes::
2209 * Microsoft Windows Function Attributes::
2210 * MIPS Function Attributes::
2211 * MSP430 Function Attributes::
2212 * NDS32 Function Attributes::
2213 * Nios II Function Attributes::
2214 * PowerPC Function Attributes::
2215 * RL78 Function Attributes::
2216 * RX Function Attributes::
2217 * S/390 Function Attributes::
2218 * SH Function Attributes::
2219 * SPU Function Attributes::
2220 * Symbian OS Function Attributes::
2221 * Visium Function Attributes::
2222 * x86 Function Attributes::
2223 * Xstormy16 Function Attributes::
2224 @end menu
2226 @node Common Function Attributes
2227 @subsection Common Function Attributes
2229 The following attributes are supported on most targets.
2231 @table @code
2232 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2234 @item alias ("@var{target}")
2235 @cindex @code{alias} function attribute
2236 The @code{alias} attribute causes the declaration to be emitted as an
2237 alias for another symbol, which must be specified.  For instance,
2239 @smallexample
2240 void __f () @{ /* @r{Do something.} */; @}
2241 void f () __attribute__ ((weak, alias ("__f")));
2242 @end smallexample
2244 @noindent
2245 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2246 mangled name for the target must be used.  It is an error if @samp{__f}
2247 is not defined in the same translation unit.
2249 This attribute requires assembler and object file support,
2250 and may not be available on all targets.
2252 @item aligned (@var{alignment})
2253 @cindex @code{aligned} function attribute
2254 This attribute specifies a minimum alignment for the function,
2255 measured in bytes.
2257 You cannot use this attribute to decrease the alignment of a function,
2258 only to increase it.  However, when you explicitly specify a function
2259 alignment this overrides the effect of the
2260 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2261 function.
2263 Note that the effectiveness of @code{aligned} attributes may be
2264 limited by inherent limitations in your linker.  On many systems, the
2265 linker is only able to arrange for functions to be aligned up to a
2266 certain maximum alignment.  (For some linkers, the maximum supported
2267 alignment may be very very small.)  See your linker documentation for
2268 further information.
2270 The @code{aligned} attribute can also be used for variables and fields
2271 (@pxref{Variable Attributes}.)
2273 @item alloc_align
2274 @cindex @code{alloc_align} function attribute
2275 The @code{alloc_align} attribute is used to tell the compiler that the
2276 function return value points to memory, where the returned pointer minimum
2277 alignment is given by one of the functions parameters.  GCC uses this
2278 information to improve pointer alignment analysis.
2280 The function parameter denoting the allocated alignment is specified by
2281 one integer argument, whose number is the argument of the attribute.
2282 Argument numbering starts at one.
2284 For instance,
2286 @smallexample
2287 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2288 @end smallexample
2290 @noindent
2291 declares that @code{my_memalign} returns memory with minimum alignment
2292 given by parameter 1.
2294 @item alloc_size
2295 @cindex @code{alloc_size} function attribute
2296 The @code{alloc_size} attribute is used to tell the compiler that the
2297 function return value points to memory, where the size is given by
2298 one or two of the functions parameters.  GCC uses this
2299 information to improve the correctness of @code{__builtin_object_size}.
2301 The function parameter(s) denoting the allocated size are specified by
2302 one or two integer arguments supplied to the attribute.  The allocated size
2303 is either the value of the single function argument specified or the product
2304 of the two function arguments specified.  Argument numbering starts at
2305 one.
2307 For instance,
2309 @smallexample
2310 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2311 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2312 @end smallexample
2314 @noindent
2315 declares that @code{my_calloc} returns memory of the size given by
2316 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2317 of the size given by parameter 2.
2319 @item always_inline
2320 @cindex @code{always_inline} function attribute
2321 Generally, functions are not inlined unless optimization is specified.
2322 For functions declared inline, this attribute inlines the function
2323 independent of any restrictions that otherwise apply to inlining.
2324 Failure to inline such a function is diagnosed as an error.
2325 Note that if such a function is called indirectly the compiler may
2326 or may not inline it depending on optimization level and a failure
2327 to inline an indirect call may or may not be diagnosed.
2329 @item artificial
2330 @cindex @code{artificial} function attribute
2331 This attribute is useful for small inline wrappers that if possible
2332 should appear during debugging as a unit.  Depending on the debug
2333 info format it either means marking the function as artificial
2334 or using the caller location for all instructions within the inlined
2335 body.
2337 @item assume_aligned
2338 @cindex @code{assume_aligned} function attribute
2339 The @code{assume_aligned} attribute is used to tell the compiler that the
2340 function return value points to memory, where the returned pointer minimum
2341 alignment is given by the first argument.
2342 If the attribute has two arguments, the second argument is misalignment offset.
2344 For instance
2346 @smallexample
2347 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2348 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2349 @end smallexample
2351 @noindent
2352 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2353 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2354 to 8.
2356 @item bnd_instrument
2357 @cindex @code{bnd_instrument} function attribute
2358 The @code{bnd_instrument} attribute on functions is used to inform the
2359 compiler that the function should be instrumented when compiled
2360 with the @option{-fchkp-instrument-marked-only} option.
2362 @item bnd_legacy
2363 @cindex @code{bnd_legacy} function attribute
2364 @cindex Pointer Bounds Checker attributes
2365 The @code{bnd_legacy} attribute on functions is used to inform the
2366 compiler that the function should not be instrumented when compiled
2367 with the @option{-fcheck-pointer-bounds} option.
2369 @item cold
2370 @cindex @code{cold} function attribute
2371 The @code{cold} attribute on functions is used to inform the compiler that
2372 the function is unlikely to be executed.  The function is optimized for
2373 size rather than speed and on many targets it is placed into a special
2374 subsection of the text section so all cold functions appear close together,
2375 improving code locality of non-cold parts of program.  The paths leading
2376 to calls of cold functions within code are marked as unlikely by the branch
2377 prediction mechanism.  It is thus useful to mark functions used to handle
2378 unlikely conditions, such as @code{perror}, as cold to improve optimization
2379 of hot functions that do call marked functions in rare occasions.
2381 When profile feedback is available, via @option{-fprofile-use}, cold functions
2382 are automatically detected and this attribute is ignored.
2384 @item const
2385 @cindex @code{const} function attribute
2386 @cindex functions that have no side effects
2387 Many functions do not examine any values except their arguments, and
2388 have no effects except the return value.  Basically this is just slightly
2389 more strict class than the @code{pure} attribute below, since function is not
2390 allowed to read global memory.
2392 @cindex pointer arguments
2393 Note that a function that has pointer arguments and examines the data
2394 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2395 function that calls a non-@code{const} function usually must not be
2396 @code{const}.  It does not make sense for a @code{const} function to
2397 return @code{void}.
2399 @item constructor
2400 @itemx destructor
2401 @itemx constructor (@var{priority})
2402 @itemx destructor (@var{priority})
2403 @cindex @code{constructor} function attribute
2404 @cindex @code{destructor} function attribute
2405 The @code{constructor} attribute causes the function to be called
2406 automatically before execution enters @code{main ()}.  Similarly, the
2407 @code{destructor} attribute causes the function to be called
2408 automatically after @code{main ()} completes or @code{exit ()} is
2409 called.  Functions with these attributes are useful for
2410 initializing data that is used implicitly during the execution of
2411 the program.
2413 You may provide an optional integer priority to control the order in
2414 which constructor and destructor functions are run.  A constructor
2415 with a smaller priority number runs before a constructor with a larger
2416 priority number; the opposite relationship holds for destructors.  So,
2417 if you have a constructor that allocates a resource and a destructor
2418 that deallocates the same resource, both functions typically have the
2419 same priority.  The priorities for constructor and destructor
2420 functions are the same as those specified for namespace-scope C++
2421 objects (@pxref{C++ Attributes}).
2423 These attributes are not currently implemented for Objective-C@.
2425 @item deprecated
2426 @itemx deprecated (@var{msg})
2427 @cindex @code{deprecated} function attribute
2428 The @code{deprecated} attribute results in a warning if the function
2429 is used anywhere in the source file.  This is useful when identifying
2430 functions that are expected to be removed in a future version of a
2431 program.  The warning also includes the location of the declaration
2432 of the deprecated function, to enable users to easily find further
2433 information about why the function is deprecated, or what they should
2434 do instead.  Note that the warnings only occurs for uses:
2436 @smallexample
2437 int old_fn () __attribute__ ((deprecated));
2438 int old_fn ();
2439 int (*fn_ptr)() = old_fn;
2440 @end smallexample
2442 @noindent
2443 results in a warning on line 3 but not line 2.  The optional @var{msg}
2444 argument, which must be a string, is printed in the warning if
2445 present.
2447 The @code{deprecated} attribute can also be used for variables and
2448 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2450 @item error ("@var{message}")
2451 @itemx warning ("@var{message}")
2452 @cindex @code{error} function attribute
2453 @cindex @code{warning} function attribute
2454 If the @code{error} or @code{warning} attribute 
2455 is used on a function declaration and a call to such a function
2456 is not eliminated through dead code elimination or other optimizations, 
2457 an error or warning (respectively) that includes @var{message} is diagnosed.  
2458 This is useful
2459 for compile-time checking, especially together with @code{__builtin_constant_p}
2460 and inline functions where checking the inline function arguments is not
2461 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2463 While it is possible to leave the function undefined and thus invoke
2464 a link failure (to define the function with
2465 a message in @code{.gnu.warning*} section),
2466 when using these attributes the problem is diagnosed
2467 earlier and with exact location of the call even in presence of inline
2468 functions or when not emitting debugging information.
2470 @item externally_visible
2471 @cindex @code{externally_visible} function attribute
2472 This attribute, attached to a global variable or function, nullifies
2473 the effect of the @option{-fwhole-program} command-line option, so the
2474 object remains visible outside the current compilation unit.
2476 If @option{-fwhole-program} is used together with @option{-flto} and 
2477 @command{gold} is used as the linker plugin, 
2478 @code{externally_visible} attributes are automatically added to functions 
2479 (not variable yet due to a current @command{gold} issue) 
2480 that are accessed outside of LTO objects according to resolution file
2481 produced by @command{gold}.
2482 For other linkers that cannot generate resolution file,
2483 explicit @code{externally_visible} attributes are still necessary.
2485 @item flatten
2486 @cindex @code{flatten} function attribute
2487 Generally, inlining into a function is limited.  For a function marked with
2488 this attribute, every call inside this function is inlined, if possible.
2489 Whether the function itself is considered for inlining depends on its size and
2490 the current inlining parameters.
2492 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2493 @cindex @code{format} function attribute
2494 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2495 @opindex Wformat
2496 The @code{format} attribute specifies that a function takes @code{printf},
2497 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2498 should be type-checked against a format string.  For example, the
2499 declaration:
2501 @smallexample
2502 extern int
2503 my_printf (void *my_object, const char *my_format, ...)
2504       __attribute__ ((format (printf, 2, 3)));
2505 @end smallexample
2507 @noindent
2508 causes the compiler to check the arguments in calls to @code{my_printf}
2509 for consistency with the @code{printf} style format string argument
2510 @code{my_format}.
2512 The parameter @var{archetype} determines how the format string is
2513 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2514 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2515 @code{strfmon}.  (You can also use @code{__printf__},
2516 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2517 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2518 @code{ms_strftime} are also present.
2519 @var{archetype} values such as @code{printf} refer to the formats accepted
2520 by the system's C runtime library,
2521 while values prefixed with @samp{gnu_} always refer
2522 to the formats accepted by the GNU C Library.  On Microsoft Windows
2523 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2524 @file{msvcrt.dll} library.
2525 The parameter @var{string-index}
2526 specifies which argument is the format string argument (starting
2527 from 1), while @var{first-to-check} is the number of the first
2528 argument to check against the format string.  For functions
2529 where the arguments are not available to be checked (such as
2530 @code{vprintf}), specify the third parameter as zero.  In this case the
2531 compiler only checks the format string for consistency.  For
2532 @code{strftime} formats, the third parameter is required to be zero.
2533 Since non-static C++ methods have an implicit @code{this} argument, the
2534 arguments of such methods should be counted from two, not one, when
2535 giving values for @var{string-index} and @var{first-to-check}.
2537 In the example above, the format string (@code{my_format}) is the second
2538 argument of the function @code{my_print}, and the arguments to check
2539 start with the third argument, so the correct parameters for the format
2540 attribute are 2 and 3.
2542 @opindex ffreestanding
2543 @opindex fno-builtin
2544 The @code{format} attribute allows you to identify your own functions
2545 that take format strings as arguments, so that GCC can check the
2546 calls to these functions for errors.  The compiler always (unless
2547 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2548 for the standard library functions @code{printf}, @code{fprintf},
2549 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2550 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2551 warnings are requested (using @option{-Wformat}), so there is no need to
2552 modify the header file @file{stdio.h}.  In C99 mode, the functions
2553 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2554 @code{vsscanf} are also checked.  Except in strictly conforming C
2555 standard modes, the X/Open function @code{strfmon} is also checked as
2556 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2557 @xref{C Dialect Options,,Options Controlling C Dialect}.
2559 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2560 recognized in the same context.  Declarations including these format attributes
2561 are parsed for correct syntax, however the result of checking of such format
2562 strings is not yet defined, and is not carried out by this version of the
2563 compiler.
2565 The target may also provide additional types of format checks.
2566 @xref{Target Format Checks,,Format Checks Specific to Particular
2567 Target Machines}.
2569 @item format_arg (@var{string-index})
2570 @cindex @code{format_arg} function attribute
2571 @opindex Wformat-nonliteral
2572 The @code{format_arg} attribute specifies that a function takes a format
2573 string for a @code{printf}, @code{scanf}, @code{strftime} or
2574 @code{strfmon} style function and modifies it (for example, to translate
2575 it into another language), so the result can be passed to a
2576 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2577 function (with the remaining arguments to the format function the same
2578 as they would have been for the unmodified string).  For example, the
2579 declaration:
2581 @smallexample
2582 extern char *
2583 my_dgettext (char *my_domain, const char *my_format)
2584       __attribute__ ((format_arg (2)));
2585 @end smallexample
2587 @noindent
2588 causes the compiler to check the arguments in calls to a @code{printf},
2589 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2590 format string argument is a call to the @code{my_dgettext} function, for
2591 consistency with the format string argument @code{my_format}.  If the
2592 @code{format_arg} attribute had not been specified, all the compiler
2593 could tell in such calls to format functions would be that the format
2594 string argument is not constant; this would generate a warning when
2595 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2596 without the attribute.
2598 The parameter @var{string-index} specifies which argument is the format
2599 string argument (starting from one).  Since non-static C++ methods have
2600 an implicit @code{this} argument, the arguments of such methods should
2601 be counted from two.
2603 The @code{format_arg} attribute allows you to identify your own
2604 functions that modify format strings, so that GCC can check the
2605 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2606 type function whose operands are a call to one of your own function.
2607 The compiler always treats @code{gettext}, @code{dgettext}, and
2608 @code{dcgettext} in this manner except when strict ISO C support is
2609 requested by @option{-ansi} or an appropriate @option{-std} option, or
2610 @option{-ffreestanding} or @option{-fno-builtin}
2611 is used.  @xref{C Dialect Options,,Options
2612 Controlling C Dialect}.
2614 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2615 @code{NSString} reference for compatibility with the @code{format} attribute
2616 above.
2618 The target may also allow additional types in @code{format-arg} attributes.
2619 @xref{Target Format Checks,,Format Checks Specific to Particular
2620 Target Machines}.
2622 @item gnu_inline
2623 @cindex @code{gnu_inline} function attribute
2624 This attribute should be used with a function that is also declared
2625 with the @code{inline} keyword.  It directs GCC to treat the function
2626 as if it were defined in gnu90 mode even when compiling in C99 or
2627 gnu99 mode.
2629 If the function is declared @code{extern}, then this definition of the
2630 function is used only for inlining.  In no case is the function
2631 compiled as a standalone function, not even if you take its address
2632 explicitly.  Such an address becomes an external reference, as if you
2633 had only declared the function, and had not defined it.  This has
2634 almost the effect of a macro.  The way to use this is to put a
2635 function definition in a header file with this attribute, and put
2636 another copy of the function, without @code{extern}, in a library
2637 file.  The definition in the header file causes most calls to the
2638 function to be inlined.  If any uses of the function remain, they
2639 refer to the single copy in the library.  Note that the two
2640 definitions of the functions need not be precisely the same, although
2641 if they do not have the same effect your program may behave oddly.
2643 In C, if the function is neither @code{extern} nor @code{static}, then
2644 the function is compiled as a standalone function, as well as being
2645 inlined where possible.
2647 This is how GCC traditionally handled functions declared
2648 @code{inline}.  Since ISO C99 specifies a different semantics for
2649 @code{inline}, this function attribute is provided as a transition
2650 measure and as a useful feature in its own right.  This attribute is
2651 available in GCC 4.1.3 and later.  It is available if either of the
2652 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2653 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2654 Function is As Fast As a Macro}.
2656 In C++, this attribute does not depend on @code{extern} in any way,
2657 but it still requires the @code{inline} keyword to enable its special
2658 behavior.
2660 @item hot
2661 @cindex @code{hot} function attribute
2662 The @code{hot} attribute on a function is used to inform the compiler that
2663 the function is a hot spot of the compiled program.  The function is
2664 optimized more aggressively and on many targets it is placed into a special
2665 subsection of the text section so all hot functions appear close together,
2666 improving locality.
2668 When profile feedback is available, via @option{-fprofile-use}, hot functions
2669 are automatically detected and this attribute is ignored.
2671 @item ifunc ("@var{resolver}")
2672 @cindex @code{ifunc} function attribute
2673 @cindex indirect functions
2674 @cindex functions that are dynamically resolved
2675 The @code{ifunc} attribute is used to mark a function as an indirect
2676 function using the STT_GNU_IFUNC symbol type extension to the ELF
2677 standard.  This allows the resolution of the symbol value to be
2678 determined dynamically at load time, and an optimized version of the
2679 routine can be selected for the particular processor or other system
2680 characteristics determined then.  To use this attribute, first define
2681 the implementation functions available, and a resolver function that
2682 returns a pointer to the selected implementation function.  The
2683 implementation functions' declarations must match the API of the
2684 function being implemented, the resolver's declaration is be a
2685 function returning pointer to void function returning void:
2687 @smallexample
2688 void *my_memcpy (void *dst, const void *src, size_t len)
2690   @dots{}
2693 static void (*resolve_memcpy (void)) (void)
2695   return my_memcpy; // we'll just always select this routine
2697 @end smallexample
2699 @noindent
2700 The exported header file declaring the function the user calls would
2701 contain:
2703 @smallexample
2704 extern void *memcpy (void *, const void *, size_t);
2705 @end smallexample
2707 @noindent
2708 allowing the user to call this as a regular function, unaware of the
2709 implementation.  Finally, the indirect function needs to be defined in
2710 the same translation unit as the resolver function:
2712 @smallexample
2713 void *memcpy (void *, const void *, size_t)
2714      __attribute__ ((ifunc ("resolve_memcpy")));
2715 @end smallexample
2717 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2718 and GNU C Library version 2.11.1 are required to use this feature.
2720 @item interrupt
2721 @itemx interrupt_handler
2722 Many GCC back ends support attributes to indicate that a function is
2723 an interrupt handler, which tells the compiler to generate function
2724 entry and exit sequences that differ from those from regular
2725 functions.  The exact syntax and behavior are target-specific;
2726 refer to the following subsections for details.
2728 @item leaf
2729 @cindex @code{leaf} function attribute
2730 Calls to external functions with this attribute must return to the current
2731 compilation unit only by return or by exception handling.  In particular, leaf
2732 functions are not allowed to call callback function passed to it from the current
2733 compilation unit or directly call functions exported by the unit or longjmp
2734 into the unit.  Leaf function might still call functions from other compilation
2735 units and thus they are not necessarily leaf in the sense that they contain no
2736 function calls at all.
2738 The attribute is intended for library functions to improve dataflow analysis.
2739 The compiler takes the hint that any data not escaping the current compilation unit can
2740 not be used or modified by the leaf function.  For example, the @code{sin} function
2741 is a leaf function, but @code{qsort} is not.
2743 Note that leaf functions might invoke signals and signal handlers might be
2744 defined in the current compilation unit and use static variables.  The only
2745 compliant way to write such a signal handler is to declare such variables
2746 @code{volatile}.
2748 The attribute has no effect on functions defined within the current compilation
2749 unit.  This is to allow easy merging of multiple compilation units into one,
2750 for example, by using the link-time optimization.  For this reason the
2751 attribute is not allowed on types to annotate indirect calls.
2754 @item malloc
2755 @cindex @code{malloc} function attribute
2756 @cindex functions that behave like malloc
2757 This tells the compiler that a function is @code{malloc}-like, i.e.,
2758 that the pointer @var{P} returned by the function cannot alias any
2759 other pointer valid when the function returns, and moreover no
2760 pointers to valid objects occur in any storage addressed by @var{P}.
2762 Using this attribute can improve optimization.  Functions like
2763 @code{malloc} and @code{calloc} have this property because they return
2764 a pointer to uninitialized or zeroed-out storage.  However, functions
2765 like @code{realloc} do not have this property, as they can return a
2766 pointer to storage containing pointers.
2768 @item no_icf
2769 @cindex @code{no_icf} function attribute
2770 This function attribute prevents a functions from being merged with another
2771 semantically equivalent function.
2773 @item no_instrument_function
2774 @cindex @code{no_instrument_function} function attribute
2775 @opindex finstrument-functions
2776 If @option{-finstrument-functions} is given, profiling function calls are
2777 generated at entry and exit of most user-compiled functions.
2778 Functions with this attribute are not so instrumented.
2780 @item no_reorder
2781 @cindex @code{no_reorder} function attribute
2782 Do not reorder functions or variables marked @code{no_reorder}
2783 against each other or top level assembler statements the executable.
2784 The actual order in the program will depend on the linker command
2785 line. Static variables marked like this are also not removed.
2786 This has a similar effect
2787 as the @option{-fno-toplevel-reorder} option, but only applies to the
2788 marked symbols.
2790 @item no_sanitize_address
2791 @itemx no_address_safety_analysis
2792 @cindex @code{no_sanitize_address} function attribute
2793 The @code{no_sanitize_address} attribute on functions is used
2794 to inform the compiler that it should not instrument memory accesses
2795 in the function when compiling with the @option{-fsanitize=address} option.
2796 The @code{no_address_safety_analysis} is a deprecated alias of the
2797 @code{no_sanitize_address} attribute, new code should use
2798 @code{no_sanitize_address}.
2800 @item no_sanitize_thread
2801 @cindex @code{no_sanitize_thread} function attribute
2802 The @code{no_sanitize_thread} attribute on functions is used
2803 to inform the compiler that it should not instrument memory accesses
2804 in the function when compiling with the @option{-fsanitize=thread} option.
2806 @item no_sanitize_undefined
2807 @cindex @code{no_sanitize_undefined} function attribute
2808 The @code{no_sanitize_undefined} attribute on functions is used
2809 to inform the compiler that it should not check for undefined behavior
2810 in the function when compiling with the @option{-fsanitize=undefined} option.
2812 @item no_split_stack
2813 @cindex @code{no_split_stack} function attribute
2814 @opindex fsplit-stack
2815 If @option{-fsplit-stack} is given, functions have a small
2816 prologue which decides whether to split the stack.  Functions with the
2817 @code{no_split_stack} attribute do not have that prologue, and thus
2818 may run with only a small amount of stack space available.
2820 @item noclone
2821 @cindex @code{noclone} function attribute
2822 This function attribute prevents a function from being considered for
2823 cloning---a mechanism that produces specialized copies of functions
2824 and which is (currently) performed by interprocedural constant
2825 propagation.
2827 @item noinline
2828 @cindex @code{noinline} function attribute
2829 This function attribute prevents a function from being considered for
2830 inlining.
2831 @c Don't enumerate the optimizations by name here; we try to be
2832 @c future-compatible with this mechanism.
2833 If the function does not have side-effects, there are optimizations
2834 other than inlining that cause function calls to be optimized away,
2835 although the function call is live.  To keep such calls from being
2836 optimized away, put
2837 @smallexample
2838 asm ("");
2839 @end smallexample
2841 @noindent
2842 (@pxref{Extended Asm}) in the called function, to serve as a special
2843 side-effect.
2845 @item nonnull (@var{arg-index}, @dots{})
2846 @cindex @code{nonnull} function attribute
2847 @cindex functions with non-null pointer arguments
2848 The @code{nonnull} attribute specifies that some function parameters should
2849 be non-null pointers.  For instance, the declaration:
2851 @smallexample
2852 extern void *
2853 my_memcpy (void *dest, const void *src, size_t len)
2854         __attribute__((nonnull (1, 2)));
2855 @end smallexample
2857 @noindent
2858 causes the compiler to check that, in calls to @code{my_memcpy},
2859 arguments @var{dest} and @var{src} are non-null.  If the compiler
2860 determines that a null pointer is passed in an argument slot marked
2861 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2862 is issued.  The compiler may also choose to make optimizations based
2863 on the knowledge that certain function arguments will never be null.
2865 If no argument index list is given to the @code{nonnull} attribute,
2866 all pointer arguments are marked as non-null.  To illustrate, the
2867 following declaration is equivalent to the previous example:
2869 @smallexample
2870 extern void *
2871 my_memcpy (void *dest, const void *src, size_t len)
2872         __attribute__((nonnull));
2873 @end smallexample
2875 @item noreturn
2876 @cindex @code{noreturn} function attribute
2877 @cindex functions that never return
2878 A few standard library functions, such as @code{abort} and @code{exit},
2879 cannot return.  GCC knows this automatically.  Some programs define
2880 their own functions that never return.  You can declare them
2881 @code{noreturn} to tell the compiler this fact.  For example,
2883 @smallexample
2884 @group
2885 void fatal () __attribute__ ((noreturn));
2887 void
2888 fatal (/* @r{@dots{}} */)
2890   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2891   exit (1);
2893 @end group
2894 @end smallexample
2896 The @code{noreturn} keyword tells the compiler to assume that
2897 @code{fatal} cannot return.  It can then optimize without regard to what
2898 would happen if @code{fatal} ever did return.  This makes slightly
2899 better code.  More importantly, it helps avoid spurious warnings of
2900 uninitialized variables.
2902 The @code{noreturn} keyword does not affect the exceptional path when that
2903 applies: a @code{noreturn}-marked function may still return to the caller
2904 by throwing an exception or calling @code{longjmp}.
2906 Do not assume that registers saved by the calling function are
2907 restored before calling the @code{noreturn} function.
2909 It does not make sense for a @code{noreturn} function to have a return
2910 type other than @code{void}.
2912 @item nothrow
2913 @cindex @code{nothrow} function attribute
2914 The @code{nothrow} attribute is used to inform the compiler that a
2915 function cannot throw an exception.  For example, most functions in
2916 the standard C library can be guaranteed not to throw an exception
2917 with the notable exceptions of @code{qsort} and @code{bsearch} that
2918 take function pointer arguments.
2920 @item noplt
2921 @cindex @code{noplt} function attribute
2922 The @code{noplt} attribute is the counterpart to option @option{-fno-plt} and
2923 does not use PLT for calls to functions marked with this attribute in position
2924 independent code. 
2926 @smallexample
2927 @group
2928 /* Externally defined function foo.  */
2929 int foo () __attribute__ ((noplt));
2932 main (/* @r{@dots{}} */)
2934   /* @r{@dots{}} */
2935   foo ();
2936   /* @r{@dots{}} */
2938 @end group
2939 @end smallexample
2941 The @code{noplt} attribute on function foo tells the compiler to assume that
2942 the function foo is externally defined and the call to foo must avoid the PLT
2943 in position independent code.
2945 Additionally, a few targets also convert calls to those functions that are
2946 marked to not use the PLT to use the GOT instead for non-position independent
2947 code.
2949 @item optimize
2950 @cindex @code{optimize} function attribute
2951 The @code{optimize} attribute is used to specify that a function is to
2952 be compiled with different optimization options than specified on the
2953 command line.  Arguments can either be numbers or strings.  Numbers
2954 are assumed to be an optimization level.  Strings that begin with
2955 @code{O} are assumed to be an optimization option, while other options
2956 are assumed to be used with a @code{-f} prefix.  You can also use the
2957 @samp{#pragma GCC optimize} pragma to set the optimization options
2958 that affect more than one function.
2959 @xref{Function Specific Option Pragmas}, for details about the
2960 @samp{#pragma GCC optimize} pragma.
2962 This can be used for instance to have frequently-executed functions
2963 compiled with more aggressive optimization options that produce faster
2964 and larger code, while other functions can be compiled with less
2965 aggressive options.
2967 @item pure
2968 @cindex @code{pure} function attribute
2969 @cindex functions that have no side effects
2970 Many functions have no effects except the return value and their
2971 return value depends only on the parameters and/or global variables.
2972 Such a function can be subject
2973 to common subexpression elimination and loop optimization just as an
2974 arithmetic operator would be.  These functions should be declared
2975 with the attribute @code{pure}.  For example,
2977 @smallexample
2978 int square (int) __attribute__ ((pure));
2979 @end smallexample
2981 @noindent
2982 says that the hypothetical function @code{square} is safe to call
2983 fewer times than the program says.
2985 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
2986 Interesting non-pure functions are functions with infinite loops or those
2987 depending on volatile memory or other system resource, that may change between
2988 two consecutive calls (such as @code{feof} in a multithreading environment).
2990 @item returns_nonnull
2991 @cindex @code{returns_nonnull} function attribute
2992 The @code{returns_nonnull} attribute specifies that the function
2993 return value should be a non-null pointer.  For instance, the declaration:
2995 @smallexample
2996 extern void *
2997 mymalloc (size_t len) __attribute__((returns_nonnull));
2998 @end smallexample
3000 @noindent
3001 lets the compiler optimize callers based on the knowledge
3002 that the return value will never be null.
3004 @item returns_twice
3005 @cindex @code{returns_twice} function attribute
3006 @cindex functions that return more than once
3007 The @code{returns_twice} attribute tells the compiler that a function may
3008 return more than one time.  The compiler ensures that all registers
3009 are dead before calling such a function and emits a warning about
3010 the variables that may be clobbered after the second return from the
3011 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3012 The @code{longjmp}-like counterpart of such function, if any, might need
3013 to be marked with the @code{noreturn} attribute.
3015 @item section ("@var{section-name}")
3016 @cindex @code{section} function attribute
3017 @cindex functions in arbitrary sections
3018 Normally, the compiler places the code it generates in the @code{text} section.
3019 Sometimes, however, you need additional sections, or you need certain
3020 particular functions to appear in special sections.  The @code{section}
3021 attribute specifies that a function lives in a particular section.
3022 For example, the declaration:
3024 @smallexample
3025 extern void foobar (void) __attribute__ ((section ("bar")));
3026 @end smallexample
3028 @noindent
3029 puts the function @code{foobar} in the @code{bar} section.
3031 Some file formats do not support arbitrary sections so the @code{section}
3032 attribute is not available on all platforms.
3033 If you need to map the entire contents of a module to a particular
3034 section, consider using the facilities of the linker instead.
3036 @item sentinel
3037 @cindex @code{sentinel} function attribute
3038 This function attribute ensures that a parameter in a function call is
3039 an explicit @code{NULL}.  The attribute is only valid on variadic
3040 functions.  By default, the sentinel is located at position zero, the
3041 last parameter of the function call.  If an optional integer position
3042 argument P is supplied to the attribute, the sentinel must be located at
3043 position P counting backwards from the end of the argument list.
3045 @smallexample
3046 __attribute__ ((sentinel))
3047 is equivalent to
3048 __attribute__ ((sentinel(0)))
3049 @end smallexample
3051 The attribute is automatically set with a position of 0 for the built-in
3052 functions @code{execl} and @code{execlp}.  The built-in function
3053 @code{execle} has the attribute set with a position of 1.
3055 A valid @code{NULL} in this context is defined as zero with any pointer
3056 type.  If your system defines the @code{NULL} macro with an integer type
3057 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3058 with a copy that redefines NULL appropriately.
3060 The warnings for missing or incorrect sentinels are enabled with
3061 @option{-Wformat}.
3063 @item stack_protect
3064 @cindex @code{stack_protect} function attribute
3065 This function attribute make a stack protection of the function if 
3066 flags @option{fstack-protector} or @option{fstack-protector-strong}
3067 or @option{fstack-protector-explicit} are set.
3069 @item target (@var{options})
3070 @cindex @code{target} function attribute
3071 Multiple target back ends implement the @code{target} attribute
3072 to specify that a function is to
3073 be compiled with different target options than specified on the
3074 command line.  This can be used for instance to have functions
3075 compiled with a different ISA (instruction set architecture) than the
3076 default.  You can also use the @samp{#pragma GCC target} pragma to set
3077 more than one function to be compiled with specific target options.
3078 @xref{Function Specific Option Pragmas}, for details about the
3079 @samp{#pragma GCC target} pragma.
3081 For instance, on an x86, you could declare one function with the
3082 @code{target("sse4.1,arch=core2")} attribute and another with
3083 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3084 compiling the first function with @option{-msse4.1} and
3085 @option{-march=core2} options, and the second function with
3086 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3087 to make sure that a function is only invoked on a machine that
3088 supports the particular ISA it is compiled for (for example by using
3089 @code{cpuid} on x86 to determine what feature bits and architecture
3090 family are used).
3092 @smallexample
3093 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3094 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3095 @end smallexample
3097 You can either use multiple
3098 strings separated by commas to specify multiple options,
3099 or separate the options with a comma (@samp{,}) within a single string.
3101 The options supported are specific to each target; refer to @ref{x86
3102 Function Attributes}, @ref{PowerPC Function Attributes},
3103 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3104 for details.
3106 @item unused
3107 @cindex @code{unused} function attribute
3108 This attribute, attached to a function, means that the function is meant
3109 to be possibly unused.  GCC does not produce a warning for this
3110 function.
3112 @item used
3113 @cindex @code{used} function attribute
3114 This attribute, attached to a function, means that code must be emitted
3115 for the function even if it appears that the function is not referenced.
3116 This is useful, for example, when the function is referenced only in
3117 inline assembly.
3119 When applied to a member function of a C++ class template, the
3120 attribute also means that the function is instantiated if the
3121 class itself is instantiated.
3123 @item visibility ("@var{visibility_type}")
3124 @cindex @code{visibility} function attribute
3125 This attribute affects the linkage of the declaration to which it is attached.
3126 There are four supported @var{visibility_type} values: default,
3127 hidden, protected or internal visibility.
3129 @smallexample
3130 void __attribute__ ((visibility ("protected")))
3131 f () @{ /* @r{Do something.} */; @}
3132 int i __attribute__ ((visibility ("hidden")));
3133 @end smallexample
3135 The possible values of @var{visibility_type} correspond to the
3136 visibility settings in the ELF gABI.
3138 @table @code
3139 @c keep this list of visibilities in alphabetical order.
3141 @item default
3142 Default visibility is the normal case for the object file format.
3143 This value is available for the visibility attribute to override other
3144 options that may change the assumed visibility of entities.
3146 On ELF, default visibility means that the declaration is visible to other
3147 modules and, in shared libraries, means that the declared entity may be
3148 overridden.
3150 On Darwin, default visibility means that the declaration is visible to
3151 other modules.
3153 Default visibility corresponds to ``external linkage'' in the language.
3155 @item hidden
3156 Hidden visibility indicates that the entity declared has a new
3157 form of linkage, which we call ``hidden linkage''.  Two
3158 declarations of an object with hidden linkage refer to the same object
3159 if they are in the same shared object.
3161 @item internal
3162 Internal visibility is like hidden visibility, but with additional
3163 processor specific semantics.  Unless otherwise specified by the
3164 psABI, GCC defines internal visibility to mean that a function is
3165 @emph{never} called from another module.  Compare this with hidden
3166 functions which, while they cannot be referenced directly by other
3167 modules, can be referenced indirectly via function pointers.  By
3168 indicating that a function cannot be called from outside the module,
3169 GCC may for instance omit the load of a PIC register since it is known
3170 that the calling function loaded the correct value.
3172 @item protected
3173 Protected visibility is like default visibility except that it
3174 indicates that references within the defining module bind to the
3175 definition in that module.  That is, the declared entity cannot be
3176 overridden by another module.
3178 @end table
3180 All visibilities are supported on many, but not all, ELF targets
3181 (supported when the assembler supports the @samp{.visibility}
3182 pseudo-op).  Default visibility is supported everywhere.  Hidden
3183 visibility is supported on Darwin targets.
3185 The visibility attribute should be applied only to declarations that
3186 would otherwise have external linkage.  The attribute should be applied
3187 consistently, so that the same entity should not be declared with
3188 different settings of the attribute.
3190 In C++, the visibility attribute applies to types as well as functions
3191 and objects, because in C++ types have linkage.  A class must not have
3192 greater visibility than its non-static data member types and bases,
3193 and class members default to the visibility of their class.  Also, a
3194 declaration without explicit visibility is limited to the visibility
3195 of its type.
3197 In C++, you can mark member functions and static member variables of a
3198 class with the visibility attribute.  This is useful if you know a
3199 particular method or static member variable should only be used from
3200 one shared object; then you can mark it hidden while the rest of the
3201 class has default visibility.  Care must be taken to avoid breaking
3202 the One Definition Rule; for example, it is usually not useful to mark
3203 an inline method as hidden without marking the whole class as hidden.
3205 A C++ namespace declaration can also have the visibility attribute.
3207 @smallexample
3208 namespace nspace1 __attribute__ ((visibility ("protected")))
3209 @{ /* @r{Do something.} */; @}
3210 @end smallexample
3212 This attribute applies only to the particular namespace body, not to
3213 other definitions of the same namespace; it is equivalent to using
3214 @samp{#pragma GCC visibility} before and after the namespace
3215 definition (@pxref{Visibility Pragmas}).
3217 In C++, if a template argument has limited visibility, this
3218 restriction is implicitly propagated to the template instantiation.
3219 Otherwise, template instantiations and specializations default to the
3220 visibility of their template.
3222 If both the template and enclosing class have explicit visibility, the
3223 visibility from the template is used.
3225 @item warn_unused_result
3226 @cindex @code{warn_unused_result} function attribute
3227 The @code{warn_unused_result} attribute causes a warning to be emitted
3228 if a caller of the function with this attribute does not use its
3229 return value.  This is useful for functions where not checking
3230 the result is either a security problem or always a bug, such as
3231 @code{realloc}.
3233 @smallexample
3234 int fn () __attribute__ ((warn_unused_result));
3235 int foo ()
3237   if (fn () < 0) return -1;
3238   fn ();
3239   return 0;
3241 @end smallexample
3243 @noindent
3244 results in warning on line 5.
3246 @item weak
3247 @cindex @code{weak} function attribute
3248 The @code{weak} attribute causes the declaration to be emitted as a weak
3249 symbol rather than a global.  This is primarily useful in defining
3250 library functions that can be overridden in user code, though it can
3251 also be used with non-function declarations.  Weak symbols are supported
3252 for ELF targets, and also for a.out targets when using the GNU assembler
3253 and linker.
3255 @item weakref
3256 @itemx weakref ("@var{target}")
3257 @cindex @code{weakref} function attribute
3258 The @code{weakref} attribute marks a declaration as a weak reference.
3259 Without arguments, it should be accompanied by an @code{alias} attribute
3260 naming the target symbol.  Optionally, the @var{target} may be given as
3261 an argument to @code{weakref} itself.  In either case, @code{weakref}
3262 implicitly marks the declaration as @code{weak}.  Without a
3263 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3264 @code{weakref} is equivalent to @code{weak}.
3266 @smallexample
3267 static int x() __attribute__ ((weakref ("y")));
3268 /* is equivalent to... */
3269 static int x() __attribute__ ((weak, weakref, alias ("y")));
3270 /* and to... */
3271 static int x() __attribute__ ((weakref));
3272 static int x() __attribute__ ((alias ("y")));
3273 @end smallexample
3275 A weak reference is an alias that does not by itself require a
3276 definition to be given for the target symbol.  If the target symbol is
3277 only referenced through weak references, then it becomes a @code{weak}
3278 undefined symbol.  If it is directly referenced, however, then such
3279 strong references prevail, and a definition is required for the
3280 symbol, not necessarily in the same translation unit.
3282 The effect is equivalent to moving all references to the alias to a
3283 separate translation unit, renaming the alias to the aliased symbol,
3284 declaring it as weak, compiling the two separate translation units and
3285 performing a reloadable link on them.
3287 At present, a declaration to which @code{weakref} is attached can
3288 only be @code{static}.
3290 @item lower
3291 @itemx upper
3292 @itemx either
3293 @cindex lower memory region on the MSP430
3294 @cindex upper memory region on the MSP430
3295 @cindex either memory region on the MSP430
3296 On the MSP430 target these attributes can be used to specify whether
3297 the function or variable should be placed into low memory, high
3298 memory, or the placement should be left to the linker to decide.  The
3299 attributes are only significant if compiling for the MSP430X
3300 architecture.
3302 The attributes work in conjunction with a linker script that has been
3303 augmented to specify where to place sections with a @code{.lower} and
3304 a @code{.upper} prefix.  So for example as well as placing the
3305 @code{.data} section the script would also specify the placement of a
3306 @code{.lower.data} and a @code{.upper.data} section.  The intention
3307 being that @code{lower} sections are placed into a small but easier to
3308 access memory region and the upper sections are placed into a larger, but
3309 slower to access region.
3311 The @code{either} attribute is special.  It tells the linker to place
3312 the object into the corresponding @code{lower} section if there is
3313 room for it.  If there is insufficient room then the object is placed
3314 into the corresponding @code{upper} section instead.  Note - the
3315 placement algorithm is not very sophisticated.  It will not attempt to
3316 find an optimal packing of the @code{lower} sections.  It just makes
3317 one pass over the objects and does the best that it can.  Using the
3318 @option{-ffunction-sections} and @option{-fdata-sections} command line
3319 options can help the packing however, since they produce smaller,
3320 easier to pack regions.
3322 @end table
3324 @c This is the end of the target-independent attribute table
3326 @node AArch64 Function Attributes
3327 @subsection AArch64 Function Attributes
3329 The following target-specific function attributes are available for the
3330 AArch64 target.  For the most part, these options mirror the behavior of
3331 similar command-line options (@pxref{AArch64 Options}), but on a
3332 per-function basis.
3334 @table @code
3335 @item general-regs-only
3336 @cindex @code{general-regs-only} function attribute, AArch64
3337 Indicates that no floating-point or Advanced SIMD registers should be
3338 used when generating code for this function.  If the function explicitly
3339 uses floating-point code, then the compiler gives an error.  This is
3340 the same behavior as that of the command-line option
3341 @option{-mgeneral-regs-only}.
3343 @item fix-cortex-a53-835769
3344 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3345 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3346 applied to this function.  To explicitly disable the workaround for this
3347 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3348 This corresponds to the behavior of the command line options
3349 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3351 @item cmodel=
3352 @cindex @code{cmodel=} function attribute, AArch64
3353 Indicates that code should be generated for a particular code model for
3354 this function.  The behavior and permissible arguments are the same as
3355 for the command line option @option{-mcmodel=}.
3357 @item strict-align
3358 @cindex @code{strict-align} function attribute, AArch64
3359 Indicates that the compiler should not assume that unaligned memory references
3360 are handled by the system.  The behavior is the same as for the command-line
3361 option @option{-mstrict-align}.
3363 @item omit-leaf-frame-pointer
3364 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3365 Indicates that the frame pointer should be omitted for a leaf function call.
3366 To keep the frame pointer, the inverse attribute
3367 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3368 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3369 and @option{-mno-omit-leaf-frame-pointer}.
3371 @item tls-dialect=
3372 @cindex @code{tls-dialect=} function attribute, AArch64
3373 Specifies the TLS dialect to use for this function.  The behavior and
3374 permissible arguments are the same as for the command-line option
3375 @option{-mtls-dialect=}.
3377 @item arch=
3378 @cindex @code{arch=} function attribute, AArch64
3379 Specifies the architecture version and architectural extensions to use
3380 for this function.  The behavior and permissible arguments are the same as
3381 for the @option{-march=} command-line option.
3383 @item tune=
3384 @cindex @code{tune=} function attribute, AArch64
3385 Specifies the core for which to tune the performance of this function.
3386 The behavior and permissible arguments are the same as for the @option{-mtune=}
3387 command-line option.
3389 @item cpu=
3390 @cindex @code{cpu=} function attribute, AArch64
3391 Specifies the core for which to tune the performance of this function and also
3392 whose architectural features to use.  The behavior and valid arguments are the
3393 same as for the @option{-mcpu=} command-line option.
3395 @end table
3397 The above target attributes can be specified as follows:
3399 @smallexample
3400 __attribute__((target("@var{attr-string}")))
3402 f (int a)
3404   return a + 5;
3406 @end smallexample
3408 where @code{@var{attr-string}} is one of the attribute strings specified above.
3410 Additionally, the architectural extension string may be specified on its
3411 own.  This can be used to turn on and off particular architectural extensions
3412 without having to specify a particular architecture version or core.  Example:
3414 @smallexample
3415 __attribute__((target("+crc+nocrypto")))
3417 foo (int a)
3419   return a + 5;
3421 @end smallexample
3423 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3424 extension and disables the @code{crypto} extension for the function @code{foo}
3425 without modifying an existing @option{-march=} or @option{-mcpu} option.
3427 Multiple target function attributes can be specified by separating them with
3428 a comma.  For example:
3429 @smallexample
3430 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3432 foo (int a)
3434   return a + 5;
3436 @end smallexample
3438 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3439 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3441 @subsubsection Inlining rules
3442 Specifying target attributes on individual functions or performing link-time
3443 optimization across translation units compiled with different target options
3444 can affect function inlining rules:
3446 In particular, a caller function can inline a callee function only if the
3447 architectural features available to the callee are a subset of the features
3448 available to the caller.
3449 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3450 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3451 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3452 because the all the architectural features that function @code{bar} requires
3453 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3454 inline function @code{foo}.
3456 Additionally inlining a function compiled with @option{-mstrict-align} into a
3457 function compiled without @code{-mstrict-align} is not allowed.
3458 However, inlining a function compiled without @option{-mstrict-align} into a
3459 function compiled with @option{-mstrict-align} is allowed.
3461 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3462 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3463 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3464 architectural feature rules specified above.
3466 @node ARC Function Attributes
3467 @subsection ARC Function Attributes
3469 These function attributes are supported by the ARC back end:
3471 @table @code
3472 @item interrupt
3473 @cindex @code{interrupt} function attribute, ARC
3474 Use this attribute to indicate
3475 that the specified function is an interrupt handler.  The compiler generates
3476 function entry and exit sequences suitable for use in an interrupt handler
3477 when this attribute is present.
3479 On the ARC, you must specify the kind of interrupt to be handled
3480 in a parameter to the interrupt attribute like this:
3482 @smallexample
3483 void f () __attribute__ ((interrupt ("ilink1")));
3484 @end smallexample
3486 Permissible values for this parameter are: @w{@code{ilink1}} and
3487 @w{@code{ilink2}}.
3489 @item long_call
3490 @itemx medium_call
3491 @itemx short_call
3492 @cindex @code{long_call} function attribute, ARC
3493 @cindex @code{medium_call} function attribute, ARC
3494 @cindex @code{short_call} function attribute, ARC
3495 @cindex indirect calls, ARC
3496 These attributes specify how a particular function is called.
3497 These attributes override the
3498 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3499 command-line switches and @code{#pragma long_calls} settings.
3501 For ARC, a function marked with the @code{long_call} attribute is
3502 always called using register-indirect jump-and-link instructions,
3503 thereby enabling the called function to be placed anywhere within the
3504 32-bit address space.  A function marked with the @code{medium_call}
3505 attribute will always be close enough to be called with an unconditional
3506 branch-and-link instruction, which has a 25-bit offset from
3507 the call site.  A function marked with the @code{short_call}
3508 attribute will always be close enough to be called with a conditional
3509 branch-and-link instruction, which has a 21-bit offset from
3510 the call site.
3511 @end table
3513 @node ARM Function Attributes
3514 @subsection ARM Function Attributes
3516 These function attributes are supported for ARM targets:
3518 @table @code
3519 @item interrupt
3520 @cindex @code{interrupt} function attribute, ARM
3521 Use this attribute to indicate
3522 that the specified function is an interrupt handler.  The compiler generates
3523 function entry and exit sequences suitable for use in an interrupt handler
3524 when this attribute is present.
3526 You can specify the kind of interrupt to be handled by
3527 adding an optional parameter to the interrupt attribute like this:
3529 @smallexample
3530 void f () __attribute__ ((interrupt ("IRQ")));
3531 @end smallexample
3533 @noindent
3534 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3535 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3537 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3538 may be called with a word-aligned stack pointer.
3540 @item isr
3541 @cindex @code{isr} function attribute, ARM
3542 Use this attribute on ARM to write Interrupt Service Routines. This is an
3543 alias to the @code{interrupt} attribute above.
3545 @item long_call
3546 @itemx short_call
3547 @cindex @code{long_call} function attribute, ARM
3548 @cindex @code{short_call} function attribute, ARM
3549 @cindex indirect calls, ARM
3550 These attributes specify how a particular function is called.
3551 These attributes override the
3552 @option{-mlong-calls} (@pxref{ARM Options})
3553 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3554 @code{long_call} attribute indicates that the function might be far
3555 away from the call site and require a different (more expensive)
3556 calling sequence.   The @code{short_call} attribute always places
3557 the offset to the function from the call site into the @samp{BL}
3558 instruction directly.
3560 @item naked
3561 @cindex @code{naked} function attribute, ARM
3562 This attribute allows the compiler to construct the
3563 requisite function declaration, while allowing the body of the
3564 function to be assembly code. The specified function will not have
3565 prologue/epilogue sequences generated by the compiler. Only basic
3566 @code{asm} statements can safely be included in naked functions
3567 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3568 basic @code{asm} and C code may appear to work, they cannot be
3569 depended upon to work reliably and are not supported.
3571 @item pcs
3572 @cindex @code{pcs} function attribute, ARM
3574 The @code{pcs} attribute can be used to control the calling convention
3575 used for a function on ARM.  The attribute takes an argument that specifies
3576 the calling convention to use.
3578 When compiling using the AAPCS ABI (or a variant of it) then valid
3579 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3580 order to use a variant other than @code{"aapcs"} then the compiler must
3581 be permitted to use the appropriate co-processor registers (i.e., the
3582 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3583 For example,
3585 @smallexample
3586 /* Argument passed in r0, and result returned in r0+r1.  */
3587 double f2d (float) __attribute__((pcs("aapcs")));
3588 @end smallexample
3590 Variadic functions always use the @code{"aapcs"} calling convention and
3591 the compiler rejects attempts to specify an alternative.
3593 @item target (@var{options})
3594 @cindex @code{target} function attribute
3595 As discussed in @ref{Common Function Attributes}, this attribute 
3596 allows specification of target-specific compilation options.
3598 On ARM, the following options are allowed:
3600 @table @samp
3601 @item thumb
3602 @cindex @code{target("thumb")} function attribute, ARM
3603 Force code generation in the Thumb (T16/T32) ISA, depending on the
3604 architecture level.
3606 @item arm
3607 @cindex @code{target("arm")} function attribute, ARM
3608 Force code generation in the ARM (A32) ISA.
3609 @end table
3611 Functions from different modes can be inlined in the caller's mode.
3613 @end table
3615 @node AVR Function Attributes
3616 @subsection AVR Function Attributes
3618 These function attributes are supported by the AVR back end:
3620 @table @code
3621 @item interrupt
3622 @cindex @code{interrupt} function attribute, AVR
3623 Use this attribute to indicate
3624 that the specified function is an interrupt handler.  The compiler generates
3625 function entry and exit sequences suitable for use in an interrupt handler
3626 when this attribute is present.
3628 On the AVR, the hardware globally disables interrupts when an
3629 interrupt is executed.  The first instruction of an interrupt handler
3630 declared with this attribute is a @code{SEI} instruction to
3631 re-enable interrupts.  See also the @code{signal} function attribute
3632 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3633 @code{interrupt} are specified for the same function, @code{signal}
3634 is silently ignored.
3636 @item naked
3637 @cindex @code{naked} function attribute, AVR
3638 This attribute allows the compiler to construct the
3639 requisite function declaration, while allowing the body of the
3640 function to be assembly code. The specified function will not have
3641 prologue/epilogue sequences generated by the compiler. Only basic
3642 @code{asm} statements can safely be included in naked functions
3643 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3644 basic @code{asm} and C code may appear to work, they cannot be
3645 depended upon to work reliably and are not supported.
3647 @item OS_main
3648 @itemx OS_task
3649 @cindex @code{OS_main} function attribute, AVR
3650 @cindex @code{OS_task} function attribute, AVR
3651 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3652 do not save/restore any call-saved register in their prologue/epilogue.
3654 The @code{OS_main} attribute can be used when there @emph{is
3655 guarantee} that interrupts are disabled at the time when the function
3656 is entered.  This saves resources when the stack pointer has to be
3657 changed to set up a frame for local variables.
3659 The @code{OS_task} attribute can be used when there is @emph{no
3660 guarantee} that interrupts are disabled at that time when the function
3661 is entered like for, e@.g@. task functions in a multi-threading operating
3662 system. In that case, changing the stack pointer register is
3663 guarded by save/clear/restore of the global interrupt enable flag.
3665 The differences to the @code{naked} function attribute are:
3666 @itemize @bullet
3667 @item @code{naked} functions do not have a return instruction whereas 
3668 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3669 @code{RETI} return instruction.
3670 @item @code{naked} functions do not set up a frame for local variables
3671 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3672 as needed.
3673 @end itemize
3675 @item signal
3676 @cindex @code{signal} function attribute, AVR
3677 Use this attribute on the AVR to indicate that the specified
3678 function is an interrupt handler.  The compiler generates function
3679 entry and exit sequences suitable for use in an interrupt handler when this
3680 attribute is present.
3682 See also the @code{interrupt} function attribute. 
3684 The AVR hardware globally disables interrupts when an interrupt is executed.
3685 Interrupt handler functions defined with the @code{signal} attribute
3686 do not re-enable interrupts.  It is save to enable interrupts in a
3687 @code{signal} handler.  This ``save'' only applies to the code
3688 generated by the compiler and not to the IRQ layout of the
3689 application which is responsibility of the application.
3691 If both @code{signal} and @code{interrupt} are specified for the same
3692 function, @code{signal} is silently ignored.
3693 @end table
3695 @node Blackfin Function Attributes
3696 @subsection Blackfin Function Attributes
3698 These function attributes are supported by the Blackfin back end:
3700 @table @code
3702 @item exception_handler
3703 @cindex @code{exception_handler} function attribute
3704 @cindex exception handler functions, Blackfin
3705 Use this attribute on the Blackfin to indicate that the specified function
3706 is an exception handler.  The compiler generates function entry and
3707 exit sequences suitable for use in an exception handler when this
3708 attribute is present.
3710 @item interrupt_handler
3711 @cindex @code{interrupt_handler} function attribute, Blackfin
3712 Use this attribute to
3713 indicate that the specified function is an interrupt handler.  The compiler
3714 generates function entry and exit sequences suitable for use in an
3715 interrupt handler when this attribute is present.
3717 @item kspisusp
3718 @cindex @code{kspisusp} function attribute, Blackfin
3719 @cindex User stack pointer in interrupts on the Blackfin
3720 When used together with @code{interrupt_handler}, @code{exception_handler}
3721 or @code{nmi_handler}, code is generated to load the stack pointer
3722 from the USP register in the function prologue.
3724 @item l1_text
3725 @cindex @code{l1_text} function attribute, Blackfin
3726 This attribute specifies a function to be placed into L1 Instruction
3727 SRAM@. The function is put into a specific section named @code{.l1.text}.
3728 With @option{-mfdpic}, function calls with a such function as the callee
3729 or caller uses inlined PLT.
3731 @item l2
3732 @cindex @code{l2} function attribute, Blackfin
3733 This attribute specifies a function to be placed into L2
3734 SRAM. The function is put into a specific section named
3735 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3736 an inlined PLT.
3738 @item longcall
3739 @itemx shortcall
3740 @cindex indirect calls, Blackfin
3741 @cindex @code{longcall} function attribute, Blackfin
3742 @cindex @code{shortcall} function attribute, Blackfin
3743 The @code{longcall} attribute
3744 indicates that the function might be far away from the call site and
3745 require a different (more expensive) calling sequence.  The
3746 @code{shortcall} attribute indicates that the function is always close
3747 enough for the shorter calling sequence to be used.  These attributes
3748 override the @option{-mlongcall} switch.
3750 @item nesting
3751 @cindex @code{nesting} function attribute, Blackfin
3752 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3753 Use this attribute together with @code{interrupt_handler},
3754 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3755 entry code should enable nested interrupts or exceptions.
3757 @item nmi_handler
3758 @cindex @code{nmi_handler} function attribute, Blackfin
3759 @cindex NMI handler functions on the Blackfin processor
3760 Use this attribute on the Blackfin to indicate that the specified function
3761 is an NMI handler.  The compiler generates function entry and
3762 exit sequences suitable for use in an NMI handler when this
3763 attribute is present.
3765 @item saveall
3766 @cindex @code{saveall} function attribute, Blackfin
3767 @cindex save all registers on the Blackfin
3768 Use this attribute to indicate that
3769 all registers except the stack pointer should be saved in the prologue
3770 regardless of whether they are used or not.
3771 @end table
3773 @node CR16 Function Attributes
3774 @subsection CR16 Function Attributes
3776 These function attributes are supported by the CR16 back end:
3778 @table @code
3779 @item interrupt
3780 @cindex @code{interrupt} function attribute, CR16
3781 Use this attribute to indicate
3782 that the specified function is an interrupt handler.  The compiler generates
3783 function entry and exit sequences suitable for use in an interrupt handler
3784 when this attribute is present.
3785 @end table
3787 @node Epiphany Function Attributes
3788 @subsection Epiphany Function Attributes
3790 These function attributes are supported by the Epiphany back end:
3792 @table @code
3793 @item disinterrupt
3794 @cindex @code{disinterrupt} function attribute, Epiphany
3795 This attribute causes the compiler to emit
3796 instructions to disable interrupts for the duration of the given
3797 function.
3799 @item forwarder_section
3800 @cindex @code{forwarder_section} function attribute, Epiphany
3801 This attribute modifies the behavior of an interrupt handler.
3802 The interrupt handler may be in external memory which cannot be
3803 reached by a branch instruction, so generate a local memory trampoline
3804 to transfer control.  The single parameter identifies the section where
3805 the trampoline is placed.
3807 @item interrupt
3808 @cindex @code{interrupt} function attribute, Epiphany
3809 Use this attribute to indicate
3810 that the specified function is an interrupt handler.  The compiler generates
3811 function entry and exit sequences suitable for use in an interrupt handler
3812 when this attribute is present.  It may also generate
3813 a special section with code to initialize the interrupt vector table.
3815 On Epiphany targets one or more optional parameters can be added like this:
3817 @smallexample
3818 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3819 @end smallexample
3821 Permissible values for these parameters are: @w{@code{reset}},
3822 @w{@code{software_exception}}, @w{@code{page_miss}},
3823 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3824 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3825 Multiple parameters indicate that multiple entries in the interrupt
3826 vector table should be initialized for this function, i.e.@: for each
3827 parameter @w{@var{name}}, a jump to the function is emitted in
3828 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3829 entirely, in which case no interrupt vector table entry is provided.
3831 Note that interrupts are enabled inside the function
3832 unless the @code{disinterrupt} attribute is also specified.
3834 The following examples are all valid uses of these attributes on
3835 Epiphany targets:
3836 @smallexample
3837 void __attribute__ ((interrupt)) universal_handler ();
3838 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3839 void __attribute__ ((interrupt ("dma0, dma1"))) 
3840   universal_dma_handler ();
3841 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3842   fast_timer_handler ();
3843 void __attribute__ ((interrupt ("dma0, dma1"), 
3844                      forwarder_section ("tramp")))
3845   external_dma_handler ();
3846 @end smallexample
3848 @item long_call
3849 @itemx short_call
3850 @cindex @code{long_call} function attribute, Epiphany
3851 @cindex @code{short_call} function attribute, Epiphany
3852 @cindex indirect calls, Epiphany
3853 These attributes specify how a particular function is called.
3854 These attributes override the
3855 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3856 command-line switch and @code{#pragma long_calls} settings.
3857 @end table
3860 @node H8/300 Function Attributes
3861 @subsection H8/300 Function Attributes
3863 These function attributes are available for H8/300 targets:
3865 @table @code
3866 @item function_vector
3867 @cindex @code{function_vector} function attribute, H8/300
3868 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
3869 that the specified function should be called through the function vector.
3870 Calling a function through the function vector reduces code size; however,
3871 the function vector has a limited size (maximum 128 entries on the H8/300
3872 and 64 entries on the H8/300H and H8S)
3873 and shares space with the interrupt vector.
3875 @item interrupt_handler
3876 @cindex @code{interrupt_handler} function attribute, H8/300
3877 Use this attribute on the H8/300, H8/300H, and H8S to
3878 indicate that the specified function is an interrupt handler.  The compiler
3879 generates function entry and exit sequences suitable for use in an
3880 interrupt handler when this attribute is present.
3882 @item saveall
3883 @cindex @code{saveall} function attribute, H8/300
3884 @cindex save all registers on the H8/300, H8/300H, and H8S
3885 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3886 all registers except the stack pointer should be saved in the prologue
3887 regardless of whether they are used or not.
3888 @end table
3890 @node IA-64 Function Attributes
3891 @subsection IA-64 Function Attributes
3893 These function attributes are supported on IA-64 targets:
3895 @table @code
3896 @item syscall_linkage
3897 @cindex @code{syscall_linkage} function attribute, IA-64
3898 This attribute is used to modify the IA-64 calling convention by marking
3899 all input registers as live at all function exits.  This makes it possible
3900 to restart a system call after an interrupt without having to save/restore
3901 the input registers.  This also prevents kernel data from leaking into
3902 application code.
3904 @item version_id
3905 @cindex @code{version_id} function attribute, IA-64
3906 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3907 symbol to contain a version string, thus allowing for function level
3908 versioning.  HP-UX system header files may use function level versioning
3909 for some system calls.
3911 @smallexample
3912 extern int foo () __attribute__((version_id ("20040821")));
3913 @end smallexample
3915 @noindent
3916 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
3917 @end table
3919 @node M32C Function Attributes
3920 @subsection M32C Function Attributes
3922 These function attributes are supported by the M32C back end:
3924 @table @code
3925 @item bank_switch
3926 @cindex @code{bank_switch} function attribute, M32C
3927 When added to an interrupt handler with the M32C port, causes the
3928 prologue and epilogue to use bank switching to preserve the registers
3929 rather than saving them on the stack.
3931 @item fast_interrupt
3932 @cindex @code{fast_interrupt} function attribute, M32C
3933 Use this attribute on the M32C port to indicate that the specified
3934 function is a fast interrupt handler.  This is just like the
3935 @code{interrupt} attribute, except that @code{freit} is used to return
3936 instead of @code{reit}.
3938 @item function_vector
3939 @cindex @code{function_vector} function attribute, M16C/M32C
3940 On M16C/M32C targets, the @code{function_vector} attribute declares a
3941 special page subroutine call function. Use of this attribute reduces
3942 the code size by 2 bytes for each call generated to the
3943 subroutine. The argument to the attribute is the vector number entry
3944 from the special page vector table which contains the 16 low-order
3945 bits of the subroutine's entry address. Each vector table has special
3946 page number (18 to 255) that is used in @code{jsrs} instructions.
3947 Jump addresses of the routines are generated by adding 0x0F0000 (in
3948 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
3949 2-byte addresses set in the vector table. Therefore you need to ensure
3950 that all the special page vector routines should get mapped within the
3951 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
3952 (for M32C).
3954 In the following example 2 bytes are saved for each call to
3955 function @code{foo}.
3957 @smallexample
3958 void foo (void) __attribute__((function_vector(0x18)));
3959 void foo (void)
3963 void bar (void)
3965     foo();
3967 @end smallexample
3969 If functions are defined in one file and are called in another file,
3970 then be sure to write this declaration in both files.
3972 This attribute is ignored for R8C target.
3974 @item interrupt
3975 @cindex @code{interrupt} function attribute, M32C
3976 Use this attribute to indicate
3977 that the specified function is an interrupt handler.  The compiler generates
3978 function entry and exit sequences suitable for use in an interrupt handler
3979 when this attribute is present.
3980 @end table
3982 @node M32R/D Function Attributes
3983 @subsection M32R/D Function Attributes
3985 These function attributes are supported by the M32R/D back end:
3987 @table @code
3988 @item interrupt
3989 @cindex @code{interrupt} function attribute, M32R/D
3990 Use this attribute to indicate
3991 that the specified function is an interrupt handler.  The compiler generates
3992 function entry and exit sequences suitable for use in an interrupt handler
3993 when this attribute is present.
3995 @item model (@var{model-name})
3996 @cindex @code{model} function attribute, M32R/D
3997 @cindex function addressability on the M32R/D
3999 On the M32R/D, use this attribute to set the addressability of an
4000 object, and of the code generated for a function.  The identifier
4001 @var{model-name} is one of @code{small}, @code{medium}, or
4002 @code{large}, representing each of the code models.
4004 Small model objects live in the lower 16MB of memory (so that their
4005 addresses can be loaded with the @code{ld24} instruction), and are
4006 callable with the @code{bl} instruction.
4008 Medium model objects may live anywhere in the 32-bit address space (the
4009 compiler generates @code{seth/add3} instructions to load their addresses),
4010 and are callable with the @code{bl} instruction.
4012 Large model objects may live anywhere in the 32-bit address space (the
4013 compiler generates @code{seth/add3} instructions to load their addresses),
4014 and may not be reachable with the @code{bl} instruction (the compiler
4015 generates the much slower @code{seth/add3/jl} instruction sequence).
4016 @end table
4018 @node m68k Function Attributes
4019 @subsection m68k Function Attributes
4021 These function attributes are supported by the m68k back end:
4023 @table @code
4024 @item interrupt
4025 @itemx interrupt_handler
4026 @cindex @code{interrupt} function attribute, m68k
4027 @cindex @code{interrupt_handler} function attribute, m68k
4028 Use this attribute to
4029 indicate that the specified function is an interrupt handler.  The compiler
4030 generates function entry and exit sequences suitable for use in an
4031 interrupt handler when this attribute is present.  Either name may be used.
4033 @item interrupt_thread
4034 @cindex @code{interrupt_thread} function attribute, fido
4035 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4036 that the specified function is an interrupt handler that is designed
4037 to run as a thread.  The compiler omits generate prologue/epilogue
4038 sequences and replaces the return instruction with a @code{sleep}
4039 instruction.  This attribute is available only on fido.
4040 @end table
4042 @node MCORE Function Attributes
4043 @subsection MCORE Function Attributes
4045 These function attributes are supported by the MCORE back end:
4047 @table @code
4048 @item naked
4049 @cindex @code{naked} function attribute, MCORE
4050 This attribute allows the compiler to construct the
4051 requisite function declaration, while allowing the body of the
4052 function to be assembly code. The specified function will not have
4053 prologue/epilogue sequences generated by the compiler. Only basic
4054 @code{asm} statements can safely be included in naked functions
4055 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4056 basic @code{asm} and C code may appear to work, they cannot be
4057 depended upon to work reliably and are not supported.
4058 @end table
4060 @node MeP Function Attributes
4061 @subsection MeP Function Attributes
4063 These function attributes are supported by the MeP back end:
4065 @table @code
4066 @item disinterrupt
4067 @cindex @code{disinterrupt} function attribute, MeP
4068 On MeP targets, this attribute causes the compiler to emit
4069 instructions to disable interrupts for the duration of the given
4070 function.
4072 @item interrupt
4073 @cindex @code{interrupt} function attribute, MeP
4074 Use this attribute to indicate
4075 that the specified function is an interrupt handler.  The compiler generates
4076 function entry and exit sequences suitable for use in an interrupt handler
4077 when this attribute is present.
4079 @item near
4080 @cindex @code{near} function attribute, MeP
4081 This attribute causes the compiler to assume the called
4082 function is close enough to use the normal calling convention,
4083 overriding the @option{-mtf} command-line option.
4085 @item far
4086 @cindex @code{far} function attribute, MeP
4087 On MeP targets this causes the compiler to use a calling convention
4088 that assumes the called function is too far away for the built-in
4089 addressing modes.
4091 @item vliw
4092 @cindex @code{vliw} function attribute, MeP
4093 The @code{vliw} attribute tells the compiler to emit
4094 instructions in VLIW mode instead of core mode.  Note that this
4095 attribute is not allowed unless a VLIW coprocessor has been configured
4096 and enabled through command-line options.
4097 @end table
4099 @node MicroBlaze Function Attributes
4100 @subsection MicroBlaze Function Attributes
4102 These function attributes are supported on MicroBlaze targets:
4104 @table @code
4105 @item save_volatiles
4106 @cindex @code{save_volatiles} function attribute, MicroBlaze
4107 Use this attribute to indicate that the function is
4108 an interrupt handler.  All volatile registers (in addition to non-volatile
4109 registers) are saved in the function prologue.  If the function is a leaf
4110 function, only volatiles used by the function are saved.  A normal function
4111 return is generated instead of a return from interrupt.
4113 @item break_handler
4114 @cindex @code{break_handler} function attribute, MicroBlaze
4115 @cindex break handler functions
4116 Use this attribute to indicate that
4117 the specified function is a break handler.  The compiler generates function
4118 entry and exit sequences suitable for use in an break handler when this
4119 attribute is present. The return from @code{break_handler} is done through
4120 the @code{rtbd} instead of @code{rtsd}.
4122 @smallexample
4123 void f () __attribute__ ((break_handler));
4124 @end smallexample
4125 @end table
4127 @node Microsoft Windows Function Attributes
4128 @subsection Microsoft Windows Function Attributes
4130 The following attributes are available on Microsoft Windows and Symbian OS
4131 targets.
4133 @table @code
4134 @item dllexport
4135 @cindex @code{dllexport} function attribute
4136 @cindex @code{__declspec(dllexport)}
4137 On Microsoft Windows targets and Symbian OS targets the
4138 @code{dllexport} attribute causes the compiler to provide a global
4139 pointer to a pointer in a DLL, so that it can be referenced with the
4140 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4141 name is formed by combining @code{_imp__} and the function or variable
4142 name.
4144 You can use @code{__declspec(dllexport)} as a synonym for
4145 @code{__attribute__ ((dllexport))} for compatibility with other
4146 compilers.
4148 On systems that support the @code{visibility} attribute, this
4149 attribute also implies ``default'' visibility.  It is an error to
4150 explicitly specify any other visibility.
4152 GCC's default behavior is to emit all inline functions with the
4153 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4154 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4155 ignore the attribute for inlined functions unless the 
4156 @option{-fkeep-inline-functions} flag is used instead.
4158 The attribute is ignored for undefined symbols.
4160 When applied to C++ classes, the attribute marks defined non-inlined
4161 member functions and static data members as exports.  Static consts
4162 initialized in-class are not marked unless they are also defined
4163 out-of-class.
4165 For Microsoft Windows targets there are alternative methods for
4166 including the symbol in the DLL's export table such as using a
4167 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4168 the @option{--export-all} linker flag.
4170 @item dllimport
4171 @cindex @code{dllimport} function attribute
4172 @cindex @code{__declspec(dllimport)}
4173 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4174 attribute causes the compiler to reference a function or variable via
4175 a global pointer to a pointer that is set up by the DLL exporting the
4176 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4177 targets, the pointer name is formed by combining @code{_imp__} and the
4178 function or variable name.
4180 You can use @code{__declspec(dllimport)} as a synonym for
4181 @code{__attribute__ ((dllimport))} for compatibility with other
4182 compilers.
4184 On systems that support the @code{visibility} attribute, this
4185 attribute also implies ``default'' visibility.  It is an error to
4186 explicitly specify any other visibility.
4188 Currently, the attribute is ignored for inlined functions.  If the
4189 attribute is applied to a symbol @emph{definition}, an error is reported.
4190 If a symbol previously declared @code{dllimport} is later defined, the
4191 attribute is ignored in subsequent references, and a warning is emitted.
4192 The attribute is also overridden by a subsequent declaration as
4193 @code{dllexport}.
4195 When applied to C++ classes, the attribute marks non-inlined
4196 member functions and static data members as imports.  However, the
4197 attribute is ignored for virtual methods to allow creation of vtables
4198 using thunks.
4200 On the SH Symbian OS target the @code{dllimport} attribute also has
4201 another affect---it can cause the vtable and run-time type information
4202 for a class to be exported.  This happens when the class has a
4203 dllimported constructor or a non-inline, non-pure virtual function
4204 and, for either of those two conditions, the class also has an inline
4205 constructor or destructor and has a key function that is defined in
4206 the current translation unit.
4208 For Microsoft Windows targets the use of the @code{dllimport}
4209 attribute on functions is not necessary, but provides a small
4210 performance benefit by eliminating a thunk in the DLL@.  The use of the
4211 @code{dllimport} attribute on imported variables can be avoided by passing the
4212 @option{--enable-auto-import} switch to the GNU linker.  As with
4213 functions, using the attribute for a variable eliminates a thunk in
4214 the DLL@.
4216 One drawback to using this attribute is that a pointer to a
4217 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4218 address. However, a pointer to a @emph{function} with the
4219 @code{dllimport} attribute can be used as a constant initializer; in
4220 this case, the address of a stub function in the import lib is
4221 referenced.  On Microsoft Windows targets, the attribute can be disabled
4222 for functions by setting the @option{-mnop-fun-dllimport} flag.
4223 @end table
4225 @node MIPS Function Attributes
4226 @subsection MIPS Function Attributes
4228 These function attributes are supported by the MIPS back end:
4230 @table @code
4231 @item interrupt
4232 @cindex @code{interrupt} function attribute, MIPS
4233 Use this attribute to indicate that the specified function is an interrupt
4234 handler.  The compiler generates function entry and exit sequences suitable
4235 for use in an interrupt handler when this attribute is present.
4236 An optional argument is supported for the interrupt attribute which allows
4237 the interrupt mode to be described.  By default GCC assumes the external
4238 interrupt controller (EIC) mode is in use, this can be explicitly set using
4239 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4240 Priority Level (IPL) is copied to the current IPL which has the effect of only
4241 enabling higher priority interrupts.  To use vectored interrupt mode use
4242 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4243 the behaviour of the non-masked interrupt support and GCC will arrange to mask
4244 all interrupts from sw0 up to and including the specified interrupt vector.
4246 You can use the following attributes to modify the behavior
4247 of an interrupt handler:
4248 @table @code
4249 @item use_shadow_register_set
4250 @cindex @code{use_shadow_register_set} function attribute, MIPS
4251 Assume that the handler uses a shadow register set, instead of
4252 the main general-purpose registers.  An optional argument @code{intstack} is
4253 supported to indicate that the shadow register set contains a valid stack
4254 pointer.
4256 @item keep_interrupts_masked
4257 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4258 Keep interrupts masked for the whole function.  Without this attribute,
4259 GCC tries to reenable interrupts for as much of the function as it can.
4261 @item use_debug_exception_return
4262 @cindex @code{use_debug_exception_return} function attribute, MIPS
4263 Return using the @code{deret} instruction.  Interrupt handlers that don't
4264 have this attribute return using @code{eret} instead.
4265 @end table
4267 You can use any combination of these attributes, as shown below:
4268 @smallexample
4269 void __attribute__ ((interrupt)) v0 ();
4270 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4271 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4272 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4273 void __attribute__ ((interrupt, use_shadow_register_set,
4274                      keep_interrupts_masked)) v4 ();
4275 void __attribute__ ((interrupt, use_shadow_register_set,
4276                      use_debug_exception_return)) v5 ();
4277 void __attribute__ ((interrupt, keep_interrupts_masked,
4278                      use_debug_exception_return)) v6 ();
4279 void __attribute__ ((interrupt, use_shadow_register_set,
4280                      keep_interrupts_masked,
4281                      use_debug_exception_return)) v7 ();
4282 void __attribute__ ((interrupt("eic"))) v8 ();
4283 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4284 @end smallexample
4286 @item long_call
4287 @itemx near
4288 @itemx far
4289 @cindex indirect calls, MIPS
4290 @cindex @code{long_call} function attribute, MIPS
4291 @cindex @code{near} function attribute, MIPS
4292 @cindex @code{far} function attribute, MIPS
4293 These attributes specify how a particular function is called on MIPS@.
4294 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4295 command-line switch.  The @code{long_call} and @code{far} attributes are
4296 synonyms, and cause the compiler to always call
4297 the function by first loading its address into a register, and then using
4298 the contents of that register.  The @code{near} attribute has the opposite
4299 effect; it specifies that non-PIC calls should be made using the more
4300 efficient @code{jal} instruction.
4302 @item mips16
4303 @itemx nomips16
4304 @cindex @code{mips16} function attribute, MIPS
4305 @cindex @code{nomips16} function attribute, MIPS
4307 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4308 function attributes to locally select or turn off MIPS16 code generation.
4309 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4310 while MIPS16 code generation is disabled for functions with the
4311 @code{nomips16} attribute.  These attributes override the
4312 @option{-mips16} and @option{-mno-mips16} options on the command line
4313 (@pxref{MIPS Options}).
4315 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4316 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4317 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4318 may interact badly with some GCC extensions such as @code{__builtin_apply}
4319 (@pxref{Constructing Calls}).
4321 @item micromips, MIPS
4322 @itemx nomicromips, MIPS
4323 @cindex @code{micromips} function attribute
4324 @cindex @code{nomicromips} function attribute
4326 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4327 function attributes to locally select or turn off microMIPS code generation.
4328 A function with the @code{micromips} attribute is emitted as microMIPS code,
4329 while microMIPS code generation is disabled for functions with the
4330 @code{nomicromips} attribute.  These attributes override the
4331 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4332 (@pxref{MIPS Options}).
4334 When compiling files containing mixed microMIPS and non-microMIPS code, the
4335 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4336 command line,
4337 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4338 may interact badly with some GCC extensions such as @code{__builtin_apply}
4339 (@pxref{Constructing Calls}).
4341 @item nocompression
4342 @cindex @code{nocompression} function attribute, MIPS
4343 On MIPS targets, you can use the @code{nocompression} function attribute
4344 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4345 overrides the @option{-mips16} and @option{-mmicromips} options on the
4346 command line (@pxref{MIPS Options}).
4347 @end table
4349 @node MSP430 Function Attributes
4350 @subsection MSP430 Function Attributes
4352 These function attributes are supported by the MSP430 back end:
4354 @table @code
4355 @item critical
4356 @cindex @code{critical} function attribute, MSP430
4357 Critical functions disable interrupts upon entry and restore the
4358 previous interrupt state upon exit.  Critical functions cannot also
4359 have the @code{naked} or @code{reentrant} attributes.  They can have
4360 the @code{interrupt} attribute.
4362 @item interrupt
4363 @cindex @code{interrupt} function attribute, MSP430
4364 Use this attribute to indicate
4365 that the specified function is an interrupt handler.  The compiler generates
4366 function entry and exit sequences suitable for use in an interrupt handler
4367 when this attribute is present.
4369 You can provide an argument to the interrupt
4370 attribute which specifies a name or number.  If the argument is a
4371 number it indicates the slot in the interrupt vector table (0 - 31) to
4372 which this handler should be assigned.  If the argument is a name it
4373 is treated as a symbolic name for the vector slot.  These names should
4374 match up with appropriate entries in the linker script.  By default
4375 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4376 @code{reset} for vector 31 are recognized.
4378 @item naked
4379 @cindex @code{naked} function attribute, MSP430
4380 This attribute allows the compiler to construct the
4381 requisite function declaration, while allowing the body of the
4382 function to be assembly code. The specified function will not have
4383 prologue/epilogue sequences generated by the compiler. Only basic
4384 @code{asm} statements can safely be included in naked functions
4385 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4386 basic @code{asm} and C code may appear to work, they cannot be
4387 depended upon to work reliably and are not supported.
4389 @item reentrant
4390 @cindex @code{reentrant} function attribute, MSP430
4391 Reentrant functions disable interrupts upon entry and enable them
4392 upon exit.  Reentrant functions cannot also have the @code{naked}
4393 or @code{critical} attributes.  They can have the @code{interrupt}
4394 attribute.
4396 @item wakeup
4397 @cindex @code{wakeup} function attribute, MSP430
4398 This attribute only applies to interrupt functions.  It is silently
4399 ignored if applied to a non-interrupt function.  A wakeup interrupt
4400 function will rouse the processor from any low-power state that it
4401 might be in when the function exits.
4402 @end table
4404 @node NDS32 Function Attributes
4405 @subsection NDS32 Function Attributes
4407 These function attributes are supported by the NDS32 back end:
4409 @table @code
4410 @item exception
4411 @cindex @code{exception} function attribute
4412 @cindex exception handler functions, NDS32
4413 Use this attribute on the NDS32 target to indicate that the specified function
4414 is an exception handler.  The compiler will generate corresponding sections
4415 for use in an exception handler.
4417 @item interrupt
4418 @cindex @code{interrupt} function attribute, NDS32
4419 On NDS32 target, this attribute indicates that the specified function
4420 is an interrupt handler.  The compiler generates corresponding sections
4421 for use in an interrupt handler.  You can use the following attributes
4422 to modify the behavior:
4423 @table @code
4424 @item nested
4425 @cindex @code{nested} function attribute, NDS32
4426 This interrupt service routine is interruptible.
4427 @item not_nested
4428 @cindex @code{not_nested} function attribute, NDS32
4429 This interrupt service routine is not interruptible.
4430 @item nested_ready
4431 @cindex @code{nested_ready} function attribute, NDS32
4432 This interrupt service routine is interruptible after @code{PSW.GIE}
4433 (global interrupt enable) is set.  This allows interrupt service routine to
4434 finish some short critical code before enabling interrupts.
4435 @item save_all
4436 @cindex @code{save_all} function attribute, NDS32
4437 The system will help save all registers into stack before entering
4438 interrupt handler.
4439 @item partial_save
4440 @cindex @code{partial_save} function attribute, NDS32
4441 The system will help save caller registers into stack before entering
4442 interrupt handler.
4443 @end table
4445 @item naked
4446 @cindex @code{naked} function attribute, NDS32
4447 This attribute allows the compiler to construct the
4448 requisite function declaration, while allowing the body of the
4449 function to be assembly code. The specified function will not have
4450 prologue/epilogue sequences generated by the compiler. Only basic
4451 @code{asm} statements can safely be included in naked functions
4452 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4453 basic @code{asm} and C code may appear to work, they cannot be
4454 depended upon to work reliably and are not supported.
4456 @item reset
4457 @cindex @code{reset} function attribute, NDS32
4458 @cindex reset handler functions
4459 Use this attribute on the NDS32 target to indicate that the specified function
4460 is a reset handler.  The compiler will generate corresponding sections
4461 for use in a reset handler.  You can use the following attributes
4462 to provide extra exception handling:
4463 @table @code
4464 @item nmi
4465 @cindex @code{nmi} function attribute, NDS32
4466 Provide a user-defined function to handle NMI exception.
4467 @item warm
4468 @cindex @code{warm} function attribute, NDS32
4469 Provide a user-defined function to handle warm reset exception.
4470 @end table
4471 @end table
4473 @node Nios II Function Attributes
4474 @subsection Nios II Function Attributes
4476 These function attributes are supported by the Nios II back end:
4478 @table @code
4479 @item target (@var{options})
4480 @cindex @code{target} function attribute
4481 As discussed in @ref{Common Function Attributes}, this attribute 
4482 allows specification of target-specific compilation options.
4484 When compiling for Nios II, the following options are allowed:
4486 @table @samp
4487 @item custom-@var{insn}=@var{N}
4488 @itemx no-custom-@var{insn}
4489 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4490 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4491 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4492 custom instruction with encoding @var{N} when generating code that uses 
4493 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4494 the custom instruction @var{insn}.
4495 These target attributes correspond to the
4496 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4497 command-line options, and support the same set of @var{insn} keywords.
4498 @xref{Nios II Options}, for more information.
4500 @item custom-fpu-cfg=@var{name}
4501 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4502 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4503 command-line option, to select a predefined set of custom instructions
4504 named @var{name}.
4505 @xref{Nios II Options}, for more information.
4506 @end table
4507 @end table
4509 @node PowerPC Function Attributes
4510 @subsection PowerPC Function Attributes
4512 These function attributes are supported by the PowerPC back end:
4514 @table @code
4515 @item longcall
4516 @itemx shortcall
4517 @cindex indirect calls, PowerPC
4518 @cindex @code{longcall} function attribute, PowerPC
4519 @cindex @code{shortcall} function attribute, PowerPC
4520 The @code{longcall} attribute
4521 indicates that the function might be far away from the call site and
4522 require a different (more expensive) calling sequence.  The
4523 @code{shortcall} attribute indicates that the function is always close
4524 enough for the shorter calling sequence to be used.  These attributes
4525 override both the @option{-mlongcall} switch and
4526 the @code{#pragma longcall} setting.
4528 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4529 calls are necessary.
4531 @item target (@var{options})
4532 @cindex @code{target} function attribute
4533 As discussed in @ref{Common Function Attributes}, this attribute 
4534 allows specification of target-specific compilation options.
4536 On the PowerPC, the following options are allowed:
4538 @table @samp
4539 @item altivec
4540 @itemx no-altivec
4541 @cindex @code{target("altivec")} function attribute, PowerPC
4542 Generate code that uses (does not use) AltiVec instructions.  In
4543 32-bit code, you cannot enable AltiVec instructions unless
4544 @option{-mabi=altivec} is used on the command line.
4546 @item cmpb
4547 @itemx no-cmpb
4548 @cindex @code{target("cmpb")} function attribute, PowerPC
4549 Generate code that uses (does not use) the compare bytes instruction
4550 implemented on the POWER6 processor and other processors that support
4551 the PowerPC V2.05 architecture.
4553 @item dlmzb
4554 @itemx no-dlmzb
4555 @cindex @code{target("dlmzb")} function attribute, PowerPC
4556 Generate code that uses (does not use) the string-search @samp{dlmzb}
4557 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4558 generated by default when targeting those processors.
4560 @item fprnd
4561 @itemx no-fprnd
4562 @cindex @code{target("fprnd")} function attribute, PowerPC
4563 Generate code that uses (does not use) the FP round to integer
4564 instructions implemented on the POWER5+ processor and other processors
4565 that support the PowerPC V2.03 architecture.
4567 @item hard-dfp
4568 @itemx no-hard-dfp
4569 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4570 Generate code that uses (does not use) the decimal floating-point
4571 instructions implemented on some POWER processors.
4573 @item isel
4574 @itemx no-isel
4575 @cindex @code{target("isel")} function attribute, PowerPC
4576 Generate code that uses (does not use) ISEL instruction.
4578 @item mfcrf
4579 @itemx no-mfcrf
4580 @cindex @code{target("mfcrf")} function attribute, PowerPC
4581 Generate code that uses (does not use) the move from condition
4582 register field instruction implemented on the POWER4 processor and
4583 other processors that support the PowerPC V2.01 architecture.
4585 @item mfpgpr
4586 @itemx no-mfpgpr
4587 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4588 Generate code that uses (does not use) the FP move to/from general
4589 purpose register instructions implemented on the POWER6X processor and
4590 other processors that support the extended PowerPC V2.05 architecture.
4592 @item mulhw
4593 @itemx no-mulhw
4594 @cindex @code{target("mulhw")} function attribute, PowerPC
4595 Generate code that uses (does not use) the half-word multiply and
4596 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4597 These instructions are generated by default when targeting those
4598 processors.
4600 @item multiple
4601 @itemx no-multiple
4602 @cindex @code{target("multiple")} function attribute, PowerPC
4603 Generate code that uses (does not use) the load multiple word
4604 instructions and the store multiple word instructions.
4606 @item update
4607 @itemx no-update
4608 @cindex @code{target("update")} function attribute, PowerPC
4609 Generate code that uses (does not use) the load or store instructions
4610 that update the base register to the address of the calculated memory
4611 location.
4613 @item popcntb
4614 @itemx no-popcntb
4615 @cindex @code{target("popcntb")} function attribute, PowerPC
4616 Generate code that uses (does not use) the popcount and double-precision
4617 FP reciprocal estimate instruction implemented on the POWER5
4618 processor and other processors that support the PowerPC V2.02
4619 architecture.
4621 @item popcntd
4622 @itemx no-popcntd
4623 @cindex @code{target("popcntd")} function attribute, PowerPC
4624 Generate code that uses (does not use) the popcount instruction
4625 implemented on the POWER7 processor and other processors that support
4626 the PowerPC V2.06 architecture.
4628 @item powerpc-gfxopt
4629 @itemx no-powerpc-gfxopt
4630 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4631 Generate code that uses (does not use) the optional PowerPC
4632 architecture instructions in the Graphics group, including
4633 floating-point select.
4635 @item powerpc-gpopt
4636 @itemx no-powerpc-gpopt
4637 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4638 Generate code that uses (does not use) the optional PowerPC
4639 architecture instructions in the General Purpose group, including
4640 floating-point square root.
4642 @item recip-precision
4643 @itemx no-recip-precision
4644 @cindex @code{target("recip-precision")} function attribute, PowerPC
4645 Assume (do not assume) that the reciprocal estimate instructions
4646 provide higher-precision estimates than is mandated by the PowerPC
4647 ABI.
4649 @item string
4650 @itemx no-string
4651 @cindex @code{target("string")} function attribute, PowerPC
4652 Generate code that uses (does not use) the load string instructions
4653 and the store string word instructions to save multiple registers and
4654 do small block moves.
4656 @item vsx
4657 @itemx no-vsx
4658 @cindex @code{target("vsx")} function attribute, PowerPC
4659 Generate code that uses (does not use) vector/scalar (VSX)
4660 instructions, and also enable the use of built-in functions that allow
4661 more direct access to the VSX instruction set.  In 32-bit code, you
4662 cannot enable VSX or AltiVec instructions unless
4663 @option{-mabi=altivec} is used on the command line.
4665 @item friz
4666 @itemx no-friz
4667 @cindex @code{target("friz")} function attribute, PowerPC
4668 Generate (do not generate) the @code{friz} instruction when the
4669 @option{-funsafe-math-optimizations} option is used to optimize
4670 rounding a floating-point value to 64-bit integer and back to floating
4671 point.  The @code{friz} instruction does not return the same value if
4672 the floating-point number is too large to fit in an integer.
4674 @item avoid-indexed-addresses
4675 @itemx no-avoid-indexed-addresses
4676 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4677 Generate code that tries to avoid (not avoid) the use of indexed load
4678 or store instructions.
4680 @item paired
4681 @itemx no-paired
4682 @cindex @code{target("paired")} function attribute, PowerPC
4683 Generate code that uses (does not use) the generation of PAIRED simd
4684 instructions.
4686 @item longcall
4687 @itemx no-longcall
4688 @cindex @code{target("longcall")} function attribute, PowerPC
4689 Generate code that assumes (does not assume) that all calls are far
4690 away so that a longer more expensive calling sequence is required.
4692 @item cpu=@var{CPU}
4693 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4694 Specify the architecture to generate code for when compiling the
4695 function.  If you select the @code{target("cpu=power7")} attribute when
4696 generating 32-bit code, VSX and AltiVec instructions are not generated
4697 unless you use the @option{-mabi=altivec} option on the command line.
4699 @item tune=@var{TUNE}
4700 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4701 Specify the architecture to tune for when compiling the function.  If
4702 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4703 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4704 compilation tunes for the @var{CPU} architecture, and not the
4705 default tuning specified on the command line.
4706 @end table
4708 On the PowerPC, the inliner does not inline a
4709 function that has different target options than the caller, unless the
4710 callee has a subset of the target options of the caller.
4711 @end table
4713 @node RL78 Function Attributes
4714 @subsection RL78 Function Attributes
4716 These function attributes are supported by the RL78 back end:
4718 @table @code
4719 @item interrupt
4720 @itemx brk_interrupt
4721 @cindex @code{interrupt} function attribute, RL78
4722 @cindex @code{brk_interrupt} function attribute, RL78
4723 These attributes indicate
4724 that the specified function is an interrupt handler.  The compiler generates
4725 function entry and exit sequences suitable for use in an interrupt handler
4726 when this attribute is present.
4728 Use @code{brk_interrupt} instead of @code{interrupt} for
4729 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4730 that must end with @code{RETB} instead of @code{RETI}).
4732 @item naked
4733 @cindex @code{naked} function attribute, RL78
4734 This attribute allows the compiler to construct the
4735 requisite function declaration, while allowing the body of the
4736 function to be assembly code. The specified function will not have
4737 prologue/epilogue sequences generated by the compiler. Only basic
4738 @code{asm} statements can safely be included in naked functions
4739 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4740 basic @code{asm} and C code may appear to work, they cannot be
4741 depended upon to work reliably and are not supported.
4742 @end table
4744 @node RX Function Attributes
4745 @subsection RX Function Attributes
4747 These function attributes are supported by the RX back end:
4749 @table @code
4750 @item fast_interrupt
4751 @cindex @code{fast_interrupt} function attribute, RX
4752 Use this attribute on the RX port to indicate that the specified
4753 function is a fast interrupt handler.  This is just like the
4754 @code{interrupt} attribute, except that @code{freit} is used to return
4755 instead of @code{reit}.
4757 @item interrupt
4758 @cindex @code{interrupt} function attribute, RX
4759 Use this attribute to indicate
4760 that the specified function is an interrupt handler.  The compiler generates
4761 function entry and exit sequences suitable for use in an interrupt handler
4762 when this attribute is present.
4764 On RX targets, you may specify one or more vector numbers as arguments
4765 to the attribute, as well as naming an alternate table name.
4766 Parameters are handled sequentially, so one handler can be assigned to
4767 multiple entries in multiple tables.  One may also pass the magic
4768 string @code{"$default"} which causes the function to be used for any
4769 unfilled slots in the current table.
4771 This example shows a simple assignment of a function to one vector in
4772 the default table (note that preprocessor macros may be used for
4773 chip-specific symbolic vector names):
4774 @smallexample
4775 void __attribute__ ((interrupt (5))) txd1_handler ();
4776 @end smallexample
4778 This example assigns a function to two slots in the default table
4779 (using preprocessor macros defined elsewhere) and makes it the default
4780 for the @code{dct} table:
4781 @smallexample
4782 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4783         txd1_handler ();
4784 @end smallexample
4786 @item naked
4787 @cindex @code{naked} function attribute, RX
4788 This attribute allows the compiler to construct the
4789 requisite function declaration, while allowing the body of the
4790 function to be assembly code. The specified function will not have
4791 prologue/epilogue sequences generated by the compiler. Only basic
4792 @code{asm} statements can safely be included in naked functions
4793 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4794 basic @code{asm} and C code may appear to work, they cannot be
4795 depended upon to work reliably and are not supported.
4797 @item vector
4798 @cindex @code{vector} function attribute, RX
4799 This RX attribute is similar to the @code{interrupt} attribute, including its
4800 parameters, but does not make the function an interrupt-handler type
4801 function (i.e. it retains the normal C function calling ABI).  See the
4802 @code{interrupt} attribute for a description of its arguments.
4803 @end table
4805 @node S/390 Function Attributes
4806 @subsection S/390 Function Attributes
4808 These function attributes are supported on the S/390:
4810 @table @code
4811 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4812 @cindex @code{hotpatch} function attribute, S/390
4814 On S/390 System z targets, you can use this function attribute to
4815 make GCC generate a ``hot-patching'' function prologue.  If the
4816 @option{-mhotpatch=} command-line option is used at the same time,
4817 the @code{hotpatch} attribute takes precedence.  The first of the
4818 two arguments specifies the number of halfwords to be added before
4819 the function label.  A second argument can be used to specify the
4820 number of halfwords to be added after the function label.  For
4821 both arguments the maximum allowed value is 1000000.
4823 If both arguments are zero, hotpatching is disabled.
4824 @end table
4826 @node SH Function Attributes
4827 @subsection SH Function Attributes
4829 These function attributes are supported on the SH family of processors:
4831 @table @code
4832 @item function_vector
4833 @cindex @code{function_vector} function attribute, SH
4834 @cindex calling functions through the function vector on SH2A
4835 On SH2A targets, this attribute declares a function to be called using the
4836 TBR relative addressing mode.  The argument to this attribute is the entry
4837 number of the same function in a vector table containing all the TBR
4838 relative addressable functions.  For correct operation the TBR must be setup
4839 accordingly to point to the start of the vector table before any functions with
4840 this attribute are invoked.  Usually a good place to do the initialization is
4841 the startup routine.  The TBR relative vector table can have at max 256 function
4842 entries.  The jumps to these functions are generated using a SH2A specific,
4843 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
4844 from GNU binutils version 2.7 or later for this attribute to work correctly.
4846 In an application, for a function being called once, this attribute
4847 saves at least 8 bytes of code; and if other successive calls are being
4848 made to the same function, it saves 2 bytes of code per each of these
4849 calls.
4851 @item interrupt_handler
4852 @cindex @code{interrupt_handler} function attribute, SH
4853 Use this attribute to
4854 indicate that the specified function is an interrupt handler.  The compiler
4855 generates function entry and exit sequences suitable for use in an
4856 interrupt handler when this attribute is present.
4858 @item nosave_low_regs
4859 @cindex @code{nosave_low_regs} function attribute, SH
4860 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
4861 function should not save and restore registers R0..R7.  This can be used on SH3*
4862 and SH4* targets that have a second R0..R7 register bank for non-reentrant
4863 interrupt handlers.
4865 @item renesas
4866 @cindex @code{renesas} function attribute, SH
4867 On SH targets this attribute specifies that the function or struct follows the
4868 Renesas ABI.
4870 @item resbank
4871 @cindex @code{resbank} function attribute, SH
4872 On the SH2A target, this attribute enables the high-speed register
4873 saving and restoration using a register bank for @code{interrupt_handler}
4874 routines.  Saving to the bank is performed automatically after the CPU
4875 accepts an interrupt that uses a register bank.
4877 The nineteen 32-bit registers comprising general register R0 to R14,
4878 control register GBR, and system registers MACH, MACL, and PR and the
4879 vector table address offset are saved into a register bank.  Register
4880 banks are stacked in first-in last-out (FILO) sequence.  Restoration
4881 from the bank is executed by issuing a RESBANK instruction.
4883 @item sp_switch
4884 @cindex @code{sp_switch} function attribute, SH
4885 Use this attribute on the SH to indicate an @code{interrupt_handler}
4886 function should switch to an alternate stack.  It expects a string
4887 argument that names a global variable holding the address of the
4888 alternate stack.
4890 @smallexample
4891 void *alt_stack;
4892 void f () __attribute__ ((interrupt_handler,
4893                           sp_switch ("alt_stack")));
4894 @end smallexample
4896 @item trap_exit
4897 @cindex @code{trap_exit} function attribute, SH
4898 Use this attribute on the SH for an @code{interrupt_handler} to return using
4899 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4900 argument specifying the trap number to be used.
4902 @item trapa_handler
4903 @cindex @code{trapa_handler} function attribute, SH
4904 On SH targets this function attribute is similar to @code{interrupt_handler}
4905 but it does not save and restore all registers.
4906 @end table
4908 @node SPU Function Attributes
4909 @subsection SPU Function Attributes
4911 These function attributes are supported by the SPU back end:
4913 @table @code
4914 @item naked
4915 @cindex @code{naked} function attribute, SPU
4916 This attribute allows the compiler to construct the
4917 requisite function declaration, while allowing the body of the
4918 function to be assembly code. The specified function will not have
4919 prologue/epilogue sequences generated by the compiler. Only basic
4920 @code{asm} statements can safely be included in naked functions
4921 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4922 basic @code{asm} and C code may appear to work, they cannot be
4923 depended upon to work reliably and are not supported.
4924 @end table
4926 @node Symbian OS Function Attributes
4927 @subsection Symbian OS Function Attributes
4929 @xref{Microsoft Windows Function Attributes}, for discussion of the
4930 @code{dllexport} and @code{dllimport} attributes.
4932 @node Visium Function Attributes
4933 @subsection Visium Function Attributes
4935 These function attributes are supported by the Visium back end:
4937 @table @code
4938 @item interrupt
4939 @cindex @code{interrupt} function attribute, Visium
4940 Use this attribute to indicate
4941 that the specified function is an interrupt handler.  The compiler generates
4942 function entry and exit sequences suitable for use in an interrupt handler
4943 when this attribute is present.
4944 @end table
4946 @node x86 Function Attributes
4947 @subsection x86 Function Attributes
4949 These function attributes are supported by the x86 back end:
4951 @table @code
4952 @item cdecl
4953 @cindex @code{cdecl} function attribute, x86-32
4954 @cindex functions that pop the argument stack on x86-32
4955 @opindex mrtd
4956 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
4957 assume that the calling function pops off the stack space used to
4958 pass arguments.  This is
4959 useful to override the effects of the @option{-mrtd} switch.
4961 @item fastcall
4962 @cindex @code{fastcall} function attribute, x86-32
4963 @cindex functions that pop the argument stack on x86-32
4964 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
4965 pass the first argument (if of integral type) in the register ECX and
4966 the second argument (if of integral type) in the register EDX@.  Subsequent
4967 and other typed arguments are passed on the stack.  The called function
4968 pops the arguments off the stack.  If the number of arguments is variable all
4969 arguments are pushed on the stack.
4971 @item thiscall
4972 @cindex @code{thiscall} function attribute, x86-32
4973 @cindex functions that pop the argument stack on x86-32
4974 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
4975 pass the first argument (if of integral type) in the register ECX.
4976 Subsequent and other typed arguments are passed on the stack. The called
4977 function pops the arguments off the stack.
4978 If the number of arguments is variable all arguments are pushed on the
4979 stack.
4980 The @code{thiscall} attribute is intended for C++ non-static member functions.
4981 As a GCC extension, this calling convention can be used for C functions
4982 and for static member methods.
4984 @item ms_abi
4985 @itemx sysv_abi
4986 @cindex @code{ms_abi} function attribute, x86
4987 @cindex @code{sysv_abi} function attribute, x86
4989 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
4990 to indicate which calling convention should be used for a function.  The
4991 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
4992 while the @code{sysv_abi} attribute tells the compiler to use the ABI
4993 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
4994 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
4996 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
4997 requires the @option{-maccumulate-outgoing-args} option.
4999 @item callee_pop_aggregate_return (@var{number})
5000 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5002 On x86-32 targets, you can use this attribute to control how
5003 aggregates are returned in memory.  If the caller is responsible for
5004 popping the hidden pointer together with the rest of the arguments, specify
5005 @var{number} equal to zero.  If callee is responsible for popping the
5006 hidden pointer, specify @var{number} equal to one.  
5008 The default x86-32 ABI assumes that the callee pops the
5009 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5010 the compiler assumes that the
5011 caller pops the stack for hidden pointer.
5013 @item ms_hook_prologue
5014 @cindex @code{ms_hook_prologue} function attribute, x86
5016 On 32-bit and 64-bit x86 targets, you can use
5017 this function attribute to make GCC generate the ``hot-patching'' function
5018 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5019 and newer.
5021 @item regparm (@var{number})
5022 @cindex @code{regparm} function attribute, x86
5023 @cindex functions that are passed arguments in registers on x86-32
5024 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5025 pass arguments number one to @var{number} if they are of integral type
5026 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5027 take a variable number of arguments continue to be passed all of their
5028 arguments on the stack.
5030 Beware that on some ELF systems this attribute is unsuitable for
5031 global functions in shared libraries with lazy binding (which is the
5032 default).  Lazy binding sends the first call via resolving code in
5033 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5034 per the standard calling conventions.  Solaris 8 is affected by this.
5035 Systems with the GNU C Library version 2.1 or higher
5036 and FreeBSD are believed to be
5037 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5038 disabled with the linker or the loader if desired, to avoid the
5039 problem.)
5041 @item sseregparm
5042 @cindex @code{sseregparm} function attribute, x86
5043 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5044 causes the compiler to pass up to 3 floating-point arguments in
5045 SSE registers instead of on the stack.  Functions that take a
5046 variable number of arguments continue to pass all of their
5047 floating-point arguments on the stack.
5049 @item force_align_arg_pointer
5050 @cindex @code{force_align_arg_pointer} function attribute, x86
5051 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5052 applied to individual function definitions, generating an alternate
5053 prologue and epilogue that realigns the run-time stack if necessary.
5054 This supports mixing legacy codes that run with a 4-byte aligned stack
5055 with modern codes that keep a 16-byte stack for SSE compatibility.
5057 @item stdcall
5058 @cindex @code{stdcall} function attribute, x86-32
5059 @cindex functions that pop the argument stack on x86-32
5060 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5061 assume that the called function pops off the stack space used to
5062 pass arguments, unless it takes a variable number of arguments.
5064 @item target (@var{options})
5065 @cindex @code{target} function attribute
5066 As discussed in @ref{Common Function Attributes}, this attribute 
5067 allows specification of target-specific compilation options.
5069 On the x86, the following options are allowed:
5070 @table @samp
5071 @item abm
5072 @itemx no-abm
5073 @cindex @code{target("abm")} function attribute, x86
5074 Enable/disable the generation of the advanced bit instructions.
5076 @item aes
5077 @itemx no-aes
5078 @cindex @code{target("aes")} function attribute, x86
5079 Enable/disable the generation of the AES instructions.
5081 @item default
5082 @cindex @code{target("default")} function attribute, x86
5083 @xref{Function Multiversioning}, where it is used to specify the
5084 default function version.
5086 @item mmx
5087 @itemx no-mmx
5088 @cindex @code{target("mmx")} function attribute, x86
5089 Enable/disable the generation of the MMX instructions.
5091 @item pclmul
5092 @itemx no-pclmul
5093 @cindex @code{target("pclmul")} function attribute, x86
5094 Enable/disable the generation of the PCLMUL instructions.
5096 @item popcnt
5097 @itemx no-popcnt
5098 @cindex @code{target("popcnt")} function attribute, x86
5099 Enable/disable the generation of the POPCNT instruction.
5101 @item sse
5102 @itemx no-sse
5103 @cindex @code{target("sse")} function attribute, x86
5104 Enable/disable the generation of the SSE instructions.
5106 @item sse2
5107 @itemx no-sse2
5108 @cindex @code{target("sse2")} function attribute, x86
5109 Enable/disable the generation of the SSE2 instructions.
5111 @item sse3
5112 @itemx no-sse3
5113 @cindex @code{target("sse3")} function attribute, x86
5114 Enable/disable the generation of the SSE3 instructions.
5116 @item sse4
5117 @itemx no-sse4
5118 @cindex @code{target("sse4")} function attribute, x86
5119 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5120 and SSE4.2).
5122 @item sse4.1
5123 @itemx no-sse4.1
5124 @cindex @code{target("sse4.1")} function attribute, x86
5125 Enable/disable the generation of the sse4.1 instructions.
5127 @item sse4.2
5128 @itemx no-sse4.2
5129 @cindex @code{target("sse4.2")} function attribute, x86
5130 Enable/disable the generation of the sse4.2 instructions.
5132 @item sse4a
5133 @itemx no-sse4a
5134 @cindex @code{target("sse4a")} function attribute, x86
5135 Enable/disable the generation of the SSE4A instructions.
5137 @item fma4
5138 @itemx no-fma4
5139 @cindex @code{target("fma4")} function attribute, x86
5140 Enable/disable the generation of the FMA4 instructions.
5142 @item xop
5143 @itemx no-xop
5144 @cindex @code{target("xop")} function attribute, x86
5145 Enable/disable the generation of the XOP instructions.
5147 @item lwp
5148 @itemx no-lwp
5149 @cindex @code{target("lwp")} function attribute, x86
5150 Enable/disable the generation of the LWP instructions.
5152 @item ssse3
5153 @itemx no-ssse3
5154 @cindex @code{target("ssse3")} function attribute, x86
5155 Enable/disable the generation of the SSSE3 instructions.
5157 @item cld
5158 @itemx no-cld
5159 @cindex @code{target("cld")} function attribute, x86
5160 Enable/disable the generation of the CLD before string moves.
5162 @item fancy-math-387
5163 @itemx no-fancy-math-387
5164 @cindex @code{target("fancy-math-387")} function attribute, x86
5165 Enable/disable the generation of the @code{sin}, @code{cos}, and
5166 @code{sqrt} instructions on the 387 floating-point unit.
5168 @item fused-madd
5169 @itemx no-fused-madd
5170 @cindex @code{target("fused-madd")} function attribute, x86
5171 Enable/disable the generation of the fused multiply/add instructions.
5173 @item ieee-fp
5174 @itemx no-ieee-fp
5175 @cindex @code{target("ieee-fp")} function attribute, x86
5176 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5178 @item inline-all-stringops
5179 @itemx no-inline-all-stringops
5180 @cindex @code{target("inline-all-stringops")} function attribute, x86
5181 Enable/disable inlining of string operations.
5183 @item inline-stringops-dynamically
5184 @itemx no-inline-stringops-dynamically
5185 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5186 Enable/disable the generation of the inline code to do small string
5187 operations and calling the library routines for large operations.
5189 @item align-stringops
5190 @itemx no-align-stringops
5191 @cindex @code{target("align-stringops")} function attribute, x86
5192 Do/do not align destination of inlined string operations.
5194 @item recip
5195 @itemx no-recip
5196 @cindex @code{target("recip")} function attribute, x86
5197 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5198 instructions followed an additional Newton-Raphson step instead of
5199 doing a floating-point division.
5201 @item arch=@var{ARCH}
5202 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5203 Specify the architecture to generate code for in compiling the function.
5205 @item tune=@var{TUNE}
5206 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5207 Specify the architecture to tune for in compiling the function.
5209 @item fpmath=@var{FPMATH}
5210 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5211 Specify which floating-point unit to use.  You must specify the
5212 @code{target("fpmath=sse,387")} option as
5213 @code{target("fpmath=sse+387")} because the comma would separate
5214 different options.
5215 @end table
5217 On the x86, the inliner does not inline a
5218 function that has different target options than the caller, unless the
5219 callee has a subset of the target options of the caller.  For example
5220 a function declared with @code{target("sse3")} can inline a function
5221 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5222 @end table
5224 @node Xstormy16 Function Attributes
5225 @subsection Xstormy16 Function Attributes
5227 These function attributes are supported by the Xstormy16 back end:
5229 @table @code
5230 @item interrupt
5231 @cindex @code{interrupt} function attribute, Xstormy16
5232 Use this attribute to indicate
5233 that the specified function is an interrupt handler.  The compiler generates
5234 function entry and exit sequences suitable for use in an interrupt handler
5235 when this attribute is present.
5236 @end table
5238 @node Variable Attributes
5239 @section Specifying Attributes of Variables
5240 @cindex attribute of variables
5241 @cindex variable attributes
5243 The keyword @code{__attribute__} allows you to specify special
5244 attributes of variables or structure fields.  This keyword is followed
5245 by an attribute specification inside double parentheses.  Some
5246 attributes are currently defined generically for variables.
5247 Other attributes are defined for variables on particular target
5248 systems.  Other attributes are available for functions
5249 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5250 enumerators (@pxref{Enumerator Attributes}), and for types
5251 (@pxref{Type Attributes}).
5252 Other front ends might define more attributes
5253 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5255 @xref{Attribute Syntax}, for details of the exact syntax for using
5256 attributes.
5258 @menu
5259 * Common Variable Attributes::
5260 * AVR Variable Attributes::
5261 * Blackfin Variable Attributes::
5262 * H8/300 Variable Attributes::
5263 * IA-64 Variable Attributes::
5264 * M32R/D Variable Attributes::
5265 * MeP Variable Attributes::
5266 * Microsoft Windows Variable Attributes::
5267 * PowerPC Variable Attributes::
5268 * SPU Variable Attributes::
5269 * x86 Variable Attributes::
5270 * Xstormy16 Variable Attributes::
5271 @end menu
5273 @node Common Variable Attributes
5274 @subsection Common Variable Attributes
5276 The following attributes are supported on most targets.
5278 @table @code
5279 @cindex @code{aligned} variable attribute
5280 @item aligned (@var{alignment})
5281 This attribute specifies a minimum alignment for the variable or
5282 structure field, measured in bytes.  For example, the declaration:
5284 @smallexample
5285 int x __attribute__ ((aligned (16))) = 0;
5286 @end smallexample
5288 @noindent
5289 causes the compiler to allocate the global variable @code{x} on a
5290 16-byte boundary.  On a 68040, this could be used in conjunction with
5291 an @code{asm} expression to access the @code{move16} instruction which
5292 requires 16-byte aligned operands.
5294 You can also specify the alignment of structure fields.  For example, to
5295 create a double-word aligned @code{int} pair, you could write:
5297 @smallexample
5298 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5299 @end smallexample
5301 @noindent
5302 This is an alternative to creating a union with a @code{double} member,
5303 which forces the union to be double-word aligned.
5305 As in the preceding examples, you can explicitly specify the alignment
5306 (in bytes) that you wish the compiler to use for a given variable or
5307 structure field.  Alternatively, you can leave out the alignment factor
5308 and just ask the compiler to align a variable or field to the
5309 default alignment for the target architecture you are compiling for.
5310 The default alignment is sufficient for all scalar types, but may not be
5311 enough for all vector types on a target that supports vector operations.
5312 The default alignment is fixed for a particular target ABI.
5314 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5315 which is the largest alignment ever used for any data type on the
5316 target machine you are compiling for.  For example, you could write:
5318 @smallexample
5319 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5320 @end smallexample
5322 The compiler automatically sets the alignment for the declared
5323 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5324 often make copy operations more efficient, because the compiler can
5325 use whatever instructions copy the biggest chunks of memory when
5326 performing copies to or from the variables or fields that you have
5327 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5328 may change depending on command-line options.
5330 When used on a struct, or struct member, the @code{aligned} attribute can
5331 only increase the alignment; in order to decrease it, the @code{packed}
5332 attribute must be specified as well.  When used as part of a typedef, the
5333 @code{aligned} attribute can both increase and decrease alignment, and
5334 specifying the @code{packed} attribute generates a warning.
5336 Note that the effectiveness of @code{aligned} attributes may be limited
5337 by inherent limitations in your linker.  On many systems, the linker is
5338 only able to arrange for variables to be aligned up to a certain maximum
5339 alignment.  (For some linkers, the maximum supported alignment may
5340 be very very small.)  If your linker is only able to align variables
5341 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5342 in an @code{__attribute__} still only provides you with 8-byte
5343 alignment.  See your linker documentation for further information.
5345 The @code{aligned} attribute can also be used for functions
5346 (@pxref{Common Function Attributes}.)
5348 @item cleanup (@var{cleanup_function})
5349 @cindex @code{cleanup} variable attribute
5350 The @code{cleanup} attribute runs a function when the variable goes
5351 out of scope.  This attribute can only be applied to auto function
5352 scope variables; it may not be applied to parameters or variables
5353 with static storage duration.  The function must take one parameter,
5354 a pointer to a type compatible with the variable.  The return value
5355 of the function (if any) is ignored.
5357 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5358 is run during the stack unwinding that happens during the
5359 processing of the exception.  Note that the @code{cleanup} attribute
5360 does not allow the exception to be caught, only to perform an action.
5361 It is undefined what happens if @var{cleanup_function} does not
5362 return normally.
5364 @item common
5365 @itemx nocommon
5366 @cindex @code{common} variable attribute
5367 @cindex @code{nocommon} variable attribute
5368 @opindex fcommon
5369 @opindex fno-common
5370 The @code{common} attribute requests GCC to place a variable in
5371 ``common'' storage.  The @code{nocommon} attribute requests the
5372 opposite---to allocate space for it directly.
5374 These attributes override the default chosen by the
5375 @option{-fno-common} and @option{-fcommon} flags respectively.
5377 @item deprecated
5378 @itemx deprecated (@var{msg})
5379 @cindex @code{deprecated} variable attribute
5380 The @code{deprecated} attribute results in a warning if the variable
5381 is used anywhere in the source file.  This is useful when identifying
5382 variables that are expected to be removed in a future version of a
5383 program.  The warning also includes the location of the declaration
5384 of the deprecated variable, to enable users to easily find further
5385 information about why the variable is deprecated, or what they should
5386 do instead.  Note that the warning only occurs for uses:
5388 @smallexample
5389 extern int old_var __attribute__ ((deprecated));
5390 extern int old_var;
5391 int new_fn () @{ return old_var; @}
5392 @end smallexample
5394 @noindent
5395 results in a warning on line 3 but not line 2.  The optional @var{msg}
5396 argument, which must be a string, is printed in the warning if
5397 present.
5399 The @code{deprecated} attribute can also be used for functions and
5400 types (@pxref{Common Function Attributes},
5401 @pxref{Common Type Attributes}).
5403 @item mode (@var{mode})
5404 @cindex @code{mode} variable attribute
5405 This attribute specifies the data type for the declaration---whichever
5406 type corresponds to the mode @var{mode}.  This in effect lets you
5407 request an integer or floating-point type according to its width.
5409 You may also specify a mode of @code{byte} or @code{__byte__} to
5410 indicate the mode corresponding to a one-byte integer, @code{word} or
5411 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5412 or @code{__pointer__} for the mode used to represent pointers.
5414 @item packed
5415 @cindex @code{packed} variable attribute
5416 The @code{packed} attribute specifies that a variable or structure field
5417 should have the smallest possible alignment---one byte for a variable,
5418 and one bit for a field, unless you specify a larger value with the
5419 @code{aligned} attribute.
5421 Here is a structure in which the field @code{x} is packed, so that it
5422 immediately follows @code{a}:
5424 @smallexample
5425 struct foo
5427   char a;
5428   int x[2] __attribute__ ((packed));
5430 @end smallexample
5432 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5433 @code{packed} attribute on bit-fields of type @code{char}.  This has
5434 been fixed in GCC 4.4 but the change can lead to differences in the
5435 structure layout.  See the documentation of
5436 @option{-Wpacked-bitfield-compat} for more information.
5438 @item section ("@var{section-name}")
5439 @cindex @code{section} variable attribute
5440 Normally, the compiler places the objects it generates in sections like
5441 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5442 or you need certain particular variables to appear in special sections,
5443 for example to map to special hardware.  The @code{section}
5444 attribute specifies that a variable (or function) lives in a particular
5445 section.  For example, this small program uses several specific section names:
5447 @smallexample
5448 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5449 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5450 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5451 int init_data __attribute__ ((section ("INITDATA")));
5453 main()
5455   /* @r{Initialize stack pointer} */
5456   init_sp (stack + sizeof (stack));
5458   /* @r{Initialize initialized data} */
5459   memcpy (&init_data, &data, &edata - &data);
5461   /* @r{Turn on the serial ports} */
5462   init_duart (&a);
5463   init_duart (&b);
5465 @end smallexample
5467 @noindent
5468 Use the @code{section} attribute with
5469 @emph{global} variables and not @emph{local} variables,
5470 as shown in the example.
5472 You may use the @code{section} attribute with initialized or
5473 uninitialized global variables but the linker requires
5474 each object be defined once, with the exception that uninitialized
5475 variables tentatively go in the @code{common} (or @code{bss}) section
5476 and can be multiply ``defined''.  Using the @code{section} attribute
5477 changes what section the variable goes into and may cause the
5478 linker to issue an error if an uninitialized variable has multiple
5479 definitions.  You can force a variable to be initialized with the
5480 @option{-fno-common} flag or the @code{nocommon} attribute.
5482 Some file formats do not support arbitrary sections so the @code{section}
5483 attribute is not available on all platforms.
5484 If you need to map the entire contents of a module to a particular
5485 section, consider using the facilities of the linker instead.
5487 @item tls_model ("@var{tls_model}")
5488 @cindex @code{tls_model} variable attribute
5489 The @code{tls_model} attribute sets thread-local storage model
5490 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5491 overriding @option{-ftls-model=} command-line switch on a per-variable
5492 basis.
5493 The @var{tls_model} argument should be one of @code{global-dynamic},
5494 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5496 Not all targets support this attribute.
5498 @item unused
5499 @cindex @code{unused} variable attribute
5500 This attribute, attached to a variable, means that the variable is meant
5501 to be possibly unused.  GCC does not produce a warning for this
5502 variable.
5504 @item used
5505 @cindex @code{used} variable attribute
5506 This attribute, attached to a variable with static storage, means that
5507 the variable must be emitted even if it appears that the variable is not
5508 referenced.
5510 When applied to a static data member of a C++ class template, the
5511 attribute also means that the member is instantiated if the
5512 class itself is instantiated.
5514 @item vector_size (@var{bytes})
5515 @cindex @code{vector_size} variable attribute
5516 This attribute specifies the vector size for the variable, measured in
5517 bytes.  For example, the declaration:
5519 @smallexample
5520 int foo __attribute__ ((vector_size (16)));
5521 @end smallexample
5523 @noindent
5524 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5525 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5526 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5528 This attribute is only applicable to integral and float scalars,
5529 although arrays, pointers, and function return values are allowed in
5530 conjunction with this construct.
5532 Aggregates with this attribute are invalid, even if they are of the same
5533 size as a corresponding scalar.  For example, the declaration:
5535 @smallexample
5536 struct S @{ int a; @};
5537 struct S  __attribute__ ((vector_size (16))) foo;
5538 @end smallexample
5540 @noindent
5541 is invalid even if the size of the structure is the same as the size of
5542 the @code{int}.
5544 @item weak
5545 @cindex @code{weak} variable attribute
5546 The @code{weak} attribute is described in
5547 @ref{Common Function Attributes}.
5549 @end table
5551 @node AVR Variable Attributes
5552 @subsection AVR Variable Attributes
5554 @table @code
5555 @item progmem
5556 @cindex @code{progmem} variable attribute, AVR
5557 The @code{progmem} attribute is used on the AVR to place read-only
5558 data in the non-volatile program memory (flash). The @code{progmem}
5559 attribute accomplishes this by putting respective variables into a
5560 section whose name starts with @code{.progmem}.
5562 This attribute works similar to the @code{section} attribute
5563 but adds additional checking. Notice that just like the
5564 @code{section} attribute, @code{progmem} affects the location
5565 of the data but not how this data is accessed.
5567 In order to read data located with the @code{progmem} attribute
5568 (inline) assembler must be used.
5569 @smallexample
5570 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5571 #include <avr/pgmspace.h> 
5573 /* Locate var in flash memory */
5574 const int var[2] PROGMEM = @{ 1, 2 @};
5576 int read_var (int i)
5578     /* Access var[] by accessor macro from avr/pgmspace.h */
5579     return (int) pgm_read_word (& var[i]);
5581 @end smallexample
5583 AVR is a Harvard architecture processor and data and read-only data
5584 normally resides in the data memory (RAM).
5586 See also the @ref{AVR Named Address Spaces} section for
5587 an alternate way to locate and access data in flash memory.
5589 @item io
5590 @itemx io (@var{addr})
5591 @cindex @code{io} variable attribute, AVR
5592 Variables with the @code{io} attribute are used to address
5593 memory-mapped peripherals in the io address range.
5594 If an address is specified, the variable
5595 is assigned that address, and the value is interpreted as an
5596 address in the data address space.
5597 Example:
5599 @smallexample
5600 volatile int porta __attribute__((io (0x22)));
5601 @end smallexample
5603 The address specified in the address in the data address range.
5605 Otherwise, the variable it is not assigned an address, but the
5606 compiler will still use in/out instructions where applicable,
5607 assuming some other module assigns an address in the io address range.
5608 Example:
5610 @smallexample
5611 extern volatile int porta __attribute__((io));
5612 @end smallexample
5614 @item io_low
5615 @itemx io_low (@var{addr})
5616 @cindex @code{io_low} variable attribute, AVR
5617 This is like the @code{io} attribute, but additionally it informs the
5618 compiler that the object lies in the lower half of the I/O area,
5619 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5620 instructions.
5622 @item address
5623 @itemx address (@var{addr})
5624 @cindex @code{address} variable attribute, AVR
5625 Variables with the @code{address} attribute are used to address
5626 memory-mapped peripherals that may lie outside the io address range.
5628 @smallexample
5629 volatile int porta __attribute__((address (0x600)));
5630 @end smallexample
5632 @end table
5634 @node Blackfin Variable Attributes
5635 @subsection Blackfin Variable Attributes
5637 Three attributes are currently defined for the Blackfin.
5639 @table @code
5640 @item l1_data
5641 @itemx l1_data_A
5642 @itemx l1_data_B
5643 @cindex @code{l1_data} variable attribute, Blackfin
5644 @cindex @code{l1_data_A} variable attribute, Blackfin
5645 @cindex @code{l1_data_B} variable attribute, Blackfin
5646 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5647 Variables with @code{l1_data} attribute are put into the specific section
5648 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5649 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5650 attribute are put into the specific section named @code{.l1.data.B}.
5652 @item l2
5653 @cindex @code{l2} variable attribute, Blackfin
5654 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5655 Variables with @code{l2} attribute are put into the specific section
5656 named @code{.l2.data}.
5657 @end table
5659 @node H8/300 Variable Attributes
5660 @subsection H8/300 Variable Attributes
5662 These variable attributes are available for H8/300 targets:
5664 @table @code
5665 @item eightbit_data
5666 @cindex @code{eightbit_data} variable attribute, H8/300
5667 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5668 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5669 variable should be placed into the eight-bit data section.
5670 The compiler generates more efficient code for certain operations
5671 on data in the eight-bit data area.  Note the eight-bit data area is limited to
5672 256 bytes of data.
5674 You must use GAS and GLD from GNU binutils version 2.7 or later for
5675 this attribute to work correctly.
5677 @item tiny_data
5678 @cindex @code{tiny_data} variable attribute, H8/300
5679 @cindex tiny data section on the H8/300H and H8S
5680 Use this attribute on the H8/300H and H8S to indicate that the specified
5681 variable should be placed into the tiny data section.
5682 The compiler generates more efficient code for loads and stores
5683 on data in the tiny data section.  Note the tiny data area is limited to
5684 slightly under 32KB of data.
5686 @end table
5688 @node IA-64 Variable Attributes
5689 @subsection IA-64 Variable Attributes
5691 The IA-64 back end supports the following variable attribute:
5693 @table @code
5694 @item model (@var{model-name})
5695 @cindex @code{model} variable attribute, IA-64
5697 On IA-64, use this attribute to set the addressability of an object.
5698 At present, the only supported identifier for @var{model-name} is
5699 @code{small}, indicating addressability via ``small'' (22-bit)
5700 addresses (so that their addresses can be loaded with the @code{addl}
5701 instruction).  Caveat: such addressing is by definition not position
5702 independent and hence this attribute must not be used for objects
5703 defined by shared libraries.
5705 @end table
5707 @node M32R/D Variable Attributes
5708 @subsection M32R/D Variable Attributes
5710 One attribute is currently defined for the M32R/D@.
5712 @table @code
5713 @item model (@var{model-name})
5714 @cindex @code{model-name} variable attribute, M32R/D
5715 @cindex variable addressability on the M32R/D
5716 Use this attribute on the M32R/D to set the addressability of an object.
5717 The identifier @var{model-name} is one of @code{small}, @code{medium},
5718 or @code{large}, representing each of the code models.
5720 Small model objects live in the lower 16MB of memory (so that their
5721 addresses can be loaded with the @code{ld24} instruction).
5723 Medium and large model objects may live anywhere in the 32-bit address space
5724 (the compiler generates @code{seth/add3} instructions to load their
5725 addresses).
5726 @end table
5728 @node MeP Variable Attributes
5729 @subsection MeP Variable Attributes
5731 The MeP target has a number of addressing modes and busses.  The
5732 @code{near} space spans the standard memory space's first 16 megabytes
5733 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5734 The @code{based} space is a 128-byte region in the memory space that
5735 is addressed relative to the @code{$tp} register.  The @code{tiny}
5736 space is a 65536-byte region relative to the @code{$gp} register.  In
5737 addition to these memory regions, the MeP target has a separate 16-bit
5738 control bus which is specified with @code{cb} attributes.
5740 @table @code
5742 @item based
5743 @cindex @code{based} variable attribute, MeP
5744 Any variable with the @code{based} attribute is assigned to the
5745 @code{.based} section, and is accessed with relative to the
5746 @code{$tp} register.
5748 @item tiny
5749 @cindex @code{tiny} variable attribute, MeP
5750 Likewise, the @code{tiny} attribute assigned variables to the
5751 @code{.tiny} section, relative to the @code{$gp} register.
5753 @item near
5754 @cindex @code{near} variable attribute, MeP
5755 Variables with the @code{near} attribute are assumed to have addresses
5756 that fit in a 24-bit addressing mode.  This is the default for large
5757 variables (@code{-mtiny=4} is the default) but this attribute can
5758 override @code{-mtiny=} for small variables, or override @code{-ml}.
5760 @item far
5761 @cindex @code{far} variable attribute, MeP
5762 Variables with the @code{far} attribute are addressed using a full
5763 32-bit address.  Since this covers the entire memory space, this
5764 allows modules to make no assumptions about where variables might be
5765 stored.
5767 @item io
5768 @cindex @code{io} variable attribute, MeP
5769 @itemx io (@var{addr})
5770 Variables with the @code{io} attribute are used to address
5771 memory-mapped peripherals.  If an address is specified, the variable
5772 is assigned that address, else it is not assigned an address (it is
5773 assumed some other module assigns an address).  Example:
5775 @smallexample
5776 int timer_count __attribute__((io(0x123)));
5777 @end smallexample
5779 @item cb
5780 @itemx cb (@var{addr})
5781 @cindex @code{cb} variable attribute, MeP
5782 Variables with the @code{cb} attribute are used to access the control
5783 bus, using special instructions.  @code{addr} indicates the control bus
5784 address.  Example:
5786 @smallexample
5787 int cpu_clock __attribute__((cb(0x123)));
5788 @end smallexample
5790 @end table
5792 @node Microsoft Windows Variable Attributes
5793 @subsection Microsoft Windows Variable Attributes
5795 You can use these attributes on Microsoft Windows targets.
5796 @ref{x86 Variable Attributes} for additional Windows compatibility
5797 attributes available on all x86 targets.
5799 @table @code
5800 @item dllimport
5801 @itemx dllexport
5802 @cindex @code{dllimport} variable attribute
5803 @cindex @code{dllexport} variable attribute
5804 The @code{dllimport} and @code{dllexport} attributes are described in
5805 @ref{Microsoft Windows Function Attributes}.
5807 @item selectany
5808 @cindex @code{selectany} variable attribute
5809 The @code{selectany} attribute causes an initialized global variable to
5810 have link-once semantics.  When multiple definitions of the variable are
5811 encountered by the linker, the first is selected and the remainder are
5812 discarded.  Following usage by the Microsoft compiler, the linker is told
5813 @emph{not} to warn about size or content differences of the multiple
5814 definitions.
5816 Although the primary usage of this attribute is for POD types, the
5817 attribute can also be applied to global C++ objects that are initialized
5818 by a constructor.  In this case, the static initialization and destruction
5819 code for the object is emitted in each translation defining the object,
5820 but the calls to the constructor and destructor are protected by a
5821 link-once guard variable.
5823 The @code{selectany} attribute is only available on Microsoft Windows
5824 targets.  You can use @code{__declspec (selectany)} as a synonym for
5825 @code{__attribute__ ((selectany))} for compatibility with other
5826 compilers.
5828 @item shared
5829 @cindex @code{shared} variable attribute
5830 On Microsoft Windows, in addition to putting variable definitions in a named
5831 section, the section can also be shared among all running copies of an
5832 executable or DLL@.  For example, this small program defines shared data
5833 by putting it in a named section @code{shared} and marking the section
5834 shareable:
5836 @smallexample
5837 int foo __attribute__((section ("shared"), shared)) = 0;
5840 main()
5842   /* @r{Read and write foo.  All running
5843      copies see the same value.}  */
5844   return 0;
5846 @end smallexample
5848 @noindent
5849 You may only use the @code{shared} attribute along with @code{section}
5850 attribute with a fully-initialized global definition because of the way
5851 linkers work.  See @code{section} attribute for more information.
5853 The @code{shared} attribute is only available on Microsoft Windows@.
5855 @end table
5857 @node PowerPC Variable Attributes
5858 @subsection PowerPC Variable Attributes
5860 Three attributes currently are defined for PowerPC configurations:
5861 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5863 @cindex @code{ms_struct} variable attribute, PowerPC
5864 @cindex @code{gcc_struct} variable attribute, PowerPC
5865 For full documentation of the struct attributes please see the
5866 documentation in @ref{x86 Variable Attributes}.
5868 @cindex @code{altivec} variable attribute, PowerPC
5869 For documentation of @code{altivec} attribute please see the
5870 documentation in @ref{PowerPC Type Attributes}.
5872 @node SPU Variable Attributes
5873 @subsection SPU Variable Attributes
5875 @cindex @code{spu_vector} variable attribute, SPU
5876 The SPU supports the @code{spu_vector} attribute for variables.  For
5877 documentation of this attribute please see the documentation in
5878 @ref{SPU Type Attributes}.
5880 @node x86 Variable Attributes
5881 @subsection x86 Variable Attributes
5883 Two attributes are currently defined for x86 configurations:
5884 @code{ms_struct} and @code{gcc_struct}.
5886 @table @code
5887 @item ms_struct
5888 @itemx gcc_struct
5889 @cindex @code{ms_struct} variable attribute, x86
5890 @cindex @code{gcc_struct} variable attribute, x86
5892 If @code{packed} is used on a structure, or if bit-fields are used,
5893 it may be that the Microsoft ABI lays out the structure differently
5894 than the way GCC normally does.  Particularly when moving packed
5895 data between functions compiled with GCC and the native Microsoft compiler
5896 (either via function call or as data in a file), it may be necessary to access
5897 either format.
5899 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
5900 compilers to match the native Microsoft compiler.
5902 The Microsoft structure layout algorithm is fairly simple with the exception
5903 of the bit-field packing.  
5904 The padding and alignment of members of structures and whether a bit-field 
5905 can straddle a storage-unit boundary are determine by these rules:
5907 @enumerate
5908 @item Structure members are stored sequentially in the order in which they are
5909 declared: the first member has the lowest memory address and the last member
5910 the highest.
5912 @item Every data object has an alignment requirement.  The alignment requirement
5913 for all data except structures, unions, and arrays is either the size of the
5914 object or the current packing size (specified with either the
5915 @code{aligned} attribute or the @code{pack} pragma),
5916 whichever is less.  For structures, unions, and arrays,
5917 the alignment requirement is the largest alignment requirement of its members.
5918 Every object is allocated an offset so that:
5920 @smallexample
5921 offset % alignment_requirement == 0
5922 @end smallexample
5924 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5925 unit if the integral types are the same size and if the next bit-field fits
5926 into the current allocation unit without crossing the boundary imposed by the
5927 common alignment requirements of the bit-fields.
5928 @end enumerate
5930 MSVC interprets zero-length bit-fields in the following ways:
5932 @enumerate
5933 @item If a zero-length bit-field is inserted between two bit-fields that
5934 are normally coalesced, the bit-fields are not coalesced.
5936 For example:
5938 @smallexample
5939 struct
5940  @{
5941    unsigned long bf_1 : 12;
5942    unsigned long : 0;
5943    unsigned long bf_2 : 12;
5944  @} t1;
5945 @end smallexample
5947 @noindent
5948 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5949 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5951 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5952 alignment of the zero-length bit-field is greater than the member that follows it,
5953 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5955 For example:
5957 @smallexample
5958 struct
5959  @{
5960    char foo : 4;
5961    short : 0;
5962    char bar;
5963  @} t2;
5965 struct
5966  @{
5967    char foo : 4;
5968    short : 0;
5969    double bar;
5970  @} t3;
5971 @end smallexample
5973 @noindent
5974 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5975 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5976 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5977 of the structure.
5979 Taking this into account, it is important to note the following:
5981 @enumerate
5982 @item If a zero-length bit-field follows a normal bit-field, the type of the
5983 zero-length bit-field may affect the alignment of the structure as whole. For
5984 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5985 normal bit-field, and is of type short.
5987 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5988 still affect the alignment of the structure:
5990 @smallexample
5991 struct
5992  @{
5993    char foo : 6;
5994    long : 0;
5995  @} t4;
5996 @end smallexample
5998 @noindent
5999 Here, @code{t4} takes up 4 bytes.
6000 @end enumerate
6002 @item Zero-length bit-fields following non-bit-field members are ignored:
6004 @smallexample
6005 struct
6006  @{
6007    char foo;
6008    long : 0;
6009    char bar;
6010  @} t5;
6011 @end smallexample
6013 @noindent
6014 Here, @code{t5} takes up 2 bytes.
6015 @end enumerate
6016 @end table
6018 @node Xstormy16 Variable Attributes
6019 @subsection Xstormy16 Variable Attributes
6021 One attribute is currently defined for xstormy16 configurations:
6022 @code{below100}.
6024 @table @code
6025 @item below100
6026 @cindex @code{below100} variable attribute, Xstormy16
6028 If a variable has the @code{below100} attribute (@code{BELOW100} is
6029 allowed also), GCC places the variable in the first 0x100 bytes of
6030 memory and use special opcodes to access it.  Such variables are
6031 placed in either the @code{.bss_below100} section or the
6032 @code{.data_below100} section.
6034 @end table
6036 @node Type Attributes
6037 @section Specifying Attributes of Types
6038 @cindex attribute of types
6039 @cindex type attributes
6041 The keyword @code{__attribute__} allows you to specify special
6042 attributes of types.  Some type attributes apply only to @code{struct}
6043 and @code{union} types, while others can apply to any type defined
6044 via a @code{typedef} declaration.  Other attributes are defined for
6045 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6046 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6047 variables (@pxref{Variable Attributes}).
6049 The @code{__attribute__} keyword is followed by an attribute specification
6050 inside double parentheses.  
6052 You may specify type attributes in an enum, struct or union type
6053 declaration or definition by placing them immediately after the
6054 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6055 syntax is to place them just past the closing curly brace of the
6056 definition.
6058 You can also include type attributes in a @code{typedef} declaration.
6059 @xref{Attribute Syntax}, for details of the exact syntax for using
6060 attributes.
6062 @menu
6063 * Common Type Attributes::
6064 * ARM Type Attributes::
6065 * MeP Type Attributes::
6066 * PowerPC Type Attributes::
6067 * SPU Type Attributes::
6068 * x86 Type Attributes::
6069 @end menu
6071 @node Common Type Attributes
6072 @subsection Common Type Attributes
6074 The following type attributes are supported on most targets.
6076 @table @code
6077 @cindex @code{aligned} type attribute
6078 @item aligned (@var{alignment})
6079 This attribute specifies a minimum alignment (in bytes) for variables
6080 of the specified type.  For example, the declarations:
6082 @smallexample
6083 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6084 typedef int more_aligned_int __attribute__ ((aligned (8)));
6085 @end smallexample
6087 @noindent
6088 force the compiler to ensure (as far as it can) that each variable whose
6089 type is @code{struct S} or @code{more_aligned_int} is allocated and
6090 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6091 variables of type @code{struct S} aligned to 8-byte boundaries allows
6092 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6093 store) instructions when copying one variable of type @code{struct S} to
6094 another, thus improving run-time efficiency.
6096 Note that the alignment of any given @code{struct} or @code{union} type
6097 is required by the ISO C standard to be at least a perfect multiple of
6098 the lowest common multiple of the alignments of all of the members of
6099 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6100 effectively adjust the alignment of a @code{struct} or @code{union}
6101 type by attaching an @code{aligned} attribute to any one of the members
6102 of such a type, but the notation illustrated in the example above is a
6103 more obvious, intuitive, and readable way to request the compiler to
6104 adjust the alignment of an entire @code{struct} or @code{union} type.
6106 As in the preceding example, you can explicitly specify the alignment
6107 (in bytes) that you wish the compiler to use for a given @code{struct}
6108 or @code{union} type.  Alternatively, you can leave out the alignment factor
6109 and just ask the compiler to align a type to the maximum
6110 useful alignment for the target machine you are compiling for.  For
6111 example, you could write:
6113 @smallexample
6114 struct S @{ short f[3]; @} __attribute__ ((aligned));
6115 @end smallexample
6117 Whenever you leave out the alignment factor in an @code{aligned}
6118 attribute specification, the compiler automatically sets the alignment
6119 for the type to the largest alignment that is ever used for any data
6120 type on the target machine you are compiling for.  Doing this can often
6121 make copy operations more efficient, because the compiler can use
6122 whatever instructions copy the biggest chunks of memory when performing
6123 copies to or from the variables that have types that you have aligned
6124 this way.
6126 In the example above, if the size of each @code{short} is 2 bytes, then
6127 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6128 power of two that is greater than or equal to that is 8, so the
6129 compiler sets the alignment for the entire @code{struct S} type to 8
6130 bytes.
6132 Note that although you can ask the compiler to select a time-efficient
6133 alignment for a given type and then declare only individual stand-alone
6134 objects of that type, the compiler's ability to select a time-efficient
6135 alignment is primarily useful only when you plan to create arrays of
6136 variables having the relevant (efficiently aligned) type.  If you
6137 declare or use arrays of variables of an efficiently-aligned type, then
6138 it is likely that your program also does pointer arithmetic (or
6139 subscripting, which amounts to the same thing) on pointers to the
6140 relevant type, and the code that the compiler generates for these
6141 pointer arithmetic operations is often more efficient for
6142 efficiently-aligned types than for other types.
6144 The @code{aligned} attribute can only increase the alignment; but you
6145 can decrease it by specifying @code{packed} as well.  See below.
6147 Note that the effectiveness of @code{aligned} attributes may be limited
6148 by inherent limitations in your linker.  On many systems, the linker is
6149 only able to arrange for variables to be aligned up to a certain maximum
6150 alignment.  (For some linkers, the maximum supported alignment may
6151 be very very small.)  If your linker is only able to align variables
6152 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6153 in an @code{__attribute__} still only provides you with 8-byte
6154 alignment.  See your linker documentation for further information.
6156 @opindex fshort-enums
6157 Specifying this attribute for @code{struct} and @code{union} types is
6158 equivalent to specifying the @code{packed} attribute on each of the
6159 structure or union members.  Specifying the @option{-fshort-enums}
6160 flag on the line is equivalent to specifying the @code{packed}
6161 attribute on all @code{enum} definitions.
6163 In the following example @code{struct my_packed_struct}'s members are
6164 packed closely together, but the internal layout of its @code{s} member
6165 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6166 be packed too.
6168 @smallexample
6169 struct my_unpacked_struct
6170  @{
6171     char c;
6172     int i;
6173  @};
6175 struct __attribute__ ((__packed__)) my_packed_struct
6176   @{
6177      char c;
6178      int  i;
6179      struct my_unpacked_struct s;
6180   @};
6181 @end smallexample
6183 You may only specify this attribute on the definition of an @code{enum},
6184 @code{struct} or @code{union}, not on a @code{typedef} that does not
6185 also define the enumerated type, structure or union.
6187 @item bnd_variable_size
6188 @cindex @code{bnd_variable_size} type attribute
6189 @cindex Pointer Bounds Checker attributes
6190 When applied to a structure field, this attribute tells Pointer
6191 Bounds Checker that the size of this field should not be computed
6192 using static type information.  It may be used to mark variably-sized
6193 static array fields placed at the end of a structure.
6195 @smallexample
6196 struct S
6198   int size;
6199   char data[1];
6201 S *p = (S *)malloc (sizeof(S) + 100);
6202 p->data[10] = 0; //Bounds violation
6203 @end smallexample
6205 @noindent
6206 By using an attribute for the field we may avoid unwanted bound
6207 violation checks:
6209 @smallexample
6210 struct S
6212   int size;
6213   char data[1] __attribute__((bnd_variable_size));
6215 S *p = (S *)malloc (sizeof(S) + 100);
6216 p->data[10] = 0; //OK
6217 @end smallexample
6219 @item deprecated
6220 @itemx deprecated (@var{msg})
6221 @cindex @code{deprecated} type attribute
6222 The @code{deprecated} attribute results in a warning if the type
6223 is used anywhere in the source file.  This is useful when identifying
6224 types that are expected to be removed in a future version of a program.
6225 If possible, the warning also includes the location of the declaration
6226 of the deprecated type, to enable users to easily find further
6227 information about why the type is deprecated, or what they should do
6228 instead.  Note that the warnings only occur for uses and then only
6229 if the type is being applied to an identifier that itself is not being
6230 declared as deprecated.
6232 @smallexample
6233 typedef int T1 __attribute__ ((deprecated));
6234 T1 x;
6235 typedef T1 T2;
6236 T2 y;
6237 typedef T1 T3 __attribute__ ((deprecated));
6238 T3 z __attribute__ ((deprecated));
6239 @end smallexample
6241 @noindent
6242 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6243 warning is issued for line 4 because T2 is not explicitly
6244 deprecated.  Line 5 has no warning because T3 is explicitly
6245 deprecated.  Similarly for line 6.  The optional @var{msg}
6246 argument, which must be a string, is printed in the warning if
6247 present.
6249 The @code{deprecated} attribute can also be used for functions and
6250 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6252 @item designated_init
6253 @cindex @code{designated_init} type attribute
6254 This attribute may only be applied to structure types.  It indicates
6255 that any initialization of an object of this type must use designated
6256 initializers rather than positional initializers.  The intent of this
6257 attribute is to allow the programmer to indicate that a structure's
6258 layout may change, and that therefore relying on positional
6259 initialization will result in future breakage.
6261 GCC emits warnings based on this attribute by default; use
6262 @option{-Wno-designated-init} to suppress them.
6264 @item may_alias
6265 @cindex @code{may_alias} type attribute
6266 Accesses through pointers to types with this attribute are not subject
6267 to type-based alias analysis, but are instead assumed to be able to alias
6268 any other type of objects.
6269 In the context of section 6.5 paragraph 7 of the C99 standard,
6270 an lvalue expression
6271 dereferencing such a pointer is treated like having a character type.
6272 See @option{-fstrict-aliasing} for more information on aliasing issues.
6273 This extension exists to support some vector APIs, in which pointers to
6274 one vector type are permitted to alias pointers to a different vector type.
6276 Note that an object of a type with this attribute does not have any
6277 special semantics.
6279 Example of use:
6281 @smallexample
6282 typedef short __attribute__((__may_alias__)) short_a;
6285 main (void)
6287   int a = 0x12345678;
6288   short_a *b = (short_a *) &a;
6290   b[1] = 0;
6292   if (a == 0x12345678)
6293     abort();
6295   exit(0);
6297 @end smallexample
6299 @noindent
6300 If you replaced @code{short_a} with @code{short} in the variable
6301 declaration, the above program would abort when compiled with
6302 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6303 above.
6305 @item packed
6306 @cindex @code{packed} type attribute
6307 This attribute, attached to @code{struct} or @code{union} type
6308 definition, specifies that each member (other than zero-width bit-fields)
6309 of the structure or union is placed to minimize the memory required.  When
6310 attached to an @code{enum} definition, it indicates that the smallest
6311 integral type should be used.
6313 @item transparent_union
6314 @cindex @code{transparent_union} type attribute
6316 This attribute, attached to a @code{union} type definition, indicates
6317 that any function parameter having that union type causes calls to that
6318 function to be treated in a special way.
6320 First, the argument corresponding to a transparent union type can be of
6321 any type in the union; no cast is required.  Also, if the union contains
6322 a pointer type, the corresponding argument can be a null pointer
6323 constant or a void pointer expression; and if the union contains a void
6324 pointer type, the corresponding argument can be any pointer expression.
6325 If the union member type is a pointer, qualifiers like @code{const} on
6326 the referenced type must be respected, just as with normal pointer
6327 conversions.
6329 Second, the argument is passed to the function using the calling
6330 conventions of the first member of the transparent union, not the calling
6331 conventions of the union itself.  All members of the union must have the
6332 same machine representation; this is necessary for this argument passing
6333 to work properly.
6335 Transparent unions are designed for library functions that have multiple
6336 interfaces for compatibility reasons.  For example, suppose the
6337 @code{wait} function must accept either a value of type @code{int *} to
6338 comply with POSIX, or a value of type @code{union wait *} to comply with
6339 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6340 @code{wait} would accept both kinds of arguments, but it would also
6341 accept any other pointer type and this would make argument type checking
6342 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6343 as follows:
6345 @smallexample
6346 typedef union __attribute__ ((__transparent_union__))
6347   @{
6348     int *__ip;
6349     union wait *__up;
6350   @} wait_status_ptr_t;
6352 pid_t wait (wait_status_ptr_t);
6353 @end smallexample
6355 @noindent
6356 This interface allows either @code{int *} or @code{union wait *}
6357 arguments to be passed, using the @code{int *} calling convention.
6358 The program can call @code{wait} with arguments of either type:
6360 @smallexample
6361 int w1 () @{ int w; return wait (&w); @}
6362 int w2 () @{ union wait w; return wait (&w); @}
6363 @end smallexample
6365 @noindent
6366 With this interface, @code{wait}'s implementation might look like this:
6368 @smallexample
6369 pid_t wait (wait_status_ptr_t p)
6371   return waitpid (-1, p.__ip, 0);
6373 @end smallexample
6375 @item unused
6376 @cindex @code{unused} type attribute
6377 When attached to a type (including a @code{union} or a @code{struct}),
6378 this attribute means that variables of that type are meant to appear
6379 possibly unused.  GCC does not produce a warning for any variables of
6380 that type, even if the variable appears to do nothing.  This is often
6381 the case with lock or thread classes, which are usually defined and then
6382 not referenced, but contain constructors and destructors that have
6383 nontrivial bookkeeping functions.
6385 @item visibility
6386 @cindex @code{visibility} type attribute
6387 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6388 applied to class, struct, union and enum types.  Unlike other type
6389 attributes, the attribute must appear between the initial keyword and
6390 the name of the type; it cannot appear after the body of the type.
6392 Note that the type visibility is applied to vague linkage entities
6393 associated with the class (vtable, typeinfo node, etc.).  In
6394 particular, if a class is thrown as an exception in one shared object
6395 and caught in another, the class must have default visibility.
6396 Otherwise the two shared objects are unable to use the same
6397 typeinfo node and exception handling will break.
6399 @end table
6401 To specify multiple attributes, separate them by commas within the
6402 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6403 packed))}.
6405 @node ARM Type Attributes
6406 @subsection ARM Type Attributes
6408 @cindex @code{notshared} type attribute, ARM
6409 On those ARM targets that support @code{dllimport} (such as Symbian
6410 OS), you can use the @code{notshared} attribute to indicate that the
6411 virtual table and other similar data for a class should not be
6412 exported from a DLL@.  For example:
6414 @smallexample
6415 class __declspec(notshared) C @{
6416 public:
6417   __declspec(dllimport) C();
6418   virtual void f();
6421 __declspec(dllexport)
6422 C::C() @{@}
6423 @end smallexample
6425 @noindent
6426 In this code, @code{C::C} is exported from the current DLL, but the
6427 virtual table for @code{C} is not exported.  (You can use
6428 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6429 most Symbian OS code uses @code{__declspec}.)
6431 @node MeP Type Attributes
6432 @subsection MeP Type Attributes
6434 @cindex @code{based} type attribute, MeP
6435 @cindex @code{tiny} type attribute, MeP
6436 @cindex @code{near} type attribute, MeP
6437 @cindex @code{far} type attribute, MeP
6438 Many of the MeP variable attributes may be applied to types as well.
6439 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6440 @code{far} attributes may be applied to either.  The @code{io} and
6441 @code{cb} attributes may not be applied to types.
6443 @node PowerPC Type Attributes
6444 @subsection PowerPC Type Attributes
6446 Three attributes currently are defined for PowerPC configurations:
6447 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6449 @cindex @code{ms_struct} type attribute, PowerPC
6450 @cindex @code{gcc_struct} type attribute, PowerPC
6451 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6452 attributes please see the documentation in @ref{x86 Type Attributes}.
6454 @cindex @code{altivec} type attribute, PowerPC
6455 The @code{altivec} attribute allows one to declare AltiVec vector data
6456 types supported by the AltiVec Programming Interface Manual.  The
6457 attribute requires an argument to specify one of three vector types:
6458 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6459 and @code{bool__} (always followed by unsigned).
6461 @smallexample
6462 __attribute__((altivec(vector__)))
6463 __attribute__((altivec(pixel__))) unsigned short
6464 __attribute__((altivec(bool__))) unsigned
6465 @end smallexample
6467 These attributes mainly are intended to support the @code{__vector},
6468 @code{__pixel}, and @code{__bool} AltiVec keywords.
6470 @node SPU Type Attributes
6471 @subsection SPU Type Attributes
6473 @cindex @code{spu_vector} type attribute, SPU
6474 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6475 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6476 Language Extensions Specification.  It is intended to support the
6477 @code{__vector} keyword.
6479 @node x86 Type Attributes
6480 @subsection x86 Type Attributes
6482 Two attributes are currently defined for x86 configurations:
6483 @code{ms_struct} and @code{gcc_struct}.
6485 @table @code
6487 @item ms_struct
6488 @itemx gcc_struct
6489 @cindex @code{ms_struct} type attribute, x86
6490 @cindex @code{gcc_struct} type attribute, x86
6492 If @code{packed} is used on a structure, or if bit-fields are used
6493 it may be that the Microsoft ABI packs them differently
6494 than GCC normally packs them.  Particularly when moving packed
6495 data between functions compiled with GCC and the native Microsoft compiler
6496 (either via function call or as data in a file), it may be necessary to access
6497 either format.
6499 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6500 compilers to match the native Microsoft compiler.
6501 @end table
6503 @node Label Attributes
6504 @section Label Attributes
6505 @cindex Label Attributes
6507 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
6508 details of the exact syntax for using attributes.  Other attributes are 
6509 available for functions (@pxref{Function Attributes}), variables 
6510 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6511 and for types (@pxref{Type Attributes}).
6513 This example uses the @code{cold} label attribute to indicate the 
6514 @code{ErrorHandling} branch is unlikely to be taken and that the
6515 @code{ErrorHandling} label is unused:
6517 @smallexample
6519    asm goto ("some asm" : : : : NoError);
6521 /* This branch (the fall-through from the asm) is less commonly used */
6522 ErrorHandling: 
6523    __attribute__((cold, unused)); /* Semi-colon is required here */
6524    printf("error\n");
6525    return 0;
6527 NoError:
6528    printf("no error\n");
6529    return 1;
6530 @end smallexample
6532 @table @code
6533 @item unused
6534 @cindex @code{unused} label attribute
6535 This feature is intended for program-generated code that may contain 
6536 unused labels, but which is compiled with @option{-Wall}.  It is
6537 not normally appropriate to use in it human-written code, though it
6538 could be useful in cases where the code that jumps to the label is
6539 contained within an @code{#ifdef} conditional.
6541 @item hot
6542 @cindex @code{hot} label attribute
6543 The @code{hot} attribute on a label is used to inform the compiler that
6544 the path following the label is more likely than paths that are not so
6545 annotated.  This attribute is used in cases where @code{__builtin_expect}
6546 cannot be used, for instance with computed goto or @code{asm goto}.
6548 @item cold
6549 @cindex @code{cold} label attribute
6550 The @code{cold} attribute on labels is used to inform the compiler that
6551 the path following the label is unlikely to be executed.  This attribute
6552 is used in cases where @code{__builtin_expect} cannot be used, for instance
6553 with computed goto or @code{asm goto}.
6555 @end table
6557 @node Enumerator Attributes
6558 @section Enumerator Attributes
6559 @cindex Enumerator Attributes
6561 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
6562 details of the exact syntax for using attributes.  Other attributes are
6563 available for functions (@pxref{Function Attributes}), variables
6564 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6565 and for types (@pxref{Type Attributes}).
6567 This example uses the @code{deprecated} enumerator attribute to indicate the
6568 @code{oldval} enumerator is deprecated:
6570 @smallexample
6571 enum E @{
6572   oldval __attribute__((deprecated)),
6573   newval
6577 fn (void)
6579   return oldval;
6581 @end smallexample
6583 @table @code
6584 @item deprecated
6585 @cindex @code{deprecated} enumerator attribute
6586 The @code{deprecated} attribute results in a warning if the enumerator
6587 is used anywhere in the source file.  This is useful when identifying
6588 enumerators that are expected to be removed in a future version of a
6589 program.  The warning also includes the location of the declaration
6590 of the deprecated enumerator, to enable users to easily find further
6591 information about why the enumerator is deprecated, or what they should
6592 do instead.  Note that the warnings only occurs for uses.
6594 @end table
6596 @node Attribute Syntax
6597 @section Attribute Syntax
6598 @cindex attribute syntax
6600 This section describes the syntax with which @code{__attribute__} may be
6601 used, and the constructs to which attribute specifiers bind, for the C
6602 language.  Some details may vary for C++ and Objective-C@.  Because of
6603 infelicities in the grammar for attributes, some forms described here
6604 may not be successfully parsed in all cases.
6606 There are some problems with the semantics of attributes in C++.  For
6607 example, there are no manglings for attributes, although they may affect
6608 code generation, so problems may arise when attributed types are used in
6609 conjunction with templates or overloading.  Similarly, @code{typeid}
6610 does not distinguish between types with different attributes.  Support
6611 for attributes in C++ may be restricted in future to attributes on
6612 declarations only, but not on nested declarators.
6614 @xref{Function Attributes}, for details of the semantics of attributes
6615 applying to functions.  @xref{Variable Attributes}, for details of the
6616 semantics of attributes applying to variables.  @xref{Type Attributes},
6617 for details of the semantics of attributes applying to structure, union
6618 and enumerated types.
6619 @xref{Label Attributes}, for details of the semantics of attributes 
6620 applying to labels.
6621 @xref{Enumerator Attributes}, for details of the semantics of attributes
6622 applying to enumerators.
6624 An @dfn{attribute specifier} is of the form
6625 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
6626 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6627 each attribute is one of the following:
6629 @itemize @bullet
6630 @item
6631 Empty.  Empty attributes are ignored.
6633 @item
6634 An attribute name
6635 (which may be an identifier such as @code{unused}, or a reserved
6636 word such as @code{const}).
6638 @item
6639 An attribute name followed by a parenthesized list of
6640 parameters for the attribute.
6641 These parameters take one of the following forms:
6643 @itemize @bullet
6644 @item
6645 An identifier.  For example, @code{mode} attributes use this form.
6647 @item
6648 An identifier followed by a comma and a non-empty comma-separated list
6649 of expressions.  For example, @code{format} attributes use this form.
6651 @item
6652 A possibly empty comma-separated list of expressions.  For example,
6653 @code{format_arg} attributes use this form with the list being a single
6654 integer constant expression, and @code{alias} attributes use this form
6655 with the list being a single string constant.
6656 @end itemize
6657 @end itemize
6659 An @dfn{attribute specifier list} is a sequence of one or more attribute
6660 specifiers, not separated by any other tokens.
6662 You may optionally specify attribute names with @samp{__}
6663 preceding and following the name.
6664 This allows you to use them in header files without
6665 being concerned about a possible macro of the same name.  For example,
6666 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6669 @subsubheading Label Attributes
6671 In GNU C, an attribute specifier list may appear after the colon following a
6672 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
6673 attributes on labels if the attribute specifier is immediately
6674 followed by a semicolon (i.e., the label applies to an empty
6675 statement).  If the semicolon is missing, C++ label attributes are
6676 ambiguous, as it is permissible for a declaration, which could begin
6677 with an attribute list, to be labelled in C++.  Declarations cannot be
6678 labelled in C90 or C99, so the ambiguity does not arise there.
6680 @subsubheading Enumerator Attributes
6682 In GNU C, an attribute specifier list may appear as part of an enumerator.
6683 The attribute goes after the enumeration constant, before @code{=}, if
6684 present.  The optional attribute in the enumerator appertains to the
6685 enumeration constant.  It is not possible to place the attribute after
6686 the constant expression, if present.
6688 @subsubheading Type Attributes
6690 An attribute specifier list may appear as part of a @code{struct},
6691 @code{union} or @code{enum} specifier.  It may go either immediately
6692 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6693 the closing brace.  The former syntax is preferred.
6694 Where attribute specifiers follow the closing brace, they are considered
6695 to relate to the structure, union or enumerated type defined, not to any
6696 enclosing declaration the type specifier appears in, and the type
6697 defined is not complete until after the attribute specifiers.
6698 @c Otherwise, there would be the following problems: a shift/reduce
6699 @c conflict between attributes binding the struct/union/enum and
6700 @c binding to the list of specifiers/qualifiers; and "aligned"
6701 @c attributes could use sizeof for the structure, but the size could be
6702 @c changed later by "packed" attributes.
6705 @subsubheading All other attributes
6707 Otherwise, an attribute specifier appears as part of a declaration,
6708 counting declarations of unnamed parameters and type names, and relates
6709 to that declaration (which may be nested in another declaration, for
6710 example in the case of a parameter declaration), or to a particular declarator
6711 within a declaration.  Where an
6712 attribute specifier is applied to a parameter declared as a function or
6713 an array, it should apply to the function or array rather than the
6714 pointer to which the parameter is implicitly converted, but this is not
6715 yet correctly implemented.
6717 Any list of specifiers and qualifiers at the start of a declaration may
6718 contain attribute specifiers, whether or not such a list may in that
6719 context contain storage class specifiers.  (Some attributes, however,
6720 are essentially in the nature of storage class specifiers, and only make
6721 sense where storage class specifiers may be used; for example,
6722 @code{section}.)  There is one necessary limitation to this syntax: the
6723 first old-style parameter declaration in a function definition cannot
6724 begin with an attribute specifier, because such an attribute applies to
6725 the function instead by syntax described below (which, however, is not
6726 yet implemented in this case).  In some other cases, attribute
6727 specifiers are permitted by this grammar but not yet supported by the
6728 compiler.  All attribute specifiers in this place relate to the
6729 declaration as a whole.  In the obsolescent usage where a type of
6730 @code{int} is implied by the absence of type specifiers, such a list of
6731 specifiers and qualifiers may be an attribute specifier list with no
6732 other specifiers or qualifiers.
6734 At present, the first parameter in a function prototype must have some
6735 type specifier that is not an attribute specifier; this resolves an
6736 ambiguity in the interpretation of @code{void f(int
6737 (__attribute__((foo)) x))}, but is subject to change.  At present, if
6738 the parentheses of a function declarator contain only attributes then
6739 those attributes are ignored, rather than yielding an error or warning
6740 or implying a single parameter of type int, but this is subject to
6741 change.
6743 An attribute specifier list may appear immediately before a declarator
6744 (other than the first) in a comma-separated list of declarators in a
6745 declaration of more than one identifier using a single list of
6746 specifiers and qualifiers.  Such attribute specifiers apply
6747 only to the identifier before whose declarator they appear.  For
6748 example, in
6750 @smallexample
6751 __attribute__((noreturn)) void d0 (void),
6752     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6753      d2 (void);
6754 @end smallexample
6756 @noindent
6757 the @code{noreturn} attribute applies to all the functions
6758 declared; the @code{format} attribute only applies to @code{d1}.
6760 An attribute specifier list may appear immediately before the comma,
6761 @code{=} or semicolon terminating the declaration of an identifier other
6762 than a function definition.  Such attribute specifiers apply
6763 to the declared object or function.  Where an
6764 assembler name for an object or function is specified (@pxref{Asm
6765 Labels}), the attribute must follow the @code{asm}
6766 specification.
6768 An attribute specifier list may, in future, be permitted to appear after
6769 the declarator in a function definition (before any old-style parameter
6770 declarations or the function body).
6772 Attribute specifiers may be mixed with type qualifiers appearing inside
6773 the @code{[]} of a parameter array declarator, in the C99 construct by
6774 which such qualifiers are applied to the pointer to which the array is
6775 implicitly converted.  Such attribute specifiers apply to the pointer,
6776 not to the array, but at present this is not implemented and they are
6777 ignored.
6779 An attribute specifier list may appear at the start of a nested
6780 declarator.  At present, there are some limitations in this usage: the
6781 attributes correctly apply to the declarator, but for most individual
6782 attributes the semantics this implies are not implemented.
6783 When attribute specifiers follow the @code{*} of a pointer
6784 declarator, they may be mixed with any type qualifiers present.
6785 The following describes the formal semantics of this syntax.  It makes the
6786 most sense if you are familiar with the formal specification of
6787 declarators in the ISO C standard.
6789 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6790 D1}, where @code{T} contains declaration specifiers that specify a type
6791 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6792 contains an identifier @var{ident}.  The type specified for @var{ident}
6793 for derived declarators whose type does not include an attribute
6794 specifier is as in the ISO C standard.
6796 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
6797 and the declaration @code{T D} specifies the type
6798 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6799 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6800 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
6802 If @code{D1} has the form @code{*
6803 @var{type-qualifier-and-attribute-specifier-list} D}, and the
6804 declaration @code{T D} specifies the type
6805 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6806 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6807 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
6808 @var{ident}.
6810 For example,
6812 @smallexample
6813 void (__attribute__((noreturn)) ****f) (void);
6814 @end smallexample
6816 @noindent
6817 specifies the type ``pointer to pointer to pointer to pointer to
6818 non-returning function returning @code{void}''.  As another example,
6820 @smallexample
6821 char *__attribute__((aligned(8))) *f;
6822 @end smallexample
6824 @noindent
6825 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
6826 Note again that this does not work with most attributes; for example,
6827 the usage of @samp{aligned} and @samp{noreturn} attributes given above
6828 is not yet supported.
6830 For compatibility with existing code written for compiler versions that
6831 did not implement attributes on nested declarators, some laxity is
6832 allowed in the placing of attributes.  If an attribute that only applies
6833 to types is applied to a declaration, it is treated as applying to
6834 the type of that declaration.  If an attribute that only applies to
6835 declarations is applied to the type of a declaration, it is treated
6836 as applying to that declaration; and, for compatibility with code
6837 placing the attributes immediately before the identifier declared, such
6838 an attribute applied to a function return type is treated as
6839 applying to the function type, and such an attribute applied to an array
6840 element type is treated as applying to the array type.  If an
6841 attribute that only applies to function types is applied to a
6842 pointer-to-function type, it is treated as applying to the pointer
6843 target type; if such an attribute is applied to a function return type
6844 that is not a pointer-to-function type, it is treated as applying
6845 to the function type.
6847 @node Function Prototypes
6848 @section Prototypes and Old-Style Function Definitions
6849 @cindex function prototype declarations
6850 @cindex old-style function definitions
6851 @cindex promotion of formal parameters
6853 GNU C extends ISO C to allow a function prototype to override a later
6854 old-style non-prototype definition.  Consider the following example:
6856 @smallexample
6857 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
6858 #ifdef __STDC__
6859 #define P(x) x
6860 #else
6861 #define P(x) ()
6862 #endif
6864 /* @r{Prototype function declaration.}  */
6865 int isroot P((uid_t));
6867 /* @r{Old-style function definition.}  */
6869 isroot (x)   /* @r{??? lossage here ???} */
6870      uid_t x;
6872   return x == 0;
6874 @end smallexample
6876 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
6877 not allow this example, because subword arguments in old-style
6878 non-prototype definitions are promoted.  Therefore in this example the
6879 function definition's argument is really an @code{int}, which does not
6880 match the prototype argument type of @code{short}.
6882 This restriction of ISO C makes it hard to write code that is portable
6883 to traditional C compilers, because the programmer does not know
6884 whether the @code{uid_t} type is @code{short}, @code{int}, or
6885 @code{long}.  Therefore, in cases like these GNU C allows a prototype
6886 to override a later old-style definition.  More precisely, in GNU C, a
6887 function prototype argument type overrides the argument type specified
6888 by a later old-style definition if the former type is the same as the
6889 latter type before promotion.  Thus in GNU C the above example is
6890 equivalent to the following:
6892 @smallexample
6893 int isroot (uid_t);
6896 isroot (uid_t x)
6898   return x == 0;
6900 @end smallexample
6902 @noindent
6903 GNU C++ does not support old-style function definitions, so this
6904 extension is irrelevant.
6906 @node C++ Comments
6907 @section C++ Style Comments
6908 @cindex @code{//}
6909 @cindex C++ comments
6910 @cindex comments, C++ style
6912 In GNU C, you may use C++ style comments, which start with @samp{//} and
6913 continue until the end of the line.  Many other C implementations allow
6914 such comments, and they are included in the 1999 C standard.  However,
6915 C++ style comments are not recognized if you specify an @option{-std}
6916 option specifying a version of ISO C before C99, or @option{-ansi}
6917 (equivalent to @option{-std=c90}).
6919 @node Dollar Signs
6920 @section Dollar Signs in Identifier Names
6921 @cindex $
6922 @cindex dollar signs in identifier names
6923 @cindex identifier names, dollar signs in
6925 In GNU C, you may normally use dollar signs in identifier names.
6926 This is because many traditional C implementations allow such identifiers.
6927 However, dollar signs in identifiers are not supported on a few target
6928 machines, typically because the target assembler does not allow them.
6930 @node Character Escapes
6931 @section The Character @key{ESC} in Constants
6933 You can use the sequence @samp{\e} in a string or character constant to
6934 stand for the ASCII character @key{ESC}.
6936 @node Alignment
6937 @section Inquiring on Alignment of Types or Variables
6938 @cindex alignment
6939 @cindex type alignment
6940 @cindex variable alignment
6942 The keyword @code{__alignof__} allows you to inquire about how an object
6943 is aligned, or the minimum alignment usually required by a type.  Its
6944 syntax is just like @code{sizeof}.
6946 For example, if the target machine requires a @code{double} value to be
6947 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6948 This is true on many RISC machines.  On more traditional machine
6949 designs, @code{__alignof__ (double)} is 4 or even 2.
6951 Some machines never actually require alignment; they allow reference to any
6952 data type even at an odd address.  For these machines, @code{__alignof__}
6953 reports the smallest alignment that GCC gives the data type, usually as
6954 mandated by the target ABI.
6956 If the operand of @code{__alignof__} is an lvalue rather than a type,
6957 its value is the required alignment for its type, taking into account
6958 any minimum alignment specified with GCC's @code{__attribute__}
6959 extension (@pxref{Variable Attributes}).  For example, after this
6960 declaration:
6962 @smallexample
6963 struct foo @{ int x; char y; @} foo1;
6964 @end smallexample
6966 @noindent
6967 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6968 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6970 It is an error to ask for the alignment of an incomplete type.
6973 @node Inline
6974 @section An Inline Function is As Fast As a Macro
6975 @cindex inline functions
6976 @cindex integrating function code
6977 @cindex open coding
6978 @cindex macros, inline alternative
6980 By declaring a function inline, you can direct GCC to make
6981 calls to that function faster.  One way GCC can achieve this is to
6982 integrate that function's code into the code for its callers.  This
6983 makes execution faster by eliminating the function-call overhead; in
6984 addition, if any of the actual argument values are constant, their
6985 known values may permit simplifications at compile time so that not
6986 all of the inline function's code needs to be included.  The effect on
6987 code size is less predictable; object code may be larger or smaller
6988 with function inlining, depending on the particular case.  You can
6989 also direct GCC to try to integrate all ``simple enough'' functions
6990 into their callers with the option @option{-finline-functions}.
6992 GCC implements three different semantics of declaring a function
6993 inline.  One is available with @option{-std=gnu89} or
6994 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6995 on all inline declarations, another when
6996 @option{-std=c99}, @option{-std=c11},
6997 @option{-std=gnu99} or @option{-std=gnu11}
6998 (without @option{-fgnu89-inline}), and the third
6999 is used when compiling C++.
7001 To declare a function inline, use the @code{inline} keyword in its
7002 declaration, like this:
7004 @smallexample
7005 static inline int
7006 inc (int *a)
7008   return (*a)++;
7010 @end smallexample
7012 If you are writing a header file to be included in ISO C90 programs, write
7013 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7015 The three types of inlining behave similarly in two important cases:
7016 when the @code{inline} keyword is used on a @code{static} function,
7017 like the example above, and when a function is first declared without
7018 using the @code{inline} keyword and then is defined with
7019 @code{inline}, like this:
7021 @smallexample
7022 extern int inc (int *a);
7023 inline int
7024 inc (int *a)
7026   return (*a)++;
7028 @end smallexample
7030 In both of these common cases, the program behaves the same as if you
7031 had not used the @code{inline} keyword, except for its speed.
7033 @cindex inline functions, omission of
7034 @opindex fkeep-inline-functions
7035 When a function is both inline and @code{static}, if all calls to the
7036 function are integrated into the caller, and the function's address is
7037 never used, then the function's own assembler code is never referenced.
7038 In this case, GCC does not actually output assembler code for the
7039 function, unless you specify the option @option{-fkeep-inline-functions}.
7040 Some calls cannot be integrated for various reasons (in particular,
7041 calls that precede the function's definition cannot be integrated, and
7042 neither can recursive calls within the definition).  If there is a
7043 nonintegrated call, then the function is compiled to assembler code as
7044 usual.  The function must also be compiled as usual if the program
7045 refers to its address, because that can't be inlined.
7047 @opindex Winline
7048 Note that certain usages in a function definition can make it unsuitable
7049 for inline substitution.  Among these usages are: variadic functions, use of
7050 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
7051 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
7052 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
7053 warns when a function marked @code{inline} could not be substituted,
7054 and gives the reason for the failure.
7056 @cindex automatic @code{inline} for C++ member fns
7057 @cindex @code{inline} automatic for C++ member fns
7058 @cindex member fns, automatically @code{inline}
7059 @cindex C++ member fns, automatically @code{inline}
7060 @opindex fno-default-inline
7061 As required by ISO C++, GCC considers member functions defined within
7062 the body of a class to be marked inline even if they are
7063 not explicitly declared with the @code{inline} keyword.  You can
7064 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7065 Options,,Options Controlling C++ Dialect}.
7067 GCC does not inline any functions when not optimizing unless you specify
7068 the @samp{always_inline} attribute for the function, like this:
7070 @smallexample
7071 /* @r{Prototype.}  */
7072 inline void foo (const char) __attribute__((always_inline));
7073 @end smallexample
7075 The remainder of this section is specific to GNU C90 inlining.
7077 @cindex non-static inline function
7078 When an inline function is not @code{static}, then the compiler must assume
7079 that there may be calls from other source files; since a global symbol can
7080 be defined only once in any program, the function must not be defined in
7081 the other source files, so the calls therein cannot be integrated.
7082 Therefore, a non-@code{static} inline function is always compiled on its
7083 own in the usual fashion.
7085 If you specify both @code{inline} and @code{extern} in the function
7086 definition, then the definition is used only for inlining.  In no case
7087 is the function compiled on its own, not even if you refer to its
7088 address explicitly.  Such an address becomes an external reference, as
7089 if you had only declared the function, and had not defined it.
7091 This combination of @code{inline} and @code{extern} has almost the
7092 effect of a macro.  The way to use it is to put a function definition in
7093 a header file with these keywords, and put another copy of the
7094 definition (lacking @code{inline} and @code{extern}) in a library file.
7095 The definition in the header file causes most calls to the function
7096 to be inlined.  If any uses of the function remain, they refer to
7097 the single copy in the library.
7099 @node Volatiles
7100 @section When is a Volatile Object Accessed?
7101 @cindex accessing volatiles
7102 @cindex volatile read
7103 @cindex volatile write
7104 @cindex volatile access
7106 C has the concept of volatile objects.  These are normally accessed by
7107 pointers and used for accessing hardware or inter-thread
7108 communication.  The standard encourages compilers to refrain from
7109 optimizations concerning accesses to volatile objects, but leaves it
7110 implementation defined as to what constitutes a volatile access.  The
7111 minimum requirement is that at a sequence point all previous accesses
7112 to volatile objects have stabilized and no subsequent accesses have
7113 occurred.  Thus an implementation is free to reorder and combine
7114 volatile accesses that occur between sequence points, but cannot do
7115 so for accesses across a sequence point.  The use of volatile does
7116 not allow you to violate the restriction on updating objects multiple
7117 times between two sequence points.
7119 Accesses to non-volatile objects are not ordered with respect to
7120 volatile accesses.  You cannot use a volatile object as a memory
7121 barrier to order a sequence of writes to non-volatile memory.  For
7122 instance:
7124 @smallexample
7125 int *ptr = @var{something};
7126 volatile int vobj;
7127 *ptr = @var{something};
7128 vobj = 1;
7129 @end smallexample
7131 @noindent
7132 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7133 that the write to @var{*ptr} occurs by the time the update
7134 of @var{vobj} happens.  If you need this guarantee, you must use
7135 a stronger memory barrier such as:
7137 @smallexample
7138 int *ptr = @var{something};
7139 volatile int vobj;
7140 *ptr = @var{something};
7141 asm volatile ("" : : : "memory");
7142 vobj = 1;
7143 @end smallexample
7145 A scalar volatile object is read when it is accessed in a void context:
7147 @smallexample
7148 volatile int *src = @var{somevalue};
7149 *src;
7150 @end smallexample
7152 Such expressions are rvalues, and GCC implements this as a
7153 read of the volatile object being pointed to.
7155 Assignments are also expressions and have an rvalue.  However when
7156 assigning to a scalar volatile, the volatile object is not reread,
7157 regardless of whether the assignment expression's rvalue is used or
7158 not.  If the assignment's rvalue is used, the value is that assigned
7159 to the volatile object.  For instance, there is no read of @var{vobj}
7160 in all the following cases:
7162 @smallexample
7163 int obj;
7164 volatile int vobj;
7165 vobj = @var{something};
7166 obj = vobj = @var{something};
7167 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7168 obj = (@var{something}, vobj = @var{anotherthing});
7169 @end smallexample
7171 If you need to read the volatile object after an assignment has
7172 occurred, you must use a separate expression with an intervening
7173 sequence point.
7175 As bit-fields are not individually addressable, volatile bit-fields may
7176 be implicitly read when written to, or when adjacent bit-fields are
7177 accessed.  Bit-field operations may be optimized such that adjacent
7178 bit-fields are only partially accessed, if they straddle a storage unit
7179 boundary.  For these reasons it is unwise to use volatile bit-fields to
7180 access hardware.
7182 @node Using Assembly Language with C
7183 @section How to Use Inline Assembly Language in C Code
7184 @cindex @code{asm} keyword
7185 @cindex assembly language in C
7186 @cindex inline assembly language
7187 @cindex mixing assembly language and C
7189 The @code{asm} keyword allows you to embed assembler instructions
7190 within C code.  GCC provides two forms of inline @code{asm}
7191 statements.  A @dfn{basic @code{asm}} statement is one with no
7192 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7193 statement (@pxref{Extended Asm}) includes one or more operands.  
7194 The extended form is preferred for mixing C and assembly language
7195 within a function, but to include assembly language at
7196 top level you must use basic @code{asm}.
7198 You can also use the @code{asm} keyword to override the assembler name
7199 for a C symbol, or to place a C variable in a specific register.
7201 @menu
7202 * Basic Asm::          Inline assembler without operands.
7203 * Extended Asm::       Inline assembler with operands.
7204 * Constraints::        Constraints for @code{asm} operands
7205 * Asm Labels::         Specifying the assembler name to use for a C symbol.
7206 * Explicit Reg Vars::  Defining variables residing in specified registers.
7207 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
7208 @end menu
7210 @node Basic Asm
7211 @subsection Basic Asm --- Assembler Instructions Without Operands
7212 @cindex basic @code{asm}
7213 @cindex assembly language in C, basic
7215 A basic @code{asm} statement has the following syntax:
7217 @example
7218 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7219 @end example
7221 The @code{asm} keyword is a GNU extension.
7222 When writing code that can be compiled with @option{-ansi} and the
7223 various @option{-std} options, use @code{__asm__} instead of 
7224 @code{asm} (@pxref{Alternate Keywords}).
7226 @subsubheading Qualifiers
7227 @table @code
7228 @item volatile
7229 The optional @code{volatile} qualifier has no effect. 
7230 All basic @code{asm} blocks are implicitly volatile.
7231 @end table
7233 @subsubheading Parameters
7234 @table @var
7236 @item AssemblerInstructions
7237 This is a literal string that specifies the assembler code. The string can 
7238 contain any instructions recognized by the assembler, including directives. 
7239 GCC does not parse the assembler instructions themselves and 
7240 does not know what they mean or even whether they are valid assembler input. 
7242 You may place multiple assembler instructions together in a single @code{asm} 
7243 string, separated by the characters normally used in assembly code for the 
7244 system. A combination that works in most places is a newline to break the 
7245 line, plus a tab character (written as @samp{\n\t}).
7246 Some assemblers allow semicolons as a line separator. However, 
7247 note that some assembler dialects use semicolons to start a comment. 
7248 @end table
7250 @subsubheading Remarks
7251 Using extended @code{asm} typically produces smaller, safer, and more
7252 efficient code, and in most cases it is a better solution than basic
7253 @code{asm}.  However, there are two situations where only basic @code{asm}
7254 can be used:
7256 @itemize @bullet
7257 @item
7258 Extended @code{asm} statements have to be inside a C
7259 function, so to write inline assembly language at file scope (``top-level''),
7260 outside of C functions, you must use basic @code{asm}.
7261 You can use this technique to emit assembler directives,
7262 define assembly language macros that can be invoked elsewhere in the file,
7263 or write entire functions in assembly language.
7265 @item
7266 Functions declared
7267 with the @code{naked} attribute also require basic @code{asm}
7268 (@pxref{Function Attributes}).
7269 @end itemize
7271 Safely accessing C data and calling functions from basic @code{asm} is more 
7272 complex than it may appear. To access C data, it is better to use extended 
7273 @code{asm}.
7275 Do not expect a sequence of @code{asm} statements to remain perfectly 
7276 consecutive after compilation. If certain instructions need to remain 
7277 consecutive in the output, put them in a single multi-instruction @code{asm}
7278 statement. Note that GCC's optimizers can move @code{asm} statements 
7279 relative to other code, including across jumps.
7281 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7282 GCC does not know about these jumps, and therefore cannot take 
7283 account of them when deciding how to optimize. Jumps from @code{asm} to C 
7284 labels are only supported in extended @code{asm}.
7286 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7287 assembly code when optimizing. This can lead to unexpected duplicate 
7288 symbol errors during compilation if your assembly code defines symbols or 
7289 labels.
7291 Since GCC does not parse the @var{AssemblerInstructions}, it has no 
7292 visibility of any symbols it references. This may result in GCC discarding 
7293 those symbols as unreferenced.
7295 The compiler copies the assembler instructions in a basic @code{asm} 
7296 verbatim to the assembly language output file, without 
7297 processing dialects or any of the @samp{%} operators that are available with
7298 extended @code{asm}. This results in minor differences between basic 
7299 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7300 registers you might use @samp{%eax} in basic @code{asm} and
7301 @samp{%%eax} in extended @code{asm}.
7303 On targets such as x86 that support multiple assembler dialects,
7304 all basic @code{asm} blocks use the assembler dialect specified by the 
7305 @option{-masm} command-line option (@pxref{x86 Options}).  
7306 Basic @code{asm} provides no
7307 mechanism to provide different assembler strings for different dialects.
7309 Here is an example of basic @code{asm} for i386:
7311 @example
7312 /* Note that this code will not compile with -masm=intel */
7313 #define DebugBreak() asm("int $3")
7314 @end example
7316 @node Extended Asm
7317 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7318 @cindex extended @code{asm}
7319 @cindex assembly language in C, extended
7321 With extended @code{asm} you can read and write C variables from 
7322 assembler and perform jumps from assembler code to C labels.  
7323 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7324 the operand parameters after the assembler template:
7326 @example
7327 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7328                  : @var{OutputOperands} 
7329                  @r{[} : @var{InputOperands}
7330                  @r{[} : @var{Clobbers} @r{]} @r{]})
7332 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7333                       : 
7334                       : @var{InputOperands}
7335                       : @var{Clobbers}
7336                       : @var{GotoLabels})
7337 @end example
7339 The @code{asm} keyword is a GNU extension.
7340 When writing code that can be compiled with @option{-ansi} and the
7341 various @option{-std} options, use @code{__asm__} instead of 
7342 @code{asm} (@pxref{Alternate Keywords}).
7344 @subsubheading Qualifiers
7345 @table @code
7347 @item volatile
7348 The typical use of extended @code{asm} statements is to manipulate input 
7349 values to produce output values. However, your @code{asm} statements may 
7350 also produce side effects. If so, you may need to use the @code{volatile} 
7351 qualifier to disable certain optimizations. @xref{Volatile}.
7353 @item goto
7354 This qualifier informs the compiler that the @code{asm} statement may 
7355 perform a jump to one of the labels listed in the @var{GotoLabels}.
7356 @xref{GotoLabels}.
7357 @end table
7359 @subsubheading Parameters
7360 @table @var
7361 @item AssemblerTemplate
7362 This is a literal string that is the template for the assembler code. It is a 
7363 combination of fixed text and tokens that refer to the input, output, 
7364 and goto parameters. @xref{AssemblerTemplate}.
7366 @item OutputOperands
7367 A comma-separated list of the C variables modified by the instructions in the 
7368 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7370 @item InputOperands
7371 A comma-separated list of C expressions read by the instructions in the 
7372 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7374 @item Clobbers
7375 A comma-separated list of registers or other values changed by the 
7376 @var{AssemblerTemplate}, beyond those listed as outputs.
7377 An empty list is permitted.  @xref{Clobbers}.
7379 @item GotoLabels
7380 When you are using the @code{goto} form of @code{asm}, this section contains 
7381 the list of all C labels to which the code in the 
7382 @var{AssemblerTemplate} may jump. 
7383 @xref{GotoLabels}.
7385 @code{asm} statements may not perform jumps into other @code{asm} statements,
7386 only to the listed @var{GotoLabels}.
7387 GCC's optimizers do not know about other jumps; therefore they cannot take 
7388 account of them when deciding how to optimize.
7389 @end table
7391 The total number of input + output + goto operands is limited to 30.
7393 @subsubheading Remarks
7394 The @code{asm} statement allows you to include assembly instructions directly 
7395 within C code. This may help you to maximize performance in time-sensitive 
7396 code or to access assembly instructions that are not readily available to C 
7397 programs.
7399 Note that extended @code{asm} statements must be inside a function. Only 
7400 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7401 Functions declared with the @code{naked} attribute also require basic 
7402 @code{asm} (@pxref{Function Attributes}).
7404 While the uses of @code{asm} are many and varied, it may help to think of an 
7405 @code{asm} statement as a series of low-level instructions that convert input 
7406 parameters to output parameters. So a simple (if not particularly useful) 
7407 example for i386 using @code{asm} might look like this:
7409 @example
7410 int src = 1;
7411 int dst;   
7413 asm ("mov %1, %0\n\t"
7414     "add $1, %0"
7415     : "=r" (dst) 
7416     : "r" (src));
7418 printf("%d\n", dst);
7419 @end example
7421 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7423 @anchor{Volatile}
7424 @subsubsection Volatile
7425 @cindex volatile @code{asm}
7426 @cindex @code{asm} volatile
7428 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7429 there is no need for the output variables. Also, the optimizers may move 
7430 code out of loops if they believe that the code will always return the same 
7431 result (i.e. none of its input values change between calls). Using the 
7432 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7433 that have no output operands, including @code{asm goto} statements, 
7434 are implicitly volatile.
7436 This i386 code demonstrates a case that does not use (or require) the 
7437 @code{volatile} qualifier. If it is performing assertion checking, this code 
7438 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7439 unreferenced by any code. As a result, the optimizers can discard the 
7440 @code{asm} statement, which in turn removes the need for the entire 
7441 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7442 isn't needed you allow the optimizers to produce the most efficient code 
7443 possible.
7445 @example
7446 void DoCheck(uint32_t dwSomeValue)
7448    uint32_t dwRes;
7450    // Assumes dwSomeValue is not zero.
7451    asm ("bsfl %1,%0"
7452      : "=r" (dwRes)
7453      : "r" (dwSomeValue)
7454      : "cc");
7456    assert(dwRes > 3);
7458 @end example
7460 The next example shows a case where the optimizers can recognize that the input 
7461 (@code{dwSomeValue}) never changes during the execution of the function and can 
7462 therefore move the @code{asm} outside the loop to produce more efficient code. 
7463 Again, using @code{volatile} disables this type of optimization.
7465 @example
7466 void do_print(uint32_t dwSomeValue)
7468    uint32_t dwRes;
7470    for (uint32_t x=0; x < 5; x++)
7471    @{
7472       // Assumes dwSomeValue is not zero.
7473       asm ("bsfl %1,%0"
7474         : "=r" (dwRes)
7475         : "r" (dwSomeValue)
7476         : "cc");
7478       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7479    @}
7481 @end example
7483 The following example demonstrates a case where you need to use the 
7484 @code{volatile} qualifier. 
7485 It uses the x86 @code{rdtsc} instruction, which reads 
7486 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
7487 the optimizers might assume that the @code{asm} block will always return the 
7488 same value and therefore optimize away the second call.
7490 @example
7491 uint64_t msr;
7493 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7494         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7495         "or %%rdx, %0"        // 'Or' in the lower bits.
7496         : "=a" (msr)
7497         : 
7498         : "rdx");
7500 printf("msr: %llx\n", msr);
7502 // Do other work...
7504 // Reprint the timestamp
7505 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7506         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7507         "or %%rdx, %0"        // 'Or' in the lower bits.
7508         : "=a" (msr)
7509         : 
7510         : "rdx");
7512 printf("msr: %llx\n", msr);
7513 @end example
7515 GCC's optimizers do not treat this code like the non-volatile code in the 
7516 earlier examples. They do not move it out of loops or omit it on the 
7517 assumption that the result from a previous call is still valid.
7519 Note that the compiler can move even volatile @code{asm} instructions relative 
7520 to other code, including across jump instructions. For example, on many 
7521 targets there is a system register that controls the rounding mode of 
7522 floating-point operations. Setting it with a volatile @code{asm}, as in the 
7523 following PowerPC example, does not work reliably.
7525 @example
7526 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7527 sum = x + y;
7528 @end example
7530 The compiler may move the addition back before the volatile @code{asm}. To 
7531 make it work as expected, add an artificial dependency to the @code{asm} by 
7532 referencing a variable in the subsequent code, for example: 
7534 @example
7535 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7536 sum = x + y;
7537 @end example
7539 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7540 assembly code when optimizing. This can lead to unexpected duplicate symbol 
7541 errors during compilation if your asm code defines symbols or labels. 
7542 Using @samp{%=} 
7543 (@pxref{AssemblerTemplate}) may help resolve this problem.
7545 @anchor{AssemblerTemplate}
7546 @subsubsection Assembler Template
7547 @cindex @code{asm} assembler template
7549 An assembler template is a literal string containing assembler instructions.
7550 The compiler replaces tokens in the template that refer 
7551 to inputs, outputs, and goto labels,
7552 and then outputs the resulting string to the assembler. The 
7553 string can contain any instructions recognized by the assembler, including 
7554 directives. GCC does not parse the assembler instructions 
7555 themselves and does not know what they mean or even whether they are valid 
7556 assembler input. However, it does count the statements 
7557 (@pxref{Size of an asm}).
7559 You may place multiple assembler instructions together in a single @code{asm} 
7560 string, separated by the characters normally used in assembly code for the 
7561 system. A combination that works in most places is a newline to break the 
7562 line, plus a tab character to move to the instruction field (written as 
7563 @samp{\n\t}). 
7564 Some assemblers allow semicolons as a line separator. However, note 
7565 that some assembler dialects use semicolons to start a comment. 
7567 Do not expect a sequence of @code{asm} statements to remain perfectly 
7568 consecutive after compilation, even when you are using the @code{volatile} 
7569 qualifier. If certain instructions need to remain consecutive in the output, 
7570 put them in a single multi-instruction asm statement.
7572 Accessing data from C programs without using input/output operands (such as 
7573 by using global symbols directly from the assembler template) may not work as 
7574 expected. Similarly, calling functions directly from an assembler template 
7575 requires a detailed understanding of the target assembler and ABI.
7577 Since GCC does not parse the assembler template,
7578 it has no visibility of any 
7579 symbols it references. This may result in GCC discarding those symbols as 
7580 unreferenced unless they are also listed as input, output, or goto operands.
7582 @subsubheading Special format strings
7584 In addition to the tokens described by the input, output, and goto operands, 
7585 these tokens have special meanings in the assembler template:
7587 @table @samp
7588 @item %% 
7589 Outputs a single @samp{%} into the assembler code.
7591 @item %= 
7592 Outputs a number that is unique to each instance of the @code{asm} 
7593 statement in the entire compilation. This option is useful when creating local 
7594 labels and referring to them multiple times in a single template that 
7595 generates multiple assembler instructions. 
7597 @item %@{
7598 @itemx %|
7599 @itemx %@}
7600 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7601 into the assembler code.  When unescaped, these characters have special
7602 meaning to indicate multiple assembler dialects, as described below.
7603 @end table
7605 @subsubheading Multiple assembler dialects in @code{asm} templates
7607 On targets such as x86, GCC supports multiple assembler dialects.
7608 The @option{-masm} option controls which dialect GCC uses as its 
7609 default for inline assembler. The target-specific documentation for the 
7610 @option{-masm} option contains the list of supported dialects, as well as the 
7611 default dialect if the option is not specified. This information may be 
7612 important to understand, since assembler code that works correctly when 
7613 compiled using one dialect will likely fail if compiled using another.
7614 @xref{x86 Options}.
7616 If your code needs to support multiple assembler dialects (for example, if 
7617 you are writing public headers that need to support a variety of compilation 
7618 options), use constructs of this form:
7620 @example
7621 @{ dialect0 | dialect1 | dialect2... @}
7622 @end example
7624 This construct outputs @code{dialect0} 
7625 when using dialect #0 to compile the code, 
7626 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
7627 braces than the number of dialects the compiler supports, the construct 
7628 outputs nothing.
7630 For example, if an x86 compiler supports two dialects
7631 (@samp{att}, @samp{intel}), an 
7632 assembler template such as this:
7634 @example
7635 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7636 @end example
7638 @noindent
7639 is equivalent to one of
7641 @example
7642 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
7643 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
7644 @end example
7646 Using that same compiler, this code:
7648 @example
7649 "xchg@{l@}\t@{%%@}ebx, %1"
7650 @end example
7652 @noindent
7653 corresponds to either
7655 @example
7656 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
7657 "xchg\tebx, %1"                    @r{/* intel dialect */}
7658 @end example
7660 There is no support for nesting dialect alternatives.
7662 @anchor{OutputOperands}
7663 @subsubsection Output Operands
7664 @cindex @code{asm} output operands
7666 An @code{asm} statement has zero or more output operands indicating the names
7667 of C variables modified by the assembler code.
7669 In this i386 example, @code{old} (referred to in the template string as 
7670 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
7671 (@code{%2}) is an input:
7673 @example
7674 bool old;
7676 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7677          "sbb %0,%0"      // Use the CF to calculate old.
7678    : "=r" (old), "+rm" (*Base)
7679    : "Ir" (Offset)
7680    : "cc");
7682 return old;
7683 @end example
7685 Operands are separated by commas.  Each operand has this format:
7687 @example
7688 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7689 @end example
7691 @table @var
7692 @item asmSymbolicName
7693 Specifies a symbolic name for the operand.
7694 Reference the name in the assembler template 
7695 by enclosing it in square brackets 
7696 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7697 that contains the definition. Any valid C variable name is acceptable, 
7698 including names already defined in the surrounding code. No two operands 
7699 within the same @code{asm} statement can use the same symbolic name.
7701 When not using an @var{asmSymbolicName}, use the (zero-based) position
7702 of the operand 
7703 in the list of operands in the assembler template. For example if there are 
7704 three output operands, use @samp{%0} in the template to refer to the first, 
7705 @samp{%1} for the second, and @samp{%2} for the third. 
7707 @item constraint
7708 A string constant specifying constraints on the placement of the operand; 
7709 @xref{Constraints}, for details.
7711 Output constraints must begin with either @samp{=} (a variable overwriting an 
7712 existing value) or @samp{+} (when reading and writing). When using 
7713 @samp{=}, do not assume the location contains the existing value
7714 on entry to the @code{asm}, except 
7715 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7717 After the prefix, there must be one or more additional constraints 
7718 (@pxref{Constraints}) that describe where the value resides. Common 
7719 constraints include @samp{r} for register and @samp{m} for memory. 
7720 When you list more than one possible location (for example, @code{"=rm"}),
7721 the compiler chooses the most efficient one based on the current context. 
7722 If you list as many alternates as the @code{asm} statement allows, you permit 
7723 the optimizers to produce the best possible code. 
7724 If you must use a specific register, but your Machine Constraints do not
7725 provide sufficient control to select the specific register you want, 
7726 local register variables may provide a solution (@pxref{Local Reg Vars}).
7728 @item cvariablename
7729 Specifies a C lvalue expression to hold the output, typically a variable name.
7730 The enclosing parentheses are a required part of the syntax.
7732 @end table
7734 When the compiler selects the registers to use to 
7735 represent the output operands, it does not use any of the clobbered registers 
7736 (@pxref{Clobbers}).
7738 Output operand expressions must be lvalues. The compiler cannot check whether 
7739 the operands have data types that are reasonable for the instruction being 
7740 executed. For output expressions that are not directly addressable (for 
7741 example a bit-field), the constraint must allow a register. In that case, GCC 
7742 uses the register as the output of the @code{asm}, and then stores that 
7743 register into the output. 
7745 Operands using the @samp{+} constraint modifier count as two operands 
7746 (that is, both as input and output) towards the total maximum of 30 operands
7747 per @code{asm} statement.
7749 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7750 operands that must not overlap an input.  Otherwise, 
7751 GCC may allocate the output operand in the same register as an unrelated 
7752 input operand, on the assumption that the assembler code consumes its 
7753 inputs before producing outputs. This assumption may be false if the assembler 
7754 code actually consists of more than one instruction.
7756 The same problem can occur if one output parameter (@var{a}) allows a register 
7757 constraint and another output parameter (@var{b}) allows a memory constraint.
7758 The code generated by GCC to access the memory address in @var{b} can contain
7759 registers which @emph{might} be shared by @var{a}, and GCC considers those 
7760 registers to be inputs to the asm. As above, GCC assumes that such input
7761 registers are consumed before any outputs are written. This assumption may 
7762 result in incorrect behavior if the asm writes to @var{a} before using 
7763 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7764 ensures that modifying @var{a} does not affect the address referenced by 
7765 @var{b}. Otherwise, the location of @var{b} 
7766 is undefined if @var{a} is modified before using @var{b}.
7768 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7769 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7770 dependent. The list of supported modifiers for x86 is found at 
7771 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7773 If the C code that follows the @code{asm} makes no use of any of the output 
7774 operands, use @code{volatile} for the @code{asm} statement to prevent the 
7775 optimizers from discarding the @code{asm} statement as unneeded 
7776 (see @ref{Volatile}).
7778 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
7779 references the first output operand as @code{%0} (were there a second, it 
7780 would be @code{%1}, etc). The number of the first input operand is one greater 
7781 than that of the last output operand. In this i386 example, that makes 
7782 @code{Mask} referenced as @code{%1}:
7784 @example
7785 uint32_t Mask = 1234;
7786 uint32_t Index;
7788   asm ("bsfl %1, %0"
7789      : "=r" (Index)
7790      : "r" (Mask)
7791      : "cc");
7792 @end example
7794 That code overwrites the variable @code{Index} (@samp{=}),
7795 placing the value in a register (@samp{r}).
7796 Using the generic @samp{r} constraint instead of a constraint for a specific 
7797 register allows the compiler to pick the register to use, which can result 
7798 in more efficient code. This may not be possible if an assembler instruction 
7799 requires a specific register.
7801 The following i386 example uses the @var{asmSymbolicName} syntax.
7802 It produces the 
7803 same result as the code above, but some may consider it more readable or more 
7804 maintainable since reordering index numbers is not necessary when adding or 
7805 removing operands. The names @code{aIndex} and @code{aMask}
7806 are only used in this example to emphasize which 
7807 names get used where.
7808 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7810 @example
7811 uint32_t Mask = 1234;
7812 uint32_t Index;
7814   asm ("bsfl %[aMask], %[aIndex]"
7815      : [aIndex] "=r" (Index)
7816      : [aMask] "r" (Mask)
7817      : "cc");
7818 @end example
7820 Here are some more examples of output operands.
7822 @example
7823 uint32_t c = 1;
7824 uint32_t d;
7825 uint32_t *e = &c;
7827 asm ("mov %[e], %[d]"
7828    : [d] "=rm" (d)
7829    : [e] "rm" (*e));
7830 @end example
7832 Here, @code{d} may either be in a register or in memory. Since the compiler 
7833 might already have the current value of the @code{uint32_t} location
7834 pointed to by @code{e}
7835 in a register, you can enable it to choose the best location
7836 for @code{d} by specifying both constraints.
7838 @anchor{FlagOutputOperands}
7839 @subsection Flag Output Operands
7840 @cindex @code{asm} flag output operands
7842 Some targets have a special register that holds the ``flags'' for the
7843 result of an operation or comparison.  Normally, the contents of that
7844 register are either unmodifed by the asm, or the asm is considered to
7845 clobber the contents.
7847 On some targets, a special form of output operand exists by which
7848 conditions in the flags register may be outputs of the asm.  The set of
7849 conditions supported are target specific, but the general rule is that
7850 the output variable must be a scalar integer, and the value will be boolean.
7851 When supported, the target will define the preprocessor symbol
7852 @code{__GCC_ASM_FLAG_OUTPUTS__}.
7854 Because of the special nature of the flag output operands, the constraint
7855 may not include alternatives.
7857 Most often, the target has only one flags register, and thus is an implied
7858 operand of many instructions.  In this case, the operand should not be
7859 referenced within the assembler template via @code{%0} etc, as there's
7860 no corresponding text in the assembly language.
7862 @table @asis
7863 @item x86 family
7864 The flag output constraints for the x86 family are of the form
7865 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
7866 conditions defined in the ISA manual for @code{j@var{cc}} or
7867 @code{set@var{cc}}.
7869 @table @code
7870 @item a
7871 ``above'' or unsigned greater than
7872 @item ae
7873 ``above or equal'' or unsigned greater than or equal
7874 @item b
7875 ``below'' or unsigned less than
7876 @item be
7877 ``below or equal'' or unsigned less than or equal
7878 @item c
7879 carry flag set
7880 @item e
7881 @itemx z
7882 ``equal'' or zero flag set
7883 @item g
7884 signed greater than
7885 @item ge
7886 signed greater than or equal
7887 @item l
7888 signed less than
7889 @item le
7890 signed less than or equal
7891 @item o
7892 overflow flag set
7893 @item p
7894 parity flag set
7895 @item s
7896 sign flag set
7897 @item na
7898 @itemx nae
7899 @itemx nb
7900 @itemx nbe
7901 @itemx nc
7902 @itemx ne
7903 @itemx ng
7904 @itemx nge
7905 @itemx nl
7906 @itemx nle
7907 @itemx no
7908 @itemx np
7909 @itemx ns
7910 @itemx nz
7911 ``not'' @var{flag}, or inverted versions of those above
7912 @end table
7914 @end table
7916 @anchor{InputOperands}
7917 @subsubsection Input Operands
7918 @cindex @code{asm} input operands
7919 @cindex @code{asm} expressions
7921 Input operands make values from C variables and expressions available to the 
7922 assembly code.
7924 Operands are separated by commas.  Each operand has this format:
7926 @example
7927 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
7928 @end example
7930 @table @var
7931 @item asmSymbolicName
7932 Specifies a symbolic name for the operand.
7933 Reference the name in the assembler template 
7934 by enclosing it in square brackets 
7935 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7936 that contains the definition. Any valid C variable name is acceptable, 
7937 including names already defined in the surrounding code. No two operands 
7938 within the same @code{asm} statement can use the same symbolic name.
7940 When not using an @var{asmSymbolicName}, use the (zero-based) position
7941 of the operand 
7942 in the list of operands in the assembler template. For example if there are
7943 two output operands and three inputs,
7944 use @samp{%2} in the template to refer to the first input operand,
7945 @samp{%3} for the second, and @samp{%4} for the third. 
7947 @item constraint
7948 A string constant specifying constraints on the placement of the operand; 
7949 @xref{Constraints}, for details.
7951 Input constraint strings may not begin with either @samp{=} or @samp{+}.
7952 When you list more than one possible location (for example, @samp{"irm"}), 
7953 the compiler chooses the most efficient one based on the current context.
7954 If you must use a specific register, but your Machine Constraints do not
7955 provide sufficient control to select the specific register you want, 
7956 local register variables may provide a solution (@pxref{Local Reg Vars}).
7958 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7959 that the specified input must be in the same place as the output constraint 
7960 at the (zero-based) index in the output constraint list. 
7961 When using @var{asmSymbolicName} syntax for the output operands,
7962 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
7964 @item cexpression
7965 This is the C variable or expression being passed to the @code{asm} statement 
7966 as input.  The enclosing parentheses are a required part of the syntax.
7968 @end table
7970 When the compiler selects the registers to use to represent the input 
7971 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
7973 If there are no output operands but there are input operands, place two 
7974 consecutive colons where the output operands would go:
7976 @example
7977 __asm__ ("some instructions"
7978    : /* No outputs. */
7979    : "r" (Offset / 8));
7980 @end example
7982 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7983 (except for inputs tied to outputs). The compiler assumes that on exit from 
7984 the @code{asm} statement these operands contain the same values as they 
7985 had before executing the statement. 
7986 It is @emph{not} possible to use clobbers
7987 to inform the compiler that the values in these inputs are changing. One 
7988 common work-around is to tie the changing input variable to an output variable 
7989 that never gets used. Note, however, that if the code that follows the 
7990 @code{asm} statement makes no use of any of the output operands, the GCC 
7991 optimizers may discard the @code{asm} statement as unneeded 
7992 (see @ref{Volatile}).
7994 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7995 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7996 dependent. The list of supported modifiers for x86 is found at 
7997 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7999 In this example using the fictitious @code{combine} instruction, the 
8000 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8001 location as output operand 0. Only input operands may use numbers in 
8002 constraints, and they must each refer to an output operand. Only a number (or 
8003 the symbolic assembler name) in the constraint can guarantee that one operand 
8004 is in the same place as another. The mere fact that @code{foo} is the value of 
8005 both operands is not enough to guarantee that they are in the same place in 
8006 the generated assembler code.
8008 @example
8009 asm ("combine %2, %0" 
8010    : "=r" (foo) 
8011    : "0" (foo), "g" (bar));
8012 @end example
8014 Here is an example using symbolic names.
8016 @example
8017 asm ("cmoveq %1, %2, %[result]" 
8018    : [result] "=r"(result) 
8019    : "r" (test), "r" (new), "[result]" (old));
8020 @end example
8022 @anchor{Clobbers}
8023 @subsubsection Clobbers
8024 @cindex @code{asm} clobbers
8026 While the compiler is aware of changes to entries listed in the output 
8027 operands, the inline @code{asm} code may modify more than just the outputs. For 
8028 example, calculations may require additional registers, or the processor may 
8029 overwrite a register as a side effect of a particular assembler instruction. 
8030 In order to inform the compiler of these changes, list them in the clobber 
8031 list. Clobber list items are either register names or the special clobbers 
8032 (listed below). Each clobber list item is a string constant 
8033 enclosed in double quotes and separated by commas.
8035 Clobber descriptions may not in any way overlap with an input or output 
8036 operand. For example, you may not have an operand describing a register class 
8037 with one member when listing that register in the clobber list. Variables 
8038 declared to live in specific registers (@pxref{Explicit Reg Vars}) and used 
8039 as @code{asm} input or output operands must have no part mentioned in the 
8040 clobber description. In particular, there is no way to specify that input 
8041 operands get modified without also specifying them as output operands.
8043 When the compiler selects which registers to use to represent input and output 
8044 operands, it does not use any of the clobbered registers. As a result, 
8045 clobbered registers are available for any use in the assembler code.
8047 Here is a realistic example for the VAX showing the use of clobbered 
8048 registers: 
8050 @example
8051 asm volatile ("movc3 %0, %1, %2"
8052                    : /* No outputs. */
8053                    : "g" (from), "g" (to), "g" (count)
8054                    : "r0", "r1", "r2", "r3", "r4", "r5");
8055 @end example
8057 Also, there are two special clobber arguments:
8059 @table @code
8060 @item "cc"
8061 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
8062 register. On some machines, GCC represents the condition codes as a specific 
8063 hardware register; @code{"cc"} serves to name this register.
8064 On other machines, condition code handling is different, 
8065 and specifying @code{"cc"} has no effect. But 
8066 it is valid no matter what the target.
8068 @item "memory"
8069 The @code{"memory"} clobber tells the compiler that the assembly code
8070 performs memory 
8071 reads or writes to items other than those listed in the input and output 
8072 operands (for example, accessing the memory pointed to by one of the input 
8073 parameters). To ensure memory contains correct values, GCC may need to flush 
8074 specific register values to memory before executing the @code{asm}. Further, 
8075 the compiler does not assume that any values read from memory before an 
8076 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
8077 needed.  
8078 Using the @code{"memory"} clobber effectively forms a read/write
8079 memory barrier for the compiler.
8081 Note that this clobber does not prevent the @emph{processor} from doing 
8082 speculative reads past the @code{asm} statement. To prevent that, you need 
8083 processor-specific fence instructions.
8085 Flushing registers to memory has performance implications and may be an issue 
8086 for time-sensitive code.  You can use a trick to avoid this if the size of 
8087 the memory being accessed is known at compile time. For example, if accessing 
8088 ten bytes of a string, use a memory input like: 
8090 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8092 @end table
8094 @anchor{GotoLabels}
8095 @subsubsection Goto Labels
8096 @cindex @code{asm} goto labels
8098 @code{asm goto} allows assembly code to jump to one or more C labels.  The
8099 @var{GotoLabels} section in an @code{asm goto} statement contains 
8100 a comma-separated 
8101 list of all C labels to which the assembler code may jump. GCC assumes that 
8102 @code{asm} execution falls through to the next statement (if this is not the 
8103 case, consider using the @code{__builtin_unreachable} intrinsic after the 
8104 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
8105 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
8106 Attributes}).
8108 An @code{asm goto} statement cannot have outputs.
8109 This is due to an internal restriction of 
8110 the compiler: control transfer instructions cannot have outputs. 
8111 If the assembler code does modify anything, use the @code{"memory"} clobber 
8112 to force the 
8113 optimizers to flush all register values to memory and reload them if 
8114 necessary after the @code{asm} statement.
8116 Also note that an @code{asm goto} statement is always implicitly
8117 considered volatile.
8119 To reference a label in the assembler template,
8120 prefix it with @samp{%l} (lowercase @samp{L}) followed 
8121 by its (zero-based) position in @var{GotoLabels} plus the number of input 
8122 operands.  For example, if the @code{asm} has three inputs and references two 
8123 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8125 Alternately, you can reference labels using the actual C label name enclosed
8126 in brackets.  For example, to reference a label named @code{carry}, you can
8127 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
8128 section when using this approach.
8130 Here is an example of @code{asm goto} for i386:
8132 @example
8133 asm goto (
8134     "btl %1, %0\n\t"
8135     "jc %l2"
8136     : /* No outputs. */
8137     : "r" (p1), "r" (p2) 
8138     : "cc" 
8139     : carry);
8141 return 0;
8143 carry:
8144 return 1;
8145 @end example
8147 The following example shows an @code{asm goto} that uses a memory clobber.
8149 @example
8150 int frob(int x)
8152   int y;
8153   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8154             : /* No outputs. */
8155             : "r"(x), "r"(&y)
8156             : "r5", "memory" 
8157             : error);
8158   return y;
8159 error:
8160   return -1;
8162 @end example
8164 @anchor{x86Operandmodifiers}
8165 @subsubsection x86 Operand Modifiers
8167 References to input, output, and goto operands in the assembler template
8168 of extended @code{asm} statements can use 
8169 modifiers to affect the way the operands are formatted in 
8170 the code output to the assembler. For example, the 
8171 following code uses the @samp{h} and @samp{b} modifiers for x86:
8173 @example
8174 uint16_t  num;
8175 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8176 @end example
8178 @noindent
8179 These modifiers generate this assembler code:
8181 @example
8182 xchg %ah, %al
8183 @end example
8185 The rest of this discussion uses the following code for illustrative purposes.
8187 @example
8188 int main()
8190    int iInt = 1;
8192 top:
8194    asm volatile goto ("some assembler instructions here"
8195    : /* No outputs. */
8196    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8197    : /* No clobbers. */
8198    : top);
8200 @end example
8202 With no modifiers, this is what the output from the operands would be for the 
8203 @samp{att} and @samp{intel} dialects of assembler:
8205 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8206 @headitem Operand @tab masm=att @tab masm=intel
8207 @item @code{%0}
8208 @tab @code{%eax}
8209 @tab @code{eax}
8210 @item @code{%1}
8211 @tab @code{$2}
8212 @tab @code{2}
8213 @item @code{%2}
8214 @tab @code{$.L2}
8215 @tab @code{OFFSET FLAT:.L2}
8216 @end multitable
8218 The table below shows the list of supported modifiers and their effects.
8220 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8221 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8222 @item @code{z}
8223 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8224 @tab @code{%z0}
8225 @tab @code{l}
8226 @tab 
8227 @item @code{b}
8228 @tab Print the QImode name of the register.
8229 @tab @code{%b0}
8230 @tab @code{%al}
8231 @tab @code{al}
8232 @item @code{h}
8233 @tab Print the QImode name for a ``high'' register.
8234 @tab @code{%h0}
8235 @tab @code{%ah}
8236 @tab @code{ah}
8237 @item @code{w}
8238 @tab Print the HImode name of the register.
8239 @tab @code{%w0}
8240 @tab @code{%ax}
8241 @tab @code{ax}
8242 @item @code{k}
8243 @tab Print the SImode name of the register.
8244 @tab @code{%k0}
8245 @tab @code{%eax}
8246 @tab @code{eax}
8247 @item @code{q}
8248 @tab Print the DImode name of the register.
8249 @tab @code{%q0}
8250 @tab @code{%rax}
8251 @tab @code{rax}
8252 @item @code{l}
8253 @tab Print the label name with no punctuation.
8254 @tab @code{%l2}
8255 @tab @code{.L2}
8256 @tab @code{.L2}
8257 @item @code{c}
8258 @tab Require a constant operand and print the constant expression with no punctuation.
8259 @tab @code{%c1}
8260 @tab @code{2}
8261 @tab @code{2}
8262 @end multitable
8264 @anchor{x86floatingpointasmoperands}
8265 @subsubsection x86 Floating-Point @code{asm} Operands
8267 On x86 targets, there are several rules on the usage of stack-like registers
8268 in the operands of an @code{asm}.  These rules apply only to the operands
8269 that are stack-like registers:
8271 @enumerate
8272 @item
8273 Given a set of input registers that die in an @code{asm}, it is
8274 necessary to know which are implicitly popped by the @code{asm}, and
8275 which must be explicitly popped by GCC@.
8277 An input register that is implicitly popped by the @code{asm} must be
8278 explicitly clobbered, unless it is constrained to match an
8279 output operand.
8281 @item
8282 For any input register that is implicitly popped by an @code{asm}, it is
8283 necessary to know how to adjust the stack to compensate for the pop.
8284 If any non-popped input is closer to the top of the reg-stack than
8285 the implicitly popped register, it would not be possible to know what the
8286 stack looked like---it's not clear how the rest of the stack ``slides
8287 up''.
8289 All implicitly popped input registers must be closer to the top of
8290 the reg-stack than any input that is not implicitly popped.
8292 It is possible that if an input dies in an @code{asm}, the compiler might
8293 use the input register for an output reload.  Consider this example:
8295 @smallexample
8296 asm ("foo" : "=t" (a) : "f" (b));
8297 @end smallexample
8299 @noindent
8300 This code says that input @code{b} is not popped by the @code{asm}, and that
8301 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8302 deeper after the @code{asm} than it was before.  But, it is possible that
8303 reload may think that it can use the same register for both the input and
8304 the output.
8306 To prevent this from happening,
8307 if any input operand uses the @samp{f} constraint, all output register
8308 constraints must use the @samp{&} early-clobber modifier.
8310 The example above is correctly written as:
8312 @smallexample
8313 asm ("foo" : "=&t" (a) : "f" (b));
8314 @end smallexample
8316 @item
8317 Some operands need to be in particular places on the stack.  All
8318 output operands fall in this category---GCC has no other way to
8319 know which registers the outputs appear in unless you indicate
8320 this in the constraints.
8322 Output operands must specifically indicate which register an output
8323 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
8324 constraints must select a class with a single register.
8326 @item
8327 Output operands may not be ``inserted'' between existing stack registers.
8328 Since no 387 opcode uses a read/write operand, all output operands
8329 are dead before the @code{asm}, and are pushed by the @code{asm}.
8330 It makes no sense to push anywhere but the top of the reg-stack.
8332 Output operands must start at the top of the reg-stack: output
8333 operands may not ``skip'' a register.
8335 @item
8336 Some @code{asm} statements may need extra stack space for internal
8337 calculations.  This can be guaranteed by clobbering stack registers
8338 unrelated to the inputs and outputs.
8340 @end enumerate
8342 This @code{asm}
8343 takes one input, which is internally popped, and produces two outputs.
8345 @smallexample
8346 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8347 @end smallexample
8349 @noindent
8350 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8351 and replaces them with one output.  The @code{st(1)} clobber is necessary 
8352 for the compiler to know that @code{fyl2xp1} pops both inputs.
8354 @smallexample
8355 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8356 @end smallexample
8358 @lowersections
8359 @include md.texi
8360 @raisesections
8362 @node Asm Labels
8363 @subsection Controlling Names Used in Assembler Code
8364 @cindex assembler names for identifiers
8365 @cindex names used in assembler code
8366 @cindex identifiers, names in assembler code
8368 You can specify the name to be used in the assembler code for a C
8369 function or variable by writing the @code{asm} (or @code{__asm__})
8370 keyword after the declarator as follows:
8372 @smallexample
8373 int foo asm ("myfoo") = 2;
8374 @end smallexample
8376 @noindent
8377 This specifies that the name to be used for the variable @code{foo} in
8378 the assembler code should be @samp{myfoo} rather than the usual
8379 @samp{_foo}.
8381 On systems where an underscore is normally prepended to the name of a C
8382 function or variable, this feature allows you to define names for the
8383 linker that do not start with an underscore.
8385 It does not make sense to use this feature with a non-static local
8386 variable since such variables do not have assembler names.  If you are
8387 trying to put the variable in a particular register, see @ref{Explicit
8388 Reg Vars}.  GCC presently accepts such code with a warning, but will
8389 probably be changed to issue an error, rather than a warning, in the
8390 future.
8392 You cannot use @code{asm} in this way in a function @emph{definition}; but
8393 you can get the same effect by writing a declaration for the function
8394 before its definition and putting @code{asm} there, like this:
8396 @smallexample
8397 extern func () asm ("FUNC");
8399 func (x, y)
8400      int x, y;
8401 /* @r{@dots{}} */
8402 @end smallexample
8404 It is up to you to make sure that the assembler names you choose do not
8405 conflict with any other assembler symbols.  Also, you must not use a
8406 register name; that would produce completely invalid assembler code.  GCC
8407 does not as yet have the ability to store static variables in registers.
8408 Perhaps that will be added.
8410 @node Explicit Reg Vars
8411 @subsection Variables in Specified Registers
8412 @cindex explicit register variables
8413 @cindex variables in specified registers
8414 @cindex specified registers
8415 @cindex registers, global allocation
8417 GNU C allows you to put a few global variables into specified hardware
8418 registers.  You can also specify the register in which an ordinary
8419 register variable should be allocated.
8421 @itemize @bullet
8422 @item
8423 Global register variables reserve registers throughout the program.
8424 This may be useful in programs such as programming language
8425 interpreters that have a couple of global variables that are accessed
8426 very often.
8428 @item
8429 Local register variables in specific registers do not reserve the
8430 registers, except at the point where they are used as input or output
8431 operands in an @code{asm} statement and the @code{asm} statement itself is
8432 not deleted.  The compiler's data flow analysis is capable of determining
8433 where the specified registers contain live values, and where they are
8434 available for other uses.  Stores into local register variables may be deleted
8435 when they appear to be dead according to dataflow analysis.  References
8436 to local register variables may be deleted or moved or simplified.
8438 These local variables are sometimes convenient for use with the extended
8439 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
8440 output of the assembler instruction directly into a particular register.
8441 (This works provided the register you specify fits the constraints
8442 specified for that operand in the @code{asm}.)
8443 @end itemize
8445 @menu
8446 * Global Reg Vars::
8447 * Local Reg Vars::
8448 @end menu
8450 @node Global Reg Vars
8451 @subsubsection Defining Global Register Variables
8452 @cindex global register variables
8453 @cindex registers, global variables in
8455 You can define a global register variable in GNU C like this:
8457 @smallexample
8458 register int *foo asm ("a5");
8459 @end smallexample
8461 @noindent
8462 Here @code{a5} is the name of the register that should be used.  Choose a
8463 register that is normally saved and restored by function calls on your
8464 machine, so that library routines will not clobber it.
8466 Naturally the register name is CPU-dependent, so you need to
8467 conditionalize your program according to CPU type.  The register
8468 @code{a5} is a good choice on a 68000 for a variable of pointer
8469 type.  On machines with register windows, be sure to choose a ``global''
8470 register that is not affected magically by the function call mechanism.
8472 In addition, different operating systems on the same CPU may differ in how they
8473 name the registers; then you need additional conditionals.  For
8474 example, some 68000 operating systems call this register @code{%a5}.
8476 Eventually there may be a way of asking the compiler to choose a register
8477 automatically, but first we need to figure out how it should choose and
8478 how to enable you to guide the choice.  No solution is evident.
8480 Defining a global register variable in a certain register reserves that
8481 register entirely for this use, at least within the current compilation.
8482 The register is not allocated for any other purpose in the functions
8483 in the current compilation, and is not saved and restored by
8484 these functions.  Stores into this register are never deleted even if they
8485 appear to be dead, but references may be deleted or moved or
8486 simplified.
8488 It is not safe to access the global register variables from signal
8489 handlers, or from more than one thread of control, because the system
8490 library routines may temporarily use the register for other things (unless
8491 you recompile them specially for the task at hand).
8493 @cindex @code{qsort}, and global register variables
8494 It is not safe for one function that uses a global register variable to
8495 call another such function @code{foo} by way of a third function
8496 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
8497 different source file in which the variable isn't declared).  This is
8498 because @code{lose} might save the register and put some other value there.
8499 For example, you can't expect a global register variable to be available in
8500 the comparison-function that you pass to @code{qsort}, since @code{qsort}
8501 might have put something else in that register.  (If you are prepared to
8502 recompile @code{qsort} with the same global register variable, you can
8503 solve this problem.)
8505 If you want to recompile @code{qsort} or other source files that do not
8506 actually use your global register variable, so that they do not use that
8507 register for any other purpose, then it suffices to specify the compiler
8508 option @option{-ffixed-@var{reg}}.  You need not actually add a global
8509 register declaration to their source code.
8511 A function that can alter the value of a global register variable cannot
8512 safely be called from a function compiled without this variable, because it
8513 could clobber the value the caller expects to find there on return.
8514 Therefore, the function that is the entry point into the part of the
8515 program that uses the global register variable must explicitly save and
8516 restore the value that belongs to its caller.
8518 @cindex register variable after @code{longjmp}
8519 @cindex global register after @code{longjmp}
8520 @cindex value after @code{longjmp}
8521 @findex longjmp
8522 @findex setjmp
8523 On most machines, @code{longjmp} restores to each global register
8524 variable the value it had at the time of the @code{setjmp}.  On some
8525 machines, however, @code{longjmp} does not change the value of global
8526 register variables.  To be portable, the function that called @code{setjmp}
8527 should make other arrangements to save the values of the global register
8528 variables, and to restore them in a @code{longjmp}.  This way, the same
8529 thing happens regardless of what @code{longjmp} does.
8531 All global register variable declarations must precede all function
8532 definitions.  If such a declaration could appear after function
8533 definitions, the declaration would be too late to prevent the register from
8534 being used for other purposes in the preceding functions.
8536 Global register variables may not have initial values, because an
8537 executable file has no means to supply initial contents for a register.
8539 On the SPARC, there are reports that g3 @dots{} g7 are suitable
8540 registers, but certain library functions, such as @code{getwd}, as well
8541 as the subroutines for division and remainder, modify g3 and g4.  g1 and
8542 g2 are local temporaries.
8544 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
8545 Of course, it does not do to use more than a few of those.
8547 @node Local Reg Vars
8548 @subsubsection Specifying Registers for Local Variables
8549 @cindex local variables, specifying registers
8550 @cindex specifying registers for local variables
8551 @cindex registers for local variables
8553 You can define a local register variable with a specified register
8554 like this:
8556 @smallexample
8557 register int *foo asm ("a5");
8558 @end smallexample
8560 @noindent
8561 Here @code{a5} is the name of the register that should be used.  Note
8562 that this is the same syntax used for defining global register
8563 variables, but for a local variable it appears within a function.
8565 Naturally the register name is CPU-dependent, but this is not a
8566 problem, since specific registers are most often useful with explicit
8567 assembler instructions (@pxref{Extended Asm}).  Both of these things
8568 generally require that you conditionalize your program according to
8569 CPU type.
8571 In addition, operating systems on one type of CPU may differ in how they
8572 name the registers; then you need additional conditionals.  For
8573 example, some 68000 operating systems call this register @code{%a5}.
8575 Defining such a register variable does not reserve the register; it
8576 remains available for other uses in places where flow control determines
8577 the variable's value is not live.
8579 This option does not guarantee that GCC generates code that has
8580 this variable in the register you specify at all times.  You may not
8581 code an explicit reference to this register in the assembler
8582 instruction template part of an @code{asm} statement and assume it
8583 always refers to this variable.
8584 However, using the variable as an input or output operand to the @code{asm}
8585 guarantees that the specified register is used for that operand.  
8586 @xref{Extended Asm}, for more information.
8588 Stores into local register variables may be deleted when they appear to be dead
8589 according to dataflow analysis.  References to local register variables may
8590 be deleted or moved or simplified.
8592 As with global register variables, it is recommended that you choose a
8593 register that is normally saved and restored by function calls on
8594 your machine, so that library routines will not clobber it.  
8596 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
8597 specific register, but there's no matching constraint letter for that 
8598 register. To force the operand into that register, create a local variable 
8599 and specify the register in the variable's declaration. Then use the local 
8600 variable for the asm operand and specify any constraint letter that matches 
8601 the register:
8603 @smallexample
8604 register int *p1 asm ("r0") = @dots{};
8605 register int *p2 asm ("r1") = @dots{};
8606 register int *result asm ("r0");
8607 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8608 @end smallexample
8610 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
8611 call-clobbered by subsequent code, including function calls and library calls 
8612 for arithmetic operators on other variables (for example the initialization 
8613 of p2). In this case, use temporary variables for expressions between the 
8614 register assignments:
8616 @smallexample
8617 int t1 = @dots{};
8618 register int *p1 asm ("r0") = @dots{};
8619 register int *p2 asm ("r1") = t1;
8620 register int *result asm ("r0");
8621 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8622 @end smallexample
8624 @node Size of an asm
8625 @subsection Size of an @code{asm}
8627 Some targets require that GCC track the size of each instruction used
8628 in order to generate correct code.  Because the final length of the
8629 code produced by an @code{asm} statement is only known by the
8630 assembler, GCC must make an estimate as to how big it will be.  It
8631 does this by counting the number of instructions in the pattern of the
8632 @code{asm} and multiplying that by the length of the longest
8633 instruction supported by that processor.  (When working out the number
8634 of instructions, it assumes that any occurrence of a newline or of
8635 whatever statement separator character is supported by the assembler --
8636 typically @samp{;} --- indicates the end of an instruction.)
8638 Normally, GCC's estimate is adequate to ensure that correct
8639 code is generated, but it is possible to confuse the compiler if you use
8640 pseudo instructions or assembler macros that expand into multiple real
8641 instructions, or if you use assembler directives that expand to more
8642 space in the object file than is needed for a single instruction.
8643 If this happens then the assembler may produce a diagnostic saying that
8644 a label is unreachable.
8646 @node Alternate Keywords
8647 @section Alternate Keywords
8648 @cindex alternate keywords
8649 @cindex keywords, alternate
8651 @option{-ansi} and the various @option{-std} options disable certain
8652 keywords.  This causes trouble when you want to use GNU C extensions, or
8653 a general-purpose header file that should be usable by all programs,
8654 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
8655 @code{inline} are not available in programs compiled with
8656 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8657 program compiled with @option{-std=c99} or @option{-std=c11}).  The
8658 ISO C99 keyword
8659 @code{restrict} is only available when @option{-std=gnu99} (which will
8660 eventually be the default) or @option{-std=c99} (or the equivalent
8661 @option{-std=iso9899:1999}), or an option for a later standard
8662 version, is used.
8664 The way to solve these problems is to put @samp{__} at the beginning and
8665 end of each problematical keyword.  For example, use @code{__asm__}
8666 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8668 Other C compilers won't accept these alternative keywords; if you want to
8669 compile with another compiler, you can define the alternate keywords as
8670 macros to replace them with the customary keywords.  It looks like this:
8672 @smallexample
8673 #ifndef __GNUC__
8674 #define __asm__ asm
8675 #endif
8676 @end smallexample
8678 @findex __extension__
8679 @opindex pedantic
8680 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8681 You can
8682 prevent such warnings within one expression by writing
8683 @code{__extension__} before the expression.  @code{__extension__} has no
8684 effect aside from this.
8686 @node Incomplete Enums
8687 @section Incomplete @code{enum} Types
8689 You can define an @code{enum} tag without specifying its possible values.
8690 This results in an incomplete type, much like what you get if you write
8691 @code{struct foo} without describing the elements.  A later declaration
8692 that does specify the possible values completes the type.
8694 You can't allocate variables or storage using the type while it is
8695 incomplete.  However, you can work with pointers to that type.
8697 This extension may not be very useful, but it makes the handling of
8698 @code{enum} more consistent with the way @code{struct} and @code{union}
8699 are handled.
8701 This extension is not supported by GNU C++.
8703 @node Function Names
8704 @section Function Names as Strings
8705 @cindex @code{__func__} identifier
8706 @cindex @code{__FUNCTION__} identifier
8707 @cindex @code{__PRETTY_FUNCTION__} identifier
8709 GCC provides three magic variables that hold the name of the current
8710 function, as a string.  The first of these is @code{__func__}, which
8711 is part of the C99 standard:
8713 The identifier @code{__func__} is implicitly declared by the translator
8714 as if, immediately following the opening brace of each function
8715 definition, the declaration
8717 @smallexample
8718 static const char __func__[] = "function-name";
8719 @end smallexample
8721 @noindent
8722 appeared, where function-name is the name of the lexically-enclosing
8723 function.  This name is the unadorned name of the function.
8725 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8726 backward compatibility with old versions of GCC.
8728 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8729 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
8730 the type signature of the function as well as its bare name.  For
8731 example, this program:
8733 @smallexample
8734 extern "C" @{
8735 extern int printf (char *, ...);
8738 class a @{
8739  public:
8740   void sub (int i)
8741     @{
8742       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8743       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8744     @}
8748 main (void)
8750   a ax;
8751   ax.sub (0);
8752   return 0;
8754 @end smallexample
8756 @noindent
8757 gives this output:
8759 @smallexample
8760 __FUNCTION__ = sub
8761 __PRETTY_FUNCTION__ = void a::sub(int)
8762 @end smallexample
8764 These identifiers are variables, not preprocessor macros, and may not
8765 be used to initialize @code{char} arrays or be concatenated with other string
8766 literals.
8768 @node Return Address
8769 @section Getting the Return or Frame Address of a Function
8771 These functions may be used to get information about the callers of a
8772 function.
8774 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8775 This function returns the return address of the current function, or of
8776 one of its callers.  The @var{level} argument is number of frames to
8777 scan up the call stack.  A value of @code{0} yields the return address
8778 of the current function, a value of @code{1} yields the return address
8779 of the caller of the current function, and so forth.  When inlining
8780 the expected behavior is that the function returns the address of
8781 the function that is returned to.  To work around this behavior use
8782 the @code{noinline} function attribute.
8784 The @var{level} argument must be a constant integer.
8786 On some machines it may be impossible to determine the return address of
8787 any function other than the current one; in such cases, or when the top
8788 of the stack has been reached, this function returns @code{0} or a
8789 random value.  In addition, @code{__builtin_frame_address} may be used
8790 to determine if the top of the stack has been reached.
8792 Additional post-processing of the returned value may be needed, see
8793 @code{__builtin_extract_return_addr}.
8795 Calling this function with a nonzero argument can have unpredictable
8796 effects, including crashing the calling program.  As a result, calls
8797 that are considered unsafe are diagnosed when the @option{-Wframe-address}
8798 option is in effect.  Such calls should only be made in debugging
8799 situations.
8800 @end deftypefn
8802 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8803 The address as returned by @code{__builtin_return_address} may have to be fed
8804 through this function to get the actual encoded address.  For example, on the
8805 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8806 platforms an offset has to be added for the true next instruction to be
8807 executed.
8809 If no fixup is needed, this function simply passes through @var{addr}.
8810 @end deftypefn
8812 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
8813 This function does the reverse of @code{__builtin_extract_return_addr}.
8814 @end deftypefn
8816 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
8817 This function is similar to @code{__builtin_return_address}, but it
8818 returns the address of the function frame rather than the return address
8819 of the function.  Calling @code{__builtin_frame_address} with a value of
8820 @code{0} yields the frame address of the current function, a value of
8821 @code{1} yields the frame address of the caller of the current function,
8822 and so forth.
8824 The frame is the area on the stack that holds local variables and saved
8825 registers.  The frame address is normally the address of the first word
8826 pushed on to the stack by the function.  However, the exact definition
8827 depends upon the processor and the calling convention.  If the processor
8828 has a dedicated frame pointer register, and the function has a frame,
8829 then @code{__builtin_frame_address} returns the value of the frame
8830 pointer register.
8832 On some machines it may be impossible to determine the frame address of
8833 any function other than the current one; in such cases, or when the top
8834 of the stack has been reached, this function returns @code{0} if
8835 the first frame pointer is properly initialized by the startup code.
8837 Calling this function with a nonzero argument can have unpredictable
8838 effects, including crashing the calling program.  As a result, calls
8839 that are considered unsafe are diagnosed when the @option{-Wframe-address}
8840 option is in effect.  Such calls should only be made in debugging
8841 situations.
8842 @end deftypefn
8844 @node Vector Extensions
8845 @section Using Vector Instructions through Built-in Functions
8847 On some targets, the instruction set contains SIMD vector instructions which
8848 operate on multiple values contained in one large register at the same time.
8849 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
8850 this way.
8852 The first step in using these extensions is to provide the necessary data
8853 types.  This should be done using an appropriate @code{typedef}:
8855 @smallexample
8856 typedef int v4si __attribute__ ((vector_size (16)));
8857 @end smallexample
8859 @noindent
8860 The @code{int} type specifies the base type, while the attribute specifies
8861 the vector size for the variable, measured in bytes.  For example, the
8862 declaration above causes the compiler to set the mode for the @code{v4si}
8863 type to be 16 bytes wide and divided into @code{int} sized units.  For
8864 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
8865 corresponding mode of @code{foo} is @acronym{V4SI}.
8867 The @code{vector_size} attribute is only applicable to integral and
8868 float scalars, although arrays, pointers, and function return values
8869 are allowed in conjunction with this construct. Only sizes that are
8870 a power of two are currently allowed.
8872 All the basic integer types can be used as base types, both as signed
8873 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
8874 @code{long long}.  In addition, @code{float} and @code{double} can be
8875 used to build floating-point vector types.
8877 Specifying a combination that is not valid for the current architecture
8878 causes GCC to synthesize the instructions using a narrower mode.
8879 For example, if you specify a variable of type @code{V4SI} and your
8880 architecture does not allow for this specific SIMD type, GCC
8881 produces code that uses 4 @code{SIs}.
8883 The types defined in this manner can be used with a subset of normal C
8884 operations.  Currently, GCC allows using the following operators
8885 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
8887 The operations behave like C++ @code{valarrays}.  Addition is defined as
8888 the addition of the corresponding elements of the operands.  For
8889 example, in the code below, each of the 4 elements in @var{a} is
8890 added to the corresponding 4 elements in @var{b} and the resulting
8891 vector is stored in @var{c}.
8893 @smallexample
8894 typedef int v4si __attribute__ ((vector_size (16)));
8896 v4si a, b, c;
8898 c = a + b;
8899 @end smallexample
8901 Subtraction, multiplication, division, and the logical operations
8902 operate in a similar manner.  Likewise, the result of using the unary
8903 minus or complement operators on a vector type is a vector whose
8904 elements are the negative or complemented values of the corresponding
8905 elements in the operand.
8907 It is possible to use shifting operators @code{<<}, @code{>>} on
8908 integer-type vectors. The operation is defined as following: @code{@{a0,
8909 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
8910 @dots{}, an >> bn@}}@. Vector operands must have the same number of
8911 elements. 
8913 For convenience, it is allowed to use a binary vector operation
8914 where one operand is a scalar. In that case the compiler transforms
8915 the scalar operand into a vector where each element is the scalar from
8916 the operation. The transformation happens only if the scalar could be
8917 safely converted to the vector-element type.
8918 Consider the following code.
8920 @smallexample
8921 typedef int v4si __attribute__ ((vector_size (16)));
8923 v4si a, b, c;
8924 long l;
8926 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8927 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8929 a = l + a;    /* Error, cannot convert long to int. */
8930 @end smallexample
8932 Vectors can be subscripted as if the vector were an array with
8933 the same number of elements and base type.  Out of bound accesses
8934 invoke undefined behavior at run time.  Warnings for out of bound
8935 accesses for vector subscription can be enabled with
8936 @option{-Warray-bounds}.
8938 Vector comparison is supported with standard comparison
8939 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8940 vector expressions of integer-type or real-type. Comparison between
8941 integer-type vectors and real-type vectors are not supported.  The
8942 result of the comparison is a vector of the same width and number of
8943 elements as the comparison operands with a signed integral element
8944 type.
8946 Vectors are compared element-wise producing 0 when comparison is false
8947 and -1 (constant of the appropriate type where all bits are set)
8948 otherwise. Consider the following example.
8950 @smallexample
8951 typedef int v4si __attribute__ ((vector_size (16)));
8953 v4si a = @{1,2,3,4@};
8954 v4si b = @{3,2,1,4@};
8955 v4si c;
8957 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8958 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8959 @end smallexample
8961 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8962 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8963 integer vector with the same number of elements of the same size as @code{b}
8964 and @code{c}, computes all three arguments and creates a vector
8965 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8966 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8967 As in the case of binary operations, this syntax is also accepted when
8968 one of @code{b} or @code{c} is a scalar that is then transformed into a
8969 vector. If both @code{b} and @code{c} are scalars and the type of
8970 @code{true?b:c} has the same size as the element type of @code{a}, then
8971 @code{b} and @code{c} are converted to a vector type whose elements have
8972 this type and with the same number of elements as @code{a}.
8974 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8975 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8976 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8977 For mixed operations between a scalar @code{s} and a vector @code{v},
8978 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8979 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8981 Vector shuffling is available using functions
8982 @code{__builtin_shuffle (vec, mask)} and
8983 @code{__builtin_shuffle (vec0, vec1, mask)}.
8984 Both functions construct a permutation of elements from one or two
8985 vectors and return a vector of the same type as the input vector(s).
8986 The @var{mask} is an integral vector with the same width (@var{W})
8987 and element count (@var{N}) as the output vector.
8989 The elements of the input vectors are numbered in memory ordering of
8990 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8991 elements of @var{mask} are considered modulo @var{N} in the single-operand
8992 case and modulo @math{2*@var{N}} in the two-operand case.
8994 Consider the following example,
8996 @smallexample
8997 typedef int v4si __attribute__ ((vector_size (16)));
8999 v4si a = @{1,2,3,4@};
9000 v4si b = @{5,6,7,8@};
9001 v4si mask1 = @{0,1,1,3@};
9002 v4si mask2 = @{0,4,2,5@};
9003 v4si res;
9005 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
9006 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
9007 @end smallexample
9009 Note that @code{__builtin_shuffle} is intentionally semantically
9010 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9012 You can declare variables and use them in function calls and returns, as
9013 well as in assignments and some casts.  You can specify a vector type as
9014 a return type for a function.  Vector types can also be used as function
9015 arguments.  It is possible to cast from one vector type to another,
9016 provided they are of the same size (in fact, you can also cast vectors
9017 to and from other datatypes of the same size).
9019 You cannot operate between vectors of different lengths or different
9020 signedness without a cast.
9022 @node Offsetof
9023 @section Support for @code{offsetof}
9024 @findex __builtin_offsetof
9026 GCC implements for both C and C++ a syntactic extension to implement
9027 the @code{offsetof} macro.
9029 @smallexample
9030 primary:
9031         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9033 offsetof_member_designator:
9034           @code{identifier}
9035         | offsetof_member_designator "." @code{identifier}
9036         | offsetof_member_designator "[" @code{expr} "]"
9037 @end smallexample
9039 This extension is sufficient such that
9041 @smallexample
9042 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
9043 @end smallexample
9045 @noindent
9046 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
9047 may be dependent.  In either case, @var{member} may consist of a single
9048 identifier, or a sequence of member accesses and array references.
9050 @node __sync Builtins
9051 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9053 The following built-in functions
9054 are intended to be compatible with those described
9055 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9056 section 7.4.  As such, they depart from normal GCC practice by not using
9057 the @samp{__builtin_} prefix and also by being overloaded so that they
9058 work on multiple types.
9060 The definition given in the Intel documentation allows only for the use of
9061 the types @code{int}, @code{long}, @code{long long} or their unsigned
9062 counterparts.  GCC allows any integral scalar or pointer type that is
9063 1, 2, 4 or 8 bytes in length.
9065 These functions are implemented in terms of the @samp{__atomic}
9066 builtins (@pxref{__atomic Builtins}).  They should not be used for new
9067 code which should use the @samp{__atomic} builtins instead.
9069 Not all operations are supported by all target processors.  If a particular
9070 operation cannot be implemented on the target processor, a warning is
9071 generated and a call to an external function is generated.  The external
9072 function carries the same name as the built-in version,
9073 with an additional suffix
9074 @samp{_@var{n}} where @var{n} is the size of the data type.
9076 @c ??? Should we have a mechanism to suppress this warning?  This is almost
9077 @c useful for implementing the operation under the control of an external
9078 @c mutex.
9080 In most cases, these built-in functions are considered a @dfn{full barrier}.
9081 That is,
9082 no memory operand is moved across the operation, either forward or
9083 backward.  Further, instructions are issued as necessary to prevent the
9084 processor from speculating loads across the operation and from queuing stores
9085 after the operation.
9087 All of the routines are described in the Intel documentation to take
9088 ``an optional list of variables protected by the memory barrier''.  It's
9089 not clear what is meant by that; it could mean that @emph{only} the
9090 listed variables are protected, or it could mean a list of additional
9091 variables to be protected.  The list is ignored by GCC which treats it as
9092 empty.  GCC interprets an empty list as meaning that all globally
9093 accessible variables should be protected.
9095 @table @code
9096 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9097 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9098 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9099 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9100 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9101 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9102 @findex __sync_fetch_and_add
9103 @findex __sync_fetch_and_sub
9104 @findex __sync_fetch_and_or
9105 @findex __sync_fetch_and_and
9106 @findex __sync_fetch_and_xor
9107 @findex __sync_fetch_and_nand
9108 These built-in functions perform the operation suggested by the name, and
9109 returns the value that had previously been in memory.  That is,
9111 @smallexample
9112 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9113 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
9114 @end smallexample
9116 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9117 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9119 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9120 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9121 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9122 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9123 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9124 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9125 @findex __sync_add_and_fetch
9126 @findex __sync_sub_and_fetch
9127 @findex __sync_or_and_fetch
9128 @findex __sync_and_and_fetch
9129 @findex __sync_xor_and_fetch
9130 @findex __sync_nand_and_fetch
9131 These built-in functions perform the operation suggested by the name, and
9132 return the new value.  That is,
9134 @smallexample
9135 @{ *ptr @var{op}= value; return *ptr; @}
9136 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
9137 @end smallexample
9139 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9140 as @code{*ptr = ~(*ptr & value)} instead of
9141 @code{*ptr = ~*ptr & value}.
9143 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9144 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9145 @findex __sync_bool_compare_and_swap
9146 @findex __sync_val_compare_and_swap
9147 These built-in functions perform an atomic compare and swap.
9148 That is, if the current
9149 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9150 @code{*@var{ptr}}.
9152 The ``bool'' version returns true if the comparison is successful and
9153 @var{newval} is written.  The ``val'' version returns the contents
9154 of @code{*@var{ptr}} before the operation.
9156 @item __sync_synchronize (...)
9157 @findex __sync_synchronize
9158 This built-in function issues a full memory barrier.
9160 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9161 @findex __sync_lock_test_and_set
9162 This built-in function, as described by Intel, is not a traditional test-and-set
9163 operation, but rather an atomic exchange operation.  It writes @var{value}
9164 into @code{*@var{ptr}}, and returns the previous contents of
9165 @code{*@var{ptr}}.
9167 Many targets have only minimal support for such locks, and do not support
9168 a full exchange operation.  In this case, a target may support reduced
9169 functionality here by which the @emph{only} valid value to store is the
9170 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
9171 is implementation defined.
9173 This built-in function is not a full barrier,
9174 but rather an @dfn{acquire barrier}.
9175 This means that references after the operation cannot move to (or be
9176 speculated to) before the operation, but previous memory stores may not
9177 be globally visible yet, and previous memory loads may not yet be
9178 satisfied.
9180 @item void __sync_lock_release (@var{type} *ptr, ...)
9181 @findex __sync_lock_release
9182 This built-in function releases the lock acquired by
9183 @code{__sync_lock_test_and_set}.
9184 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9186 This built-in function is not a full barrier,
9187 but rather a @dfn{release barrier}.
9188 This means that all previous memory stores are globally visible, and all
9189 previous memory loads have been satisfied, but following memory reads
9190 are not prevented from being speculated to before the barrier.
9191 @end table
9193 @node __atomic Builtins
9194 @section Built-in Functions for Memory Model Aware Atomic Operations
9196 The following built-in functions approximately match the requirements
9197 for the C++11 memory model.  They are all
9198 identified by being prefixed with @samp{__atomic} and most are
9199 overloaded so that they work with multiple types.
9201 These functions are intended to replace the legacy @samp{__sync}
9202 builtins.  The main difference is that the memory order that is requested
9203 is a parameter to the functions.  New code should always use the
9204 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9206 Note that the @samp{__atomic} builtins assume that programs will
9207 conform to the C++11 memory model.  In particular, they assume
9208 that programs are free of data races.  See the C++11 standard for
9209 detailed requirements.
9211 The @samp{__atomic} builtins can be used with any integral scalar or
9212 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
9213 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9214 supported by the architecture.
9216 The four non-arithmetic functions (load, store, exchange, and 
9217 compare_exchange) all have a generic version as well.  This generic
9218 version works on any data type.  It uses the lock-free built-in function
9219 if the specific data type size makes that possible; otherwise, an
9220 external call is left to be resolved at run time.  This external call is
9221 the same format with the addition of a @samp{size_t} parameter inserted
9222 as the first parameter indicating the size of the object being pointed to.
9223 All objects must be the same size.
9225 There are 6 different memory orders that can be specified.  These map
9226 to the C++11 memory orders with the same names, see the C++11 standard
9227 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9228 on atomic synchronization} for detailed definitions.  Individual
9229 targets may also support additional memory orders for use on specific
9230 architectures.  Refer to the target documentation for details of
9231 these.
9233 An atomic operation can both constrain code motion and
9234 be mapped to hardware instructions for synchronization between threads
9235 (e.g., a fence).  To which extent this happens is controlled by the
9236 memory orders, which are listed here in approximately ascending order of
9237 strength.  The description of each memory order is only meant to roughly
9238 illustrate the effects and is not a specification; see the C++11
9239 memory model for precise semantics.
9241 @table  @code
9242 @item __ATOMIC_RELAXED
9243 Implies no inter-thread ordering constraints.
9244 @item __ATOMIC_CONSUME
9245 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9246 memory order because of a deficiency in C++11's semantics for
9247 @code{memory_order_consume}.
9248 @item __ATOMIC_ACQUIRE
9249 Creates an inter-thread happens-before constraint from the release (or
9250 stronger) semantic store to this acquire load.  Can prevent hoisting
9251 of code to before the operation.
9252 @item __ATOMIC_RELEASE
9253 Creates an inter-thread happens-before constraint to acquire (or stronger)
9254 semantic loads that read from this release store.  Can prevent sinking
9255 of code to after the operation.
9256 @item __ATOMIC_ACQ_REL
9257 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9258 @code{__ATOMIC_RELEASE}.
9259 @item __ATOMIC_SEQ_CST
9260 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9261 @end table
9263 Note that in the C++11 memory model, @emph{fences} (e.g.,
9264 @samp{__atomic_thread_fence}) take effect in combination with other
9265 atomic operations on specific memory locations (e.g., atomic loads);
9266 operations on specific memory locations do not necessarily affect other
9267 operations in the same way.
9269 Target architectures are encouraged to provide their own patterns for
9270 each of the atomic built-in functions.  If no target is provided, the original
9271 non-memory model set of @samp{__sync} atomic built-in functions are
9272 used, along with any required synchronization fences surrounding it in
9273 order to achieve the proper behavior.  Execution in this case is subject
9274 to the same restrictions as those built-in functions.
9276 If there is no pattern or mechanism to provide a lock-free instruction
9277 sequence, a call is made to an external routine with the same parameters
9278 to be resolved at run time.
9280 When implementing patterns for these built-in functions, the memory order
9281 parameter can be ignored as long as the pattern implements the most
9282 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
9283 orders execute correctly with this memory order but they may not execute as
9284 efficiently as they could with a more appropriate implementation of the
9285 relaxed requirements.
9287 Note that the C++11 standard allows for the memory order parameter to be
9288 determined at run time rather than at compile time.  These built-in
9289 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9290 than invoke a runtime library call or inline a switch statement.  This is
9291 standard compliant, safe, and the simplest approach for now.
9293 The memory order parameter is a signed int, but only the lower 16 bits are
9294 reserved for the memory order.  The remainder of the signed int is reserved
9295 for target use and should be 0.  Use of the predefined atomic values
9296 ensures proper usage.
9298 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9299 This built-in function implements an atomic load operation.  It returns the
9300 contents of @code{*@var{ptr}}.
9302 The valid memory order variants are
9303 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9304 and @code{__ATOMIC_CONSUME}.
9306 @end deftypefn
9308 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9309 This is the generic version of an atomic load.  It returns the
9310 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9312 @end deftypefn
9314 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9315 This built-in function implements an atomic store operation.  It writes 
9316 @code{@var{val}} into @code{*@var{ptr}}.  
9318 The valid memory order variants are
9319 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9321 @end deftypefn
9323 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9324 This is the generic version of an atomic store.  It stores the value
9325 of @code{*@var{val}} into @code{*@var{ptr}}.
9327 @end deftypefn
9329 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9330 This built-in function implements an atomic exchange operation.  It writes
9331 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9332 @code{*@var{ptr}}.
9334 The valid memory order variants are
9335 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9336 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9338 @end deftypefn
9340 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9341 This is the generic version of an atomic exchange.  It stores the
9342 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9343 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9345 @end deftypefn
9347 @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)
9348 This built-in function implements an atomic compare and exchange operation.
9349 This compares the contents of @code{*@var{ptr}} with the contents of
9350 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9351 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
9352 equal, the operation is a @emph{read} and the current contents of
9353 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
9354 for weak compare_exchange, and false for the strong variation.  Many targets 
9355 only offer the strong variation and ignore the parameter.  When in doubt, use
9356 the strong variation.
9358 True is returned if @var{desired} is written into
9359 @code{*@var{ptr}} and the operation is considered to conform to the
9360 memory order specified by @var{success_memorder}.  There are no
9361 restrictions on what memory order can be used here.
9363 False is returned otherwise, and the operation is considered to conform
9364 to @var{failure_memorder}. This memory order cannot be
9365 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
9366 stronger order than that specified by @var{success_memorder}.
9368 @end deftypefn
9370 @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)
9371 This built-in function implements the generic version of
9372 @code{__atomic_compare_exchange}.  The function is virtually identical to
9373 @code{__atomic_compare_exchange_n}, except the desired value is also a
9374 pointer.
9376 @end deftypefn
9378 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9379 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9380 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9381 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9382 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9383 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9384 These built-in functions perform the operation suggested by the name, and
9385 return the result of the operation. That is,
9387 @smallexample
9388 @{ *ptr @var{op}= val; return *ptr; @}
9389 @end smallexample
9391 All memory orders are valid.
9393 @end deftypefn
9395 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9396 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9397 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9398 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9399 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9400 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9401 These built-in functions perform the operation suggested by the name, and
9402 return the value that had previously been in @code{*@var{ptr}}.  That is,
9404 @smallexample
9405 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9406 @end smallexample
9408 All memory orders are valid.
9410 @end deftypefn
9412 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9414 This built-in function performs an atomic test-and-set operation on
9415 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9416 defined nonzero ``set'' value and the return value is @code{true} if and only
9417 if the previous contents were ``set''.
9418 It should be only used for operands of type @code{bool} or @code{char}. For 
9419 other types only part of the value may be set.
9421 All memory orders are valid.
9423 @end deftypefn
9425 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9427 This built-in function performs an atomic clear operation on
9428 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9429 It should be only used for operands of type @code{bool} or @code{char} and 
9430 in conjunction with @code{__atomic_test_and_set}.
9431 For other types it may only clear partially. If the type is not @code{bool}
9432 prefer using @code{__atomic_store}.
9434 The valid memory order variants are
9435 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9436 @code{__ATOMIC_RELEASE}.
9438 @end deftypefn
9440 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9442 This built-in function acts as a synchronization fence between threads
9443 based on the specified memory order.
9445 All memory orders are valid.
9447 @end deftypefn
9449 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9451 This built-in function acts as a synchronization fence between a thread
9452 and signal handlers based in the same thread.
9454 All memory orders are valid.
9456 @end deftypefn
9458 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
9460 This built-in function returns true if objects of @var{size} bytes always
9461 generate lock-free atomic instructions for the target architecture.
9462 @var{size} must resolve to a compile-time constant and the result also
9463 resolves to a compile-time constant.
9465 @var{ptr} is an optional pointer to the object that may be used to determine
9466 alignment.  A value of 0 indicates typical alignment should be used.  The 
9467 compiler may also ignore this parameter.
9469 @smallexample
9470 if (_atomic_always_lock_free (sizeof (long long), 0))
9471 @end smallexample
9473 @end deftypefn
9475 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9477 This built-in function returns true if objects of @var{size} bytes always
9478 generate lock-free atomic instructions for the target architecture.  If
9479 the built-in function is not known to be lock-free, a call is made to a
9480 runtime routine named @code{__atomic_is_lock_free}.
9482 @var{ptr} is an optional pointer to the object that may be used to determine
9483 alignment.  A value of 0 indicates typical alignment should be used.  The 
9484 compiler may also ignore this parameter.
9485 @end deftypefn
9487 @node Integer Overflow Builtins
9488 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9490 The following built-in functions allow performing simple arithmetic operations
9491 together with checking whether the operations overflowed.
9493 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9494 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9495 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9496 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9497 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9498 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9499 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9501 These built-in functions promote the first two operands into infinite precision signed
9502 type and perform addition on those promoted operands.  The result is then
9503 cast to the type the third pointer argument points to and stored there.
9504 If the stored result is equal to the infinite precision result, the built-in
9505 functions return false, otherwise they return true.  As the addition is
9506 performed in infinite signed precision, these built-in functions have fully defined
9507 behavior for all argument values.
9509 The first built-in function allows arbitrary integral types for operands and
9510 the result type must be pointer to some integer type, the rest of the built-in
9511 functions have explicit integer types.
9513 The compiler will attempt to use hardware instructions to implement
9514 these built-in functions where possible, like conditional jump on overflow
9515 after addition, conditional jump on carry etc.
9517 @end deftypefn
9519 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9520 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9521 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9522 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9523 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9524 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9525 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9527 These built-in functions are similar to the add overflow checking built-in
9528 functions above, except they perform subtraction, subtract the second argument
9529 from the first one, instead of addition.
9531 @end deftypefn
9533 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9534 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9535 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9536 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9537 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9538 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9539 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9541 These built-in functions are similar to the add overflow checking built-in
9542 functions above, except they perform multiplication, instead of addition.
9544 @end deftypefn
9546 @node x86 specific memory model extensions for transactional memory
9547 @section x86-Specific Memory Model Extensions for Transactional Memory
9549 The x86 architecture supports additional memory ordering flags
9550 to mark lock critical sections for hardware lock elision. 
9551 These must be specified in addition to an existing memory order to
9552 atomic intrinsics.
9554 @table @code
9555 @item __ATOMIC_HLE_ACQUIRE
9556 Start lock elision on a lock variable.
9557 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9558 @item __ATOMIC_HLE_RELEASE
9559 End lock elision on a lock variable.
9560 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9561 @end table
9563 When a lock acquire fails, it is required for good performance to abort
9564 the transaction quickly. This can be done with a @code{_mm_pause}.
9566 @smallexample
9567 #include <immintrin.h> // For _mm_pause
9569 int lockvar;
9571 /* Acquire lock with lock elision */
9572 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9573     _mm_pause(); /* Abort failed transaction */
9575 /* Free lock with lock elision */
9576 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9577 @end smallexample
9579 @node Object Size Checking
9580 @section Object Size Checking Built-in Functions
9581 @findex __builtin_object_size
9582 @findex __builtin___memcpy_chk
9583 @findex __builtin___mempcpy_chk
9584 @findex __builtin___memmove_chk
9585 @findex __builtin___memset_chk
9586 @findex __builtin___strcpy_chk
9587 @findex __builtin___stpcpy_chk
9588 @findex __builtin___strncpy_chk
9589 @findex __builtin___strcat_chk
9590 @findex __builtin___strncat_chk
9591 @findex __builtin___sprintf_chk
9592 @findex __builtin___snprintf_chk
9593 @findex __builtin___vsprintf_chk
9594 @findex __builtin___vsnprintf_chk
9595 @findex __builtin___printf_chk
9596 @findex __builtin___vprintf_chk
9597 @findex __builtin___fprintf_chk
9598 @findex __builtin___vfprintf_chk
9600 GCC implements a limited buffer overflow protection mechanism
9601 that can prevent some buffer overflow attacks.
9603 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9604 is a built-in construct that returns a constant number of bytes from
9605 @var{ptr} to the end of the object @var{ptr} pointer points to
9606 (if known at compile time).  @code{__builtin_object_size} never evaluates
9607 its arguments for side-effects.  If there are any side-effects in them, it
9608 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9609 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
9610 point to and all of them are known at compile time, the returned number
9611 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9612 0 and minimum if nonzero.  If it is not possible to determine which objects
9613 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9614 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9615 for @var{type} 2 or 3.
9617 @var{type} is an integer constant from 0 to 3.  If the least significant
9618 bit is clear, objects are whole variables, if it is set, a closest
9619 surrounding subobject is considered the object a pointer points to.
9620 The second bit determines if maximum or minimum of remaining bytes
9621 is computed.
9623 @smallexample
9624 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9625 char *p = &var.buf1[1], *q = &var.b;
9627 /* Here the object p points to is var.  */
9628 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9629 /* The subobject p points to is var.buf1.  */
9630 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9631 /* The object q points to is var.  */
9632 assert (__builtin_object_size (q, 0)
9633         == (char *) (&var + 1) - (char *) &var.b);
9634 /* The subobject q points to is var.b.  */
9635 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9636 @end smallexample
9637 @end deftypefn
9639 There are built-in functions added for many common string operation
9640 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9641 built-in is provided.  This built-in has an additional last argument,
9642 which is the number of bytes remaining in object the @var{dest}
9643 argument points to or @code{(size_t) -1} if the size is not known.
9645 The built-in functions are optimized into the normal string functions
9646 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9647 it is known at compile time that the destination object will not
9648 be overflown.  If the compiler can determine at compile time the
9649 object will be always overflown, it issues a warning.
9651 The intended use can be e.g.@:
9653 @smallexample
9654 #undef memcpy
9655 #define bos0(dest) __builtin_object_size (dest, 0)
9656 #define memcpy(dest, src, n) \
9657   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9659 char *volatile p;
9660 char buf[10];
9661 /* It is unknown what object p points to, so this is optimized
9662    into plain memcpy - no checking is possible.  */
9663 memcpy (p, "abcde", n);
9664 /* Destination is known and length too.  It is known at compile
9665    time there will be no overflow.  */
9666 memcpy (&buf[5], "abcde", 5);
9667 /* Destination is known, but the length is not known at compile time.
9668    This will result in __memcpy_chk call that can check for overflow
9669    at run time.  */
9670 memcpy (&buf[5], "abcde", n);
9671 /* Destination is known and it is known at compile time there will
9672    be overflow.  There will be a warning and __memcpy_chk call that
9673    will abort the program at run time.  */
9674 memcpy (&buf[6], "abcde", 5);
9675 @end smallexample
9677 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9678 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9679 @code{strcat} and @code{strncat}.
9681 There are also checking built-in functions for formatted output functions.
9682 @smallexample
9683 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9684 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9685                               const char *fmt, ...);
9686 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9687                               va_list ap);
9688 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9689                                const char *fmt, va_list ap);
9690 @end smallexample
9692 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9693 etc.@: functions and can contain implementation specific flags on what
9694 additional security measures the checking function might take, such as
9695 handling @code{%n} differently.
9697 The @var{os} argument is the object size @var{s} points to, like in the
9698 other built-in functions.  There is a small difference in the behavior
9699 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9700 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9701 the checking function is called with @var{os} argument set to
9702 @code{(size_t) -1}.
9704 In addition to this, there are checking built-in functions
9705 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9706 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9707 These have just one additional argument, @var{flag}, right before
9708 format string @var{fmt}.  If the compiler is able to optimize them to
9709 @code{fputc} etc.@: functions, it does, otherwise the checking function
9710 is called and the @var{flag} argument passed to it.
9712 @node Pointer Bounds Checker builtins
9713 @section Pointer Bounds Checker Built-in Functions
9714 @cindex Pointer Bounds Checker builtins
9715 @findex __builtin___bnd_set_ptr_bounds
9716 @findex __builtin___bnd_narrow_ptr_bounds
9717 @findex __builtin___bnd_copy_ptr_bounds
9718 @findex __builtin___bnd_init_ptr_bounds
9719 @findex __builtin___bnd_null_ptr_bounds
9720 @findex __builtin___bnd_store_ptr_bounds
9721 @findex __builtin___bnd_chk_ptr_lbounds
9722 @findex __builtin___bnd_chk_ptr_ubounds
9723 @findex __builtin___bnd_chk_ptr_bounds
9724 @findex __builtin___bnd_get_ptr_lbound
9725 @findex __builtin___bnd_get_ptr_ubound
9727 GCC provides a set of built-in functions to control Pointer Bounds Checker
9728 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
9729 even if you compile with Pointer Bounds Checker off
9730 (@option{-fno-check-pointer-bounds}).
9731 The behavior may differ in such case as documented below.
9733 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9735 This built-in function returns a new pointer with the value of @var{q}, and
9736 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
9737 Bounds Checker off, the built-in function just returns the first argument.
9739 @smallexample
9740 extern void *__wrap_malloc (size_t n)
9742   void *p = (void *)__real_malloc (n);
9743   if (!p) return __builtin___bnd_null_ptr_bounds (p);
9744   return __builtin___bnd_set_ptr_bounds (p, n);
9746 @end smallexample
9748 @end deftypefn
9750 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
9752 This built-in function returns a new pointer with the value of @var{p}
9753 and associates it with the narrowed bounds formed by the intersection
9754 of bounds associated with @var{q} and the bounds
9755 [@var{p}, @var{p} + @var{size} - 1].
9756 With Pointer Bounds Checker off, the built-in function just returns the first
9757 argument.
9759 @smallexample
9760 void init_objects (object *objs, size_t size)
9762   size_t i;
9763   /* Initialize objects one-by-one passing pointers with bounds of 
9764      an object, not the full array of objects.  */
9765   for (i = 0; i < size; i++)
9766     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9767                                                     sizeof(object)));
9769 @end smallexample
9771 @end deftypefn
9773 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9775 This built-in function returns a new pointer with the value of @var{q},
9776 and associates it with the bounds already associated with pointer @var{r}.
9777 With Pointer Bounds Checker off, the built-in function just returns the first
9778 argument.
9780 @smallexample
9781 /* Here is a way to get pointer to object's field but
9782    still with the full object's bounds.  */
9783 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
9784                                                   objptr);
9785 @end smallexample
9787 @end deftypefn
9789 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
9791 This built-in function returns a new pointer with the value of @var{q}, and
9792 associates it with INIT (allowing full memory access) bounds. With Pointer
9793 Bounds Checker off, the built-in function just returns the first argument.
9795 @end deftypefn
9797 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
9799 This built-in function returns a new pointer with the value of @var{q}, and
9800 associates it with NULL (allowing no memory access) bounds. With Pointer
9801 Bounds Checker off, the built-in function just returns the first argument.
9803 @end deftypefn
9805 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
9807 This built-in function stores the bounds associated with pointer @var{ptr_val}
9808 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
9809 bounds from legacy code without touching the associated pointer's memory when
9810 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
9811 function call is ignored.
9813 @end deftypefn
9815 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
9817 This built-in function checks if the pointer @var{q} is within the lower
9818 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9819 function call is ignored.
9821 @smallexample
9822 extern void *__wrap_memset (void *dst, int c, size_t len)
9824   if (len > 0)
9825     @{
9826       __builtin___bnd_chk_ptr_lbounds (dst);
9827       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
9828       __real_memset (dst, c, len);
9829     @}
9830   return dst;
9832 @end smallexample
9834 @end deftypefn
9836 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
9838 This built-in function checks if the pointer @var{q} is within the upper
9839 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
9840 function call is ignored.
9842 @end deftypefn
9844 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
9846 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
9847 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
9848 off, the built-in function call is ignored.
9850 @smallexample
9851 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
9853   if (n > 0)
9854     @{
9855       __bnd_chk_ptr_bounds (dst, n);
9856       __bnd_chk_ptr_bounds (src, n);
9857       __real_memcpy (dst, src, n);
9858     @}
9859   return dst;
9861 @end smallexample
9863 @end deftypefn
9865 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
9867 This built-in function returns the lower bound associated
9868 with the pointer @var{q}, as a pointer value.  
9869 This is useful for debugging using @code{printf}.
9870 With Pointer Bounds Checker off, the built-in function returns 0.
9872 @smallexample
9873 void *lb = __builtin___bnd_get_ptr_lbound (q);
9874 void *ub = __builtin___bnd_get_ptr_ubound (q);
9875 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
9876 @end smallexample
9878 @end deftypefn
9880 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
9882 This built-in function returns the upper bound (which is a pointer) associated
9883 with the pointer @var{q}.  With Pointer Bounds Checker off,
9884 the built-in function returns -1.
9886 @end deftypefn
9888 @node Cilk Plus Builtins
9889 @section Cilk Plus C/C++ Language Extension Built-in Functions
9891 GCC provides support for the following built-in reduction functions if Cilk Plus
9892 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9894 @itemize @bullet
9895 @item @code{__sec_implicit_index}
9896 @item @code{__sec_reduce}
9897 @item @code{__sec_reduce_add}
9898 @item @code{__sec_reduce_all_nonzero}
9899 @item @code{__sec_reduce_all_zero}
9900 @item @code{__sec_reduce_any_nonzero}
9901 @item @code{__sec_reduce_any_zero}
9902 @item @code{__sec_reduce_max}
9903 @item @code{__sec_reduce_min}
9904 @item @code{__sec_reduce_max_ind}
9905 @item @code{__sec_reduce_min_ind}
9906 @item @code{__sec_reduce_mul}
9907 @item @code{__sec_reduce_mutating}
9908 @end itemize
9910 Further details and examples about these built-in functions are described 
9911 in the Cilk Plus language manual which can be found at 
9912 @uref{http://www.cilkplus.org}.
9914 @node Other Builtins
9915 @section Other Built-in Functions Provided by GCC
9916 @cindex built-in functions
9917 @findex __builtin_call_with_static_chain
9918 @findex __builtin_fpclassify
9919 @findex __builtin_isfinite
9920 @findex __builtin_isnormal
9921 @findex __builtin_isgreater
9922 @findex __builtin_isgreaterequal
9923 @findex __builtin_isinf_sign
9924 @findex __builtin_isless
9925 @findex __builtin_islessequal
9926 @findex __builtin_islessgreater
9927 @findex __builtin_isunordered
9928 @findex __builtin_powi
9929 @findex __builtin_powif
9930 @findex __builtin_powil
9931 @findex _Exit
9932 @findex _exit
9933 @findex abort
9934 @findex abs
9935 @findex acos
9936 @findex acosf
9937 @findex acosh
9938 @findex acoshf
9939 @findex acoshl
9940 @findex acosl
9941 @findex alloca
9942 @findex asin
9943 @findex asinf
9944 @findex asinh
9945 @findex asinhf
9946 @findex asinhl
9947 @findex asinl
9948 @findex atan
9949 @findex atan2
9950 @findex atan2f
9951 @findex atan2l
9952 @findex atanf
9953 @findex atanh
9954 @findex atanhf
9955 @findex atanhl
9956 @findex atanl
9957 @findex bcmp
9958 @findex bzero
9959 @findex cabs
9960 @findex cabsf
9961 @findex cabsl
9962 @findex cacos
9963 @findex cacosf
9964 @findex cacosh
9965 @findex cacoshf
9966 @findex cacoshl
9967 @findex cacosl
9968 @findex calloc
9969 @findex carg
9970 @findex cargf
9971 @findex cargl
9972 @findex casin
9973 @findex casinf
9974 @findex casinh
9975 @findex casinhf
9976 @findex casinhl
9977 @findex casinl
9978 @findex catan
9979 @findex catanf
9980 @findex catanh
9981 @findex catanhf
9982 @findex catanhl
9983 @findex catanl
9984 @findex cbrt
9985 @findex cbrtf
9986 @findex cbrtl
9987 @findex ccos
9988 @findex ccosf
9989 @findex ccosh
9990 @findex ccoshf
9991 @findex ccoshl
9992 @findex ccosl
9993 @findex ceil
9994 @findex ceilf
9995 @findex ceill
9996 @findex cexp
9997 @findex cexpf
9998 @findex cexpl
9999 @findex cimag
10000 @findex cimagf
10001 @findex cimagl
10002 @findex clog
10003 @findex clogf
10004 @findex clogl
10005 @findex conj
10006 @findex conjf
10007 @findex conjl
10008 @findex copysign
10009 @findex copysignf
10010 @findex copysignl
10011 @findex cos
10012 @findex cosf
10013 @findex cosh
10014 @findex coshf
10015 @findex coshl
10016 @findex cosl
10017 @findex cpow
10018 @findex cpowf
10019 @findex cpowl
10020 @findex cproj
10021 @findex cprojf
10022 @findex cprojl
10023 @findex creal
10024 @findex crealf
10025 @findex creall
10026 @findex csin
10027 @findex csinf
10028 @findex csinh
10029 @findex csinhf
10030 @findex csinhl
10031 @findex csinl
10032 @findex csqrt
10033 @findex csqrtf
10034 @findex csqrtl
10035 @findex ctan
10036 @findex ctanf
10037 @findex ctanh
10038 @findex ctanhf
10039 @findex ctanhl
10040 @findex ctanl
10041 @findex dcgettext
10042 @findex dgettext
10043 @findex drem
10044 @findex dremf
10045 @findex dreml
10046 @findex erf
10047 @findex erfc
10048 @findex erfcf
10049 @findex erfcl
10050 @findex erff
10051 @findex erfl
10052 @findex exit
10053 @findex exp
10054 @findex exp10
10055 @findex exp10f
10056 @findex exp10l
10057 @findex exp2
10058 @findex exp2f
10059 @findex exp2l
10060 @findex expf
10061 @findex expl
10062 @findex expm1
10063 @findex expm1f
10064 @findex expm1l
10065 @findex fabs
10066 @findex fabsf
10067 @findex fabsl
10068 @findex fdim
10069 @findex fdimf
10070 @findex fdiml
10071 @findex ffs
10072 @findex floor
10073 @findex floorf
10074 @findex floorl
10075 @findex fma
10076 @findex fmaf
10077 @findex fmal
10078 @findex fmax
10079 @findex fmaxf
10080 @findex fmaxl
10081 @findex fmin
10082 @findex fminf
10083 @findex fminl
10084 @findex fmod
10085 @findex fmodf
10086 @findex fmodl
10087 @findex fprintf
10088 @findex fprintf_unlocked
10089 @findex fputs
10090 @findex fputs_unlocked
10091 @findex frexp
10092 @findex frexpf
10093 @findex frexpl
10094 @findex fscanf
10095 @findex gamma
10096 @findex gammaf
10097 @findex gammal
10098 @findex gamma_r
10099 @findex gammaf_r
10100 @findex gammal_r
10101 @findex gettext
10102 @findex hypot
10103 @findex hypotf
10104 @findex hypotl
10105 @findex ilogb
10106 @findex ilogbf
10107 @findex ilogbl
10108 @findex imaxabs
10109 @findex index
10110 @findex isalnum
10111 @findex isalpha
10112 @findex isascii
10113 @findex isblank
10114 @findex iscntrl
10115 @findex isdigit
10116 @findex isgraph
10117 @findex islower
10118 @findex isprint
10119 @findex ispunct
10120 @findex isspace
10121 @findex isupper
10122 @findex iswalnum
10123 @findex iswalpha
10124 @findex iswblank
10125 @findex iswcntrl
10126 @findex iswdigit
10127 @findex iswgraph
10128 @findex iswlower
10129 @findex iswprint
10130 @findex iswpunct
10131 @findex iswspace
10132 @findex iswupper
10133 @findex iswxdigit
10134 @findex isxdigit
10135 @findex j0
10136 @findex j0f
10137 @findex j0l
10138 @findex j1
10139 @findex j1f
10140 @findex j1l
10141 @findex jn
10142 @findex jnf
10143 @findex jnl
10144 @findex labs
10145 @findex ldexp
10146 @findex ldexpf
10147 @findex ldexpl
10148 @findex lgamma
10149 @findex lgammaf
10150 @findex lgammal
10151 @findex lgamma_r
10152 @findex lgammaf_r
10153 @findex lgammal_r
10154 @findex llabs
10155 @findex llrint
10156 @findex llrintf
10157 @findex llrintl
10158 @findex llround
10159 @findex llroundf
10160 @findex llroundl
10161 @findex log
10162 @findex log10
10163 @findex log10f
10164 @findex log10l
10165 @findex log1p
10166 @findex log1pf
10167 @findex log1pl
10168 @findex log2
10169 @findex log2f
10170 @findex log2l
10171 @findex logb
10172 @findex logbf
10173 @findex logbl
10174 @findex logf
10175 @findex logl
10176 @findex lrint
10177 @findex lrintf
10178 @findex lrintl
10179 @findex lround
10180 @findex lroundf
10181 @findex lroundl
10182 @findex malloc
10183 @findex memchr
10184 @findex memcmp
10185 @findex memcpy
10186 @findex mempcpy
10187 @findex memset
10188 @findex modf
10189 @findex modff
10190 @findex modfl
10191 @findex nearbyint
10192 @findex nearbyintf
10193 @findex nearbyintl
10194 @findex nextafter
10195 @findex nextafterf
10196 @findex nextafterl
10197 @findex nexttoward
10198 @findex nexttowardf
10199 @findex nexttowardl
10200 @findex pow
10201 @findex pow10
10202 @findex pow10f
10203 @findex pow10l
10204 @findex powf
10205 @findex powl
10206 @findex printf
10207 @findex printf_unlocked
10208 @findex putchar
10209 @findex puts
10210 @findex remainder
10211 @findex remainderf
10212 @findex remainderl
10213 @findex remquo
10214 @findex remquof
10215 @findex remquol
10216 @findex rindex
10217 @findex rint
10218 @findex rintf
10219 @findex rintl
10220 @findex round
10221 @findex roundf
10222 @findex roundl
10223 @findex scalb
10224 @findex scalbf
10225 @findex scalbl
10226 @findex scalbln
10227 @findex scalblnf
10228 @findex scalblnf
10229 @findex scalbn
10230 @findex scalbnf
10231 @findex scanfnl
10232 @findex signbit
10233 @findex signbitf
10234 @findex signbitl
10235 @findex signbitd32
10236 @findex signbitd64
10237 @findex signbitd128
10238 @findex significand
10239 @findex significandf
10240 @findex significandl
10241 @findex sin
10242 @findex sincos
10243 @findex sincosf
10244 @findex sincosl
10245 @findex sinf
10246 @findex sinh
10247 @findex sinhf
10248 @findex sinhl
10249 @findex sinl
10250 @findex snprintf
10251 @findex sprintf
10252 @findex sqrt
10253 @findex sqrtf
10254 @findex sqrtl
10255 @findex sscanf
10256 @findex stpcpy
10257 @findex stpncpy
10258 @findex strcasecmp
10259 @findex strcat
10260 @findex strchr
10261 @findex strcmp
10262 @findex strcpy
10263 @findex strcspn
10264 @findex strdup
10265 @findex strfmon
10266 @findex strftime
10267 @findex strlen
10268 @findex strncasecmp
10269 @findex strncat
10270 @findex strncmp
10271 @findex strncpy
10272 @findex strndup
10273 @findex strpbrk
10274 @findex strrchr
10275 @findex strspn
10276 @findex strstr
10277 @findex tan
10278 @findex tanf
10279 @findex tanh
10280 @findex tanhf
10281 @findex tanhl
10282 @findex tanl
10283 @findex tgamma
10284 @findex tgammaf
10285 @findex tgammal
10286 @findex toascii
10287 @findex tolower
10288 @findex toupper
10289 @findex towlower
10290 @findex towupper
10291 @findex trunc
10292 @findex truncf
10293 @findex truncl
10294 @findex vfprintf
10295 @findex vfscanf
10296 @findex vprintf
10297 @findex vscanf
10298 @findex vsnprintf
10299 @findex vsprintf
10300 @findex vsscanf
10301 @findex y0
10302 @findex y0f
10303 @findex y0l
10304 @findex y1
10305 @findex y1f
10306 @findex y1l
10307 @findex yn
10308 @findex ynf
10309 @findex ynl
10311 GCC provides a large number of built-in functions other than the ones
10312 mentioned above.  Some of these are for internal use in the processing
10313 of exceptions or variable-length argument lists and are not
10314 documented here because they may change from time to time; we do not
10315 recommend general use of these functions.
10317 The remaining functions are provided for optimization purposes.
10319 @opindex fno-builtin
10320 GCC includes built-in versions of many of the functions in the standard
10321 C library.  The versions prefixed with @code{__builtin_} are always
10322 treated as having the same meaning as the C library function even if you
10323 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
10324 Many of these functions are only optimized in certain cases; if they are
10325 not optimized in a particular case, a call to the library function is
10326 emitted.
10328 @opindex ansi
10329 @opindex std
10330 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10331 @option{-std=c99} or @option{-std=c11}), the functions
10332 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10333 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10334 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10335 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10336 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10337 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10338 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10339 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10340 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10341 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10342 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10343 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10344 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10345 @code{significandl}, @code{significand}, @code{sincosf},
10346 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10347 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10348 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10349 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10350 @code{yn}
10351 may be handled as built-in functions.
10352 All these functions have corresponding versions
10353 prefixed with @code{__builtin_}, which may be used even in strict C90
10354 mode.
10356 The ISO C99 functions
10357 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10358 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10359 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10360 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10361 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10362 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10363 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10364 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10365 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10366 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10367 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10368 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10369 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10370 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10371 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10372 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10373 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10374 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10375 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10376 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10377 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10378 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10379 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10380 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10381 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10382 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10383 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10384 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10385 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10386 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10387 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10388 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10389 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10390 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10391 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10392 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10393 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10394 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10395 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10396 are handled as built-in functions
10397 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10399 There are also built-in versions of the ISO C99 functions
10400 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10401 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10402 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10403 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10404 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10405 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10406 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10407 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10408 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10409 that are recognized in any mode since ISO C90 reserves these names for
10410 the purpose to which ISO C99 puts them.  All these functions have
10411 corresponding versions prefixed with @code{__builtin_}.
10413 The ISO C94 functions
10414 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10415 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10416 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10417 @code{towupper}
10418 are handled as built-in functions
10419 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10421 The ISO C90 functions
10422 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10423 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10424 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10425 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10426 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10427 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10428 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10429 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10430 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10431 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10432 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10433 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10434 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10435 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10436 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10437 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10438 are all recognized as built-in functions unless
10439 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10440 is specified for an individual function).  All of these functions have
10441 corresponding versions prefixed with @code{__builtin_}.
10443 GCC provides built-in versions of the ISO C99 floating-point comparison
10444 macros that avoid raising exceptions for unordered operands.  They have
10445 the same names as the standard macros ( @code{isgreater},
10446 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10447 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10448 prefixed.  We intend for a library implementor to be able to simply
10449 @code{#define} each standard macro to its built-in equivalent.
10450 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10451 @code{isinf_sign} and @code{isnormal} built-ins used with
10452 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
10453 built-in functions appear both with and without the @code{__builtin_} prefix.
10455 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10457 You can use the built-in function @code{__builtin_types_compatible_p} to
10458 determine whether two types are the same.
10460 This built-in function returns 1 if the unqualified versions of the
10461 types @var{type1} and @var{type2} (which are types, not expressions) are
10462 compatible, 0 otherwise.  The result of this built-in function can be
10463 used in integer constant expressions.
10465 This built-in function ignores top level qualifiers (e.g., @code{const},
10466 @code{volatile}).  For example, @code{int} is equivalent to @code{const
10467 int}.
10469 The type @code{int[]} and @code{int[5]} are compatible.  On the other
10470 hand, @code{int} and @code{char *} are not compatible, even if the size
10471 of their types, on the particular architecture are the same.  Also, the
10472 amount of pointer indirection is taken into account when determining
10473 similarity.  Consequently, @code{short *} is not similar to
10474 @code{short **}.  Furthermore, two types that are typedefed are
10475 considered compatible if their underlying types are compatible.
10477 An @code{enum} type is not considered to be compatible with another
10478 @code{enum} type even if both are compatible with the same integer
10479 type; this is what the C standard specifies.
10480 For example, @code{enum @{foo, bar@}} is not similar to
10481 @code{enum @{hot, dog@}}.
10483 You typically use this function in code whose execution varies
10484 depending on the arguments' types.  For example:
10486 @smallexample
10487 #define foo(x)                                                  \
10488   (@{                                                           \
10489     typeof (x) tmp = (x);                                       \
10490     if (__builtin_types_compatible_p (typeof (x), long double)) \
10491       tmp = foo_long_double (tmp);                              \
10492     else if (__builtin_types_compatible_p (typeof (x), double)) \
10493       tmp = foo_double (tmp);                                   \
10494     else if (__builtin_types_compatible_p (typeof (x), float))  \
10495       tmp = foo_float (tmp);                                    \
10496     else                                                        \
10497       abort ();                                                 \
10498     tmp;                                                        \
10499   @})
10500 @end smallexample
10502 @emph{Note:} This construct is only available for C@.
10504 @end deftypefn
10506 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10508 The @var{call_exp} expression must be a function call, and the
10509 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
10510 is passed to the function call in the target's static chain location.
10511 The result of builtin is the result of the function call.
10513 @emph{Note:} This builtin is only available for C@.
10514 This builtin can be used to call Go closures from C.
10516 @end deftypefn
10518 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10520 You can use the built-in function @code{__builtin_choose_expr} to
10521 evaluate code depending on the value of a constant expression.  This
10522 built-in function returns @var{exp1} if @var{const_exp}, which is an
10523 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
10525 This built-in function is analogous to the @samp{? :} operator in C,
10526 except that the expression returned has its type unaltered by promotion
10527 rules.  Also, the built-in function does not evaluate the expression
10528 that is not chosen.  For example, if @var{const_exp} evaluates to true,
10529 @var{exp2} is not evaluated even if it has side-effects.
10531 This built-in function can return an lvalue if the chosen argument is an
10532 lvalue.
10534 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10535 type.  Similarly, if @var{exp2} is returned, its return type is the same
10536 as @var{exp2}.
10538 Example:
10540 @smallexample
10541 #define foo(x)                                                    \
10542   __builtin_choose_expr (                                         \
10543     __builtin_types_compatible_p (typeof (x), double),            \
10544     foo_double (x),                                               \
10545     __builtin_choose_expr (                                       \
10546       __builtin_types_compatible_p (typeof (x), float),           \
10547       foo_float (x),                                              \
10548       /* @r{The void expression results in a compile-time error}  \
10549          @r{when assigning the result to something.}  */          \
10550       (void)0))
10551 @end smallexample
10553 @emph{Note:} This construct is only available for C@.  Furthermore, the
10554 unused expression (@var{exp1} or @var{exp2} depending on the value of
10555 @var{const_exp}) may still generate syntax errors.  This may change in
10556 future revisions.
10558 @end deftypefn
10560 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10562 The built-in function @code{__builtin_complex} is provided for use in
10563 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10564 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
10565 real binary floating-point type, and the result has the corresponding
10566 complex type with real and imaginary parts @var{real} and @var{imag}.
10567 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10568 infinities, NaNs and negative zeros are involved.
10570 @end deftypefn
10572 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10573 You can use the built-in function @code{__builtin_constant_p} to
10574 determine if a value is known to be constant at compile time and hence
10575 that GCC can perform constant-folding on expressions involving that
10576 value.  The argument of the function is the value to test.  The function
10577 returns the integer 1 if the argument is known to be a compile-time
10578 constant and 0 if it is not known to be a compile-time constant.  A
10579 return of 0 does not indicate that the value is @emph{not} a constant,
10580 but merely that GCC cannot prove it is a constant with the specified
10581 value of the @option{-O} option.
10583 You typically use this function in an embedded application where
10584 memory is a critical resource.  If you have some complex calculation,
10585 you may want it to be folded if it involves constants, but need to call
10586 a function if it does not.  For example:
10588 @smallexample
10589 #define Scale_Value(X)      \
10590   (__builtin_constant_p (X) \
10591   ? ((X) * SCALE + OFFSET) : Scale (X))
10592 @end smallexample
10594 You may use this built-in function in either a macro or an inline
10595 function.  However, if you use it in an inlined function and pass an
10596 argument of the function as the argument to the built-in, GCC 
10597 never returns 1 when you call the inline function with a string constant
10598 or compound literal (@pxref{Compound Literals}) and does not return 1
10599 when you pass a constant numeric value to the inline function unless you
10600 specify the @option{-O} option.
10602 You may also use @code{__builtin_constant_p} in initializers for static
10603 data.  For instance, you can write
10605 @smallexample
10606 static const int table[] = @{
10607    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10608    /* @r{@dots{}} */
10610 @end smallexample
10612 @noindent
10613 This is an acceptable initializer even if @var{EXPRESSION} is not a
10614 constant expression, including the case where
10615 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10616 folded to a constant but @var{EXPRESSION} contains operands that are
10617 not otherwise permitted in a static initializer (for example,
10618 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
10619 built-in in this case, because it has no opportunity to perform
10620 optimization.
10621 @end deftypefn
10623 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10624 @opindex fprofile-arcs
10625 You may use @code{__builtin_expect} to provide the compiler with
10626 branch prediction information.  In general, you should prefer to
10627 use actual profile feedback for this (@option{-fprofile-arcs}), as
10628 programmers are notoriously bad at predicting how their programs
10629 actually perform.  However, there are applications in which this
10630 data is hard to collect.
10632 The return value is the value of @var{exp}, which should be an integral
10633 expression.  The semantics of the built-in are that it is expected that
10634 @var{exp} == @var{c}.  For example:
10636 @smallexample
10637 if (__builtin_expect (x, 0))
10638   foo ();
10639 @end smallexample
10641 @noindent
10642 indicates that we do not expect to call @code{foo}, since
10643 we expect @code{x} to be zero.  Since you are limited to integral
10644 expressions for @var{exp}, you should use constructions such as
10646 @smallexample
10647 if (__builtin_expect (ptr != NULL, 1))
10648   foo (*ptr);
10649 @end smallexample
10651 @noindent
10652 when testing pointer or floating-point values.
10653 @end deftypefn
10655 @deftypefn {Built-in Function} void __builtin_trap (void)
10656 This function causes the program to exit abnormally.  GCC implements
10657 this function by using a target-dependent mechanism (such as
10658 intentionally executing an illegal instruction) or by calling
10659 @code{abort}.  The mechanism used may vary from release to release so
10660 you should not rely on any particular implementation.
10661 @end deftypefn
10663 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10664 If control flow reaches the point of the @code{__builtin_unreachable},
10665 the program is undefined.  It is useful in situations where the
10666 compiler cannot deduce the unreachability of the code.
10668 One such case is immediately following an @code{asm} statement that
10669 either never terminates, or one that transfers control elsewhere
10670 and never returns.  In this example, without the
10671 @code{__builtin_unreachable}, GCC issues a warning that control
10672 reaches the end of a non-void function.  It also generates code
10673 to return after the @code{asm}.
10675 @smallexample
10676 int f (int c, int v)
10678   if (c)
10679     @{
10680       return v;
10681     @}
10682   else
10683     @{
10684       asm("jmp error_handler");
10685       __builtin_unreachable ();
10686     @}
10688 @end smallexample
10690 @noindent
10691 Because the @code{asm} statement unconditionally transfers control out
10692 of the function, control never reaches the end of the function
10693 body.  The @code{__builtin_unreachable} is in fact unreachable and
10694 communicates this fact to the compiler.
10696 Another use for @code{__builtin_unreachable} is following a call a
10697 function that never returns but that is not declared
10698 @code{__attribute__((noreturn))}, as in this example:
10700 @smallexample
10701 void function_that_never_returns (void);
10703 int g (int c)
10705   if (c)
10706     @{
10707       return 1;
10708     @}
10709   else
10710     @{
10711       function_that_never_returns ();
10712       __builtin_unreachable ();
10713     @}
10715 @end smallexample
10717 @end deftypefn
10719 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10720 This function returns its first argument, and allows the compiler
10721 to assume that the returned pointer is at least @var{align} bytes
10722 aligned.  This built-in can have either two or three arguments,
10723 if it has three, the third argument should have integer type, and
10724 if it is nonzero means misalignment offset.  For example:
10726 @smallexample
10727 void *x = __builtin_assume_aligned (arg, 16);
10728 @end smallexample
10730 @noindent
10731 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10732 16-byte aligned, while:
10734 @smallexample
10735 void *x = __builtin_assume_aligned (arg, 32, 8);
10736 @end smallexample
10738 @noindent
10739 means that the compiler can assume for @code{x}, set to @code{arg}, that
10740 @code{(char *) x - 8} is 32-byte aligned.
10741 @end deftypefn
10743 @deftypefn {Built-in Function} int __builtin_LINE ()
10744 This function is the equivalent to the preprocessor @code{__LINE__}
10745 macro and returns the line number of the invocation of the built-in.
10746 In a C++ default argument for a function @var{F}, it gets the line number of
10747 the call to @var{F}.
10748 @end deftypefn
10750 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10751 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10752 macro and returns the function name the invocation of the built-in is in.
10753 @end deftypefn
10755 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10756 This function is the equivalent to the preprocessor @code{__FILE__}
10757 macro and returns the file name the invocation of the built-in is in.
10758 In a C++ default argument for a function @var{F}, it gets the file name of
10759 the call to @var{F}.
10760 @end deftypefn
10762 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10763 This function is used to flush the processor's instruction cache for
10764 the region of memory between @var{begin} inclusive and @var{end}
10765 exclusive.  Some targets require that the instruction cache be
10766 flushed, after modifying memory containing code, in order to obtain
10767 deterministic behavior.
10769 If the target does not require instruction cache flushes,
10770 @code{__builtin___clear_cache} has no effect.  Otherwise either
10771 instructions are emitted in-line to clear the instruction cache or a
10772 call to the @code{__clear_cache} function in libgcc is made.
10773 @end deftypefn
10775 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10776 This function is used to minimize cache-miss latency by moving data into
10777 a cache before it is accessed.
10778 You can insert calls to @code{__builtin_prefetch} into code for which
10779 you know addresses of data in memory that is likely to be accessed soon.
10780 If the target supports them, data prefetch instructions are generated.
10781 If the prefetch is done early enough before the access then the data will
10782 be in the cache by the time it is accessed.
10784 The value of @var{addr} is the address of the memory to prefetch.
10785 There are two optional arguments, @var{rw} and @var{locality}.
10786 The value of @var{rw} is a compile-time constant one or zero; one
10787 means that the prefetch is preparing for a write to the memory address
10788 and zero, the default, means that the prefetch is preparing for a read.
10789 The value @var{locality} must be a compile-time constant integer between
10790 zero and three.  A value of zero means that the data has no temporal
10791 locality, so it need not be left in the cache after the access.  A value
10792 of three means that the data has a high degree of temporal locality and
10793 should be left in all levels of cache possible.  Values of one and two
10794 mean, respectively, a low or moderate degree of temporal locality.  The
10795 default is three.
10797 @smallexample
10798 for (i = 0; i < n; i++)
10799   @{
10800     a[i] = a[i] + b[i];
10801     __builtin_prefetch (&a[i+j], 1, 1);
10802     __builtin_prefetch (&b[i+j], 0, 1);
10803     /* @r{@dots{}} */
10804   @}
10805 @end smallexample
10807 Data prefetch does not generate faults if @var{addr} is invalid, but
10808 the address expression itself must be valid.  For example, a prefetch
10809 of @code{p->next} does not fault if @code{p->next} is not a valid
10810 address, but evaluation faults if @code{p} is not a valid address.
10812 If the target does not support data prefetch, the address expression
10813 is evaluated if it includes side effects but no other code is generated
10814 and GCC does not issue a warning.
10815 @end deftypefn
10817 @deftypefn {Built-in Function} double __builtin_huge_val (void)
10818 Returns a positive infinity, if supported by the floating-point format,
10819 else @code{DBL_MAX}.  This function is suitable for implementing the
10820 ISO C macro @code{HUGE_VAL}.
10821 @end deftypefn
10823 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
10824 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
10825 @end deftypefn
10827 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
10828 Similar to @code{__builtin_huge_val}, except the return
10829 type is @code{long double}.
10830 @end deftypefn
10832 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
10833 This built-in implements the C99 fpclassify functionality.  The first
10834 five int arguments should be the target library's notion of the
10835 possible FP classes and are used for return values.  They must be
10836 constant values and they must appear in this order: @code{FP_NAN},
10837 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
10838 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
10839 to classify.  GCC treats the last argument as type-generic, which
10840 means it does not do default promotion from float to double.
10841 @end deftypefn
10843 @deftypefn {Built-in Function} double __builtin_inf (void)
10844 Similar to @code{__builtin_huge_val}, except a warning is generated
10845 if the target floating-point format does not support infinities.
10846 @end deftypefn
10848 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
10849 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
10850 @end deftypefn
10852 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
10853 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
10854 @end deftypefn
10856 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
10857 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
10858 @end deftypefn
10860 @deftypefn {Built-in Function} float __builtin_inff (void)
10861 Similar to @code{__builtin_inf}, except the return type is @code{float}.
10862 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
10863 @end deftypefn
10865 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
10866 Similar to @code{__builtin_inf}, except the return
10867 type is @code{long double}.
10868 @end deftypefn
10870 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
10871 Similar to @code{isinf}, except the return value is -1 for
10872 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
10873 Note while the parameter list is an
10874 ellipsis, this function only accepts exactly one floating-point
10875 argument.  GCC treats this parameter as type-generic, which means it
10876 does not do default promotion from float to double.
10877 @end deftypefn
10879 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
10880 This is an implementation of the ISO C99 function @code{nan}.
10882 Since ISO C99 defines this function in terms of @code{strtod}, which we
10883 do not implement, a description of the parsing is in order.  The string
10884 is parsed as by @code{strtol}; that is, the base is recognized by
10885 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
10886 in the significand such that the least significant bit of the number
10887 is at the least significant bit of the significand.  The number is
10888 truncated to fit the significand field provided.  The significand is
10889 forced to be a quiet NaN@.
10891 This function, if given a string literal all of which would have been
10892 consumed by @code{strtol}, is evaluated early enough that it is considered a
10893 compile-time constant.
10894 @end deftypefn
10896 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
10897 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
10898 @end deftypefn
10900 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
10901 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
10902 @end deftypefn
10904 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
10905 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
10906 @end deftypefn
10908 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
10909 Similar to @code{__builtin_nan}, except the return type is @code{float}.
10910 @end deftypefn
10912 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
10913 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
10914 @end deftypefn
10916 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
10917 Similar to @code{__builtin_nan}, except the significand is forced
10918 to be a signaling NaN@.  The @code{nans} function is proposed by
10919 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
10920 @end deftypefn
10922 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
10923 Similar to @code{__builtin_nans}, except the return type is @code{float}.
10924 @end deftypefn
10926 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
10927 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
10928 @end deftypefn
10930 @deftypefn {Built-in Function} int __builtin_ffs (int x)
10931 Returns one plus the index of the least significant 1-bit of @var{x}, or
10932 if @var{x} is zero, returns zero.
10933 @end deftypefn
10935 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
10936 Returns the number of leading 0-bits in @var{x}, starting at the most
10937 significant bit position.  If @var{x} is 0, the result is undefined.
10938 @end deftypefn
10940 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
10941 Returns the number of trailing 0-bits in @var{x}, starting at the least
10942 significant bit position.  If @var{x} is 0, the result is undefined.
10943 @end deftypefn
10945 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
10946 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
10947 number of bits following the most significant bit that are identical
10948 to it.  There are no special cases for 0 or other values. 
10949 @end deftypefn
10951 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
10952 Returns the number of 1-bits in @var{x}.
10953 @end deftypefn
10955 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10956 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10957 modulo 2.
10958 @end deftypefn
10960 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10961 Similar to @code{__builtin_ffs}, except the argument type is
10962 @code{long}.
10963 @end deftypefn
10965 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10966 Similar to @code{__builtin_clz}, except the argument type is
10967 @code{unsigned long}.
10968 @end deftypefn
10970 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10971 Similar to @code{__builtin_ctz}, except the argument type is
10972 @code{unsigned long}.
10973 @end deftypefn
10975 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10976 Similar to @code{__builtin_clrsb}, except the argument type is
10977 @code{long}.
10978 @end deftypefn
10980 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10981 Similar to @code{__builtin_popcount}, except the argument type is
10982 @code{unsigned long}.
10983 @end deftypefn
10985 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10986 Similar to @code{__builtin_parity}, except the argument type is
10987 @code{unsigned long}.
10988 @end deftypefn
10990 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10991 Similar to @code{__builtin_ffs}, except the argument type is
10992 @code{long long}.
10993 @end deftypefn
10995 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10996 Similar to @code{__builtin_clz}, except the argument type is
10997 @code{unsigned long long}.
10998 @end deftypefn
11000 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11001 Similar to @code{__builtin_ctz}, except the argument type is
11002 @code{unsigned long long}.
11003 @end deftypefn
11005 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11006 Similar to @code{__builtin_clrsb}, except the argument type is
11007 @code{long long}.
11008 @end deftypefn
11010 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11011 Similar to @code{__builtin_popcount}, except the argument type is
11012 @code{unsigned long long}.
11013 @end deftypefn
11015 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11016 Similar to @code{__builtin_parity}, except the argument type is
11017 @code{unsigned long long}.
11018 @end deftypefn
11020 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11021 Returns the first argument raised to the power of the second.  Unlike the
11022 @code{pow} function no guarantees about precision and rounding are made.
11023 @end deftypefn
11025 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11026 Similar to @code{__builtin_powi}, except the argument and return types
11027 are @code{float}.
11028 @end deftypefn
11030 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11031 Similar to @code{__builtin_powi}, except the argument and return types
11032 are @code{long double}.
11033 @end deftypefn
11035 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11036 Returns @var{x} with the order of the bytes reversed; for example,
11037 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
11038 exactly 8 bits.
11039 @end deftypefn
11041 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11042 Similar to @code{__builtin_bswap16}, except the argument and return types
11043 are 32 bit.
11044 @end deftypefn
11046 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11047 Similar to @code{__builtin_bswap32}, except the argument and return types
11048 are 64 bit.
11049 @end deftypefn
11051 @node Target Builtins
11052 @section Built-in Functions Specific to Particular Target Machines
11054 On some target machines, GCC supports many built-in functions specific
11055 to those machines.  Generally these generate calls to specific machine
11056 instructions, but allow the compiler to schedule those calls.
11058 @menu
11059 * AArch64 Built-in Functions::
11060 * Alpha Built-in Functions::
11061 * Altera Nios II Built-in Functions::
11062 * ARC Built-in Functions::
11063 * ARC SIMD Built-in Functions::
11064 * ARM iWMMXt Built-in Functions::
11065 * ARM C Language Extensions (ACLE)::
11066 * ARM Floating Point Status and Control Intrinsics::
11067 * AVR Built-in Functions::
11068 * Blackfin Built-in Functions::
11069 * FR-V Built-in Functions::
11070 * MIPS DSP Built-in Functions::
11071 * MIPS Paired-Single Support::
11072 * MIPS Loongson Built-in Functions::
11073 * Other MIPS Built-in Functions::
11074 * MSP430 Built-in Functions::
11075 * NDS32 Built-in Functions::
11076 * picoChip Built-in Functions::
11077 * PowerPC Built-in Functions::
11078 * PowerPC AltiVec/VSX Built-in Functions::
11079 * PowerPC Hardware Transactional Memory Built-in Functions::
11080 * RX Built-in Functions::
11081 * S/390 System z Built-in Functions::
11082 * SH Built-in Functions::
11083 * SPARC VIS Built-in Functions::
11084 * SPU Built-in Functions::
11085 * TI C6X Built-in Functions::
11086 * TILE-Gx Built-in Functions::
11087 * TILEPro Built-in Functions::
11088 * x86 Built-in Functions::
11089 * x86 transactional memory intrinsics::
11090 @end menu
11092 @node AArch64 Built-in Functions
11093 @subsection AArch64 Built-in Functions
11095 These built-in functions are available for the AArch64 family of
11096 processors.
11097 @smallexample
11098 unsigned int __builtin_aarch64_get_fpcr ()
11099 void __builtin_aarch64_set_fpcr (unsigned int)
11100 unsigned int __builtin_aarch64_get_fpsr ()
11101 void __builtin_aarch64_set_fpsr (unsigned int)
11102 @end smallexample
11104 @node Alpha Built-in Functions
11105 @subsection Alpha Built-in Functions
11107 These built-in functions are available for the Alpha family of
11108 processors, depending on the command-line switches used.
11110 The following built-in functions are always available.  They
11111 all generate the machine instruction that is part of the name.
11113 @smallexample
11114 long __builtin_alpha_implver (void)
11115 long __builtin_alpha_rpcc (void)
11116 long __builtin_alpha_amask (long)
11117 long __builtin_alpha_cmpbge (long, long)
11118 long __builtin_alpha_extbl (long, long)
11119 long __builtin_alpha_extwl (long, long)
11120 long __builtin_alpha_extll (long, long)
11121 long __builtin_alpha_extql (long, long)
11122 long __builtin_alpha_extwh (long, long)
11123 long __builtin_alpha_extlh (long, long)
11124 long __builtin_alpha_extqh (long, long)
11125 long __builtin_alpha_insbl (long, long)
11126 long __builtin_alpha_inswl (long, long)
11127 long __builtin_alpha_insll (long, long)
11128 long __builtin_alpha_insql (long, long)
11129 long __builtin_alpha_inswh (long, long)
11130 long __builtin_alpha_inslh (long, long)
11131 long __builtin_alpha_insqh (long, long)
11132 long __builtin_alpha_mskbl (long, long)
11133 long __builtin_alpha_mskwl (long, long)
11134 long __builtin_alpha_mskll (long, long)
11135 long __builtin_alpha_mskql (long, long)
11136 long __builtin_alpha_mskwh (long, long)
11137 long __builtin_alpha_msklh (long, long)
11138 long __builtin_alpha_mskqh (long, long)
11139 long __builtin_alpha_umulh (long, long)
11140 long __builtin_alpha_zap (long, long)
11141 long __builtin_alpha_zapnot (long, long)
11142 @end smallexample
11144 The following built-in functions are always with @option{-mmax}
11145 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11146 later.  They all generate the machine instruction that is part
11147 of the name.
11149 @smallexample
11150 long __builtin_alpha_pklb (long)
11151 long __builtin_alpha_pkwb (long)
11152 long __builtin_alpha_unpkbl (long)
11153 long __builtin_alpha_unpkbw (long)
11154 long __builtin_alpha_minub8 (long, long)
11155 long __builtin_alpha_minsb8 (long, long)
11156 long __builtin_alpha_minuw4 (long, long)
11157 long __builtin_alpha_minsw4 (long, long)
11158 long __builtin_alpha_maxub8 (long, long)
11159 long __builtin_alpha_maxsb8 (long, long)
11160 long __builtin_alpha_maxuw4 (long, long)
11161 long __builtin_alpha_maxsw4 (long, long)
11162 long __builtin_alpha_perr (long, long)
11163 @end smallexample
11165 The following built-in functions are always with @option{-mcix}
11166 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11167 later.  They all generate the machine instruction that is part
11168 of the name.
11170 @smallexample
11171 long __builtin_alpha_cttz (long)
11172 long __builtin_alpha_ctlz (long)
11173 long __builtin_alpha_ctpop (long)
11174 @end smallexample
11176 The following built-in functions are available on systems that use the OSF/1
11177 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
11178 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11179 @code{rdval} and @code{wrval}.
11181 @smallexample
11182 void *__builtin_thread_pointer (void)
11183 void __builtin_set_thread_pointer (void *)
11184 @end smallexample
11186 @node Altera Nios II Built-in Functions
11187 @subsection Altera Nios II Built-in Functions
11189 These built-in functions are available for the Altera Nios II
11190 family of processors.
11192 The following built-in functions are always available.  They
11193 all generate the machine instruction that is part of the name.
11195 @example
11196 int __builtin_ldbio (volatile const void *)
11197 int __builtin_ldbuio (volatile const void *)
11198 int __builtin_ldhio (volatile const void *)
11199 int __builtin_ldhuio (volatile const void *)
11200 int __builtin_ldwio (volatile const void *)
11201 void __builtin_stbio (volatile void *, int)
11202 void __builtin_sthio (volatile void *, int)
11203 void __builtin_stwio (volatile void *, int)
11204 void __builtin_sync (void)
11205 int __builtin_rdctl (int) 
11206 int __builtin_rdprs (int, int)
11207 void __builtin_wrctl (int, int)
11208 void __builtin_flushd (volatile void *)
11209 void __builtin_flushda (volatile void *)
11210 int __builtin_wrpie (int);
11211 void __builtin_eni (int);
11212 int __builtin_ldex (volatile const void *)
11213 int __builtin_stex (volatile void *, int)
11214 int __builtin_ldsex (volatile const void *)
11215 int __builtin_stsex (volatile void *, int)
11216 @end example
11218 The following built-in functions are always available.  They
11219 all generate a Nios II Custom Instruction. The name of the
11220 function represents the types that the function takes and
11221 returns. The letter before the @code{n} is the return type
11222 or void if absent. The @code{n} represents the first parameter
11223 to all the custom instructions, the custom instruction number.
11224 The two letters after the @code{n} represent the up to two
11225 parameters to the function.
11227 The letters represent the following data types:
11228 @table @code
11229 @item <no letter>
11230 @code{void} for return type and no parameter for parameter types.
11232 @item i
11233 @code{int} for return type and parameter type
11235 @item f
11236 @code{float} for return type and parameter type
11238 @item p
11239 @code{void *} for return type and parameter type
11241 @end table
11243 And the function names are:
11244 @example
11245 void __builtin_custom_n (void)
11246 void __builtin_custom_ni (int)
11247 void __builtin_custom_nf (float)
11248 void __builtin_custom_np (void *)
11249 void __builtin_custom_nii (int, int)
11250 void __builtin_custom_nif (int, float)
11251 void __builtin_custom_nip (int, void *)
11252 void __builtin_custom_nfi (float, int)
11253 void __builtin_custom_nff (float, float)
11254 void __builtin_custom_nfp (float, void *)
11255 void __builtin_custom_npi (void *, int)
11256 void __builtin_custom_npf (void *, float)
11257 void __builtin_custom_npp (void *, void *)
11258 int __builtin_custom_in (void)
11259 int __builtin_custom_ini (int)
11260 int __builtin_custom_inf (float)
11261 int __builtin_custom_inp (void *)
11262 int __builtin_custom_inii (int, int)
11263 int __builtin_custom_inif (int, float)
11264 int __builtin_custom_inip (int, void *)
11265 int __builtin_custom_infi (float, int)
11266 int __builtin_custom_inff (float, float)
11267 int __builtin_custom_infp (float, void *)
11268 int __builtin_custom_inpi (void *, int)
11269 int __builtin_custom_inpf (void *, float)
11270 int __builtin_custom_inpp (void *, void *)
11271 float __builtin_custom_fn (void)
11272 float __builtin_custom_fni (int)
11273 float __builtin_custom_fnf (float)
11274 float __builtin_custom_fnp (void *)
11275 float __builtin_custom_fnii (int, int)
11276 float __builtin_custom_fnif (int, float)
11277 float __builtin_custom_fnip (int, void *)
11278 float __builtin_custom_fnfi (float, int)
11279 float __builtin_custom_fnff (float, float)
11280 float __builtin_custom_fnfp (float, void *)
11281 float __builtin_custom_fnpi (void *, int)
11282 float __builtin_custom_fnpf (void *, float)
11283 float __builtin_custom_fnpp (void *, void *)
11284 void * __builtin_custom_pn (void)
11285 void * __builtin_custom_pni (int)
11286 void * __builtin_custom_pnf (float)
11287 void * __builtin_custom_pnp (void *)
11288 void * __builtin_custom_pnii (int, int)
11289 void * __builtin_custom_pnif (int, float)
11290 void * __builtin_custom_pnip (int, void *)
11291 void * __builtin_custom_pnfi (float, int)
11292 void * __builtin_custom_pnff (float, float)
11293 void * __builtin_custom_pnfp (float, void *)
11294 void * __builtin_custom_pnpi (void *, int)
11295 void * __builtin_custom_pnpf (void *, float)
11296 void * __builtin_custom_pnpp (void *, void *)
11297 @end example
11299 @node ARC Built-in Functions
11300 @subsection ARC Built-in Functions
11302 The following built-in functions are provided for ARC targets.  The
11303 built-ins generate the corresponding assembly instructions.  In the
11304 examples given below, the generated code often requires an operand or
11305 result to be in a register.  Where necessary further code will be
11306 generated to ensure this is true, but for brevity this is not
11307 described in each case.
11309 @emph{Note:} Using a built-in to generate an instruction not supported
11310 by a target may cause problems. At present the compiler is not
11311 guaranteed to detect such misuse, and as a result an internal compiler
11312 error may be generated.
11314 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11315 Return 1 if @var{val} is known to have the byte alignment given
11316 by @var{alignval}, otherwise return 0.
11317 Note that this is different from
11318 @smallexample
11319 __alignof__(*(char *)@var{val}) >= alignval
11320 @end smallexample
11321 because __alignof__ sees only the type of the dereference, whereas
11322 __builtin_arc_align uses alignment information from the pointer
11323 as well as from the pointed-to type.
11324 The information available will depend on optimization level.
11325 @end deftypefn
11327 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11328 Generates
11329 @example
11331 @end example
11332 @end deftypefn
11334 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11335 The operand is the number of a register to be read.  Generates:
11336 @example
11337 mov  @var{dest}, r@var{regno}
11338 @end example
11339 where the value in @var{dest} will be the result returned from the
11340 built-in.
11341 @end deftypefn
11343 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11344 The first operand is the number of a register to be written, the
11345 second operand is a compile time constant to write into that
11346 register.  Generates:
11347 @example
11348 mov  r@var{regno}, @var{val}
11349 @end example
11350 @end deftypefn
11352 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11353 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11354 Generates:
11355 @example
11356 divaw  @var{dest}, @var{a}, @var{b}
11357 @end example
11358 where the value in @var{dest} will be the result returned from the
11359 built-in.
11360 @end deftypefn
11362 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11363 Generates
11364 @example
11365 flag  @var{a}
11366 @end example
11367 @end deftypefn
11369 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11370 The operand, @var{auxv}, is the address of an auxiliary register and
11371 must be a compile time constant.  Generates:
11372 @example
11373 lr  @var{dest}, [@var{auxr}]
11374 @end example
11375 Where the value in @var{dest} will be the result returned from the
11376 built-in.
11377 @end deftypefn
11379 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11380 Only available with @option{-mmul64}.  Generates:
11381 @example
11382 mul64  @var{a}, @var{b}
11383 @end example
11384 @end deftypefn
11386 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11387 Only available with @option{-mmul64}.  Generates:
11388 @example
11389 mulu64  @var{a}, @var{b}
11390 @end example
11391 @end deftypefn
11393 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11394 Generates:
11395 @example
11397 @end example
11398 @end deftypefn
11400 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11401 Only valid if the @samp{norm} instruction is available through the
11402 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11403 Generates:
11404 @example
11405 norm  @var{dest}, @var{src}
11406 @end example
11407 Where the value in @var{dest} will be the result returned from the
11408 built-in.
11409 @end deftypefn
11411 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
11412 Only valid if the @samp{normw} instruction is available through the
11413 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11414 Generates:
11415 @example
11416 normw  @var{dest}, @var{src}
11417 @end example
11418 Where the value in @var{dest} will be the result returned from the
11419 built-in.
11420 @end deftypefn
11422 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
11423 Generates:
11424 @example
11425 rtie
11426 @end example
11427 @end deftypefn
11429 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
11430 Generates:
11431 @example
11432 sleep  @var{a}
11433 @end example
11434 @end deftypefn
11436 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11437 The first argument, @var{auxv}, is the address of an auxiliary
11438 register, the second argument, @var{val}, is a compile time constant
11439 to be written to the register.  Generates:
11440 @example
11441 sr  @var{auxr}, [@var{val}]
11442 @end example
11443 @end deftypefn
11445 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
11446 Only valid with @option{-mswap}.  Generates:
11447 @example
11448 swap  @var{dest}, @var{src}
11449 @end example
11450 Where the value in @var{dest} will be the result returned from the
11451 built-in.
11452 @end deftypefn
11454 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
11455 Generates:
11456 @example
11458 @end example
11459 @end deftypefn
11461 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
11462 Only available with @option{-mcpu=ARC700}.  Generates:
11463 @example
11464 sync
11465 @end example
11466 @end deftypefn
11468 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
11469 Only available with @option{-mcpu=ARC700}.  Generates:
11470 @example
11471 trap_s  @var{c}
11472 @end example
11473 @end deftypefn
11475 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
11476 Only available with @option{-mcpu=ARC700}.  Generates:
11477 @example
11478 unimp_s
11479 @end example
11480 @end deftypefn
11482 The instructions generated by the following builtins are not
11483 considered as candidates for scheduling.  They are not moved around by
11484 the compiler during scheduling, and thus can be expected to appear
11485 where they are put in the C code:
11486 @example
11487 __builtin_arc_brk()
11488 __builtin_arc_core_read()
11489 __builtin_arc_core_write()
11490 __builtin_arc_flag()
11491 __builtin_arc_lr()
11492 __builtin_arc_sleep()
11493 __builtin_arc_sr()
11494 __builtin_arc_swi()
11495 @end example
11497 @node ARC SIMD Built-in Functions
11498 @subsection ARC SIMD Built-in Functions
11500 SIMD builtins provided by the compiler can be used to generate the
11501 vector instructions.  This section describes the available builtins
11502 and their usage in programs.  With the @option{-msimd} option, the
11503 compiler provides 128-bit vector types, which can be specified using
11504 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
11505 can be included to use the following predefined types:
11506 @example
11507 typedef int __v4si   __attribute__((vector_size(16)));
11508 typedef short __v8hi __attribute__((vector_size(16)));
11509 @end example
11511 These types can be used to define 128-bit variables.  The built-in
11512 functions listed in the following section can be used on these
11513 variables to generate the vector operations.
11515 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11516 @file{arc-simd.h} also provides equivalent macros called
11517 @code{_@var{someinsn}} that can be used for programming ease and
11518 improved readability.  The following macros for DMA control are also
11519 provided:
11520 @example
11521 #define _setup_dma_in_channel_reg _vdiwr
11522 #define _setup_dma_out_channel_reg _vdowr
11523 @end example
11525 The following is a complete list of all the SIMD built-ins provided
11526 for ARC, grouped by calling signature.
11528 The following take two @code{__v8hi} arguments and return a
11529 @code{__v8hi} result:
11530 @example
11531 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11532 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11533 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11534 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11535 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11536 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11537 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11538 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11539 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11540 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11541 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11542 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11543 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11544 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11545 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11546 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11547 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11548 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11549 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11550 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11551 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11552 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11553 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11554 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11555 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11556 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11557 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11558 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11559 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11560 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11561 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11562 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11563 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11564 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11565 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11566 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11567 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11568 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11569 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11570 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11571 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11572 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11573 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11574 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11575 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11576 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11577 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11578 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11579 @end example
11581 The following take one @code{__v8hi} and one @code{int} argument and return a
11582 @code{__v8hi} result:
11584 @example
11585 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11586 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11587 __v8hi __builtin_arc_vbminw (__v8hi, int)
11588 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11589 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11590 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11591 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11592 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11593 @end example
11595 The following take one @code{__v8hi} argument and one @code{int} argument which
11596 must be a 3-bit compile time constant indicating a register number
11597 I0-I7.  They return a @code{__v8hi} result.
11598 @example
11599 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11600 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11601 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11602 @end example
11604 The following take one @code{__v8hi} argument and one @code{int}
11605 argument which must be a 6-bit compile time constant.  They return a
11606 @code{__v8hi} result.
11607 @example
11608 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11609 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11610 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11611 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11612 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11613 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11614 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11615 @end example
11617 The following take one @code{__v8hi} argument and one @code{int} argument which
11618 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11619 result.
11620 @example
11621 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11622 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11623 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11624 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11625 @end example
11627 The following take two @code{int} arguments, the second of which which
11628 must be a 8-bit compile time constant.  They return a @code{__v8hi}
11629 result:
11630 @example
11631 __v8hi __builtin_arc_vmovaw (int, const int)
11632 __v8hi __builtin_arc_vmovw (int, const int)
11633 __v8hi __builtin_arc_vmovzw (int, const int)
11634 @end example
11636 The following take a single @code{__v8hi} argument and return a
11637 @code{__v8hi} result:
11638 @example
11639 __v8hi __builtin_arc_vabsaw (__v8hi)
11640 __v8hi __builtin_arc_vabsw (__v8hi)
11641 __v8hi __builtin_arc_vaddsuw (__v8hi)
11642 __v8hi __builtin_arc_vexch1 (__v8hi)
11643 __v8hi __builtin_arc_vexch2 (__v8hi)
11644 __v8hi __builtin_arc_vexch4 (__v8hi)
11645 __v8hi __builtin_arc_vsignw (__v8hi)
11646 __v8hi __builtin_arc_vupbaw (__v8hi)
11647 __v8hi __builtin_arc_vupbw (__v8hi)
11648 __v8hi __builtin_arc_vupsbaw (__v8hi)
11649 __v8hi __builtin_arc_vupsbw (__v8hi)
11650 @end example
11652 The following take two @code{int} arguments and return no result:
11653 @example
11654 void __builtin_arc_vdirun (int, int)
11655 void __builtin_arc_vdorun (int, int)
11656 @end example
11658 The following take two @code{int} arguments and return no result.  The
11659 first argument must a 3-bit compile time constant indicating one of
11660 the DR0-DR7 DMA setup channels:
11661 @example
11662 void __builtin_arc_vdiwr (const int, int)
11663 void __builtin_arc_vdowr (const int, int)
11664 @end example
11666 The following take an @code{int} argument and return no result:
11667 @example
11668 void __builtin_arc_vendrec (int)
11669 void __builtin_arc_vrec (int)
11670 void __builtin_arc_vrecrun (int)
11671 void __builtin_arc_vrun (int)
11672 @end example
11674 The following take a @code{__v8hi} argument and two @code{int}
11675 arguments and return a @code{__v8hi} result.  The second argument must
11676 be a 3-bit compile time constants, indicating one the registers I0-I7,
11677 and the third argument must be an 8-bit compile time constant.
11679 @emph{Note:} Although the equivalent hardware instructions do not take
11680 an SIMD register as an operand, these builtins overwrite the relevant
11681 bits of the @code{__v8hi} register provided as the first argument with
11682 the value loaded from the @code{[Ib, u8]} location in the SDM.
11684 @example
11685 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11686 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11687 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11688 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11689 @end example
11691 The following take two @code{int} arguments and return a @code{__v8hi}
11692 result.  The first argument must be a 3-bit compile time constants,
11693 indicating one the registers I0-I7, and the second argument must be an
11694 8-bit compile time constant.
11696 @example
11697 __v8hi __builtin_arc_vld128 (const int, const int)
11698 __v8hi __builtin_arc_vld64w (const int, const int)
11699 @end example
11701 The following take a @code{__v8hi} argument and two @code{int}
11702 arguments and return no result.  The second argument must be a 3-bit
11703 compile time constants, indicating one the registers I0-I7, and the
11704 third argument must be an 8-bit compile time constant.
11706 @example
11707 void __builtin_arc_vst128 (__v8hi, const int, const int)
11708 void __builtin_arc_vst64 (__v8hi, const int, const int)
11709 @end example
11711 The following take a @code{__v8hi} argument and three @code{int}
11712 arguments and return no result.  The second argument must be a 3-bit
11713 compile-time constant, identifying the 16-bit sub-register to be
11714 stored, the third argument must be a 3-bit compile time constants,
11715 indicating one the registers I0-I7, and the fourth argument must be an
11716 8-bit compile time constant.
11718 @example
11719 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11720 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11721 @end example
11723 @node ARM iWMMXt Built-in Functions
11724 @subsection ARM iWMMXt Built-in Functions
11726 These built-in functions are available for the ARM family of
11727 processors when the @option{-mcpu=iwmmxt} switch is used:
11729 @smallexample
11730 typedef int v2si __attribute__ ((vector_size (8)));
11731 typedef short v4hi __attribute__ ((vector_size (8)));
11732 typedef char v8qi __attribute__ ((vector_size (8)));
11734 int __builtin_arm_getwcgr0 (void)
11735 void __builtin_arm_setwcgr0 (int)
11736 int __builtin_arm_getwcgr1 (void)
11737 void __builtin_arm_setwcgr1 (int)
11738 int __builtin_arm_getwcgr2 (void)
11739 void __builtin_arm_setwcgr2 (int)
11740 int __builtin_arm_getwcgr3 (void)
11741 void __builtin_arm_setwcgr3 (int)
11742 int __builtin_arm_textrmsb (v8qi, int)
11743 int __builtin_arm_textrmsh (v4hi, int)
11744 int __builtin_arm_textrmsw (v2si, int)
11745 int __builtin_arm_textrmub (v8qi, int)
11746 int __builtin_arm_textrmuh (v4hi, int)
11747 int __builtin_arm_textrmuw (v2si, int)
11748 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11749 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11750 v2si __builtin_arm_tinsrw (v2si, int, int)
11751 long long __builtin_arm_tmia (long long, int, int)
11752 long long __builtin_arm_tmiabb (long long, int, int)
11753 long long __builtin_arm_tmiabt (long long, int, int)
11754 long long __builtin_arm_tmiaph (long long, int, int)
11755 long long __builtin_arm_tmiatb (long long, int, int)
11756 long long __builtin_arm_tmiatt (long long, int, int)
11757 int __builtin_arm_tmovmskb (v8qi)
11758 int __builtin_arm_tmovmskh (v4hi)
11759 int __builtin_arm_tmovmskw (v2si)
11760 long long __builtin_arm_waccb (v8qi)
11761 long long __builtin_arm_wacch (v4hi)
11762 long long __builtin_arm_waccw (v2si)
11763 v8qi __builtin_arm_waddb (v8qi, v8qi)
11764 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11765 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11766 v4hi __builtin_arm_waddh (v4hi, v4hi)
11767 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11768 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11769 v2si __builtin_arm_waddw (v2si, v2si)
11770 v2si __builtin_arm_waddwss (v2si, v2si)
11771 v2si __builtin_arm_waddwus (v2si, v2si)
11772 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11773 long long __builtin_arm_wand(long long, long long)
11774 long long __builtin_arm_wandn (long long, long long)
11775 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11776 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11777 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11778 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11779 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
11780 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
11781 v2si __builtin_arm_wcmpeqw (v2si, v2si)
11782 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
11783 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
11784 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
11785 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
11786 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
11787 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
11788 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
11789 long long __builtin_arm_wmacsz (v4hi, v4hi)
11790 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
11791 long long __builtin_arm_wmacuz (v4hi, v4hi)
11792 v4hi __builtin_arm_wmadds (v4hi, v4hi)
11793 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
11794 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
11795 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
11796 v2si __builtin_arm_wmaxsw (v2si, v2si)
11797 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
11798 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
11799 v2si __builtin_arm_wmaxuw (v2si, v2si)
11800 v8qi __builtin_arm_wminsb (v8qi, v8qi)
11801 v4hi __builtin_arm_wminsh (v4hi, v4hi)
11802 v2si __builtin_arm_wminsw (v2si, v2si)
11803 v8qi __builtin_arm_wminub (v8qi, v8qi)
11804 v4hi __builtin_arm_wminuh (v4hi, v4hi)
11805 v2si __builtin_arm_wminuw (v2si, v2si)
11806 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
11807 v4hi __builtin_arm_wmulul (v4hi, v4hi)
11808 v4hi __builtin_arm_wmulum (v4hi, v4hi)
11809 long long __builtin_arm_wor (long long, long long)
11810 v2si __builtin_arm_wpackdss (long long, long long)
11811 v2si __builtin_arm_wpackdus (long long, long long)
11812 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
11813 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
11814 v4hi __builtin_arm_wpackwss (v2si, v2si)
11815 v4hi __builtin_arm_wpackwus (v2si, v2si)
11816 long long __builtin_arm_wrord (long long, long long)
11817 long long __builtin_arm_wrordi (long long, int)
11818 v4hi __builtin_arm_wrorh (v4hi, long long)
11819 v4hi __builtin_arm_wrorhi (v4hi, int)
11820 v2si __builtin_arm_wrorw (v2si, long long)
11821 v2si __builtin_arm_wrorwi (v2si, int)
11822 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
11823 v2si __builtin_arm_wsadbz (v8qi, v8qi)
11824 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
11825 v2si __builtin_arm_wsadhz (v4hi, v4hi)
11826 v4hi __builtin_arm_wshufh (v4hi, int)
11827 long long __builtin_arm_wslld (long long, long long)
11828 long long __builtin_arm_wslldi (long long, int)
11829 v4hi __builtin_arm_wsllh (v4hi, long long)
11830 v4hi __builtin_arm_wsllhi (v4hi, int)
11831 v2si __builtin_arm_wsllw (v2si, long long)
11832 v2si __builtin_arm_wsllwi (v2si, int)
11833 long long __builtin_arm_wsrad (long long, long long)
11834 long long __builtin_arm_wsradi (long long, int)
11835 v4hi __builtin_arm_wsrah (v4hi, long long)
11836 v4hi __builtin_arm_wsrahi (v4hi, int)
11837 v2si __builtin_arm_wsraw (v2si, long long)
11838 v2si __builtin_arm_wsrawi (v2si, int)
11839 long long __builtin_arm_wsrld (long long, long long)
11840 long long __builtin_arm_wsrldi (long long, int)
11841 v4hi __builtin_arm_wsrlh (v4hi, long long)
11842 v4hi __builtin_arm_wsrlhi (v4hi, int)
11843 v2si __builtin_arm_wsrlw (v2si, long long)
11844 v2si __builtin_arm_wsrlwi (v2si, int)
11845 v8qi __builtin_arm_wsubb (v8qi, v8qi)
11846 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
11847 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
11848 v4hi __builtin_arm_wsubh (v4hi, v4hi)
11849 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
11850 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
11851 v2si __builtin_arm_wsubw (v2si, v2si)
11852 v2si __builtin_arm_wsubwss (v2si, v2si)
11853 v2si __builtin_arm_wsubwus (v2si, v2si)
11854 v4hi __builtin_arm_wunpckehsb (v8qi)
11855 v2si __builtin_arm_wunpckehsh (v4hi)
11856 long long __builtin_arm_wunpckehsw (v2si)
11857 v4hi __builtin_arm_wunpckehub (v8qi)
11858 v2si __builtin_arm_wunpckehuh (v4hi)
11859 long long __builtin_arm_wunpckehuw (v2si)
11860 v4hi __builtin_arm_wunpckelsb (v8qi)
11861 v2si __builtin_arm_wunpckelsh (v4hi)
11862 long long __builtin_arm_wunpckelsw (v2si)
11863 v4hi __builtin_arm_wunpckelub (v8qi)
11864 v2si __builtin_arm_wunpckeluh (v4hi)
11865 long long __builtin_arm_wunpckeluw (v2si)
11866 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
11867 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
11868 v2si __builtin_arm_wunpckihw (v2si, v2si)
11869 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
11870 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
11871 v2si __builtin_arm_wunpckilw (v2si, v2si)
11872 long long __builtin_arm_wxor (long long, long long)
11873 long long __builtin_arm_wzero ()
11874 @end smallexample
11877 @node ARM C Language Extensions (ACLE)
11878 @subsection ARM C Language Extensions (ACLE)
11880 GCC implements extensions for C as described in the ARM C Language
11881 Extensions (ACLE) specification, which can be found at
11882 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
11884 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
11885 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
11886 intrinsics can be found at
11887 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
11888 The built-in intrinsics for the Advanced SIMD extension are available when
11889 NEON is enabled.
11891 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
11892 back ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM back end's
11893 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
11894 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
11895 intrinsics yet.
11897 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
11898 availability of extensions.
11900 @node ARM Floating Point Status and Control Intrinsics
11901 @subsection ARM Floating Point Status and Control Intrinsics
11903 These built-in functions are available for the ARM family of
11904 processors with floating-point unit.
11906 @smallexample
11907 unsigned int __builtin_arm_get_fpscr ()
11908 void __builtin_arm_set_fpscr (unsigned int)
11909 @end smallexample
11911 @node AVR Built-in Functions
11912 @subsection AVR Built-in Functions
11914 For each built-in function for AVR, there is an equally named,
11915 uppercase built-in macro defined. That way users can easily query if
11916 or if not a specific built-in is implemented or not. For example, if
11917 @code{__builtin_avr_nop} is available the macro
11918 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
11920 The following built-in functions map to the respective machine
11921 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
11922 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
11923 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
11924 as library call if no hardware multiplier is available.
11926 @smallexample
11927 void __builtin_avr_nop (void)
11928 void __builtin_avr_sei (void)
11929 void __builtin_avr_cli (void)
11930 void __builtin_avr_sleep (void)
11931 void __builtin_avr_wdr (void)
11932 unsigned char __builtin_avr_swap (unsigned char)
11933 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
11934 int __builtin_avr_fmuls (char, char)
11935 int __builtin_avr_fmulsu (char, unsigned char)
11936 @end smallexample
11938 In order to delay execution for a specific number of cycles, GCC
11939 implements
11940 @smallexample
11941 void __builtin_avr_delay_cycles (unsigned long ticks)
11942 @end smallexample
11944 @noindent
11945 @code{ticks} is the number of ticks to delay execution. Note that this
11946 built-in does not take into account the effect of interrupts that
11947 might increase delay time. @code{ticks} must be a compile-time
11948 integer constant; delays with a variable number of cycles are not supported.
11950 @smallexample
11951 char __builtin_avr_flash_segment (const __memx void*)
11952 @end smallexample
11954 @noindent
11955 This built-in takes a byte address to the 24-bit
11956 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
11957 the number of the flash segment (the 64 KiB chunk) where the address
11958 points to.  Counting starts at @code{0}.
11959 If the address does not point to flash memory, return @code{-1}.
11961 @smallexample
11962 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11963 @end smallexample
11965 @noindent
11966 Insert bits from @var{bits} into @var{val} and return the resulting
11967 value. The nibbles of @var{map} determine how the insertion is
11968 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11969 @enumerate
11970 @item If @var{X} is @code{0xf},
11971 then the @var{n}-th bit of @var{val} is returned unaltered.
11973 @item If X is in the range 0@dots{}7,
11974 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11976 @item If X is in the range 8@dots{}@code{0xe},
11977 then the @var{n}-th result bit is undefined.
11978 @end enumerate
11980 @noindent
11981 One typical use case for this built-in is adjusting input and
11982 output values to non-contiguous port layouts. Some examples:
11984 @smallexample
11985 // same as val, bits is unused
11986 __builtin_avr_insert_bits (0xffffffff, bits, val)
11987 @end smallexample
11989 @smallexample
11990 // same as bits, val is unused
11991 __builtin_avr_insert_bits (0x76543210, bits, val)
11992 @end smallexample
11994 @smallexample
11995 // same as rotating bits by 4
11996 __builtin_avr_insert_bits (0x32107654, bits, 0)
11997 @end smallexample
11999 @smallexample
12000 // high nibble of result is the high nibble of val
12001 // low nibble of result is the low nibble of bits
12002 __builtin_avr_insert_bits (0xffff3210, bits, val)
12003 @end smallexample
12005 @smallexample
12006 // reverse the bit order of bits
12007 __builtin_avr_insert_bits (0x01234567, bits, 0)
12008 @end smallexample
12010 @node Blackfin Built-in Functions
12011 @subsection Blackfin Built-in Functions
12013 Currently, there are two Blackfin-specific built-in functions.  These are
12014 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12015 using inline assembly; by using these built-in functions the compiler can
12016 automatically add workarounds for hardware errata involving these
12017 instructions.  These functions are named as follows:
12019 @smallexample
12020 void __builtin_bfin_csync (void)
12021 void __builtin_bfin_ssync (void)
12022 @end smallexample
12024 @node FR-V Built-in Functions
12025 @subsection FR-V Built-in Functions
12027 GCC provides many FR-V-specific built-in functions.  In general,
12028 these functions are intended to be compatible with those described
12029 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12030 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
12031 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12032 pointer rather than by value.
12034 Most of the functions are named after specific FR-V instructions.
12035 Such functions are said to be ``directly mapped'' and are summarized
12036 here in tabular form.
12038 @menu
12039 * Argument Types::
12040 * Directly-mapped Integer Functions::
12041 * Directly-mapped Media Functions::
12042 * Raw read/write Functions::
12043 * Other Built-in Functions::
12044 @end menu
12046 @node Argument Types
12047 @subsubsection Argument Types
12049 The arguments to the built-in functions can be divided into three groups:
12050 register numbers, compile-time constants and run-time values.  In order
12051 to make this classification clear at a glance, the arguments and return
12052 values are given the following pseudo types:
12054 @multitable @columnfractions .20 .30 .15 .35
12055 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12056 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12057 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12058 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12059 @item @code{uw2} @tab @code{unsigned long long} @tab No
12060 @tab an unsigned doubleword
12061 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12062 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12063 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12064 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12065 @end multitable
12067 These pseudo types are not defined by GCC, they are simply a notational
12068 convenience used in this manual.
12070 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12071 and @code{sw2} are evaluated at run time.  They correspond to
12072 register operands in the underlying FR-V instructions.
12074 @code{const} arguments represent immediate operands in the underlying
12075 FR-V instructions.  They must be compile-time constants.
12077 @code{acc} arguments are evaluated at compile time and specify the number
12078 of an accumulator register.  For example, an @code{acc} argument of 2
12079 selects the ACC2 register.
12081 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12082 number of an IACC register.  See @pxref{Other Built-in Functions}
12083 for more details.
12085 @node Directly-mapped Integer Functions
12086 @subsubsection Directly-Mapped Integer Functions
12088 The functions listed below map directly to FR-V I-type instructions.
12090 @multitable @columnfractions .45 .32 .23
12091 @item Function prototype @tab Example usage @tab Assembly output
12092 @item @code{sw1 __ADDSS (sw1, sw1)}
12093 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12094 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12095 @item @code{sw1 __SCAN (sw1, sw1)}
12096 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12097 @tab @code{SCAN @var{a},@var{b},@var{c}}
12098 @item @code{sw1 __SCUTSS (sw1)}
12099 @tab @code{@var{b} = __SCUTSS (@var{a})}
12100 @tab @code{SCUTSS @var{a},@var{b}}
12101 @item @code{sw1 __SLASS (sw1, sw1)}
12102 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12103 @tab @code{SLASS @var{a},@var{b},@var{c}}
12104 @item @code{void __SMASS (sw1, sw1)}
12105 @tab @code{__SMASS (@var{a}, @var{b})}
12106 @tab @code{SMASS @var{a},@var{b}}
12107 @item @code{void __SMSSS (sw1, sw1)}
12108 @tab @code{__SMSSS (@var{a}, @var{b})}
12109 @tab @code{SMSSS @var{a},@var{b}}
12110 @item @code{void __SMU (sw1, sw1)}
12111 @tab @code{__SMU (@var{a}, @var{b})}
12112 @tab @code{SMU @var{a},@var{b}}
12113 @item @code{sw2 __SMUL (sw1, sw1)}
12114 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12115 @tab @code{SMUL @var{a},@var{b},@var{c}}
12116 @item @code{sw1 __SUBSS (sw1, sw1)}
12117 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12118 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12119 @item @code{uw2 __UMUL (uw1, uw1)}
12120 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12121 @tab @code{UMUL @var{a},@var{b},@var{c}}
12122 @end multitable
12124 @node Directly-mapped Media Functions
12125 @subsubsection Directly-Mapped Media Functions
12127 The functions listed below map directly to FR-V M-type instructions.
12129 @multitable @columnfractions .45 .32 .23
12130 @item Function prototype @tab Example usage @tab Assembly output
12131 @item @code{uw1 __MABSHS (sw1)}
12132 @tab @code{@var{b} = __MABSHS (@var{a})}
12133 @tab @code{MABSHS @var{a},@var{b}}
12134 @item @code{void __MADDACCS (acc, acc)}
12135 @tab @code{__MADDACCS (@var{b}, @var{a})}
12136 @tab @code{MADDACCS @var{a},@var{b}}
12137 @item @code{sw1 __MADDHSS (sw1, sw1)}
12138 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12139 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12140 @item @code{uw1 __MADDHUS (uw1, uw1)}
12141 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12142 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12143 @item @code{uw1 __MAND (uw1, uw1)}
12144 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12145 @tab @code{MAND @var{a},@var{b},@var{c}}
12146 @item @code{void __MASACCS (acc, acc)}
12147 @tab @code{__MASACCS (@var{b}, @var{a})}
12148 @tab @code{MASACCS @var{a},@var{b}}
12149 @item @code{uw1 __MAVEH (uw1, uw1)}
12150 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12151 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12152 @item @code{uw2 __MBTOH (uw1)}
12153 @tab @code{@var{b} = __MBTOH (@var{a})}
12154 @tab @code{MBTOH @var{a},@var{b}}
12155 @item @code{void __MBTOHE (uw1 *, uw1)}
12156 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12157 @tab @code{MBTOHE @var{a},@var{b}}
12158 @item @code{void __MCLRACC (acc)}
12159 @tab @code{__MCLRACC (@var{a})}
12160 @tab @code{MCLRACC @var{a}}
12161 @item @code{void __MCLRACCA (void)}
12162 @tab @code{__MCLRACCA ()}
12163 @tab @code{MCLRACCA}
12164 @item @code{uw1 __Mcop1 (uw1, uw1)}
12165 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12166 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12167 @item @code{uw1 __Mcop2 (uw1, uw1)}
12168 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12169 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12170 @item @code{uw1 __MCPLHI (uw2, const)}
12171 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12172 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12173 @item @code{uw1 __MCPLI (uw2, const)}
12174 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12175 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12176 @item @code{void __MCPXIS (acc, sw1, sw1)}
12177 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12178 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12179 @item @code{void __MCPXIU (acc, uw1, uw1)}
12180 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12181 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12182 @item @code{void __MCPXRS (acc, sw1, sw1)}
12183 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12184 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12185 @item @code{void __MCPXRU (acc, uw1, uw1)}
12186 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12187 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12188 @item @code{uw1 __MCUT (acc, uw1)}
12189 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12190 @tab @code{MCUT @var{a},@var{b},@var{c}}
12191 @item @code{uw1 __MCUTSS (acc, sw1)}
12192 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12193 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12194 @item @code{void __MDADDACCS (acc, acc)}
12195 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12196 @tab @code{MDADDACCS @var{a},@var{b}}
12197 @item @code{void __MDASACCS (acc, acc)}
12198 @tab @code{__MDASACCS (@var{b}, @var{a})}
12199 @tab @code{MDASACCS @var{a},@var{b}}
12200 @item @code{uw2 __MDCUTSSI (acc, const)}
12201 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12202 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12203 @item @code{uw2 __MDPACKH (uw2, uw2)}
12204 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12205 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12206 @item @code{uw2 __MDROTLI (uw2, const)}
12207 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12208 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12209 @item @code{void __MDSUBACCS (acc, acc)}
12210 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12211 @tab @code{MDSUBACCS @var{a},@var{b}}
12212 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12213 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12214 @tab @code{MDUNPACKH @var{a},@var{b}}
12215 @item @code{uw2 __MEXPDHD (uw1, const)}
12216 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12217 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12218 @item @code{uw1 __MEXPDHW (uw1, const)}
12219 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12220 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12221 @item @code{uw1 __MHDSETH (uw1, const)}
12222 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12223 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12224 @item @code{sw1 __MHDSETS (const)}
12225 @tab @code{@var{b} = __MHDSETS (@var{a})}
12226 @tab @code{MHDSETS #@var{a},@var{b}}
12227 @item @code{uw1 __MHSETHIH (uw1, const)}
12228 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12229 @tab @code{MHSETHIH #@var{a},@var{b}}
12230 @item @code{sw1 __MHSETHIS (sw1, const)}
12231 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12232 @tab @code{MHSETHIS #@var{a},@var{b}}
12233 @item @code{uw1 __MHSETLOH (uw1, const)}
12234 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12235 @tab @code{MHSETLOH #@var{a},@var{b}}
12236 @item @code{sw1 __MHSETLOS (sw1, const)}
12237 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12238 @tab @code{MHSETLOS #@var{a},@var{b}}
12239 @item @code{uw1 __MHTOB (uw2)}
12240 @tab @code{@var{b} = __MHTOB (@var{a})}
12241 @tab @code{MHTOB @var{a},@var{b}}
12242 @item @code{void __MMACHS (acc, sw1, sw1)}
12243 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12244 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12245 @item @code{void __MMACHU (acc, uw1, uw1)}
12246 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12247 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12248 @item @code{void __MMRDHS (acc, sw1, sw1)}
12249 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12250 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12251 @item @code{void __MMRDHU (acc, uw1, uw1)}
12252 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12253 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12254 @item @code{void __MMULHS (acc, sw1, sw1)}
12255 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12256 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12257 @item @code{void __MMULHU (acc, uw1, uw1)}
12258 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12259 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12260 @item @code{void __MMULXHS (acc, sw1, sw1)}
12261 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12262 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12263 @item @code{void __MMULXHU (acc, uw1, uw1)}
12264 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12265 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12266 @item @code{uw1 __MNOT (uw1)}
12267 @tab @code{@var{b} = __MNOT (@var{a})}
12268 @tab @code{MNOT @var{a},@var{b}}
12269 @item @code{uw1 __MOR (uw1, uw1)}
12270 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12271 @tab @code{MOR @var{a},@var{b},@var{c}}
12272 @item @code{uw1 __MPACKH (uh, uh)}
12273 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12274 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12275 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12276 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12277 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12278 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12279 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12280 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12281 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12282 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12283 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12284 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12285 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12286 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12287 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12288 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12289 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12290 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12291 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12292 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12293 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12294 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12295 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12296 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12297 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12298 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12299 @item @code{void __MQMACHS (acc, sw2, sw2)}
12300 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12301 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12302 @item @code{void __MQMACHU (acc, uw2, uw2)}
12303 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12304 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12305 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12306 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12307 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12308 @item @code{void __MQMULHS (acc, sw2, sw2)}
12309 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12310 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12311 @item @code{void __MQMULHU (acc, uw2, uw2)}
12312 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12313 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12314 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12315 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12316 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12317 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12318 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12319 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12320 @item @code{sw2 __MQSATHS (sw2, sw2)}
12321 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12322 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12323 @item @code{uw2 __MQSLLHI (uw2, int)}
12324 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12325 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12326 @item @code{sw2 __MQSRAHI (sw2, int)}
12327 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12328 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12329 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12330 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12331 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12332 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12333 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12334 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12335 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12336 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12337 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12338 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12339 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12340 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12341 @item @code{uw1 __MRDACC (acc)}
12342 @tab @code{@var{b} = __MRDACC (@var{a})}
12343 @tab @code{MRDACC @var{a},@var{b}}
12344 @item @code{uw1 __MRDACCG (acc)}
12345 @tab @code{@var{b} = __MRDACCG (@var{a})}
12346 @tab @code{MRDACCG @var{a},@var{b}}
12347 @item @code{uw1 __MROTLI (uw1, const)}
12348 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12349 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12350 @item @code{uw1 __MROTRI (uw1, const)}
12351 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12352 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12353 @item @code{sw1 __MSATHS (sw1, sw1)}
12354 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12355 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12356 @item @code{uw1 __MSATHU (uw1, uw1)}
12357 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12358 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12359 @item @code{uw1 __MSLLHI (uw1, const)}
12360 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12361 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12362 @item @code{sw1 __MSRAHI (sw1, const)}
12363 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12364 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12365 @item @code{uw1 __MSRLHI (uw1, const)}
12366 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12367 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12368 @item @code{void __MSUBACCS (acc, acc)}
12369 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12370 @tab @code{MSUBACCS @var{a},@var{b}}
12371 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12372 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12373 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12374 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12375 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12376 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12377 @item @code{void __MTRAP (void)}
12378 @tab @code{__MTRAP ()}
12379 @tab @code{MTRAP}
12380 @item @code{uw2 __MUNPACKH (uw1)}
12381 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12382 @tab @code{MUNPACKH @var{a},@var{b}}
12383 @item @code{uw1 __MWCUT (uw2, uw1)}
12384 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12385 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12386 @item @code{void __MWTACC (acc, uw1)}
12387 @tab @code{__MWTACC (@var{b}, @var{a})}
12388 @tab @code{MWTACC @var{a},@var{b}}
12389 @item @code{void __MWTACCG (acc, uw1)}
12390 @tab @code{__MWTACCG (@var{b}, @var{a})}
12391 @tab @code{MWTACCG @var{a},@var{b}}
12392 @item @code{uw1 __MXOR (uw1, uw1)}
12393 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12394 @tab @code{MXOR @var{a},@var{b},@var{c}}
12395 @end multitable
12397 @node Raw read/write Functions
12398 @subsubsection Raw Read/Write Functions
12400 This sections describes built-in functions related to read and write
12401 instructions to access memory.  These functions generate
12402 @code{membar} instructions to flush the I/O load and stores where
12403 appropriate, as described in Fujitsu's manual described above.
12405 @table @code
12407 @item unsigned char __builtin_read8 (void *@var{data})
12408 @item unsigned short __builtin_read16 (void *@var{data})
12409 @item unsigned long __builtin_read32 (void *@var{data})
12410 @item unsigned long long __builtin_read64 (void *@var{data})
12412 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12413 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12414 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12415 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12416 @end table
12418 @node Other Built-in Functions
12419 @subsubsection Other Built-in Functions
12421 This section describes built-in functions that are not named after
12422 a specific FR-V instruction.
12424 @table @code
12425 @item sw2 __IACCreadll (iacc @var{reg})
12426 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
12427 for future expansion and must be 0.
12429 @item sw1 __IACCreadl (iacc @var{reg})
12430 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12431 Other values of @var{reg} are rejected as invalid.
12433 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12434 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
12435 is reserved for future expansion and must be 0.
12437 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12438 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12439 is 1.  Other values of @var{reg} are rejected as invalid.
12441 @item void __data_prefetch0 (const void *@var{x})
12442 Use the @code{dcpl} instruction to load the contents of address @var{x}
12443 into the data cache.
12445 @item void __data_prefetch (const void *@var{x})
12446 Use the @code{nldub} instruction to load the contents of address @var{x}
12447 into the data cache.  The instruction is issued in slot I1@.
12448 @end table
12450 @node MIPS DSP Built-in Functions
12451 @subsection MIPS DSP Built-in Functions
12453 The MIPS DSP Application-Specific Extension (ASE) includes new
12454 instructions that are designed to improve the performance of DSP and
12455 media applications.  It provides instructions that operate on packed
12456 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12458 GCC supports MIPS DSP operations using both the generic
12459 vector extensions (@pxref{Vector Extensions}) and a collection of
12460 MIPS-specific built-in functions.  Both kinds of support are
12461 enabled by the @option{-mdsp} command-line option.
12463 Revision 2 of the ASE was introduced in the second half of 2006.
12464 This revision adds extra instructions to the original ASE, but is
12465 otherwise backwards-compatible with it.  You can select revision 2
12466 using the command-line option @option{-mdspr2}; this option implies
12467 @option{-mdsp}.
12469 The SCOUNT and POS bits of the DSP control register are global.  The
12470 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12471 POS bits.  During optimization, the compiler does not delete these
12472 instructions and it does not delete calls to functions containing
12473 these instructions.
12475 At present, GCC only provides support for operations on 32-bit
12476 vectors.  The vector type associated with 8-bit integer data is
12477 usually called @code{v4i8}, the vector type associated with Q7
12478 is usually called @code{v4q7}, the vector type associated with 16-bit
12479 integer data is usually called @code{v2i16}, and the vector type
12480 associated with Q15 is usually called @code{v2q15}.  They can be
12481 defined in C as follows:
12483 @smallexample
12484 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12485 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12486 typedef short v2i16 __attribute__ ((vector_size(4)));
12487 typedef short v2q15 __attribute__ ((vector_size(4)));
12488 @end smallexample
12490 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12491 initialized in the same way as aggregates.  For example:
12493 @smallexample
12494 v4i8 a = @{1, 2, 3, 4@};
12495 v4i8 b;
12496 b = (v4i8) @{5, 6, 7, 8@};
12498 v2q15 c = @{0x0fcb, 0x3a75@};
12499 v2q15 d;
12500 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12501 @end smallexample
12503 @emph{Note:} The CPU's endianness determines the order in which values
12504 are packed.  On little-endian targets, the first value is the least
12505 significant and the last value is the most significant.  The opposite
12506 order applies to big-endian targets.  For example, the code above
12507 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12508 and @code{4} on big-endian targets.
12510 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12511 representation.  As shown in this example, the integer representation
12512 of a Q7 value can be obtained by multiplying the fractional value by
12513 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12514 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12515 @code{0x1.0p31}.
12517 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12518 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12519 and @code{c} and @code{d} are @code{v2q15} values.
12521 @multitable @columnfractions .50 .50
12522 @item C code @tab MIPS instruction
12523 @item @code{a + b} @tab @code{addu.qb}
12524 @item @code{c + d} @tab @code{addq.ph}
12525 @item @code{a - b} @tab @code{subu.qb}
12526 @item @code{c - d} @tab @code{subq.ph}
12527 @end multitable
12529 The table below lists the @code{v2i16} operation for which
12530 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12531 @code{v2i16} values.
12533 @multitable @columnfractions .50 .50
12534 @item C code @tab MIPS instruction
12535 @item @code{e * f} @tab @code{mul.ph}
12536 @end multitable
12538 It is easier to describe the DSP built-in functions if we first define
12539 the following types:
12541 @smallexample
12542 typedef int q31;
12543 typedef int i32;
12544 typedef unsigned int ui32;
12545 typedef long long a64;
12546 @end smallexample
12548 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12549 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12550 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12551 @code{long long}, but we use @code{a64} to indicate values that are
12552 placed in one of the four DSP accumulators (@code{$ac0},
12553 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12555 Also, some built-in functions prefer or require immediate numbers as
12556 parameters, because the corresponding DSP instructions accept both immediate
12557 numbers and register operands, or accept immediate numbers only.  The
12558 immediate parameters are listed as follows.
12560 @smallexample
12561 imm0_3: 0 to 3.
12562 imm0_7: 0 to 7.
12563 imm0_15: 0 to 15.
12564 imm0_31: 0 to 31.
12565 imm0_63: 0 to 63.
12566 imm0_255: 0 to 255.
12567 imm_n32_31: -32 to 31.
12568 imm_n512_511: -512 to 511.
12569 @end smallexample
12571 The following built-in functions map directly to a particular MIPS DSP
12572 instruction.  Please refer to the architecture specification
12573 for details on what each instruction does.
12575 @smallexample
12576 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12577 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12578 q31 __builtin_mips_addq_s_w (q31, q31)
12579 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12580 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12581 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12582 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12583 q31 __builtin_mips_subq_s_w (q31, q31)
12584 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12585 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12586 i32 __builtin_mips_addsc (i32, i32)
12587 i32 __builtin_mips_addwc (i32, i32)
12588 i32 __builtin_mips_modsub (i32, i32)
12589 i32 __builtin_mips_raddu_w_qb (v4i8)
12590 v2q15 __builtin_mips_absq_s_ph (v2q15)
12591 q31 __builtin_mips_absq_s_w (q31)
12592 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12593 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12594 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12595 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12596 q31 __builtin_mips_preceq_w_phl (v2q15)
12597 q31 __builtin_mips_preceq_w_phr (v2q15)
12598 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12599 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12600 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12601 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12602 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12603 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12604 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12605 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12606 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12607 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12608 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12609 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12610 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12611 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12612 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12613 q31 __builtin_mips_shll_s_w (q31, i32)
12614 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12615 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12616 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12617 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12618 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12619 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12620 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12621 q31 __builtin_mips_shra_r_w (q31, i32)
12622 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12623 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12624 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12625 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12626 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12627 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12628 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12629 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12630 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12631 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12632 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12633 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12634 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12635 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12636 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12637 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12638 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12639 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12640 i32 __builtin_mips_bitrev (i32)
12641 i32 __builtin_mips_insv (i32, i32)
12642 v4i8 __builtin_mips_repl_qb (imm0_255)
12643 v4i8 __builtin_mips_repl_qb (i32)
12644 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12645 v2q15 __builtin_mips_repl_ph (i32)
12646 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12647 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12648 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12649 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12650 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12651 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12652 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12653 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12654 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12655 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12656 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12657 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12658 i32 __builtin_mips_extr_w (a64, imm0_31)
12659 i32 __builtin_mips_extr_w (a64, i32)
12660 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12661 i32 __builtin_mips_extr_s_h (a64, i32)
12662 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12663 i32 __builtin_mips_extr_rs_w (a64, i32)
12664 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12665 i32 __builtin_mips_extr_r_w (a64, i32)
12666 i32 __builtin_mips_extp (a64, imm0_31)
12667 i32 __builtin_mips_extp (a64, i32)
12668 i32 __builtin_mips_extpdp (a64, imm0_31)
12669 i32 __builtin_mips_extpdp (a64, i32)
12670 a64 __builtin_mips_shilo (a64, imm_n32_31)
12671 a64 __builtin_mips_shilo (a64, i32)
12672 a64 __builtin_mips_mthlip (a64, i32)
12673 void __builtin_mips_wrdsp (i32, imm0_63)
12674 i32 __builtin_mips_rddsp (imm0_63)
12675 i32 __builtin_mips_lbux (void *, i32)
12676 i32 __builtin_mips_lhx (void *, i32)
12677 i32 __builtin_mips_lwx (void *, i32)
12678 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12679 i32 __builtin_mips_bposge32 (void)
12680 a64 __builtin_mips_madd (a64, i32, i32);
12681 a64 __builtin_mips_maddu (a64, ui32, ui32);
12682 a64 __builtin_mips_msub (a64, i32, i32);
12683 a64 __builtin_mips_msubu (a64, ui32, ui32);
12684 a64 __builtin_mips_mult (i32, i32);
12685 a64 __builtin_mips_multu (ui32, ui32);
12686 @end smallexample
12688 The following built-in functions map directly to a particular MIPS DSP REV 2
12689 instruction.  Please refer to the architecture specification
12690 for details on what each instruction does.
12692 @smallexample
12693 v4q7 __builtin_mips_absq_s_qb (v4q7);
12694 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12695 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12696 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12697 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12698 i32 __builtin_mips_append (i32, i32, imm0_31);
12699 i32 __builtin_mips_balign (i32, i32, imm0_3);
12700 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12701 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12702 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12703 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12704 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12705 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12706 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12707 q31 __builtin_mips_mulq_rs_w (q31, q31);
12708 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12709 q31 __builtin_mips_mulq_s_w (q31, q31);
12710 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12711 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12712 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12713 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12714 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12715 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12716 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12717 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12718 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12719 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12720 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12721 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12722 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12723 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12724 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12725 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12726 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12727 q31 __builtin_mips_addqh_w (q31, q31);
12728 q31 __builtin_mips_addqh_r_w (q31, q31);
12729 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12730 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12731 q31 __builtin_mips_subqh_w (q31, q31);
12732 q31 __builtin_mips_subqh_r_w (q31, q31);
12733 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12734 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12735 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12736 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12737 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12738 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12739 @end smallexample
12742 @node MIPS Paired-Single Support
12743 @subsection MIPS Paired-Single Support
12745 The MIPS64 architecture includes a number of instructions that
12746 operate on pairs of single-precision floating-point values.
12747 Each pair is packed into a 64-bit floating-point register,
12748 with one element being designated the ``upper half'' and
12749 the other being designated the ``lower half''.
12751 GCC supports paired-single operations using both the generic
12752 vector extensions (@pxref{Vector Extensions}) and a collection of
12753 MIPS-specific built-in functions.  Both kinds of support are
12754 enabled by the @option{-mpaired-single} command-line option.
12756 The vector type associated with paired-single values is usually
12757 called @code{v2sf}.  It can be defined in C as follows:
12759 @smallexample
12760 typedef float v2sf __attribute__ ((vector_size (8)));
12761 @end smallexample
12763 @code{v2sf} values are initialized in the same way as aggregates.
12764 For example:
12766 @smallexample
12767 v2sf a = @{1.5, 9.1@};
12768 v2sf b;
12769 float e, f;
12770 b = (v2sf) @{e, f@};
12771 @end smallexample
12773 @emph{Note:} The CPU's endianness determines which value is stored in
12774 the upper half of a register and which value is stored in the lower half.
12775 On little-endian targets, the first value is the lower one and the second
12776 value is the upper one.  The opposite order applies to big-endian targets.
12777 For example, the code above sets the lower half of @code{a} to
12778 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12780 @node MIPS Loongson Built-in Functions
12781 @subsection MIPS Loongson Built-in Functions
12783 GCC provides intrinsics to access the SIMD instructions provided by the
12784 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12785 available after inclusion of the @code{loongson.h} header file,
12786 operate on the following 64-bit vector types:
12788 @itemize
12789 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12790 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12791 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12792 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12793 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12794 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12795 @end itemize
12797 The intrinsics provided are listed below; each is named after the
12798 machine instruction to which it corresponds, with suffixes added as
12799 appropriate to distinguish intrinsics that expand to the same machine
12800 instruction yet have different argument types.  Refer to the architecture
12801 documentation for a description of the functionality of each
12802 instruction.
12804 @smallexample
12805 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12806 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12807 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12808 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12809 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12810 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12811 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12812 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12813 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12814 uint64_t paddd_u (uint64_t s, uint64_t t);
12815 int64_t paddd_s (int64_t s, int64_t t);
12816 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12817 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12818 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12819 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12820 uint64_t pandn_ud (uint64_t s, uint64_t t);
12821 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12822 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12823 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12824 int64_t pandn_sd (int64_t s, int64_t t);
12825 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12826 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12827 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12828 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12829 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12830 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12831 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12832 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12833 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12834 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12835 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12836 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12837 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12838 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12839 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12840 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12841 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12842 uint16x4_t pextrh_u (uint16x4_t s, int field);
12843 int16x4_t pextrh_s (int16x4_t s, int field);
12844 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12845 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12846 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12847 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12848 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12849 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12850 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12851 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12852 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12853 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12854 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12855 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12856 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12857 uint8x8_t pmovmskb_u (uint8x8_t s);
12858 int8x8_t pmovmskb_s (int8x8_t s);
12859 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12860 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12861 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12862 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12863 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12864 uint16x4_t biadd (uint8x8_t s);
12865 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12866 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12867 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12868 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12869 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12870 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12871 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12872 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12873 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12874 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12875 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12876 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12877 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12878 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12879 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12880 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12881 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12882 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12883 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12884 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12885 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12886 uint64_t psubd_u (uint64_t s, uint64_t t);
12887 int64_t psubd_s (int64_t s, int64_t t);
12888 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12889 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12890 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12891 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12892 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12893 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12894 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12895 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12896 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12897 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12898 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12899 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12900 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12901 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12902 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12903 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12904 @end smallexample
12906 @menu
12907 * Paired-Single Arithmetic::
12908 * Paired-Single Built-in Functions::
12909 * MIPS-3D Built-in Functions::
12910 @end menu
12912 @node Paired-Single Arithmetic
12913 @subsubsection Paired-Single Arithmetic
12915 The table below lists the @code{v2sf} operations for which hardware
12916 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12917 values and @code{x} is an integral value.
12919 @multitable @columnfractions .50 .50
12920 @item C code @tab MIPS instruction
12921 @item @code{a + b} @tab @code{add.ps}
12922 @item @code{a - b} @tab @code{sub.ps}
12923 @item @code{-a} @tab @code{neg.ps}
12924 @item @code{a * b} @tab @code{mul.ps}
12925 @item @code{a * b + c} @tab @code{madd.ps}
12926 @item @code{a * b - c} @tab @code{msub.ps}
12927 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12928 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12929 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12930 @end multitable
12932 Note that the multiply-accumulate instructions can be disabled
12933 using the command-line option @code{-mno-fused-madd}.
12935 @node Paired-Single Built-in Functions
12936 @subsubsection Paired-Single Built-in Functions
12938 The following paired-single functions map directly to a particular
12939 MIPS instruction.  Please refer to the architecture specification
12940 for details on what each instruction does.
12942 @table @code
12943 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12944 Pair lower lower (@code{pll.ps}).
12946 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12947 Pair upper lower (@code{pul.ps}).
12949 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12950 Pair lower upper (@code{plu.ps}).
12952 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12953 Pair upper upper (@code{puu.ps}).
12955 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12956 Convert pair to paired single (@code{cvt.ps.s}).
12958 @item float __builtin_mips_cvt_s_pl (v2sf)
12959 Convert pair lower to single (@code{cvt.s.pl}).
12961 @item float __builtin_mips_cvt_s_pu (v2sf)
12962 Convert pair upper to single (@code{cvt.s.pu}).
12964 @item v2sf __builtin_mips_abs_ps (v2sf)
12965 Absolute value (@code{abs.ps}).
12967 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12968 Align variable (@code{alnv.ps}).
12970 @emph{Note:} The value of the third parameter must be 0 or 4
12971 modulo 8, otherwise the result is unpredictable.  Please read the
12972 instruction description for details.
12973 @end table
12975 The following multi-instruction functions are also available.
12976 In each case, @var{cond} can be any of the 16 floating-point conditions:
12977 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12978 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12979 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12981 @table @code
12982 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12983 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12984 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12985 @code{movt.ps}/@code{movf.ps}).
12987 The @code{movt} functions return the value @var{x} computed by:
12989 @smallexample
12990 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12991 mov.ps @var{x},@var{c}
12992 movt.ps @var{x},@var{d},@var{cc}
12993 @end smallexample
12995 The @code{movf} functions are similar but use @code{movf.ps} instead
12996 of @code{movt.ps}.
12998 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12999 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13000 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13001 @code{bc1t}/@code{bc1f}).
13003 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13004 and return either the upper or lower half of the result.  For example:
13006 @smallexample
13007 v2sf a, b;
13008 if (__builtin_mips_upper_c_eq_ps (a, b))
13009   upper_halves_are_equal ();
13010 else
13011   upper_halves_are_unequal ();
13013 if (__builtin_mips_lower_c_eq_ps (a, b))
13014   lower_halves_are_equal ();
13015 else
13016   lower_halves_are_unequal ();
13017 @end smallexample
13018 @end table
13020 @node MIPS-3D Built-in Functions
13021 @subsubsection MIPS-3D Built-in Functions
13023 The MIPS-3D Application-Specific Extension (ASE) includes additional
13024 paired-single instructions that are designed to improve the performance
13025 of 3D graphics operations.  Support for these instructions is controlled
13026 by the @option{-mips3d} command-line option.
13028 The functions listed below map directly to a particular MIPS-3D
13029 instruction.  Please refer to the architecture specification for
13030 more details on what each instruction does.
13032 @table @code
13033 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13034 Reduction add (@code{addr.ps}).
13036 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13037 Reduction multiply (@code{mulr.ps}).
13039 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13040 Convert paired single to paired word (@code{cvt.pw.ps}).
13042 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13043 Convert paired word to paired single (@code{cvt.ps.pw}).
13045 @item float __builtin_mips_recip1_s (float)
13046 @itemx double __builtin_mips_recip1_d (double)
13047 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13048 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13050 @item float __builtin_mips_recip2_s (float, float)
13051 @itemx double __builtin_mips_recip2_d (double, double)
13052 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13053 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13055 @item float __builtin_mips_rsqrt1_s (float)
13056 @itemx double __builtin_mips_rsqrt1_d (double)
13057 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13058 Reduced-precision reciprocal square root (sequence step 1)
13059 (@code{rsqrt1.@var{fmt}}).
13061 @item float __builtin_mips_rsqrt2_s (float, float)
13062 @itemx double __builtin_mips_rsqrt2_d (double, double)
13063 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13064 Reduced-precision reciprocal square root (sequence step 2)
13065 (@code{rsqrt2.@var{fmt}}).
13066 @end table
13068 The following multi-instruction functions are also available.
13069 In each case, @var{cond} can be any of the 16 floating-point conditions:
13070 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13071 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13072 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13074 @table @code
13075 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13076 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13077 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13078 @code{bc1t}/@code{bc1f}).
13080 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13081 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13082 For example:
13084 @smallexample
13085 float a, b;
13086 if (__builtin_mips_cabs_eq_s (a, b))
13087   true ();
13088 else
13089   false ();
13090 @end smallexample
13092 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13093 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13094 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13095 @code{bc1t}/@code{bc1f}).
13097 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13098 and return either the upper or lower half of the result.  For example:
13100 @smallexample
13101 v2sf a, b;
13102 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13103   upper_halves_are_equal ();
13104 else
13105   upper_halves_are_unequal ();
13107 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13108   lower_halves_are_equal ();
13109 else
13110   lower_halves_are_unequal ();
13111 @end smallexample
13113 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13114 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13115 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13116 @code{movt.ps}/@code{movf.ps}).
13118 The @code{movt} functions return the value @var{x} computed by:
13120 @smallexample
13121 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13122 mov.ps @var{x},@var{c}
13123 movt.ps @var{x},@var{d},@var{cc}
13124 @end smallexample
13126 The @code{movf} functions are similar but use @code{movf.ps} instead
13127 of @code{movt.ps}.
13129 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13130 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13131 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13132 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13133 Comparison of two paired-single values
13134 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13135 @code{bc1any2t}/@code{bc1any2f}).
13137 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13138 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13139 result is true and the @code{all} forms return true if both results are true.
13140 For example:
13142 @smallexample
13143 v2sf a, b;
13144 if (__builtin_mips_any_c_eq_ps (a, b))
13145   one_is_true ();
13146 else
13147   both_are_false ();
13149 if (__builtin_mips_all_c_eq_ps (a, b))
13150   both_are_true ();
13151 else
13152   one_is_false ();
13153 @end smallexample
13155 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13156 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13157 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13158 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13159 Comparison of four paired-single values
13160 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13161 @code{bc1any4t}/@code{bc1any4f}).
13163 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13164 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13165 The @code{any} forms return true if any of the four results are true
13166 and the @code{all} forms return true if all four results are true.
13167 For example:
13169 @smallexample
13170 v2sf a, b, c, d;
13171 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13172   some_are_true ();
13173 else
13174   all_are_false ();
13176 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13177   all_are_true ();
13178 else
13179   some_are_false ();
13180 @end smallexample
13181 @end table
13183 @node Other MIPS Built-in Functions
13184 @subsection Other MIPS Built-in Functions
13186 GCC provides other MIPS-specific built-in functions:
13188 @table @code
13189 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13190 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13191 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13192 when this function is available.
13194 @item unsigned int __builtin_mips_get_fcsr (void)
13195 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13196 Get and set the contents of the floating-point control and status register
13197 (FPU control register 31).  These functions are only available in hard-float
13198 code but can be called in both MIPS16 and non-MIPS16 contexts.
13200 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13201 register except the condition codes, which GCC assumes are preserved.
13202 @end table
13204 @node MSP430 Built-in Functions
13205 @subsection MSP430 Built-in Functions
13207 GCC provides a couple of special builtin functions to aid in the
13208 writing of interrupt handlers in C.
13210 @table @code
13211 @item __bic_SR_register_on_exit (int @var{mask})
13212 This clears the indicated bits in the saved copy of the status register
13213 currently residing on the stack.  This only works inside interrupt
13214 handlers and the changes to the status register will only take affect
13215 once the handler returns.
13217 @item __bis_SR_register_on_exit (int @var{mask})
13218 This sets the indicated bits in the saved copy of the status register
13219 currently residing on the stack.  This only works inside interrupt
13220 handlers and the changes to the status register will only take affect
13221 once the handler returns.
13223 @item __delay_cycles (long long @var{cycles})
13224 This inserts an instruction sequence that takes exactly @var{cycles}
13225 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13226 may use jumps, loops, or no-ops, and does not interfere with any other
13227 instructions.  Note that @var{cycles} must be a compile-time constant
13228 integer - that is, you must pass a number, not a variable that may be
13229 optimized to a constant later.  The number of cycles delayed by this
13230 builtin is exact.
13231 @end table
13233 @node NDS32 Built-in Functions
13234 @subsection NDS32 Built-in Functions
13236 These built-in functions are available for the NDS32 target:
13238 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13239 Insert an ISYNC instruction into the instruction stream where
13240 @var{addr} is an instruction address for serialization.
13241 @end deftypefn
13243 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13244 Insert an ISB instruction into the instruction stream.
13245 @end deftypefn
13247 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13248 Return the content of a system register which is mapped by @var{sr}.
13249 @end deftypefn
13251 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13252 Return the content of a user space register which is mapped by @var{usr}.
13253 @end deftypefn
13255 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13256 Move the @var{value} to a system register which is mapped by @var{sr}.
13257 @end deftypefn
13259 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13260 Move the @var{value} to a user space register which is mapped by @var{usr}.
13261 @end deftypefn
13263 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13264 Enable global interrupt.
13265 @end deftypefn
13267 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13268 Disable global interrupt.
13269 @end deftypefn
13271 @node picoChip Built-in Functions
13272 @subsection picoChip Built-in Functions
13274 GCC provides an interface to selected machine instructions from the
13275 picoChip instruction set.
13277 @table @code
13278 @item int __builtin_sbc (int @var{value})
13279 Sign bit count.  Return the number of consecutive bits in @var{value}
13280 that have the same value as the sign bit.  The result is the number of
13281 leading sign bits minus one, giving the number of redundant sign bits in
13282 @var{value}.
13284 @item int __builtin_byteswap (int @var{value})
13285 Byte swap.  Return the result of swapping the upper and lower bytes of
13286 @var{value}.
13288 @item int __builtin_brev (int @var{value})
13289 Bit reversal.  Return the result of reversing the bits in
13290 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13291 and so on.
13293 @item int __builtin_adds (int @var{x}, int @var{y})
13294 Saturating addition.  Return the result of adding @var{x} and @var{y},
13295 storing the value 32767 if the result overflows.
13297 @item int __builtin_subs (int @var{x}, int @var{y})
13298 Saturating subtraction.  Return the result of subtracting @var{y} from
13299 @var{x}, storing the value @minus{}32768 if the result overflows.
13301 @item void __builtin_halt (void)
13302 Halt.  The processor stops execution.  This built-in is useful for
13303 implementing assertions.
13305 @end table
13307 @node PowerPC Built-in Functions
13308 @subsection PowerPC Built-in Functions
13310 These built-in functions are available for the PowerPC family of
13311 processors:
13312 @smallexample
13313 float __builtin_recipdivf (float, float);
13314 float __builtin_rsqrtf (float);
13315 double __builtin_recipdiv (double, double);
13316 double __builtin_rsqrt (double);
13317 uint64_t __builtin_ppc_get_timebase ();
13318 unsigned long __builtin_ppc_mftb ();
13319 double __builtin_unpack_longdouble (long double, int);
13320 long double __builtin_pack_longdouble (double, double);
13321 @end smallexample
13323 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13324 @code{__builtin_rsqrtf} functions generate multiple instructions to
13325 implement the reciprocal sqrt functionality using reciprocal sqrt
13326 estimate instructions.
13328 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13329 functions generate multiple instructions to implement division using
13330 the reciprocal estimate instructions.
13332 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13333 functions generate instructions to read the Time Base Register.  The
13334 @code{__builtin_ppc_get_timebase} function may generate multiple
13335 instructions and always returns the 64 bits of the Time Base Register.
13336 The @code{__builtin_ppc_mftb} function always generates one instruction and
13337 returns the Time Base Register value as an unsigned long, throwing away
13338 the most significant word on 32-bit environments.
13340 The following built-in functions are available for the PowerPC family
13341 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13342 or @option{-mpopcntd}):
13343 @smallexample
13344 long __builtin_bpermd (long, long);
13345 int __builtin_divwe (int, int);
13346 int __builtin_divweo (int, int);
13347 unsigned int __builtin_divweu (unsigned int, unsigned int);
13348 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13349 long __builtin_divde (long, long);
13350 long __builtin_divdeo (long, long);
13351 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13352 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13353 unsigned int cdtbcd (unsigned int);
13354 unsigned int cbcdtd (unsigned int);
13355 unsigned int addg6s (unsigned int, unsigned int);
13356 @end smallexample
13358 The @code{__builtin_divde}, @code{__builtin_divdeo},
13359 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13360 64-bit environment support ISA 2.06 or later.
13362 The following built-in functions are available for the PowerPC family
13363 of processors when hardware decimal floating point
13364 (@option{-mhard-dfp}) is available:
13365 @smallexample
13366 _Decimal64 __builtin_dxex (_Decimal64);
13367 _Decimal128 __builtin_dxexq (_Decimal128);
13368 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13369 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13370 _Decimal64 __builtin_denbcd (int, _Decimal64);
13371 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13372 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13373 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13374 _Decimal64 __builtin_dscli (_Decimal64, int);
13375 _Decimal128 __builtin_dscliq (_Decimal128, int);
13376 _Decimal64 __builtin_dscri (_Decimal64, int);
13377 _Decimal128 __builtin_dscriq (_Decimal128, int);
13378 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13379 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13380 @end smallexample
13382 The following built-in functions are available for the PowerPC family
13383 of processors when the Vector Scalar (vsx) instruction set is
13384 available:
13385 @smallexample
13386 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13387 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13388                                                 unsigned long long);
13389 @end smallexample
13391 @node PowerPC AltiVec/VSX Built-in Functions
13392 @subsection PowerPC AltiVec Built-in Functions
13394 GCC provides an interface for the PowerPC family of processors to access
13395 the AltiVec operations described in Motorola's AltiVec Programming
13396 Interface Manual.  The interface is made available by including
13397 @code{<altivec.h>} and using @option{-maltivec} and
13398 @option{-mabi=altivec}.  The interface supports the following vector
13399 types.
13401 @smallexample
13402 vector unsigned char
13403 vector signed char
13404 vector bool char
13406 vector unsigned short
13407 vector signed short
13408 vector bool short
13409 vector pixel
13411 vector unsigned int
13412 vector signed int
13413 vector bool int
13414 vector float
13415 @end smallexample
13417 If @option{-mvsx} is used the following additional vector types are
13418 implemented.
13420 @smallexample
13421 vector unsigned long
13422 vector signed long
13423 vector double
13424 @end smallexample
13426 The long types are only implemented for 64-bit code generation, and
13427 the long type is only used in the floating point/integer conversion
13428 instructions.
13430 GCC's implementation of the high-level language interface available from
13431 C and C++ code differs from Motorola's documentation in several ways.
13433 @itemize @bullet
13435 @item
13436 A vector constant is a list of constant expressions within curly braces.
13438 @item
13439 A vector initializer requires no cast if the vector constant is of the
13440 same type as the variable it is initializing.
13442 @item
13443 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13444 vector type is the default signedness of the base type.  The default
13445 varies depending on the operating system, so a portable program should
13446 always specify the signedness.
13448 @item
13449 Compiling with @option{-maltivec} adds keywords @code{__vector},
13450 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13451 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13452 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13453 disabled.  To use them, you must include @code{<altivec.h>} instead.
13455 @item
13456 GCC allows using a @code{typedef} name as the type specifier for a
13457 vector type.
13459 @item
13460 For C, overloaded functions are implemented with macros so the following
13461 does not work:
13463 @smallexample
13464   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13465 @end smallexample
13467 @noindent
13468 Since @code{vec_add} is a macro, the vector constant in the example
13469 is treated as four separate arguments.  Wrap the entire argument in
13470 parentheses for this to work.
13471 @end itemize
13473 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13474 Internally, GCC uses built-in functions to achieve the functionality in
13475 the aforementioned header file, but they are not supported and are
13476 subject to change without notice.
13478 The following interfaces are supported for the generic and specific
13479 AltiVec operations and the AltiVec predicates.  In cases where there
13480 is a direct mapping between generic and specific operations, only the
13481 generic names are shown here, although the specific operations can also
13482 be used.
13484 Arguments that are documented as @code{const int} require literal
13485 integral values within the range required for that operation.
13487 @smallexample
13488 vector signed char vec_abs (vector signed char);
13489 vector signed short vec_abs (vector signed short);
13490 vector signed int vec_abs (vector signed int);
13491 vector float vec_abs (vector float);
13493 vector signed char vec_abss (vector signed char);
13494 vector signed short vec_abss (vector signed short);
13495 vector signed int vec_abss (vector signed int);
13497 vector signed char vec_add (vector bool char, vector signed char);
13498 vector signed char vec_add (vector signed char, vector bool char);
13499 vector signed char vec_add (vector signed char, vector signed char);
13500 vector unsigned char vec_add (vector bool char, vector unsigned char);
13501 vector unsigned char vec_add (vector unsigned char, vector bool char);
13502 vector unsigned char vec_add (vector unsigned char,
13503                               vector unsigned char);
13504 vector signed short vec_add (vector bool short, vector signed short);
13505 vector signed short vec_add (vector signed short, vector bool short);
13506 vector signed short vec_add (vector signed short, vector signed short);
13507 vector unsigned short vec_add (vector bool short,
13508                                vector unsigned short);
13509 vector unsigned short vec_add (vector unsigned short,
13510                                vector bool short);
13511 vector unsigned short vec_add (vector unsigned short,
13512                                vector unsigned short);
13513 vector signed int vec_add (vector bool int, vector signed int);
13514 vector signed int vec_add (vector signed int, vector bool int);
13515 vector signed int vec_add (vector signed int, vector signed int);
13516 vector unsigned int vec_add (vector bool int, vector unsigned int);
13517 vector unsigned int vec_add (vector unsigned int, vector bool int);
13518 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13519 vector float vec_add (vector float, vector float);
13521 vector float vec_vaddfp (vector float, vector float);
13523 vector signed int vec_vadduwm (vector bool int, vector signed int);
13524 vector signed int vec_vadduwm (vector signed int, vector bool int);
13525 vector signed int vec_vadduwm (vector signed int, vector signed int);
13526 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13527 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13528 vector unsigned int vec_vadduwm (vector unsigned int,
13529                                  vector unsigned int);
13531 vector signed short vec_vadduhm (vector bool short,
13532                                  vector signed short);
13533 vector signed short vec_vadduhm (vector signed short,
13534                                  vector bool short);
13535 vector signed short vec_vadduhm (vector signed short,
13536                                  vector signed short);
13537 vector unsigned short vec_vadduhm (vector bool short,
13538                                    vector unsigned short);
13539 vector unsigned short vec_vadduhm (vector unsigned short,
13540                                    vector bool short);
13541 vector unsigned short vec_vadduhm (vector unsigned short,
13542                                    vector unsigned short);
13544 vector signed char vec_vaddubm (vector bool char, vector signed char);
13545 vector signed char vec_vaddubm (vector signed char, vector bool char);
13546 vector signed char vec_vaddubm (vector signed char, vector signed char);
13547 vector unsigned char vec_vaddubm (vector bool char,
13548                                   vector unsigned char);
13549 vector unsigned char vec_vaddubm (vector unsigned char,
13550                                   vector bool char);
13551 vector unsigned char vec_vaddubm (vector unsigned char,
13552                                   vector unsigned char);
13554 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13556 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13557 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13558 vector unsigned char vec_adds (vector unsigned char,
13559                                vector unsigned char);
13560 vector signed char vec_adds (vector bool char, vector signed char);
13561 vector signed char vec_adds (vector signed char, vector bool char);
13562 vector signed char vec_adds (vector signed char, vector signed char);
13563 vector unsigned short vec_adds (vector bool short,
13564                                 vector unsigned short);
13565 vector unsigned short vec_adds (vector unsigned short,
13566                                 vector bool short);
13567 vector unsigned short vec_adds (vector unsigned short,
13568                                 vector unsigned short);
13569 vector signed short vec_adds (vector bool short, vector signed short);
13570 vector signed short vec_adds (vector signed short, vector bool short);
13571 vector signed short vec_adds (vector signed short, vector signed short);
13572 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13573 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13574 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13575 vector signed int vec_adds (vector bool int, vector signed int);
13576 vector signed int vec_adds (vector signed int, vector bool int);
13577 vector signed int vec_adds (vector signed int, vector signed int);
13579 vector signed int vec_vaddsws (vector bool int, vector signed int);
13580 vector signed int vec_vaddsws (vector signed int, vector bool int);
13581 vector signed int vec_vaddsws (vector signed int, vector signed int);
13583 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13584 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13585 vector unsigned int vec_vadduws (vector unsigned int,
13586                                  vector unsigned int);
13588 vector signed short vec_vaddshs (vector bool short,
13589                                  vector signed short);
13590 vector signed short vec_vaddshs (vector signed short,
13591                                  vector bool short);
13592 vector signed short vec_vaddshs (vector signed short,
13593                                  vector signed short);
13595 vector unsigned short vec_vadduhs (vector bool short,
13596                                    vector unsigned short);
13597 vector unsigned short vec_vadduhs (vector unsigned short,
13598                                    vector bool short);
13599 vector unsigned short vec_vadduhs (vector unsigned short,
13600                                    vector unsigned short);
13602 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13603 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13604 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13606 vector unsigned char vec_vaddubs (vector bool char,
13607                                   vector unsigned char);
13608 vector unsigned char vec_vaddubs (vector unsigned char,
13609                                   vector bool char);
13610 vector unsigned char vec_vaddubs (vector unsigned char,
13611                                   vector unsigned char);
13613 vector float vec_and (vector float, vector float);
13614 vector float vec_and (vector float, vector bool int);
13615 vector float vec_and (vector bool int, vector float);
13616 vector bool int vec_and (vector bool int, vector bool int);
13617 vector signed int vec_and (vector bool int, vector signed int);
13618 vector signed int vec_and (vector signed int, vector bool int);
13619 vector signed int vec_and (vector signed int, vector signed int);
13620 vector unsigned int vec_and (vector bool int, vector unsigned int);
13621 vector unsigned int vec_and (vector unsigned int, vector bool int);
13622 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13623 vector bool short vec_and (vector bool short, vector bool short);
13624 vector signed short vec_and (vector bool short, vector signed short);
13625 vector signed short vec_and (vector signed short, vector bool short);
13626 vector signed short vec_and (vector signed short, vector signed short);
13627 vector unsigned short vec_and (vector bool short,
13628                                vector unsigned short);
13629 vector unsigned short vec_and (vector unsigned short,
13630                                vector bool short);
13631 vector unsigned short vec_and (vector unsigned short,
13632                                vector unsigned short);
13633 vector signed char vec_and (vector bool char, vector signed char);
13634 vector bool char vec_and (vector bool char, vector bool char);
13635 vector signed char vec_and (vector signed char, vector bool char);
13636 vector signed char vec_and (vector signed char, vector signed char);
13637 vector unsigned char vec_and (vector bool char, vector unsigned char);
13638 vector unsigned char vec_and (vector unsigned char, vector bool char);
13639 vector unsigned char vec_and (vector unsigned char,
13640                               vector unsigned char);
13642 vector float vec_andc (vector float, vector float);
13643 vector float vec_andc (vector float, vector bool int);
13644 vector float vec_andc (vector bool int, vector float);
13645 vector bool int vec_andc (vector bool int, vector bool int);
13646 vector signed int vec_andc (vector bool int, vector signed int);
13647 vector signed int vec_andc (vector signed int, vector bool int);
13648 vector signed int vec_andc (vector signed int, vector signed int);
13649 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13650 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13651 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13652 vector bool short vec_andc (vector bool short, vector bool short);
13653 vector signed short vec_andc (vector bool short, vector signed short);
13654 vector signed short vec_andc (vector signed short, vector bool short);
13655 vector signed short vec_andc (vector signed short, vector signed short);
13656 vector unsigned short vec_andc (vector bool short,
13657                                 vector unsigned short);
13658 vector unsigned short vec_andc (vector unsigned short,
13659                                 vector bool short);
13660 vector unsigned short vec_andc (vector unsigned short,
13661                                 vector unsigned short);
13662 vector signed char vec_andc (vector bool char, vector signed char);
13663 vector bool char vec_andc (vector bool char, vector bool char);
13664 vector signed char vec_andc (vector signed char, vector bool char);
13665 vector signed char vec_andc (vector signed char, vector signed char);
13666 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13667 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13668 vector unsigned char vec_andc (vector unsigned char,
13669                                vector unsigned char);
13671 vector unsigned char vec_avg (vector unsigned char,
13672                               vector unsigned char);
13673 vector signed char vec_avg (vector signed char, vector signed char);
13674 vector unsigned short vec_avg (vector unsigned short,
13675                                vector unsigned short);
13676 vector signed short vec_avg (vector signed short, vector signed short);
13677 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13678 vector signed int vec_avg (vector signed int, vector signed int);
13680 vector signed int vec_vavgsw (vector signed int, vector signed int);
13682 vector unsigned int vec_vavguw (vector unsigned int,
13683                                 vector unsigned int);
13685 vector signed short vec_vavgsh (vector signed short,
13686                                 vector signed short);
13688 vector unsigned short vec_vavguh (vector unsigned short,
13689                                   vector unsigned short);
13691 vector signed char vec_vavgsb (vector signed char, vector signed char);
13693 vector unsigned char vec_vavgub (vector unsigned char,
13694                                  vector unsigned char);
13696 vector float vec_copysign (vector float);
13698 vector float vec_ceil (vector float);
13700 vector signed int vec_cmpb (vector float, vector float);
13702 vector bool char vec_cmpeq (vector signed char, vector signed char);
13703 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13704 vector bool short vec_cmpeq (vector signed short, vector signed short);
13705 vector bool short vec_cmpeq (vector unsigned short,
13706                              vector unsigned short);
13707 vector bool int vec_cmpeq (vector signed int, vector signed int);
13708 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13709 vector bool int vec_cmpeq (vector float, vector float);
13711 vector bool int vec_vcmpeqfp (vector float, vector float);
13713 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13714 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13716 vector bool short vec_vcmpequh (vector signed short,
13717                                 vector signed short);
13718 vector bool short vec_vcmpequh (vector unsigned short,
13719                                 vector unsigned short);
13721 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13722 vector bool char vec_vcmpequb (vector unsigned char,
13723                                vector unsigned char);
13725 vector bool int vec_cmpge (vector float, vector float);
13727 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13728 vector bool char vec_cmpgt (vector signed char, vector signed char);
13729 vector bool short vec_cmpgt (vector unsigned short,
13730                              vector unsigned short);
13731 vector bool short vec_cmpgt (vector signed short, vector signed short);
13732 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13733 vector bool int vec_cmpgt (vector signed int, vector signed int);
13734 vector bool int vec_cmpgt (vector float, vector float);
13736 vector bool int vec_vcmpgtfp (vector float, vector float);
13738 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13740 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13742 vector bool short vec_vcmpgtsh (vector signed short,
13743                                 vector signed short);
13745 vector bool short vec_vcmpgtuh (vector unsigned short,
13746                                 vector unsigned short);
13748 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13750 vector bool char vec_vcmpgtub (vector unsigned char,
13751                                vector unsigned char);
13753 vector bool int vec_cmple (vector float, vector float);
13755 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13756 vector bool char vec_cmplt (vector signed char, vector signed char);
13757 vector bool short vec_cmplt (vector unsigned short,
13758                              vector unsigned short);
13759 vector bool short vec_cmplt (vector signed short, vector signed short);
13760 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13761 vector bool int vec_cmplt (vector signed int, vector signed int);
13762 vector bool int vec_cmplt (vector float, vector float);
13764 vector float vec_cpsgn (vector float, vector float);
13766 vector float vec_ctf (vector unsigned int, const int);
13767 vector float vec_ctf (vector signed int, const int);
13768 vector double vec_ctf (vector unsigned long, const int);
13769 vector double vec_ctf (vector signed long, const int);
13771 vector float vec_vcfsx (vector signed int, const int);
13773 vector float vec_vcfux (vector unsigned int, const int);
13775 vector signed int vec_cts (vector float, const int);
13776 vector signed long vec_cts (vector double, const int);
13778 vector unsigned int vec_ctu (vector float, const int);
13779 vector unsigned long vec_ctu (vector double, const int);
13781 void vec_dss (const int);
13783 void vec_dssall (void);
13785 void vec_dst (const vector unsigned char *, int, const int);
13786 void vec_dst (const vector signed char *, int, const int);
13787 void vec_dst (const vector bool char *, int, const int);
13788 void vec_dst (const vector unsigned short *, int, const int);
13789 void vec_dst (const vector signed short *, int, const int);
13790 void vec_dst (const vector bool short *, int, const int);
13791 void vec_dst (const vector pixel *, int, const int);
13792 void vec_dst (const vector unsigned int *, int, const int);
13793 void vec_dst (const vector signed int *, int, const int);
13794 void vec_dst (const vector bool int *, int, const int);
13795 void vec_dst (const vector float *, int, const int);
13796 void vec_dst (const unsigned char *, int, const int);
13797 void vec_dst (const signed char *, int, const int);
13798 void vec_dst (const unsigned short *, int, const int);
13799 void vec_dst (const short *, int, const int);
13800 void vec_dst (const unsigned int *, int, const int);
13801 void vec_dst (const int *, int, const int);
13802 void vec_dst (const unsigned long *, int, const int);
13803 void vec_dst (const long *, int, const int);
13804 void vec_dst (const float *, int, const int);
13806 void vec_dstst (const vector unsigned char *, int, const int);
13807 void vec_dstst (const vector signed char *, int, const int);
13808 void vec_dstst (const vector bool char *, int, const int);
13809 void vec_dstst (const vector unsigned short *, int, const int);
13810 void vec_dstst (const vector signed short *, int, const int);
13811 void vec_dstst (const vector bool short *, int, const int);
13812 void vec_dstst (const vector pixel *, int, const int);
13813 void vec_dstst (const vector unsigned int *, int, const int);
13814 void vec_dstst (const vector signed int *, int, const int);
13815 void vec_dstst (const vector bool int *, int, const int);
13816 void vec_dstst (const vector float *, int, const int);
13817 void vec_dstst (const unsigned char *, int, const int);
13818 void vec_dstst (const signed char *, int, const int);
13819 void vec_dstst (const unsigned short *, int, const int);
13820 void vec_dstst (const short *, int, const int);
13821 void vec_dstst (const unsigned int *, int, const int);
13822 void vec_dstst (const int *, int, const int);
13823 void vec_dstst (const unsigned long *, int, const int);
13824 void vec_dstst (const long *, int, const int);
13825 void vec_dstst (const float *, int, const int);
13827 void vec_dststt (const vector unsigned char *, int, const int);
13828 void vec_dststt (const vector signed char *, int, const int);
13829 void vec_dststt (const vector bool char *, int, const int);
13830 void vec_dststt (const vector unsigned short *, int, const int);
13831 void vec_dststt (const vector signed short *, int, const int);
13832 void vec_dststt (const vector bool short *, int, const int);
13833 void vec_dststt (const vector pixel *, int, const int);
13834 void vec_dststt (const vector unsigned int *, int, const int);
13835 void vec_dststt (const vector signed int *, int, const int);
13836 void vec_dststt (const vector bool int *, int, const int);
13837 void vec_dststt (const vector float *, int, const int);
13838 void vec_dststt (const unsigned char *, int, const int);
13839 void vec_dststt (const signed char *, int, const int);
13840 void vec_dststt (const unsigned short *, int, const int);
13841 void vec_dststt (const short *, int, const int);
13842 void vec_dststt (const unsigned int *, int, const int);
13843 void vec_dststt (const int *, int, const int);
13844 void vec_dststt (const unsigned long *, int, const int);
13845 void vec_dststt (const long *, int, const int);
13846 void vec_dststt (const float *, int, const int);
13848 void vec_dstt (const vector unsigned char *, int, const int);
13849 void vec_dstt (const vector signed char *, int, const int);
13850 void vec_dstt (const vector bool char *, int, const int);
13851 void vec_dstt (const vector unsigned short *, int, const int);
13852 void vec_dstt (const vector signed short *, int, const int);
13853 void vec_dstt (const vector bool short *, int, const int);
13854 void vec_dstt (const vector pixel *, int, const int);
13855 void vec_dstt (const vector unsigned int *, int, const int);
13856 void vec_dstt (const vector signed int *, int, const int);
13857 void vec_dstt (const vector bool int *, int, const int);
13858 void vec_dstt (const vector float *, int, const int);
13859 void vec_dstt (const unsigned char *, int, const int);
13860 void vec_dstt (const signed char *, int, const int);
13861 void vec_dstt (const unsigned short *, int, const int);
13862 void vec_dstt (const short *, int, const int);
13863 void vec_dstt (const unsigned int *, int, const int);
13864 void vec_dstt (const int *, int, const int);
13865 void vec_dstt (const unsigned long *, int, const int);
13866 void vec_dstt (const long *, int, const int);
13867 void vec_dstt (const float *, int, const int);
13869 vector float vec_expte (vector float);
13871 vector float vec_floor (vector float);
13873 vector float vec_ld (int, const vector float *);
13874 vector float vec_ld (int, const float *);
13875 vector bool int vec_ld (int, const vector bool int *);
13876 vector signed int vec_ld (int, const vector signed int *);
13877 vector signed int vec_ld (int, const int *);
13878 vector signed int vec_ld (int, const long *);
13879 vector unsigned int vec_ld (int, const vector unsigned int *);
13880 vector unsigned int vec_ld (int, const unsigned int *);
13881 vector unsigned int vec_ld (int, const unsigned long *);
13882 vector bool short vec_ld (int, const vector bool short *);
13883 vector pixel vec_ld (int, const vector pixel *);
13884 vector signed short vec_ld (int, const vector signed short *);
13885 vector signed short vec_ld (int, const short *);
13886 vector unsigned short vec_ld (int, const vector unsigned short *);
13887 vector unsigned short vec_ld (int, const unsigned short *);
13888 vector bool char vec_ld (int, const vector bool char *);
13889 vector signed char vec_ld (int, const vector signed char *);
13890 vector signed char vec_ld (int, const signed char *);
13891 vector unsigned char vec_ld (int, const vector unsigned char *);
13892 vector unsigned char vec_ld (int, const unsigned char *);
13894 vector signed char vec_lde (int, const signed char *);
13895 vector unsigned char vec_lde (int, const unsigned char *);
13896 vector signed short vec_lde (int, const short *);
13897 vector unsigned short vec_lde (int, const unsigned short *);
13898 vector float vec_lde (int, const float *);
13899 vector signed int vec_lde (int, const int *);
13900 vector unsigned int vec_lde (int, const unsigned int *);
13901 vector signed int vec_lde (int, const long *);
13902 vector unsigned int vec_lde (int, const unsigned long *);
13904 vector float vec_lvewx (int, float *);
13905 vector signed int vec_lvewx (int, int *);
13906 vector unsigned int vec_lvewx (int, unsigned int *);
13907 vector signed int vec_lvewx (int, long *);
13908 vector unsigned int vec_lvewx (int, unsigned long *);
13910 vector signed short vec_lvehx (int, short *);
13911 vector unsigned short vec_lvehx (int, unsigned short *);
13913 vector signed char vec_lvebx (int, char *);
13914 vector unsigned char vec_lvebx (int, unsigned char *);
13916 vector float vec_ldl (int, const vector float *);
13917 vector float vec_ldl (int, const float *);
13918 vector bool int vec_ldl (int, const vector bool int *);
13919 vector signed int vec_ldl (int, const vector signed int *);
13920 vector signed int vec_ldl (int, const int *);
13921 vector signed int vec_ldl (int, const long *);
13922 vector unsigned int vec_ldl (int, const vector unsigned int *);
13923 vector unsigned int vec_ldl (int, const unsigned int *);
13924 vector unsigned int vec_ldl (int, const unsigned long *);
13925 vector bool short vec_ldl (int, const vector bool short *);
13926 vector pixel vec_ldl (int, const vector pixel *);
13927 vector signed short vec_ldl (int, const vector signed short *);
13928 vector signed short vec_ldl (int, const short *);
13929 vector unsigned short vec_ldl (int, const vector unsigned short *);
13930 vector unsigned short vec_ldl (int, const unsigned short *);
13931 vector bool char vec_ldl (int, const vector bool char *);
13932 vector signed char vec_ldl (int, const vector signed char *);
13933 vector signed char vec_ldl (int, const signed char *);
13934 vector unsigned char vec_ldl (int, const vector unsigned char *);
13935 vector unsigned char vec_ldl (int, const unsigned char *);
13937 vector float vec_loge (vector float);
13939 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13940 vector unsigned char vec_lvsl (int, const volatile signed char *);
13941 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13942 vector unsigned char vec_lvsl (int, const volatile short *);
13943 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13944 vector unsigned char vec_lvsl (int, const volatile int *);
13945 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13946 vector unsigned char vec_lvsl (int, const volatile long *);
13947 vector unsigned char vec_lvsl (int, const volatile float *);
13949 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13950 vector unsigned char vec_lvsr (int, const volatile signed char *);
13951 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13952 vector unsigned char vec_lvsr (int, const volatile short *);
13953 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13954 vector unsigned char vec_lvsr (int, const volatile int *);
13955 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13956 vector unsigned char vec_lvsr (int, const volatile long *);
13957 vector unsigned char vec_lvsr (int, const volatile float *);
13959 vector float vec_madd (vector float, vector float, vector float);
13961 vector signed short vec_madds (vector signed short,
13962                                vector signed short,
13963                                vector signed short);
13965 vector unsigned char vec_max (vector bool char, vector unsigned char);
13966 vector unsigned char vec_max (vector unsigned char, vector bool char);
13967 vector unsigned char vec_max (vector unsigned char,
13968                               vector unsigned char);
13969 vector signed char vec_max (vector bool char, vector signed char);
13970 vector signed char vec_max (vector signed char, vector bool char);
13971 vector signed char vec_max (vector signed char, vector signed char);
13972 vector unsigned short vec_max (vector bool short,
13973                                vector unsigned short);
13974 vector unsigned short vec_max (vector unsigned short,
13975                                vector bool short);
13976 vector unsigned short vec_max (vector unsigned short,
13977                                vector unsigned short);
13978 vector signed short vec_max (vector bool short, vector signed short);
13979 vector signed short vec_max (vector signed short, vector bool short);
13980 vector signed short vec_max (vector signed short, vector signed short);
13981 vector unsigned int vec_max (vector bool int, vector unsigned int);
13982 vector unsigned int vec_max (vector unsigned int, vector bool int);
13983 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13984 vector signed int vec_max (vector bool int, vector signed int);
13985 vector signed int vec_max (vector signed int, vector bool int);
13986 vector signed int vec_max (vector signed int, vector signed int);
13987 vector float vec_max (vector float, vector float);
13989 vector float vec_vmaxfp (vector float, vector float);
13991 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13992 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13993 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13995 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13996 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13997 vector unsigned int vec_vmaxuw (vector unsigned int,
13998                                 vector unsigned int);
14000 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14001 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14002 vector signed short vec_vmaxsh (vector signed short,
14003                                 vector signed short);
14005 vector unsigned short vec_vmaxuh (vector bool short,
14006                                   vector unsigned short);
14007 vector unsigned short vec_vmaxuh (vector unsigned short,
14008                                   vector bool short);
14009 vector unsigned short vec_vmaxuh (vector unsigned short,
14010                                   vector unsigned short);
14012 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14013 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14014 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14016 vector unsigned char vec_vmaxub (vector bool char,
14017                                  vector unsigned char);
14018 vector unsigned char vec_vmaxub (vector unsigned char,
14019                                  vector bool char);
14020 vector unsigned char vec_vmaxub (vector unsigned char,
14021                                  vector unsigned char);
14023 vector bool char vec_mergeh (vector bool char, vector bool char);
14024 vector signed char vec_mergeh (vector signed char, vector signed char);
14025 vector unsigned char vec_mergeh (vector unsigned char,
14026                                  vector unsigned char);
14027 vector bool short vec_mergeh (vector bool short, vector bool short);
14028 vector pixel vec_mergeh (vector pixel, vector pixel);
14029 vector signed short vec_mergeh (vector signed short,
14030                                 vector signed short);
14031 vector unsigned short vec_mergeh (vector unsigned short,
14032                                   vector unsigned short);
14033 vector float vec_mergeh (vector float, vector float);
14034 vector bool int vec_mergeh (vector bool int, vector bool int);
14035 vector signed int vec_mergeh (vector signed int, vector signed int);
14036 vector unsigned int vec_mergeh (vector unsigned int,
14037                                 vector unsigned int);
14039 vector float vec_vmrghw (vector float, vector float);
14040 vector bool int vec_vmrghw (vector bool int, vector bool int);
14041 vector signed int vec_vmrghw (vector signed int, vector signed int);
14042 vector unsigned int vec_vmrghw (vector unsigned int,
14043                                 vector unsigned int);
14045 vector bool short vec_vmrghh (vector bool short, vector bool short);
14046 vector signed short vec_vmrghh (vector signed short,
14047                                 vector signed short);
14048 vector unsigned short vec_vmrghh (vector unsigned short,
14049                                   vector unsigned short);
14050 vector pixel vec_vmrghh (vector pixel, vector pixel);
14052 vector bool char vec_vmrghb (vector bool char, vector bool char);
14053 vector signed char vec_vmrghb (vector signed char, vector signed char);
14054 vector unsigned char vec_vmrghb (vector unsigned char,
14055                                  vector unsigned char);
14057 vector bool char vec_mergel (vector bool char, vector bool char);
14058 vector signed char vec_mergel (vector signed char, vector signed char);
14059 vector unsigned char vec_mergel (vector unsigned char,
14060                                  vector unsigned char);
14061 vector bool short vec_mergel (vector bool short, vector bool short);
14062 vector pixel vec_mergel (vector pixel, vector pixel);
14063 vector signed short vec_mergel (vector signed short,
14064                                 vector signed short);
14065 vector unsigned short vec_mergel (vector unsigned short,
14066                                   vector unsigned short);
14067 vector float vec_mergel (vector float, vector float);
14068 vector bool int vec_mergel (vector bool int, vector bool int);
14069 vector signed int vec_mergel (vector signed int, vector signed int);
14070 vector unsigned int vec_mergel (vector unsigned int,
14071                                 vector unsigned int);
14073 vector float vec_vmrglw (vector float, vector float);
14074 vector signed int vec_vmrglw (vector signed int, vector signed int);
14075 vector unsigned int vec_vmrglw (vector unsigned int,
14076                                 vector unsigned int);
14077 vector bool int vec_vmrglw (vector bool int, vector bool int);
14079 vector bool short vec_vmrglh (vector bool short, vector bool short);
14080 vector signed short vec_vmrglh (vector signed short,
14081                                 vector signed short);
14082 vector unsigned short vec_vmrglh (vector unsigned short,
14083                                   vector unsigned short);
14084 vector pixel vec_vmrglh (vector pixel, vector pixel);
14086 vector bool char vec_vmrglb (vector bool char, vector bool char);
14087 vector signed char vec_vmrglb (vector signed char, vector signed char);
14088 vector unsigned char vec_vmrglb (vector unsigned char,
14089                                  vector unsigned char);
14091 vector unsigned short vec_mfvscr (void);
14093 vector unsigned char vec_min (vector bool char, vector unsigned char);
14094 vector unsigned char vec_min (vector unsigned char, vector bool char);
14095 vector unsigned char vec_min (vector unsigned char,
14096                               vector unsigned char);
14097 vector signed char vec_min (vector bool char, vector signed char);
14098 vector signed char vec_min (vector signed char, vector bool char);
14099 vector signed char vec_min (vector signed char, vector signed char);
14100 vector unsigned short vec_min (vector bool short,
14101                                vector unsigned short);
14102 vector unsigned short vec_min (vector unsigned short,
14103                                vector bool short);
14104 vector unsigned short vec_min (vector unsigned short,
14105                                vector unsigned short);
14106 vector signed short vec_min (vector bool short, vector signed short);
14107 vector signed short vec_min (vector signed short, vector bool short);
14108 vector signed short vec_min (vector signed short, vector signed short);
14109 vector unsigned int vec_min (vector bool int, vector unsigned int);
14110 vector unsigned int vec_min (vector unsigned int, vector bool int);
14111 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14112 vector signed int vec_min (vector bool int, vector signed int);
14113 vector signed int vec_min (vector signed int, vector bool int);
14114 vector signed int vec_min (vector signed int, vector signed int);
14115 vector float vec_min (vector float, vector float);
14117 vector float vec_vminfp (vector float, vector float);
14119 vector signed int vec_vminsw (vector bool int, vector signed int);
14120 vector signed int vec_vminsw (vector signed int, vector bool int);
14121 vector signed int vec_vminsw (vector signed int, vector signed int);
14123 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14124 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14125 vector unsigned int vec_vminuw (vector unsigned int,
14126                                 vector unsigned int);
14128 vector signed short vec_vminsh (vector bool short, vector signed short);
14129 vector signed short vec_vminsh (vector signed short, vector bool short);
14130 vector signed short vec_vminsh (vector signed short,
14131                                 vector signed short);
14133 vector unsigned short vec_vminuh (vector bool short,
14134                                   vector unsigned short);
14135 vector unsigned short vec_vminuh (vector unsigned short,
14136                                   vector bool short);
14137 vector unsigned short vec_vminuh (vector unsigned short,
14138                                   vector unsigned short);
14140 vector signed char vec_vminsb (vector bool char, vector signed char);
14141 vector signed char vec_vminsb (vector signed char, vector bool char);
14142 vector signed char vec_vminsb (vector signed char, vector signed char);
14144 vector unsigned char vec_vminub (vector bool char,
14145                                  vector unsigned char);
14146 vector unsigned char vec_vminub (vector unsigned char,
14147                                  vector bool char);
14148 vector unsigned char vec_vminub (vector unsigned char,
14149                                  vector unsigned char);
14151 vector signed short vec_mladd (vector signed short,
14152                                vector signed short,
14153                                vector signed short);
14154 vector signed short vec_mladd (vector signed short,
14155                                vector unsigned short,
14156                                vector unsigned short);
14157 vector signed short vec_mladd (vector unsigned short,
14158                                vector signed short,
14159                                vector signed short);
14160 vector unsigned short vec_mladd (vector unsigned short,
14161                                  vector unsigned short,
14162                                  vector unsigned short);
14164 vector signed short vec_mradds (vector signed short,
14165                                 vector signed short,
14166                                 vector signed short);
14168 vector unsigned int vec_msum (vector unsigned char,
14169                               vector unsigned char,
14170                               vector unsigned int);
14171 vector signed int vec_msum (vector signed char,
14172                             vector unsigned char,
14173                             vector signed int);
14174 vector unsigned int vec_msum (vector unsigned short,
14175                               vector unsigned short,
14176                               vector unsigned int);
14177 vector signed int vec_msum (vector signed short,
14178                             vector signed short,
14179                             vector signed int);
14181 vector signed int vec_vmsumshm (vector signed short,
14182                                 vector signed short,
14183                                 vector signed int);
14185 vector unsigned int vec_vmsumuhm (vector unsigned short,
14186                                   vector unsigned short,
14187                                   vector unsigned int);
14189 vector signed int vec_vmsummbm (vector signed char,
14190                                 vector unsigned char,
14191                                 vector signed int);
14193 vector unsigned int vec_vmsumubm (vector unsigned char,
14194                                   vector unsigned char,
14195                                   vector unsigned int);
14197 vector unsigned int vec_msums (vector unsigned short,
14198                                vector unsigned short,
14199                                vector unsigned int);
14200 vector signed int vec_msums (vector signed short,
14201                              vector signed short,
14202                              vector signed int);
14204 vector signed int vec_vmsumshs (vector signed short,
14205                                 vector signed short,
14206                                 vector signed int);
14208 vector unsigned int vec_vmsumuhs (vector unsigned short,
14209                                   vector unsigned short,
14210                                   vector unsigned int);
14212 void vec_mtvscr (vector signed int);
14213 void vec_mtvscr (vector unsigned int);
14214 void vec_mtvscr (vector bool int);
14215 void vec_mtvscr (vector signed short);
14216 void vec_mtvscr (vector unsigned short);
14217 void vec_mtvscr (vector bool short);
14218 void vec_mtvscr (vector pixel);
14219 void vec_mtvscr (vector signed char);
14220 void vec_mtvscr (vector unsigned char);
14221 void vec_mtvscr (vector bool char);
14223 vector unsigned short vec_mule (vector unsigned char,
14224                                 vector unsigned char);
14225 vector signed short vec_mule (vector signed char,
14226                               vector signed char);
14227 vector unsigned int vec_mule (vector unsigned short,
14228                               vector unsigned short);
14229 vector signed int vec_mule (vector signed short, vector signed short);
14231 vector signed int vec_vmulesh (vector signed short,
14232                                vector signed short);
14234 vector unsigned int vec_vmuleuh (vector unsigned short,
14235                                  vector unsigned short);
14237 vector signed short vec_vmulesb (vector signed char,
14238                                  vector signed char);
14240 vector unsigned short vec_vmuleub (vector unsigned char,
14241                                   vector unsigned char);
14243 vector unsigned short vec_mulo (vector unsigned char,
14244                                 vector unsigned char);
14245 vector signed short vec_mulo (vector signed char, vector signed char);
14246 vector unsigned int vec_mulo (vector unsigned short,
14247                               vector unsigned short);
14248 vector signed int vec_mulo (vector signed short, vector signed short);
14250 vector signed int vec_vmulosh (vector signed short,
14251                                vector signed short);
14253 vector unsigned int vec_vmulouh (vector unsigned short,
14254                                  vector unsigned short);
14256 vector signed short vec_vmulosb (vector signed char,
14257                                  vector signed char);
14259 vector unsigned short vec_vmuloub (vector unsigned char,
14260                                    vector unsigned char);
14262 vector float vec_nmsub (vector float, vector float, vector float);
14264 vector float vec_nor (vector float, vector float);
14265 vector signed int vec_nor (vector signed int, vector signed int);
14266 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14267 vector bool int vec_nor (vector bool int, vector bool int);
14268 vector signed short vec_nor (vector signed short, vector signed short);
14269 vector unsigned short vec_nor (vector unsigned short,
14270                                vector unsigned short);
14271 vector bool short vec_nor (vector bool short, vector bool short);
14272 vector signed char vec_nor (vector signed char, vector signed char);
14273 vector unsigned char vec_nor (vector unsigned char,
14274                               vector unsigned char);
14275 vector bool char vec_nor (vector bool char, vector bool char);
14277 vector float vec_or (vector float, vector float);
14278 vector float vec_or (vector float, vector bool int);
14279 vector float vec_or (vector bool int, vector float);
14280 vector bool int vec_or (vector bool int, vector bool int);
14281 vector signed int vec_or (vector bool int, vector signed int);
14282 vector signed int vec_or (vector signed int, vector bool int);
14283 vector signed int vec_or (vector signed int, vector signed int);
14284 vector unsigned int vec_or (vector bool int, vector unsigned int);
14285 vector unsigned int vec_or (vector unsigned int, vector bool int);
14286 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14287 vector bool short vec_or (vector bool short, vector bool short);
14288 vector signed short vec_or (vector bool short, vector signed short);
14289 vector signed short vec_or (vector signed short, vector bool short);
14290 vector signed short vec_or (vector signed short, vector signed short);
14291 vector unsigned short vec_or (vector bool short, vector unsigned short);
14292 vector unsigned short vec_or (vector unsigned short, vector bool short);
14293 vector unsigned short vec_or (vector unsigned short,
14294                               vector unsigned short);
14295 vector signed char vec_or (vector bool char, vector signed char);
14296 vector bool char vec_or (vector bool char, vector bool char);
14297 vector signed char vec_or (vector signed char, vector bool char);
14298 vector signed char vec_or (vector signed char, vector signed char);
14299 vector unsigned char vec_or (vector bool char, vector unsigned char);
14300 vector unsigned char vec_or (vector unsigned char, vector bool char);
14301 vector unsigned char vec_or (vector unsigned char,
14302                              vector unsigned char);
14304 vector signed char vec_pack (vector signed short, vector signed short);
14305 vector unsigned char vec_pack (vector unsigned short,
14306                                vector unsigned short);
14307 vector bool char vec_pack (vector bool short, vector bool short);
14308 vector signed short vec_pack (vector signed int, vector signed int);
14309 vector unsigned short vec_pack (vector unsigned int,
14310                                 vector unsigned int);
14311 vector bool short vec_pack (vector bool int, vector bool int);
14313 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14314 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14315 vector unsigned short vec_vpkuwum (vector unsigned int,
14316                                    vector unsigned int);
14318 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14319 vector signed char vec_vpkuhum (vector signed short,
14320                                 vector signed short);
14321 vector unsigned char vec_vpkuhum (vector unsigned short,
14322                                   vector unsigned short);
14324 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14326 vector unsigned char vec_packs (vector unsigned short,
14327                                 vector unsigned short);
14328 vector signed char vec_packs (vector signed short, vector signed short);
14329 vector unsigned short vec_packs (vector unsigned int,
14330                                  vector unsigned int);
14331 vector signed short vec_packs (vector signed int, vector signed int);
14333 vector signed short vec_vpkswss (vector signed int, vector signed int);
14335 vector unsigned short vec_vpkuwus (vector unsigned int,
14336                                    vector unsigned int);
14338 vector signed char vec_vpkshss (vector signed short,
14339                                 vector signed short);
14341 vector unsigned char vec_vpkuhus (vector unsigned short,
14342                                   vector unsigned short);
14344 vector unsigned char vec_packsu (vector unsigned short,
14345                                  vector unsigned short);
14346 vector unsigned char vec_packsu (vector signed short,
14347                                  vector signed short);
14348 vector unsigned short vec_packsu (vector unsigned int,
14349                                   vector unsigned int);
14350 vector unsigned short vec_packsu (vector signed int, vector signed int);
14352 vector unsigned short vec_vpkswus (vector signed int,
14353                                    vector signed int);
14355 vector unsigned char vec_vpkshus (vector signed short,
14356                                   vector signed short);
14358 vector float vec_perm (vector float,
14359                        vector float,
14360                        vector unsigned char);
14361 vector signed int vec_perm (vector signed int,
14362                             vector signed int,
14363                             vector unsigned char);
14364 vector unsigned int vec_perm (vector unsigned int,
14365                               vector unsigned int,
14366                               vector unsigned char);
14367 vector bool int vec_perm (vector bool int,
14368                           vector bool int,
14369                           vector unsigned char);
14370 vector signed short vec_perm (vector signed short,
14371                               vector signed short,
14372                               vector unsigned char);
14373 vector unsigned short vec_perm (vector unsigned short,
14374                                 vector unsigned short,
14375                                 vector unsigned char);
14376 vector bool short vec_perm (vector bool short,
14377                             vector bool short,
14378                             vector unsigned char);
14379 vector pixel vec_perm (vector pixel,
14380                        vector pixel,
14381                        vector unsigned char);
14382 vector signed char vec_perm (vector signed char,
14383                              vector signed char,
14384                              vector unsigned char);
14385 vector unsigned char vec_perm (vector unsigned char,
14386                                vector unsigned char,
14387                                vector unsigned char);
14388 vector bool char vec_perm (vector bool char,
14389                            vector bool char,
14390                            vector unsigned char);
14392 vector float vec_re (vector float);
14394 vector signed char vec_rl (vector signed char,
14395                            vector unsigned char);
14396 vector unsigned char vec_rl (vector unsigned char,
14397                              vector unsigned char);
14398 vector signed short vec_rl (vector signed short, vector unsigned short);
14399 vector unsigned short vec_rl (vector unsigned short,
14400                               vector unsigned short);
14401 vector signed int vec_rl (vector signed int, vector unsigned int);
14402 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14404 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14405 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14407 vector signed short vec_vrlh (vector signed short,
14408                               vector unsigned short);
14409 vector unsigned short vec_vrlh (vector unsigned short,
14410                                 vector unsigned short);
14412 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14413 vector unsigned char vec_vrlb (vector unsigned char,
14414                                vector unsigned char);
14416 vector float vec_round (vector float);
14418 vector float vec_recip (vector float, vector float);
14420 vector float vec_rsqrt (vector float);
14422 vector float vec_rsqrte (vector float);
14424 vector float vec_sel (vector float, vector float, vector bool int);
14425 vector float vec_sel (vector float, vector float, vector unsigned int);
14426 vector signed int vec_sel (vector signed int,
14427                            vector signed int,
14428                            vector bool int);
14429 vector signed int vec_sel (vector signed int,
14430                            vector signed int,
14431                            vector unsigned int);
14432 vector unsigned int vec_sel (vector unsigned int,
14433                              vector unsigned int,
14434                              vector bool int);
14435 vector unsigned int vec_sel (vector unsigned int,
14436                              vector unsigned int,
14437                              vector unsigned int);
14438 vector bool int vec_sel (vector bool int,
14439                          vector bool int,
14440                          vector bool int);
14441 vector bool int vec_sel (vector bool int,
14442                          vector bool int,
14443                          vector unsigned int);
14444 vector signed short vec_sel (vector signed short,
14445                              vector signed short,
14446                              vector bool short);
14447 vector signed short vec_sel (vector signed short,
14448                              vector signed short,
14449                              vector unsigned short);
14450 vector unsigned short vec_sel (vector unsigned short,
14451                                vector unsigned short,
14452                                vector bool short);
14453 vector unsigned short vec_sel (vector unsigned short,
14454                                vector unsigned short,
14455                                vector unsigned short);
14456 vector bool short vec_sel (vector bool short,
14457                            vector bool short,
14458                            vector bool short);
14459 vector bool short vec_sel (vector bool short,
14460                            vector bool short,
14461                            vector unsigned short);
14462 vector signed char vec_sel (vector signed char,
14463                             vector signed char,
14464                             vector bool char);
14465 vector signed char vec_sel (vector signed char,
14466                             vector signed char,
14467                             vector unsigned char);
14468 vector unsigned char vec_sel (vector unsigned char,
14469                               vector unsigned char,
14470                               vector bool char);
14471 vector unsigned char vec_sel (vector unsigned char,
14472                               vector unsigned char,
14473                               vector unsigned char);
14474 vector bool char vec_sel (vector bool char,
14475                           vector bool char,
14476                           vector bool char);
14477 vector bool char vec_sel (vector bool char,
14478                           vector bool char,
14479                           vector unsigned char);
14481 vector signed char vec_sl (vector signed char,
14482                            vector unsigned char);
14483 vector unsigned char vec_sl (vector unsigned char,
14484                              vector unsigned char);
14485 vector signed short vec_sl (vector signed short, vector unsigned short);
14486 vector unsigned short vec_sl (vector unsigned short,
14487                               vector unsigned short);
14488 vector signed int vec_sl (vector signed int, vector unsigned int);
14489 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14491 vector signed int vec_vslw (vector signed int, vector unsigned int);
14492 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14494 vector signed short vec_vslh (vector signed short,
14495                               vector unsigned short);
14496 vector unsigned short vec_vslh (vector unsigned short,
14497                                 vector unsigned short);
14499 vector signed char vec_vslb (vector signed char, vector unsigned char);
14500 vector unsigned char vec_vslb (vector unsigned char,
14501                                vector unsigned char);
14503 vector float vec_sld (vector float, vector float, const int);
14504 vector signed int vec_sld (vector signed int,
14505                            vector signed int,
14506                            const int);
14507 vector unsigned int vec_sld (vector unsigned int,
14508                              vector unsigned int,
14509                              const int);
14510 vector bool int vec_sld (vector bool int,
14511                          vector bool int,
14512                          const int);
14513 vector signed short vec_sld (vector signed short,
14514                              vector signed short,
14515                              const int);
14516 vector unsigned short vec_sld (vector unsigned short,
14517                                vector unsigned short,
14518                                const int);
14519 vector bool short vec_sld (vector bool short,
14520                            vector bool short,
14521                            const int);
14522 vector pixel vec_sld (vector pixel,
14523                       vector pixel,
14524                       const int);
14525 vector signed char vec_sld (vector signed char,
14526                             vector signed char,
14527                             const int);
14528 vector unsigned char vec_sld (vector unsigned char,
14529                               vector unsigned char,
14530                               const int);
14531 vector bool char vec_sld (vector bool char,
14532                           vector bool char,
14533                           const int);
14535 vector signed int vec_sll (vector signed int,
14536                            vector unsigned int);
14537 vector signed int vec_sll (vector signed int,
14538                            vector unsigned short);
14539 vector signed int vec_sll (vector signed int,
14540                            vector unsigned char);
14541 vector unsigned int vec_sll (vector unsigned int,
14542                              vector unsigned int);
14543 vector unsigned int vec_sll (vector unsigned int,
14544                              vector unsigned short);
14545 vector unsigned int vec_sll (vector unsigned int,
14546                              vector unsigned char);
14547 vector bool int vec_sll (vector bool int,
14548                          vector unsigned int);
14549 vector bool int vec_sll (vector bool int,
14550                          vector unsigned short);
14551 vector bool int vec_sll (vector bool int,
14552                          vector unsigned char);
14553 vector signed short vec_sll (vector signed short,
14554                              vector unsigned int);
14555 vector signed short vec_sll (vector signed short,
14556                              vector unsigned short);
14557 vector signed short vec_sll (vector signed short,
14558                              vector unsigned char);
14559 vector unsigned short vec_sll (vector unsigned short,
14560                                vector unsigned int);
14561 vector unsigned short vec_sll (vector unsigned short,
14562                                vector unsigned short);
14563 vector unsigned short vec_sll (vector unsigned short,
14564                                vector unsigned char);
14565 vector bool short vec_sll (vector bool short, vector unsigned int);
14566 vector bool short vec_sll (vector bool short, vector unsigned short);
14567 vector bool short vec_sll (vector bool short, vector unsigned char);
14568 vector pixel vec_sll (vector pixel, vector unsigned int);
14569 vector pixel vec_sll (vector pixel, vector unsigned short);
14570 vector pixel vec_sll (vector pixel, vector unsigned char);
14571 vector signed char vec_sll (vector signed char, vector unsigned int);
14572 vector signed char vec_sll (vector signed char, vector unsigned short);
14573 vector signed char vec_sll (vector signed char, vector unsigned char);
14574 vector unsigned char vec_sll (vector unsigned char,
14575                               vector unsigned int);
14576 vector unsigned char vec_sll (vector unsigned char,
14577                               vector unsigned short);
14578 vector unsigned char vec_sll (vector unsigned char,
14579                               vector unsigned char);
14580 vector bool char vec_sll (vector bool char, vector unsigned int);
14581 vector bool char vec_sll (vector bool char, vector unsigned short);
14582 vector bool char vec_sll (vector bool char, vector unsigned char);
14584 vector float vec_slo (vector float, vector signed char);
14585 vector float vec_slo (vector float, vector unsigned char);
14586 vector signed int vec_slo (vector signed int, vector signed char);
14587 vector signed int vec_slo (vector signed int, vector unsigned char);
14588 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14589 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14590 vector signed short vec_slo (vector signed short, vector signed char);
14591 vector signed short vec_slo (vector signed short, vector unsigned char);
14592 vector unsigned short vec_slo (vector unsigned short,
14593                                vector signed char);
14594 vector unsigned short vec_slo (vector unsigned short,
14595                                vector unsigned char);
14596 vector pixel vec_slo (vector pixel, vector signed char);
14597 vector pixel vec_slo (vector pixel, vector unsigned char);
14598 vector signed char vec_slo (vector signed char, vector signed char);
14599 vector signed char vec_slo (vector signed char, vector unsigned char);
14600 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14601 vector unsigned char vec_slo (vector unsigned char,
14602                               vector unsigned char);
14604 vector signed char vec_splat (vector signed char, const int);
14605 vector unsigned char vec_splat (vector unsigned char, const int);
14606 vector bool char vec_splat (vector bool char, const int);
14607 vector signed short vec_splat (vector signed short, const int);
14608 vector unsigned short vec_splat (vector unsigned short, const int);
14609 vector bool short vec_splat (vector bool short, const int);
14610 vector pixel vec_splat (vector pixel, const int);
14611 vector float vec_splat (vector float, const int);
14612 vector signed int vec_splat (vector signed int, const int);
14613 vector unsigned int vec_splat (vector unsigned int, const int);
14614 vector bool int vec_splat (vector bool int, const int);
14615 vector signed long vec_splat (vector signed long, const int);
14616 vector unsigned long vec_splat (vector unsigned long, const int);
14618 vector signed char vec_splats (signed char);
14619 vector unsigned char vec_splats (unsigned char);
14620 vector signed short vec_splats (signed short);
14621 vector unsigned short vec_splats (unsigned short);
14622 vector signed int vec_splats (signed int);
14623 vector unsigned int vec_splats (unsigned int);
14624 vector float vec_splats (float);
14626 vector float vec_vspltw (vector float, const int);
14627 vector signed int vec_vspltw (vector signed int, const int);
14628 vector unsigned int vec_vspltw (vector unsigned int, const int);
14629 vector bool int vec_vspltw (vector bool int, const int);
14631 vector bool short vec_vsplth (vector bool short, const int);
14632 vector signed short vec_vsplth (vector signed short, const int);
14633 vector unsigned short vec_vsplth (vector unsigned short, const int);
14634 vector pixel vec_vsplth (vector pixel, const int);
14636 vector signed char vec_vspltb (vector signed char, const int);
14637 vector unsigned char vec_vspltb (vector unsigned char, const int);
14638 vector bool char vec_vspltb (vector bool char, const int);
14640 vector signed char vec_splat_s8 (const int);
14642 vector signed short vec_splat_s16 (const int);
14644 vector signed int vec_splat_s32 (const int);
14646 vector unsigned char vec_splat_u8 (const int);
14648 vector unsigned short vec_splat_u16 (const int);
14650 vector unsigned int vec_splat_u32 (const int);
14652 vector signed char vec_sr (vector signed char, vector unsigned char);
14653 vector unsigned char vec_sr (vector unsigned char,
14654                              vector unsigned char);
14655 vector signed short vec_sr (vector signed short,
14656                             vector unsigned short);
14657 vector unsigned short vec_sr (vector unsigned short,
14658                               vector unsigned short);
14659 vector signed int vec_sr (vector signed int, vector unsigned int);
14660 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14662 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14663 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14665 vector signed short vec_vsrh (vector signed short,
14666                               vector unsigned short);
14667 vector unsigned short vec_vsrh (vector unsigned short,
14668                                 vector unsigned short);
14670 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14671 vector unsigned char vec_vsrb (vector unsigned char,
14672                                vector unsigned char);
14674 vector signed char vec_sra (vector signed char, vector unsigned char);
14675 vector unsigned char vec_sra (vector unsigned char,
14676                               vector unsigned char);
14677 vector signed short vec_sra (vector signed short,
14678                              vector unsigned short);
14679 vector unsigned short vec_sra (vector unsigned short,
14680                                vector unsigned short);
14681 vector signed int vec_sra (vector signed int, vector unsigned int);
14682 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14684 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14685 vector unsigned int vec_vsraw (vector unsigned int,
14686                                vector unsigned int);
14688 vector signed short vec_vsrah (vector signed short,
14689                                vector unsigned short);
14690 vector unsigned short vec_vsrah (vector unsigned short,
14691                                  vector unsigned short);
14693 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14694 vector unsigned char vec_vsrab (vector unsigned char,
14695                                 vector unsigned char);
14697 vector signed int vec_srl (vector signed int, vector unsigned int);
14698 vector signed int vec_srl (vector signed int, vector unsigned short);
14699 vector signed int vec_srl (vector signed int, vector unsigned char);
14700 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14701 vector unsigned int vec_srl (vector unsigned int,
14702                              vector unsigned short);
14703 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14704 vector bool int vec_srl (vector bool int, vector unsigned int);
14705 vector bool int vec_srl (vector bool int, vector unsigned short);
14706 vector bool int vec_srl (vector bool int, vector unsigned char);
14707 vector signed short vec_srl (vector signed short, vector unsigned int);
14708 vector signed short vec_srl (vector signed short,
14709                              vector unsigned short);
14710 vector signed short vec_srl (vector signed short, vector unsigned char);
14711 vector unsigned short vec_srl (vector unsigned short,
14712                                vector unsigned int);
14713 vector unsigned short vec_srl (vector unsigned short,
14714                                vector unsigned short);
14715 vector unsigned short vec_srl (vector unsigned short,
14716                                vector unsigned char);
14717 vector bool short vec_srl (vector bool short, vector unsigned int);
14718 vector bool short vec_srl (vector bool short, vector unsigned short);
14719 vector bool short vec_srl (vector bool short, vector unsigned char);
14720 vector pixel vec_srl (vector pixel, vector unsigned int);
14721 vector pixel vec_srl (vector pixel, vector unsigned short);
14722 vector pixel vec_srl (vector pixel, vector unsigned char);
14723 vector signed char vec_srl (vector signed char, vector unsigned int);
14724 vector signed char vec_srl (vector signed char, vector unsigned short);
14725 vector signed char vec_srl (vector signed char, vector unsigned char);
14726 vector unsigned char vec_srl (vector unsigned char,
14727                               vector unsigned int);
14728 vector unsigned char vec_srl (vector unsigned char,
14729                               vector unsigned short);
14730 vector unsigned char vec_srl (vector unsigned char,
14731                               vector unsigned char);
14732 vector bool char vec_srl (vector bool char, vector unsigned int);
14733 vector bool char vec_srl (vector bool char, vector unsigned short);
14734 vector bool char vec_srl (vector bool char, vector unsigned char);
14736 vector float vec_sro (vector float, vector signed char);
14737 vector float vec_sro (vector float, vector unsigned char);
14738 vector signed int vec_sro (vector signed int, vector signed char);
14739 vector signed int vec_sro (vector signed int, vector unsigned char);
14740 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14741 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14742 vector signed short vec_sro (vector signed short, vector signed char);
14743 vector signed short vec_sro (vector signed short, vector unsigned char);
14744 vector unsigned short vec_sro (vector unsigned short,
14745                                vector signed char);
14746 vector unsigned short vec_sro (vector unsigned short,
14747                                vector unsigned char);
14748 vector pixel vec_sro (vector pixel, vector signed char);
14749 vector pixel vec_sro (vector pixel, vector unsigned char);
14750 vector signed char vec_sro (vector signed char, vector signed char);
14751 vector signed char vec_sro (vector signed char, vector unsigned char);
14752 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14753 vector unsigned char vec_sro (vector unsigned char,
14754                               vector unsigned char);
14756 void vec_st (vector float, int, vector float *);
14757 void vec_st (vector float, int, float *);
14758 void vec_st (vector signed int, int, vector signed int *);
14759 void vec_st (vector signed int, int, int *);
14760 void vec_st (vector unsigned int, int, vector unsigned int *);
14761 void vec_st (vector unsigned int, int, unsigned int *);
14762 void vec_st (vector bool int, int, vector bool int *);
14763 void vec_st (vector bool int, int, unsigned int *);
14764 void vec_st (vector bool int, int, int *);
14765 void vec_st (vector signed short, int, vector signed short *);
14766 void vec_st (vector signed short, int, short *);
14767 void vec_st (vector unsigned short, int, vector unsigned short *);
14768 void vec_st (vector unsigned short, int, unsigned short *);
14769 void vec_st (vector bool short, int, vector bool short *);
14770 void vec_st (vector bool short, int, unsigned short *);
14771 void vec_st (vector pixel, int, vector pixel *);
14772 void vec_st (vector pixel, int, unsigned short *);
14773 void vec_st (vector pixel, int, short *);
14774 void vec_st (vector bool short, int, short *);
14775 void vec_st (vector signed char, int, vector signed char *);
14776 void vec_st (vector signed char, int, signed char *);
14777 void vec_st (vector unsigned char, int, vector unsigned char *);
14778 void vec_st (vector unsigned char, int, unsigned char *);
14779 void vec_st (vector bool char, int, vector bool char *);
14780 void vec_st (vector bool char, int, unsigned char *);
14781 void vec_st (vector bool char, int, signed char *);
14783 void vec_ste (vector signed char, int, signed char *);
14784 void vec_ste (vector unsigned char, int, unsigned char *);
14785 void vec_ste (vector bool char, int, signed char *);
14786 void vec_ste (vector bool char, int, unsigned char *);
14787 void vec_ste (vector signed short, int, short *);
14788 void vec_ste (vector unsigned short, int, unsigned short *);
14789 void vec_ste (vector bool short, int, short *);
14790 void vec_ste (vector bool short, int, unsigned short *);
14791 void vec_ste (vector pixel, int, short *);
14792 void vec_ste (vector pixel, int, unsigned short *);
14793 void vec_ste (vector float, int, float *);
14794 void vec_ste (vector signed int, int, int *);
14795 void vec_ste (vector unsigned int, int, unsigned int *);
14796 void vec_ste (vector bool int, int, int *);
14797 void vec_ste (vector bool int, int, unsigned int *);
14799 void vec_stvewx (vector float, int, float *);
14800 void vec_stvewx (vector signed int, int, int *);
14801 void vec_stvewx (vector unsigned int, int, unsigned int *);
14802 void vec_stvewx (vector bool int, int, int *);
14803 void vec_stvewx (vector bool int, int, unsigned int *);
14805 void vec_stvehx (vector signed short, int, short *);
14806 void vec_stvehx (vector unsigned short, int, unsigned short *);
14807 void vec_stvehx (vector bool short, int, short *);
14808 void vec_stvehx (vector bool short, int, unsigned short *);
14809 void vec_stvehx (vector pixel, int, short *);
14810 void vec_stvehx (vector pixel, int, unsigned short *);
14812 void vec_stvebx (vector signed char, int, signed char *);
14813 void vec_stvebx (vector unsigned char, int, unsigned char *);
14814 void vec_stvebx (vector bool char, int, signed char *);
14815 void vec_stvebx (vector bool char, int, unsigned char *);
14817 void vec_stl (vector float, int, vector float *);
14818 void vec_stl (vector float, int, float *);
14819 void vec_stl (vector signed int, int, vector signed int *);
14820 void vec_stl (vector signed int, int, int *);
14821 void vec_stl (vector unsigned int, int, vector unsigned int *);
14822 void vec_stl (vector unsigned int, int, unsigned int *);
14823 void vec_stl (vector bool int, int, vector bool int *);
14824 void vec_stl (vector bool int, int, unsigned int *);
14825 void vec_stl (vector bool int, int, int *);
14826 void vec_stl (vector signed short, int, vector signed short *);
14827 void vec_stl (vector signed short, int, short *);
14828 void vec_stl (vector unsigned short, int, vector unsigned short *);
14829 void vec_stl (vector unsigned short, int, unsigned short *);
14830 void vec_stl (vector bool short, int, vector bool short *);
14831 void vec_stl (vector bool short, int, unsigned short *);
14832 void vec_stl (vector bool short, int, short *);
14833 void vec_stl (vector pixel, int, vector pixel *);
14834 void vec_stl (vector pixel, int, unsigned short *);
14835 void vec_stl (vector pixel, int, short *);
14836 void vec_stl (vector signed char, int, vector signed char *);
14837 void vec_stl (vector signed char, int, signed char *);
14838 void vec_stl (vector unsigned char, int, vector unsigned char *);
14839 void vec_stl (vector unsigned char, int, unsigned char *);
14840 void vec_stl (vector bool char, int, vector bool char *);
14841 void vec_stl (vector bool char, int, unsigned char *);
14842 void vec_stl (vector bool char, int, signed char *);
14844 vector signed char vec_sub (vector bool char, vector signed char);
14845 vector signed char vec_sub (vector signed char, vector bool char);
14846 vector signed char vec_sub (vector signed char, vector signed char);
14847 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14848 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14849 vector unsigned char vec_sub (vector unsigned char,
14850                               vector unsigned char);
14851 vector signed short vec_sub (vector bool short, vector signed short);
14852 vector signed short vec_sub (vector signed short, vector bool short);
14853 vector signed short vec_sub (vector signed short, vector signed short);
14854 vector unsigned short vec_sub (vector bool short,
14855                                vector unsigned short);
14856 vector unsigned short vec_sub (vector unsigned short,
14857                                vector bool short);
14858 vector unsigned short vec_sub (vector unsigned short,
14859                                vector unsigned short);
14860 vector signed int vec_sub (vector bool int, vector signed int);
14861 vector signed int vec_sub (vector signed int, vector bool int);
14862 vector signed int vec_sub (vector signed int, vector signed int);
14863 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14864 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14865 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14866 vector float vec_sub (vector float, vector float);
14868 vector float vec_vsubfp (vector float, vector float);
14870 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14871 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14872 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14873 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14874 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14875 vector unsigned int vec_vsubuwm (vector unsigned int,
14876                                  vector unsigned int);
14878 vector signed short vec_vsubuhm (vector bool short,
14879                                  vector signed short);
14880 vector signed short vec_vsubuhm (vector signed short,
14881                                  vector bool short);
14882 vector signed short vec_vsubuhm (vector signed short,
14883                                  vector signed short);
14884 vector unsigned short vec_vsubuhm (vector bool short,
14885                                    vector unsigned short);
14886 vector unsigned short vec_vsubuhm (vector unsigned short,
14887                                    vector bool short);
14888 vector unsigned short vec_vsubuhm (vector unsigned short,
14889                                    vector unsigned short);
14891 vector signed char vec_vsububm (vector bool char, vector signed char);
14892 vector signed char vec_vsububm (vector signed char, vector bool char);
14893 vector signed char vec_vsububm (vector signed char, vector signed char);
14894 vector unsigned char vec_vsububm (vector bool char,
14895                                   vector unsigned char);
14896 vector unsigned char vec_vsububm (vector unsigned char,
14897                                   vector bool char);
14898 vector unsigned char vec_vsububm (vector unsigned char,
14899                                   vector unsigned char);
14901 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14903 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14904 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14905 vector unsigned char vec_subs (vector unsigned char,
14906                                vector unsigned char);
14907 vector signed char vec_subs (vector bool char, vector signed char);
14908 vector signed char vec_subs (vector signed char, vector bool char);
14909 vector signed char vec_subs (vector signed char, vector signed char);
14910 vector unsigned short vec_subs (vector bool short,
14911                                 vector unsigned short);
14912 vector unsigned short vec_subs (vector unsigned short,
14913                                 vector bool short);
14914 vector unsigned short vec_subs (vector unsigned short,
14915                                 vector unsigned short);
14916 vector signed short vec_subs (vector bool short, vector signed short);
14917 vector signed short vec_subs (vector signed short, vector bool short);
14918 vector signed short vec_subs (vector signed short, vector signed short);
14919 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14920 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14921 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14922 vector signed int vec_subs (vector bool int, vector signed int);
14923 vector signed int vec_subs (vector signed int, vector bool int);
14924 vector signed int vec_subs (vector signed int, vector signed int);
14926 vector signed int vec_vsubsws (vector bool int, vector signed int);
14927 vector signed int vec_vsubsws (vector signed int, vector bool int);
14928 vector signed int vec_vsubsws (vector signed int, vector signed int);
14930 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14931 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14932 vector unsigned int vec_vsubuws (vector unsigned int,
14933                                  vector unsigned int);
14935 vector signed short vec_vsubshs (vector bool short,
14936                                  vector signed short);
14937 vector signed short vec_vsubshs (vector signed short,
14938                                  vector bool short);
14939 vector signed short vec_vsubshs (vector signed short,
14940                                  vector signed short);
14942 vector unsigned short vec_vsubuhs (vector bool short,
14943                                    vector unsigned short);
14944 vector unsigned short vec_vsubuhs (vector unsigned short,
14945                                    vector bool short);
14946 vector unsigned short vec_vsubuhs (vector unsigned short,
14947                                    vector unsigned short);
14949 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14950 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14951 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14953 vector unsigned char vec_vsububs (vector bool char,
14954                                   vector unsigned char);
14955 vector unsigned char vec_vsububs (vector unsigned char,
14956                                   vector bool char);
14957 vector unsigned char vec_vsububs (vector unsigned char,
14958                                   vector unsigned char);
14960 vector unsigned int vec_sum4s (vector unsigned char,
14961                                vector unsigned int);
14962 vector signed int vec_sum4s (vector signed char, vector signed int);
14963 vector signed int vec_sum4s (vector signed short, vector signed int);
14965 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14967 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14969 vector unsigned int vec_vsum4ubs (vector unsigned char,
14970                                   vector unsigned int);
14972 vector signed int vec_sum2s (vector signed int, vector signed int);
14974 vector signed int vec_sums (vector signed int, vector signed int);
14976 vector float vec_trunc (vector float);
14978 vector signed short vec_unpackh (vector signed char);
14979 vector bool short vec_unpackh (vector bool char);
14980 vector signed int vec_unpackh (vector signed short);
14981 vector bool int vec_unpackh (vector bool short);
14982 vector unsigned int vec_unpackh (vector pixel);
14984 vector bool int vec_vupkhsh (vector bool short);
14985 vector signed int vec_vupkhsh (vector signed short);
14987 vector unsigned int vec_vupkhpx (vector pixel);
14989 vector bool short vec_vupkhsb (vector bool char);
14990 vector signed short vec_vupkhsb (vector signed char);
14992 vector signed short vec_unpackl (vector signed char);
14993 vector bool short vec_unpackl (vector bool char);
14994 vector unsigned int vec_unpackl (vector pixel);
14995 vector signed int vec_unpackl (vector signed short);
14996 vector bool int vec_unpackl (vector bool short);
14998 vector unsigned int vec_vupklpx (vector pixel);
15000 vector bool int vec_vupklsh (vector bool short);
15001 vector signed int vec_vupklsh (vector signed short);
15003 vector bool short vec_vupklsb (vector bool char);
15004 vector signed short vec_vupklsb (vector signed char);
15006 vector float vec_xor (vector float, vector float);
15007 vector float vec_xor (vector float, vector bool int);
15008 vector float vec_xor (vector bool int, vector float);
15009 vector bool int vec_xor (vector bool int, vector bool int);
15010 vector signed int vec_xor (vector bool int, vector signed int);
15011 vector signed int vec_xor (vector signed int, vector bool int);
15012 vector signed int vec_xor (vector signed int, vector signed int);
15013 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15014 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15015 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15016 vector bool short vec_xor (vector bool short, vector bool short);
15017 vector signed short vec_xor (vector bool short, vector signed short);
15018 vector signed short vec_xor (vector signed short, vector bool short);
15019 vector signed short vec_xor (vector signed short, vector signed short);
15020 vector unsigned short vec_xor (vector bool short,
15021                                vector unsigned short);
15022 vector unsigned short vec_xor (vector unsigned short,
15023                                vector bool short);
15024 vector unsigned short vec_xor (vector unsigned short,
15025                                vector unsigned short);
15026 vector signed char vec_xor (vector bool char, vector signed char);
15027 vector bool char vec_xor (vector bool char, vector bool char);
15028 vector signed char vec_xor (vector signed char, vector bool char);
15029 vector signed char vec_xor (vector signed char, vector signed char);
15030 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15031 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15032 vector unsigned char vec_xor (vector unsigned char,
15033                               vector unsigned char);
15035 int vec_all_eq (vector signed char, vector bool char);
15036 int vec_all_eq (vector signed char, vector signed char);
15037 int vec_all_eq (vector unsigned char, vector bool char);
15038 int vec_all_eq (vector unsigned char, vector unsigned char);
15039 int vec_all_eq (vector bool char, vector bool char);
15040 int vec_all_eq (vector bool char, vector unsigned char);
15041 int vec_all_eq (vector bool char, vector signed char);
15042 int vec_all_eq (vector signed short, vector bool short);
15043 int vec_all_eq (vector signed short, vector signed short);
15044 int vec_all_eq (vector unsigned short, vector bool short);
15045 int vec_all_eq (vector unsigned short, vector unsigned short);
15046 int vec_all_eq (vector bool short, vector bool short);
15047 int vec_all_eq (vector bool short, vector unsigned short);
15048 int vec_all_eq (vector bool short, vector signed short);
15049 int vec_all_eq (vector pixel, vector pixel);
15050 int vec_all_eq (vector signed int, vector bool int);
15051 int vec_all_eq (vector signed int, vector signed int);
15052 int vec_all_eq (vector unsigned int, vector bool int);
15053 int vec_all_eq (vector unsigned int, vector unsigned int);
15054 int vec_all_eq (vector bool int, vector bool int);
15055 int vec_all_eq (vector bool int, vector unsigned int);
15056 int vec_all_eq (vector bool int, vector signed int);
15057 int vec_all_eq (vector float, vector float);
15059 int vec_all_ge (vector bool char, vector unsigned char);
15060 int vec_all_ge (vector unsigned char, vector bool char);
15061 int vec_all_ge (vector unsigned char, vector unsigned char);
15062 int vec_all_ge (vector bool char, vector signed char);
15063 int vec_all_ge (vector signed char, vector bool char);
15064 int vec_all_ge (vector signed char, vector signed char);
15065 int vec_all_ge (vector bool short, vector unsigned short);
15066 int vec_all_ge (vector unsigned short, vector bool short);
15067 int vec_all_ge (vector unsigned short, vector unsigned short);
15068 int vec_all_ge (vector signed short, vector signed short);
15069 int vec_all_ge (vector bool short, vector signed short);
15070 int vec_all_ge (vector signed short, vector bool short);
15071 int vec_all_ge (vector bool int, vector unsigned int);
15072 int vec_all_ge (vector unsigned int, vector bool int);
15073 int vec_all_ge (vector unsigned int, vector unsigned int);
15074 int vec_all_ge (vector bool int, vector signed int);
15075 int vec_all_ge (vector signed int, vector bool int);
15076 int vec_all_ge (vector signed int, vector signed int);
15077 int vec_all_ge (vector float, vector float);
15079 int vec_all_gt (vector bool char, vector unsigned char);
15080 int vec_all_gt (vector unsigned char, vector bool char);
15081 int vec_all_gt (vector unsigned char, vector unsigned char);
15082 int vec_all_gt (vector bool char, vector signed char);
15083 int vec_all_gt (vector signed char, vector bool char);
15084 int vec_all_gt (vector signed char, vector signed char);
15085 int vec_all_gt (vector bool short, vector unsigned short);
15086 int vec_all_gt (vector unsigned short, vector bool short);
15087 int vec_all_gt (vector unsigned short, vector unsigned short);
15088 int vec_all_gt (vector bool short, vector signed short);
15089 int vec_all_gt (vector signed short, vector bool short);
15090 int vec_all_gt (vector signed short, vector signed short);
15091 int vec_all_gt (vector bool int, vector unsigned int);
15092 int vec_all_gt (vector unsigned int, vector bool int);
15093 int vec_all_gt (vector unsigned int, vector unsigned int);
15094 int vec_all_gt (vector bool int, vector signed int);
15095 int vec_all_gt (vector signed int, vector bool int);
15096 int vec_all_gt (vector signed int, vector signed int);
15097 int vec_all_gt (vector float, vector float);
15099 int vec_all_in (vector float, vector float);
15101 int vec_all_le (vector bool char, vector unsigned char);
15102 int vec_all_le (vector unsigned char, vector bool char);
15103 int vec_all_le (vector unsigned char, vector unsigned char);
15104 int vec_all_le (vector bool char, vector signed char);
15105 int vec_all_le (vector signed char, vector bool char);
15106 int vec_all_le (vector signed char, vector signed char);
15107 int vec_all_le (vector bool short, vector unsigned short);
15108 int vec_all_le (vector unsigned short, vector bool short);
15109 int vec_all_le (vector unsigned short, vector unsigned short);
15110 int vec_all_le (vector bool short, vector signed short);
15111 int vec_all_le (vector signed short, vector bool short);
15112 int vec_all_le (vector signed short, vector signed short);
15113 int vec_all_le (vector bool int, vector unsigned int);
15114 int vec_all_le (vector unsigned int, vector bool int);
15115 int vec_all_le (vector unsigned int, vector unsigned int);
15116 int vec_all_le (vector bool int, vector signed int);
15117 int vec_all_le (vector signed int, vector bool int);
15118 int vec_all_le (vector signed int, vector signed int);
15119 int vec_all_le (vector float, vector float);
15121 int vec_all_lt (vector bool char, vector unsigned char);
15122 int vec_all_lt (vector unsigned char, vector bool char);
15123 int vec_all_lt (vector unsigned char, vector unsigned char);
15124 int vec_all_lt (vector bool char, vector signed char);
15125 int vec_all_lt (vector signed char, vector bool char);
15126 int vec_all_lt (vector signed char, vector signed char);
15127 int vec_all_lt (vector bool short, vector unsigned short);
15128 int vec_all_lt (vector unsigned short, vector bool short);
15129 int vec_all_lt (vector unsigned short, vector unsigned short);
15130 int vec_all_lt (vector bool short, vector signed short);
15131 int vec_all_lt (vector signed short, vector bool short);
15132 int vec_all_lt (vector signed short, vector signed short);
15133 int vec_all_lt (vector bool int, vector unsigned int);
15134 int vec_all_lt (vector unsigned int, vector bool int);
15135 int vec_all_lt (vector unsigned int, vector unsigned int);
15136 int vec_all_lt (vector bool int, vector signed int);
15137 int vec_all_lt (vector signed int, vector bool int);
15138 int vec_all_lt (vector signed int, vector signed int);
15139 int vec_all_lt (vector float, vector float);
15141 int vec_all_nan (vector float);
15143 int vec_all_ne (vector signed char, vector bool char);
15144 int vec_all_ne (vector signed char, vector signed char);
15145 int vec_all_ne (vector unsigned char, vector bool char);
15146 int vec_all_ne (vector unsigned char, vector unsigned char);
15147 int vec_all_ne (vector bool char, vector bool char);
15148 int vec_all_ne (vector bool char, vector unsigned char);
15149 int vec_all_ne (vector bool char, vector signed char);
15150 int vec_all_ne (vector signed short, vector bool short);
15151 int vec_all_ne (vector signed short, vector signed short);
15152 int vec_all_ne (vector unsigned short, vector bool short);
15153 int vec_all_ne (vector unsigned short, vector unsigned short);
15154 int vec_all_ne (vector bool short, vector bool short);
15155 int vec_all_ne (vector bool short, vector unsigned short);
15156 int vec_all_ne (vector bool short, vector signed short);
15157 int vec_all_ne (vector pixel, vector pixel);
15158 int vec_all_ne (vector signed int, vector bool int);
15159 int vec_all_ne (vector signed int, vector signed int);
15160 int vec_all_ne (vector unsigned int, vector bool int);
15161 int vec_all_ne (vector unsigned int, vector unsigned int);
15162 int vec_all_ne (vector bool int, vector bool int);
15163 int vec_all_ne (vector bool int, vector unsigned int);
15164 int vec_all_ne (vector bool int, vector signed int);
15165 int vec_all_ne (vector float, vector float);
15167 int vec_all_nge (vector float, vector float);
15169 int vec_all_ngt (vector float, vector float);
15171 int vec_all_nle (vector float, vector float);
15173 int vec_all_nlt (vector float, vector float);
15175 int vec_all_numeric (vector float);
15177 int vec_any_eq (vector signed char, vector bool char);
15178 int vec_any_eq (vector signed char, vector signed char);
15179 int vec_any_eq (vector unsigned char, vector bool char);
15180 int vec_any_eq (vector unsigned char, vector unsigned char);
15181 int vec_any_eq (vector bool char, vector bool char);
15182 int vec_any_eq (vector bool char, vector unsigned char);
15183 int vec_any_eq (vector bool char, vector signed char);
15184 int vec_any_eq (vector signed short, vector bool short);
15185 int vec_any_eq (vector signed short, vector signed short);
15186 int vec_any_eq (vector unsigned short, vector bool short);
15187 int vec_any_eq (vector unsigned short, vector unsigned short);
15188 int vec_any_eq (vector bool short, vector bool short);
15189 int vec_any_eq (vector bool short, vector unsigned short);
15190 int vec_any_eq (vector bool short, vector signed short);
15191 int vec_any_eq (vector pixel, vector pixel);
15192 int vec_any_eq (vector signed int, vector bool int);
15193 int vec_any_eq (vector signed int, vector signed int);
15194 int vec_any_eq (vector unsigned int, vector bool int);
15195 int vec_any_eq (vector unsigned int, vector unsigned int);
15196 int vec_any_eq (vector bool int, vector bool int);
15197 int vec_any_eq (vector bool int, vector unsigned int);
15198 int vec_any_eq (vector bool int, vector signed int);
15199 int vec_any_eq (vector float, vector float);
15201 int vec_any_ge (vector signed char, vector bool char);
15202 int vec_any_ge (vector unsigned char, vector bool char);
15203 int vec_any_ge (vector unsigned char, vector unsigned char);
15204 int vec_any_ge (vector signed char, vector signed char);
15205 int vec_any_ge (vector bool char, vector unsigned char);
15206 int vec_any_ge (vector bool char, vector signed char);
15207 int vec_any_ge (vector unsigned short, vector bool short);
15208 int vec_any_ge (vector unsigned short, vector unsigned short);
15209 int vec_any_ge (vector signed short, vector signed short);
15210 int vec_any_ge (vector signed short, vector bool short);
15211 int vec_any_ge (vector bool short, vector unsigned short);
15212 int vec_any_ge (vector bool short, vector signed short);
15213 int vec_any_ge (vector signed int, vector bool int);
15214 int vec_any_ge (vector unsigned int, vector bool int);
15215 int vec_any_ge (vector unsigned int, vector unsigned int);
15216 int vec_any_ge (vector signed int, vector signed int);
15217 int vec_any_ge (vector bool int, vector unsigned int);
15218 int vec_any_ge (vector bool int, vector signed int);
15219 int vec_any_ge (vector float, vector float);
15221 int vec_any_gt (vector bool char, vector unsigned char);
15222 int vec_any_gt (vector unsigned char, vector bool char);
15223 int vec_any_gt (vector unsigned char, vector unsigned char);
15224 int vec_any_gt (vector bool char, vector signed char);
15225 int vec_any_gt (vector signed char, vector bool char);
15226 int vec_any_gt (vector signed char, vector signed char);
15227 int vec_any_gt (vector bool short, vector unsigned short);
15228 int vec_any_gt (vector unsigned short, vector bool short);
15229 int vec_any_gt (vector unsigned short, vector unsigned short);
15230 int vec_any_gt (vector bool short, vector signed short);
15231 int vec_any_gt (vector signed short, vector bool short);
15232 int vec_any_gt (vector signed short, vector signed short);
15233 int vec_any_gt (vector bool int, vector unsigned int);
15234 int vec_any_gt (vector unsigned int, vector bool int);
15235 int vec_any_gt (vector unsigned int, vector unsigned int);
15236 int vec_any_gt (vector bool int, vector signed int);
15237 int vec_any_gt (vector signed int, vector bool int);
15238 int vec_any_gt (vector signed int, vector signed int);
15239 int vec_any_gt (vector float, vector float);
15241 int vec_any_le (vector bool char, vector unsigned char);
15242 int vec_any_le (vector unsigned char, vector bool char);
15243 int vec_any_le (vector unsigned char, vector unsigned char);
15244 int vec_any_le (vector bool char, vector signed char);
15245 int vec_any_le (vector signed char, vector bool char);
15246 int vec_any_le (vector signed char, vector signed char);
15247 int vec_any_le (vector bool short, vector unsigned short);
15248 int vec_any_le (vector unsigned short, vector bool short);
15249 int vec_any_le (vector unsigned short, vector unsigned short);
15250 int vec_any_le (vector bool short, vector signed short);
15251 int vec_any_le (vector signed short, vector bool short);
15252 int vec_any_le (vector signed short, vector signed short);
15253 int vec_any_le (vector bool int, vector unsigned int);
15254 int vec_any_le (vector unsigned int, vector bool int);
15255 int vec_any_le (vector unsigned int, vector unsigned int);
15256 int vec_any_le (vector bool int, vector signed int);
15257 int vec_any_le (vector signed int, vector bool int);
15258 int vec_any_le (vector signed int, vector signed int);
15259 int vec_any_le (vector float, vector float);
15261 int vec_any_lt (vector bool char, vector unsigned char);
15262 int vec_any_lt (vector unsigned char, vector bool char);
15263 int vec_any_lt (vector unsigned char, vector unsigned char);
15264 int vec_any_lt (vector bool char, vector signed char);
15265 int vec_any_lt (vector signed char, vector bool char);
15266 int vec_any_lt (vector signed char, vector signed char);
15267 int vec_any_lt (vector bool short, vector unsigned short);
15268 int vec_any_lt (vector unsigned short, vector bool short);
15269 int vec_any_lt (vector unsigned short, vector unsigned short);
15270 int vec_any_lt (vector bool short, vector signed short);
15271 int vec_any_lt (vector signed short, vector bool short);
15272 int vec_any_lt (vector signed short, vector signed short);
15273 int vec_any_lt (vector bool int, vector unsigned int);
15274 int vec_any_lt (vector unsigned int, vector bool int);
15275 int vec_any_lt (vector unsigned int, vector unsigned int);
15276 int vec_any_lt (vector bool int, vector signed int);
15277 int vec_any_lt (vector signed int, vector bool int);
15278 int vec_any_lt (vector signed int, vector signed int);
15279 int vec_any_lt (vector float, vector float);
15281 int vec_any_nan (vector float);
15283 int vec_any_ne (vector signed char, vector bool char);
15284 int vec_any_ne (vector signed char, vector signed char);
15285 int vec_any_ne (vector unsigned char, vector bool char);
15286 int vec_any_ne (vector unsigned char, vector unsigned char);
15287 int vec_any_ne (vector bool char, vector bool char);
15288 int vec_any_ne (vector bool char, vector unsigned char);
15289 int vec_any_ne (vector bool char, vector signed char);
15290 int vec_any_ne (vector signed short, vector bool short);
15291 int vec_any_ne (vector signed short, vector signed short);
15292 int vec_any_ne (vector unsigned short, vector bool short);
15293 int vec_any_ne (vector unsigned short, vector unsigned short);
15294 int vec_any_ne (vector bool short, vector bool short);
15295 int vec_any_ne (vector bool short, vector unsigned short);
15296 int vec_any_ne (vector bool short, vector signed short);
15297 int vec_any_ne (vector pixel, vector pixel);
15298 int vec_any_ne (vector signed int, vector bool int);
15299 int vec_any_ne (vector signed int, vector signed int);
15300 int vec_any_ne (vector unsigned int, vector bool int);
15301 int vec_any_ne (vector unsigned int, vector unsigned int);
15302 int vec_any_ne (vector bool int, vector bool int);
15303 int vec_any_ne (vector bool int, vector unsigned int);
15304 int vec_any_ne (vector bool int, vector signed int);
15305 int vec_any_ne (vector float, vector float);
15307 int vec_any_nge (vector float, vector float);
15309 int vec_any_ngt (vector float, vector float);
15311 int vec_any_nle (vector float, vector float);
15313 int vec_any_nlt (vector float, vector float);
15315 int vec_any_numeric (vector float);
15317 int vec_any_out (vector float, vector float);
15318 @end smallexample
15320 If the vector/scalar (VSX) instruction set is available, the following
15321 additional functions are available:
15323 @smallexample
15324 vector double vec_abs (vector double);
15325 vector double vec_add (vector double, vector double);
15326 vector double vec_and (vector double, vector double);
15327 vector double vec_and (vector double, vector bool long);
15328 vector double vec_and (vector bool long, vector double);
15329 vector long vec_and (vector long, vector long);
15330 vector long vec_and (vector long, vector bool long);
15331 vector long vec_and (vector bool long, vector long);
15332 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15333 vector unsigned long vec_and (vector unsigned long, vector bool long);
15334 vector unsigned long vec_and (vector bool long, vector unsigned long);
15335 vector double vec_andc (vector double, vector double);
15336 vector double vec_andc (vector double, vector bool long);
15337 vector double vec_andc (vector bool long, vector double);
15338 vector long vec_andc (vector long, vector long);
15339 vector long vec_andc (vector long, vector bool long);
15340 vector long vec_andc (vector bool long, vector long);
15341 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15342 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15343 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15344 vector double vec_ceil (vector double);
15345 vector bool long vec_cmpeq (vector double, vector double);
15346 vector bool long vec_cmpge (vector double, vector double);
15347 vector bool long vec_cmpgt (vector double, vector double);
15348 vector bool long vec_cmple (vector double, vector double);
15349 vector bool long vec_cmplt (vector double, vector double);
15350 vector double vec_cpsgn (vector double, vector double);
15351 vector float vec_div (vector float, vector float);
15352 vector double vec_div (vector double, vector double);
15353 vector long vec_div (vector long, vector long);
15354 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15355 vector double vec_floor (vector double);
15356 vector double vec_ld (int, const vector double *);
15357 vector double vec_ld (int, const double *);
15358 vector double vec_ldl (int, const vector double *);
15359 vector double vec_ldl (int, const double *);
15360 vector unsigned char vec_lvsl (int, const volatile double *);
15361 vector unsigned char vec_lvsr (int, const volatile double *);
15362 vector double vec_madd (vector double, vector double, vector double);
15363 vector double vec_max (vector double, vector double);
15364 vector signed long vec_mergeh (vector signed long, vector signed long);
15365 vector signed long vec_mergeh (vector signed long, vector bool long);
15366 vector signed long vec_mergeh (vector bool long, vector signed long);
15367 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15368 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15369 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15370 vector signed long vec_mergel (vector signed long, vector signed long);
15371 vector signed long vec_mergel (vector signed long, vector bool long);
15372 vector signed long vec_mergel (vector bool long, vector signed long);
15373 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15374 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15375 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15376 vector double vec_min (vector double, vector double);
15377 vector float vec_msub (vector float, vector float, vector float);
15378 vector double vec_msub (vector double, vector double, vector double);
15379 vector float vec_mul (vector float, vector float);
15380 vector double vec_mul (vector double, vector double);
15381 vector long vec_mul (vector long, vector long);
15382 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15383 vector float vec_nearbyint (vector float);
15384 vector double vec_nearbyint (vector double);
15385 vector float vec_nmadd (vector float, vector float, vector float);
15386 vector double vec_nmadd (vector double, vector double, vector double);
15387 vector double vec_nmsub (vector double, vector double, vector double);
15388 vector double vec_nor (vector double, vector double);
15389 vector long vec_nor (vector long, vector long);
15390 vector long vec_nor (vector long, vector bool long);
15391 vector long vec_nor (vector bool long, vector long);
15392 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15393 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15394 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15395 vector double vec_or (vector double, vector double);
15396 vector double vec_or (vector double, vector bool long);
15397 vector double vec_or (vector bool long, vector double);
15398 vector long vec_or (vector long, vector long);
15399 vector long vec_or (vector long, vector bool long);
15400 vector long vec_or (vector bool long, vector long);
15401 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15402 vector unsigned long vec_or (vector unsigned long, vector bool long);
15403 vector unsigned long vec_or (vector bool long, vector unsigned long);
15404 vector double vec_perm (vector double, vector double, vector unsigned char);
15405 vector long vec_perm (vector long, vector long, vector unsigned char);
15406 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15407                                vector unsigned char);
15408 vector double vec_rint (vector double);
15409 vector double vec_recip (vector double, vector double);
15410 vector double vec_rsqrt (vector double);
15411 vector double vec_rsqrte (vector double);
15412 vector double vec_sel (vector double, vector double, vector bool long);
15413 vector double vec_sel (vector double, vector double, vector unsigned long);
15414 vector long vec_sel (vector long, vector long, vector long);
15415 vector long vec_sel (vector long, vector long, vector unsigned long);
15416 vector long vec_sel (vector long, vector long, vector bool long);
15417 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15418                               vector long);
15419 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15420                               vector unsigned long);
15421 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15422                               vector bool long);
15423 vector double vec_splats (double);
15424 vector signed long vec_splats (signed long);
15425 vector unsigned long vec_splats (unsigned long);
15426 vector float vec_sqrt (vector float);
15427 vector double vec_sqrt (vector double);
15428 void vec_st (vector double, int, vector double *);
15429 void vec_st (vector double, int, double *);
15430 vector double vec_sub (vector double, vector double);
15431 vector double vec_trunc (vector double);
15432 vector double vec_xor (vector double, vector double);
15433 vector double vec_xor (vector double, vector bool long);
15434 vector double vec_xor (vector bool long, vector double);
15435 vector long vec_xor (vector long, vector long);
15436 vector long vec_xor (vector long, vector bool long);
15437 vector long vec_xor (vector bool long, vector long);
15438 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15439 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15440 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15441 int vec_all_eq (vector double, vector double);
15442 int vec_all_ge (vector double, vector double);
15443 int vec_all_gt (vector double, vector double);
15444 int vec_all_le (vector double, vector double);
15445 int vec_all_lt (vector double, vector double);
15446 int vec_all_nan (vector double);
15447 int vec_all_ne (vector double, vector double);
15448 int vec_all_nge (vector double, vector double);
15449 int vec_all_ngt (vector double, vector double);
15450 int vec_all_nle (vector double, vector double);
15451 int vec_all_nlt (vector double, vector double);
15452 int vec_all_numeric (vector double);
15453 int vec_any_eq (vector double, vector double);
15454 int vec_any_ge (vector double, vector double);
15455 int vec_any_gt (vector double, vector double);
15456 int vec_any_le (vector double, vector double);
15457 int vec_any_lt (vector double, vector double);
15458 int vec_any_nan (vector double);
15459 int vec_any_ne (vector double, vector double);
15460 int vec_any_nge (vector double, vector double);
15461 int vec_any_ngt (vector double, vector double);
15462 int vec_any_nle (vector double, vector double);
15463 int vec_any_nlt (vector double, vector double);
15464 int vec_any_numeric (vector double);
15466 vector double vec_vsx_ld (int, const vector double *);
15467 vector double vec_vsx_ld (int, const double *);
15468 vector float vec_vsx_ld (int, const vector float *);
15469 vector float vec_vsx_ld (int, const float *);
15470 vector bool int vec_vsx_ld (int, const vector bool int *);
15471 vector signed int vec_vsx_ld (int, const vector signed int *);
15472 vector signed int vec_vsx_ld (int, const int *);
15473 vector signed int vec_vsx_ld (int, const long *);
15474 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15475 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15476 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15477 vector bool short vec_vsx_ld (int, const vector bool short *);
15478 vector pixel vec_vsx_ld (int, const vector pixel *);
15479 vector signed short vec_vsx_ld (int, const vector signed short *);
15480 vector signed short vec_vsx_ld (int, const short *);
15481 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15482 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15483 vector bool char vec_vsx_ld (int, const vector bool char *);
15484 vector signed char vec_vsx_ld (int, const vector signed char *);
15485 vector signed char vec_vsx_ld (int, const signed char *);
15486 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15487 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15489 void vec_vsx_st (vector double, int, vector double *);
15490 void vec_vsx_st (vector double, int, double *);
15491 void vec_vsx_st (vector float, int, vector float *);
15492 void vec_vsx_st (vector float, int, float *);
15493 void vec_vsx_st (vector signed int, int, vector signed int *);
15494 void vec_vsx_st (vector signed int, int, int *);
15495 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15496 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15497 void vec_vsx_st (vector bool int, int, vector bool int *);
15498 void vec_vsx_st (vector bool int, int, unsigned int *);
15499 void vec_vsx_st (vector bool int, int, int *);
15500 void vec_vsx_st (vector signed short, int, vector signed short *);
15501 void vec_vsx_st (vector signed short, int, short *);
15502 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15503 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15504 void vec_vsx_st (vector bool short, int, vector bool short *);
15505 void vec_vsx_st (vector bool short, int, unsigned short *);
15506 void vec_vsx_st (vector pixel, int, vector pixel *);
15507 void vec_vsx_st (vector pixel, int, unsigned short *);
15508 void vec_vsx_st (vector pixel, int, short *);
15509 void vec_vsx_st (vector bool short, int, short *);
15510 void vec_vsx_st (vector signed char, int, vector signed char *);
15511 void vec_vsx_st (vector signed char, int, signed char *);
15512 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15513 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15514 void vec_vsx_st (vector bool char, int, vector bool char *);
15515 void vec_vsx_st (vector bool char, int, unsigned char *);
15516 void vec_vsx_st (vector bool char, int, signed char *);
15518 vector double vec_xxpermdi (vector double, vector double, int);
15519 vector float vec_xxpermdi (vector float, vector float, int);
15520 vector long long vec_xxpermdi (vector long long, vector long long, int);
15521 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15522                                         vector unsigned long long, int);
15523 vector int vec_xxpermdi (vector int, vector int, int);
15524 vector unsigned int vec_xxpermdi (vector unsigned int,
15525                                   vector unsigned int, int);
15526 vector short vec_xxpermdi (vector short, vector short, int);
15527 vector unsigned short vec_xxpermdi (vector unsigned short,
15528                                     vector unsigned short, int);
15529 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15530 vector unsigned char vec_xxpermdi (vector unsigned char,
15531                                    vector unsigned char, int);
15533 vector double vec_xxsldi (vector double, vector double, int);
15534 vector float vec_xxsldi (vector float, vector float, int);
15535 vector long long vec_xxsldi (vector long long, vector long long, int);
15536 vector unsigned long long vec_xxsldi (vector unsigned long long,
15537                                       vector unsigned long long, int);
15538 vector int vec_xxsldi (vector int, vector int, int);
15539 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15540 vector short vec_xxsldi (vector short, vector short, int);
15541 vector unsigned short vec_xxsldi (vector unsigned short,
15542                                   vector unsigned short, int);
15543 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15544 vector unsigned char vec_xxsldi (vector unsigned char,
15545                                  vector unsigned char, int);
15546 @end smallexample
15548 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15549 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15550 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15551 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15552 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15554 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15555 instruction set is available, the following additional functions are
15556 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15557 can use @var{vector long} instead of @var{vector long long},
15558 @var{vector bool long} instead of @var{vector bool long long}, and
15559 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15561 @smallexample
15562 vector long long vec_abs (vector long long);
15564 vector long long vec_add (vector long long, vector long long);
15565 vector unsigned long long vec_add (vector unsigned long long,
15566                                    vector unsigned long long);
15568 int vec_all_eq (vector long long, vector long long);
15569 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15570 int vec_all_ge (vector long long, vector long long);
15571 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15572 int vec_all_gt (vector long long, vector long long);
15573 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15574 int vec_all_le (vector long long, vector long long);
15575 int vec_all_le (vector unsigned long long, vector unsigned long long);
15576 int vec_all_lt (vector long long, vector long long);
15577 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15578 int vec_all_ne (vector long long, vector long long);
15579 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15581 int vec_any_eq (vector long long, vector long long);
15582 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15583 int vec_any_ge (vector long long, vector long long);
15584 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15585 int vec_any_gt (vector long long, vector long long);
15586 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15587 int vec_any_le (vector long long, vector long long);
15588 int vec_any_le (vector unsigned long long, vector unsigned long long);
15589 int vec_any_lt (vector long long, vector long long);
15590 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15591 int vec_any_ne (vector long long, vector long long);
15592 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15594 vector long long vec_eqv (vector long long, vector long long);
15595 vector long long vec_eqv (vector bool long long, vector long long);
15596 vector long long vec_eqv (vector long long, vector bool long long);
15597 vector unsigned long long vec_eqv (vector unsigned long long,
15598                                    vector unsigned long long);
15599 vector unsigned long long vec_eqv (vector bool long long,
15600                                    vector unsigned long long);
15601 vector unsigned long long vec_eqv (vector unsigned long long,
15602                                    vector bool long long);
15603 vector int vec_eqv (vector int, vector int);
15604 vector int vec_eqv (vector bool int, vector int);
15605 vector int vec_eqv (vector int, vector bool int);
15606 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15607 vector unsigned int vec_eqv (vector bool unsigned int,
15608                              vector unsigned int);
15609 vector unsigned int vec_eqv (vector unsigned int,
15610                              vector bool unsigned int);
15611 vector short vec_eqv (vector short, vector short);
15612 vector short vec_eqv (vector bool short, vector short);
15613 vector short vec_eqv (vector short, vector bool short);
15614 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15615 vector unsigned short vec_eqv (vector bool unsigned short,
15616                                vector unsigned short);
15617 vector unsigned short vec_eqv (vector unsigned short,
15618                                vector bool unsigned short);
15619 vector signed char vec_eqv (vector signed char, vector signed char);
15620 vector signed char vec_eqv (vector bool signed char, vector signed char);
15621 vector signed char vec_eqv (vector signed char, vector bool signed char);
15622 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15623 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15624 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15626 vector long long vec_max (vector long long, vector long long);
15627 vector unsigned long long vec_max (vector unsigned long long,
15628                                    vector unsigned long long);
15630 vector signed int vec_mergee (vector signed int, vector signed int);
15631 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15632 vector bool int vec_mergee (vector bool int, vector bool int);
15634 vector signed int vec_mergeo (vector signed int, vector signed int);
15635 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15636 vector bool int vec_mergeo (vector bool int, vector bool int);
15638 vector long long vec_min (vector long long, vector long long);
15639 vector unsigned long long vec_min (vector unsigned long long,
15640                                    vector unsigned long long);
15642 vector long long vec_nand (vector long long, vector long long);
15643 vector long long vec_nand (vector bool long long, vector long long);
15644 vector long long vec_nand (vector long long, vector bool long long);
15645 vector unsigned long long vec_nand (vector unsigned long long,
15646                                     vector unsigned long long);
15647 vector unsigned long long vec_nand (vector bool long long,
15648                                    vector unsigned long long);
15649 vector unsigned long long vec_nand (vector unsigned long long,
15650                                     vector bool long long);
15651 vector int vec_nand (vector int, vector int);
15652 vector int vec_nand (vector bool int, vector int);
15653 vector int vec_nand (vector int, vector bool int);
15654 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15655 vector unsigned int vec_nand (vector bool unsigned int,
15656                               vector unsigned int);
15657 vector unsigned int vec_nand (vector unsigned int,
15658                               vector bool unsigned int);
15659 vector short vec_nand (vector short, vector short);
15660 vector short vec_nand (vector bool short, vector short);
15661 vector short vec_nand (vector short, vector bool short);
15662 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15663 vector unsigned short vec_nand (vector bool unsigned short,
15664                                 vector unsigned short);
15665 vector unsigned short vec_nand (vector unsigned short,
15666                                 vector bool unsigned short);
15667 vector signed char vec_nand (vector signed char, vector signed char);
15668 vector signed char vec_nand (vector bool signed char, vector signed char);
15669 vector signed char vec_nand (vector signed char, vector bool signed char);
15670 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15671 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15672 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15674 vector long long vec_orc (vector long long, vector long long);
15675 vector long long vec_orc (vector bool long long, vector long long);
15676 vector long long vec_orc (vector long long, vector bool long long);
15677 vector unsigned long long vec_orc (vector unsigned long long,
15678                                    vector unsigned long long);
15679 vector unsigned long long vec_orc (vector bool long long,
15680                                    vector unsigned long long);
15681 vector unsigned long long vec_orc (vector unsigned long long,
15682                                    vector bool long long);
15683 vector int vec_orc (vector int, vector int);
15684 vector int vec_orc (vector bool int, vector int);
15685 vector int vec_orc (vector int, vector bool int);
15686 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15687 vector unsigned int vec_orc (vector bool unsigned int,
15688                              vector unsigned int);
15689 vector unsigned int vec_orc (vector unsigned int,
15690                              vector bool unsigned int);
15691 vector short vec_orc (vector short, vector short);
15692 vector short vec_orc (vector bool short, vector short);
15693 vector short vec_orc (vector short, vector bool short);
15694 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15695 vector unsigned short vec_orc (vector bool unsigned short,
15696                                vector unsigned short);
15697 vector unsigned short vec_orc (vector unsigned short,
15698                                vector bool unsigned short);
15699 vector signed char vec_orc (vector signed char, vector signed char);
15700 vector signed char vec_orc (vector bool signed char, vector signed char);
15701 vector signed char vec_orc (vector signed char, vector bool signed char);
15702 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15703 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15704 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15706 vector int vec_pack (vector long long, vector long long);
15707 vector unsigned int vec_pack (vector unsigned long long,
15708                               vector unsigned long long);
15709 vector bool int vec_pack (vector bool long long, vector bool long long);
15711 vector int vec_packs (vector long long, vector long long);
15712 vector unsigned int vec_packs (vector unsigned long long,
15713                                vector unsigned long long);
15715 vector unsigned int vec_packsu (vector long long, vector long long);
15716 vector unsigned int vec_packsu (vector unsigned long long,
15717                                 vector unsigned long long);
15719 vector long long vec_rl (vector long long,
15720                          vector unsigned long long);
15721 vector long long vec_rl (vector unsigned long long,
15722                          vector unsigned long long);
15724 vector long long vec_sl (vector long long, vector unsigned long long);
15725 vector long long vec_sl (vector unsigned long long,
15726                          vector unsigned long long);
15728 vector long long vec_sr (vector long long, vector unsigned long long);
15729 vector unsigned long long char vec_sr (vector unsigned long long,
15730                                        vector unsigned long long);
15732 vector long long vec_sra (vector long long, vector unsigned long long);
15733 vector unsigned long long vec_sra (vector unsigned long long,
15734                                    vector unsigned long long);
15736 vector long long vec_sub (vector long long, vector long long);
15737 vector unsigned long long vec_sub (vector unsigned long long,
15738                                    vector unsigned long long);
15740 vector long long vec_unpackh (vector int);
15741 vector unsigned long long vec_unpackh (vector unsigned int);
15743 vector long long vec_unpackl (vector int);
15744 vector unsigned long long vec_unpackl (vector unsigned int);
15746 vector long long vec_vaddudm (vector long long, vector long long);
15747 vector long long vec_vaddudm (vector bool long long, vector long long);
15748 vector long long vec_vaddudm (vector long long, vector bool long long);
15749 vector unsigned long long vec_vaddudm (vector unsigned long long,
15750                                        vector unsigned long long);
15751 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15752                                        vector unsigned long long);
15753 vector unsigned long long vec_vaddudm (vector unsigned long long,
15754                                        vector bool unsigned long long);
15756 vector long long vec_vbpermq (vector signed char, vector signed char);
15757 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15759 vector long long vec_cntlz (vector long long);
15760 vector unsigned long long vec_cntlz (vector unsigned long long);
15761 vector int vec_cntlz (vector int);
15762 vector unsigned int vec_cntlz (vector int);
15763 vector short vec_cntlz (vector short);
15764 vector unsigned short vec_cntlz (vector unsigned short);
15765 vector signed char vec_cntlz (vector signed char);
15766 vector unsigned char vec_cntlz (vector unsigned char);
15768 vector long long vec_vclz (vector long long);
15769 vector unsigned long long vec_vclz (vector unsigned long long);
15770 vector int vec_vclz (vector int);
15771 vector unsigned int vec_vclz (vector int);
15772 vector short vec_vclz (vector short);
15773 vector unsigned short vec_vclz (vector unsigned short);
15774 vector signed char vec_vclz (vector signed char);
15775 vector unsigned char vec_vclz (vector unsigned char);
15777 vector signed char vec_vclzb (vector signed char);
15778 vector unsigned char vec_vclzb (vector unsigned char);
15780 vector long long vec_vclzd (vector long long);
15781 vector unsigned long long vec_vclzd (vector unsigned long long);
15783 vector short vec_vclzh (vector short);
15784 vector unsigned short vec_vclzh (vector unsigned short);
15786 vector int vec_vclzw (vector int);
15787 vector unsigned int vec_vclzw (vector int);
15789 vector signed char vec_vgbbd (vector signed char);
15790 vector unsigned char vec_vgbbd (vector unsigned char);
15792 vector long long vec_vmaxsd (vector long long, vector long long);
15794 vector unsigned long long vec_vmaxud (vector unsigned long long,
15795                                       unsigned vector long long);
15797 vector long long vec_vminsd (vector long long, vector long long);
15799 vector unsigned long long vec_vminud (vector long long,
15800                                       vector long long);
15802 vector int vec_vpksdss (vector long long, vector long long);
15803 vector unsigned int vec_vpksdss (vector long long, vector long long);
15805 vector unsigned int vec_vpkudus (vector unsigned long long,
15806                                  vector unsigned long long);
15808 vector int vec_vpkudum (vector long long, vector long long);
15809 vector unsigned int vec_vpkudum (vector unsigned long long,
15810                                  vector unsigned long long);
15811 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15813 vector long long vec_vpopcnt (vector long long);
15814 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15815 vector int vec_vpopcnt (vector int);
15816 vector unsigned int vec_vpopcnt (vector int);
15817 vector short vec_vpopcnt (vector short);
15818 vector unsigned short vec_vpopcnt (vector unsigned short);
15819 vector signed char vec_vpopcnt (vector signed char);
15820 vector unsigned char vec_vpopcnt (vector unsigned char);
15822 vector signed char vec_vpopcntb (vector signed char);
15823 vector unsigned char vec_vpopcntb (vector unsigned char);
15825 vector long long vec_vpopcntd (vector long long);
15826 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15828 vector short vec_vpopcnth (vector short);
15829 vector unsigned short vec_vpopcnth (vector unsigned short);
15831 vector int vec_vpopcntw (vector int);
15832 vector unsigned int vec_vpopcntw (vector int);
15834 vector long long vec_vrld (vector long long, vector unsigned long long);
15835 vector unsigned long long vec_vrld (vector unsigned long long,
15836                                     vector unsigned long long);
15838 vector long long vec_vsld (vector long long, vector unsigned long long);
15839 vector long long vec_vsld (vector unsigned long long,
15840                            vector unsigned long long);
15842 vector long long vec_vsrad (vector long long, vector unsigned long long);
15843 vector unsigned long long vec_vsrad (vector unsigned long long,
15844                                      vector unsigned long long);
15846 vector long long vec_vsrd (vector long long, vector unsigned long long);
15847 vector unsigned long long char vec_vsrd (vector unsigned long long,
15848                                          vector unsigned long long);
15850 vector long long vec_vsubudm (vector long long, vector long long);
15851 vector long long vec_vsubudm (vector bool long long, vector long long);
15852 vector long long vec_vsubudm (vector long long, vector bool long long);
15853 vector unsigned long long vec_vsubudm (vector unsigned long long,
15854                                        vector unsigned long long);
15855 vector unsigned long long vec_vsubudm (vector bool long long,
15856                                        vector unsigned long long);
15857 vector unsigned long long vec_vsubudm (vector unsigned long long,
15858                                        vector bool long long);
15860 vector long long vec_vupkhsw (vector int);
15861 vector unsigned long long vec_vupkhsw (vector unsigned int);
15863 vector long long vec_vupklsw (vector int);
15864 vector unsigned long long vec_vupklsw (vector int);
15865 @end smallexample
15867 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15868 instruction set is available, the following additional functions are
15869 available for 64-bit targets.  New vector types
15870 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15871 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15872 builtins.
15874 The normal vector extract, and set operations work on
15875 @var{vector __int128_t} and @var{vector __uint128_t} types,
15876 but the index value must be 0.
15878 @smallexample
15879 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15880 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15882 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15883 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15885 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15886                                 vector __int128_t);
15887 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
15888                                  vector __uint128_t);
15890 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15891                                 vector __int128_t);
15892 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
15893                                  vector __uint128_t);
15895 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15896                                 vector __int128_t);
15897 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
15898                                  vector __uint128_t);
15900 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15901                                 vector __int128_t);
15902 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15903                                  vector __uint128_t);
15905 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15906 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15908 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15909 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15911 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15912 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15913 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15914 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15915 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15916 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15917 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15918 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15919 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15920 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15921 @end smallexample
15923 If the cryptographic instructions are enabled (@option{-mcrypto} or
15924 @option{-mcpu=power8}), the following builtins are enabled.
15926 @smallexample
15927 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15929 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15930                                                     vector unsigned long long);
15932 vector unsigned long long __builtin_crypto_vcipherlast
15933                                      (vector unsigned long long,
15934                                       vector unsigned long long);
15936 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15937                                                      vector unsigned long long);
15939 vector unsigned long long __builtin_crypto_vncipherlast
15940                                      (vector unsigned long long,
15941                                       vector unsigned long long);
15943 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15944                                                 vector unsigned char,
15945                                                 vector unsigned char);
15947 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15948                                                  vector unsigned short,
15949                                                  vector unsigned short);
15951 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15952                                                vector unsigned int,
15953                                                vector unsigned int);
15955 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15956                                                      vector unsigned long long,
15957                                                      vector unsigned long long);
15959 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15960                                                vector unsigned char);
15962 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15963                                                 vector unsigned short);
15965 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15966                                               vector unsigned int);
15968 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15969                                                     vector unsigned long long);
15971 vector unsigned long long __builtin_crypto_vshasigmad
15972                                (vector unsigned long long, int, int);
15974 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15975                                                  int, int);
15976 @end smallexample
15978 The second argument to the @var{__builtin_crypto_vshasigmad} and
15979 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15980 integer that is 0 or 1.  The third argument to these builtin functions
15981 must be a constant integer in the range of 0 to 15.
15983 @node PowerPC Hardware Transactional Memory Built-in Functions
15984 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15985 GCC provides two interfaces for accessing the Hardware Transactional
15986 Memory (HTM) instructions available on some of the PowerPC family
15987 of processors (eg, POWER8).  The two interfaces come in a low level
15988 interface, consisting of built-in functions specific to PowerPC and a
15989 higher level interface consisting of inline functions that are common
15990 between PowerPC and S/390.
15992 @subsubsection PowerPC HTM Low Level Built-in Functions
15994 The following low level built-in functions are available with
15995 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15996 They all generate the machine instruction that is part of the name.
15998 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
15999 the full 4-bit condition register value set by their associated hardware
16000 instruction.  The header file @code{htmintrin.h} defines some macros that can
16001 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
16002 returns a simple true or false value depending on whether a transaction was
16003 successfully started or not.  The arguments of the builtins match exactly the
16004 type and order of the associated hardware instruction's operands, except for
16005 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16006 Refer to the ISA manual for a description of each instruction's operands.
16008 @smallexample
16009 unsigned int __builtin_tbegin (unsigned int)
16010 unsigned int __builtin_tend (unsigned int)
16012 unsigned int __builtin_tabort (unsigned int)
16013 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16014 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16015 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16016 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16018 unsigned int __builtin_tcheck (void)
16019 unsigned int __builtin_treclaim (unsigned int)
16020 unsigned int __builtin_trechkpt (void)
16021 unsigned int __builtin_tsr (unsigned int)
16022 @end smallexample
16024 In addition to the above HTM built-ins, we have added built-ins for
16025 some common extended mnemonics of the HTM instructions:
16027 @smallexample
16028 unsigned int __builtin_tendall (void)
16029 unsigned int __builtin_tresume (void)
16030 unsigned int __builtin_tsuspend (void)
16031 @end smallexample
16033 The following set of built-in functions are available to gain access
16034 to the HTM specific special purpose registers.
16036 @smallexample
16037 unsigned long __builtin_get_texasr (void)
16038 unsigned long __builtin_get_texasru (void)
16039 unsigned long __builtin_get_tfhar (void)
16040 unsigned long __builtin_get_tfiar (void)
16042 void __builtin_set_texasr (unsigned long);
16043 void __builtin_set_texasru (unsigned long);
16044 void __builtin_set_tfhar (unsigned long);
16045 void __builtin_set_tfiar (unsigned long);
16046 @end smallexample
16048 Example usage of these low level built-in functions may look like:
16050 @smallexample
16051 #include <htmintrin.h>
16053 int num_retries = 10;
16055 while (1)
16056   @{
16057     if (__builtin_tbegin (0))
16058       @{
16059         /* Transaction State Initiated.  */
16060         if (is_locked (lock))
16061           __builtin_tabort (0);
16062         ... transaction code...
16063         __builtin_tend (0);
16064         break;
16065       @}
16066     else
16067       @{
16068         /* Transaction State Failed.  Use locks if the transaction
16069            failure is "persistent" or we've tried too many times.  */
16070         if (num_retries-- <= 0
16071             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16072           @{
16073             acquire_lock (lock);
16074             ... non transactional fallback path...
16075             release_lock (lock);
16076             break;
16077           @}
16078       @}
16079   @}
16080 @end smallexample
16082 One final built-in function has been added that returns the value of
16083 the 2-bit Transaction State field of the Machine Status Register (MSR)
16084 as stored in @code{CR0}.
16086 @smallexample
16087 unsigned long __builtin_ttest (void)
16088 @end smallexample
16090 This built-in can be used to determine the current transaction state
16091 using the following code example:
16093 @smallexample
16094 #include <htmintrin.h>
16096 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16098 if (tx_state == _HTM_TRANSACTIONAL)
16099   @{
16100     /* Code to use in transactional state.  */
16101   @}
16102 else if (tx_state == _HTM_NONTRANSACTIONAL)
16103   @{
16104     /* Code to use in non-transactional state.  */
16105   @}
16106 else if (tx_state == _HTM_SUSPENDED)
16107   @{
16108     /* Code to use in transaction suspended state.  */
16109   @}
16110 @end smallexample
16112 @subsubsection PowerPC HTM High Level Inline Functions
16114 The following high level HTM interface is made available by including
16115 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16116 where CPU is `power8' or later.  This interface is common between PowerPC
16117 and S/390, allowing users to write one HTM source implementation that
16118 can be compiled and executed on either system.
16120 @smallexample
16121 long __TM_simple_begin (void)
16122 long __TM_begin (void* const TM_buff)
16123 long __TM_end (void)
16124 void __TM_abort (void)
16125 void __TM_named_abort (unsigned char const code)
16126 void __TM_resume (void)
16127 void __TM_suspend (void)
16129 long __TM_is_user_abort (void* const TM_buff)
16130 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16131 long __TM_is_illegal (void* const TM_buff)
16132 long __TM_is_footprint_exceeded (void* const TM_buff)
16133 long __TM_nesting_depth (void* const TM_buff)
16134 long __TM_is_nested_too_deep(void* const TM_buff)
16135 long __TM_is_conflict(void* const TM_buff)
16136 long __TM_is_failure_persistent(void* const TM_buff)
16137 long __TM_failure_address(void* const TM_buff)
16138 long long __TM_failure_code(void* const TM_buff)
16139 @end smallexample
16141 Using these common set of HTM inline functions, we can create
16142 a more portable version of the HTM example in the previous
16143 section that will work on either PowerPC or S/390:
16145 @smallexample
16146 #include <htmxlintrin.h>
16148 int num_retries = 10;
16149 TM_buff_type TM_buff;
16151 while (1)
16152   @{
16153     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16154       @{
16155         /* Transaction State Initiated.  */
16156         if (is_locked (lock))
16157           __TM_abort ();
16158         ... transaction code...
16159         __TM_end ();
16160         break;
16161       @}
16162     else
16163       @{
16164         /* Transaction State Failed.  Use locks if the transaction
16165            failure is "persistent" or we've tried too many times.  */
16166         if (num_retries-- <= 0
16167             || __TM_is_failure_persistent (TM_buff))
16168           @{
16169             acquire_lock (lock);
16170             ... non transactional fallback path...
16171             release_lock (lock);
16172             break;
16173           @}
16174       @}
16175   @}
16176 @end smallexample
16178 @node RX Built-in Functions
16179 @subsection RX Built-in Functions
16180 GCC supports some of the RX instructions which cannot be expressed in
16181 the C programming language via the use of built-in functions.  The
16182 following functions are supported:
16184 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16185 Generates the @code{brk} machine instruction.
16186 @end deftypefn
16188 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16189 Generates the @code{clrpsw} machine instruction to clear the specified
16190 bit in the processor status word.
16191 @end deftypefn
16193 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16194 Generates the @code{int} machine instruction to generate an interrupt
16195 with the specified value.
16196 @end deftypefn
16198 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16199 Generates the @code{machi} machine instruction to add the result of
16200 multiplying the top 16 bits of the two arguments into the
16201 accumulator.
16202 @end deftypefn
16204 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16205 Generates the @code{maclo} machine instruction to add the result of
16206 multiplying the bottom 16 bits of the two arguments into the
16207 accumulator.
16208 @end deftypefn
16210 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16211 Generates the @code{mulhi} machine instruction to place the result of
16212 multiplying the top 16 bits of the two arguments into the
16213 accumulator.
16214 @end deftypefn
16216 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16217 Generates the @code{mullo} machine instruction to place the result of
16218 multiplying the bottom 16 bits of the two arguments into the
16219 accumulator.
16220 @end deftypefn
16222 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16223 Generates the @code{mvfachi} machine instruction to read the top
16224 32 bits of the accumulator.
16225 @end deftypefn
16227 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16228 Generates the @code{mvfacmi} machine instruction to read the middle
16229 32 bits of the accumulator.
16230 @end deftypefn
16232 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16233 Generates the @code{mvfc} machine instruction which reads the control
16234 register specified in its argument and returns its value.
16235 @end deftypefn
16237 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16238 Generates the @code{mvtachi} machine instruction to set the top
16239 32 bits of the accumulator.
16240 @end deftypefn
16242 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16243 Generates the @code{mvtaclo} machine instruction to set the bottom
16244 32 bits of the accumulator.
16245 @end deftypefn
16247 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16248 Generates the @code{mvtc} machine instruction which sets control
16249 register number @code{reg} to @code{val}.
16250 @end deftypefn
16252 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16253 Generates the @code{mvtipl} machine instruction set the interrupt
16254 priority level.
16255 @end deftypefn
16257 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16258 Generates the @code{racw} machine instruction to round the accumulator
16259 according to the specified mode.
16260 @end deftypefn
16262 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16263 Generates the @code{revw} machine instruction which swaps the bytes in
16264 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16265 and also bits 16--23 occupy bits 24--31 and vice versa.
16266 @end deftypefn
16268 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16269 Generates the @code{rmpa} machine instruction which initiates a
16270 repeated multiply and accumulate sequence.
16271 @end deftypefn
16273 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16274 Generates the @code{round} machine instruction which returns the
16275 floating-point argument rounded according to the current rounding mode
16276 set in the floating-point status word register.
16277 @end deftypefn
16279 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16280 Generates the @code{sat} machine instruction which returns the
16281 saturated value of the argument.
16282 @end deftypefn
16284 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16285 Generates the @code{setpsw} machine instruction to set the specified
16286 bit in the processor status word.
16287 @end deftypefn
16289 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16290 Generates the @code{wait} machine instruction.
16291 @end deftypefn
16293 @node S/390 System z Built-in Functions
16294 @subsection S/390 System z Built-in Functions
16295 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16296 Generates the @code{tbegin} machine instruction starting a
16297 non-constraint hardware transaction.  If the parameter is non-NULL the
16298 memory area is used to store the transaction diagnostic buffer and
16299 will be passed as first operand to @code{tbegin}.  This buffer can be
16300 defined using the @code{struct __htm_tdb} C struct defined in
16301 @code{htmintrin.h} and must reside on a double-word boundary.  The
16302 second tbegin operand is set to @code{0xff0c}. This enables
16303 save/restore of all GPRs and disables aborts for FPR and AR
16304 manipulations inside the transaction body.  The condition code set by
16305 the tbegin instruction is returned as integer value.  The tbegin
16306 instruction by definition overwrites the content of all FPRs.  The
16307 compiler will generate code which saves and restores the FPRs.  For
16308 soft-float code it is recommended to used the @code{*_nofloat}
16309 variant.  In order to prevent a TDB from being written it is required
16310 to pass an constant zero value as parameter.  Passing the zero value
16311 through a variable is not sufficient.  Although modifications of
16312 access registers inside the transaction will not trigger an
16313 transaction abort it is not supported to actually modify them.  Access
16314 registers do not get saved when entering a transaction. They will have
16315 undefined state when reaching the abort code.
16316 @end deftypefn
16318 Macros for the possible return codes of tbegin are defined in the
16319 @code{htmintrin.h} header file:
16321 @table @code
16322 @item _HTM_TBEGIN_STARTED
16323 @code{tbegin} has been executed as part of normal processing.  The
16324 transaction body is supposed to be executed.
16325 @item _HTM_TBEGIN_INDETERMINATE
16326 The transaction was aborted due to an indeterminate condition which
16327 might be persistent.
16328 @item _HTM_TBEGIN_TRANSIENT
16329 The transaction aborted due to a transient failure.  The transaction
16330 should be re-executed in that case.
16331 @item _HTM_TBEGIN_PERSISTENT
16332 The transaction aborted due to a persistent failure.  Re-execution
16333 under same circumstances will not be productive.
16334 @end table
16336 @defmac _HTM_FIRST_USER_ABORT_CODE
16337 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16338 specifies the first abort code which can be used for
16339 @code{__builtin_tabort}.  Values below this threshold are reserved for
16340 machine use.
16341 @end defmac
16343 @deftp {Data type} {struct __htm_tdb}
16344 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16345 the structure of the transaction diagnostic block as specified in the
16346 Principles of Operation manual chapter 5-91.
16347 @end deftp
16349 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16350 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16351 Using this variant in code making use of FPRs will leave the FPRs in
16352 undefined state when entering the transaction abort handler code.
16353 @end deftypefn
16355 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16356 In addition to @code{__builtin_tbegin} a loop for transient failures
16357 is generated.  If tbegin returns a condition code of 2 the transaction
16358 will be retried as often as specified in the second argument.  The
16359 perform processor assist instruction is used to tell the CPU about the
16360 number of fails so far.
16361 @end deftypefn
16363 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16364 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16365 restores.  Using this variant in code making use of FPRs will leave
16366 the FPRs in undefined state when entering the transaction abort
16367 handler code.
16368 @end deftypefn
16370 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16371 Generates the @code{tbeginc} machine instruction starting a constraint
16372 hardware transaction.  The second operand is set to @code{0xff08}.
16373 @end deftypefn
16375 @deftypefn {Built-in Function} int __builtin_tend (void)
16376 Generates the @code{tend} machine instruction finishing a transaction
16377 and making the changes visible to other threads.  The condition code
16378 generated by tend is returned as integer value.
16379 @end deftypefn
16381 @deftypefn {Built-in Function} void __builtin_tabort (int)
16382 Generates the @code{tabort} machine instruction with the specified
16383 abort code.  Abort codes from 0 through 255 are reserved and will
16384 result in an error message.
16385 @end deftypefn
16387 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16388 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16389 integer parameter is loaded into rX and a value of zero is loaded into
16390 rY.  The integer parameter specifies the number of times the
16391 transaction repeatedly aborted.
16392 @end deftypefn
16394 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16395 Generates the @code{etnd} machine instruction.  The current nesting
16396 depth is returned as integer value.  For a nesting depth of 0 the code
16397 is not executed as part of an transaction.
16398 @end deftypefn
16400 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16402 Generates the @code{ntstg} machine instruction.  The second argument
16403 is written to the first arguments location.  The store operation will
16404 not be rolled-back in case of an transaction abort.
16405 @end deftypefn
16407 @node SH Built-in Functions
16408 @subsection SH Built-in Functions
16409 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16410 families of processors:
16412 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16413 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16414 used by system code that manages threads and execution contexts.  The compiler
16415 normally does not generate code that modifies the contents of @samp{GBR} and
16416 thus the value is preserved across function calls.  Changing the @samp{GBR}
16417 value in user code must be done with caution, since the compiler might use
16418 @samp{GBR} in order to access thread local variables.
16420 @end deftypefn
16422 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16423 Returns the value that is currently set in the @samp{GBR} register.
16424 Memory loads and stores that use the thread pointer as a base address are
16425 turned into @samp{GBR} based displacement loads and stores, if possible.
16426 For example:
16427 @smallexample
16428 struct my_tcb
16430    int a, b, c, d, e;
16433 int get_tcb_value (void)
16435   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16436   return ((my_tcb*)__builtin_thread_pointer ())->c;
16439 @end smallexample
16440 @end deftypefn
16442 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16443 Returns the value that is currently set in the @samp{FPSCR} register.
16444 @end deftypefn
16446 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16447 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16448 preserving the current values of the FR, SZ and PR bits.
16449 @end deftypefn
16451 @node SPARC VIS Built-in Functions
16452 @subsection SPARC VIS Built-in Functions
16454 GCC supports SIMD operations on the SPARC using both the generic vector
16455 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16456 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16457 switch, the VIS extension is exposed as the following built-in functions:
16459 @smallexample
16460 typedef int v1si __attribute__ ((vector_size (4)));
16461 typedef int v2si __attribute__ ((vector_size (8)));
16462 typedef short v4hi __attribute__ ((vector_size (8)));
16463 typedef short v2hi __attribute__ ((vector_size (4)));
16464 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16465 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16467 void __builtin_vis_write_gsr (int64_t);
16468 int64_t __builtin_vis_read_gsr (void);
16470 void * __builtin_vis_alignaddr (void *, long);
16471 void * __builtin_vis_alignaddrl (void *, long);
16472 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16473 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16474 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16475 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16477 v4hi __builtin_vis_fexpand (v4qi);
16479 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16480 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16481 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16482 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16483 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16484 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16485 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16487 v4qi __builtin_vis_fpack16 (v4hi);
16488 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16489 v2hi __builtin_vis_fpackfix (v2si);
16490 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16492 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16494 long __builtin_vis_edge8 (void *, void *);
16495 long __builtin_vis_edge8l (void *, void *);
16496 long __builtin_vis_edge16 (void *, void *);
16497 long __builtin_vis_edge16l (void *, void *);
16498 long __builtin_vis_edge32 (void *, void *);
16499 long __builtin_vis_edge32l (void *, void *);
16501 long __builtin_vis_fcmple16 (v4hi, v4hi);
16502 long __builtin_vis_fcmple32 (v2si, v2si);
16503 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16504 long __builtin_vis_fcmpne32 (v2si, v2si);
16505 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16506 long __builtin_vis_fcmpgt32 (v2si, v2si);
16507 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16508 long __builtin_vis_fcmpeq32 (v2si, v2si);
16510 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16511 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16512 v2si __builtin_vis_fpadd32 (v2si, v2si);
16513 v1si __builtin_vis_fpadd32s (v1si, v1si);
16514 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16515 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16516 v2si __builtin_vis_fpsub32 (v2si, v2si);
16517 v1si __builtin_vis_fpsub32s (v1si, v1si);
16519 long __builtin_vis_array8 (long, long);
16520 long __builtin_vis_array16 (long, long);
16521 long __builtin_vis_array32 (long, long);
16522 @end smallexample
16524 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16525 functions also become available:
16527 @smallexample
16528 long __builtin_vis_bmask (long, long);
16529 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16530 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16531 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16532 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16534 long __builtin_vis_edge8n (void *, void *);
16535 long __builtin_vis_edge8ln (void *, void *);
16536 long __builtin_vis_edge16n (void *, void *);
16537 long __builtin_vis_edge16ln (void *, void *);
16538 long __builtin_vis_edge32n (void *, void *);
16539 long __builtin_vis_edge32ln (void *, void *);
16540 @end smallexample
16542 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16543 functions also become available:
16545 @smallexample
16546 void __builtin_vis_cmask8 (long);
16547 void __builtin_vis_cmask16 (long);
16548 void __builtin_vis_cmask32 (long);
16550 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16552 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16553 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16554 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16555 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16556 v2si __builtin_vis_fsll16 (v2si, v2si);
16557 v2si __builtin_vis_fslas16 (v2si, v2si);
16558 v2si __builtin_vis_fsrl16 (v2si, v2si);
16559 v2si __builtin_vis_fsra16 (v2si, v2si);
16561 long __builtin_vis_pdistn (v8qi, v8qi);
16563 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16565 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16566 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16568 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16569 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16570 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16571 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16572 v2si __builtin_vis_fpadds32 (v2si, v2si);
16573 v1si __builtin_vis_fpadds32s (v1si, v1si);
16574 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16575 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16577 long __builtin_vis_fucmple8 (v8qi, v8qi);
16578 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16579 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16580 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16582 float __builtin_vis_fhadds (float, float);
16583 double __builtin_vis_fhaddd (double, double);
16584 float __builtin_vis_fhsubs (float, float);
16585 double __builtin_vis_fhsubd (double, double);
16586 float __builtin_vis_fnhadds (float, float);
16587 double __builtin_vis_fnhaddd (double, double);
16589 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16590 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16591 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16592 @end smallexample
16594 @node SPU Built-in Functions
16595 @subsection SPU Built-in Functions
16597 GCC provides extensions for the SPU processor as described in the
16598 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16599 found at @uref{http://cell.scei.co.jp/} or
16600 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16601 implementation differs in several ways.
16603 @itemize @bullet
16605 @item
16606 The optional extension of specifying vector constants in parentheses is
16607 not supported.
16609 @item
16610 A vector initializer requires no cast if the vector constant is of the
16611 same type as the variable it is initializing.
16613 @item
16614 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16615 vector type is the default signedness of the base type.  The default
16616 varies depending on the operating system, so a portable program should
16617 always specify the signedness.
16619 @item
16620 By default, the keyword @code{__vector} is added. The macro
16621 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16622 undefined.
16624 @item
16625 GCC allows using a @code{typedef} name as the type specifier for a
16626 vector type.
16628 @item
16629 For C, overloaded functions are implemented with macros so the following
16630 does not work:
16632 @smallexample
16633   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16634 @end smallexample
16636 @noindent
16637 Since @code{spu_add} is a macro, the vector constant in the example
16638 is treated as four separate arguments.  Wrap the entire argument in
16639 parentheses for this to work.
16641 @item
16642 The extended version of @code{__builtin_expect} is not supported.
16644 @end itemize
16646 @emph{Note:} Only the interface described in the aforementioned
16647 specification is supported. Internally, GCC uses built-in functions to
16648 implement the required functionality, but these are not supported and
16649 are subject to change without notice.
16651 @node TI C6X Built-in Functions
16652 @subsection TI C6X Built-in Functions
16654 GCC provides intrinsics to access certain instructions of the TI C6X
16655 processors.  These intrinsics, listed below, are available after
16656 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16657 to C6X instructions.
16659 @smallexample
16661 int _sadd (int, int)
16662 int _ssub (int, int)
16663 int _sadd2 (int, int)
16664 int _ssub2 (int, int)
16665 long long _mpy2 (int, int)
16666 long long _smpy2 (int, int)
16667 int _add4 (int, int)
16668 int _sub4 (int, int)
16669 int _saddu4 (int, int)
16671 int _smpy (int, int)
16672 int _smpyh (int, int)
16673 int _smpyhl (int, int)
16674 int _smpylh (int, int)
16676 int _sshl (int, int)
16677 int _subc (int, int)
16679 int _avg2 (int, int)
16680 int _avgu4 (int, int)
16682 int _clrr (int, int)
16683 int _extr (int, int)
16684 int _extru (int, int)
16685 int _abs (int)
16686 int _abs2 (int)
16688 @end smallexample
16690 @node TILE-Gx Built-in Functions
16691 @subsection TILE-Gx Built-in Functions
16693 GCC provides intrinsics to access every instruction of the TILE-Gx
16694 processor.  The intrinsics are of the form:
16696 @smallexample
16698 unsigned long long __insn_@var{op} (...)
16700 @end smallexample
16702 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16703 for the complete list of instructions.
16705 GCC also provides intrinsics to directly access the network registers.
16706 The intrinsics are:
16708 @smallexample
16710 unsigned long long __tile_idn0_receive (void)
16711 unsigned long long __tile_idn1_receive (void)
16712 unsigned long long __tile_udn0_receive (void)
16713 unsigned long long __tile_udn1_receive (void)
16714 unsigned long long __tile_udn2_receive (void)
16715 unsigned long long __tile_udn3_receive (void)
16716 void __tile_idn_send (unsigned long long)
16717 void __tile_udn_send (unsigned long long)
16719 @end smallexample
16721 The intrinsic @code{void __tile_network_barrier (void)} is used to
16722 guarantee that no network operations before it are reordered with
16723 those after it.
16725 @node TILEPro Built-in Functions
16726 @subsection TILEPro Built-in Functions
16728 GCC provides intrinsics to access every instruction of the TILEPro
16729 processor.  The intrinsics are of the form:
16731 @smallexample
16733 unsigned __insn_@var{op} (...)
16735 @end smallexample
16737 @noindent
16738 where @var{op} is the name of the instruction.  Refer to the ISA manual
16739 for the complete list of instructions.
16741 GCC also provides intrinsics to directly access the network registers.
16742 The intrinsics are:
16744 @smallexample
16746 unsigned __tile_idn0_receive (void)
16747 unsigned __tile_idn1_receive (void)
16748 unsigned __tile_sn_receive (void)
16749 unsigned __tile_udn0_receive (void)
16750 unsigned __tile_udn1_receive (void)
16751 unsigned __tile_udn2_receive (void)
16752 unsigned __tile_udn3_receive (void)
16753 void __tile_idn_send (unsigned)
16754 void __tile_sn_send (unsigned)
16755 void __tile_udn_send (unsigned)
16757 @end smallexample
16759 The intrinsic @code{void __tile_network_barrier (void)} is used to
16760 guarantee that no network operations before it are reordered with
16761 those after it.
16763 @node x86 Built-in Functions
16764 @subsection x86 Built-in Functions
16766 These built-in functions are available for the x86-32 and x86-64 family
16767 of computers, depending on the command-line switches used.
16769 If you specify command-line switches such as @option{-msse},
16770 the compiler could use the extended instruction sets even if the built-ins
16771 are not used explicitly in the program.  For this reason, applications
16772 that perform run-time CPU detection must compile separate files for each
16773 supported architecture, using the appropriate flags.  In particular,
16774 the file containing the CPU detection code should be compiled without
16775 these options.
16777 The following machine modes are available for use with MMX built-in functions
16778 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
16779 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
16780 vector of eight 8-bit integers.  Some of the built-in functions operate on
16781 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
16783 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
16784 of two 32-bit floating-point values.
16786 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
16787 floating-point values.  Some instructions use a vector of four 32-bit
16788 integers, these use @code{V4SI}.  Finally, some instructions operate on an
16789 entire vector register, interpreting it as a 128-bit integer, these use mode
16790 @code{TI}.
16792 In 64-bit mode, the x86-64 family of processors uses additional built-in
16793 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
16794 floating point and @code{TC} 128-bit complex floating-point values.
16796 The following floating-point built-in functions are available in 64-bit
16797 mode.  All of them implement the function that is part of the name.
16799 @smallexample
16800 __float128 __builtin_fabsq (__float128)
16801 __float128 __builtin_copysignq (__float128, __float128)
16802 @end smallexample
16804 The following built-in function is always available.
16806 @table @code
16807 @item void __builtin_ia32_pause (void)
16808 Generates the @code{pause} machine instruction with a compiler memory
16809 barrier.
16810 @end table
16812 The following floating-point built-in functions are made available in the
16813 64-bit mode.
16815 @table @code
16816 @item __float128 __builtin_infq (void)
16817 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
16818 @findex __builtin_infq
16820 @item __float128 __builtin_huge_valq (void)
16821 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
16822 @findex __builtin_huge_valq
16823 @end table
16825 The following built-in functions are always available and can be used to
16826 check the target platform type.
16828 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16829 This function runs the CPU detection code to check the type of CPU and the
16830 features supported.  This built-in function needs to be invoked along with the built-in functions
16831 to check CPU type and features, @code{__builtin_cpu_is} and
16832 @code{__builtin_cpu_supports}, only when used in a function that is
16833 executed before any constructors are called.  The CPU detection code is
16834 automatically executed in a very high priority constructor.
16836 For example, this function has to be used in @code{ifunc} resolvers that
16837 check for CPU type using the built-in functions @code{__builtin_cpu_is}
16838 and @code{__builtin_cpu_supports}, or in constructors on targets that
16839 don't support constructor priority.
16840 @smallexample
16842 static void (*resolve_memcpy (void)) (void)
16844   // ifunc resolvers fire before constructors, explicitly call the init
16845   // function.
16846   __builtin_cpu_init ();
16847   if (__builtin_cpu_supports ("ssse3"))
16848     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
16849   else
16850     return default_memcpy;
16853 void *memcpy (void *, const void *, size_t)
16854      __attribute__ ((ifunc ("resolve_memcpy")));
16855 @end smallexample
16857 @end deftypefn
16859 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16860 This function returns a positive integer if the run-time CPU
16861 is of type @var{cpuname}
16862 and returns @code{0} otherwise. The following CPU names can be detected:
16864 @table @samp
16865 @item intel
16866 Intel CPU.
16868 @item atom
16869 Intel Atom CPU.
16871 @item core2
16872 Intel Core 2 CPU.
16874 @item corei7
16875 Intel Core i7 CPU.
16877 @item nehalem
16878 Intel Core i7 Nehalem CPU.
16880 @item westmere
16881 Intel Core i7 Westmere CPU.
16883 @item sandybridge
16884 Intel Core i7 Sandy Bridge CPU.
16886 @item amd
16887 AMD CPU.
16889 @item amdfam10h
16890 AMD Family 10h CPU.
16892 @item barcelona
16893 AMD Family 10h Barcelona CPU.
16895 @item shanghai
16896 AMD Family 10h Shanghai CPU.
16898 @item istanbul
16899 AMD Family 10h Istanbul CPU.
16901 @item btver1
16902 AMD Family 14h CPU.
16904 @item amdfam15h
16905 AMD Family 15h CPU.
16907 @item bdver1
16908 AMD Family 15h Bulldozer version 1.
16910 @item bdver2
16911 AMD Family 15h Bulldozer version 2.
16913 @item bdver3
16914 AMD Family 15h Bulldozer version 3.
16916 @item bdver4
16917 AMD Family 15h Bulldozer version 4.
16919 @item btver2
16920 AMD Family 16h CPU.
16921 @end table
16923 Here is an example:
16924 @smallexample
16925 if (__builtin_cpu_is ("corei7"))
16926   @{
16927      do_corei7 (); // Core i7 specific implementation.
16928   @}
16929 else
16930   @{
16931      do_generic (); // Generic implementation.
16932   @}
16933 @end smallexample
16934 @end deftypefn
16936 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16937 This function returns a positive integer if the run-time CPU
16938 supports @var{feature}
16939 and returns @code{0} otherwise. The following features can be detected:
16941 @table @samp
16942 @item cmov
16943 CMOV instruction.
16944 @item mmx
16945 MMX instructions.
16946 @item popcnt
16947 POPCNT instruction.
16948 @item sse
16949 SSE instructions.
16950 @item sse2
16951 SSE2 instructions.
16952 @item sse3
16953 SSE3 instructions.
16954 @item ssse3
16955 SSSE3 instructions.
16956 @item sse4.1
16957 SSE4.1 instructions.
16958 @item sse4.2
16959 SSE4.2 instructions.
16960 @item avx
16961 AVX instructions.
16962 @item avx2
16963 AVX2 instructions.
16964 @item avx512f
16965 AVX512F instructions.
16966 @end table
16968 Here is an example:
16969 @smallexample
16970 if (__builtin_cpu_supports ("popcnt"))
16971   @{
16972      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
16973   @}
16974 else
16975   @{
16976      count = generic_countbits (n); //generic implementation.
16977   @}
16978 @end smallexample
16979 @end deftypefn
16982 The following built-in functions are made available by @option{-mmmx}.
16983 All of them generate the machine instruction that is part of the name.
16985 @smallexample
16986 v8qi __builtin_ia32_paddb (v8qi, v8qi)
16987 v4hi __builtin_ia32_paddw (v4hi, v4hi)
16988 v2si __builtin_ia32_paddd (v2si, v2si)
16989 v8qi __builtin_ia32_psubb (v8qi, v8qi)
16990 v4hi __builtin_ia32_psubw (v4hi, v4hi)
16991 v2si __builtin_ia32_psubd (v2si, v2si)
16992 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
16993 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
16994 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
16995 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
16996 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
16997 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
16998 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
16999 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17000 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17001 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17002 di __builtin_ia32_pand (di, di)
17003 di __builtin_ia32_pandn (di,di)
17004 di __builtin_ia32_por (di, di)
17005 di __builtin_ia32_pxor (di, di)
17006 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17007 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17008 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17009 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17010 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17011 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17012 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17013 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17014 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17015 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17016 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17017 v2si __builtin_ia32_punpckldq (v2si, v2si)
17018 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17019 v4hi __builtin_ia32_packssdw (v2si, v2si)
17020 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17022 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17023 v2si __builtin_ia32_pslld (v2si, v2si)
17024 v1di __builtin_ia32_psllq (v1di, v1di)
17025 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17026 v2si __builtin_ia32_psrld (v2si, v2si)
17027 v1di __builtin_ia32_psrlq (v1di, v1di)
17028 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17029 v2si __builtin_ia32_psrad (v2si, v2si)
17030 v4hi __builtin_ia32_psllwi (v4hi, int)
17031 v2si __builtin_ia32_pslldi (v2si, int)
17032 v1di __builtin_ia32_psllqi (v1di, int)
17033 v4hi __builtin_ia32_psrlwi (v4hi, int)
17034 v2si __builtin_ia32_psrldi (v2si, int)
17035 v1di __builtin_ia32_psrlqi (v1di, int)
17036 v4hi __builtin_ia32_psrawi (v4hi, int)
17037 v2si __builtin_ia32_psradi (v2si, int)
17039 @end smallexample
17041 The following built-in functions are made available either with
17042 @option{-msse}, or with a combination of @option{-m3dnow} and
17043 @option{-march=athlon}.  All of them generate the machine
17044 instruction that is part of the name.
17046 @smallexample
17047 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17048 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17049 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17050 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17051 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17052 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17053 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17054 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17055 int __builtin_ia32_pmovmskb (v8qi)
17056 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17057 void __builtin_ia32_movntq (di *, di)
17058 void __builtin_ia32_sfence (void)
17059 @end smallexample
17061 The following built-in functions are available when @option{-msse} is used.
17062 All of them generate the machine instruction that is part of the name.
17064 @smallexample
17065 int __builtin_ia32_comieq (v4sf, v4sf)
17066 int __builtin_ia32_comineq (v4sf, v4sf)
17067 int __builtin_ia32_comilt (v4sf, v4sf)
17068 int __builtin_ia32_comile (v4sf, v4sf)
17069 int __builtin_ia32_comigt (v4sf, v4sf)
17070 int __builtin_ia32_comige (v4sf, v4sf)
17071 int __builtin_ia32_ucomieq (v4sf, v4sf)
17072 int __builtin_ia32_ucomineq (v4sf, v4sf)
17073 int __builtin_ia32_ucomilt (v4sf, v4sf)
17074 int __builtin_ia32_ucomile (v4sf, v4sf)
17075 int __builtin_ia32_ucomigt (v4sf, v4sf)
17076 int __builtin_ia32_ucomige (v4sf, v4sf)
17077 v4sf __builtin_ia32_addps (v4sf, v4sf)
17078 v4sf __builtin_ia32_subps (v4sf, v4sf)
17079 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17080 v4sf __builtin_ia32_divps (v4sf, v4sf)
17081 v4sf __builtin_ia32_addss (v4sf, v4sf)
17082 v4sf __builtin_ia32_subss (v4sf, v4sf)
17083 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17084 v4sf __builtin_ia32_divss (v4sf, v4sf)
17085 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17086 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17087 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17088 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17089 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17090 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17091 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17092 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17093 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17094 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17095 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17096 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17097 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17098 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17099 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17100 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17101 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17102 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17103 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17104 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17105 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17106 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17107 v4sf __builtin_ia32_minps (v4sf, v4sf)
17108 v4sf __builtin_ia32_minss (v4sf, v4sf)
17109 v4sf __builtin_ia32_andps (v4sf, v4sf)
17110 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17111 v4sf __builtin_ia32_orps (v4sf, v4sf)
17112 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17113 v4sf __builtin_ia32_movss (v4sf, v4sf)
17114 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17115 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17116 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17117 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17118 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17119 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17120 v2si __builtin_ia32_cvtps2pi (v4sf)
17121 int __builtin_ia32_cvtss2si (v4sf)
17122 v2si __builtin_ia32_cvttps2pi (v4sf)
17123 int __builtin_ia32_cvttss2si (v4sf)
17124 v4sf __builtin_ia32_rcpps (v4sf)
17125 v4sf __builtin_ia32_rsqrtps (v4sf)
17126 v4sf __builtin_ia32_sqrtps (v4sf)
17127 v4sf __builtin_ia32_rcpss (v4sf)
17128 v4sf __builtin_ia32_rsqrtss (v4sf)
17129 v4sf __builtin_ia32_sqrtss (v4sf)
17130 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17131 void __builtin_ia32_movntps (float *, v4sf)
17132 int __builtin_ia32_movmskps (v4sf)
17133 @end smallexample
17135 The following built-in functions are available when @option{-msse} is used.
17137 @table @code
17138 @item v4sf __builtin_ia32_loadups (float *)
17139 Generates the @code{movups} machine instruction as a load from memory.
17140 @item void __builtin_ia32_storeups (float *, v4sf)
17141 Generates the @code{movups} machine instruction as a store to memory.
17142 @item v4sf __builtin_ia32_loadss (float *)
17143 Generates the @code{movss} machine instruction as a load from memory.
17144 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17145 Generates the @code{movhps} machine instruction as a load from memory.
17146 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17147 Generates the @code{movlps} machine instruction as a load from memory
17148 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17149 Generates the @code{movhps} machine instruction as a store to memory.
17150 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17151 Generates the @code{movlps} machine instruction as a store to memory.
17152 @end table
17154 The following built-in functions are available when @option{-msse2} is used.
17155 All of them generate the machine instruction that is part of the name.
17157 @smallexample
17158 int __builtin_ia32_comisdeq (v2df, v2df)
17159 int __builtin_ia32_comisdlt (v2df, v2df)
17160 int __builtin_ia32_comisdle (v2df, v2df)
17161 int __builtin_ia32_comisdgt (v2df, v2df)
17162 int __builtin_ia32_comisdge (v2df, v2df)
17163 int __builtin_ia32_comisdneq (v2df, v2df)
17164 int __builtin_ia32_ucomisdeq (v2df, v2df)
17165 int __builtin_ia32_ucomisdlt (v2df, v2df)
17166 int __builtin_ia32_ucomisdle (v2df, v2df)
17167 int __builtin_ia32_ucomisdgt (v2df, v2df)
17168 int __builtin_ia32_ucomisdge (v2df, v2df)
17169 int __builtin_ia32_ucomisdneq (v2df, v2df)
17170 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17171 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17172 v2df __builtin_ia32_cmplepd (v2df, v2df)
17173 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17174 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17175 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17176 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17177 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17178 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17179 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17180 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17181 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17182 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17183 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17184 v2df __builtin_ia32_cmplesd (v2df, v2df)
17185 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17186 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17187 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17188 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17189 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17190 v2di __builtin_ia32_paddq (v2di, v2di)
17191 v2di __builtin_ia32_psubq (v2di, v2di)
17192 v2df __builtin_ia32_addpd (v2df, v2df)
17193 v2df __builtin_ia32_subpd (v2df, v2df)
17194 v2df __builtin_ia32_mulpd (v2df, v2df)
17195 v2df __builtin_ia32_divpd (v2df, v2df)
17196 v2df __builtin_ia32_addsd (v2df, v2df)
17197 v2df __builtin_ia32_subsd (v2df, v2df)
17198 v2df __builtin_ia32_mulsd (v2df, v2df)
17199 v2df __builtin_ia32_divsd (v2df, v2df)
17200 v2df __builtin_ia32_minpd (v2df, v2df)
17201 v2df __builtin_ia32_maxpd (v2df, v2df)
17202 v2df __builtin_ia32_minsd (v2df, v2df)
17203 v2df __builtin_ia32_maxsd (v2df, v2df)
17204 v2df __builtin_ia32_andpd (v2df, v2df)
17205 v2df __builtin_ia32_andnpd (v2df, v2df)
17206 v2df __builtin_ia32_orpd (v2df, v2df)
17207 v2df __builtin_ia32_xorpd (v2df, v2df)
17208 v2df __builtin_ia32_movsd (v2df, v2df)
17209 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17210 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17211 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17212 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17213 v4si __builtin_ia32_paddd128 (v4si, v4si)
17214 v2di __builtin_ia32_paddq128 (v2di, v2di)
17215 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17216 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17217 v4si __builtin_ia32_psubd128 (v4si, v4si)
17218 v2di __builtin_ia32_psubq128 (v2di, v2di)
17219 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17220 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17221 v2di __builtin_ia32_pand128 (v2di, v2di)
17222 v2di __builtin_ia32_pandn128 (v2di, v2di)
17223 v2di __builtin_ia32_por128 (v2di, v2di)
17224 v2di __builtin_ia32_pxor128 (v2di, v2di)
17225 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17226 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17227 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17228 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17229 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17230 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17231 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17232 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17233 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17234 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17235 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17236 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17237 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17238 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17239 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17240 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17241 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17242 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17243 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17244 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17245 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17246 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17247 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17248 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17249 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17250 v2df __builtin_ia32_loadupd (double *)
17251 void __builtin_ia32_storeupd (double *, v2df)
17252 v2df __builtin_ia32_loadhpd (v2df, double const *)
17253 v2df __builtin_ia32_loadlpd (v2df, double const *)
17254 int __builtin_ia32_movmskpd (v2df)
17255 int __builtin_ia32_pmovmskb128 (v16qi)
17256 void __builtin_ia32_movnti (int *, int)
17257 void __builtin_ia32_movnti64 (long long int *, long long int)
17258 void __builtin_ia32_movntpd (double *, v2df)
17259 void __builtin_ia32_movntdq (v2df *, v2df)
17260 v4si __builtin_ia32_pshufd (v4si, int)
17261 v8hi __builtin_ia32_pshuflw (v8hi, int)
17262 v8hi __builtin_ia32_pshufhw (v8hi, int)
17263 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17264 v2df __builtin_ia32_sqrtpd (v2df)
17265 v2df __builtin_ia32_sqrtsd (v2df)
17266 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17267 v2df __builtin_ia32_cvtdq2pd (v4si)
17268 v4sf __builtin_ia32_cvtdq2ps (v4si)
17269 v4si __builtin_ia32_cvtpd2dq (v2df)
17270 v2si __builtin_ia32_cvtpd2pi (v2df)
17271 v4sf __builtin_ia32_cvtpd2ps (v2df)
17272 v4si __builtin_ia32_cvttpd2dq (v2df)
17273 v2si __builtin_ia32_cvttpd2pi (v2df)
17274 v2df __builtin_ia32_cvtpi2pd (v2si)
17275 int __builtin_ia32_cvtsd2si (v2df)
17276 int __builtin_ia32_cvttsd2si (v2df)
17277 long long __builtin_ia32_cvtsd2si64 (v2df)
17278 long long __builtin_ia32_cvttsd2si64 (v2df)
17279 v4si __builtin_ia32_cvtps2dq (v4sf)
17280 v2df __builtin_ia32_cvtps2pd (v4sf)
17281 v4si __builtin_ia32_cvttps2dq (v4sf)
17282 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17283 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17284 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17285 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17286 void __builtin_ia32_clflush (const void *)
17287 void __builtin_ia32_lfence (void)
17288 void __builtin_ia32_mfence (void)
17289 v16qi __builtin_ia32_loaddqu (const char *)
17290 void __builtin_ia32_storedqu (char *, v16qi)
17291 v1di __builtin_ia32_pmuludq (v2si, v2si)
17292 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17293 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17294 v4si __builtin_ia32_pslld128 (v4si, v4si)
17295 v2di __builtin_ia32_psllq128 (v2di, v2di)
17296 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17297 v4si __builtin_ia32_psrld128 (v4si, v4si)
17298 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17299 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17300 v4si __builtin_ia32_psrad128 (v4si, v4si)
17301 v2di __builtin_ia32_pslldqi128 (v2di, int)
17302 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17303 v4si __builtin_ia32_pslldi128 (v4si, int)
17304 v2di __builtin_ia32_psllqi128 (v2di, int)
17305 v2di __builtin_ia32_psrldqi128 (v2di, int)
17306 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17307 v4si __builtin_ia32_psrldi128 (v4si, int)
17308 v2di __builtin_ia32_psrlqi128 (v2di, int)
17309 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17310 v4si __builtin_ia32_psradi128 (v4si, int)
17311 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17312 v2di __builtin_ia32_movq128 (v2di)
17313 @end smallexample
17315 The following built-in functions are available when @option{-msse3} is used.
17316 All of them generate the machine instruction that is part of the name.
17318 @smallexample
17319 v2df __builtin_ia32_addsubpd (v2df, v2df)
17320 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17321 v2df __builtin_ia32_haddpd (v2df, v2df)
17322 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17323 v2df __builtin_ia32_hsubpd (v2df, v2df)
17324 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17325 v16qi __builtin_ia32_lddqu (char const *)
17326 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17327 v4sf __builtin_ia32_movshdup (v4sf)
17328 v4sf __builtin_ia32_movsldup (v4sf)
17329 void __builtin_ia32_mwait (unsigned int, unsigned int)
17330 @end smallexample
17332 The following built-in functions are available when @option{-mssse3} is used.
17333 All of them generate the machine instruction that is part of the name.
17335 @smallexample
17336 v2si __builtin_ia32_phaddd (v2si, v2si)
17337 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17338 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17339 v2si __builtin_ia32_phsubd (v2si, v2si)
17340 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17341 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17342 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17343 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17344 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17345 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17346 v2si __builtin_ia32_psignd (v2si, v2si)
17347 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17348 v1di __builtin_ia32_palignr (v1di, v1di, int)
17349 v8qi __builtin_ia32_pabsb (v8qi)
17350 v2si __builtin_ia32_pabsd (v2si)
17351 v4hi __builtin_ia32_pabsw (v4hi)
17352 @end smallexample
17354 The following built-in functions are available when @option{-mssse3} is used.
17355 All of them generate the machine instruction that is part of the name.
17357 @smallexample
17358 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17359 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17360 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17361 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17362 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17363 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17364 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17365 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17366 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17367 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17368 v4si __builtin_ia32_psignd128 (v4si, v4si)
17369 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17370 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17371 v16qi __builtin_ia32_pabsb128 (v16qi)
17372 v4si __builtin_ia32_pabsd128 (v4si)
17373 v8hi __builtin_ia32_pabsw128 (v8hi)
17374 @end smallexample
17376 The following built-in functions are available when @option{-msse4.1} is
17377 used.  All of them generate the machine instruction that is part of the
17378 name.
17380 @smallexample
17381 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17382 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17383 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17384 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17385 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17386 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17387 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17388 v2di __builtin_ia32_movntdqa (v2di *);
17389 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17390 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17391 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17392 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17393 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17394 v8hi __builtin_ia32_phminposuw128 (v8hi)
17395 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17396 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17397 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17398 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17399 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17400 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17401 v4si __builtin_ia32_pminud128 (v4si, v4si)
17402 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17403 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17404 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17405 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17406 v2di __builtin_ia32_pmovsxdq128 (v4si)
17407 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17408 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17409 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17410 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17411 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17412 v2di __builtin_ia32_pmovzxdq128 (v4si)
17413 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17414 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17415 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17416 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17417 int __builtin_ia32_ptestc128 (v2di, v2di)
17418 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17419 int __builtin_ia32_ptestz128 (v2di, v2di)
17420 v2df __builtin_ia32_roundpd (v2df, const int)
17421 v4sf __builtin_ia32_roundps (v4sf, const int)
17422 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17423 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17424 @end smallexample
17426 The following built-in functions are available when @option{-msse4.1} is
17427 used.
17429 @table @code
17430 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17431 Generates the @code{insertps} machine instruction.
17432 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17433 Generates the @code{pextrb} machine instruction.
17434 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17435 Generates the @code{pinsrb} machine instruction.
17436 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17437 Generates the @code{pinsrd} machine instruction.
17438 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17439 Generates the @code{pinsrq} machine instruction in 64bit mode.
17440 @end table
17442 The following built-in functions are changed to generate new SSE4.1
17443 instructions when @option{-msse4.1} is used.
17445 @table @code
17446 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17447 Generates the @code{extractps} machine instruction.
17448 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17449 Generates the @code{pextrd} machine instruction.
17450 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17451 Generates the @code{pextrq} machine instruction in 64bit mode.
17452 @end table
17454 The following built-in functions are available when @option{-msse4.2} is
17455 used.  All of them generate the machine instruction that is part of the
17456 name.
17458 @smallexample
17459 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17460 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17461 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17462 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17463 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17464 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17465 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17466 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17467 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17468 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17469 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17470 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17471 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17472 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17473 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17474 @end smallexample
17476 The following built-in functions are available when @option{-msse4.2} is
17477 used.
17479 @table @code
17480 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17481 Generates the @code{crc32b} machine instruction.
17482 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17483 Generates the @code{crc32w} machine instruction.
17484 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17485 Generates the @code{crc32l} machine instruction.
17486 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17487 Generates the @code{crc32q} machine instruction.
17488 @end table
17490 The following built-in functions are changed to generate new SSE4.2
17491 instructions when @option{-msse4.2} is used.
17493 @table @code
17494 @item int __builtin_popcount (unsigned int)
17495 Generates the @code{popcntl} machine instruction.
17496 @item int __builtin_popcountl (unsigned long)
17497 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17498 depending on the size of @code{unsigned long}.
17499 @item int __builtin_popcountll (unsigned long long)
17500 Generates the @code{popcntq} machine instruction.
17501 @end table
17503 The following built-in functions are available when @option{-mavx} is
17504 used. All of them generate the machine instruction that is part of the
17505 name.
17507 @smallexample
17508 v4df __builtin_ia32_addpd256 (v4df,v4df)
17509 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17510 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17511 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17512 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17513 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17514 v4df __builtin_ia32_andpd256 (v4df,v4df)
17515 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17516 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17517 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17518 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17519 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17520 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17521 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17522 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17523 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17524 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17525 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17526 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17527 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17528 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17529 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17530 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17531 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17532 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17533 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17534 v4df __builtin_ia32_divpd256 (v4df,v4df)
17535 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17536 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17537 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17538 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17539 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17540 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17541 v32qi __builtin_ia32_lddqu256 (pcchar)
17542 v32qi __builtin_ia32_loaddqu256 (pcchar)
17543 v4df __builtin_ia32_loadupd256 (pcdouble)
17544 v8sf __builtin_ia32_loadups256 (pcfloat)
17545 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17546 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17547 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17548 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17549 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17550 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17551 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17552 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17553 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17554 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17555 v4df __builtin_ia32_minpd256 (v4df,v4df)
17556 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17557 v4df __builtin_ia32_movddup256 (v4df)
17558 int __builtin_ia32_movmskpd256 (v4df)
17559 int __builtin_ia32_movmskps256 (v8sf)
17560 v8sf __builtin_ia32_movshdup256 (v8sf)
17561 v8sf __builtin_ia32_movsldup256 (v8sf)
17562 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17563 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17564 v4df __builtin_ia32_orpd256 (v4df,v4df)
17565 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17566 v2df __builtin_ia32_pd_pd256 (v4df)
17567 v4df __builtin_ia32_pd256_pd (v2df)
17568 v4sf __builtin_ia32_ps_ps256 (v8sf)
17569 v8sf __builtin_ia32_ps256_ps (v4sf)
17570 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17571 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17572 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17573 v8sf __builtin_ia32_rcpps256 (v8sf)
17574 v4df __builtin_ia32_roundpd256 (v4df,int)
17575 v8sf __builtin_ia32_roundps256 (v8sf,int)
17576 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17577 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17578 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17579 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17580 v4si __builtin_ia32_si_si256 (v8si)
17581 v8si __builtin_ia32_si256_si (v4si)
17582 v4df __builtin_ia32_sqrtpd256 (v4df)
17583 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17584 v8sf __builtin_ia32_sqrtps256 (v8sf)
17585 void __builtin_ia32_storedqu256 (pchar,v32qi)
17586 void __builtin_ia32_storeupd256 (pdouble,v4df)
17587 void __builtin_ia32_storeups256 (pfloat,v8sf)
17588 v4df __builtin_ia32_subpd256 (v4df,v4df)
17589 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17590 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17591 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17592 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17593 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17594 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17595 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17596 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17597 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17598 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17599 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17600 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17601 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17602 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17603 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17604 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17605 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17606 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17607 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17608 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17609 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17610 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17611 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17612 v2df __builtin_ia32_vpermilpd (v2df,int)
17613 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17614 v4sf __builtin_ia32_vpermilps (v4sf,int)
17615 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17616 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17617 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17618 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17619 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17620 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17621 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17622 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17623 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17624 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17625 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17626 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17627 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17628 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17629 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17630 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17631 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17632 void __builtin_ia32_vzeroall (void)
17633 void __builtin_ia32_vzeroupper (void)
17634 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17635 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17636 @end smallexample
17638 The following built-in functions are available when @option{-mavx2} is
17639 used. All of them generate the machine instruction that is part of the
17640 name.
17642 @smallexample
17643 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17644 v32qi __builtin_ia32_pabsb256 (v32qi)
17645 v16hi __builtin_ia32_pabsw256 (v16hi)
17646 v8si __builtin_ia32_pabsd256 (v8si)
17647 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17648 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17649 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17650 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17651 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17652 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17653 v8si __builtin_ia32_paddd256 (v8si,v8si)
17654 v4di __builtin_ia32_paddq256 (v4di,v4di)
17655 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17656 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17657 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17658 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17659 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17660 v4di __builtin_ia32_andsi256 (v4di,v4di)
17661 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17662 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17663 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17664 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17665 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17666 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17667 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17668 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17669 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17670 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17671 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17672 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17673 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17674 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17675 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17676 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17677 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17678 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17679 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17680 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17681 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17682 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17683 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17684 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17685 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17686 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17687 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17688 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17689 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17690 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17691 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17692 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17693 v8si __builtin_ia32_pminud256 (v8si,v8si)
17694 int __builtin_ia32_pmovmskb256 (v32qi)
17695 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17696 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17697 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17698 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17699 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17700 v4di __builtin_ia32_pmovsxdq256 (v4si)
17701 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17702 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17703 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17704 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17705 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17706 v4di __builtin_ia32_pmovzxdq256 (v4si)
17707 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17708 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17709 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17710 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17711 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17712 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17713 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17714 v4di __builtin_ia32_por256 (v4di,v4di)
17715 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17716 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17717 v8si __builtin_ia32_pshufd256 (v8si,int)
17718 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17719 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17720 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17721 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17722 v8si __builtin_ia32_psignd256 (v8si,v8si)
17723 v4di __builtin_ia32_pslldqi256 (v4di,int)
17724 v16hi __builtin_ia32_psllwi256 (16hi,int)
17725 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17726 v8si __builtin_ia32_pslldi256 (v8si,int)
17727 v8si __builtin_ia32_pslld256(v8si,v4si)
17728 v4di __builtin_ia32_psllqi256 (v4di,int)
17729 v4di __builtin_ia32_psllq256(v4di,v2di)
17730 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17731 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17732 v8si __builtin_ia32_psradi256 (v8si,int)
17733 v8si __builtin_ia32_psrad256 (v8si,v4si)
17734 v4di __builtin_ia32_psrldqi256 (v4di, int)
17735 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17736 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17737 v8si __builtin_ia32_psrldi256 (v8si,int)
17738 v8si __builtin_ia32_psrld256 (v8si,v4si)
17739 v4di __builtin_ia32_psrlqi256 (v4di,int)
17740 v4di __builtin_ia32_psrlq256(v4di,v2di)
17741 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17742 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17743 v8si __builtin_ia32_psubd256 (v8si,v8si)
17744 v4di __builtin_ia32_psubq256 (v4di,v4di)
17745 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17746 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17747 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17748 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17749 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17750 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17751 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17752 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
17753 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
17754 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
17755 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
17756 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
17757 v4di __builtin_ia32_pxor256 (v4di,v4di)
17758 v4di __builtin_ia32_movntdqa256 (pv4di)
17759 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
17760 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
17761 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
17762 v4di __builtin_ia32_vbroadcastsi256 (v2di)
17763 v4si __builtin_ia32_pblendd128 (v4si,v4si)
17764 v8si __builtin_ia32_pblendd256 (v8si,v8si)
17765 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
17766 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
17767 v8si __builtin_ia32_pbroadcastd256 (v4si)
17768 v4di __builtin_ia32_pbroadcastq256 (v2di)
17769 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
17770 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
17771 v4si __builtin_ia32_pbroadcastd128 (v4si)
17772 v2di __builtin_ia32_pbroadcastq128 (v2di)
17773 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
17774 v4df __builtin_ia32_permdf256 (v4df,int)
17775 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
17776 v4di __builtin_ia32_permdi256 (v4di,int)
17777 v4di __builtin_ia32_permti256 (v4di,v4di,int)
17778 v4di __builtin_ia32_extract128i256 (v4di,int)
17779 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
17780 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
17781 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
17782 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
17783 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
17784 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
17785 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
17786 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
17787 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
17788 v8si __builtin_ia32_psllv8si (v8si,v8si)
17789 v4si __builtin_ia32_psllv4si (v4si,v4si)
17790 v4di __builtin_ia32_psllv4di (v4di,v4di)
17791 v2di __builtin_ia32_psllv2di (v2di,v2di)
17792 v8si __builtin_ia32_psrav8si (v8si,v8si)
17793 v4si __builtin_ia32_psrav4si (v4si,v4si)
17794 v8si __builtin_ia32_psrlv8si (v8si,v8si)
17795 v4si __builtin_ia32_psrlv4si (v4si,v4si)
17796 v4di __builtin_ia32_psrlv4di (v4di,v4di)
17797 v2di __builtin_ia32_psrlv2di (v2di,v2di)
17798 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
17799 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
17800 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
17801 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
17802 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
17803 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
17804 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
17805 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
17806 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
17807 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
17808 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
17809 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
17810 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
17811 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
17812 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
17813 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
17814 @end smallexample
17816 The following built-in functions are available when @option{-maes} is
17817 used.  All of them generate the machine instruction that is part of the
17818 name.
17820 @smallexample
17821 v2di __builtin_ia32_aesenc128 (v2di, v2di)
17822 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
17823 v2di __builtin_ia32_aesdec128 (v2di, v2di)
17824 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
17825 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
17826 v2di __builtin_ia32_aesimc128 (v2di)
17827 @end smallexample
17829 The following built-in function is available when @option{-mpclmul} is
17830 used.
17832 @table @code
17833 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
17834 Generates the @code{pclmulqdq} machine instruction.
17835 @end table
17837 The following built-in function is available when @option{-mfsgsbase} is
17838 used.  All of them generate the machine instruction that is part of the
17839 name.
17841 @smallexample
17842 unsigned int __builtin_ia32_rdfsbase32 (void)
17843 unsigned long long __builtin_ia32_rdfsbase64 (void)
17844 unsigned int __builtin_ia32_rdgsbase32 (void)
17845 unsigned long long __builtin_ia32_rdgsbase64 (void)
17846 void _writefsbase_u32 (unsigned int)
17847 void _writefsbase_u64 (unsigned long long)
17848 void _writegsbase_u32 (unsigned int)
17849 void _writegsbase_u64 (unsigned long long)
17850 @end smallexample
17852 The following built-in function is available when @option{-mrdrnd} is
17853 used.  All of them generate the machine instruction that is part of the
17854 name.
17856 @smallexample
17857 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
17858 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
17859 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
17860 @end smallexample
17862 The following built-in functions are available when @option{-msse4a} is used.
17863 All of them generate the machine instruction that is part of the name.
17865 @smallexample
17866 void __builtin_ia32_movntsd (double *, v2df)
17867 void __builtin_ia32_movntss (float *, v4sf)
17868 v2di __builtin_ia32_extrq  (v2di, v16qi)
17869 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
17870 v2di __builtin_ia32_insertq (v2di, v2di)
17871 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
17872 @end smallexample
17874 The following built-in functions are available when @option{-mxop} is used.
17875 @smallexample
17876 v2df __builtin_ia32_vfrczpd (v2df)
17877 v4sf __builtin_ia32_vfrczps (v4sf)
17878 v2df __builtin_ia32_vfrczsd (v2df)
17879 v4sf __builtin_ia32_vfrczss (v4sf)
17880 v4df __builtin_ia32_vfrczpd256 (v4df)
17881 v8sf __builtin_ia32_vfrczps256 (v8sf)
17882 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
17883 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
17884 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
17885 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
17886 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
17887 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
17888 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
17889 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
17890 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
17891 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
17892 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
17893 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
17894 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
17895 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
17896 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17897 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
17898 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
17899 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
17900 v4si __builtin_ia32_vpcomequd (v4si, v4si)
17901 v2di __builtin_ia32_vpcomequq (v2di, v2di)
17902 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
17903 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17904 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
17905 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
17906 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
17907 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
17908 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
17909 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
17910 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
17911 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
17912 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
17913 v4si __builtin_ia32_vpcomged (v4si, v4si)
17914 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
17915 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
17916 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
17917 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
17918 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
17919 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
17920 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
17921 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
17922 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
17923 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
17924 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
17925 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
17926 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
17927 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
17928 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
17929 v4si __builtin_ia32_vpcomled (v4si, v4si)
17930 v2di __builtin_ia32_vpcomleq (v2di, v2di)
17931 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
17932 v4si __builtin_ia32_vpcomleud (v4si, v4si)
17933 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
17934 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
17935 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
17936 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
17937 v4si __builtin_ia32_vpcomltd (v4si, v4si)
17938 v2di __builtin_ia32_vpcomltq (v2di, v2di)
17939 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
17940 v4si __builtin_ia32_vpcomltud (v4si, v4si)
17941 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
17942 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
17943 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
17944 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
17945 v4si __builtin_ia32_vpcomned (v4si, v4si)
17946 v2di __builtin_ia32_vpcomneq (v2di, v2di)
17947 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
17948 v4si __builtin_ia32_vpcomneud (v4si, v4si)
17949 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
17950 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
17951 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
17952 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
17953 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
17954 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
17955 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
17956 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
17957 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
17958 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
17959 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
17960 v4si __builtin_ia32_vphaddbd (v16qi)
17961 v2di __builtin_ia32_vphaddbq (v16qi)
17962 v8hi __builtin_ia32_vphaddbw (v16qi)
17963 v2di __builtin_ia32_vphadddq (v4si)
17964 v4si __builtin_ia32_vphaddubd (v16qi)
17965 v2di __builtin_ia32_vphaddubq (v16qi)
17966 v8hi __builtin_ia32_vphaddubw (v16qi)
17967 v2di __builtin_ia32_vphaddudq (v4si)
17968 v4si __builtin_ia32_vphadduwd (v8hi)
17969 v2di __builtin_ia32_vphadduwq (v8hi)
17970 v4si __builtin_ia32_vphaddwd (v8hi)
17971 v2di __builtin_ia32_vphaddwq (v8hi)
17972 v8hi __builtin_ia32_vphsubbw (v16qi)
17973 v2di __builtin_ia32_vphsubdq (v4si)
17974 v4si __builtin_ia32_vphsubwd (v8hi)
17975 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
17976 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
17977 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
17978 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
17979 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
17980 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
17981 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
17982 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
17983 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
17984 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
17985 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
17986 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
17987 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
17988 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
17989 v4si __builtin_ia32_vprotd (v4si, v4si)
17990 v2di __builtin_ia32_vprotq (v2di, v2di)
17991 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
17992 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
17993 v4si __builtin_ia32_vpshad (v4si, v4si)
17994 v2di __builtin_ia32_vpshaq (v2di, v2di)
17995 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
17996 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
17997 v4si __builtin_ia32_vpshld (v4si, v4si)
17998 v2di __builtin_ia32_vpshlq (v2di, v2di)
17999 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18000 @end smallexample
18002 The following built-in functions are available when @option{-mfma4} is used.
18003 All of them generate the machine instruction that is part of the name.
18005 @smallexample
18006 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18007 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18008 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18009 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18010 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18011 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18012 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18013 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18014 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18015 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18016 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18017 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18018 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18019 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18020 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18021 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18022 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
18023 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
18024 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
18025 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
18026 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18027 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18028 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18029 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18030 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18031 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18032 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18033 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18034 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18035 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18036 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18037 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18039 @end smallexample
18041 The following built-in functions are available when @option{-mlwp} is used.
18043 @smallexample
18044 void __builtin_ia32_llwpcb16 (void *);
18045 void __builtin_ia32_llwpcb32 (void *);
18046 void __builtin_ia32_llwpcb64 (void *);
18047 void * __builtin_ia32_llwpcb16 (void);
18048 void * __builtin_ia32_llwpcb32 (void);
18049 void * __builtin_ia32_llwpcb64 (void);
18050 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18051 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18052 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18053 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18054 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18055 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18056 @end smallexample
18058 The following built-in functions are available when @option{-mbmi} is used.
18059 All of them generate the machine instruction that is part of the name.
18060 @smallexample
18061 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18062 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18063 @end smallexample
18065 The following built-in functions are available when @option{-mbmi2} is used.
18066 All of them generate the machine instruction that is part of the name.
18067 @smallexample
18068 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18069 unsigned int _pdep_u32 (unsigned int, unsigned int)
18070 unsigned int _pext_u32 (unsigned int, unsigned int)
18071 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18072 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18073 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18074 @end smallexample
18076 The following built-in functions are available when @option{-mlzcnt} is used.
18077 All of them generate the machine instruction that is part of the name.
18078 @smallexample
18079 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18080 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18081 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18082 @end smallexample
18084 The following built-in functions are available when @option{-mfxsr} is used.
18085 All of them generate the machine instruction that is part of the name.
18086 @smallexample
18087 void __builtin_ia32_fxsave (void *)
18088 void __builtin_ia32_fxrstor (void *)
18089 void __builtin_ia32_fxsave64 (void *)
18090 void __builtin_ia32_fxrstor64 (void *)
18091 @end smallexample
18093 The following built-in functions are available when @option{-mxsave} is used.
18094 All of them generate the machine instruction that is part of the name.
18095 @smallexample
18096 void __builtin_ia32_xsave (void *, long long)
18097 void __builtin_ia32_xrstor (void *, long long)
18098 void __builtin_ia32_xsave64 (void *, long long)
18099 void __builtin_ia32_xrstor64 (void *, long long)
18100 @end smallexample
18102 The following built-in functions are available when @option{-mxsaveopt} is used.
18103 All of them generate the machine instruction that is part of the name.
18104 @smallexample
18105 void __builtin_ia32_xsaveopt (void *, long long)
18106 void __builtin_ia32_xsaveopt64 (void *, long long)
18107 @end smallexample
18109 The following built-in functions are available when @option{-mtbm} is used.
18110 Both of them generate the immediate form of the bextr machine instruction.
18111 @smallexample
18112 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18113 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18114 @end smallexample
18117 The following built-in functions are available when @option{-m3dnow} is used.
18118 All of them generate the machine instruction that is part of the name.
18120 @smallexample
18121 void __builtin_ia32_femms (void)
18122 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18123 v2si __builtin_ia32_pf2id (v2sf)
18124 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18125 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18126 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18127 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18128 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18129 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18130 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18131 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18132 v2sf __builtin_ia32_pfrcp (v2sf)
18133 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18134 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18135 v2sf __builtin_ia32_pfrsqrt (v2sf)
18136 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18137 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18138 v2sf __builtin_ia32_pi2fd (v2si)
18139 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18140 @end smallexample
18142 The following built-in functions are available when both @option{-m3dnow}
18143 and @option{-march=athlon} are used.  All of them generate the machine
18144 instruction that is part of the name.
18146 @smallexample
18147 v2si __builtin_ia32_pf2iw (v2sf)
18148 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18149 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18150 v2sf __builtin_ia32_pi2fw (v2si)
18151 v2sf __builtin_ia32_pswapdsf (v2sf)
18152 v2si __builtin_ia32_pswapdsi (v2si)
18153 @end smallexample
18155 The following built-in functions are available when @option{-mrtm} is used
18156 They are used for restricted transactional memory. These are the internal
18157 low level functions. Normally the functions in 
18158 @ref{x86 transactional memory intrinsics} should be used instead.
18160 @smallexample
18161 int __builtin_ia32_xbegin ()
18162 void __builtin_ia32_xend ()
18163 void __builtin_ia32_xabort (status)
18164 int __builtin_ia32_xtest ()
18165 @end smallexample
18167 The following built-in functions are available when @option{-mmwaitx} is used.
18168 All of them generate the machine instruction that is part of the name.
18169 @smallexample
18170 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18171 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18172 @end smallexample
18174 @node x86 transactional memory intrinsics
18175 @subsection x86 Transactional Memory Intrinsics
18177 These hardware transactional memory intrinsics for x86 allow you to use
18178 memory transactions with RTM (Restricted Transactional Memory).
18179 This support is enabled with the @option{-mrtm} option.
18180 For using HLE (Hardware Lock Elision) see 
18181 @ref{x86 specific memory model extensions for transactional memory} instead.
18183 A memory transaction commits all changes to memory in an atomic way,
18184 as visible to other threads. If the transaction fails it is rolled back
18185 and all side effects discarded.
18187 Generally there is no guarantee that a memory transaction ever succeeds
18188 and suitable fallback code always needs to be supplied.
18190 @deftypefn {RTM Function} {unsigned} _xbegin ()
18191 Start a RTM (Restricted Transactional Memory) transaction. 
18192 Returns @code{_XBEGIN_STARTED} when the transaction
18193 started successfully (note this is not 0, so the constant has to be 
18194 explicitly tested).  
18196 If the transaction aborts, all side-effects 
18197 are undone and an abort code encoded as a bit mask is returned.
18198 The following macros are defined:
18200 @table @code
18201 @item _XABORT_EXPLICIT
18202 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
18203 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18204 @item _XABORT_RETRY
18205 Transaction retry is possible.
18206 @item _XABORT_CONFLICT
18207 Transaction abort due to a memory conflict with another thread.
18208 @item _XABORT_CAPACITY
18209 Transaction abort due to the transaction using too much memory.
18210 @item _XABORT_DEBUG
18211 Transaction abort due to a debug trap.
18212 @item _XABORT_NESTED
18213 Transaction abort in an inner nested transaction.
18214 @end table
18216 There is no guarantee
18217 any transaction ever succeeds, so there always needs to be a valid
18218 fallback path.
18219 @end deftypefn
18221 @deftypefn {RTM Function} {void} _xend ()
18222 Commit the current transaction. When no transaction is active this faults.
18223 All memory side-effects of the transaction become visible
18224 to other threads in an atomic manner.
18225 @end deftypefn
18227 @deftypefn {RTM Function} {int} _xtest ()
18228 Return a nonzero value if a transaction is currently active, otherwise 0.
18229 @end deftypefn
18231 @deftypefn {RTM Function} {void} _xabort (status)
18232 Abort the current transaction. When no transaction is active this is a no-op.
18233 The @var{status} is an 8-bit constant; its value is encoded in the return 
18234 value from @code{_xbegin}.
18235 @end deftypefn
18237 Here is an example showing handling for @code{_XABORT_RETRY}
18238 and a fallback path for other failures:
18240 @smallexample
18241 #include <immintrin.h>
18243 int n_tries, max_tries;
18244 unsigned status = _XABORT_EXPLICIT;
18247 for (n_tries = 0; n_tries < max_tries; n_tries++) 
18248   @{
18249     status = _xbegin ();
18250     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18251       break;
18252   @}
18253 if (status == _XBEGIN_STARTED) 
18254   @{
18255     ... transaction code...
18256     _xend ();
18257   @} 
18258 else 
18259   @{
18260     ... non-transactional fallback path...
18261   @}
18262 @end smallexample
18264 @noindent
18265 Note that, in most cases, the transactional and non-transactional code
18266 must synchronize together to ensure consistency.
18268 @node Target Format Checks
18269 @section Format Checks Specific to Particular Target Machines
18271 For some target machines, GCC supports additional options to the
18272 format attribute
18273 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18275 @menu
18276 * Solaris Format Checks::
18277 * Darwin Format Checks::
18278 @end menu
18280 @node Solaris Format Checks
18281 @subsection Solaris Format Checks
18283 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18284 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
18285 conversions, and the two-argument @code{%b} conversion for displaying
18286 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
18288 @node Darwin Format Checks
18289 @subsection Darwin Format Checks
18291 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18292 attribute context.  Declarations made with such attribution are parsed for correct syntax
18293 and format argument types.  However, parsing of the format string itself is currently undefined
18294 and is not carried out by this version of the compiler.
18296 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18297 also be used as format arguments.  Note that the relevant headers are only likely to be
18298 available on Darwin (OSX) installations.  On such installations, the XCode and system
18299 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18300 associated functions.
18302 @node Pragmas
18303 @section Pragmas Accepted by GCC
18304 @cindex pragmas
18305 @cindex @code{#pragma}
18307 GCC supports several types of pragmas, primarily in order to compile
18308 code originally written for other compilers.  Note that in general
18309 we do not recommend the use of pragmas; @xref{Function Attributes},
18310 for further explanation.
18312 @menu
18313 * AArch64 Pragmas::
18314 * ARM Pragmas::
18315 * M32C Pragmas::
18316 * MeP Pragmas::
18317 * RS/6000 and PowerPC Pragmas::
18318 * Darwin Pragmas::
18319 * Solaris Pragmas::
18320 * Symbol-Renaming Pragmas::
18321 * Structure-Packing Pragmas::
18322 * Weak Pragmas::
18323 * Diagnostic Pragmas::
18324 * Visibility Pragmas::
18325 * Push/Pop Macro Pragmas::
18326 * Function Specific Option Pragmas::
18327 * Loop-Specific Pragmas::
18328 @end menu
18330 @node AArch64 Pragmas
18331 @subsection AArch64 Pragmas
18333 The pragmas defined by the AArch64 target correspond to the AArch64
18334 target function attributes.  They can be specified as below:
18335 @smallexample
18336 #pragma GCC target("string")
18337 @end smallexample
18339 where @code{@var{string}} can be any string accepted as an AArch64 target
18340 attribute.  @xref{AArch64 Function Attributes}, for more details
18341 on the permissible values of @code{string}.
18343 @node ARM Pragmas
18344 @subsection ARM Pragmas
18346 The ARM target defines pragmas for controlling the default addition of
18347 @code{long_call} and @code{short_call} attributes to functions.
18348 @xref{Function Attributes}, for information about the effects of these
18349 attributes.
18351 @table @code
18352 @item long_calls
18353 @cindex pragma, long_calls
18354 Set all subsequent functions to have the @code{long_call} attribute.
18356 @item no_long_calls
18357 @cindex pragma, no_long_calls
18358 Set all subsequent functions to have the @code{short_call} attribute.
18360 @item long_calls_off
18361 @cindex pragma, long_calls_off
18362 Do not affect the @code{long_call} or @code{short_call} attributes of
18363 subsequent functions.
18364 @end table
18366 @node M32C Pragmas
18367 @subsection M32C Pragmas
18369 @table @code
18370 @item GCC memregs @var{number}
18371 @cindex pragma, memregs
18372 Overrides the command-line option @code{-memregs=} for the current
18373 file.  Use with care!  This pragma must be before any function in the
18374 file, and mixing different memregs values in different objects may
18375 make them incompatible.  This pragma is useful when a
18376 performance-critical function uses a memreg for temporary values,
18377 as it may allow you to reduce the number of memregs used.
18379 @item ADDRESS @var{name} @var{address}
18380 @cindex pragma, address
18381 For any declared symbols matching @var{name}, this does three things
18382 to that symbol: it forces the symbol to be located at the given
18383 address (a number), it forces the symbol to be volatile, and it
18384 changes the symbol's scope to be static.  This pragma exists for
18385 compatibility with other compilers, but note that the common
18386 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18387 instead).  Example:
18389 @smallexample
18390 #pragma ADDRESS port3 0x103
18391 char port3;
18392 @end smallexample
18394 @end table
18396 @node MeP Pragmas
18397 @subsection MeP Pragmas
18399 @table @code
18401 @item custom io_volatile (on|off)
18402 @cindex pragma, custom io_volatile
18403 Overrides the command-line option @code{-mio-volatile} for the current
18404 file.  Note that for compatibility with future GCC releases, this
18405 option should only be used once before any @code{io} variables in each
18406 file.
18408 @item GCC coprocessor available @var{registers}
18409 @cindex pragma, coprocessor available
18410 Specifies which coprocessor registers are available to the register
18411 allocator.  @var{registers} may be a single register, register range
18412 separated by ellipses, or comma-separated list of those.  Example:
18414 @smallexample
18415 #pragma GCC coprocessor available $c0...$c10, $c28
18416 @end smallexample
18418 @item GCC coprocessor call_saved @var{registers}
18419 @cindex pragma, coprocessor call_saved
18420 Specifies which coprocessor registers are to be saved and restored by
18421 any function using them.  @var{registers} may be a single register,
18422 register range separated by ellipses, or comma-separated list of
18423 those.  Example:
18425 @smallexample
18426 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18427 @end smallexample
18429 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18430 @cindex pragma, coprocessor subclass
18431 Creates and defines a register class.  These register classes can be
18432 used by inline @code{asm} constructs.  @var{registers} may be a single
18433 register, register range separated by ellipses, or comma-separated
18434 list of those.  Example:
18436 @smallexample
18437 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18439 asm ("cpfoo %0" : "=B" (x));
18440 @end smallexample
18442 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18443 @cindex pragma, disinterrupt
18444 For the named functions, the compiler adds code to disable interrupts
18445 for the duration of those functions.  If any functions so named 
18446 are not encountered in the source, a warning is emitted that the pragma is
18447 not used.  Examples:
18449 @smallexample
18450 #pragma disinterrupt foo
18451 #pragma disinterrupt bar, grill
18452 int foo () @{ @dots{} @}
18453 @end smallexample
18455 @item GCC call @var{name} , @var{name} @dots{}
18456 @cindex pragma, call
18457 For the named functions, the compiler always uses a register-indirect
18458 call model when calling the named functions.  Examples:
18460 @smallexample
18461 extern int foo ();
18462 #pragma call foo
18463 @end smallexample
18465 @end table
18467 @node RS/6000 and PowerPC Pragmas
18468 @subsection RS/6000 and PowerPC Pragmas
18470 The RS/6000 and PowerPC targets define one pragma for controlling
18471 whether or not the @code{longcall} attribute is added to function
18472 declarations by default.  This pragma overrides the @option{-mlongcall}
18473 option, but not the @code{longcall} and @code{shortcall} attributes.
18474 @xref{RS/6000 and PowerPC Options}, for more information about when long
18475 calls are and are not necessary.
18477 @table @code
18478 @item longcall (1)
18479 @cindex pragma, longcall
18480 Apply the @code{longcall} attribute to all subsequent function
18481 declarations.
18483 @item longcall (0)
18484 Do not apply the @code{longcall} attribute to subsequent function
18485 declarations.
18486 @end table
18488 @c Describe h8300 pragmas here.
18489 @c Describe sh pragmas here.
18490 @c Describe v850 pragmas here.
18492 @node Darwin Pragmas
18493 @subsection Darwin Pragmas
18495 The following pragmas are available for all architectures running the
18496 Darwin operating system.  These are useful for compatibility with other
18497 Mac OS compilers.
18499 @table @code
18500 @item mark @var{tokens}@dots{}
18501 @cindex pragma, mark
18502 This pragma is accepted, but has no effect.
18504 @item options align=@var{alignment}
18505 @cindex pragma, options align
18506 This pragma sets the alignment of fields in structures.  The values of
18507 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18508 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
18509 properly; to restore the previous setting, use @code{reset} for the
18510 @var{alignment}.
18512 @item segment @var{tokens}@dots{}
18513 @cindex pragma, segment
18514 This pragma is accepted, but has no effect.
18516 @item unused (@var{var} [, @var{var}]@dots{})
18517 @cindex pragma, unused
18518 This pragma declares variables to be possibly unused.  GCC does not
18519 produce warnings for the listed variables.  The effect is similar to
18520 that of the @code{unused} attribute, except that this pragma may appear
18521 anywhere within the variables' scopes.
18522 @end table
18524 @node Solaris Pragmas
18525 @subsection Solaris Pragmas
18527 The Solaris target supports @code{#pragma redefine_extname}
18528 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
18529 @code{#pragma} directives for compatibility with the system compiler.
18531 @table @code
18532 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18533 @cindex pragma, align
18535 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18536 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18537 Attributes}).  Macro expansion occurs on the arguments to this pragma
18538 when compiling C and Objective-C@.  It does not currently occur when
18539 compiling C++, but this is a bug which may be fixed in a future
18540 release.
18542 @item fini (@var{function} [, @var{function}]...)
18543 @cindex pragma, fini
18545 This pragma causes each listed @var{function} to be called after
18546 main, or during shared module unloading, by adding a call to the
18547 @code{.fini} section.
18549 @item init (@var{function} [, @var{function}]...)
18550 @cindex pragma, init
18552 This pragma causes each listed @var{function} to be called during
18553 initialization (before @code{main}) or during shared module loading, by
18554 adding a call to the @code{.init} section.
18556 @end table
18558 @node Symbol-Renaming Pragmas
18559 @subsection Symbol-Renaming Pragmas
18561 GCC supports a @code{#pragma} directive that changes the name used in
18562 assembly for a given declaration. While this pragma is supported on all
18563 platforms, it is intended primarily to provide compatibility with the
18564 Solaris system headers. This effect can also be achieved using the asm
18565 labels extension (@pxref{Asm Labels}).
18567 @table @code
18568 @item redefine_extname @var{oldname} @var{newname}
18569 @cindex pragma, redefine_extname
18571 This pragma gives the C function @var{oldname} the assembly symbol
18572 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18573 is defined if this pragma is available (currently on all platforms).
18574 @end table
18576 This pragma and the asm labels extension interact in a complicated
18577 manner.  Here are some corner cases you may want to be aware of:
18579 @enumerate
18580 @item This pragma silently applies only to declarations with external
18581 linkage.  Asm labels do not have this restriction.
18583 @item In C++, this pragma silently applies only to declarations with
18584 ``C'' linkage.  Again, asm labels do not have this restriction.
18586 @item If either of the ways of changing the assembly name of a
18587 declaration are applied to a declaration whose assembly name has
18588 already been determined (either by a previous use of one of these
18589 features, or because the compiler needed the assembly name in order to
18590 generate code), and the new name is different, a warning issues and
18591 the name does not change.
18593 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18594 always the C-language name.
18595 @end enumerate
18597 @node Structure-Packing Pragmas
18598 @subsection Structure-Packing Pragmas
18600 For compatibility with Microsoft Windows compilers, GCC supports a
18601 set of @code{#pragma} directives that change the maximum alignment of
18602 members of structures (other than zero-width bit-fields), unions, and
18603 classes subsequently defined. The @var{n} value below always is required
18604 to be a small power of two and specifies the new alignment in bytes.
18606 @enumerate
18607 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18608 @item @code{#pragma pack()} sets the alignment to the one that was in
18609 effect when compilation started (see also command-line option
18610 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18611 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18612 setting on an internal stack and then optionally sets the new alignment.
18613 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18614 saved at the top of the internal stack (and removes that stack entry).
18615 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18616 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18617 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18618 @code{#pragma pack(pop)}.
18619 @end enumerate
18621 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
18622 @code{#pragma} which lays out a structure as the documented
18623 @code{__attribute__ ((ms_struct))}.
18624 @enumerate
18625 @item @code{#pragma ms_struct on} turns on the layout for structures
18626 declared.
18627 @item @code{#pragma ms_struct off} turns off the layout for structures
18628 declared.
18629 @item @code{#pragma ms_struct reset} goes back to the default layout.
18630 @end enumerate
18632 @node Weak Pragmas
18633 @subsection Weak Pragmas
18635 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18636 directives for declaring symbols to be weak, and defining weak
18637 aliases.
18639 @table @code
18640 @item #pragma weak @var{symbol}
18641 @cindex pragma, weak
18642 This pragma declares @var{symbol} to be weak, as if the declaration
18643 had the attribute of the same name.  The pragma may appear before
18644 or after the declaration of @var{symbol}.  It is not an error for
18645 @var{symbol} to never be defined at all.
18647 @item #pragma weak @var{symbol1} = @var{symbol2}
18648 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18649 It is an error if @var{symbol2} is not defined in the current
18650 translation unit.
18651 @end table
18653 @node Diagnostic Pragmas
18654 @subsection Diagnostic Pragmas
18656 GCC allows the user to selectively enable or disable certain types of
18657 diagnostics, and change the kind of the diagnostic.  For example, a
18658 project's policy might require that all sources compile with
18659 @option{-Werror} but certain files might have exceptions allowing
18660 specific types of warnings.  Or, a project might selectively enable
18661 diagnostics and treat them as errors depending on which preprocessor
18662 macros are defined.
18664 @table @code
18665 @item #pragma GCC diagnostic @var{kind} @var{option}
18666 @cindex pragma, diagnostic
18668 Modifies the disposition of a diagnostic.  Note that not all
18669 diagnostics are modifiable; at the moment only warnings (normally
18670 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18671 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18672 are controllable and which option controls them.
18674 @var{kind} is @samp{error} to treat this diagnostic as an error,
18675 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18676 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18677 @var{option} is a double quoted string that matches the command-line
18678 option.
18680 @smallexample
18681 #pragma GCC diagnostic warning "-Wformat"
18682 #pragma GCC diagnostic error "-Wformat"
18683 #pragma GCC diagnostic ignored "-Wformat"
18684 @end smallexample
18686 Note that these pragmas override any command-line options.  GCC keeps
18687 track of the location of each pragma, and issues diagnostics according
18688 to the state as of that point in the source file.  Thus, pragmas occurring
18689 after a line do not affect diagnostics caused by that line.
18691 @item #pragma GCC diagnostic push
18692 @itemx #pragma GCC diagnostic pop
18694 Causes GCC to remember the state of the diagnostics as of each
18695 @code{push}, and restore to that point at each @code{pop}.  If a
18696 @code{pop} has no matching @code{push}, the command-line options are
18697 restored.
18699 @smallexample
18700 #pragma GCC diagnostic error "-Wuninitialized"
18701   foo(a);                       /* error is given for this one */
18702 #pragma GCC diagnostic push
18703 #pragma GCC diagnostic ignored "-Wuninitialized"
18704   foo(b);                       /* no diagnostic for this one */
18705 #pragma GCC diagnostic pop
18706   foo(c);                       /* error is given for this one */
18707 #pragma GCC diagnostic pop
18708   foo(d);                       /* depends on command-line options */
18709 @end smallexample
18711 @end table
18713 GCC also offers a simple mechanism for printing messages during
18714 compilation.
18716 @table @code
18717 @item #pragma message @var{string}
18718 @cindex pragma, diagnostic
18720 Prints @var{string} as a compiler message on compilation.  The message
18721 is informational only, and is neither a compilation warning nor an error.
18723 @smallexample
18724 #pragma message "Compiling " __FILE__ "..."
18725 @end smallexample
18727 @var{string} may be parenthesized, and is printed with location
18728 information.  For example,
18730 @smallexample
18731 #define DO_PRAGMA(x) _Pragma (#x)
18732 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
18734 TODO(Remember to fix this)
18735 @end smallexample
18737 @noindent
18738 prints @samp{/tmp/file.c:4: note: #pragma message:
18739 TODO - Remember to fix this}.
18741 @end table
18743 @node Visibility Pragmas
18744 @subsection Visibility Pragmas
18746 @table @code
18747 @item #pragma GCC visibility push(@var{visibility})
18748 @itemx #pragma GCC visibility pop
18749 @cindex pragma, visibility
18751 This pragma allows the user to set the visibility for multiple
18752 declarations without having to give each a visibility attribute
18753 (@pxref{Function Attributes}).
18755 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
18756 declarations.  Class members and template specializations are not
18757 affected; if you want to override the visibility for a particular
18758 member or instantiation, you must use an attribute.
18760 @end table
18763 @node Push/Pop Macro Pragmas
18764 @subsection Push/Pop Macro Pragmas
18766 For compatibility with Microsoft Windows compilers, GCC supports
18767 @samp{#pragma push_macro(@var{"macro_name"})}
18768 and @samp{#pragma pop_macro(@var{"macro_name"})}.
18770 @table @code
18771 @item #pragma push_macro(@var{"macro_name"})
18772 @cindex pragma, push_macro
18773 This pragma saves the value of the macro named as @var{macro_name} to
18774 the top of the stack for this macro.
18776 @item #pragma pop_macro(@var{"macro_name"})
18777 @cindex pragma, pop_macro
18778 This pragma sets the value of the macro named as @var{macro_name} to
18779 the value on top of the stack for this macro. If the stack for
18780 @var{macro_name} is empty, the value of the macro remains unchanged.
18781 @end table
18783 For example:
18785 @smallexample
18786 #define X  1
18787 #pragma push_macro("X")
18788 #undef X
18789 #define X -1
18790 #pragma pop_macro("X")
18791 int x [X];
18792 @end smallexample
18794 @noindent
18795 In this example, the definition of X as 1 is saved by @code{#pragma
18796 push_macro} and restored by @code{#pragma pop_macro}.
18798 @node Function Specific Option Pragmas
18799 @subsection Function Specific Option Pragmas
18801 @table @code
18802 @item #pragma GCC target (@var{"string"}...)
18803 @cindex pragma GCC target
18805 This pragma allows you to set target specific options for functions
18806 defined later in the source file.  One or more strings can be
18807 specified.  Each function that is defined after this point is as
18808 if @code{attribute((target("STRING")))} was specified for that
18809 function.  The parenthesis around the options is optional.
18810 @xref{Function Attributes}, for more information about the
18811 @code{target} attribute and the attribute syntax.
18813 The @code{#pragma GCC target} pragma is presently implemented for
18814 x86, PowerPC, and Nios II targets only.
18815 @end table
18817 @table @code
18818 @item #pragma GCC optimize (@var{"string"}...)
18819 @cindex pragma GCC optimize
18821 This pragma allows you to set global optimization options for functions
18822 defined later in the source file.  One or more strings can be
18823 specified.  Each function that is defined after this point is as
18824 if @code{attribute((optimize("STRING")))} was specified for that
18825 function.  The parenthesis around the options is optional.
18826 @xref{Function Attributes}, for more information about the
18827 @code{optimize} attribute and the attribute syntax.
18828 @end table
18830 @table @code
18831 @item #pragma GCC push_options
18832 @itemx #pragma GCC pop_options
18833 @cindex pragma GCC push_options
18834 @cindex pragma GCC pop_options
18836 These pragmas maintain a stack of the current target and optimization
18837 options.  It is intended for include files where you temporarily want
18838 to switch to using a different @samp{#pragma GCC target} or
18839 @samp{#pragma GCC optimize} and then to pop back to the previous
18840 options.
18841 @end table
18843 @table @code
18844 @item #pragma GCC reset_options
18845 @cindex pragma GCC reset_options
18847 This pragma clears the current @code{#pragma GCC target} and
18848 @code{#pragma GCC optimize} to use the default switches as specified
18849 on the command line.
18850 @end table
18852 @node Loop-Specific Pragmas
18853 @subsection Loop-Specific Pragmas
18855 @table @code
18856 @item #pragma GCC ivdep
18857 @cindex pragma GCC ivdep
18858 @end table
18860 With this pragma, the programmer asserts that there are no loop-carried
18861 dependencies which would prevent consecutive iterations of
18862 the following loop from executing concurrently with SIMD
18863 (single instruction multiple data) instructions.
18865 For example, the compiler can only unconditionally vectorize the following
18866 loop with the pragma:
18868 @smallexample
18869 void foo (int n, int *a, int *b, int *c)
18871   int i, j;
18872 #pragma GCC ivdep
18873   for (i = 0; i < n; ++i)
18874     a[i] = b[i] + c[i];
18876 @end smallexample
18878 @noindent
18879 In this example, using the @code{restrict} qualifier had the same
18880 effect. In the following example, that would not be possible. Assume
18881 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
18882 that it can unconditionally vectorize the following loop:
18884 @smallexample
18885 void ignore_vec_dep (int *a, int k, int c, int m)
18887 #pragma GCC ivdep
18888   for (int i = 0; i < m; i++)
18889     a[i] = a[i + k] * c;
18891 @end smallexample
18894 @node Unnamed Fields
18895 @section Unnamed Structure and Union Fields
18896 @cindex @code{struct}
18897 @cindex @code{union}
18899 As permitted by ISO C11 and for compatibility with other compilers,
18900 GCC allows you to define
18901 a structure or union that contains, as fields, structures and unions
18902 without names.  For example:
18904 @smallexample
18905 struct @{
18906   int a;
18907   union @{
18908     int b;
18909     float c;
18910   @};
18911   int d;
18912 @} foo;
18913 @end smallexample
18915 @noindent
18916 In this example, you are able to access members of the unnamed
18917 union with code like @samp{foo.b}.  Note that only unnamed structs and
18918 unions are allowed, you may not have, for example, an unnamed
18919 @code{int}.
18921 You must never create such structures that cause ambiguous field definitions.
18922 For example, in this structure:
18924 @smallexample
18925 struct @{
18926   int a;
18927   struct @{
18928     int a;
18929   @};
18930 @} foo;
18931 @end smallexample
18933 @noindent
18934 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
18935 The compiler gives errors for such constructs.
18937 @opindex fms-extensions
18938 Unless @option{-fms-extensions} is used, the unnamed field must be a
18939 structure or union definition without a tag (for example, @samp{struct
18940 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
18941 also be a definition with a tag such as @samp{struct foo @{ int a;
18942 @};}, a reference to a previously defined structure or union such as
18943 @samp{struct foo;}, or a reference to a @code{typedef} name for a
18944 previously defined structure or union type.
18946 @opindex fplan9-extensions
18947 The option @option{-fplan9-extensions} enables
18948 @option{-fms-extensions} as well as two other extensions.  First, a
18949 pointer to a structure is automatically converted to a pointer to an
18950 anonymous field for assignments and function calls.  For example:
18952 @smallexample
18953 struct s1 @{ int a; @};
18954 struct s2 @{ struct s1; @};
18955 extern void f1 (struct s1 *);
18956 void f2 (struct s2 *p) @{ f1 (p); @}
18957 @end smallexample
18959 @noindent
18960 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
18961 converted into a pointer to the anonymous field.
18963 Second, when the type of an anonymous field is a @code{typedef} for a
18964 @code{struct} or @code{union}, code may refer to the field using the
18965 name of the @code{typedef}.
18967 @smallexample
18968 typedef struct @{ int a; @} s1;
18969 struct s2 @{ s1; @};
18970 s1 f1 (struct s2 *p) @{ return p->s1; @}
18971 @end smallexample
18973 These usages are only permitted when they are not ambiguous.
18975 @node Thread-Local
18976 @section Thread-Local Storage
18977 @cindex Thread-Local Storage
18978 @cindex @acronym{TLS}
18979 @cindex @code{__thread}
18981 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
18982 are allocated such that there is one instance of the variable per extant
18983 thread.  The runtime model GCC uses to implement this originates
18984 in the IA-64 processor-specific ABI, but has since been migrated
18985 to other processors as well.  It requires significant support from
18986 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
18987 system libraries (@file{libc.so} and @file{libpthread.so}), so it
18988 is not available everywhere.
18990 At the user level, the extension is visible with a new storage
18991 class keyword: @code{__thread}.  For example:
18993 @smallexample
18994 __thread int i;
18995 extern __thread struct state s;
18996 static __thread char *p;
18997 @end smallexample
18999 The @code{__thread} specifier may be used alone, with the @code{extern}
19000 or @code{static} specifiers, but with no other storage class specifier.
19001 When used with @code{extern} or @code{static}, @code{__thread} must appear
19002 immediately after the other storage class specifier.
19004 The @code{__thread} specifier may be applied to any global, file-scoped
19005 static, function-scoped static, or static data member of a class.  It may
19006 not be applied to block-scoped automatic or non-static data member.
19008 When the address-of operator is applied to a thread-local variable, it is
19009 evaluated at run time and returns the address of the current thread's
19010 instance of that variable.  An address so obtained may be used by any
19011 thread.  When a thread terminates, any pointers to thread-local variables
19012 in that thread become invalid.
19014 No static initialization may refer to the address of a thread-local variable.
19016 In C++, if an initializer is present for a thread-local variable, it must
19017 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19018 standard.
19020 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19021 ELF Handling For Thread-Local Storage} for a detailed explanation of
19022 the four thread-local storage addressing models, and how the runtime
19023 is expected to function.
19025 @menu
19026 * C99 Thread-Local Edits::
19027 * C++98 Thread-Local Edits::
19028 @end menu
19030 @node C99 Thread-Local Edits
19031 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19033 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19034 that document the exact semantics of the language extension.
19036 @itemize @bullet
19037 @item
19038 @cite{5.1.2  Execution environments}
19040 Add new text after paragraph 1
19042 @quotation
19043 Within either execution environment, a @dfn{thread} is a flow of
19044 control within a program.  It is implementation defined whether
19045 or not there may be more than one thread associated with a program.
19046 It is implementation defined how threads beyond the first are
19047 created, the name and type of the function called at thread
19048 startup, and how threads may be terminated.  However, objects
19049 with thread storage duration shall be initialized before thread
19050 startup.
19051 @end quotation
19053 @item
19054 @cite{6.2.4  Storage durations of objects}
19056 Add new text before paragraph 3
19058 @quotation
19059 An object whose identifier is declared with the storage-class
19060 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19061 Its lifetime is the entire execution of the thread, and its
19062 stored value is initialized only once, prior to thread startup.
19063 @end quotation
19065 @item
19066 @cite{6.4.1  Keywords}
19068 Add @code{__thread}.
19070 @item
19071 @cite{6.7.1  Storage-class specifiers}
19073 Add @code{__thread} to the list of storage class specifiers in
19074 paragraph 1.
19076 Change paragraph 2 to
19078 @quotation
19079 With the exception of @code{__thread}, at most one storage-class
19080 specifier may be given [@dots{}].  The @code{__thread} specifier may
19081 be used alone, or immediately following @code{extern} or
19082 @code{static}.
19083 @end quotation
19085 Add new text after paragraph 6
19087 @quotation
19088 The declaration of an identifier for a variable that has
19089 block scope that specifies @code{__thread} shall also
19090 specify either @code{extern} or @code{static}.
19092 The @code{__thread} specifier shall be used only with
19093 variables.
19094 @end quotation
19095 @end itemize
19097 @node C++98 Thread-Local Edits
19098 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19100 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19101 that document the exact semantics of the language extension.
19103 @itemize @bullet
19104 @item
19105 @b{[intro.execution]}
19107 New text after paragraph 4
19109 @quotation
19110 A @dfn{thread} is a flow of control within the abstract machine.
19111 It is implementation defined whether or not there may be more than
19112 one thread.
19113 @end quotation
19115 New text after paragraph 7
19117 @quotation
19118 It is unspecified whether additional action must be taken to
19119 ensure when and whether side effects are visible to other threads.
19120 @end quotation
19122 @item
19123 @b{[lex.key]}
19125 Add @code{__thread}.
19127 @item
19128 @b{[basic.start.main]}
19130 Add after paragraph 5
19132 @quotation
19133 The thread that begins execution at the @code{main} function is called
19134 the @dfn{main thread}.  It is implementation defined how functions
19135 beginning threads other than the main thread are designated or typed.
19136 A function so designated, as well as the @code{main} function, is called
19137 a @dfn{thread startup function}.  It is implementation defined what
19138 happens if a thread startup function returns.  It is implementation
19139 defined what happens to other threads when any thread calls @code{exit}.
19140 @end quotation
19142 @item
19143 @b{[basic.start.init]}
19145 Add after paragraph 4
19147 @quotation
19148 The storage for an object of thread storage duration shall be
19149 statically initialized before the first statement of the thread startup
19150 function.  An object of thread storage duration shall not require
19151 dynamic initialization.
19152 @end quotation
19154 @item
19155 @b{[basic.start.term]}
19157 Add after paragraph 3
19159 @quotation
19160 The type of an object with thread storage duration shall not have a
19161 non-trivial destructor, nor shall it be an array type whose elements
19162 (directly or indirectly) have non-trivial destructors.
19163 @end quotation
19165 @item
19166 @b{[basic.stc]}
19168 Add ``thread storage duration'' to the list in paragraph 1.
19170 Change paragraph 2
19172 @quotation
19173 Thread, static, and automatic storage durations are associated with
19174 objects introduced by declarations [@dots{}].
19175 @end quotation
19177 Add @code{__thread} to the list of specifiers in paragraph 3.
19179 @item
19180 @b{[basic.stc.thread]}
19182 New section before @b{[basic.stc.static]}
19184 @quotation
19185 The keyword @code{__thread} applied to a non-local object gives the
19186 object thread storage duration.
19188 A local variable or class data member declared both @code{static}
19189 and @code{__thread} gives the variable or member thread storage
19190 duration.
19191 @end quotation
19193 @item
19194 @b{[basic.stc.static]}
19196 Change paragraph 1
19198 @quotation
19199 All objects that have neither thread storage duration, dynamic
19200 storage duration nor are local [@dots{}].
19201 @end quotation
19203 @item
19204 @b{[dcl.stc]}
19206 Add @code{__thread} to the list in paragraph 1.
19208 Change paragraph 1
19210 @quotation
19211 With the exception of @code{__thread}, at most one
19212 @var{storage-class-specifier} shall appear in a given
19213 @var{decl-specifier-seq}.  The @code{__thread} specifier may
19214 be used alone, or immediately following the @code{extern} or
19215 @code{static} specifiers.  [@dots{}]
19216 @end quotation
19218 Add after paragraph 5
19220 @quotation
19221 The @code{__thread} specifier can be applied only to the names of objects
19222 and to anonymous unions.
19223 @end quotation
19225 @item
19226 @b{[class.mem]}
19228 Add after paragraph 6
19230 @quotation
19231 Non-@code{static} members shall not be @code{__thread}.
19232 @end quotation
19233 @end itemize
19235 @node Binary constants
19236 @section Binary Constants using the @samp{0b} Prefix
19237 @cindex Binary constants using the @samp{0b} prefix
19239 Integer constants can be written as binary constants, consisting of a
19240 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19241 @samp{0B}.  This is particularly useful in environments that operate a
19242 lot on the bit level (like microcontrollers).
19244 The following statements are identical:
19246 @smallexample
19247 i =       42;
19248 i =     0x2a;
19249 i =      052;
19250 i = 0b101010;
19251 @end smallexample
19253 The type of these constants follows the same rules as for octal or
19254 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19255 can be applied.
19257 @node C++ Extensions
19258 @chapter Extensions to the C++ Language
19259 @cindex extensions, C++ language
19260 @cindex C++ language extensions
19262 The GNU compiler provides these extensions to the C++ language (and you
19263 can also use most of the C language extensions in your C++ programs).  If you
19264 want to write code that checks whether these features are available, you can
19265 test for the GNU compiler the same way as for C programs: check for a
19266 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
19267 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19268 Predefined Macros,cpp,The GNU C Preprocessor}).
19270 @menu
19271 * C++ Volatiles::       What constitutes an access to a volatile object.
19272 * Restricted Pointers:: C99 restricted pointers and references.
19273 * Vague Linkage::       Where G++ puts inlines, vtables and such.
19274 * C++ Interface::       You can use a single C++ header file for both
19275                         declarations and definitions.
19276 * Template Instantiation:: Methods for ensuring that exactly one copy of
19277                         each needed template instantiation is emitted.
19278 * Bound member functions:: You can extract a function pointer to the
19279                         method denoted by a @samp{->*} or @samp{.*} expression.
19280 * C++ Attributes::      Variable, function, and type attributes for C++ only.
19281 * Function Multiversioning::   Declaring multiple function versions.
19282 * Namespace Association:: Strong using-directives for namespace association.
19283 * Type Traits::         Compiler support for type traits
19284 * Java Exceptions::     Tweaking exception handling to work with Java.
19285 * Deprecated Features:: Things will disappear from G++.
19286 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19287 @end menu
19289 @node C++ Volatiles
19290 @section When is a Volatile C++ Object Accessed?
19291 @cindex accessing volatiles
19292 @cindex volatile read
19293 @cindex volatile write
19294 @cindex volatile access
19296 The C++ standard differs from the C standard in its treatment of
19297 volatile objects.  It fails to specify what constitutes a volatile
19298 access, except to say that C++ should behave in a similar manner to C
19299 with respect to volatiles, where possible.  However, the different
19300 lvalueness of expressions between C and C++ complicate the behavior.
19301 G++ behaves the same as GCC for volatile access, @xref{C
19302 Extensions,,Volatiles}, for a description of GCC's behavior.
19304 The C and C++ language specifications differ when an object is
19305 accessed in a void context:
19307 @smallexample
19308 volatile int *src = @var{somevalue};
19309 *src;
19310 @end smallexample
19312 The C++ standard specifies that such expressions do not undergo lvalue
19313 to rvalue conversion, and that the type of the dereferenced object may
19314 be incomplete.  The C++ standard does not specify explicitly that it
19315 is lvalue to rvalue conversion that is responsible for causing an
19316 access.  There is reason to believe that it is, because otherwise
19317 certain simple expressions become undefined.  However, because it
19318 would surprise most programmers, G++ treats dereferencing a pointer to
19319 volatile object of complete type as GCC would do for an equivalent
19320 type in C@.  When the object has incomplete type, G++ issues a
19321 warning; if you wish to force an error, you must force a conversion to
19322 rvalue with, for instance, a static cast.
19324 When using a reference to volatile, G++ does not treat equivalent
19325 expressions as accesses to volatiles, but instead issues a warning that
19326 no volatile is accessed.  The rationale for this is that otherwise it
19327 becomes difficult to determine where volatile access occur, and not
19328 possible to ignore the return value from functions returning volatile
19329 references.  Again, if you wish to force a read, cast the reference to
19330 an rvalue.
19332 G++ implements the same behavior as GCC does when assigning to a
19333 volatile object---there is no reread of the assigned-to object, the
19334 assigned rvalue is reused.  Note that in C++ assignment expressions
19335 are lvalues, and if used as an lvalue, the volatile object is
19336 referred to.  For instance, @var{vref} refers to @var{vobj}, as
19337 expected, in the following example:
19339 @smallexample
19340 volatile int vobj;
19341 volatile int &vref = vobj = @var{something};
19342 @end smallexample
19344 @node Restricted Pointers
19345 @section Restricting Pointer Aliasing
19346 @cindex restricted pointers
19347 @cindex restricted references
19348 @cindex restricted this pointer
19350 As with the C front end, G++ understands the C99 feature of restricted pointers,
19351 specified with the @code{__restrict__}, or @code{__restrict} type
19352 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
19353 language flag, @code{restrict} is not a keyword in C++.
19355 In addition to allowing restricted pointers, you can specify restricted
19356 references, which indicate that the reference is not aliased in the local
19357 context.
19359 @smallexample
19360 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19362   /* @r{@dots{}} */
19364 @end smallexample
19366 @noindent
19367 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19368 @var{rref} refers to a (different) unaliased integer.
19370 You may also specify whether a member function's @var{this} pointer is
19371 unaliased by using @code{__restrict__} as a member function qualifier.
19373 @smallexample
19374 void T::fn () __restrict__
19376   /* @r{@dots{}} */
19378 @end smallexample
19380 @noindent
19381 Within the body of @code{T::fn}, @var{this} has the effective
19382 definition @code{T *__restrict__ const this}.  Notice that the
19383 interpretation of a @code{__restrict__} member function qualifier is
19384 different to that of @code{const} or @code{volatile} qualifier, in that it
19385 is applied to the pointer rather than the object.  This is consistent with
19386 other compilers that implement restricted pointers.
19388 As with all outermost parameter qualifiers, @code{__restrict__} is
19389 ignored in function definition matching.  This means you only need to
19390 specify @code{__restrict__} in a function definition, rather than
19391 in a function prototype as well.
19393 @node Vague Linkage
19394 @section Vague Linkage
19395 @cindex vague linkage
19397 There are several constructs in C++ that require space in the object
19398 file but are not clearly tied to a single translation unit.  We say that
19399 these constructs have ``vague linkage''.  Typically such constructs are
19400 emitted wherever they are needed, though sometimes we can be more
19401 clever.
19403 @table @asis
19404 @item Inline Functions
19405 Inline functions are typically defined in a header file which can be
19406 included in many different compilations.  Hopefully they can usually be
19407 inlined, but sometimes an out-of-line copy is necessary, if the address
19408 of the function is taken or if inlining fails.  In general, we emit an
19409 out-of-line copy in all translation units where one is needed.  As an
19410 exception, we only emit inline virtual functions with the vtable, since
19411 it always requires a copy.
19413 Local static variables and string constants used in an inline function
19414 are also considered to have vague linkage, since they must be shared
19415 between all inlined and out-of-line instances of the function.
19417 @item VTables
19418 @cindex vtable
19419 C++ virtual functions are implemented in most compilers using a lookup
19420 table, known as a vtable.  The vtable contains pointers to the virtual
19421 functions provided by a class, and each object of the class contains a
19422 pointer to its vtable (or vtables, in some multiple-inheritance
19423 situations).  If the class declares any non-inline, non-pure virtual
19424 functions, the first one is chosen as the ``key method'' for the class,
19425 and the vtable is only emitted in the translation unit where the key
19426 method is defined.
19428 @emph{Note:} If the chosen key method is later defined as inline, the
19429 vtable is still emitted in every translation unit that defines it.
19430 Make sure that any inline virtuals are declared inline in the class
19431 body, even if they are not defined there.
19433 @item @code{type_info} objects
19434 @cindex @code{type_info}
19435 @cindex RTTI
19436 C++ requires information about types to be written out in order to
19437 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19438 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19439 object is written out along with the vtable so that @samp{dynamic_cast}
19440 can determine the dynamic type of a class object at run time.  For all
19441 other types, we write out the @samp{type_info} object when it is used: when
19442 applying @samp{typeid} to an expression, throwing an object, or
19443 referring to a type in a catch clause or exception specification.
19445 @item Template Instantiations
19446 Most everything in this section also applies to template instantiations,
19447 but there are other options as well.
19448 @xref{Template Instantiation,,Where's the Template?}.
19450 @end table
19452 When used with GNU ld version 2.8 or later on an ELF system such as
19453 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19454 these constructs will be discarded at link time.  This is known as
19455 COMDAT support.
19457 On targets that don't support COMDAT, but do support weak symbols, GCC
19458 uses them.  This way one copy overrides all the others, but
19459 the unused copies still take up space in the executable.
19461 For targets that do not support either COMDAT or weak symbols,
19462 most entities with vague linkage are emitted as local symbols to
19463 avoid duplicate definition errors from the linker.  This does not happen
19464 for local statics in inlines, however, as having multiple copies
19465 almost certainly breaks things.
19467 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19468 another way to control placement of these constructs.
19470 @node C++ Interface
19471 @section C++ Interface and Implementation Pragmas
19473 @cindex interface and implementation headers, C++
19474 @cindex C++ interface and implementation headers
19475 @cindex pragmas, interface and implementation
19477 @code{#pragma interface} and @code{#pragma implementation} provide the
19478 user with a way of explicitly directing the compiler to emit entities
19479 with vague linkage (and debugging information) in a particular
19480 translation unit.
19482 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19483 by COMDAT support and the ``key method'' heuristic
19484 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
19485 program to grow due to unnecessary out-of-line copies of inline
19486 functions.
19488 @table @code
19489 @item #pragma interface
19490 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19491 @kindex #pragma interface
19492 Use this directive in @emph{header files} that define object classes, to save
19493 space in most of the object files that use those classes.  Normally,
19494 local copies of certain information (backup copies of inline member
19495 functions, debugging information, and the internal tables that implement
19496 virtual functions) must be kept in each object file that includes class
19497 definitions.  You can use this pragma to avoid such duplication.  When a
19498 header file containing @samp{#pragma interface} is included in a
19499 compilation, this auxiliary information is not generated (unless
19500 the main input source file itself uses @samp{#pragma implementation}).
19501 Instead, the object files contain references to be resolved at link
19502 time.
19504 The second form of this directive is useful for the case where you have
19505 multiple headers with the same name in different directories.  If you
19506 use this form, you must specify the same string to @samp{#pragma
19507 implementation}.
19509 @item #pragma implementation
19510 @itemx #pragma implementation "@var{objects}.h"
19511 @kindex #pragma implementation
19512 Use this pragma in a @emph{main input file}, when you want full output from
19513 included header files to be generated (and made globally visible).  The
19514 included header file, in turn, should use @samp{#pragma interface}.
19515 Backup copies of inline member functions, debugging information, and the
19516 internal tables used to implement virtual functions are all generated in
19517 implementation files.
19519 @cindex implied @code{#pragma implementation}
19520 @cindex @code{#pragma implementation}, implied
19521 @cindex naming convention, implementation headers
19522 If you use @samp{#pragma implementation} with no argument, it applies to
19523 an include file with the same basename@footnote{A file's @dfn{basename}
19524 is the name stripped of all leading path information and of trailing
19525 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19526 file.  For example, in @file{allclass.cc}, giving just
19527 @samp{#pragma implementation}
19528 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19530 Use the string argument if you want a single implementation file to
19531 include code from multiple header files.  (You must also use
19532 @samp{#include} to include the header file; @samp{#pragma
19533 implementation} only specifies how to use the file---it doesn't actually
19534 include it.)
19536 There is no way to split up the contents of a single header file into
19537 multiple implementation files.
19538 @end table
19540 @cindex inlining and C++ pragmas
19541 @cindex C++ pragmas, effect on inlining
19542 @cindex pragmas in C++, effect on inlining
19543 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19544 effect on function inlining.
19546 If you define a class in a header file marked with @samp{#pragma
19547 interface}, the effect on an inline function defined in that class is
19548 similar to an explicit @code{extern} declaration---the compiler emits
19549 no code at all to define an independent version of the function.  Its
19550 definition is used only for inlining with its callers.
19552 @opindex fno-implement-inlines
19553 Conversely, when you include the same header file in a main source file
19554 that declares it as @samp{#pragma implementation}, the compiler emits
19555 code for the function itself; this defines a version of the function
19556 that can be found via pointers (or by callers compiled without
19557 inlining).  If all calls to the function can be inlined, you can avoid
19558 emitting the function by compiling with @option{-fno-implement-inlines}.
19559 If any calls are not inlined, you will get linker errors.
19561 @node Template Instantiation
19562 @section Where's the Template?
19563 @cindex template instantiation
19565 C++ templates are the first language feature to require more
19566 intelligence from the environment than one usually finds on a UNIX
19567 system.  Somehow the compiler and linker have to make sure that each
19568 template instance occurs exactly once in the executable if it is needed,
19569 and not at all otherwise.  There are two basic approaches to this
19570 problem, which are referred to as the Borland model and the Cfront model.
19572 @table @asis
19573 @item Borland model
19574 Borland C++ solved the template instantiation problem by adding the code
19575 equivalent of common blocks to their linker; the compiler emits template
19576 instances in each translation unit that uses them, and the linker
19577 collapses them together.  The advantage of this model is that the linker
19578 only has to consider the object files themselves; there is no external
19579 complexity to worry about.  This disadvantage is that compilation time
19580 is increased because the template code is being compiled repeatedly.
19581 Code written for this model tends to include definitions of all
19582 templates in the header file, since they must be seen to be
19583 instantiated.
19585 @item Cfront model
19586 The AT&T C++ translator, Cfront, solved the template instantiation
19587 problem by creating the notion of a template repository, an
19588 automatically maintained place where template instances are stored.  A
19589 more modern version of the repository works as follows: As individual
19590 object files are built, the compiler places any template definitions and
19591 instantiations encountered in the repository.  At link time, the link
19592 wrapper adds in the objects in the repository and compiles any needed
19593 instances that were not previously emitted.  The advantages of this
19594 model are more optimal compilation speed and the ability to use the
19595 system linker; to implement the Borland model a compiler vendor also
19596 needs to replace the linker.  The disadvantages are vastly increased
19597 complexity, and thus potential for error; for some code this can be
19598 just as transparent, but in practice it can been very difficult to build
19599 multiple programs in one directory and one program in multiple
19600 directories.  Code written for this model tends to separate definitions
19601 of non-inline member templates into a separate file, which should be
19602 compiled separately.
19603 @end table
19605 When used with GNU ld version 2.8 or later on an ELF system such as
19606 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
19607 Borland model.  On other systems, G++ implements neither automatic
19608 model.
19610 You have the following options for dealing with template instantiations:
19612 @enumerate
19613 @item
19614 @opindex frepo
19615 Compile your template-using code with @option{-frepo}.  The compiler
19616 generates files with the extension @samp{.rpo} listing all of the
19617 template instantiations used in the corresponding object files that
19618 could be instantiated there; the link wrapper, @samp{collect2},
19619 then updates the @samp{.rpo} files to tell the compiler where to place
19620 those instantiations and rebuild any affected object files.  The
19621 link-time overhead is negligible after the first pass, as the compiler
19622 continues to place the instantiations in the same files.
19624 This is your best option for application code written for the Borland
19625 model, as it just works.  Code written for the Cfront model 
19626 needs to be modified so that the template definitions are available at
19627 one or more points of instantiation; usually this is as simple as adding
19628 @code{#include <tmethods.cc>} to the end of each template header.
19630 For library code, if you want the library to provide all of the template
19631 instantiations it needs, just try to link all of its object files
19632 together; the link will fail, but cause the instantiations to be
19633 generated as a side effect.  Be warned, however, that this may cause
19634 conflicts if multiple libraries try to provide the same instantiations.
19635 For greater control, use explicit instantiation as described in the next
19636 option.
19638 @item
19639 @opindex fno-implicit-templates
19640 Compile your code with @option{-fno-implicit-templates} to disable the
19641 implicit generation of template instances, and explicitly instantiate
19642 all the ones you use.  This approach requires more knowledge of exactly
19643 which instances you need than do the others, but it's less
19644 mysterious and allows greater control.  You can scatter the explicit
19645 instantiations throughout your program, perhaps putting them in the
19646 translation units where the instances are used or the translation units
19647 that define the templates themselves; you can put all of the explicit
19648 instantiations you need into one big file; or you can create small files
19649 like
19651 @smallexample
19652 #include "Foo.h"
19653 #include "Foo.cc"
19655 template class Foo<int>;
19656 template ostream& operator <<
19657                 (ostream&, const Foo<int>&);
19658 @end smallexample
19660 @noindent
19661 for each of the instances you need, and create a template instantiation
19662 library from those.
19664 If you are using Cfront-model code, you can probably get away with not
19665 using @option{-fno-implicit-templates} when compiling files that don't
19666 @samp{#include} the member template definitions.
19668 If you use one big file to do the instantiations, you may want to
19669 compile it without @option{-fno-implicit-templates} so you get all of the
19670 instances required by your explicit instantiations (but not by any
19671 other files) without having to specify them as well.
19673 The ISO C++ 2011 standard allows forward declaration of explicit
19674 instantiations (with @code{extern}). G++ supports explicit instantiation
19675 declarations in C++98 mode and has extended the template instantiation
19676 syntax to support instantiation of the compiler support data for a
19677 template class (i.e.@: the vtable) without instantiating any of its
19678 members (with @code{inline}), and instantiation of only the static data
19679 members of a template class, without the support data or member
19680 functions (with @code{static}):
19682 @smallexample
19683 extern template int max (int, int);
19684 inline template class Foo<int>;
19685 static template class Foo<int>;
19686 @end smallexample
19688 @item
19689 Do nothing.  Pretend G++ does implement automatic instantiation
19690 management.  Code written for the Borland model works fine, but
19691 each translation unit contains instances of each of the templates it
19692 uses.  In a large program, this can lead to an unacceptable amount of code
19693 duplication.
19694 @end enumerate
19696 @node Bound member functions
19697 @section Extracting the Function Pointer from a Bound Pointer to Member Function
19698 @cindex pmf
19699 @cindex pointer to member function
19700 @cindex bound pointer to member function
19702 In C++, pointer to member functions (PMFs) are implemented using a wide
19703 pointer of sorts to handle all the possible call mechanisms; the PMF
19704 needs to store information about how to adjust the @samp{this} pointer,
19705 and if the function pointed to is virtual, where to find the vtable, and
19706 where in the vtable to look for the member function.  If you are using
19707 PMFs in an inner loop, you should really reconsider that decision.  If
19708 that is not an option, you can extract the pointer to the function that
19709 would be called for a given object/PMF pair and call it directly inside
19710 the inner loop, to save a bit of time.
19712 Note that you still pay the penalty for the call through a
19713 function pointer; on most modern architectures, such a call defeats the
19714 branch prediction features of the CPU@.  This is also true of normal
19715 virtual function calls.
19717 The syntax for this extension is
19719 @smallexample
19720 extern A a;
19721 extern int (A::*fp)();
19722 typedef int (*fptr)(A *);
19724 fptr p = (fptr)(a.*fp);
19725 @end smallexample
19727 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
19728 no object is needed to obtain the address of the function.  They can be
19729 converted to function pointers directly:
19731 @smallexample
19732 fptr p1 = (fptr)(&A::foo);
19733 @end smallexample
19735 @opindex Wno-pmf-conversions
19736 You must specify @option{-Wno-pmf-conversions} to use this extension.
19738 @node C++ Attributes
19739 @section C++-Specific Variable, Function, and Type Attributes
19741 Some attributes only make sense for C++ programs.
19743 @table @code
19744 @item abi_tag ("@var{tag}", ...)
19745 @cindex @code{abi_tag} function attribute
19746 @cindex @code{abi_tag} variable attribute
19747 @cindex @code{abi_tag} type attribute
19748 The @code{abi_tag} attribute can be applied to a function, variable, or class
19749 declaration.  It modifies the mangled name of the entity to
19750 incorporate the tag name, in order to distinguish the function or
19751 class from an earlier version with a different ABI; perhaps the class
19752 has changed size, or the function has a different return type that is
19753 not encoded in the mangled name.
19755 The attribute can also be applied to an inline namespace, but does not
19756 affect the mangled name of the namespace; in this case it is only used
19757 for @option{-Wabi-tag} warnings and automatic tagging of functions and
19758 variables.  Tagging inline namespaces is generally preferable to
19759 tagging individual declarations, but the latter is sometimes
19760 necessary, such as when only certain members of a class need to be
19761 tagged.
19763 The argument can be a list of strings of arbitrary length.  The
19764 strings are sorted on output, so the order of the list is
19765 unimportant.
19767 A redeclaration of an entity must not add new ABI tags,
19768 since doing so would change the mangled name.
19770 The ABI tags apply to a name, so all instantiations and
19771 specializations of a template have the same tags.  The attribute will
19772 be ignored if applied to an explicit specialization or instantiation.
19774 The @option{-Wabi-tag} flag enables a warning about a class which does
19775 not have all the ABI tags used by its subobjects and virtual functions; for users with code
19776 that needs to coexist with an earlier ABI, using this option can help
19777 to find all affected types that need to be tagged.
19779 When a type involving an ABI tag is used as the type of a variable or
19780 return type of a function where that tag is not already present in the
19781 signature of the function, the tag is automatically applied to the
19782 variable or function.  @option{-Wabi-tag} also warns about this
19783 situation; this warning can be avoided by explicitly tagging the
19784 variable or function or moving it into a tagged inline namespace.
19786 @item init_priority (@var{priority})
19787 @cindex @code{init_priority} variable attribute
19789 In Standard C++, objects defined at namespace scope are guaranteed to be
19790 initialized in an order in strict accordance with that of their definitions
19791 @emph{in a given translation unit}.  No guarantee is made for initializations
19792 across translation units.  However, GNU C++ allows users to control the
19793 order of initialization of objects defined at namespace scope with the
19794 @code{init_priority} attribute by specifying a relative @var{priority},
19795 a constant integral expression currently bounded between 101 and 65535
19796 inclusive.  Lower numbers indicate a higher priority.
19798 In the following example, @code{A} would normally be created before
19799 @code{B}, but the @code{init_priority} attribute reverses that order:
19801 @smallexample
19802 Some_Class  A  __attribute__ ((init_priority (2000)));
19803 Some_Class  B  __attribute__ ((init_priority (543)));
19804 @end smallexample
19806 @noindent
19807 Note that the particular values of @var{priority} do not matter; only their
19808 relative ordering.
19810 @item java_interface
19811 @cindex @code{java_interface} type attribute
19813 This type attribute informs C++ that the class is a Java interface.  It may
19814 only be applied to classes declared within an @code{extern "Java"} block.
19815 Calls to methods declared in this interface are dispatched using GCJ's
19816 interface table mechanism, instead of regular virtual table dispatch.
19818 @item warn_unused
19819 @cindex @code{warn_unused} type attribute
19821 For C++ types with non-trivial constructors and/or destructors it is
19822 impossible for the compiler to determine whether a variable of this
19823 type is truly unused if it is not referenced. This type attribute
19824 informs the compiler that variables of this type should be warned
19825 about if they appear to be unused, just like variables of fundamental
19826 types.
19828 This attribute is appropriate for types which just represent a value,
19829 such as @code{std::string}; it is not appropriate for types which
19830 control a resource, such as @code{std::mutex}.
19832 This attribute is also accepted in C, but it is unnecessary because C
19833 does not have constructors or destructors.
19835 @end table
19837 See also @ref{Namespace Association}.
19839 @node Function Multiversioning
19840 @section Function Multiversioning
19841 @cindex function versions
19843 With the GNU C++ front end, for x86 targets, you may specify multiple
19844 versions of a function, where each function is specialized for a
19845 specific target feature.  At runtime, the appropriate version of the
19846 function is automatically executed depending on the characteristics of
19847 the execution platform.  Here is an example.
19849 @smallexample
19850 __attribute__ ((target ("default")))
19851 int foo ()
19853   // The default version of foo.
19854   return 0;
19857 __attribute__ ((target ("sse4.2")))
19858 int foo ()
19860   // foo version for SSE4.2
19861   return 1;
19864 __attribute__ ((target ("arch=atom")))
19865 int foo ()
19867   // foo version for the Intel ATOM processor
19868   return 2;
19871 __attribute__ ((target ("arch=amdfam10")))
19872 int foo ()
19874   // foo version for the AMD Family 0x10 processors.
19875   return 3;
19878 int main ()
19880   int (*p)() = &foo;
19881   assert ((*p) () == foo ());
19882   return 0;
19884 @end smallexample
19886 In the above example, four versions of function foo are created. The
19887 first version of foo with the target attribute "default" is the default
19888 version.  This version gets executed when no other target specific
19889 version qualifies for execution on a particular platform. A new version
19890 of foo is created by using the same function signature but with a
19891 different target string.  Function foo is called or a pointer to it is
19892 taken just like a regular function.  GCC takes care of doing the
19893 dispatching to call the right version at runtime.  Refer to the
19894 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
19895 Function Multiversioning} for more details.
19897 @node Namespace Association
19898 @section Namespace Association
19900 @strong{Caution:} The semantics of this extension are equivalent
19901 to C++ 2011 inline namespaces.  Users should use inline namespaces
19902 instead as this extension will be removed in future versions of G++.
19904 A using-directive with @code{__attribute ((strong))} is stronger
19905 than a normal using-directive in two ways:
19907 @itemize @bullet
19908 @item
19909 Templates from the used namespace can be specialized and explicitly
19910 instantiated as though they were members of the using namespace.
19912 @item
19913 The using namespace is considered an associated namespace of all
19914 templates in the used namespace for purposes of argument-dependent
19915 name lookup.
19916 @end itemize
19918 The used namespace must be nested within the using namespace so that
19919 normal unqualified lookup works properly.
19921 This is useful for composing a namespace transparently from
19922 implementation namespaces.  For example:
19924 @smallexample
19925 namespace std @{
19926   namespace debug @{
19927     template <class T> struct A @{ @};
19928   @}
19929   using namespace debug __attribute ((__strong__));
19930   template <> struct A<int> @{ @};   // @r{OK to specialize}
19932   template <class T> void f (A<T>);
19935 int main()
19937   f (std::A<float>());             // @r{lookup finds} std::f
19938   f (std::A<int>());
19940 @end smallexample
19942 @node Type Traits
19943 @section Type Traits
19945 The C++ front end implements syntactic extensions that allow
19946 compile-time determination of 
19947 various characteristics of a type (or of a
19948 pair of types).
19950 @table @code
19951 @item __has_nothrow_assign (type)
19952 If @code{type} is const qualified or is a reference type then the trait is
19953 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
19954 is true, else if @code{type} is a cv class or union type with copy assignment
19955 operators that are known not to throw an exception then the trait is true,
19956 else it is false.  Requires: @code{type} shall be a complete type,
19957 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19959 @item __has_nothrow_copy (type)
19960 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
19961 @code{type} is a cv class or union type with copy constructors that
19962 are known not to throw an exception then the trait is true, else it is false.
19963 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
19964 @code{void}, or an array of unknown bound.
19966 @item __has_nothrow_constructor (type)
19967 If @code{__has_trivial_constructor (type)} is true then the trait is
19968 true, else if @code{type} is a cv class or union type (or array
19969 thereof) with a default constructor that is known not to throw an
19970 exception then the trait is true, else it is false.  Requires:
19971 @code{type} shall be a complete type, (possibly cv-qualified)
19972 @code{void}, or an array of unknown bound.
19974 @item __has_trivial_assign (type)
19975 If @code{type} is const qualified or is a reference type then the trait is
19976 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
19977 true, else if @code{type} is a cv class or union type with a trivial
19978 copy assignment ([class.copy]) then the trait is true, else it is
19979 false.  Requires: @code{type} shall be a complete type, (possibly
19980 cv-qualified) @code{void}, or an array of unknown bound.
19982 @item __has_trivial_copy (type)
19983 If @code{__is_pod (type)} is true or @code{type} is a reference type
19984 then the trait is true, else if @code{type} is a cv class or union type
19985 with a trivial copy constructor ([class.copy]) then the trait
19986 is true, else it is false.  Requires: @code{type} shall be a complete
19987 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19989 @item __has_trivial_constructor (type)
19990 If @code{__is_pod (type)} is true then the trait is true, else if
19991 @code{type} is a cv class or union type (or array thereof) with a
19992 trivial default constructor ([class.ctor]) then the trait is true,
19993 else it is false.  Requires: @code{type} shall be a complete
19994 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19996 @item __has_trivial_destructor (type)
19997 If @code{__is_pod (type)} is true or @code{type} is a reference type then
19998 the trait is true, else if @code{type} is a cv class or union type (or
19999 array thereof) with a trivial destructor ([class.dtor]) then the trait
20000 is true, else it is false.  Requires: @code{type} shall be a complete
20001 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20003 @item __has_virtual_destructor (type)
20004 If @code{type} is a class type with a virtual destructor
20005 ([class.dtor]) then the trait is true, else it is false.  Requires:
20006 @code{type} shall be a complete type, (possibly cv-qualified)
20007 @code{void}, or an array of unknown bound.
20009 @item __is_abstract (type)
20010 If @code{type} is an abstract class ([class.abstract]) then the trait
20011 is true, else it is false.  Requires: @code{type} shall be a complete
20012 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20014 @item __is_base_of (base_type, derived_type)
20015 If @code{base_type} is a base class of @code{derived_type}
20016 ([class.derived]) then the trait is true, otherwise it is false.
20017 Top-level cv qualifications of @code{base_type} and
20018 @code{derived_type} are ignored.  For the purposes of this trait, a
20019 class type is considered is own base.  Requires: if @code{__is_class
20020 (base_type)} and @code{__is_class (derived_type)} are true and
20021 @code{base_type} and @code{derived_type} are not the same type
20022 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20023 type.  Diagnostic is produced if this requirement is not met.
20025 @item __is_class (type)
20026 If @code{type} is a cv class type, and not a union type
20027 ([basic.compound]) the trait is true, else it is false.
20029 @item __is_empty (type)
20030 If @code{__is_class (type)} is false then the trait is false.
20031 Otherwise @code{type} is considered empty if and only if: @code{type}
20032 has no non-static data members, or all non-static data members, if
20033 any, are bit-fields of length 0, and @code{type} has no virtual
20034 members, and @code{type} has no virtual base classes, and @code{type}
20035 has no base classes @code{base_type} for which
20036 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
20037 be a complete type, (possibly cv-qualified) @code{void}, or an array
20038 of unknown bound.
20040 @item __is_enum (type)
20041 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20042 true, else it is false.
20044 @item __is_literal_type (type)
20045 If @code{type} is a literal type ([basic.types]) the trait is
20046 true, else it is false.  Requires: @code{type} shall be a complete type,
20047 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20049 @item __is_pod (type)
20050 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20051 else it is false.  Requires: @code{type} shall be a complete type,
20052 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20054 @item __is_polymorphic (type)
20055 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20056 is true, else it is false.  Requires: @code{type} shall be a complete
20057 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20059 @item __is_standard_layout (type)
20060 If @code{type} is a standard-layout type ([basic.types]) the trait is
20061 true, else it is false.  Requires: @code{type} shall be a complete
20062 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20064 @item __is_trivial (type)
20065 If @code{type} is a trivial type ([basic.types]) the trait is
20066 true, else it is false.  Requires: @code{type} shall be a complete
20067 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20069 @item __is_union (type)
20070 If @code{type} is a cv union type ([basic.compound]) the trait is
20071 true, else it is false.
20073 @item __underlying_type (type)
20074 The underlying type of @code{type}.  Requires: @code{type} shall be
20075 an enumeration type ([dcl.enum]).
20077 @end table
20079 @node Java Exceptions
20080 @section Java Exceptions
20082 The Java language uses a slightly different exception handling model
20083 from C++.  Normally, GNU C++ automatically detects when you are
20084 writing C++ code that uses Java exceptions, and handle them
20085 appropriately.  However, if C++ code only needs to execute destructors
20086 when Java exceptions are thrown through it, GCC guesses incorrectly.
20087 Sample problematic code is:
20089 @smallexample
20090   struct S @{ ~S(); @};
20091   extern void bar();    // @r{is written in Java, and may throw exceptions}
20092   void foo()
20093   @{
20094     S s;
20095     bar();
20096   @}
20097 @end smallexample
20099 @noindent
20100 The usual effect of an incorrect guess is a link failure, complaining of
20101 a missing routine called @samp{__gxx_personality_v0}.
20103 You can inform the compiler that Java exceptions are to be used in a
20104 translation unit, irrespective of what it might think, by writing
20105 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
20106 @samp{#pragma} must appear before any functions that throw or catch
20107 exceptions, or run destructors when exceptions are thrown through them.
20109 You cannot mix Java and C++ exceptions in the same translation unit.  It
20110 is believed to be safe to throw a C++ exception from one file through
20111 another file compiled for the Java exception model, or vice versa, but
20112 there may be bugs in this area.
20114 @node Deprecated Features
20115 @section Deprecated Features
20117 In the past, the GNU C++ compiler was extended to experiment with new
20118 features, at a time when the C++ language was still evolving.  Now that
20119 the C++ standard is complete, some of those features are superseded by
20120 superior alternatives.  Using the old features might cause a warning in
20121 some cases that the feature will be dropped in the future.  In other
20122 cases, the feature might be gone already.
20124 While the list below is not exhaustive, it documents some of the options
20125 that are now deprecated:
20127 @table @code
20128 @item -fexternal-templates
20129 @itemx -falt-external-templates
20130 These are two of the many ways for G++ to implement template
20131 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
20132 defines how template definitions have to be organized across
20133 implementation units.  G++ has an implicit instantiation mechanism that
20134 should work just fine for standard-conforming code.
20136 @item -fstrict-prototype
20137 @itemx -fno-strict-prototype
20138 Previously it was possible to use an empty prototype parameter list to
20139 indicate an unspecified number of parameters (like C), rather than no
20140 parameters, as C++ demands.  This feature has been removed, except where
20141 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
20142 @end table
20144 G++ allows a virtual function returning @samp{void *} to be overridden
20145 by one returning a different pointer type.  This extension to the
20146 covariant return type rules is now deprecated and will be removed from a
20147 future version.
20149 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20150 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20151 and are now removed from G++.  Code using these operators should be
20152 modified to use @code{std::min} and @code{std::max} instead.
20154 The named return value extension has been deprecated, and is now
20155 removed from G++.
20157 The use of initializer lists with new expressions has been deprecated,
20158 and is now removed from G++.
20160 Floating and complex non-type template parameters have been deprecated,
20161 and are now removed from G++.
20163 The implicit typename extension has been deprecated and is now
20164 removed from G++.
20166 The use of default arguments in function pointers, function typedefs
20167 and other places where they are not permitted by the standard is
20168 deprecated and will be removed from a future version of G++.
20170 G++ allows floating-point literals to appear in integral constant expressions,
20171 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20172 This extension is deprecated and will be removed from a future version.
20174 G++ allows static data members of const floating-point type to be declared
20175 with an initializer in a class definition. The standard only allows
20176 initializers for static members of const integral types and const
20177 enumeration types so this extension has been deprecated and will be removed
20178 from a future version.
20180 @node Backwards Compatibility
20181 @section Backwards Compatibility
20182 @cindex Backwards Compatibility
20183 @cindex ARM [Annotated C++ Reference Manual]
20185 Now that there is a definitive ISO standard C++, G++ has a specification
20186 to adhere to.  The C++ language evolved over time, and features that
20187 used to be acceptable in previous drafts of the standard, such as the ARM
20188 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
20189 compilation of C++ written to such drafts, G++ contains some backwards
20190 compatibilities.  @emph{All such backwards compatibility features are
20191 liable to disappear in future versions of G++.} They should be considered
20192 deprecated.   @xref{Deprecated Features}.
20194 @table @code
20195 @item For scope
20196 If a variable is declared at for scope, it used to remain in scope until
20197 the end of the scope that contained the for statement (rather than just
20198 within the for scope).  G++ retains this, but issues a warning, if such a
20199 variable is accessed outside the for scope.
20201 @item Implicit C language
20202 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20203 scope to set the language.  On such systems, all header files are
20204 implicitly scoped inside a C language scope.  Also, an empty prototype
20205 @code{()} is treated as an unspecified number of arguments, rather
20206 than no arguments, as C++ demands.
20207 @end table
20209 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
20210 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr