2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / doc / extend.texi
blob508c47624ddeefdcbad76fafcabf9458aa224691
1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001,
2 @c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 @c Free Software Foundation, Inc.
5 @c This is part of the GCC manual.
6 @c For copying conditions, see the file gcc.texi.
8 @node C Extensions
9 @chapter Extensions to the C Language Family
10 @cindex extensions, C language
11 @cindex C language extensions
13 @opindex pedantic
14 GNU C provides several language features not found in ISO standard C@.
15 (The @option{-pedantic} option directs GCC to print a warning message if
16 any of these features is used.)  To test for the availability of these
17 features in conditional compilation, check for a predefined macro
18 @code{__GNUC__}, which is always defined under GCC@.
20 These extensions are available in C and Objective-C@.  Most of them are
21 also available in C++.  @xref{C++ Extensions,,Extensions to the
22 C++ Language}, for extensions that apply @emph{only} to C++.
24 Some features that are in ISO C99 but not C90 or C++ are also, as
25 extensions, accepted by GCC in C90 mode and in C++.
27 @menu
28 * Statement Exprs::     Putting statements and declarations inside expressions.
29 * Local Labels::        Labels local to a block.
30 * Labels as Values::    Getting pointers to labels, and computed gotos.
31 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
32 * Constructing Calls::  Dispatching a call to another function.
33 * Typeof::              @code{typeof}: referring to the type of an expression.
34 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
35 * Long Long::           Double-word integers---@code{long long int}.
36 * __int128::                    128-bit integers---@code{__int128}.
37 * Complex::             Data types for complex numbers.
38 * Floating Types::      Additional Floating Types.
39 * Half-Precision::      Half-Precision Floating Point.
40 * Decimal Float::       Decimal Floating Types. 
41 * Hex Floats::          Hexadecimal floating-point constants.
42 * Fixed-Point::         Fixed-Point Types.
43 * Named Address Spaces::Named address spaces.
44 * Zero Length::         Zero-length arrays.
45 * Variable Length::     Arrays whose length is computed at run time.
46 * Empty Structures::    Structures with no members.
47 * Variadic Macros::     Macros with a variable number of arguments.
48 * Escaped Newlines::    Slightly looser rules for escaped newlines.
49 * Subscripting::        Any array can be subscripted, even if not an lvalue.
50 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
51 * Initializers::        Non-constant initializers.
52 * Compound Literals::   Compound literals give structures, unions
53                         or arrays as values.
54 * Designated Inits::    Labeling elements of initializers.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Case Ranges::         `case 1 ... 9' and such.
57 * Mixed Declarations::  Mixing declarations and code.
58 * Function Attributes:: Declaring that functions have no side effects,
59                         or that they can never return.
60 * Attribute Syntax::    Formal syntax for attributes.
61 * Function Prototypes:: Prototype declarations and old-style definitions.
62 * C++ Comments::        C++ comments are recognized.
63 * Dollar Signs::        Dollar sign is allowed in identifiers.
64 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
65 * Variable Attributes:: Specifying attributes of variables.
66 * Type Attributes::     Specifying attributes of types.
67 * Alignment::           Inquiring about the alignment of a type or variable.
68 * Inline::              Defining inline functions (as fast as macros).
69 * Extended Asm::        Assembler instructions with C expressions as operands.
70                         (With them you can define ``built-in'' functions.)
71 * Constraints::         Constraints for asm operands
72 * Asm Labels::          Specifying the assembler name to use for a C symbol.
73 * Explicit Reg Vars::   Defining variables residing in specified registers.
74 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
75 * Incomplete Enums::    @code{enum foo;}, with details to follow.
76 * Function Names::      Printable strings which are the name of the current
77                         function.
78 * Return Address::      Getting the return or frame address of a function.
79 * Vector Extensions::   Using vector instructions through built-in functions.
80 * Offsetof::            Special syntax for implementing @code{offsetof}.
81 * Atomic Builtins::     Built-in functions for atomic memory access.
82 * Object Size Checking:: Built-in functions for limited buffer overflow
83                         checking.
84 * Other Builtins::      Other built-in functions.
85 * Target Builtins::     Built-in functions specific to particular targets.
86 * Target Format Checks:: Format checks specific to particular targets.
87 * Pragmas::             Pragmas accepted by GCC.
88 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
89 * Thread-Local::        Per-thread variables.
90 * Binary constants::    Binary constants using the @samp{0b} prefix.
91 @end menu
93 @node Statement Exprs
94 @section Statements and Declarations in Expressions
95 @cindex statements inside expressions
96 @cindex declarations inside expressions
97 @cindex expressions containing statements
98 @cindex macros, statements in expressions
100 @c the above section title wrapped and causes an underfull hbox.. i
101 @c changed it from "within" to "in". --mew 4feb93
102 A compound statement enclosed in parentheses may appear as an expression
103 in GNU C@.  This allows you to use loops, switches, and local variables
104 within an expression.
106 Recall that a compound statement is a sequence of statements surrounded
107 by braces; in this construct, parentheses go around the braces.  For
108 example:
110 @smallexample
111 (@{ int y = foo (); int z;
112    if (y > 0) z = y;
113    else z = - y;
114    z; @})
115 @end smallexample
117 @noindent
118 is a valid (though slightly more complex than necessary) expression
119 for the absolute value of @code{foo ()}.
121 The last thing in the compound statement should be an expression
122 followed by a semicolon; the value of this subexpression serves as the
123 value of the entire construct.  (If you use some other kind of statement
124 last within the braces, the construct has type @code{void}, and thus
125 effectively no value.)
127 This feature is especially useful in making macro definitions ``safe'' (so
128 that they evaluate each operand exactly once).  For example, the
129 ``maximum'' function is commonly defined as a macro in standard C as
130 follows:
132 @smallexample
133 #define max(a,b) ((a) > (b) ? (a) : (b))
134 @end smallexample
136 @noindent
137 @cindex side effects, macro argument
138 But this definition computes either @var{a} or @var{b} twice, with bad
139 results if the operand has side effects.  In GNU C, if you know the
140 type of the operands (here taken as @code{int}), you can define
141 the macro safely as follows:
143 @smallexample
144 #define maxint(a,b) \
145   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
146 @end smallexample
148 Embedded statements are not allowed in constant expressions, such as
149 the value of an enumeration constant, the width of a bit-field, or
150 the initial value of a static variable.
152 If you don't know the type of the operand, you can still do this, but you
153 must use @code{typeof} (@pxref{Typeof}).
155 In G++, the result value of a statement expression undergoes array and
156 function pointer decay, and is returned by value to the enclosing
157 expression.  For instance, if @code{A} is a class, then
159 @smallexample
160         A a;
162         (@{a;@}).Foo ()
163 @end smallexample
165 @noindent
166 will construct a temporary @code{A} object to hold the result of the
167 statement expression, and that will be used to invoke @code{Foo}.
168 Therefore the @code{this} pointer observed by @code{Foo} will not be the
169 address of @code{a}.
171 Any temporaries created within a statement within a statement expression
172 will be destroyed at the statement's end.  This makes statement
173 expressions inside macros slightly different from function calls.  In
174 the latter case temporaries introduced during argument evaluation will
175 be destroyed at the end of the statement that includes the function
176 call.  In the statement expression case they will be destroyed during
177 the statement expression.  For instance,
179 @smallexample
180 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
181 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
183 void foo ()
185   macro (X ());
186   function (X ());
188 @end smallexample
190 @noindent
191 will have different places where temporaries are destroyed.  For the
192 @code{macro} case, the temporary @code{X} will be destroyed just after
193 the initialization of @code{b}.  In the @code{function} case that
194 temporary will be destroyed when the function returns.
196 These considerations mean that it is probably a bad idea to use
197 statement-expressions of this form in header files that are designed to
198 work with C++.  (Note that some versions of the GNU C Library contained
199 header files using statement-expression that lead to precisely this
200 bug.)
202 Jumping into a statement expression with @code{goto} or using a
203 @code{switch} statement outside the statement expression with a
204 @code{case} or @code{default} label inside the statement expression is
205 not permitted.  Jumping into a statement expression with a computed
206 @code{goto} (@pxref{Labels as Values}) yields undefined behavior.
207 Jumping out of a statement expression is permitted, but if the
208 statement expression is part of a larger expression then it is
209 unspecified which other subexpressions of that expression have been
210 evaluated except where the language definition requires certain
211 subexpressions to be evaluated before or after the statement
212 expression.  In any case, as with a function call the evaluation of a
213 statement expression is not interleaved with the evaluation of other
214 parts of the containing expression.  For example,
216 @smallexample
217   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
218 @end smallexample
220 @noindent
221 will call @code{foo} and @code{bar1} and will not call @code{baz} but
222 may or may not call @code{bar2}.  If @code{bar2} is called, it will be
223 called after @code{foo} and before @code{bar1}
225 @node Local Labels
226 @section Locally Declared Labels
227 @cindex local labels
228 @cindex macros, local labels
230 GCC allows you to declare @dfn{local labels} in any nested block
231 scope.  A local label is just like an ordinary label, but you can
232 only reference it (with a @code{goto} statement, or by taking its
233 address) within the block in which it was declared.
235 A local label declaration looks like this:
237 @smallexample
238 __label__ @var{label};
239 @end smallexample
241 @noindent
244 @smallexample
245 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
246 @end smallexample
248 Local label declarations must come at the beginning of the block,
249 before any ordinary declarations or statements.
251 The label declaration defines the label @emph{name}, but does not define
252 the label itself.  You must do this in the usual way, with
253 @code{@var{label}:}, within the statements of the statement expression.
255 The local label feature is useful for complex macros.  If a macro
256 contains nested loops, a @code{goto} can be useful for breaking out of
257 them.  However, an ordinary label whose scope is the whole function
258 cannot be used: if the macro can be expanded several times in one
259 function, the label will be multiply defined in that function.  A
260 local label avoids this problem.  For example:
262 @smallexample
263 #define SEARCH(value, array, target)              \
264 do @{                                              \
265   __label__ found;                                \
266   typeof (target) _SEARCH_target = (target);      \
267   typeof (*(array)) *_SEARCH_array = (array);     \
268   int i, j;                                       \
269   int value;                                      \
270   for (i = 0; i < max; i++)                       \
271     for (j = 0; j < max; j++)                     \
272       if (_SEARCH_array[i][j] == _SEARCH_target)  \
273         @{ (value) = i; goto found; @}              \
274   (value) = -1;                                   \
275  found:;                                          \
276 @} while (0)
277 @end smallexample
279 This could also be written using a statement-expression:
281 @smallexample
282 #define SEARCH(array, target)                     \
283 (@{                                                \
284   __label__ found;                                \
285   typeof (target) _SEARCH_target = (target);      \
286   typeof (*(array)) *_SEARCH_array = (array);     \
287   int i, j;                                       \
288   int value;                                      \
289   for (i = 0; i < max; i++)                       \
290     for (j = 0; j < max; j++)                     \
291       if (_SEARCH_array[i][j] == _SEARCH_target)  \
292         @{ value = i; goto found; @}                \
293   value = -1;                                     \
294  found:                                           \
295   value;                                          \
297 @end smallexample
299 Local label declarations also make the labels they declare visible to
300 nested functions, if there are any.  @xref{Nested Functions}, for details.
302 @node Labels as Values
303 @section Labels as Values
304 @cindex labels as values
305 @cindex computed gotos
306 @cindex goto with computed label
307 @cindex address of a label
309 You can get the address of a label defined in the current function
310 (or a containing function) with the unary operator @samp{&&}.  The
311 value has type @code{void *}.  This value is a constant and can be used
312 wherever a constant of that type is valid.  For example:
314 @smallexample
315 void *ptr;
316 /* @r{@dots{}} */
317 ptr = &&foo;
318 @end smallexample
320 To use these values, you need to be able to jump to one.  This is done
321 with the computed goto statement@footnote{The analogous feature in
322 Fortran is called an assigned goto, but that name seems inappropriate in
323 C, where one can do more than simply store label addresses in label
324 variables.}, @code{goto *@var{exp};}.  For example,
326 @smallexample
327 goto *ptr;
328 @end smallexample
330 @noindent
331 Any expression of type @code{void *} is allowed.
333 One way of using these constants is in initializing a static array that
334 will serve as a jump table:
336 @smallexample
337 static void *array[] = @{ &&foo, &&bar, &&hack @};
338 @end smallexample
340 Then you can select a label with indexing, like this:
342 @smallexample
343 goto *array[i];
344 @end smallexample
346 @noindent
347 Note that this does not check whether the subscript is in bounds---array
348 indexing in C never does that.
350 Such an array of label values serves a purpose much like that of the
351 @code{switch} statement.  The @code{switch} statement is cleaner, so
352 use that rather than an array unless the problem does not fit a
353 @code{switch} statement very well.
355 Another use of label values is in an interpreter for threaded code.
356 The labels within the interpreter function can be stored in the
357 threaded code for super-fast dispatching.
359 You may not use this mechanism to jump to code in a different function.
360 If you do that, totally unpredictable things will happen.  The best way to
361 avoid this is to store the label address only in automatic variables and
362 never pass it as an argument.
364 An alternate way to write the above example is
366 @smallexample
367 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
368                              &&hack - &&foo @};
369 goto *(&&foo + array[i]);
370 @end smallexample
372 @noindent
373 This is more friendly to code living in shared libraries, as it reduces
374 the number of dynamic relocations that are needed, and by consequence,
375 allows the data to be read-only.
377 The @code{&&foo} expressions for the same label might have different
378 values if the containing function is inlined or cloned.  If a program
379 relies on them being always the same,
380 @code{__attribute__((__noinline__,__noclone__))} should be used to
381 prevent inlining and cloning.  If @code{&&foo} is used in a static
382 variable initializer, inlining and cloning is forbidden.
384 @node Nested Functions
385 @section Nested Functions
386 @cindex nested functions
387 @cindex downward funargs
388 @cindex thunks
390 A @dfn{nested function} is a function defined inside another function.
391 (Nested functions are not supported for GNU C++.)  The nested function's
392 name is local to the block where it is defined.  For example, here we
393 define a nested function named @code{square}, and call it twice:
395 @smallexample
396 @group
397 foo (double a, double b)
399   double square (double z) @{ return z * z; @}
401   return square (a) + square (b);
403 @end group
404 @end smallexample
406 The nested function can access all the variables of the containing
407 function that are visible at the point of its definition.  This is
408 called @dfn{lexical scoping}.  For example, here we show a nested
409 function which uses an inherited variable named @code{offset}:
411 @smallexample
412 @group
413 bar (int *array, int offset, int size)
415   int access (int *array, int index)
416     @{ return array[index + offset]; @}
417   int i;
418   /* @r{@dots{}} */
419   for (i = 0; i < size; i++)
420     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
422 @end group
423 @end smallexample
425 Nested function definitions are permitted within functions in the places
426 where variable definitions are allowed; that is, in any block, mixed
427 with the other declarations and statements in the block.
429 It is possible to call the nested function from outside the scope of its
430 name by storing its address or passing the address to another function:
432 @smallexample
433 hack (int *array, int size)
435   void store (int index, int value)
436     @{ array[index] = value; @}
438   intermediate (store, size);
440 @end smallexample
442 Here, the function @code{intermediate} receives the address of
443 @code{store} as an argument.  If @code{intermediate} calls @code{store},
444 the arguments given to @code{store} are used to store into @code{array}.
445 But this technique works only so long as the containing function
446 (@code{hack}, in this example) does not exit.
448 If you try to call the nested function through its address after the
449 containing function has exited, all hell will break loose.  If you try
450 to call it after a containing scope level has exited, and if it refers
451 to some of the variables that are no longer in scope, you may be lucky,
452 but it's not wise to take the risk.  If, however, the nested function
453 does not refer to anything that has gone out of scope, you should be
454 safe.
456 GCC implements taking the address of a nested function using a technique
457 called @dfn{trampolines}.  This technique was described in 
458 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
459 C++ Conference Proceedings, October 17-21, 1988).
461 A nested function can jump to a label inherited from a containing
462 function, provided the label was explicitly declared in the containing
463 function (@pxref{Local Labels}).  Such a jump returns instantly to the
464 containing function, exiting the nested function which did the
465 @code{goto} and any intermediate functions as well.  Here is an example:
467 @smallexample
468 @group
469 bar (int *array, int offset, int size)
471   __label__ failure;
472   int access (int *array, int index)
473     @{
474       if (index > size)
475         goto failure;
476       return array[index + offset];
477     @}
478   int i;
479   /* @r{@dots{}} */
480   for (i = 0; i < size; i++)
481     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
482   /* @r{@dots{}} */
483   return 0;
485  /* @r{Control comes here from @code{access}
486     if it detects an error.}  */
487  failure:
488   return -1;
490 @end group
491 @end smallexample
493 A nested function always has no linkage.  Declaring one with
494 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
495 before its definition, use @code{auto} (which is otherwise meaningless
496 for function declarations).
498 @smallexample
499 bar (int *array, int offset, int size)
501   __label__ failure;
502   auto int access (int *, int);
503   /* @r{@dots{}} */
504   int access (int *array, int index)
505     @{
506       if (index > size)
507         goto failure;
508       return array[index + offset];
509     @}
510   /* @r{@dots{}} */
512 @end smallexample
514 @node Constructing Calls
515 @section Constructing Function Calls
516 @cindex constructing calls
517 @cindex forwarding calls
519 Using the built-in functions described below, you can record
520 the arguments a function received, and call another function
521 with the same arguments, without knowing the number or types
522 of the arguments.
524 You can also record the return value of that function call,
525 and later return that value, without knowing what data type
526 the function tried to return (as long as your caller expects
527 that data type).
529 However, these built-in functions may interact badly with some
530 sophisticated features or other extensions of the language.  It
531 is, therefore, not recommended to use them outside very simple
532 functions acting as mere forwarders for their arguments.
534 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
535 This built-in function returns a pointer to data
536 describing how to perform a call with the same arguments as were passed
537 to the current function.
539 The function saves the arg pointer register, structure value address,
540 and all registers that might be used to pass arguments to a function
541 into a block of memory allocated on the stack.  Then it returns the
542 address of that block.
543 @end deftypefn
545 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
546 This built-in function invokes @var{function}
547 with a copy of the parameters described by @var{arguments}
548 and @var{size}.
550 The value of @var{arguments} should be the value returned by
551 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
552 of the stack argument data, in bytes.
554 This function returns a pointer to data describing
555 how to return whatever value was returned by @var{function}.  The data
556 is saved in a block of memory allocated on the stack.
558 It is not always simple to compute the proper value for @var{size}.  The
559 value is used by @code{__builtin_apply} to compute the amount of data
560 that should be pushed on the stack and copied from the incoming argument
561 area.
562 @end deftypefn
564 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
565 This built-in function returns the value described by @var{result} from
566 the containing function.  You should specify, for @var{result}, a value
567 returned by @code{__builtin_apply}.
568 @end deftypefn
570 @deftypefn {Built-in Function} __builtin_va_arg_pack ()
571 This built-in function represents all anonymous arguments of an inline
572 function.  It can be used only in inline functions which will be always
573 inlined, never compiled as a separate function, such as those using
574 @code{__attribute__ ((__always_inline__))} or
575 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
576 It must be only passed as last argument to some other function
577 with variable arguments.  This is useful for writing small wrapper
578 inlines for variable argument functions, when using preprocessor
579 macros is undesirable.  For example:
580 @smallexample
581 extern int myprintf (FILE *f, const char *format, ...);
582 extern inline __attribute__ ((__gnu_inline__)) int
583 myprintf (FILE *f, const char *format, ...)
585   int r = fprintf (f, "myprintf: ");
586   if (r < 0)
587     return r;
588   int s = fprintf (f, format, __builtin_va_arg_pack ());
589   if (s < 0)
590     return s;
591   return r + s;
593 @end smallexample
594 @end deftypefn
596 @deftypefn {Built-in Function} __builtin_va_arg_pack_len ()
597 This built-in function returns the number of anonymous arguments of
598 an inline function.  It can be used only in inline functions which
599 will be always inlined, never compiled as a separate function, such
600 as those using @code{__attribute__ ((__always_inline__))} or
601 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
602 For example following will do link or runtime checking of open
603 arguments for optimized code:
604 @smallexample
605 #ifdef __OPTIMIZE__
606 extern inline __attribute__((__gnu_inline__)) int
607 myopen (const char *path, int oflag, ...)
609   if (__builtin_va_arg_pack_len () > 1)
610     warn_open_too_many_arguments ();
612   if (__builtin_constant_p (oflag))
613     @{
614       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
615         @{
616           warn_open_missing_mode ();
617           return __open_2 (path, oflag);
618         @}
619       return open (path, oflag, __builtin_va_arg_pack ());
620     @}
621     
622   if (__builtin_va_arg_pack_len () < 1)
623     return __open_2 (path, oflag);
625   return open (path, oflag, __builtin_va_arg_pack ());
627 #endif
628 @end smallexample
629 @end deftypefn
631 @node Typeof
632 @section Referring to a Type with @code{typeof}
633 @findex typeof
634 @findex sizeof
635 @cindex macros, types of arguments
637 Another way to refer to the type of an expression is with @code{typeof}.
638 The syntax of using of this keyword looks like @code{sizeof}, but the
639 construct acts semantically like a type name defined with @code{typedef}.
641 There are two ways of writing the argument to @code{typeof}: with an
642 expression or with a type.  Here is an example with an expression:
644 @smallexample
645 typeof (x[0](1))
646 @end smallexample
648 @noindent
649 This assumes that @code{x} is an array of pointers to functions;
650 the type described is that of the values of the functions.
652 Here is an example with a typename as the argument:
654 @smallexample
655 typeof (int *)
656 @end smallexample
658 @noindent
659 Here the type described is that of pointers to @code{int}.
661 If you are writing a header file that must work when included in ISO C
662 programs, write @code{__typeof__} instead of @code{typeof}.
663 @xref{Alternate Keywords}.
665 A @code{typeof}-construct can be used anywhere a typedef name could be
666 used.  For example, you can use it in a declaration, in a cast, or inside
667 of @code{sizeof} or @code{typeof}.
669 The operand of @code{typeof} is evaluated for its side effects if and
670 only if it is an expression of variably modified type or the name of
671 such a type.
673 @code{typeof} is often useful in conjunction with the
674 statements-within-expressions feature.  Here is how the two together can
675 be used to define a safe ``maximum'' macro that operates on any
676 arithmetic type and evaluates each of its arguments exactly once:
678 @smallexample
679 #define max(a,b) \
680   (@{ typeof (a) _a = (a); \
681       typeof (b) _b = (b); \
682     _a > _b ? _a : _b; @})
683 @end smallexample
685 @cindex underscores in variables in macros
686 @cindex @samp{_} in variables in macros
687 @cindex local variables in macros
688 @cindex variables, local, in macros
689 @cindex macros, local variables in
691 The reason for using names that start with underscores for the local
692 variables is to avoid conflicts with variable names that occur within the
693 expressions that are substituted for @code{a} and @code{b}.  Eventually we
694 hope to design a new form of declaration syntax that allows you to declare
695 variables whose scopes start only after their initializers; this will be a
696 more reliable way to prevent such conflicts.
698 @noindent
699 Some more examples of the use of @code{typeof}:
701 @itemize @bullet
702 @item
703 This declares @code{y} with the type of what @code{x} points to.
705 @smallexample
706 typeof (*x) y;
707 @end smallexample
709 @item
710 This declares @code{y} as an array of such values.
712 @smallexample
713 typeof (*x) y[4];
714 @end smallexample
716 @item
717 This declares @code{y} as an array of pointers to characters:
719 @smallexample
720 typeof (typeof (char *)[4]) y;
721 @end smallexample
723 @noindent
724 It is equivalent to the following traditional C declaration:
726 @smallexample
727 char *y[4];
728 @end smallexample
730 To see the meaning of the declaration using @code{typeof}, and why it
731 might be a useful way to write, rewrite it with these macros:
733 @smallexample
734 #define pointer(T)  typeof(T *)
735 #define array(T, N) typeof(T [N])
736 @end smallexample
738 @noindent
739 Now the declaration can be rewritten this way:
741 @smallexample
742 array (pointer (char), 4) y;
743 @end smallexample
745 @noindent
746 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
747 pointers to @code{char}.
748 @end itemize
750 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
751 a more limited extension which permitted one to write
753 @smallexample
754 typedef @var{T} = @var{expr};
755 @end smallexample
757 @noindent
758 with the effect of declaring @var{T} to have the type of the expression
759 @var{expr}.  This extension does not work with GCC 3 (versions between
760 3.0 and 3.2 will crash; 3.2.1 and later give an error).  Code which
761 relies on it should be rewritten to use @code{typeof}:
763 @smallexample
764 typedef typeof(@var{expr}) @var{T};
765 @end smallexample
767 @noindent
768 This will work with all versions of GCC@.
770 @node Conditionals
771 @section Conditionals with Omitted Operands
772 @cindex conditional expressions, extensions
773 @cindex omitted middle-operands
774 @cindex middle-operands, omitted
775 @cindex extensions, @code{?:}
776 @cindex @code{?:} extensions
778 The middle operand in a conditional expression may be omitted.  Then
779 if the first operand is nonzero, its value is the value of the conditional
780 expression.
782 Therefore, the expression
784 @smallexample
785 x ? : y
786 @end smallexample
788 @noindent
789 has the value of @code{x} if that is nonzero; otherwise, the value of
790 @code{y}.
792 This example is perfectly equivalent to
794 @smallexample
795 x ? x : y
796 @end smallexample
798 @cindex side effect in ?:
799 @cindex ?: side effect
800 @noindent
801 In this simple case, the ability to omit the middle operand is not
802 especially useful.  When it becomes useful is when the first operand does,
803 or may (if it is a macro argument), contain a side effect.  Then repeating
804 the operand in the middle would perform the side effect twice.  Omitting
805 the middle operand uses the value already computed without the undesirable
806 effects of recomputing it.
808 @node __int128
809 @section 128-bits integers
810 @cindex @code{__int128} data types
812 As an extension the integer scalar type @code{__int128} is supported for
813 targets having an integer mode wide enough to hold 128-bit.
814 Simply write @code{__int128} for a signed 128-bit integer, or
815 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
816 support in GCC to express an integer constant of type @code{__int128}
817 for targets having @code{long long} integer with less then 128 bit width.
819 @node Long Long
820 @section Double-Word Integers
821 @cindex @code{long long} data types
822 @cindex double-word arithmetic
823 @cindex multiprecision arithmetic
824 @cindex @code{LL} integer suffix
825 @cindex @code{ULL} integer suffix
827 ISO C99 supports data types for integers that are at least 64 bits wide,
828 and as an extension GCC supports them in C90 mode and in C++.
829 Simply write @code{long long int} for a signed integer, or
830 @code{unsigned long long int} for an unsigned integer.  To make an
831 integer constant of type @code{long long int}, add the suffix @samp{LL}
832 to the integer.  To make an integer constant of type @code{unsigned long
833 long int}, add the suffix @samp{ULL} to the integer.
835 You can use these types in arithmetic like any other integer types.
836 Addition, subtraction, and bitwise boolean operations on these types
837 are open-coded on all types of machines.  Multiplication is open-coded
838 if the machine supports fullword-to-doubleword a widening multiply
839 instruction.  Division and shifts are open-coded only on machines that
840 provide special support.  The operations that are not open-coded use
841 special library routines that come with GCC@.
843 There may be pitfalls when you use @code{long long} types for function
844 arguments, unless you declare function prototypes.  If a function
845 expects type @code{int} for its argument, and you pass a value of type
846 @code{long long int}, confusion will result because the caller and the
847 subroutine will disagree about the number of bytes for the argument.
848 Likewise, if the function expects @code{long long int} and you pass
849 @code{int}.  The best way to avoid such problems is to use prototypes.
851 @node Complex
852 @section Complex Numbers
853 @cindex complex numbers
854 @cindex @code{_Complex} keyword
855 @cindex @code{__complex__} keyword
857 ISO C99 supports complex floating data types, and as an extension GCC
858 supports them in C90 mode and in C++, and supports complex integer data
859 types which are not part of ISO C99.  You can declare complex types
860 using the keyword @code{_Complex}.  As an extension, the older GNU
861 keyword @code{__complex__} is also supported.
863 For example, @samp{_Complex double x;} declares @code{x} as a
864 variable whose real part and imaginary part are both of type
865 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
866 have real and imaginary parts of type @code{short int}; this is not
867 likely to be useful, but it shows that the set of complex types is
868 complete.
870 To write a constant with a complex data type, use the suffix @samp{i} or
871 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
872 has type @code{_Complex float} and @code{3i} has type
873 @code{_Complex int}.  Such a constant always has a pure imaginary
874 value, but you can form any complex value you like by adding one to a
875 real constant.  This is a GNU extension; if you have an ISO C99
876 conforming C library (such as GNU libc), and want to construct complex
877 constants of floating type, you should include @code{<complex.h>} and
878 use the macros @code{I} or @code{_Complex_I} instead.
880 @cindex @code{__real__} keyword
881 @cindex @code{__imag__} keyword
882 To extract the real part of a complex-valued expression @var{exp}, write
883 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
884 extract the imaginary part.  This is a GNU extension; for values of
885 floating type, you should use the ISO C99 functions @code{crealf},
886 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
887 @code{cimagl}, declared in @code{<complex.h>} and also provided as
888 built-in functions by GCC@.
890 @cindex complex conjugation
891 The operator @samp{~} performs complex conjugation when used on a value
892 with a complex type.  This is a GNU extension; for values of
893 floating type, you should use the ISO C99 functions @code{conjf},
894 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
895 provided as built-in functions by GCC@.
897 GCC can allocate complex automatic variables in a noncontiguous
898 fashion; it's even possible for the real part to be in a register while
899 the imaginary part is on the stack (or vice-versa).  Only the DWARF2
900 debug info format can represent this, so use of DWARF2 is recommended.
901 If you are using the stabs debug info format, GCC describes a noncontiguous
902 complex variable as if it were two separate variables of noncomplex type.
903 If the variable's actual name is @code{foo}, the two fictitious
904 variables are named @code{foo$real} and @code{foo$imag}.  You can
905 examine and set these two fictitious variables with your debugger.
907 @node Floating Types
908 @section Additional Floating Types
909 @cindex additional floating types
910 @cindex @code{__float80} data type
911 @cindex @code{__float128} data type
912 @cindex @code{w} floating point suffix
913 @cindex @code{q} floating point suffix
914 @cindex @code{W} floating point suffix
915 @cindex @code{Q} floating point suffix
917 As an extension, the GNU C compiler supports additional floating
918 types, @code{__float80} and @code{__float128} to support 80bit
919 (@code{XFmode}) and 128 bit (@code{TFmode}) floating types.
920 Support for additional types includes the arithmetic operators:
921 add, subtract, multiply, divide; unary arithmetic operators;
922 relational operators; equality operators; and conversions to and from
923 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
924 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
925 for @code{_float128}.  You can declare complex types using the
926 corresponding internal complex type, @code{XCmode} for @code{__float80}
927 type and @code{TCmode} for @code{__float128} type:
929 @smallexample
930 typedef _Complex float __attribute__((mode(TC))) _Complex128;
931 typedef _Complex float __attribute__((mode(XC))) _Complex80;
932 @end smallexample
934 Not all targets support additional floating point types.  @code{__float80}
935 and @code{__float128} types are supported on i386, x86_64 and ia64 targets.
937 @node Half-Precision
938 @section Half-Precision Floating Point
939 @cindex half-precision floating point
940 @cindex @code{__fp16} data type
942 On ARM targets, GCC supports half-precision (16-bit) floating point via
943 the @code{__fp16} type.  You must enable this type explicitly 
944 with the @option{-mfp16-format} command-line option in order to use it.
946 ARM supports two incompatible representations for half-precision
947 floating-point values.  You must choose one of the representations and
948 use it consistently in your program.
950 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
951 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
952 There are 11 bits of significand precision, approximately 3
953 decimal digits.
955 Specifying @option{-mfp16-format=alternative} selects the ARM
956 alternative format.  This representation is similar to the IEEE
957 format, but does not support infinities or NaNs.  Instead, the range
958 of exponents is extended, so that this format can represent normalized
959 values in the range of @math{2^{-14}} to 131008.
961 The @code{__fp16} type is a storage format only.  For purposes
962 of arithmetic and other operations, @code{__fp16} values in C or C++
963 expressions are automatically promoted to @code{float}.  In addition,
964 you cannot declare a function with a return value or parameters 
965 of type @code{__fp16}.
967 Note that conversions from @code{double} to @code{__fp16}
968 involve an intermediate conversion to @code{float}.  Because
969 of rounding, this can sometimes produce a different result than a
970 direct conversion.
972 ARM provides hardware support for conversions between 
973 @code{__fp16} and @code{float} values
974 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
975 code using these hardware instructions if you compile with
976 options to select an FPU that provides them; 
977 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
978 in addition to the @option{-mfp16-format} option to select
979 a half-precision format.  
981 Language-level support for the @code{__fp16} data type is
982 independent of whether GCC generates code using hardware floating-point
983 instructions.  In cases where hardware support is not specified, GCC
984 implements conversions between @code{__fp16} and @code{float} values
985 as library calls.
987 @node Decimal Float
988 @section Decimal Floating Types
989 @cindex decimal floating types
990 @cindex @code{_Decimal32} data type
991 @cindex @code{_Decimal64} data type
992 @cindex @code{_Decimal128} data type
993 @cindex @code{df} integer suffix
994 @cindex @code{dd} integer suffix
995 @cindex @code{dl} integer suffix
996 @cindex @code{DF} integer suffix
997 @cindex @code{DD} integer suffix
998 @cindex @code{DL} integer suffix
1000 As an extension, the GNU C compiler supports decimal floating types as
1001 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1002 floating types in GCC will evolve as the draft technical report changes.
1003 Calling conventions for any target might also change.  Not all targets
1004 support decimal floating types.
1006 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1007 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1008 @code{float}, @code{double}, and @code{long double} whose radix is not
1009 specified by the C standard but is usually two.
1011 Support for decimal floating types includes the arithmetic operators
1012 add, subtract, multiply, divide; unary arithmetic operators;
1013 relational operators; equality operators; and conversions to and from
1014 integer and other floating types.  Use a suffix @samp{df} or
1015 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1016 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1017 @code{_Decimal128}.
1019 GCC support of decimal float as specified by the draft technical report
1020 is incomplete:
1022 @itemize @bullet
1023 @item
1024 When the value of a decimal floating type cannot be represented in the
1025 integer type to which it is being converted, the result is undefined
1026 rather than the result value specified by the draft technical report.
1028 @item
1029 GCC does not provide the C library functionality associated with
1030 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1031 @file{wchar.h}, which must come from a separate C library implementation.
1032 Because of this the GNU C compiler does not define macro
1033 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1034 the technical report.
1035 @end itemize
1037 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1038 are supported by the DWARF2 debug information format.
1040 @node Hex Floats
1041 @section Hex Floats
1042 @cindex hex floats
1044 ISO C99 supports floating-point numbers written not only in the usual
1045 decimal notation, such as @code{1.55e1}, but also numbers such as
1046 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1047 supports this in C90 mode (except in some cases when strictly
1048 conforming) and in C++.  In that format the
1049 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1050 mandatory.  The exponent is a decimal number that indicates the power of
1051 2 by which the significant part will be multiplied.  Thus @samp{0x1.f} is
1052 @tex
1053 $1 {15\over16}$,
1054 @end tex
1055 @ifnottex
1056 1 15/16,
1057 @end ifnottex
1058 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1059 is the same as @code{1.55e1}.
1061 Unlike for floating-point numbers in the decimal notation the exponent
1062 is always required in the hexadecimal notation.  Otherwise the compiler
1063 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1064 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1065 extension for floating-point constants of type @code{float}.
1067 @node Fixed-Point
1068 @section Fixed-Point Types
1069 @cindex fixed-point types
1070 @cindex @code{_Fract} data type
1071 @cindex @code{_Accum} data type
1072 @cindex @code{_Sat} data type
1073 @cindex @code{hr} fixed-suffix
1074 @cindex @code{r} fixed-suffix
1075 @cindex @code{lr} fixed-suffix
1076 @cindex @code{llr} fixed-suffix
1077 @cindex @code{uhr} fixed-suffix
1078 @cindex @code{ur} fixed-suffix
1079 @cindex @code{ulr} fixed-suffix
1080 @cindex @code{ullr} fixed-suffix
1081 @cindex @code{hk} fixed-suffix
1082 @cindex @code{k} fixed-suffix
1083 @cindex @code{lk} fixed-suffix
1084 @cindex @code{llk} fixed-suffix
1085 @cindex @code{uhk} fixed-suffix
1086 @cindex @code{uk} fixed-suffix
1087 @cindex @code{ulk} fixed-suffix
1088 @cindex @code{ullk} fixed-suffix
1089 @cindex @code{HR} fixed-suffix
1090 @cindex @code{R} fixed-suffix
1091 @cindex @code{LR} fixed-suffix
1092 @cindex @code{LLR} fixed-suffix
1093 @cindex @code{UHR} fixed-suffix
1094 @cindex @code{UR} fixed-suffix
1095 @cindex @code{ULR} fixed-suffix
1096 @cindex @code{ULLR} fixed-suffix
1097 @cindex @code{HK} fixed-suffix
1098 @cindex @code{K} fixed-suffix
1099 @cindex @code{LK} fixed-suffix
1100 @cindex @code{LLK} fixed-suffix
1101 @cindex @code{UHK} fixed-suffix
1102 @cindex @code{UK} fixed-suffix
1103 @cindex @code{ULK} fixed-suffix
1104 @cindex @code{ULLK} fixed-suffix
1106 As an extension, the GNU C compiler supports fixed-point types as
1107 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1108 types in GCC will evolve as the draft technical report changes.
1109 Calling conventions for any target might also change.  Not all targets
1110 support fixed-point types.
1112 The fixed-point types are
1113 @code{short _Fract},
1114 @code{_Fract},
1115 @code{long _Fract},
1116 @code{long long _Fract},
1117 @code{unsigned short _Fract},
1118 @code{unsigned _Fract},
1119 @code{unsigned long _Fract},
1120 @code{unsigned long long _Fract},
1121 @code{_Sat short _Fract},
1122 @code{_Sat _Fract},
1123 @code{_Sat long _Fract},
1124 @code{_Sat long long _Fract},
1125 @code{_Sat unsigned short _Fract},
1126 @code{_Sat unsigned _Fract},
1127 @code{_Sat unsigned long _Fract},
1128 @code{_Sat unsigned long long _Fract},
1129 @code{short _Accum},
1130 @code{_Accum},
1131 @code{long _Accum},
1132 @code{long long _Accum},
1133 @code{unsigned short _Accum},
1134 @code{unsigned _Accum},
1135 @code{unsigned long _Accum},
1136 @code{unsigned long long _Accum},
1137 @code{_Sat short _Accum},
1138 @code{_Sat _Accum},
1139 @code{_Sat long _Accum},
1140 @code{_Sat long long _Accum},
1141 @code{_Sat unsigned short _Accum},
1142 @code{_Sat unsigned _Accum},
1143 @code{_Sat unsigned long _Accum},
1144 @code{_Sat unsigned long long _Accum}.
1146 Fixed-point data values contain fractional and optional integral parts.
1147 The format of fixed-point data varies and depends on the target machine.
1149 Support for fixed-point types includes:
1150 @itemize @bullet
1151 @item
1152 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1153 @item
1154 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1155 @item
1156 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1157 @item
1158 binary shift operators (@code{<<}, @code{>>})
1159 @item
1160 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1161 @item
1162 equality operators (@code{==}, @code{!=})
1163 @item
1164 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1165 @code{<<=}, @code{>>=})
1166 @item
1167 conversions to and from integer, floating-point, or fixed-point types
1168 @end itemize
1170 Use a suffix in a fixed-point literal constant:
1171 @itemize
1172 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1173 @code{_Sat short _Fract}
1174 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1175 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1176 @code{_Sat long _Fract}
1177 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1178 @code{_Sat long long _Fract}
1179 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1180 @code{_Sat unsigned short _Fract}
1181 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1182 @code{_Sat unsigned _Fract}
1183 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1184 @code{_Sat unsigned long _Fract}
1185 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1186 and @code{_Sat unsigned long long _Fract}
1187 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1188 @code{_Sat short _Accum}
1189 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1190 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1191 @code{_Sat long _Accum}
1192 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1193 @code{_Sat long long _Accum}
1194 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1195 @code{_Sat unsigned short _Accum}
1196 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1197 @code{_Sat unsigned _Accum}
1198 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1199 @code{_Sat unsigned long _Accum}
1200 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1201 and @code{_Sat unsigned long long _Accum}
1202 @end itemize
1204 GCC support of fixed-point types as specified by the draft technical report
1205 is incomplete:
1207 @itemize @bullet
1208 @item
1209 Pragmas to control overflow and rounding behaviors are not implemented.
1210 @end itemize
1212 Fixed-point types are supported by the DWARF2 debug information format.
1214 @node Named Address Spaces
1215 @section Named address spaces
1216 @cindex named address spaces
1218 As an extension, the GNU C compiler supports named address spaces as
1219 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1220 address spaces in GCC will evolve as the draft technical report changes.
1221 Calling conventions for any target might also change.  At present, only
1222 the SPU target supports other address spaces.  On the SPU target, for
1223 example, variables may be declared as belonging to another address space
1224 by qualifying the type with the @code{__ea} address space identifier:
1226 @smallexample
1227 extern int __ea i;
1228 @end smallexample
1230 When the variable @code{i} is accessed, the compiler will generate
1231 special code to access this variable.  It may use runtime library
1232 support, or generate special machine instructions to access that address
1233 space.
1235 The @code{__ea} identifier may be used exactly like any other C type
1236 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1237 document for more details.
1239 @node Zero Length
1240 @section Arrays of Length Zero
1241 @cindex arrays of length zero
1242 @cindex zero-length arrays
1243 @cindex length-zero arrays
1244 @cindex flexible array members
1246 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1247 last element of a structure which is really a header for a variable-length
1248 object:
1250 @smallexample
1251 struct line @{
1252   int length;
1253   char contents[0];
1256 struct line *thisline = (struct line *)
1257   malloc (sizeof (struct line) + this_length);
1258 thisline->length = this_length;
1259 @end smallexample
1261 In ISO C90, you would have to give @code{contents} a length of 1, which
1262 means either you waste space or complicate the argument to @code{malloc}.
1264 In ISO C99, you would use a @dfn{flexible array member}, which is
1265 slightly different in syntax and semantics:
1267 @itemize @bullet
1268 @item
1269 Flexible array members are written as @code{contents[]} without
1270 the @code{0}.
1272 @item
1273 Flexible array members have incomplete type, and so the @code{sizeof}
1274 operator may not be applied.  As a quirk of the original implementation
1275 of zero-length arrays, @code{sizeof} evaluates to zero.
1277 @item
1278 Flexible array members may only appear as the last member of a
1279 @code{struct} that is otherwise non-empty.
1281 @item
1282 A structure containing a flexible array member, or a union containing
1283 such a structure (possibly recursively), may not be a member of a
1284 structure or an element of an array.  (However, these uses are
1285 permitted by GCC as extensions.)
1286 @end itemize
1288 GCC versions before 3.0 allowed zero-length arrays to be statically
1289 initialized, as if they were flexible arrays.  In addition to those
1290 cases that were useful, it also allowed initializations in situations
1291 that would corrupt later data.  Non-empty initialization of zero-length
1292 arrays is now treated like any case where there are more initializer
1293 elements than the array holds, in that a suitable warning about "excess
1294 elements in array" is given, and the excess elements (all of them, in
1295 this case) are ignored.
1297 Instead GCC allows static initialization of flexible array members.
1298 This is equivalent to defining a new structure containing the original
1299 structure followed by an array of sufficient size to contain the data.
1300 I.e.@: in the following, @code{f1} is constructed as if it were declared
1301 like @code{f2}.
1303 @smallexample
1304 struct f1 @{
1305   int x; int y[];
1306 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1308 struct f2 @{
1309   struct f1 f1; int data[3];
1310 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1311 @end smallexample
1313 @noindent
1314 The convenience of this extension is that @code{f1} has the desired
1315 type, eliminating the need to consistently refer to @code{f2.f1}.
1317 This has symmetry with normal static arrays, in that an array of
1318 unknown size is also written with @code{[]}.
1320 Of course, this extension only makes sense if the extra data comes at
1321 the end of a top-level object, as otherwise we would be overwriting
1322 data at subsequent offsets.  To avoid undue complication and confusion
1323 with initialization of deeply nested arrays, we simply disallow any
1324 non-empty initialization except when the structure is the top-level
1325 object.  For example:
1327 @smallexample
1328 struct foo @{ int x; int y[]; @};
1329 struct bar @{ struct foo z; @};
1331 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1332 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1333 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1334 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1335 @end smallexample
1337 @node Empty Structures
1338 @section Structures With No Members
1339 @cindex empty structures
1340 @cindex zero-size structures
1342 GCC permits a C structure to have no members:
1344 @smallexample
1345 struct empty @{
1347 @end smallexample
1349 The structure will have size zero.  In C++, empty structures are part
1350 of the language.  G++ treats empty structures as if they had a single
1351 member of type @code{char}.
1353 @node Variable Length
1354 @section Arrays of Variable Length
1355 @cindex variable-length arrays
1356 @cindex arrays of variable length
1357 @cindex VLAs
1359 Variable-length automatic arrays are allowed in ISO C99, and as an
1360 extension GCC accepts them in C90 mode and in C++.  (However, GCC's
1361 implementation of variable-length arrays does not yet conform in detail
1362 to the ISO C99 standard.)  These arrays are
1363 declared like any other automatic arrays, but with a length that is not
1364 a constant expression.  The storage is allocated at the point of
1365 declaration and deallocated when the brace-level is exited.  For
1366 example:
1368 @smallexample
1369 FILE *
1370 concat_fopen (char *s1, char *s2, char *mode)
1372   char str[strlen (s1) + strlen (s2) + 1];
1373   strcpy (str, s1);
1374   strcat (str, s2);
1375   return fopen (str, mode);
1377 @end smallexample
1379 @cindex scope of a variable length array
1380 @cindex variable-length array scope
1381 @cindex deallocating variable length arrays
1382 Jumping or breaking out of the scope of the array name deallocates the
1383 storage.  Jumping into the scope is not allowed; you get an error
1384 message for it.
1386 @cindex @code{alloca} vs variable-length arrays
1387 You can use the function @code{alloca} to get an effect much like
1388 variable-length arrays.  The function @code{alloca} is available in
1389 many other C implementations (but not in all).  On the other hand,
1390 variable-length arrays are more elegant.
1392 There are other differences between these two methods.  Space allocated
1393 with @code{alloca} exists until the containing @emph{function} returns.
1394 The space for a variable-length array is deallocated as soon as the array
1395 name's scope ends.  (If you use both variable-length arrays and
1396 @code{alloca} in the same function, deallocation of a variable-length array
1397 will also deallocate anything more recently allocated with @code{alloca}.)
1399 You can also use variable-length arrays as arguments to functions:
1401 @smallexample
1402 struct entry
1403 tester (int len, char data[len][len])
1405   /* @r{@dots{}} */
1407 @end smallexample
1409 The length of an array is computed once when the storage is allocated
1410 and is remembered for the scope of the array in case you access it with
1411 @code{sizeof}.
1413 If you want to pass the array first and the length afterward, you can
1414 use a forward declaration in the parameter list---another GNU extension.
1416 @smallexample
1417 struct entry
1418 tester (int len; char data[len][len], int len)
1420   /* @r{@dots{}} */
1422 @end smallexample
1424 @cindex parameter forward declaration
1425 The @samp{int len} before the semicolon is a @dfn{parameter forward
1426 declaration}, and it serves the purpose of making the name @code{len}
1427 known when the declaration of @code{data} is parsed.
1429 You can write any number of such parameter forward declarations in the
1430 parameter list.  They can be separated by commas or semicolons, but the
1431 last one must end with a semicolon, which is followed by the ``real''
1432 parameter declarations.  Each forward declaration must match a ``real''
1433 declaration in parameter name and data type.  ISO C99 does not support
1434 parameter forward declarations.
1436 @node Variadic Macros
1437 @section Macros with a Variable Number of Arguments.
1438 @cindex variable number of arguments
1439 @cindex macro with variable arguments
1440 @cindex rest argument (in macro)
1441 @cindex variadic macros
1443 In the ISO C standard of 1999, a macro can be declared to accept a
1444 variable number of arguments much as a function can.  The syntax for
1445 defining the macro is similar to that of a function.  Here is an
1446 example:
1448 @smallexample
1449 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1450 @end smallexample
1452 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1453 such a macro, it represents the zero or more tokens until the closing
1454 parenthesis that ends the invocation, including any commas.  This set of
1455 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1456 wherever it appears.  See the CPP manual for more information.
1458 GCC has long supported variadic macros, and used a different syntax that
1459 allowed you to give a name to the variable arguments just like any other
1460 argument.  Here is an example:
1462 @smallexample
1463 #define debug(format, args...) fprintf (stderr, format, args)
1464 @end smallexample
1466 This is in all ways equivalent to the ISO C example above, but arguably
1467 more readable and descriptive.
1469 GNU CPP has two further variadic macro extensions, and permits them to
1470 be used with either of the above forms of macro definition.
1472 In standard C, you are not allowed to leave the variable argument out
1473 entirely; but you are allowed to pass an empty argument.  For example,
1474 this invocation is invalid in ISO C, because there is no comma after
1475 the string:
1477 @smallexample
1478 debug ("A message")
1479 @end smallexample
1481 GNU CPP permits you to completely omit the variable arguments in this
1482 way.  In the above examples, the compiler would complain, though since
1483 the expansion of the macro still has the extra comma after the format
1484 string.
1486 To help solve this problem, CPP behaves specially for variable arguments
1487 used with the token paste operator, @samp{##}.  If instead you write
1489 @smallexample
1490 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1491 @end smallexample
1493 and if the variable arguments are omitted or empty, the @samp{##}
1494 operator causes the preprocessor to remove the comma before it.  If you
1495 do provide some variable arguments in your macro invocation, GNU CPP
1496 does not complain about the paste operation and instead places the
1497 variable arguments after the comma.  Just like any other pasted macro
1498 argument, these arguments are not macro expanded.
1500 @node Escaped Newlines
1501 @section Slightly Looser Rules for Escaped Newlines
1502 @cindex escaped newlines
1503 @cindex newlines (escaped)
1505 Recently, the preprocessor has relaxed its treatment of escaped
1506 newlines.  Previously, the newline had to immediately follow a
1507 backslash.  The current implementation allows whitespace in the form
1508 of spaces, horizontal and vertical tabs, and form feeds between the
1509 backslash and the subsequent newline.  The preprocessor issues a
1510 warning, but treats it as a valid escaped newline and combines the two
1511 lines to form a single logical line.  This works within comments and
1512 tokens, as well as between tokens.  Comments are @emph{not} treated as
1513 whitespace for the purposes of this relaxation, since they have not
1514 yet been replaced with spaces.
1516 @node Subscripting
1517 @section Non-Lvalue Arrays May Have Subscripts
1518 @cindex subscripting
1519 @cindex arrays, non-lvalue
1521 @cindex subscripting and function values
1522 In ISO C99, arrays that are not lvalues still decay to pointers, and
1523 may be subscripted, although they may not be modified or used after
1524 the next sequence point and the unary @samp{&} operator may not be
1525 applied to them.  As an extension, GCC allows such arrays to be
1526 subscripted in C90 mode, though otherwise they do not decay to
1527 pointers outside C99 mode.  For example,
1528 this is valid in GNU C though not valid in C90:
1530 @smallexample
1531 @group
1532 struct foo @{int a[4];@};
1534 struct foo f();
1536 bar (int index)
1538   return f().a[index];
1540 @end group
1541 @end smallexample
1543 @node Pointer Arith
1544 @section Arithmetic on @code{void}- and Function-Pointers
1545 @cindex void pointers, arithmetic
1546 @cindex void, size of pointer to
1547 @cindex function pointers, arithmetic
1548 @cindex function, size of pointer to
1550 In GNU C, addition and subtraction operations are supported on pointers to
1551 @code{void} and on pointers to functions.  This is done by treating the
1552 size of a @code{void} or of a function as 1.
1554 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1555 and on function types, and returns 1.
1557 @opindex Wpointer-arith
1558 The option @option{-Wpointer-arith} requests a warning if these extensions
1559 are used.
1561 @node Initializers
1562 @section Non-Constant Initializers
1563 @cindex initializers, non-constant
1564 @cindex non-constant initializers
1566 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1567 automatic variable are not required to be constant expressions in GNU C@.
1568 Here is an example of an initializer with run-time varying elements:
1570 @smallexample
1571 foo (float f, float g)
1573   float beat_freqs[2] = @{ f-g, f+g @};
1574   /* @r{@dots{}} */
1576 @end smallexample
1578 @node Compound Literals
1579 @section Compound Literals
1580 @cindex constructor expressions
1581 @cindex initializations in expressions
1582 @cindex structures, constructor expression
1583 @cindex expressions, constructor
1584 @cindex compound literals
1585 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1587 ISO C99 supports compound literals.  A compound literal looks like
1588 a cast containing an initializer.  Its value is an object of the
1589 type specified in the cast, containing the elements specified in
1590 the initializer; it is an lvalue.  As an extension, GCC supports
1591 compound literals in C90 mode and in C++.
1593 Usually, the specified type is a structure.  Assume that
1594 @code{struct foo} and @code{structure} are declared as shown:
1596 @smallexample
1597 struct foo @{int a; char b[2];@} structure;
1598 @end smallexample
1600 @noindent
1601 Here is an example of constructing a @code{struct foo} with a compound literal:
1603 @smallexample
1604 structure = ((struct foo) @{x + y, 'a', 0@});
1605 @end smallexample
1607 @noindent
1608 This is equivalent to writing the following:
1610 @smallexample
1612   struct foo temp = @{x + y, 'a', 0@};
1613   structure = temp;
1615 @end smallexample
1617 You can also construct an array.  If all the elements of the compound literal
1618 are (made up of) simple constant expressions, suitable for use in
1619 initializers of objects of static storage duration, then the compound
1620 literal can be coerced to a pointer to its first element and used in
1621 such an initializer, as shown here:
1623 @smallexample
1624 char **foo = (char *[]) @{ "x", "y", "z" @};
1625 @end smallexample
1627 Compound literals for scalar types and union types are is
1628 also allowed, but then the compound literal is equivalent
1629 to a cast.
1631 As a GNU extension, GCC allows initialization of objects with static storage
1632 duration by compound literals (which is not possible in ISO C99, because
1633 the initializer is not a constant).
1634 It is handled as if the object was initialized only with the bracket
1635 enclosed list if the types of the compound literal and the object match.
1636 The initializer list of the compound literal must be constant.
1637 If the object being initialized has array type of unknown size, the size is
1638 determined by compound literal size.
1640 @smallexample
1641 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1642 static int y[] = (int []) @{1, 2, 3@};
1643 static int z[] = (int [3]) @{1@};
1644 @end smallexample
1646 @noindent
1647 The above lines are equivalent to the following:
1648 @smallexample
1649 static struct foo x = @{1, 'a', 'b'@};
1650 static int y[] = @{1, 2, 3@};
1651 static int z[] = @{1, 0, 0@};
1652 @end smallexample
1654 @node Designated Inits
1655 @section Designated Initializers
1656 @cindex initializers with labeled elements
1657 @cindex labeled elements in initializers
1658 @cindex case labels in initializers
1659 @cindex designated initializers
1661 Standard C90 requires the elements of an initializer to appear in a fixed
1662 order, the same as the order of the elements in the array or structure
1663 being initialized.
1665 In ISO C99 you can give the elements in any order, specifying the array
1666 indices or structure field names they apply to, and GNU C allows this as
1667 an extension in C90 mode as well.  This extension is not
1668 implemented in GNU C++.
1670 To specify an array index, write
1671 @samp{[@var{index}] =} before the element value.  For example,
1673 @smallexample
1674 int a[6] = @{ [4] = 29, [2] = 15 @};
1675 @end smallexample
1677 @noindent
1678 is equivalent to
1680 @smallexample
1681 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1682 @end smallexample
1684 @noindent
1685 The index values must be constant expressions, even if the array being
1686 initialized is automatic.
1688 An alternative syntax for this which has been obsolete since GCC 2.5 but
1689 GCC still accepts is to write @samp{[@var{index}]} before the element
1690 value, with no @samp{=}.
1692 To initialize a range of elements to the same value, write
1693 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1694 extension.  For example,
1696 @smallexample
1697 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1698 @end smallexample
1700 @noindent
1701 If the value in it has side-effects, the side-effects will happen only once,
1702 not for each initialized field by the range initializer.
1704 @noindent
1705 Note that the length of the array is the highest value specified
1706 plus one.
1708 In a structure initializer, specify the name of a field to initialize
1709 with @samp{.@var{fieldname} =} before the element value.  For example,
1710 given the following structure,
1712 @smallexample
1713 struct point @{ int x, y; @};
1714 @end smallexample
1716 @noindent
1717 the following initialization
1719 @smallexample
1720 struct point p = @{ .y = yvalue, .x = xvalue @};
1721 @end smallexample
1723 @noindent
1724 is equivalent to
1726 @smallexample
1727 struct point p = @{ xvalue, yvalue @};
1728 @end smallexample
1730 Another syntax which has the same meaning, obsolete since GCC 2.5, is
1731 @samp{@var{fieldname}:}, as shown here:
1733 @smallexample
1734 struct point p = @{ y: yvalue, x: xvalue @};
1735 @end smallexample
1737 @cindex designators
1738 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1739 @dfn{designator}.  You can also use a designator (or the obsolete colon
1740 syntax) when initializing a union, to specify which element of the union
1741 should be used.  For example,
1743 @smallexample
1744 union foo @{ int i; double d; @};
1746 union foo f = @{ .d = 4 @};
1747 @end smallexample
1749 @noindent
1750 will convert 4 to a @code{double} to store it in the union using
1751 the second element.  By contrast, casting 4 to type @code{union foo}
1752 would store it into the union as the integer @code{i}, since it is
1753 an integer.  (@xref{Cast to Union}.)
1755 You can combine this technique of naming elements with ordinary C
1756 initialization of successive elements.  Each initializer element that
1757 does not have a designator applies to the next consecutive element of the
1758 array or structure.  For example,
1760 @smallexample
1761 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1762 @end smallexample
1764 @noindent
1765 is equivalent to
1767 @smallexample
1768 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1769 @end smallexample
1771 Labeling the elements of an array initializer is especially useful
1772 when the indices are characters or belong to an @code{enum} type.
1773 For example:
1775 @smallexample
1776 int whitespace[256]
1777   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1778       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1779 @end smallexample
1781 @cindex designator lists
1782 You can also write a series of @samp{.@var{fieldname}} and
1783 @samp{[@var{index}]} designators before an @samp{=} to specify a
1784 nested subobject to initialize; the list is taken relative to the
1785 subobject corresponding to the closest surrounding brace pair.  For
1786 example, with the @samp{struct point} declaration above:
1788 @smallexample
1789 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1790 @end smallexample
1792 @noindent
1793 If the same field is initialized multiple times, it will have value from
1794 the last initialization.  If any such overridden initialization has
1795 side-effect, it is unspecified whether the side-effect happens or not.
1796 Currently, GCC will discard them and issue a warning.
1798 @node Case Ranges
1799 @section Case Ranges
1800 @cindex case ranges
1801 @cindex ranges in case statements
1803 You can specify a range of consecutive values in a single @code{case} label,
1804 like this:
1806 @smallexample
1807 case @var{low} ... @var{high}:
1808 @end smallexample
1810 @noindent
1811 This has the same effect as the proper number of individual @code{case}
1812 labels, one for each integer value from @var{low} to @var{high}, inclusive.
1814 This feature is especially useful for ranges of ASCII character codes:
1816 @smallexample
1817 case 'A' ... 'Z':
1818 @end smallexample
1820 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
1821 it may be parsed wrong when you use it with integer values.  For example,
1822 write this:
1824 @smallexample
1825 case 1 ... 5:
1826 @end smallexample
1828 @noindent
1829 rather than this:
1831 @smallexample
1832 case 1...5:
1833 @end smallexample
1835 @node Cast to Union
1836 @section Cast to a Union Type
1837 @cindex cast to a union
1838 @cindex union, casting to a
1840 A cast to union type is similar to other casts, except that the type
1841 specified is a union type.  You can specify the type either with
1842 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
1843 a constructor though, not a cast, and hence does not yield an lvalue like
1844 normal casts.  (@xref{Compound Literals}.)
1846 The types that may be cast to the union type are those of the members
1847 of the union.  Thus, given the following union and variables:
1849 @smallexample
1850 union foo @{ int i; double d; @};
1851 int x;
1852 double y;
1853 @end smallexample
1855 @noindent
1856 both @code{x} and @code{y} can be cast to type @code{union foo}.
1858 Using the cast as the right-hand side of an assignment to a variable of
1859 union type is equivalent to storing in a member of the union:
1861 @smallexample
1862 union foo u;
1863 /* @r{@dots{}} */
1864 u = (union foo) x  @equiv{}  u.i = x
1865 u = (union foo) y  @equiv{}  u.d = y
1866 @end smallexample
1868 You can also use the union cast as a function argument:
1870 @smallexample
1871 void hack (union foo);
1872 /* @r{@dots{}} */
1873 hack ((union foo) x);
1874 @end smallexample
1876 @node Mixed Declarations
1877 @section Mixed Declarations and Code
1878 @cindex mixed declarations and code
1879 @cindex declarations, mixed with code
1880 @cindex code, mixed with declarations
1882 ISO C99 and ISO C++ allow declarations and code to be freely mixed
1883 within compound statements.  As an extension, GCC also allows this in
1884 C90 mode.  For example, you could do:
1886 @smallexample
1887 int i;
1888 /* @r{@dots{}} */
1889 i++;
1890 int j = i + 2;
1891 @end smallexample
1893 Each identifier is visible from where it is declared until the end of
1894 the enclosing block.
1896 @node Function Attributes
1897 @section Declaring Attributes of Functions
1898 @cindex function attributes
1899 @cindex declaring attributes of functions
1900 @cindex functions that never return
1901 @cindex functions that return more than once
1902 @cindex functions that have no side effects
1903 @cindex functions in arbitrary sections
1904 @cindex functions that behave like malloc
1905 @cindex @code{volatile} applied to function
1906 @cindex @code{const} applied to function
1907 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
1908 @cindex functions with non-null pointer arguments
1909 @cindex functions that are passed arguments in registers on the 386
1910 @cindex functions that pop the argument stack on the 386
1911 @cindex functions that do not pop the argument stack on the 386
1912 @cindex functions that have different compilation options on the 386
1913 @cindex functions that have different optimization options
1915 In GNU C, you declare certain things about functions called in your program
1916 which help the compiler optimize function calls and check your code more
1917 carefully.
1919 The keyword @code{__attribute__} allows you to specify special
1920 attributes when making a declaration.  This keyword is followed by an
1921 attribute specification inside double parentheses.  The following
1922 attributes are currently defined for functions on all targets:
1923 @code{aligned}, @code{alloc_size}, @code{noreturn},
1924 @code{returns_twice}, @code{noinline}, @code{noclone},
1925 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
1926 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
1927 @code{no_instrument_function}, @code{section}, @code{constructor},
1928 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
1929 @code{weak}, @code{malloc}, @code{alias}, @code{warn_unused_result},
1930 @code{nonnull}, @code{gnu_inline}, @code{externally_visible},
1931 @code{hot}, @code{cold}, @code{artificial}, @code{error} and
1932 @code{warning}.  Several other attributes are defined for functions on
1933 particular target systems.  Other attributes, including @code{section}
1934 are supported for variables declarations (@pxref{Variable Attributes})
1935 and for types (@pxref{Type Attributes}).
1937 GCC plugins may provide their own attributes.
1939 You may also specify attributes with @samp{__} preceding and following
1940 each keyword.  This allows you to use them in header files without
1941 being concerned about a possible macro of the same name.  For example,
1942 you may use @code{__noreturn__} instead of @code{noreturn}.
1944 @xref{Attribute Syntax}, for details of the exact syntax for using
1945 attributes.
1947 @table @code
1948 @c Keep this table alphabetized by attribute name.  Treat _ as space.
1950 @item alias ("@var{target}")
1951 @cindex @code{alias} attribute
1952 The @code{alias} attribute causes the declaration to be emitted as an
1953 alias for another symbol, which must be specified.  For instance,
1955 @smallexample
1956 void __f () @{ /* @r{Do something.} */; @}
1957 void f () __attribute__ ((weak, alias ("__f")));
1958 @end smallexample
1960 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
1961 mangled name for the target must be used.  It is an error if @samp{__f}
1962 is not defined in the same translation unit.
1964 Not all target machines support this attribute.
1966 @item aligned (@var{alignment})
1967 @cindex @code{aligned} attribute
1968 This attribute specifies a minimum alignment for the function,
1969 measured in bytes.
1971 You cannot use this attribute to decrease the alignment of a function,
1972 only to increase it.  However, when you explicitly specify a function
1973 alignment this will override the effect of the
1974 @option{-falign-functions} (@pxref{Optimize Options}) option for this
1975 function.
1977 Note that the effectiveness of @code{aligned} attributes may be
1978 limited by inherent limitations in your linker.  On many systems, the
1979 linker is only able to arrange for functions to be aligned up to a
1980 certain maximum alignment.  (For some linkers, the maximum supported
1981 alignment may be very very small.)  See your linker documentation for
1982 further information.
1984 The @code{aligned} attribute can also be used for variables and fields
1985 (@pxref{Variable Attributes}.)
1987 @item alloc_size
1988 @cindex @code{alloc_size} attribute
1989 The @code{alloc_size} attribute is used to tell the compiler that the
1990 function return value points to memory, where the size is given by
1991 one or two of the functions parameters.  GCC uses this 
1992 information to improve the correctness of @code{__builtin_object_size}.
1994 The function parameter(s) denoting the allocated size are specified by
1995 one or two integer arguments supplied to the attribute.  The allocated size
1996 is either the value of the single function argument specified or the product
1997 of the two function arguments specified.  Argument numbering starts at
1998 one.
2000 For instance, 
2002 @smallexample
2003 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2004 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2005 @end smallexample
2007 declares that my_calloc will return memory of the size given by
2008 the product of parameter 1 and 2 and that my_realloc will return memory
2009 of the size given by parameter 2.
2011 @item always_inline
2012 @cindex @code{always_inline} function attribute
2013 Generally, functions are not inlined unless optimization is specified.
2014 For functions declared inline, this attribute inlines the function even
2015 if no optimization level was specified.
2017 @item gnu_inline
2018 @cindex @code{gnu_inline} function attribute
2019 This attribute should be used with a function which is also declared
2020 with the @code{inline} keyword.  It directs GCC to treat the function
2021 as if it were defined in gnu90 mode even when compiling in C99 or
2022 gnu99 mode.
2024 If the function is declared @code{extern}, then this definition of the
2025 function is used only for inlining.  In no case is the function
2026 compiled as a standalone function, not even if you take its address
2027 explicitly.  Such an address becomes an external reference, as if you
2028 had only declared the function, and had not defined it.  This has
2029 almost the effect of a macro.  The way to use this is to put a
2030 function definition in a header file with this attribute, and put
2031 another copy of the function, without @code{extern}, in a library
2032 file.  The definition in the header file will cause most calls to the
2033 function to be inlined.  If any uses of the function remain, they will
2034 refer to the single copy in the library.  Note that the two
2035 definitions of the functions need not be precisely the same, although
2036 if they do not have the same effect your program may behave oddly.
2038 In C, if the function is neither @code{extern} nor @code{static}, then
2039 the function is compiled as a standalone function, as well as being
2040 inlined where possible.
2042 This is how GCC traditionally handled functions declared
2043 @code{inline}.  Since ISO C99 specifies a different semantics for
2044 @code{inline}, this function attribute is provided as a transition
2045 measure and as a useful feature in its own right.  This attribute is
2046 available in GCC 4.1.3 and later.  It is available if either of the
2047 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2048 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2049 Function is As Fast As a Macro}.
2051 In C++, this attribute does not depend on @code{extern} in any way,
2052 but it still requires the @code{inline} keyword to enable its special
2053 behavior.
2055 @item artificial
2056 @cindex @code{artificial} function attribute
2057 This attribute is useful for small inline wrappers which if possible
2058 should appear during debugging as a unit, depending on the debug
2059 info format it will either mean marking the function as artificial
2060 or using the caller location for all instructions within the inlined
2061 body.
2063 @item bank_switch
2064 @cindex interrupt handler functions
2065 When added to an interrupt handler with the M32C port, causes the
2066 prologue and epilogue to use bank switching to preserve the registers
2067 rather than saving them on the stack.
2069 @item flatten
2070 @cindex @code{flatten} function attribute
2071 Generally, inlining into a function is limited.  For a function marked with
2072 this attribute, every call inside this function will be inlined, if possible.
2073 Whether the function itself is considered for inlining depends on its size and
2074 the current inlining parameters.
2076 @item error ("@var{message}")
2077 @cindex @code{error} function attribute
2078 If this attribute is used on a function declaration and a call to such a function
2079 is not eliminated through dead code elimination or other optimizations, an error
2080 which will include @var{message} will be diagnosed.  This is useful
2081 for compile time checking, especially together with @code{__builtin_constant_p}
2082 and inline functions where checking the inline function arguments is not
2083 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2084 While it is possible to leave the function undefined and thus invoke
2085 a link failure, when using this attribute the problem will be diagnosed
2086 earlier and with exact location of the call even in presence of inline
2087 functions or when not emitting debugging information.
2089 @item warning ("@var{message}")
2090 @cindex @code{warning} function attribute
2091 If this attribute is used on a function declaration and a call to such a function
2092 is not eliminated through dead code elimination or other optimizations, a warning
2093 which will include @var{message} will be diagnosed.  This is useful
2094 for compile time checking, especially together with @code{__builtin_constant_p}
2095 and inline functions.  While it is possible to define the function with
2096 a message in @code{.gnu.warning*} section, when using this attribute the problem
2097 will be diagnosed earlier and with exact location of the call even in presence
2098 of inline functions or when not emitting debugging information.
2100 @item cdecl
2101 @cindex functions that do pop the argument stack on the 386
2102 @opindex mrtd
2103 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2104 assume that the calling function will pop off the stack space used to
2105 pass arguments.  This is
2106 useful to override the effects of the @option{-mrtd} switch.
2108 @item const
2109 @cindex @code{const} function attribute
2110 Many functions do not examine any values except their arguments, and
2111 have no effects except the return value.  Basically this is just slightly
2112 more strict class than the @code{pure} attribute below, since function is not
2113 allowed to read global memory.
2115 @cindex pointer arguments
2116 Note that a function that has pointer arguments and examines the data
2117 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2118 function that calls a non-@code{const} function usually must not be
2119 @code{const}.  It does not make sense for a @code{const} function to
2120 return @code{void}.
2122 The attribute @code{const} is not implemented in GCC versions earlier
2123 than 2.5.  An alternative way to declare that a function has no side
2124 effects, which works in the current version and in some older versions,
2125 is as follows:
2127 @smallexample
2128 typedef int intfn ();
2130 extern const intfn square;
2131 @end smallexample
2133 This approach does not work in GNU C++ from 2.6.0 on, since the language
2134 specifies that the @samp{const} must be attached to the return value.
2136 @item constructor
2137 @itemx destructor
2138 @itemx constructor (@var{priority})
2139 @itemx destructor (@var{priority})
2140 @cindex @code{constructor} function attribute
2141 @cindex @code{destructor} function attribute
2142 The @code{constructor} attribute causes the function to be called
2143 automatically before execution enters @code{main ()}.  Similarly, the
2144 @code{destructor} attribute causes the function to be called
2145 automatically after @code{main ()} has completed or @code{exit ()} has
2146 been called.  Functions with these attributes are useful for
2147 initializing data that will be used implicitly during the execution of
2148 the program.
2150 You may provide an optional integer priority to control the order in
2151 which constructor and destructor functions are run.  A constructor
2152 with a smaller priority number runs before a constructor with a larger
2153 priority number; the opposite relationship holds for destructors.  So,
2154 if you have a constructor that allocates a resource and a destructor
2155 that deallocates the same resource, both functions typically have the
2156 same priority.  The priorities for constructor and destructor
2157 functions are the same as those specified for namespace-scope C++
2158 objects (@pxref{C++ Attributes}).
2160 These attributes are not currently implemented for Objective-C@.
2162 @item deprecated
2163 @itemx deprecated (@var{msg})
2164 @cindex @code{deprecated} attribute.
2165 The @code{deprecated} attribute results in a warning if the function
2166 is used anywhere in the source file.  This is useful when identifying
2167 functions that are expected to be removed in a future version of a
2168 program.  The warning also includes the location of the declaration
2169 of the deprecated function, to enable users to easily find further
2170 information about why the function is deprecated, or what they should
2171 do instead.  Note that the warnings only occurs for uses:
2173 @smallexample
2174 int old_fn () __attribute__ ((deprecated));
2175 int old_fn ();
2176 int (*fn_ptr)() = old_fn;
2177 @end smallexample
2179 results in a warning on line 3 but not line 2.  The optional msg
2180 argument, which must be a string, will be printed in the warning if
2181 present.
2183 The @code{deprecated} attribute can also be used for variables and
2184 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2186 @item disinterrupt
2187 @cindex @code{disinterrupt} attribute
2188 On MeP targets, this attribute causes the compiler to emit
2189 instructions to disable interrupts for the duration of the given
2190 function.
2192 @item dllexport
2193 @cindex @code{__declspec(dllexport)}
2194 On Microsoft Windows targets and Symbian OS targets the
2195 @code{dllexport} attribute causes the compiler to provide a global
2196 pointer to a pointer in a DLL, so that it can be referenced with the
2197 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2198 name is formed by combining @code{_imp__} and the function or variable
2199 name.
2201 You can use @code{__declspec(dllexport)} as a synonym for
2202 @code{__attribute__ ((dllexport))} for compatibility with other
2203 compilers.
2205 On systems that support the @code{visibility} attribute, this
2206 attribute also implies ``default'' visibility.  It is an error to
2207 explicitly specify any other visibility.
2209 Currently, the @code{dllexport} attribute is ignored for inlined
2210 functions, unless the @option{-fkeep-inline-functions} flag has been
2211 used.  The attribute is also ignored for undefined symbols.
2213 When applied to C++ classes, the attribute marks defined non-inlined
2214 member functions and static data members as exports.  Static consts
2215 initialized in-class are not marked unless they are also defined
2216 out-of-class.
2218 For Microsoft Windows targets there are alternative methods for
2219 including the symbol in the DLL's export table such as using a
2220 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2221 the @option{--export-all} linker flag.
2223 @item dllimport
2224 @cindex @code{__declspec(dllimport)}
2225 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2226 attribute causes the compiler to reference a function or variable via
2227 a global pointer to a pointer that is set up by the DLL exporting the
2228 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2229 targets, the pointer name is formed by combining @code{_imp__} and the
2230 function or variable name.
2232 You can use @code{__declspec(dllimport)} as a synonym for
2233 @code{__attribute__ ((dllimport))} for compatibility with other
2234 compilers.
2236 On systems that support the @code{visibility} attribute, this
2237 attribute also implies ``default'' visibility.  It is an error to
2238 explicitly specify any other visibility.
2240 Currently, the attribute is ignored for inlined functions.  If the
2241 attribute is applied to a symbol @emph{definition}, an error is reported.
2242 If a symbol previously declared @code{dllimport} is later defined, the
2243 attribute is ignored in subsequent references, and a warning is emitted.
2244 The attribute is also overridden by a subsequent declaration as
2245 @code{dllexport}.
2247 When applied to C++ classes, the attribute marks non-inlined
2248 member functions and static data members as imports.  However, the
2249 attribute is ignored for virtual methods to allow creation of vtables
2250 using thunks.
2252 On the SH Symbian OS target the @code{dllimport} attribute also has
2253 another affect---it can cause the vtable and run-time type information
2254 for a class to be exported.  This happens when the class has a
2255 dllimport'ed constructor or a non-inline, non-pure virtual function
2256 and, for either of those two conditions, the class also has an inline
2257 constructor or destructor and has a key function that is defined in
2258 the current translation unit.
2260 For Microsoft Windows based targets the use of the @code{dllimport}
2261 attribute on functions is not necessary, but provides a small
2262 performance benefit by eliminating a thunk in the DLL@.  The use of the
2263 @code{dllimport} attribute on imported variables was required on older
2264 versions of the GNU linker, but can now be avoided by passing the
2265 @option{--enable-auto-import} switch to the GNU linker.  As with
2266 functions, using the attribute for a variable eliminates a thunk in
2267 the DLL@.
2269 One drawback to using this attribute is that a pointer to a
2270 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2271 address. However, a pointer to a @emph{function} with the
2272 @code{dllimport} attribute can be used as a constant initializer; in
2273 this case, the address of a stub function in the import lib is
2274 referenced.  On Microsoft Windows targets, the attribute can be disabled
2275 for functions by setting the @option{-mnop-fun-dllimport} flag.
2277 @item eightbit_data
2278 @cindex eight bit data on the H8/300, H8/300H, and H8S
2279 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2280 variable should be placed into the eight bit data section.
2281 The compiler will generate more efficient code for certain operations
2282 on data in the eight bit data area.  Note the eight bit data area is limited to
2283 256 bytes of data.
2285 You must use GAS and GLD from GNU binutils version 2.7 or later for
2286 this attribute to work correctly.
2288 @item exception_handler
2289 @cindex exception handler functions on the Blackfin processor
2290 Use this attribute on the Blackfin to indicate that the specified function
2291 is an exception handler.  The compiler will generate function entry and
2292 exit sequences suitable for use in an exception handler when this
2293 attribute is present.
2295 @item externally_visible
2296 @cindex @code{externally_visible} attribute.
2297 This attribute, attached to a global variable or function, nullifies
2298 the effect of the @option{-fwhole-program} command-line option, so the
2299 object remains visible outside the current compilation unit. If @option{-fwhole-program} is used together with @option{-flto} and @command{gold} is used as the linker plugin, @code{externally_visible} attributes are automatically added to functions (not variable yet due to a current @command{gold} issue) that are accessed outside of LTO objects according to resolution file produced by @command{gold}.  For other linkers that cannot generate resolution file, explicit @code{externally_visible} attributes are still necessary.
2301 @item far
2302 @cindex functions which handle memory bank switching
2303 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2304 use a calling convention that takes care of switching memory banks when
2305 entering and leaving a function.  This calling convention is also the
2306 default when using the @option{-mlong-calls} option.
2308 On 68HC12 the compiler will use the @code{call} and @code{rtc} instructions
2309 to call and return from a function.
2311 On 68HC11 the compiler will generate a sequence of instructions
2312 to invoke a board-specific routine to switch the memory bank and call the
2313 real function.  The board-specific routine simulates a @code{call}.
2314 At the end of a function, it will jump to a board-specific routine
2315 instead of using @code{rts}.  The board-specific return routine simulates
2316 the @code{rtc}.
2318 On MeP targets this causes the compiler to use a calling convention
2319 which assumes the called function is too far away for the built-in
2320 addressing modes.
2322 @item fast_interrupt
2323 @cindex interrupt handler functions
2324 Use this attribute on the M32C and RX ports to indicate that the specified
2325 function is a fast interrupt handler.  This is just like the
2326 @code{interrupt} attribute, except that @code{freit} is used to return
2327 instead of @code{reit}.
2329 @item fastcall
2330 @cindex functions that pop the argument stack on the 386
2331 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2332 pass the first argument (if of integral type) in the register ECX and
2333 the second argument (if of integral type) in the register EDX@.  Subsequent
2334 and other typed arguments are passed on the stack.  The called function will
2335 pop the arguments off the stack.  If the number of arguments is variable all
2336 arguments are pushed on the stack.
2338 @item thiscall
2339 @cindex functions that pop the argument stack on the 386
2340 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2341 pass the first argument (if of integral type) in the register ECX.
2342 Subsequent and other typed arguments are passed on the stack. The called
2343 function will pop the arguments off the stack.
2344 If the number of arguments is variable all arguments are pushed on the
2345 stack.
2346 The @code{thiscall} attribute is intended for C++ non-static member functions.
2347 As gcc extension this calling convention can be used for C-functions
2348 and for static member methods.
2350 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2351 @cindex @code{format} function attribute
2352 @opindex Wformat
2353 The @code{format} attribute specifies that a function takes @code{printf},
2354 @code{scanf}, @code{strftime} or @code{strfmon} style arguments which
2355 should be type-checked against a format string.  For example, the
2356 declaration:
2358 @smallexample
2359 extern int
2360 my_printf (void *my_object, const char *my_format, ...)
2361       __attribute__ ((format (printf, 2, 3)));
2362 @end smallexample
2364 @noindent
2365 causes the compiler to check the arguments in calls to @code{my_printf}
2366 for consistency with the @code{printf} style format string argument
2367 @code{my_format}.
2369 The parameter @var{archetype} determines how the format string is
2370 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2371 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2372 @code{strfmon}.  (You can also use @code{__printf__},
2373 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2374 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2375 @code{ms_strftime} are also present.
2376 @var{archtype} values such as @code{printf} refer to the formats accepted
2377 by the system's C run-time library, while @code{gnu_} values always refer
2378 to the formats accepted by the GNU C Library.  On Microsoft Windows
2379 targets, @code{ms_} values refer to the formats accepted by the
2380 @file{msvcrt.dll} library.
2381 The parameter @var{string-index}
2382 specifies which argument is the format string argument (starting
2383 from 1), while @var{first-to-check} is the number of the first
2384 argument to check against the format string.  For functions
2385 where the arguments are not available to be checked (such as
2386 @code{vprintf}), specify the third parameter as zero.  In this case the
2387 compiler only checks the format string for consistency.  For
2388 @code{strftime} formats, the third parameter is required to be zero.
2389 Since non-static C++ methods have an implicit @code{this} argument, the
2390 arguments of such methods should be counted from two, not one, when
2391 giving values for @var{string-index} and @var{first-to-check}.
2393 In the example above, the format string (@code{my_format}) is the second
2394 argument of the function @code{my_print}, and the arguments to check
2395 start with the third argument, so the correct parameters for the format
2396 attribute are 2 and 3.
2398 @opindex ffreestanding
2399 @opindex fno-builtin
2400 The @code{format} attribute allows you to identify your own functions
2401 which take format strings as arguments, so that GCC can check the
2402 calls to these functions for errors.  The compiler always (unless
2403 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2404 for the standard library functions @code{printf}, @code{fprintf},
2405 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2406 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2407 warnings are requested (using @option{-Wformat}), so there is no need to
2408 modify the header file @file{stdio.h}.  In C99 mode, the functions
2409 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2410 @code{vsscanf} are also checked.  Except in strictly conforming C
2411 standard modes, the X/Open function @code{strfmon} is also checked as
2412 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2413 @xref{C Dialect Options,,Options Controlling C Dialect}.
2415 The target may provide additional types of format checks.
2416 @xref{Target Format Checks,,Format Checks Specific to Particular
2417 Target Machines}.
2419 @item format_arg (@var{string-index})
2420 @cindex @code{format_arg} function attribute
2421 @opindex Wformat-nonliteral
2422 The @code{format_arg} attribute specifies that a function takes a format
2423 string for a @code{printf}, @code{scanf}, @code{strftime} or
2424 @code{strfmon} style function and modifies it (for example, to translate
2425 it into another language), so the result can be passed to a
2426 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2427 function (with the remaining arguments to the format function the same
2428 as they would have been for the unmodified string).  For example, the
2429 declaration:
2431 @smallexample
2432 extern char *
2433 my_dgettext (char *my_domain, const char *my_format)
2434       __attribute__ ((format_arg (2)));
2435 @end smallexample
2437 @noindent
2438 causes the compiler to check the arguments in calls to a @code{printf},
2439 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2440 format string argument is a call to the @code{my_dgettext} function, for
2441 consistency with the format string argument @code{my_format}.  If the
2442 @code{format_arg} attribute had not been specified, all the compiler
2443 could tell in such calls to format functions would be that the format
2444 string argument is not constant; this would generate a warning when
2445 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2446 without the attribute.
2448 The parameter @var{string-index} specifies which argument is the format
2449 string argument (starting from one).  Since non-static C++ methods have
2450 an implicit @code{this} argument, the arguments of such methods should
2451 be counted from two.
2453 The @code{format-arg} attribute allows you to identify your own
2454 functions which modify format strings, so that GCC can check the
2455 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2456 type function whose operands are a call to one of your own function.
2457 The compiler always treats @code{gettext}, @code{dgettext}, and
2458 @code{dcgettext} in this manner except when strict ISO C support is
2459 requested by @option{-ansi} or an appropriate @option{-std} option, or
2460 @option{-ffreestanding} or @option{-fno-builtin}
2461 is used.  @xref{C Dialect Options,,Options
2462 Controlling C Dialect}.
2464 @item function_vector
2465 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2466 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2467 function should be called through the function vector.  Calling a
2468 function through the function vector will reduce code size, however;
2469 the function vector has a limited size (maximum 128 entries on the H8/300
2470 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2472 In SH2A target, this attribute declares a function to be called using the
2473 TBR relative addressing mode.  The argument to this attribute is the entry
2474 number of the same function in a vector table containing all the TBR
2475 relative addressable functions.  For the successful jump, register TBR
2476 should contain the start address of this TBR relative vector table.
2477 In the startup routine of the user application, user needs to care of this
2478 TBR register initialization.  The TBR relative vector table can have at
2479 max 256 function entries.  The jumps to these functions will be generated
2480 using a SH2A specific, non delayed branch instruction JSR/N @@(disp8,TBR).
2481 You must use GAS and GLD from GNU binutils version 2.7 or later for
2482 this attribute to work correctly.
2484 Please refer the example of M16C target, to see the use of this
2485 attribute while declaring a function,
2487 In an application, for a function being called once, this attribute will
2488 save at least 8 bytes of code; and if other successive calls are being
2489 made to the same function, it will save 2 bytes of code per each of these
2490 calls.
2492 On M16C/M32C targets, the @code{function_vector} attribute declares a
2493 special page subroutine call function. Use of this attribute reduces
2494 the code size by 2 bytes for each call generated to the
2495 subroutine. The argument to the attribute is the vector number entry
2496 from the special page vector table which contains the 16 low-order
2497 bits of the subroutine's entry address. Each vector table has special
2498 page number (18 to 255) which are used in @code{jsrs} instruction.
2499 Jump addresses of the routines are generated by adding 0x0F0000 (in
2500 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the 2
2501 byte addresses set in the vector table. Therefore you need to ensure
2502 that all the special page vector routines should get mapped within the
2503 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2504 (for M32C).
2506 In the following example 2 bytes will be saved for each call to
2507 function @code{foo}.
2509 @smallexample
2510 void foo (void) __attribute__((function_vector(0x18)));
2511 void foo (void)
2515 void bar (void)
2517     foo();
2519 @end smallexample
2521 If functions are defined in one file and are called in another file,
2522 then be sure to write this declaration in both files.
2524 This attribute is ignored for R8C target.
2526 @item interrupt
2527 @cindex interrupt handler functions
2528 Use this attribute on the ARM, AVR, CRX, M32C, M32R/D, m68k, MeP, MIPS,
2529 RX and Xstormy16 ports to indicate that the specified function is an
2530 interrupt handler.  The compiler will generate function entry and exit
2531 sequences suitable for use in an interrupt handler when this attribute
2532 is present.
2534 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, and
2535 SH processors can be specified via the @code{interrupt_handler} attribute.
2537 Note, on the AVR, interrupts will be enabled inside the function.
2539 Note, for the ARM, you can specify the kind of interrupt to be handled by
2540 adding an optional parameter to the interrupt attribute like this:
2542 @smallexample
2543 void f () __attribute__ ((interrupt ("IRQ")));
2544 @end smallexample
2546 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
2548 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2549 may be called with a word aligned stack pointer.
2551 On MIPS targets, you can use the following attributes to modify the behavior
2552 of an interrupt handler:
2553 @table @code
2554 @item use_shadow_register_set
2555 @cindex @code{use_shadow_register_set} attribute
2556 Assume that the handler uses a shadow register set, instead of
2557 the main general-purpose registers.
2559 @item keep_interrupts_masked
2560 @cindex @code{keep_interrupts_masked} attribute
2561 Keep interrupts masked for the whole function.  Without this attribute,
2562 GCC tries to reenable interrupts for as much of the function as it can.
2564 @item use_debug_exception_return
2565 @cindex @code{use_debug_exception_return} attribute
2566 Return using the @code{deret} instruction.  Interrupt handlers that don't
2567 have this attribute return using @code{eret} instead.
2568 @end table
2570 You can use any combination of these attributes, as shown below:
2571 @smallexample
2572 void __attribute__ ((interrupt)) v0 ();
2573 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2574 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2575 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2576 void __attribute__ ((interrupt, use_shadow_register_set,
2577                      keep_interrupts_masked)) v4 ();
2578 void __attribute__ ((interrupt, use_shadow_register_set,
2579                      use_debug_exception_return)) v5 ();
2580 void __attribute__ ((interrupt, keep_interrupts_masked,
2581                      use_debug_exception_return)) v6 ();
2582 void __attribute__ ((interrupt, use_shadow_register_set,
2583                      keep_interrupts_masked,
2584                      use_debug_exception_return)) v7 ();
2585 @end smallexample
2587 @item interrupt_handler
2588 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2589 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2590 indicate that the specified function is an interrupt handler.  The compiler
2591 will generate function entry and exit sequences suitable for use in an
2592 interrupt handler when this attribute is present.
2594 @item interrupt_thread
2595 @cindex interrupt thread functions on fido
2596 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2597 that the specified function is an interrupt handler that is designed
2598 to run as a thread.  The compiler omits generate prologue/epilogue
2599 sequences and replaces the return instruction with a @code{sleep}
2600 instruction.  This attribute is available only on fido.
2602 @item isr
2603 @cindex interrupt service routines on ARM
2604 Use this attribute on ARM to write Interrupt Service Routines. This is an
2605 alias to the @code{interrupt} attribute above.
2607 @item kspisusp
2608 @cindex User stack pointer in interrupts on the Blackfin
2609 When used together with @code{interrupt_handler}, @code{exception_handler}
2610 or @code{nmi_handler}, code will be generated to load the stack pointer
2611 from the USP register in the function prologue.
2613 @item l1_text
2614 @cindex @code{l1_text} function attribute
2615 This attribute specifies a function to be placed into L1 Instruction
2616 SRAM@. The function will be put into a specific section named @code{.l1.text}.
2617 With @option{-mfdpic}, function calls with a such function as the callee
2618 or caller will use inlined PLT.
2620 @item l2
2621 @cindex @code{l2} function attribute
2622 On the Blackfin, this attribute specifies a function to be placed into L2
2623 SRAM. The function will be put into a specific section named
2624 @code{.l1.text}. With @option{-mfdpic}, callers of such functions will use
2625 an inlined PLT.
2627 @item long_call/short_call
2628 @cindex indirect calls on ARM
2629 This attribute specifies how a particular function is called on
2630 ARM@.  Both attributes override the @option{-mlong-calls} (@pxref{ARM Options})
2631 command-line switch and @code{#pragma long_calls} settings.  The
2632 @code{long_call} attribute indicates that the function might be far
2633 away from the call site and require a different (more expensive)
2634 calling sequence.   The @code{short_call} attribute always places
2635 the offset to the function from the call site into the @samp{BL}
2636 instruction directly.
2638 @item longcall/shortcall
2639 @cindex functions called via pointer on the RS/6000 and PowerPC
2640 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
2641 indicates that the function might be far away from the call site and
2642 require a different (more expensive) calling sequence.  The
2643 @code{shortcall} attribute indicates that the function is always close
2644 enough for the shorter calling sequence to be used.  These attributes
2645 override both the @option{-mlongcall} switch and, on the RS/6000 and
2646 PowerPC, the @code{#pragma longcall} setting.
2648 @xref{RS/6000 and PowerPC Options}, for more information on whether long
2649 calls are necessary.
2651 @item long_call/near/far
2652 @cindex indirect calls on MIPS
2653 These attributes specify how a particular function is called on MIPS@.
2654 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
2655 command-line switch.  The @code{long_call} and @code{far} attributes are
2656 synonyms, and cause the compiler to always call
2657 the function by first loading its address into a register, and then using
2658 the contents of that register.  The @code{near} attribute has the opposite
2659 effect; it specifies that non-PIC calls should be made using the more 
2660 efficient @code{jal} instruction.
2662 @item malloc
2663 @cindex @code{malloc} attribute
2664 The @code{malloc} attribute is used to tell the compiler that a function
2665 may be treated as if any non-@code{NULL} pointer it returns cannot
2666 alias any other pointer valid when the function returns.
2667 This will often improve optimization.
2668 Standard functions with this property include @code{malloc} and
2669 @code{calloc}.  @code{realloc}-like functions have this property as
2670 long as the old pointer is never referred to (including comparing it
2671 to the new pointer) after the function returns a non-@code{NULL}
2672 value.
2674 @item mips16/nomips16
2675 @cindex @code{mips16} attribute
2676 @cindex @code{nomips16} attribute
2678 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
2679 function attributes to locally select or turn off MIPS16 code generation.
2680 A function with the @code{mips16} attribute is emitted as MIPS16 code, 
2681 while MIPS16 code generation is disabled for functions with the 
2682 @code{nomips16} attribute.  These attributes override the 
2683 @option{-mips16} and @option{-mno-mips16} options on the command line
2684 (@pxref{MIPS Options}).  
2686 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
2687 preprocessor symbol @code{__mips16} reflects the setting on the command line,
2688 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
2689 may interact badly with some GCC extensions such as @code{__builtin_apply}
2690 (@pxref{Constructing Calls}).
2692 @item model (@var{model-name})
2693 @cindex function addressability on the M32R/D
2694 @cindex variable addressability on the IA-64
2696 On the M32R/D, use this attribute to set the addressability of an
2697 object, and of the code generated for a function.  The identifier
2698 @var{model-name} is one of @code{small}, @code{medium}, or
2699 @code{large}, representing each of the code models.
2701 Small model objects live in the lower 16MB of memory (so that their
2702 addresses can be loaded with the @code{ld24} instruction), and are
2703 callable with the @code{bl} instruction.
2705 Medium model objects may live anywhere in the 32-bit address space (the
2706 compiler will generate @code{seth/add3} instructions to load their addresses),
2707 and are callable with the @code{bl} instruction.
2709 Large model objects may live anywhere in the 32-bit address space (the
2710 compiler will generate @code{seth/add3} instructions to load their addresses),
2711 and may not be reachable with the @code{bl} instruction (the compiler will
2712 generate the much slower @code{seth/add3/jl} instruction sequence).
2714 On IA-64, use this attribute to set the addressability of an object.
2715 At present, the only supported identifier for @var{model-name} is
2716 @code{small}, indicating addressability via ``small'' (22-bit)
2717 addresses (so that their addresses can be loaded with the @code{addl}
2718 instruction).  Caveat: such addressing is by definition not position
2719 independent and hence this attribute must not be used for objects
2720 defined by shared libraries.
2722 @item ms_abi/sysv_abi
2723 @cindex @code{ms_abi} attribute
2724 @cindex @code{sysv_abi} attribute
2726 On 64-bit x86_64-*-* targets, you can use an ABI attribute to indicate
2727 which calling convention should be used for a function.  The @code{ms_abi}
2728 attribute tells the compiler to use the Microsoft ABI, while the
2729 @code{sysv_abi} attribute tells the compiler to use the ABI used on
2730 GNU/Linux and other systems.  The default is to use the Microsoft ABI
2731 when targeting Windows.  On all other systems, the default is the AMD ABI.
2733 Note, the @code{ms_abi} attribute for Windows targets currently requires
2734 the @option{-maccumulate-outgoing-args} option.
2736 @item ms_hook_prologue
2737 @cindex @code{ms_hook_prologue} attribute
2739 On 32 bit i[34567]86-*-* targets and 64 bit x86_64-*-* targets, you can use
2740 this function attribute to make gcc generate the "hot-patching" function
2741 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
2742 and newer.
2744 @item naked
2745 @cindex function without a prologue/epilogue code
2746 Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that
2747 the specified function does not need prologue/epilogue sequences generated by
2748 the compiler.  It is up to the programmer to provide these sequences. The 
2749 only statements that can be safely included in naked functions are 
2750 @code{asm} statements that do not have operands.  All other statements,
2751 including declarations of local variables, @code{if} statements, and so 
2752 forth, should be avoided.  Naked functions should be used to implement the 
2753 body of an assembly function, while allowing the compiler to construct
2754 the requisite function declaration for the assembler.
2756 @item near
2757 @cindex functions which do not handle memory bank switching on 68HC11/68HC12
2758 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
2759 use the normal calling convention based on @code{jsr} and @code{rts}.
2760 This attribute can be used to cancel the effect of the @option{-mlong-calls}
2761 option.
2763 On MeP targets this attribute causes the compiler to assume the called
2764 function is close enough to use the normal calling convention,
2765 overriding the @code{-mtf} command line option.
2767 @item nesting
2768 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
2769 Use this attribute together with @code{interrupt_handler},
2770 @code{exception_handler} or @code{nmi_handler} to indicate that the function
2771 entry code should enable nested interrupts or exceptions.
2773 @item nmi_handler
2774 @cindex NMI handler functions on the Blackfin processor
2775 Use this attribute on the Blackfin to indicate that the specified function
2776 is an NMI handler.  The compiler will generate function entry and
2777 exit sequences suitable for use in an NMI handler when this
2778 attribute is present.
2780 @item no_instrument_function
2781 @cindex @code{no_instrument_function} function attribute
2782 @opindex finstrument-functions
2783 If @option{-finstrument-functions} is given, profiling function calls will
2784 be generated at entry and exit of most user-compiled functions.
2785 Functions with this attribute will not be so instrumented.
2787 @item noinline
2788 @cindex @code{noinline} function attribute
2789 This function attribute prevents a function from being considered for
2790 inlining.
2791 @c Don't enumerate the optimizations by name here; we try to be
2792 @c future-compatible with this mechanism.
2793 If the function does not have side-effects, there are optimizations
2794 other than inlining that causes function calls to be optimized away,
2795 although the function call is live.  To keep such calls from being
2796 optimized away, put
2797 @smallexample
2798 asm ("");
2799 @end smallexample
2800 (@pxref{Extended Asm}) in the called function, to serve as a special
2801 side-effect.
2803 @item noclone
2804 @cindex @code{noclone} function attribute
2805 This function attribute prevents a function from being considered for
2806 cloning - a mechanism which produces specialized copies of functions
2807 and which is (currently) performed by interprocedural constant
2808 propagation.
2810 @item nonnull (@var{arg-index}, @dots{})
2811 @cindex @code{nonnull} function attribute
2812 The @code{nonnull} attribute specifies that some function parameters should
2813 be non-null pointers.  For instance, the declaration:
2815 @smallexample
2816 extern void *
2817 my_memcpy (void *dest, const void *src, size_t len)
2818         __attribute__((nonnull (1, 2)));
2819 @end smallexample
2821 @noindent
2822 causes the compiler to check that, in calls to @code{my_memcpy},
2823 arguments @var{dest} and @var{src} are non-null.  If the compiler
2824 determines that a null pointer is passed in an argument slot marked
2825 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2826 is issued.  The compiler may also choose to make optimizations based
2827 on the knowledge that certain function arguments will not be null.
2829 If no argument index list is given to the @code{nonnull} attribute,
2830 all pointer arguments are marked as non-null.  To illustrate, the
2831 following declaration is equivalent to the previous example:
2833 @smallexample
2834 extern void *
2835 my_memcpy (void *dest, const void *src, size_t len)
2836         __attribute__((nonnull));
2837 @end smallexample
2839 @item noreturn
2840 @cindex @code{noreturn} function attribute
2841 A few standard library functions, such as @code{abort} and @code{exit},
2842 cannot return.  GCC knows this automatically.  Some programs define
2843 their own functions that never return.  You can declare them
2844 @code{noreturn} to tell the compiler this fact.  For example,
2846 @smallexample
2847 @group
2848 void fatal () __attribute__ ((noreturn));
2850 void
2851 fatal (/* @r{@dots{}} */)
2853   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2854   exit (1);
2856 @end group
2857 @end smallexample
2859 The @code{noreturn} keyword tells the compiler to assume that
2860 @code{fatal} cannot return.  It can then optimize without regard to what
2861 would happen if @code{fatal} ever did return.  This makes slightly
2862 better code.  More importantly, it helps avoid spurious warnings of
2863 uninitialized variables.
2865 The @code{noreturn} keyword does not affect the exceptional path when that
2866 applies: a @code{noreturn}-marked function may still return to the caller
2867 by throwing an exception or calling @code{longjmp}.
2869 Do not assume that registers saved by the calling function are
2870 restored before calling the @code{noreturn} function.
2872 It does not make sense for a @code{noreturn} function to have a return
2873 type other than @code{void}.
2875 The attribute @code{noreturn} is not implemented in GCC versions
2876 earlier than 2.5.  An alternative way to declare that a function does
2877 not return, which works in the current version and in some older
2878 versions, is as follows:
2880 @smallexample
2881 typedef void voidfn ();
2883 volatile voidfn fatal;
2884 @end smallexample
2886 This approach does not work in GNU C++.
2888 @item nothrow
2889 @cindex @code{nothrow} function attribute
2890 The @code{nothrow} attribute is used to inform the compiler that a
2891 function cannot throw an exception.  For example, most functions in
2892 the standard C library can be guaranteed not to throw an exception
2893 with the notable exceptions of @code{qsort} and @code{bsearch} that
2894 take function pointer arguments.  The @code{nothrow} attribute is not
2895 implemented in GCC versions earlier than 3.3.
2897 @item optimize
2898 @cindex @code{optimize} function attribute
2899 The @code{optimize} attribute is used to specify that a function is to
2900 be compiled with different optimization options than specified on the
2901 command line.  Arguments can either be numbers or strings.  Numbers
2902 are assumed to be an optimization level.  Strings that begin with
2903 @code{O} are assumed to be an optimization option, while other options
2904 are assumed to be used with a @code{-f} prefix.  You can also use the
2905 @samp{#pragma GCC optimize} pragma to set the optimization options
2906 that affect more than one function.
2907 @xref{Function Specific Option Pragmas}, for details about the
2908 @samp{#pragma GCC optimize} pragma.
2910 This can be used for instance to have frequently executed functions
2911 compiled with more aggressive optimization options that produce faster
2912 and larger code, while other functions can be called with less
2913 aggressive options.
2915 @item pcs
2916 @cindex @code{pcs} function attribute
2918 The @code{pcs} attribute can be used to control the calling convention
2919 used for a function on ARM.  The attribute takes an argument that specifies
2920 the calling convention to use.
2922 When compiling using the AAPCS ABI (or a variant of that) then valid
2923 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
2924 order to use a variant other than @code{"aapcs"} then the compiler must
2925 be permitted to use the appropriate co-processor registers (i.e., the
2926 VFP registers must be available in order to use @code{"aapcs-vfp"}).
2927 For example,
2929 @smallexample
2930 /* Argument passed in r0, and result returned in r0+r1.  */
2931 double f2d (float) __attribute__((pcs("aapcs")));
2932 @end smallexample
2934 Variadic functions always use the @code{"aapcs"} calling convention and
2935 the compiler will reject attempts to specify an alternative.
2937 @item pure
2938 @cindex @code{pure} function attribute
2939 Many functions have no effects except the return value and their
2940 return value depends only on the parameters and/or global variables.
2941 Such a function can be subject
2942 to common subexpression elimination and loop optimization just as an
2943 arithmetic operator would be.  These functions should be declared
2944 with the attribute @code{pure}.  For example,
2946 @smallexample
2947 int square (int) __attribute__ ((pure));
2948 @end smallexample
2950 @noindent
2951 says that the hypothetical function @code{square} is safe to call
2952 fewer times than the program says.
2954 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
2955 Interesting non-pure functions are functions with infinite loops or those
2956 depending on volatile memory or other system resource, that may change between
2957 two consecutive calls (such as @code{feof} in a multithreading environment).
2959 The attribute @code{pure} is not implemented in GCC versions earlier
2960 than 2.96.
2962 @item hot
2963 @cindex @code{hot} function attribute
2964 The @code{hot} attribute is used to inform the compiler that a function is a
2965 hot spot of the compiled program.  The function is optimized more aggressively
2966 and on many target it is placed into special subsection of the text section so
2967 all hot functions appears close together improving locality.
2969 When profile feedback is available, via @option{-fprofile-use}, hot functions
2970 are automatically detected and this attribute is ignored.
2972 The @code{hot} attribute is not implemented in GCC versions earlier
2973 than 4.3.
2975 @item cold
2976 @cindex @code{cold} function attribute
2977 The @code{cold} attribute is used to inform the compiler that a function is
2978 unlikely executed.  The function is optimized for size rather than speed and on
2979 many targets it is placed into special subsection of the text section so all
2980 cold functions appears close together improving code locality of non-cold parts
2981 of program.  The paths leading to call of cold functions within code are marked
2982 as unlikely by the branch prediction mechanism. It is thus useful to mark
2983 functions used to handle unlikely conditions, such as @code{perror}, as cold to
2984 improve optimization of hot functions that do call marked functions in rare
2985 occasions.
2987 When profile feedback is available, via @option{-fprofile-use}, hot functions
2988 are automatically detected and this attribute is ignored.
2990 The @code{cold} attribute is not implemented in GCC versions earlier than 4.3.
2992 @item regparm (@var{number})
2993 @cindex @code{regparm} attribute
2994 @cindex functions that are passed arguments in registers on the 386
2995 On the Intel 386, the @code{regparm} attribute causes the compiler to
2996 pass arguments number one to @var{number} if they are of integral type
2997 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
2998 take a variable number of arguments will continue to be passed all of their
2999 arguments on the stack.
3001 Beware that on some ELF systems this attribute is unsuitable for
3002 global functions in shared libraries with lazy binding (which is the
3003 default).  Lazy binding will send the first call via resolving code in
3004 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3005 per the standard calling conventions.  Solaris 8 is affected by this.
3006 GNU systems with GLIBC 2.1 or higher, and FreeBSD, are believed to be
3007 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3008 disabled with the linker or the loader if desired, to avoid the
3009 problem.)
3011 @item sseregparm
3012 @cindex @code{sseregparm} attribute
3013 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3014 causes the compiler to pass up to 3 floating point arguments in
3015 SSE registers instead of on the stack.  Functions that take a
3016 variable number of arguments will continue to pass all of their
3017 floating point arguments on the stack.
3019 @item force_align_arg_pointer
3020 @cindex @code{force_align_arg_pointer} attribute
3021 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3022 applied to individual function definitions, generating an alternate
3023 prologue and epilogue that realigns the runtime stack if necessary.
3024 This supports mixing legacy codes that run with a 4-byte aligned stack
3025 with modern codes that keep a 16-byte stack for SSE compatibility.
3027 @item resbank
3028 @cindex @code{resbank} attribute
3029 On the SH2A target, this attribute enables the high-speed register
3030 saving and restoration using a register bank for @code{interrupt_handler}
3031 routines.  Saving to the bank is performed automatically after the CPU
3032 accepts an interrupt that uses a register bank.
3034 The nineteen 32-bit registers comprising general register R0 to R14,
3035 control register GBR, and system registers MACH, MACL, and PR and the
3036 vector table address offset are saved into a register bank.  Register
3037 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3038 from the bank is executed by issuing a RESBANK instruction.
3040 @item returns_twice
3041 @cindex @code{returns_twice} attribute
3042 The @code{returns_twice} attribute tells the compiler that a function may
3043 return more than one time.  The compiler will ensure that all registers
3044 are dead before calling such a function and will emit a warning about
3045 the variables that may be clobbered after the second return from the
3046 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3047 The @code{longjmp}-like counterpart of such function, if any, might need
3048 to be marked with the @code{noreturn} attribute.
3050 @item saveall
3051 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3052 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3053 all registers except the stack pointer should be saved in the prologue
3054 regardless of whether they are used or not.
3056 @item section ("@var{section-name}")
3057 @cindex @code{section} function attribute
3058 Normally, the compiler places the code it generates in the @code{text} section.
3059 Sometimes, however, you need additional sections, or you need certain
3060 particular functions to appear in special sections.  The @code{section}
3061 attribute specifies that a function lives in a particular section.
3062 For example, the declaration:
3064 @smallexample
3065 extern void foobar (void) __attribute__ ((section ("bar")));
3066 @end smallexample
3068 @noindent
3069 puts the function @code{foobar} in the @code{bar} section.
3071 Some file formats do not support arbitrary sections so the @code{section}
3072 attribute is not available on all platforms.
3073 If you need to map the entire contents of a module to a particular
3074 section, consider using the facilities of the linker instead.
3076 @item sentinel
3077 @cindex @code{sentinel} function attribute
3078 This function attribute ensures that a parameter in a function call is
3079 an explicit @code{NULL}.  The attribute is only valid on variadic
3080 functions.  By default, the sentinel is located at position zero, the
3081 last parameter of the function call.  If an optional integer position
3082 argument P is supplied to the attribute, the sentinel must be located at
3083 position P counting backwards from the end of the argument list.
3085 @smallexample
3086 __attribute__ ((sentinel))
3087 is equivalent to
3088 __attribute__ ((sentinel(0)))
3089 @end smallexample
3091 The attribute is automatically set with a position of 0 for the built-in
3092 functions @code{execl} and @code{execlp}.  The built-in function
3093 @code{execle} has the attribute set with a position of 1.
3095 A valid @code{NULL} in this context is defined as zero with any pointer
3096 type.  If your system defines the @code{NULL} macro with an integer type
3097 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3098 with a copy that redefines NULL appropriately.
3100 The warnings for missing or incorrect sentinels are enabled with
3101 @option{-Wformat}.
3103 @item short_call
3104 See long_call/short_call.
3106 @item shortcall
3107 See longcall/shortcall.
3109 @item signal
3110 @cindex signal handler functions on the AVR processors
3111 Use this attribute on the AVR to indicate that the specified
3112 function is a signal handler.  The compiler will generate function
3113 entry and exit sequences suitable for use in a signal handler when this
3114 attribute is present.  Interrupts will be disabled inside the function.
3116 @item sp_switch
3117 Use this attribute on the SH to indicate an @code{interrupt_handler}
3118 function should switch to an alternate stack.  It expects a string
3119 argument that names a global variable holding the address of the
3120 alternate stack.
3122 @smallexample
3123 void *alt_stack;
3124 void f () __attribute__ ((interrupt_handler,
3125                           sp_switch ("alt_stack")));
3126 @end smallexample
3128 @item stdcall
3129 @cindex functions that pop the argument stack on the 386
3130 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3131 assume that the called function will pop off the stack space used to
3132 pass arguments, unless it takes a variable number of arguments.
3134 @item syscall_linkage
3135 @cindex @code{syscall_linkage} attribute
3136 This attribute is used to modify the IA64 calling convention by marking
3137 all input registers as live at all function exits.  This makes it possible
3138 to restart a system call after an interrupt without having to save/restore
3139 the input registers.  This also prevents kernel data from leaking into
3140 application code.
3142 @item target
3143 @cindex @code{target} function attribute
3144 The @code{target} attribute is used to specify that a function is to
3145 be compiled with different target options than specified on the
3146 command line.  This can be used for instance to have functions
3147 compiled with a different ISA (instruction set architecture) than the
3148 default.  You can also use the @samp{#pragma GCC target} pragma to set
3149 more than one function to be compiled with specific target options.
3150 @xref{Function Specific Option Pragmas}, for details about the
3151 @samp{#pragma GCC target} pragma.
3153 For instance on a 386, you could compile one function with
3154 @code{target("sse4.1,arch=core2")} and another with
3155 @code{target("sse4a,arch=amdfam10")} that would be equivalent to
3156 compiling the first function with @option{-msse4.1} and
3157 @option{-march=core2} options, and the second function with
3158 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3159 user to make sure that a function is only invoked on a machine that
3160 supports the particular ISA it was compiled for (for example by using
3161 @code{cpuid} on 386 to determine what feature bits and architecture
3162 family are used).
3164 @smallexample
3165 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3166 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3167 @end smallexample
3169 On the 386, the following options are allowed:
3171 @table @samp
3172 @item abm
3173 @itemx no-abm
3174 @cindex @code{target("abm")} attribute
3175 Enable/disable the generation of the advanced bit instructions.
3177 @item aes
3178 @itemx no-aes
3179 @cindex @code{target("aes")} attribute
3180 Enable/disable the generation of the AES instructions.
3182 @item mmx
3183 @itemx no-mmx
3184 @cindex @code{target("mmx")} attribute
3185 Enable/disable the generation of the MMX instructions.
3187 @item pclmul
3188 @itemx no-pclmul
3189 @cindex @code{target("pclmul")} attribute
3190 Enable/disable the generation of the PCLMUL instructions.
3192 @item popcnt
3193 @itemx no-popcnt
3194 @cindex @code{target("popcnt")} attribute
3195 Enable/disable the generation of the POPCNT instruction.
3197 @item sse
3198 @itemx no-sse
3199 @cindex @code{target("sse")} attribute
3200 Enable/disable the generation of the SSE instructions.
3202 @item sse2
3203 @itemx no-sse2
3204 @cindex @code{target("sse2")} attribute
3205 Enable/disable the generation of the SSE2 instructions.
3207 @item sse3
3208 @itemx no-sse3
3209 @cindex @code{target("sse3")} attribute
3210 Enable/disable the generation of the SSE3 instructions.
3212 @item sse4
3213 @itemx no-sse4
3214 @cindex @code{target("sse4")} attribute
3215 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3216 and SSE4.2).
3218 @item sse4.1
3219 @itemx no-sse4.1
3220 @cindex @code{target("sse4.1")} attribute
3221 Enable/disable the generation of the sse4.1 instructions.
3223 @item sse4.2
3224 @itemx no-sse4.2
3225 @cindex @code{target("sse4.2")} attribute
3226 Enable/disable the generation of the sse4.2 instructions.
3228 @item sse4a
3229 @itemx no-sse4a
3230 @cindex @code{target("sse4a")} attribute
3231 Enable/disable the generation of the SSE4A instructions.
3233 @item fma4
3234 @itemx no-fma4
3235 @cindex @code{target("fma4")} attribute
3236 Enable/disable the generation of the FMA4 instructions.
3238 @item xop
3239 @itemx no-xop
3240 @cindex @code{target("xop")} attribute
3241 Enable/disable the generation of the XOP instructions.
3243 @item lwp
3244 @itemx no-lwp
3245 @cindex @code{target("lwp")} attribute
3246 Enable/disable the generation of the LWP instructions.
3248 @item ssse3
3249 @itemx no-ssse3
3250 @cindex @code{target("ssse3")} attribute
3251 Enable/disable the generation of the SSSE3 instructions.
3253 @item cld
3254 @itemx no-cld
3255 @cindex @code{target("cld")} attribute
3256 Enable/disable the generation of the CLD before string moves.
3258 @item fancy-math-387
3259 @itemx no-fancy-math-387
3260 @cindex @code{target("fancy-math-387")} attribute
3261 Enable/disable the generation of the @code{sin}, @code{cos}, and
3262 @code{sqrt} instructions on the 387 floating point unit.
3264 @item fused-madd
3265 @itemx no-fused-madd
3266 @cindex @code{target("fused-madd")} attribute
3267 Enable/disable the generation of the fused multiply/add instructions.
3269 @item ieee-fp
3270 @itemx no-ieee-fp
3271 @cindex @code{target("ieee-fp")} attribute
3272 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3274 @item inline-all-stringops
3275 @itemx no-inline-all-stringops
3276 @cindex @code{target("inline-all-stringops")} attribute
3277 Enable/disable inlining of string operations.
3279 @item inline-stringops-dynamically
3280 @itemx no-inline-stringops-dynamically
3281 @cindex @code{target("inline-stringops-dynamically")} attribute
3282 Enable/disable the generation of the inline code to do small string
3283 operations and calling the library routines for large operations.
3285 @item align-stringops
3286 @itemx no-align-stringops
3287 @cindex @code{target("align-stringops")} attribute
3288 Do/do not align destination of inlined string operations.
3290 @item recip
3291 @itemx no-recip
3292 @cindex @code{target("recip")} attribute
3293 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3294 instructions followed an additional Newton-Raphson step instead of
3295 doing a floating point division.
3297 @item arch=@var{ARCH}
3298 @cindex @code{target("arch=@var{ARCH}")} attribute
3299 Specify the architecture to generate code for in compiling the function.
3301 @item tune=@var{TUNE}
3302 @cindex @code{target("tune=@var{TUNE}")} attribute
3303 Specify the architecture to tune for in compiling the function.
3305 @item fpmath=@var{FPMATH}
3306 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3307 Specify which floating point unit to use.  The
3308 @code{target("fpmath=sse,387")} option must be specified as
3309 @code{target("fpmath=sse+387")} because the comma would separate
3310 different options.
3311 @end table
3313 On the 386, you can use either multiple strings to specify multiple
3314 options, or you can separate the option with a comma (@code{,}).
3316 On the 386, the inliner will not inline a function that has different
3317 target options than the caller, unless the callee has a subset of the
3318 target options of the caller.  For example a function declared with
3319 @code{target("sse3")} can inline a function with
3320 @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
3322 The @code{target} attribute is not implemented in GCC versions earlier
3323 than 4.4, and at present only the 386 uses it.
3325 @item tiny_data
3326 @cindex tiny data section on the H8/300H and H8S
3327 Use this attribute on the H8/300H and H8S to indicate that the specified
3328 variable should be placed into the tiny data section.
3329 The compiler will generate more efficient code for loads and stores
3330 on data in the tiny data section.  Note the tiny data area is limited to
3331 slightly under 32kbytes of data.
3333 @item trap_exit
3334 Use this attribute on the SH for an @code{interrupt_handler} to return using
3335 @code{trapa} instead of @code{rte}.  This attribute expects an integer
3336 argument specifying the trap number to be used.
3338 @item unused
3339 @cindex @code{unused} attribute.
3340 This attribute, attached to a function, means that the function is meant
3341 to be possibly unused.  GCC will not produce a warning for this
3342 function.
3344 @item used
3345 @cindex @code{used} attribute.
3346 This attribute, attached to a function, means that code must be emitted
3347 for the function even if it appears that the function is not referenced.
3348 This is useful, for example, when the function is referenced only in
3349 inline assembly.
3351 @item version_id
3352 @cindex @code{version_id} attribute
3353 This IA64 HP-UX attribute, attached to a global variable or function, renames a
3354 symbol to contain a version string, thus allowing for function level
3355 versioning.  HP-UX system header files may use version level functioning
3356 for some system calls.
3358 @smallexample
3359 extern int foo () __attribute__((version_id ("20040821")));
3360 @end smallexample
3362 Calls to @var{foo} will be mapped to calls to @var{foo@{20040821@}}.
3364 @item visibility ("@var{visibility_type}")
3365 @cindex @code{visibility} attribute
3366 This attribute affects the linkage of the declaration to which it is attached.
3367 There are four supported @var{visibility_type} values: default,
3368 hidden, protected or internal visibility.
3370 @smallexample
3371 void __attribute__ ((visibility ("protected")))
3372 f () @{ /* @r{Do something.} */; @}
3373 int i __attribute__ ((visibility ("hidden")));
3374 @end smallexample
3376 The possible values of @var{visibility_type} correspond to the
3377 visibility settings in the ELF gABI.
3379 @table @dfn
3380 @c keep this list of visibilities in alphabetical order.
3382 @item default
3383 Default visibility is the normal case for the object file format.
3384 This value is available for the visibility attribute to override other
3385 options that may change the assumed visibility of entities.
3387 On ELF, default visibility means that the declaration is visible to other
3388 modules and, in shared libraries, means that the declared entity may be
3389 overridden.
3391 On Darwin, default visibility means that the declaration is visible to
3392 other modules.
3394 Default visibility corresponds to ``external linkage'' in the language.
3396 @item hidden
3397 Hidden visibility indicates that the entity declared will have a new
3398 form of linkage, which we'll call ``hidden linkage''.  Two
3399 declarations of an object with hidden linkage refer to the same object
3400 if they are in the same shared object.
3402 @item internal
3403 Internal visibility is like hidden visibility, but with additional
3404 processor specific semantics.  Unless otherwise specified by the
3405 psABI, GCC defines internal visibility to mean that a function is
3406 @emph{never} called from another module.  Compare this with hidden
3407 functions which, while they cannot be referenced directly by other
3408 modules, can be referenced indirectly via function pointers.  By
3409 indicating that a function cannot be called from outside the module,
3410 GCC may for instance omit the load of a PIC register since it is known
3411 that the calling function loaded the correct value.
3413 @item protected
3414 Protected visibility is like default visibility except that it
3415 indicates that references within the defining module will bind to the
3416 definition in that module.  That is, the declared entity cannot be
3417 overridden by another module.
3419 @end table
3421 All visibilities are supported on many, but not all, ELF targets
3422 (supported when the assembler supports the @samp{.visibility}
3423 pseudo-op).  Default visibility is supported everywhere.  Hidden
3424 visibility is supported on Darwin targets.
3426 The visibility attribute should be applied only to declarations which
3427 would otherwise have external linkage.  The attribute should be applied
3428 consistently, so that the same entity should not be declared with
3429 different settings of the attribute.
3431 In C++, the visibility attribute applies to types as well as functions
3432 and objects, because in C++ types have linkage.  A class must not have
3433 greater visibility than its non-static data member types and bases,
3434 and class members default to the visibility of their class.  Also, a
3435 declaration without explicit visibility is limited to the visibility
3436 of its type.
3438 In C++, you can mark member functions and static member variables of a
3439 class with the visibility attribute.  This is useful if you know a
3440 particular method or static member variable should only be used from
3441 one shared object; then you can mark it hidden while the rest of the
3442 class has default visibility.  Care must be taken to avoid breaking
3443 the One Definition Rule; for example, it is usually not useful to mark
3444 an inline method as hidden without marking the whole class as hidden.
3446 A C++ namespace declaration can also have the visibility attribute.
3447 This attribute applies only to the particular namespace body, not to
3448 other definitions of the same namespace; it is equivalent to using
3449 @samp{#pragma GCC visibility} before and after the namespace
3450 definition (@pxref{Visibility Pragmas}).
3452 In C++, if a template argument has limited visibility, this
3453 restriction is implicitly propagated to the template instantiation.
3454 Otherwise, template instantiations and specializations default to the
3455 visibility of their template.
3457 If both the template and enclosing class have explicit visibility, the
3458 visibility from the template is used.
3460 @item vliw
3461 @cindex @code{vliw} attribute
3462 On MeP, the @code{vliw} attribute tells the compiler to emit
3463 instructions in VLIW mode instead of core mode.  Note that this
3464 attribute is not allowed unless a VLIW coprocessor has been configured
3465 and enabled through command line options.
3467 @item warn_unused_result
3468 @cindex @code{warn_unused_result} attribute
3469 The @code{warn_unused_result} attribute causes a warning to be emitted
3470 if a caller of the function with this attribute does not use its
3471 return value.  This is useful for functions where not checking
3472 the result is either a security problem or always a bug, such as
3473 @code{realloc}.
3475 @smallexample
3476 int fn () __attribute__ ((warn_unused_result));
3477 int foo ()
3479   if (fn () < 0) return -1;
3480   fn ();
3481   return 0;
3483 @end smallexample
3485 results in warning on line 5.
3487 @item weak
3488 @cindex @code{weak} attribute
3489 The @code{weak} attribute causes the declaration to be emitted as a weak
3490 symbol rather than a global.  This is primarily useful in defining
3491 library functions which can be overridden in user code, though it can
3492 also be used with non-function declarations.  Weak symbols are supported
3493 for ELF targets, and also for a.out targets when using the GNU assembler
3494 and linker.
3496 @item weakref
3497 @itemx weakref ("@var{target}")
3498 @cindex @code{weakref} attribute
3499 The @code{weakref} attribute marks a declaration as a weak reference.
3500 Without arguments, it should be accompanied by an @code{alias} attribute
3501 naming the target symbol.  Optionally, the @var{target} may be given as
3502 an argument to @code{weakref} itself.  In either case, @code{weakref}
3503 implicitly marks the declaration as @code{weak}.  Without a
3504 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3505 @code{weakref} is equivalent to @code{weak}.
3507 @smallexample
3508 static int x() __attribute__ ((weakref ("y")));
3509 /* is equivalent to... */
3510 static int x() __attribute__ ((weak, weakref, alias ("y")));
3511 /* and to... */
3512 static int x() __attribute__ ((weakref));
3513 static int x() __attribute__ ((alias ("y")));
3514 @end smallexample
3516 A weak reference is an alias that does not by itself require a
3517 definition to be given for the target symbol.  If the target symbol is
3518 only referenced through weak references, then it becomes a @code{weak}
3519 undefined symbol.  If it is directly referenced, however, then such
3520 strong references prevail, and a definition will be required for the
3521 symbol, not necessarily in the same translation unit.
3523 The effect is equivalent to moving all references to the alias to a
3524 separate translation unit, renaming the alias to the aliased symbol,
3525 declaring it as weak, compiling the two separate translation units and
3526 performing a reloadable link on them.
3528 At present, a declaration to which @code{weakref} is attached can
3529 only be @code{static}.
3531 @end table
3533 You can specify multiple attributes in a declaration by separating them
3534 by commas within the double parentheses or by immediately following an
3535 attribute declaration with another attribute declaration.
3537 @cindex @code{#pragma}, reason for not using
3538 @cindex pragma, reason for not using
3539 Some people object to the @code{__attribute__} feature, suggesting that
3540 ISO C's @code{#pragma} should be used instead.  At the time
3541 @code{__attribute__} was designed, there were two reasons for not doing
3542 this.
3544 @enumerate
3545 @item
3546 It is impossible to generate @code{#pragma} commands from a macro.
3548 @item
3549 There is no telling what the same @code{#pragma} might mean in another
3550 compiler.
3551 @end enumerate
3553 These two reasons applied to almost any application that might have been
3554 proposed for @code{#pragma}.  It was basically a mistake to use
3555 @code{#pragma} for @emph{anything}.
3557 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
3558 to be generated from macros.  In addition, a @code{#pragma GCC}
3559 namespace is now in use for GCC-specific pragmas.  However, it has been
3560 found convenient to use @code{__attribute__} to achieve a natural
3561 attachment of attributes to their corresponding declarations, whereas
3562 @code{#pragma GCC} is of use for constructs that do not naturally form
3563 part of the grammar.  @xref{Other Directives,,Miscellaneous
3564 Preprocessing Directives, cpp, The GNU C Preprocessor}.
3566 @node Attribute Syntax
3567 @section Attribute Syntax
3568 @cindex attribute syntax
3570 This section describes the syntax with which @code{__attribute__} may be
3571 used, and the constructs to which attribute specifiers bind, for the C
3572 language.  Some details may vary for C++ and Objective-C@.  Because of
3573 infelicities in the grammar for attributes, some forms described here
3574 may not be successfully parsed in all cases.
3576 There are some problems with the semantics of attributes in C++.  For
3577 example, there are no manglings for attributes, although they may affect
3578 code generation, so problems may arise when attributed types are used in
3579 conjunction with templates or overloading.  Similarly, @code{typeid}
3580 does not distinguish between types with different attributes.  Support
3581 for attributes in C++ may be restricted in future to attributes on
3582 declarations only, but not on nested declarators.
3584 @xref{Function Attributes}, for details of the semantics of attributes
3585 applying to functions.  @xref{Variable Attributes}, for details of the
3586 semantics of attributes applying to variables.  @xref{Type Attributes},
3587 for details of the semantics of attributes applying to structure, union
3588 and enumerated types.
3590 An @dfn{attribute specifier} is of the form
3591 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
3592 is a possibly empty comma-separated sequence of @dfn{attributes}, where
3593 each attribute is one of the following:
3595 @itemize @bullet
3596 @item
3597 Empty.  Empty attributes are ignored.
3599 @item
3600 A word (which may be an identifier such as @code{unused}, or a reserved
3601 word such as @code{const}).
3603 @item
3604 A word, followed by, in parentheses, parameters for the attribute.
3605 These parameters take one of the following forms:
3607 @itemize @bullet
3608 @item
3609 An identifier.  For example, @code{mode} attributes use this form.
3611 @item
3612 An identifier followed by a comma and a non-empty comma-separated list
3613 of expressions.  For example, @code{format} attributes use this form.
3615 @item
3616 A possibly empty comma-separated list of expressions.  For example,
3617 @code{format_arg} attributes use this form with the list being a single
3618 integer constant expression, and @code{alias} attributes use this form
3619 with the list being a single string constant.
3620 @end itemize
3621 @end itemize
3623 An @dfn{attribute specifier list} is a sequence of one or more attribute
3624 specifiers, not separated by any other tokens.
3626 In GNU C, an attribute specifier list may appear after the colon following a
3627 label, other than a @code{case} or @code{default} label.  The only
3628 attribute it makes sense to use after a label is @code{unused}.  This
3629 feature is intended for code generated by programs which contains labels
3630 that may be unused but which is compiled with @option{-Wall}.  It would
3631 not normally be appropriate to use in it human-written code, though it
3632 could be useful in cases where the code that jumps to the label is
3633 contained within an @code{#ifdef} conditional.  GNU C++ only permits
3634 attributes on labels if the attribute specifier is immediately
3635 followed by a semicolon (i.e., the label applies to an empty
3636 statement).  If the semicolon is missing, C++ label attributes are
3637 ambiguous, as it is permissible for a declaration, which could begin
3638 with an attribute list, to be labelled in C++.  Declarations cannot be
3639 labelled in C90 or C99, so the ambiguity does not arise there.
3641 An attribute specifier list may appear as part of a @code{struct},
3642 @code{union} or @code{enum} specifier.  It may go either immediately
3643 after the @code{struct}, @code{union} or @code{enum} keyword, or after
3644 the closing brace.  The former syntax is preferred.
3645 Where attribute specifiers follow the closing brace, they are considered
3646 to relate to the structure, union or enumerated type defined, not to any
3647 enclosing declaration the type specifier appears in, and the type
3648 defined is not complete until after the attribute specifiers.
3649 @c Otherwise, there would be the following problems: a shift/reduce
3650 @c conflict between attributes binding the struct/union/enum and
3651 @c binding to the list of specifiers/qualifiers; and "aligned"
3652 @c attributes could use sizeof for the structure, but the size could be
3653 @c changed later by "packed" attributes.
3655 Otherwise, an attribute specifier appears as part of a declaration,
3656 counting declarations of unnamed parameters and type names, and relates
3657 to that declaration (which may be nested in another declaration, for
3658 example in the case of a parameter declaration), or to a particular declarator
3659 within a declaration.  Where an
3660 attribute specifier is applied to a parameter declared as a function or
3661 an array, it should apply to the function or array rather than the
3662 pointer to which the parameter is implicitly converted, but this is not
3663 yet correctly implemented.
3665 Any list of specifiers and qualifiers at the start of a declaration may
3666 contain attribute specifiers, whether or not such a list may in that
3667 context contain storage class specifiers.  (Some attributes, however,
3668 are essentially in the nature of storage class specifiers, and only make
3669 sense where storage class specifiers may be used; for example,
3670 @code{section}.)  There is one necessary limitation to this syntax: the
3671 first old-style parameter declaration in a function definition cannot
3672 begin with an attribute specifier, because such an attribute applies to
3673 the function instead by syntax described below (which, however, is not
3674 yet implemented in this case).  In some other cases, attribute
3675 specifiers are permitted by this grammar but not yet supported by the
3676 compiler.  All attribute specifiers in this place relate to the
3677 declaration as a whole.  In the obsolescent usage where a type of
3678 @code{int} is implied by the absence of type specifiers, such a list of
3679 specifiers and qualifiers may be an attribute specifier list with no
3680 other specifiers or qualifiers.
3682 At present, the first parameter in a function prototype must have some
3683 type specifier which is not an attribute specifier; this resolves an
3684 ambiguity in the interpretation of @code{void f(int
3685 (__attribute__((foo)) x))}, but is subject to change.  At present, if
3686 the parentheses of a function declarator contain only attributes then
3687 those attributes are ignored, rather than yielding an error or warning
3688 or implying a single parameter of type int, but this is subject to
3689 change.
3691 An attribute specifier list may appear immediately before a declarator
3692 (other than the first) in a comma-separated list of declarators in a
3693 declaration of more than one identifier using a single list of
3694 specifiers and qualifiers.  Such attribute specifiers apply
3695 only to the identifier before whose declarator they appear.  For
3696 example, in
3698 @smallexample
3699 __attribute__((noreturn)) void d0 (void),
3700     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
3701      d2 (void)
3702 @end smallexample
3704 @noindent
3705 the @code{noreturn} attribute applies to all the functions
3706 declared; the @code{format} attribute only applies to @code{d1}.
3708 An attribute specifier list may appear immediately before the comma,
3709 @code{=} or semicolon terminating the declaration of an identifier other
3710 than a function definition.  Such attribute specifiers apply
3711 to the declared object or function.  Where an
3712 assembler name for an object or function is specified (@pxref{Asm
3713 Labels}), the attribute must follow the @code{asm}
3714 specification.
3716 An attribute specifier list may, in future, be permitted to appear after
3717 the declarator in a function definition (before any old-style parameter
3718 declarations or the function body).
3720 Attribute specifiers may be mixed with type qualifiers appearing inside
3721 the @code{[]} of a parameter array declarator, in the C99 construct by
3722 which such qualifiers are applied to the pointer to which the array is
3723 implicitly converted.  Such attribute specifiers apply to the pointer,
3724 not to the array, but at present this is not implemented and they are
3725 ignored.
3727 An attribute specifier list may appear at the start of a nested
3728 declarator.  At present, there are some limitations in this usage: the
3729 attributes correctly apply to the declarator, but for most individual
3730 attributes the semantics this implies are not implemented.
3731 When attribute specifiers follow the @code{*} of a pointer
3732 declarator, they may be mixed with any type qualifiers present.
3733 The following describes the formal semantics of this syntax.  It will make the
3734 most sense if you are familiar with the formal specification of
3735 declarators in the ISO C standard.
3737 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
3738 D1}, where @code{T} contains declaration specifiers that specify a type
3739 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
3740 contains an identifier @var{ident}.  The type specified for @var{ident}
3741 for derived declarators whose type does not include an attribute
3742 specifier is as in the ISO C standard.
3744 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
3745 and the declaration @code{T D} specifies the type
3746 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
3747 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
3748 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
3750 If @code{D1} has the form @code{*
3751 @var{type-qualifier-and-attribute-specifier-list} D}, and the
3752 declaration @code{T D} specifies the type
3753 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
3754 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
3755 @var{type-qualifier-and-attribute-specifier-list} @var{Type}'' for
3756 @var{ident}.
3758 For example,
3760 @smallexample
3761 void (__attribute__((noreturn)) ****f) (void);
3762 @end smallexample
3764 @noindent
3765 specifies the type ``pointer to pointer to pointer to pointer to
3766 non-returning function returning @code{void}''.  As another example,
3768 @smallexample
3769 char *__attribute__((aligned(8))) *f;
3770 @end smallexample
3772 @noindent
3773 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
3774 Note again that this does not work with most attributes; for example,
3775 the usage of @samp{aligned} and @samp{noreturn} attributes given above
3776 is not yet supported.
3778 For compatibility with existing code written for compiler versions that
3779 did not implement attributes on nested declarators, some laxity is
3780 allowed in the placing of attributes.  If an attribute that only applies
3781 to types is applied to a declaration, it will be treated as applying to
3782 the type of that declaration.  If an attribute that only applies to
3783 declarations is applied to the type of a declaration, it will be treated
3784 as applying to that declaration; and, for compatibility with code
3785 placing the attributes immediately before the identifier declared, such
3786 an attribute applied to a function return type will be treated as
3787 applying to the function type, and such an attribute applied to an array
3788 element type will be treated as applying to the array type.  If an
3789 attribute that only applies to function types is applied to a
3790 pointer-to-function type, it will be treated as applying to the pointer
3791 target type; if such an attribute is applied to a function return type
3792 that is not a pointer-to-function type, it will be treated as applying
3793 to the function type.
3795 @node Function Prototypes
3796 @section Prototypes and Old-Style Function Definitions
3797 @cindex function prototype declarations
3798 @cindex old-style function definitions
3799 @cindex promotion of formal parameters
3801 GNU C extends ISO C to allow a function prototype to override a later
3802 old-style non-prototype definition.  Consider the following example:
3804 @smallexample
3805 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
3806 #ifdef __STDC__
3807 #define P(x) x
3808 #else
3809 #define P(x) ()
3810 #endif
3812 /* @r{Prototype function declaration.}  */
3813 int isroot P((uid_t));
3815 /* @r{Old-style function definition.}  */
3817 isroot (x)   /* @r{??? lossage here ???} */
3818      uid_t x;
3820   return x == 0;
3822 @end smallexample
3824 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
3825 not allow this example, because subword arguments in old-style
3826 non-prototype definitions are promoted.  Therefore in this example the
3827 function definition's argument is really an @code{int}, which does not
3828 match the prototype argument type of @code{short}.
3830 This restriction of ISO C makes it hard to write code that is portable
3831 to traditional C compilers, because the programmer does not know
3832 whether the @code{uid_t} type is @code{short}, @code{int}, or
3833 @code{long}.  Therefore, in cases like these GNU C allows a prototype
3834 to override a later old-style definition.  More precisely, in GNU C, a
3835 function prototype argument type overrides the argument type specified
3836 by a later old-style definition if the former type is the same as the
3837 latter type before promotion.  Thus in GNU C the above example is
3838 equivalent to the following:
3840 @smallexample
3841 int isroot (uid_t);
3844 isroot (uid_t x)
3846   return x == 0;
3848 @end smallexample
3850 @noindent
3851 GNU C++ does not support old-style function definitions, so this
3852 extension is irrelevant.
3854 @node C++ Comments
3855 @section C++ Style Comments
3856 @cindex //
3857 @cindex C++ comments
3858 @cindex comments, C++ style
3860 In GNU C, you may use C++ style comments, which start with @samp{//} and
3861 continue until the end of the line.  Many other C implementations allow
3862 such comments, and they are included in the 1999 C standard.  However,
3863 C++ style comments are not recognized if you specify an @option{-std}
3864 option specifying a version of ISO C before C99, or @option{-ansi}
3865 (equivalent to @option{-std=c90}).
3867 @node Dollar Signs
3868 @section Dollar Signs in Identifier Names
3869 @cindex $
3870 @cindex dollar signs in identifier names
3871 @cindex identifier names, dollar signs in
3873 In GNU C, you may normally use dollar signs in identifier names.
3874 This is because many traditional C implementations allow such identifiers.
3875 However, dollar signs in identifiers are not supported on a few target
3876 machines, typically because the target assembler does not allow them.
3878 @node Character Escapes
3879 @section The Character @key{ESC} in Constants
3881 You can use the sequence @samp{\e} in a string or character constant to
3882 stand for the ASCII character @key{ESC}.
3884 @node Alignment
3885 @section Inquiring on Alignment of Types or Variables
3886 @cindex alignment
3887 @cindex type alignment
3888 @cindex variable alignment
3890 The keyword @code{__alignof__} allows you to inquire about how an object
3891 is aligned, or the minimum alignment usually required by a type.  Its
3892 syntax is just like @code{sizeof}.
3894 For example, if the target machine requires a @code{double} value to be
3895 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
3896 This is true on many RISC machines.  On more traditional machine
3897 designs, @code{__alignof__ (double)} is 4 or even 2.
3899 Some machines never actually require alignment; they allow reference to any
3900 data type even at an odd address.  For these machines, @code{__alignof__}
3901 reports the smallest alignment that GCC will give the data type, usually as
3902 mandated by the target ABI.
3904 If the operand of @code{__alignof__} is an lvalue rather than a type,
3905 its value is the required alignment for its type, taking into account
3906 any minimum alignment specified with GCC's @code{__attribute__}
3907 extension (@pxref{Variable Attributes}).  For example, after this
3908 declaration:
3910 @smallexample
3911 struct foo @{ int x; char y; @} foo1;
3912 @end smallexample
3914 @noindent
3915 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
3916 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
3918 It is an error to ask for the alignment of an incomplete type.
3920 @node Variable Attributes
3921 @section Specifying Attributes of Variables
3922 @cindex attribute of variables
3923 @cindex variable attributes
3925 The keyword @code{__attribute__} allows you to specify special
3926 attributes of variables or structure fields.  This keyword is followed
3927 by an attribute specification inside double parentheses.  Some
3928 attributes are currently defined generically for variables.
3929 Other attributes are defined for variables on particular target
3930 systems.  Other attributes are available for functions
3931 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
3932 Other front ends might define more attributes
3933 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
3935 You may also specify attributes with @samp{__} preceding and following
3936 each keyword.  This allows you to use them in header files without
3937 being concerned about a possible macro of the same name.  For example,
3938 you may use @code{__aligned__} instead of @code{aligned}.
3940 @xref{Attribute Syntax}, for details of the exact syntax for using
3941 attributes.
3943 @table @code
3944 @cindex @code{aligned} attribute
3945 @item aligned (@var{alignment})
3946 This attribute specifies a minimum alignment for the variable or
3947 structure field, measured in bytes.  For example, the declaration:
3949 @smallexample
3950 int x __attribute__ ((aligned (16))) = 0;
3951 @end smallexample
3953 @noindent
3954 causes the compiler to allocate the global variable @code{x} on a
3955 16-byte boundary.  On a 68040, this could be used in conjunction with
3956 an @code{asm} expression to access the @code{move16} instruction which
3957 requires 16-byte aligned operands.
3959 You can also specify the alignment of structure fields.  For example, to
3960 create a double-word aligned @code{int} pair, you could write:
3962 @smallexample
3963 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
3964 @end smallexample
3966 @noindent
3967 This is an alternative to creating a union with a @code{double} member
3968 that forces the union to be double-word aligned.
3970 As in the preceding examples, you can explicitly specify the alignment
3971 (in bytes) that you wish the compiler to use for a given variable or
3972 structure field.  Alternatively, you can leave out the alignment factor
3973 and just ask the compiler to align a variable or field to the
3974 default alignment for the target architecture you are compiling for.
3975 The default alignment is sufficient for all scalar types, but may not be
3976 enough for all vector types on a target which supports vector operations.
3977 The default alignment is fixed for a particular target ABI.
3979 Gcc also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
3980 which is the largest alignment ever used for any data type on the
3981 target machine you are compiling for.  For example, you could write:
3983 @smallexample
3984 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
3985 @end smallexample
3987 The compiler automatically sets the alignment for the declared
3988 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
3989 often make copy operations more efficient, because the compiler can
3990 use whatever instructions copy the biggest chunks of memory when
3991 performing copies to or from the variables or fields that you have
3992 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
3993 may change depending on command line options.
3995 When used on a struct, or struct member, the @code{aligned} attribute can
3996 only increase the alignment; in order to decrease it, the @code{packed}
3997 attribute must be specified as well.  When used as part of a typedef, the
3998 @code{aligned} attribute can both increase and decrease alignment, and
3999 specifying the @code{packed} attribute will generate a warning.
4001 Note that the effectiveness of @code{aligned} attributes may be limited
4002 by inherent limitations in your linker.  On many systems, the linker is
4003 only able to arrange for variables to be aligned up to a certain maximum
4004 alignment.  (For some linkers, the maximum supported alignment may
4005 be very very small.)  If your linker is only able to align variables
4006 up to a maximum of 8 byte alignment, then specifying @code{aligned(16)}
4007 in an @code{__attribute__} will still only provide you with 8 byte
4008 alignment.  See your linker documentation for further information.
4010 The @code{aligned} attribute can also be used for functions 
4011 (@pxref{Function Attributes}.)
4013 @item cleanup (@var{cleanup_function})
4014 @cindex @code{cleanup} attribute
4015 The @code{cleanup} attribute runs a function when the variable goes
4016 out of scope.  This attribute can only be applied to auto function
4017 scope variables; it may not be applied to parameters or variables
4018 with static storage duration.  The function must take one parameter,
4019 a pointer to a type compatible with the variable.  The return value
4020 of the function (if any) is ignored.
4022 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4023 will be run during the stack unwinding that happens during the
4024 processing of the exception.  Note that the @code{cleanup} attribute
4025 does not allow the exception to be caught, only to perform an action.
4026 It is undefined what happens if @var{cleanup_function} does not
4027 return normally.
4029 @item common
4030 @itemx nocommon
4031 @cindex @code{common} attribute
4032 @cindex @code{nocommon} attribute
4033 @opindex fcommon
4034 @opindex fno-common
4035 The @code{common} attribute requests GCC to place a variable in
4036 ``common'' storage.  The @code{nocommon} attribute requests the
4037 opposite---to allocate space for it directly.
4039 These attributes override the default chosen by the
4040 @option{-fno-common} and @option{-fcommon} flags respectively.
4042 @item deprecated
4043 @itemx deprecated (@var{msg})
4044 @cindex @code{deprecated} attribute
4045 The @code{deprecated} attribute results in a warning if the variable
4046 is used anywhere in the source file.  This is useful when identifying
4047 variables that are expected to be removed in a future version of a
4048 program.  The warning also includes the location of the declaration
4049 of the deprecated variable, to enable users to easily find further
4050 information about why the variable is deprecated, or what they should
4051 do instead.  Note that the warning only occurs for uses:
4053 @smallexample
4054 extern int old_var __attribute__ ((deprecated));
4055 extern int old_var;
4056 int new_fn () @{ return old_var; @}
4057 @end smallexample
4059 results in a warning on line 3 but not line 2.  The optional msg
4060 argument, which must be a string, will be printed in the warning if
4061 present.
4063 The @code{deprecated} attribute can also be used for functions and
4064 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4066 @item mode (@var{mode})
4067 @cindex @code{mode} attribute
4068 This attribute specifies the data type for the declaration---whichever
4069 type corresponds to the mode @var{mode}.  This in effect lets you
4070 request an integer or floating point type according to its width.
4072 You may also specify a mode of @samp{byte} or @samp{__byte__} to
4073 indicate the mode corresponding to a one-byte integer, @samp{word} or
4074 @samp{__word__} for the mode of a one-word integer, and @samp{pointer}
4075 or @samp{__pointer__} for the mode used to represent pointers.
4077 @item packed
4078 @cindex @code{packed} attribute
4079 The @code{packed} attribute specifies that a variable or structure field
4080 should have the smallest possible alignment---one byte for a variable,
4081 and one bit for a field, unless you specify a larger value with the
4082 @code{aligned} attribute.
4084 Here is a structure in which the field @code{x} is packed, so that it
4085 immediately follows @code{a}:
4087 @smallexample
4088 struct foo
4090   char a;
4091   int x[2] __attribute__ ((packed));
4093 @end smallexample
4095 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4096 @code{packed} attribute on bit-fields of type @code{char}.  This has
4097 been fixed in GCC 4.4 but the change can lead to differences in the
4098 structure layout.  See the documentation of
4099 @option{-Wpacked-bitfield-compat} for more information.
4101 @item section ("@var{section-name}")
4102 @cindex @code{section} variable attribute
4103 Normally, the compiler places the objects it generates in sections like
4104 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
4105 or you need certain particular variables to appear in special sections,
4106 for example to map to special hardware.  The @code{section}
4107 attribute specifies that a variable (or function) lives in a particular
4108 section.  For example, this small program uses several specific section names:
4110 @smallexample
4111 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4112 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4113 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4114 int init_data __attribute__ ((section ("INITDATA")));
4116 main()
4118   /* @r{Initialize stack pointer} */
4119   init_sp (stack + sizeof (stack));
4121   /* @r{Initialize initialized data} */
4122   memcpy (&init_data, &data, &edata - &data);
4124   /* @r{Turn on the serial ports} */
4125   init_duart (&a);
4126   init_duart (&b);
4128 @end smallexample
4130 @noindent
4131 Use the @code{section} attribute with
4132 @emph{global} variables and not @emph{local} variables,
4133 as shown in the example.
4135 You may use the @code{section} attribute with initialized or
4136 uninitialized global variables but the linker requires
4137 each object be defined once, with the exception that uninitialized
4138 variables tentatively go in the @code{common} (or @code{bss}) section
4139 and can be multiply ``defined''.  Using the @code{section} attribute
4140 will change what section the variable goes into and may cause the
4141 linker to issue an error if an uninitialized variable has multiple
4142 definitions.  You can force a variable to be initialized with the
4143 @option{-fno-common} flag or the @code{nocommon} attribute.
4145 Some file formats do not support arbitrary sections so the @code{section}
4146 attribute is not available on all platforms.
4147 If you need to map the entire contents of a module to a particular
4148 section, consider using the facilities of the linker instead.
4150 @item shared
4151 @cindex @code{shared} variable attribute
4152 On Microsoft Windows, in addition to putting variable definitions in a named
4153 section, the section can also be shared among all running copies of an
4154 executable or DLL@.  For example, this small program defines shared data
4155 by putting it in a named section @code{shared} and marking the section
4156 shareable:
4158 @smallexample
4159 int foo __attribute__((section ("shared"), shared)) = 0;
4162 main()
4164   /* @r{Read and write foo.  All running
4165      copies see the same value.}  */
4166   return 0;
4168 @end smallexample
4170 @noindent
4171 You may only use the @code{shared} attribute along with @code{section}
4172 attribute with a fully initialized global definition because of the way
4173 linkers work.  See @code{section} attribute for more information.
4175 The @code{shared} attribute is only available on Microsoft Windows@.
4177 @item tls_model ("@var{tls_model}")
4178 @cindex @code{tls_model} attribute
4179 The @code{tls_model} attribute sets thread-local storage model
4180 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4181 overriding @option{-ftls-model=} command-line switch on a per-variable
4182 basis.
4183 The @var{tls_model} argument should be one of @code{global-dynamic},
4184 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4186 Not all targets support this attribute.
4188 @item unused
4189 This attribute, attached to a variable, means that the variable is meant
4190 to be possibly unused.  GCC will not produce a warning for this
4191 variable.
4193 @item used
4194 This attribute, attached to a variable, means that the variable must be
4195 emitted even if it appears that the variable is not referenced.
4197 @item vector_size (@var{bytes})
4198 This attribute specifies the vector size for the variable, measured in
4199 bytes.  For example, the declaration:
4201 @smallexample
4202 int foo __attribute__ ((vector_size (16)));
4203 @end smallexample
4205 @noindent
4206 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4207 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
4208 4 units of 4 bytes), the corresponding mode of @code{foo} will be V4SI@.
4210 This attribute is only applicable to integral and float scalars,
4211 although arrays, pointers, and function return values are allowed in
4212 conjunction with this construct.
4214 Aggregates with this attribute are invalid, even if they are of the same
4215 size as a corresponding scalar.  For example, the declaration:
4217 @smallexample
4218 struct S @{ int a; @};
4219 struct S  __attribute__ ((vector_size (16))) foo;
4220 @end smallexample
4222 @noindent
4223 is invalid even if the size of the structure is the same as the size of
4224 the @code{int}.
4226 @item selectany
4227 The @code{selectany} attribute causes an initialized global variable to
4228 have link-once semantics.  When multiple definitions of the variable are
4229 encountered by the linker, the first is selected and the remainder are
4230 discarded.  Following usage by the Microsoft compiler, the linker is told
4231 @emph{not} to warn about size or content differences of the multiple
4232 definitions.
4234 Although the primary usage of this attribute is for POD types, the
4235 attribute can also be applied to global C++ objects that are initialized
4236 by a constructor.  In this case, the static initialization and destruction
4237 code for the object is emitted in each translation defining the object,
4238 but the calls to the constructor and destructor are protected by a
4239 link-once guard variable.
4241 The @code{selectany} attribute is only available on Microsoft Windows
4242 targets.  You can use @code{__declspec (selectany)} as a synonym for
4243 @code{__attribute__ ((selectany))} for compatibility with other
4244 compilers.
4246 @item weak
4247 The @code{weak} attribute is described in @ref{Function Attributes}.
4249 @item dllimport
4250 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4252 @item dllexport
4253 The @code{dllexport} attribute is described in @ref{Function Attributes}.
4255 @end table
4257 @subsection Blackfin Variable Attributes
4259 Three attributes are currently defined for the Blackfin.
4261 @table @code
4262 @item l1_data
4263 @itemx l1_data_A
4264 @itemx l1_data_B
4265 @cindex @code{l1_data} variable attribute
4266 @cindex @code{l1_data_A} variable attribute
4267 @cindex @code{l1_data_B} variable attribute
4268 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
4269 Variables with @code{l1_data} attribute will be put into the specific section
4270 named @code{.l1.data}. Those with @code{l1_data_A} attribute will be put into
4271 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
4272 attribute will be put into the specific section named @code{.l1.data.B}.
4274 @item l2
4275 @cindex @code{l2} variable attribute
4276 Use this attribute on the Blackfin to place the variable into L2 SRAM.
4277 Variables with @code{l2} attribute will be put into the specific section
4278 named @code{.l2.data}.
4279 @end table
4281 @subsection M32R/D Variable Attributes
4283 One attribute is currently defined for the M32R/D@.
4285 @table @code
4286 @item model (@var{model-name})
4287 @cindex variable addressability on the M32R/D
4288 Use this attribute on the M32R/D to set the addressability of an object.
4289 The identifier @var{model-name} is one of @code{small}, @code{medium},
4290 or @code{large}, representing each of the code models.
4292 Small model objects live in the lower 16MB of memory (so that their
4293 addresses can be loaded with the @code{ld24} instruction).
4295 Medium and large model objects may live anywhere in the 32-bit address space
4296 (the compiler will generate @code{seth/add3} instructions to load their
4297 addresses).
4298 @end table
4300 @anchor{MeP Variable Attributes}
4301 @subsection MeP Variable Attributes
4303 The MeP target has a number of addressing modes and busses.  The
4304 @code{near} space spans the standard memory space's first 16 megabytes
4305 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
4306 The @code{based} space is a 128 byte region in the memory space which
4307 is addressed relative to the @code{$tp} register.  The @code{tiny}
4308 space is a 65536 byte region relative to the @code{$gp} register.  In
4309 addition to these memory regions, the MeP target has a separate 16-bit
4310 control bus which is specified with @code{cb} attributes.
4312 @table @code
4314 @item based
4315 Any variable with the @code{based} attribute will be assigned to the
4316 @code{.based} section, and will be accessed with relative to the
4317 @code{$tp} register.
4319 @item tiny
4320 Likewise, the @code{tiny} attribute assigned variables to the
4321 @code{.tiny} section, relative to the @code{$gp} register.
4323 @item near
4324 Variables with the @code{near} attribute are assumed to have addresses
4325 that fit in a 24-bit addressing mode.  This is the default for large
4326 variables (@code{-mtiny=4} is the default) but this attribute can
4327 override @code{-mtiny=} for small variables, or override @code{-ml}.
4329 @item far
4330 Variables with the @code{far} attribute are addressed using a full
4331 32-bit address.  Since this covers the entire memory space, this
4332 allows modules to make no assumptions about where variables might be
4333 stored.
4335 @item io
4336 @itemx io (@var{addr})
4337 Variables with the @code{io} attribute are used to address
4338 memory-mapped peripherals.  If an address is specified, the variable
4339 is assigned that address, else it is not assigned an address (it is
4340 assumed some other module will assign an address).  Example:
4342 @example
4343 int timer_count __attribute__((io(0x123)));
4344 @end example
4346 @item cb
4347 @itemx cb (@var{addr})
4348 Variables with the @code{cb} attribute are used to access the control
4349 bus, using special instructions.  @code{addr} indicates the control bus
4350 address.  Example:
4352 @example
4353 int cpu_clock __attribute__((cb(0x123)));
4354 @end example
4356 @end table
4358 @anchor{i386 Variable Attributes}
4359 @subsection i386 Variable Attributes
4361 Two attributes are currently defined for i386 configurations:
4362 @code{ms_struct} and @code{gcc_struct}
4364 @table @code
4365 @item ms_struct
4366 @itemx gcc_struct
4367 @cindex @code{ms_struct} attribute
4368 @cindex @code{gcc_struct} attribute
4370 If @code{packed} is used on a structure, or if bit-fields are used
4371 it may be that the Microsoft ABI packs them differently
4372 than GCC would normally pack them.  Particularly when moving packed
4373 data between functions compiled with GCC and the native Microsoft compiler
4374 (either via function call or as data in a file), it may be necessary to access
4375 either format.
4377 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
4378 compilers to match the native Microsoft compiler.
4380 The Microsoft structure layout algorithm is fairly simple with the exception
4381 of the bitfield packing:
4383 The padding and alignment of members of structures and whether a bit field
4384 can straddle a storage-unit boundary
4386 @enumerate
4387 @item Structure members are stored sequentially in the order in which they are
4388 declared: the first member has the lowest memory address and the last member
4389 the highest.
4391 @item Every data object has an alignment-requirement. The alignment-requirement
4392 for all data except structures, unions, and arrays is either the size of the
4393 object or the current packing size (specified with either the aligned attribute
4394 or the pack pragma), whichever is less. For structures,  unions, and arrays,
4395 the alignment-requirement is the largest alignment-requirement of its members.
4396 Every object is allocated an offset so that:
4398 offset %  alignment-requirement == 0
4400 @item Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation
4401 unit if the integral types are the same size and if the next bit field fits
4402 into the current allocation unit without crossing the boundary imposed by the
4403 common alignment requirements of the bit fields.
4404 @end enumerate
4406 Handling of zero-length bitfields:
4408 MSVC interprets zero-length bitfields in the following ways:
4410 @enumerate
4411 @item If a zero-length bitfield is inserted between two bitfields that would
4412 normally be coalesced, the bitfields will not be coalesced.
4414 For example:
4416 @smallexample
4417 struct
4418  @{
4419    unsigned long bf_1 : 12;
4420    unsigned long : 0;
4421    unsigned long bf_2 : 12;
4422  @} t1;
4423 @end smallexample
4425 The size of @code{t1} would be 8 bytes with the zero-length bitfield.  If the
4426 zero-length bitfield were removed, @code{t1}'s size would be 4 bytes.
4428 @item If a zero-length bitfield is inserted after a bitfield, @code{foo}, and the
4429 alignment of the zero-length bitfield is greater than the member that follows it,
4430 @code{bar}, @code{bar} will be aligned as the type of the zero-length bitfield.
4432 For example:
4434 @smallexample
4435 struct
4436  @{
4437    char foo : 4;
4438    short : 0;
4439    char bar;
4440  @} t2;
4442 struct
4443  @{
4444    char foo : 4;
4445    short : 0;
4446    double bar;
4447  @} t3;
4448 @end smallexample
4450 For @code{t2}, @code{bar} will be placed at offset 2, rather than offset 1.
4451 Accordingly, the size of @code{t2} will be 4.  For @code{t3}, the zero-length
4452 bitfield will not affect the alignment of @code{bar} or, as a result, the size
4453 of the structure.
4455 Taking this into account, it is important to note the following:
4457 @enumerate
4458 @item If a zero-length bitfield follows a normal bitfield, the type of the
4459 zero-length bitfield may affect the alignment of the structure as whole. For
4460 example, @code{t2} has a size of 4 bytes, since the zero-length bitfield follows a
4461 normal bitfield, and is of type short.
4463 @item Even if a zero-length bitfield is not followed by a normal bitfield, it may
4464 still affect the alignment of the structure:
4466 @smallexample
4467 struct
4468  @{
4469    char foo : 6;
4470    long : 0;
4471  @} t4;
4472 @end smallexample
4474 Here, @code{t4} will take up 4 bytes.
4475 @end enumerate
4477 @item Zero-length bitfields following non-bitfield members are ignored:
4479 @smallexample
4480 struct
4481  @{
4482    char foo;
4483    long : 0;
4484    char bar;
4485  @} t5;
4486 @end smallexample
4488 Here, @code{t5} will take up 2 bytes.
4489 @end enumerate
4490 @end table
4492 @subsection PowerPC Variable Attributes
4494 Three attributes currently are defined for PowerPC configurations:
4495 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
4497 For full documentation of the struct attributes please see the
4498 documentation in @ref{i386 Variable Attributes}.
4500 For documentation of @code{altivec} attribute please see the
4501 documentation in @ref{PowerPC Type Attributes}.
4503 @subsection SPU Variable Attributes
4505 The SPU supports the @code{spu_vector} attribute for variables.  For
4506 documentation of this attribute please see the documentation in
4507 @ref{SPU Type Attributes}.
4509 @subsection Xstormy16 Variable Attributes
4511 One attribute is currently defined for xstormy16 configurations:
4512 @code{below100}.
4514 @table @code
4515 @item below100
4516 @cindex @code{below100} attribute
4518 If a variable has the @code{below100} attribute (@code{BELOW100} is
4519 allowed also), GCC will place the variable in the first 0x100 bytes of
4520 memory and use special opcodes to access it.  Such variables will be
4521 placed in either the @code{.bss_below100} section or the
4522 @code{.data_below100} section.
4524 @end table
4526 @subsection AVR Variable Attributes
4528 @table @code
4529 @item progmem
4530 @cindex @code{progmem} variable attribute
4531 The @code{progmem} attribute is used on the AVR to place data in the Program
4532 Memory address space. The AVR is a Harvard Architecture processor and data
4533 normally resides in the Data Memory address space.
4534 @end table
4536 @node Type Attributes
4537 @section Specifying Attributes of Types
4538 @cindex attribute of types
4539 @cindex type attributes
4541 The keyword @code{__attribute__} allows you to specify special
4542 attributes of @code{struct} and @code{union} types when you define
4543 such types.  This keyword is followed by an attribute specification
4544 inside double parentheses.  Seven attributes are currently defined for
4545 types: @code{aligned}, @code{packed}, @code{transparent_union},
4546 @code{unused}, @code{deprecated}, @code{visibility}, and
4547 @code{may_alias}.  Other attributes are defined for functions
4548 (@pxref{Function Attributes}) and for variables (@pxref{Variable
4549 Attributes}).
4551 You may also specify any one of these attributes with @samp{__}
4552 preceding and following its keyword.  This allows you to use these
4553 attributes in header files without being concerned about a possible
4554 macro of the same name.  For example, you may use @code{__aligned__}
4555 instead of @code{aligned}.
4557 You may specify type attributes in an enum, struct or union type
4558 declaration or definition, or for other types in a @code{typedef}
4559 declaration.
4561 For an enum, struct or union type, you may specify attributes either
4562 between the enum, struct or union tag and the name of the type, or
4563 just past the closing curly brace of the @emph{definition}.  The
4564 former syntax is preferred.
4566 @xref{Attribute Syntax}, for details of the exact syntax for using
4567 attributes.
4569 @table @code
4570 @cindex @code{aligned} attribute
4571 @item aligned (@var{alignment})
4572 This attribute specifies a minimum alignment (in bytes) for variables
4573 of the specified type.  For example, the declarations:
4575 @smallexample
4576 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
4577 typedef int more_aligned_int __attribute__ ((aligned (8)));
4578 @end smallexample
4580 @noindent
4581 force the compiler to insure (as far as it can) that each variable whose
4582 type is @code{struct S} or @code{more_aligned_int} will be allocated and
4583 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
4584 variables of type @code{struct S} aligned to 8-byte boundaries allows
4585 the compiler to use the @code{ldd} and @code{std} (doubleword load and
4586 store) instructions when copying one variable of type @code{struct S} to
4587 another, thus improving run-time efficiency.
4589 Note that the alignment of any given @code{struct} or @code{union} type
4590 is required by the ISO C standard to be at least a perfect multiple of
4591 the lowest common multiple of the alignments of all of the members of
4592 the @code{struct} or @code{union} in question.  This means that you @emph{can}
4593 effectively adjust the alignment of a @code{struct} or @code{union}
4594 type by attaching an @code{aligned} attribute to any one of the members
4595 of such a type, but the notation illustrated in the example above is a
4596 more obvious, intuitive, and readable way to request the compiler to
4597 adjust the alignment of an entire @code{struct} or @code{union} type.
4599 As in the preceding example, you can explicitly specify the alignment
4600 (in bytes) that you wish the compiler to use for a given @code{struct}
4601 or @code{union} type.  Alternatively, you can leave out the alignment factor
4602 and just ask the compiler to align a type to the maximum
4603 useful alignment for the target machine you are compiling for.  For
4604 example, you could write:
4606 @smallexample
4607 struct S @{ short f[3]; @} __attribute__ ((aligned));
4608 @end smallexample
4610 Whenever you leave out the alignment factor in an @code{aligned}
4611 attribute specification, the compiler automatically sets the alignment
4612 for the type to the largest alignment which is ever used for any data
4613 type on the target machine you are compiling for.  Doing this can often
4614 make copy operations more efficient, because the compiler can use
4615 whatever instructions copy the biggest chunks of memory when performing
4616 copies to or from the variables which have types that you have aligned
4617 this way.
4619 In the example above, if the size of each @code{short} is 2 bytes, then
4620 the size of the entire @code{struct S} type is 6 bytes.  The smallest
4621 power of two which is greater than or equal to that is 8, so the
4622 compiler sets the alignment for the entire @code{struct S} type to 8
4623 bytes.
4625 Note that although you can ask the compiler to select a time-efficient
4626 alignment for a given type and then declare only individual stand-alone
4627 objects of that type, the compiler's ability to select a time-efficient
4628 alignment is primarily useful only when you plan to create arrays of
4629 variables having the relevant (efficiently aligned) type.  If you
4630 declare or use arrays of variables of an efficiently-aligned type, then
4631 it is likely that your program will also be doing pointer arithmetic (or
4632 subscripting, which amounts to the same thing) on pointers to the
4633 relevant type, and the code that the compiler generates for these
4634 pointer arithmetic operations will often be more efficient for
4635 efficiently-aligned types than for other types.
4637 The @code{aligned} attribute can only increase the alignment; but you
4638 can decrease it by specifying @code{packed} as well.  See below.
4640 Note that the effectiveness of @code{aligned} attributes may be limited
4641 by inherent limitations in your linker.  On many systems, the linker is
4642 only able to arrange for variables to be aligned up to a certain maximum
4643 alignment.  (For some linkers, the maximum supported alignment may
4644 be very very small.)  If your linker is only able to align variables
4645 up to a maximum of 8 byte alignment, then specifying @code{aligned(16)}
4646 in an @code{__attribute__} will still only provide you with 8 byte
4647 alignment.  See your linker documentation for further information.
4649 @item packed
4650 This attribute, attached to @code{struct} or @code{union} type
4651 definition, specifies that each member (other than zero-width bitfields)
4652 of the structure or union is placed to minimize the memory required.  When
4653 attached to an @code{enum} definition, it indicates that the smallest
4654 integral type should be used.
4656 @opindex fshort-enums
4657 Specifying this attribute for @code{struct} and @code{union} types is
4658 equivalent to specifying the @code{packed} attribute on each of the
4659 structure or union members.  Specifying the @option{-fshort-enums}
4660 flag on the line is equivalent to specifying the @code{packed}
4661 attribute on all @code{enum} definitions.
4663 In the following example @code{struct my_packed_struct}'s members are
4664 packed closely together, but the internal layout of its @code{s} member
4665 is not packed---to do that, @code{struct my_unpacked_struct} would need to
4666 be packed too.
4668 @smallexample
4669 struct my_unpacked_struct
4670  @{
4671     char c;
4672     int i;
4673  @};
4675 struct __attribute__ ((__packed__)) my_packed_struct
4676   @{
4677      char c;
4678      int  i;
4679      struct my_unpacked_struct s;
4680   @};
4681 @end smallexample
4683 You may only specify this attribute on the definition of an @code{enum},
4684 @code{struct} or @code{union}, not on a @code{typedef} which does not
4685 also define the enumerated type, structure or union.
4687 @item transparent_union
4688 This attribute, attached to a @code{union} type definition, indicates
4689 that any function parameter having that union type causes calls to that
4690 function to be treated in a special way.
4692 First, the argument corresponding to a transparent union type can be of
4693 any type in the union; no cast is required.  Also, if the union contains
4694 a pointer type, the corresponding argument can be a null pointer
4695 constant or a void pointer expression; and if the union contains a void
4696 pointer type, the corresponding argument can be any pointer expression.
4697 If the union member type is a pointer, qualifiers like @code{const} on
4698 the referenced type must be respected, just as with normal pointer
4699 conversions.
4701 Second, the argument is passed to the function using the calling
4702 conventions of the first member of the transparent union, not the calling
4703 conventions of the union itself.  All members of the union must have the
4704 same machine representation; this is necessary for this argument passing
4705 to work properly.
4707 Transparent unions are designed for library functions that have multiple
4708 interfaces for compatibility reasons.  For example, suppose the
4709 @code{wait} function must accept either a value of type @code{int *} to
4710 comply with Posix, or a value of type @code{union wait *} to comply with
4711 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
4712 @code{wait} would accept both kinds of arguments, but it would also
4713 accept any other pointer type and this would make argument type checking
4714 less useful.  Instead, @code{<sys/wait.h>} might define the interface
4715 as follows:
4717 @smallexample
4718 typedef union __attribute__ ((__transparent_union__))
4719   @{
4720     int *__ip;
4721     union wait *__up;
4722   @} wait_status_ptr_t;
4724 pid_t wait (wait_status_ptr_t);
4725 @end smallexample
4727 This interface allows either @code{int *} or @code{union wait *}
4728 arguments to be passed, using the @code{int *} calling convention.
4729 The program can call @code{wait} with arguments of either type:
4731 @smallexample
4732 int w1 () @{ int w; return wait (&w); @}
4733 int w2 () @{ union wait w; return wait (&w); @}
4734 @end smallexample
4736 With this interface, @code{wait}'s implementation might look like this:
4738 @smallexample
4739 pid_t wait (wait_status_ptr_t p)
4741   return waitpid (-1, p.__ip, 0);
4743 @end smallexample
4745 @item unused
4746 When attached to a type (including a @code{union} or a @code{struct}),
4747 this attribute means that variables of that type are meant to appear
4748 possibly unused.  GCC will not produce a warning for any variables of
4749 that type, even if the variable appears to do nothing.  This is often
4750 the case with lock or thread classes, which are usually defined and then
4751 not referenced, but contain constructors and destructors that have
4752 nontrivial bookkeeping functions.
4754 @item deprecated
4755 @itemx deprecated (@var{msg})
4756 The @code{deprecated} attribute results in a warning if the type
4757 is used anywhere in the source file.  This is useful when identifying
4758 types that are expected to be removed in a future version of a program.
4759 If possible, the warning also includes the location of the declaration
4760 of the deprecated type, to enable users to easily find further
4761 information about why the type is deprecated, or what they should do
4762 instead.  Note that the warnings only occur for uses and then only
4763 if the type is being applied to an identifier that itself is not being
4764 declared as deprecated.
4766 @smallexample
4767 typedef int T1 __attribute__ ((deprecated));
4768 T1 x;
4769 typedef T1 T2;
4770 T2 y;
4771 typedef T1 T3 __attribute__ ((deprecated));
4772 T3 z __attribute__ ((deprecated));
4773 @end smallexample
4775 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
4776 warning is issued for line 4 because T2 is not explicitly
4777 deprecated.  Line 5 has no warning because T3 is explicitly
4778 deprecated.  Similarly for line 6.  The optional msg
4779 argument, which must be a string, will be printed in the warning if
4780 present.
4782 The @code{deprecated} attribute can also be used for functions and
4783 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
4785 @item may_alias
4786 Accesses through pointers to types with this attribute are not subject
4787 to type-based alias analysis, but are instead assumed to be able to alias
4788 any other type of objects.  In the context of 6.5/7 an lvalue expression
4789 dereferencing such a pointer is treated like having a character type.
4790 See @option{-fstrict-aliasing} for more information on aliasing issues.
4791 This extension exists to support some vector APIs, in which pointers to
4792 one vector type are permitted to alias pointers to a different vector type.
4794 Note that an object of a type with this attribute does not have any
4795 special semantics.
4797 Example of use:
4799 @smallexample
4800 typedef short __attribute__((__may_alias__)) short_a;
4803 main (void)
4805   int a = 0x12345678;
4806   short_a *b = (short_a *) &a;
4808   b[1] = 0;
4810   if (a == 0x12345678)
4811     abort();
4813   exit(0);
4815 @end smallexample
4817 If you replaced @code{short_a} with @code{short} in the variable
4818 declaration, the above program would abort when compiled with
4819 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
4820 above in recent GCC versions.
4822 @item visibility
4823 In C++, attribute visibility (@pxref{Function Attributes}) can also be
4824 applied to class, struct, union and enum types.  Unlike other type
4825 attributes, the attribute must appear between the initial keyword and
4826 the name of the type; it cannot appear after the body of the type.
4828 Note that the type visibility is applied to vague linkage entities
4829 associated with the class (vtable, typeinfo node, etc.).  In
4830 particular, if a class is thrown as an exception in one shared object
4831 and caught in another, the class must have default visibility.
4832 Otherwise the two shared objects will be unable to use the same
4833 typeinfo node and exception handling will break.
4835 @end table
4837 @subsection ARM Type Attributes
4839 On those ARM targets that support @code{dllimport} (such as Symbian
4840 OS), you can use the @code{notshared} attribute to indicate that the
4841 virtual table and other similar data for a class should not be
4842 exported from a DLL@.  For example:
4844 @smallexample
4845 class __declspec(notshared) C @{
4846 public:
4847   __declspec(dllimport) C();
4848   virtual void f();
4851 __declspec(dllexport)
4852 C::C() @{@}
4853 @end smallexample
4855 In this code, @code{C::C} is exported from the current DLL, but the
4856 virtual table for @code{C} is not exported.  (You can use
4857 @code{__attribute__} instead of @code{__declspec} if you prefer, but
4858 most Symbian OS code uses @code{__declspec}.)
4860 @anchor{MeP Type Attributes}
4861 @subsection MeP Type Attributes
4863 Many of the MeP variable attributes may be applied to types as well.
4864 Specifically, the @code{based}, @code{tiny}, @code{near}, and
4865 @code{far} attributes may be applied to either.  The @code{io} and
4866 @code{cb} attributes may not be applied to types.
4868 @anchor{i386 Type Attributes}
4869 @subsection i386 Type Attributes
4871 Two attributes are currently defined for i386 configurations:
4872 @code{ms_struct} and @code{gcc_struct}.
4874 @table @code
4876 @item ms_struct
4877 @itemx gcc_struct
4878 @cindex @code{ms_struct}
4879 @cindex @code{gcc_struct}
4881 If @code{packed} is used on a structure, or if bit-fields are used
4882 it may be that the Microsoft ABI packs them differently
4883 than GCC would normally pack them.  Particularly when moving packed
4884 data between functions compiled with GCC and the native Microsoft compiler
4885 (either via function call or as data in a file), it may be necessary to access
4886 either format.
4888 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
4889 compilers to match the native Microsoft compiler.
4890 @end table
4892 To specify multiple attributes, separate them by commas within the
4893 double parentheses: for example, @samp{__attribute__ ((aligned (16),
4894 packed))}.
4896 @anchor{PowerPC Type Attributes}
4897 @subsection PowerPC Type Attributes
4899 Three attributes currently are defined for PowerPC configurations:
4900 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
4902 For full documentation of the @code{ms_struct} and @code{gcc_struct} 
4903 attributes please see the documentation in @ref{i386 Type Attributes}.
4905 The @code{altivec} attribute allows one to declare AltiVec vector data
4906 types supported by the AltiVec Programming Interface Manual.  The
4907 attribute requires an argument to specify one of three vector types:
4908 @code{vector__}, @code{pixel__} (always followed by unsigned short),
4909 and @code{bool__} (always followed by unsigned).
4911 @smallexample
4912 __attribute__((altivec(vector__)))
4913 __attribute__((altivec(pixel__))) unsigned short
4914 __attribute__((altivec(bool__))) unsigned
4915 @end smallexample
4917 These attributes mainly are intended to support the @code{__vector},
4918 @code{__pixel}, and @code{__bool} AltiVec keywords.
4920 @anchor{SPU Type Attributes}
4921 @subsection SPU Type Attributes
4923 The SPU supports the @code{spu_vector} attribute for types.  This attribute
4924 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
4925 Language Extensions Specification.  It is intended to support the
4926 @code{__vector} keyword.
4929 @node Inline
4930 @section An Inline Function is As Fast As a Macro
4931 @cindex inline functions
4932 @cindex integrating function code
4933 @cindex open coding
4934 @cindex macros, inline alternative
4936 By declaring a function inline, you can direct GCC to make
4937 calls to that function faster.  One way GCC can achieve this is to
4938 integrate that function's code into the code for its callers.  This
4939 makes execution faster by eliminating the function-call overhead; in
4940 addition, if any of the actual argument values are constant, their
4941 known values may permit simplifications at compile time so that not
4942 all of the inline function's code needs to be included.  The effect on
4943 code size is less predictable; object code may be larger or smaller
4944 with function inlining, depending on the particular case.  You can
4945 also direct GCC to try to integrate all ``simple enough'' functions
4946 into their callers with the option @option{-finline-functions}.
4948 GCC implements three different semantics of declaring a function
4949 inline.  One is available with @option{-std=gnu89} or
4950 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
4951 on all inline declarations, another when
4952 @option{-std=c99}, @option{-std=c1x},
4953 @option{-std=gnu99} or @option{-std=gnu1x}
4954 (without @option{-fgnu89-inline}), and the third
4955 is used when compiling C++.
4957 To declare a function inline, use the @code{inline} keyword in its
4958 declaration, like this:
4960 @smallexample
4961 static inline int
4962 inc (int *a)
4964   return (*a)++;
4966 @end smallexample
4968 If you are writing a header file to be included in ISO C90 programs, write
4969 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
4971 The three types of inlining behave similarly in two important cases:
4972 when the @code{inline} keyword is used on a @code{static} function,
4973 like the example above, and when a function is first declared without
4974 using the @code{inline} keyword and then is defined with
4975 @code{inline}, like this:
4977 @smallexample
4978 extern int inc (int *a);
4979 inline int
4980 inc (int *a)
4982   return (*a)++;
4984 @end smallexample
4986 In both of these common cases, the program behaves the same as if you
4987 had not used the @code{inline} keyword, except for its speed.
4989 @cindex inline functions, omission of
4990 @opindex fkeep-inline-functions
4991 When a function is both inline and @code{static}, if all calls to the
4992 function are integrated into the caller, and the function's address is
4993 never used, then the function's own assembler code is never referenced.
4994 In this case, GCC does not actually output assembler code for the
4995 function, unless you specify the option @option{-fkeep-inline-functions}.
4996 Some calls cannot be integrated for various reasons (in particular,
4997 calls that precede the function's definition cannot be integrated, and
4998 neither can recursive calls within the definition).  If there is a
4999 nonintegrated call, then the function is compiled to assembler code as
5000 usual.  The function must also be compiled as usual if the program
5001 refers to its address, because that can't be inlined.
5003 @opindex Winline
5004 Note that certain usages in a function definition can make it unsuitable
5005 for inline substitution.  Among these usages are: use of varargs, use of
5006 alloca, use of variable sized data types (@pxref{Variable Length}),
5007 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5008 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
5009 will warn when a function marked @code{inline} could not be substituted,
5010 and will give the reason for the failure.
5012 @cindex automatic @code{inline} for C++ member fns
5013 @cindex @code{inline} automatic for C++ member fns
5014 @cindex member fns, automatically @code{inline}
5015 @cindex C++ member fns, automatically @code{inline}
5016 @opindex fno-default-inline
5017 As required by ISO C++, GCC considers member functions defined within
5018 the body of a class to be marked inline even if they are
5019 not explicitly declared with the @code{inline} keyword.  You can
5020 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5021 Options,,Options Controlling C++ Dialect}.
5023 GCC does not inline any functions when not optimizing unless you specify
5024 the @samp{always_inline} attribute for the function, like this:
5026 @smallexample
5027 /* @r{Prototype.}  */
5028 inline void foo (const char) __attribute__((always_inline));
5029 @end smallexample
5031 The remainder of this section is specific to GNU C90 inlining.
5033 @cindex non-static inline function
5034 When an inline function is not @code{static}, then the compiler must assume
5035 that there may be calls from other source files; since a global symbol can
5036 be defined only once in any program, the function must not be defined in
5037 the other source files, so the calls therein cannot be integrated.
5038 Therefore, a non-@code{static} inline function is always compiled on its
5039 own in the usual fashion.
5041 If you specify both @code{inline} and @code{extern} in the function
5042 definition, then the definition is used only for inlining.  In no case
5043 is the function compiled on its own, not even if you refer to its
5044 address explicitly.  Such an address becomes an external reference, as
5045 if you had only declared the function, and had not defined it.
5047 This combination of @code{inline} and @code{extern} has almost the
5048 effect of a macro.  The way to use it is to put a function definition in
5049 a header file with these keywords, and put another copy of the
5050 definition (lacking @code{inline} and @code{extern}) in a library file.
5051 The definition in the header file will cause most calls to the function
5052 to be inlined.  If any uses of the function remain, they will refer to
5053 the single copy in the library.
5055 @node Extended Asm
5056 @section Assembler Instructions with C Expression Operands
5057 @cindex extended @code{asm}
5058 @cindex @code{asm} expressions
5059 @cindex assembler instructions
5060 @cindex registers
5062 In an assembler instruction using @code{asm}, you can specify the
5063 operands of the instruction using C expressions.  This means you need not
5064 guess which registers or memory locations will contain the data you want
5065 to use.
5067 You must specify an assembler instruction template much like what
5068 appears in a machine description, plus an operand constraint string for
5069 each operand.
5071 For example, here is how to use the 68881's @code{fsinx} instruction:
5073 @smallexample
5074 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5075 @end smallexample
5077 @noindent
5078 Here @code{angle} is the C expression for the input operand while
5079 @code{result} is that of the output operand.  Each has @samp{"f"} as its
5080 operand constraint, saying that a floating point register is required.
5081 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5082 output operands' constraints must use @samp{=}.  The constraints use the
5083 same language used in the machine description (@pxref{Constraints}).
5085 Each operand is described by an operand-constraint string followed by
5086 the C expression in parentheses.  A colon separates the assembler
5087 template from the first output operand and another separates the last
5088 output operand from the first input, if any.  Commas separate the
5089 operands within each group.  The total number of operands is currently
5090 limited to 30; this limitation may be lifted in some future version of
5091 GCC@.
5093 If there are no output operands but there are input operands, you must
5094 place two consecutive colons surrounding the place where the output
5095 operands would go.
5097 As of GCC version 3.1, it is also possible to specify input and output
5098 operands using symbolic names which can be referenced within the
5099 assembler code.  These names are specified inside square brackets
5100 preceding the constraint string, and can be referenced inside the
5101 assembler code using @code{%[@var{name}]} instead of a percentage sign
5102 followed by the operand number.  Using named operands the above example
5103 could look like:
5105 @smallexample
5106 asm ("fsinx %[angle],%[output]"
5107      : [output] "=f" (result)
5108      : [angle] "f" (angle));
5109 @end smallexample
5111 @noindent
5112 Note that the symbolic operand names have no relation whatsoever to
5113 other C identifiers.  You may use any name you like, even those of
5114 existing C symbols, but you must ensure that no two operands within the same
5115 assembler construct use the same symbolic name.
5117 Output operand expressions must be lvalues; the compiler can check this.
5118 The input operands need not be lvalues.  The compiler cannot check
5119 whether the operands have data types that are reasonable for the
5120 instruction being executed.  It does not parse the assembler instruction
5121 template and does not know what it means or even whether it is valid
5122 assembler input.  The extended @code{asm} feature is most often used for
5123 machine instructions the compiler itself does not know exist.  If
5124 the output expression cannot be directly addressed (for example, it is a
5125 bit-field), your constraint must allow a register.  In that case, GCC
5126 will use the register as the output of the @code{asm}, and then store
5127 that register into the output.
5129 The ordinary output operands must be write-only; GCC will assume that
5130 the values in these operands before the instruction are dead and need
5131 not be generated.  Extended asm supports input-output or read-write
5132 operands.  Use the constraint character @samp{+} to indicate such an
5133 operand and list it with the output operands.  You should only use
5134 read-write operands when the constraints for the operand (or the
5135 operand in which only some of the bits are to be changed) allow a
5136 register.
5138 You may, as an alternative, logically split its function into two
5139 separate operands, one input operand and one write-only output
5140 operand.  The connection between them is expressed by constraints
5141 which say they need to be in the same location when the instruction
5142 executes.  You can use the same C expression for both operands, or
5143 different expressions.  For example, here we write the (fictitious)
5144 @samp{combine} instruction with @code{bar} as its read-only source
5145 operand and @code{foo} as its read-write destination:
5147 @smallexample
5148 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
5149 @end smallexample
5151 @noindent
5152 The constraint @samp{"0"} for operand 1 says that it must occupy the
5153 same location as operand 0.  A number in constraint is allowed only in
5154 an input operand and it must refer to an output operand.
5156 Only a number in the constraint can guarantee that one operand will be in
5157 the same place as another.  The mere fact that @code{foo} is the value
5158 of both operands is not enough to guarantee that they will be in the
5159 same place in the generated assembler code.  The following would not
5160 work reliably:
5162 @smallexample
5163 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
5164 @end smallexample
5166 Various optimizations or reloading could cause operands 0 and 1 to be in
5167 different registers; GCC knows no reason not to do so.  For example, the
5168 compiler might find a copy of the value of @code{foo} in one register and
5169 use it for operand 1, but generate the output operand 0 in a different
5170 register (copying it afterward to @code{foo}'s own address).  Of course,
5171 since the register for operand 1 is not even mentioned in the assembler
5172 code, the result will not work, but GCC can't tell that.
5174 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
5175 the operand number for a matching constraint.  For example:
5177 @smallexample
5178 asm ("cmoveq %1,%2,%[result]"
5179      : [result] "=r"(result)
5180      : "r" (test), "r"(new), "[result]"(old));
5181 @end smallexample
5183 Sometimes you need to make an @code{asm} operand be a specific register,
5184 but there's no matching constraint letter for that register @emph{by
5185 itself}.  To force the operand into that register, use a local variable
5186 for the operand and specify the register in the variable declaration.
5187 @xref{Explicit Reg Vars}.  Then for the @code{asm} operand, use any
5188 register constraint letter that matches the register:
5190 @smallexample
5191 register int *p1 asm ("r0") = @dots{};
5192 register int *p2 asm ("r1") = @dots{};
5193 register int *result asm ("r0");
5194 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5195 @end smallexample
5197 @anchor{Example of asm with clobbered asm reg}
5198 In the above example, beware that a register that is call-clobbered by
5199 the target ABI will be overwritten by any function call in the
5200 assignment, including library calls for arithmetic operators.
5201 Also a register may be clobbered when generating some operations,
5202 like variable shift, memory copy or memory move on x86.
5203 Assuming it is a call-clobbered register, this may happen to @code{r0}
5204 above by the assignment to @code{p2}.  If you have to use such a
5205 register, use temporary variables for expressions between the register
5206 assignment and use:
5208 @smallexample
5209 int t1 = @dots{};
5210 register int *p1 asm ("r0") = @dots{};
5211 register int *p2 asm ("r1") = t1;
5212 register int *result asm ("r0");
5213 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5214 @end smallexample
5216 Some instructions clobber specific hard registers.  To describe this,
5217 write a third colon after the input operands, followed by the names of
5218 the clobbered hard registers (given as strings).  Here is a realistic
5219 example for the VAX:
5221 @smallexample
5222 asm volatile ("movc3 %0,%1,%2"
5223               : /* @r{no outputs} */
5224               : "g" (from), "g" (to), "g" (count)
5225               : "r0", "r1", "r2", "r3", "r4", "r5");
5226 @end smallexample
5228 You may not write a clobber description in a way that overlaps with an
5229 input or output operand.  For example, you may not have an operand
5230 describing a register class with one member if you mention that register
5231 in the clobber list.  Variables declared to live in specific registers
5232 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
5233 have no part mentioned in the clobber description.
5234 There is no way for you to specify that an input
5235 operand is modified without also specifying it as an output
5236 operand.  Note that if all the output operands you specify are for this
5237 purpose (and hence unused), you will then also need to specify
5238 @code{volatile} for the @code{asm} construct, as described below, to
5239 prevent GCC from deleting the @code{asm} statement as unused.
5241 If you refer to a particular hardware register from the assembler code,
5242 you will probably have to list the register after the third colon to
5243 tell the compiler the register's value is modified.  In some assemblers,
5244 the register names begin with @samp{%}; to produce one @samp{%} in the
5245 assembler code, you must write @samp{%%} in the input.
5247 If your assembler instruction can alter the condition code register, add
5248 @samp{cc} to the list of clobbered registers.  GCC on some machines
5249 represents the condition codes as a specific hardware register;
5250 @samp{cc} serves to name this register.  On other machines, the
5251 condition code is handled differently, and specifying @samp{cc} has no
5252 effect.  But it is valid no matter what the machine.
5254 If your assembler instructions access memory in an unpredictable
5255 fashion, add @samp{memory} to the list of clobbered registers.  This
5256 will cause GCC to not keep memory values cached in registers across the
5257 assembler instruction and not optimize stores or loads to that memory.
5258 You will also want to add the @code{volatile} keyword if the memory
5259 affected is not listed in the inputs or outputs of the @code{asm}, as
5260 the @samp{memory} clobber does not count as a side-effect of the
5261 @code{asm}.  If you know how large the accessed memory is, you can add
5262 it as input or output but if this is not known, you should add
5263 @samp{memory}.  As an example, if you access ten bytes of a string, you
5264 can use a memory input like:
5266 @smallexample
5267 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
5268 @end smallexample
5270 Note that in the following example the memory input is necessary,
5271 otherwise GCC might optimize the store to @code{x} away:
5272 @smallexample
5273 int foo ()
5275   int x = 42;
5276   int *y = &x;
5277   int result;
5278   asm ("magic stuff accessing an 'int' pointed to by '%1'"
5279         "=&d" (r) : "a" (y), "m" (*y));
5280   return result;
5282 @end smallexample
5284 You can put multiple assembler instructions together in a single
5285 @code{asm} template, separated by the characters normally used in assembly
5286 code for the system.  A combination that works in most places is a newline
5287 to break the line, plus a tab character to move to the instruction field
5288 (written as @samp{\n\t}).  Sometimes semicolons can be used, if the
5289 assembler allows semicolons as a line-breaking character.  Note that some
5290 assembler dialects use semicolons to start a comment.
5291 The input operands are guaranteed not to use any of the clobbered
5292 registers, and neither will the output operands' addresses, so you can
5293 read and write the clobbered registers as many times as you like.  Here
5294 is an example of multiple instructions in a template; it assumes the
5295 subroutine @code{_foo} accepts arguments in registers 9 and 10:
5297 @smallexample
5298 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
5299      : /* no outputs */
5300      : "g" (from), "g" (to)
5301      : "r9", "r10");
5302 @end smallexample
5304 Unless an output operand has the @samp{&} constraint modifier, GCC
5305 may allocate it in the same register as an unrelated input operand, on
5306 the assumption the inputs are consumed before the outputs are produced.
5307 This assumption may be false if the assembler code actually consists of
5308 more than one instruction.  In such a case, use @samp{&} for each output
5309 operand that may not overlap an input.  @xref{Modifiers}.
5311 If you want to test the condition code produced by an assembler
5312 instruction, you must include a branch and a label in the @code{asm}
5313 construct, as follows:
5315 @smallexample
5316 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
5317      : "g" (result)
5318      : "g" (input));
5319 @end smallexample
5321 @noindent
5322 This assumes your assembler supports local labels, as the GNU assembler
5323 and most Unix assemblers do.
5325 Speaking of labels, jumps from one @code{asm} to another are not
5326 supported.  The compiler's optimizers do not know about these jumps, and
5327 therefore they cannot take account of them when deciding how to
5328 optimize.  @xref{Extended asm with goto}.
5330 @cindex macros containing @code{asm}
5331 Usually the most convenient way to use these @code{asm} instructions is to
5332 encapsulate them in macros that look like functions.  For example,
5334 @smallexample
5335 #define sin(x)       \
5336 (@{ double __value, __arg = (x);   \
5337    asm ("fsinx %1,%0": "=f" (__value): "f" (__arg));  \
5338    __value; @})
5339 @end smallexample
5341 @noindent
5342 Here the variable @code{__arg} is used to make sure that the instruction
5343 operates on a proper @code{double} value, and to accept only those
5344 arguments @code{x} which can convert automatically to a @code{double}.
5346 Another way to make sure the instruction operates on the correct data
5347 type is to use a cast in the @code{asm}.  This is different from using a
5348 variable @code{__arg} in that it converts more different types.  For
5349 example, if the desired type were @code{int}, casting the argument to
5350 @code{int} would accept a pointer with no complaint, while assigning the
5351 argument to an @code{int} variable named @code{__arg} would warn about
5352 using a pointer unless the caller explicitly casts it.
5354 If an @code{asm} has output operands, GCC assumes for optimization
5355 purposes the instruction has no side effects except to change the output
5356 operands.  This does not mean instructions with a side effect cannot be
5357 used, but you must be careful, because the compiler may eliminate them
5358 if the output operands aren't used, or move them out of loops, or
5359 replace two with one if they constitute a common subexpression.  Also,
5360 if your instruction does have a side effect on a variable that otherwise
5361 appears not to change, the old value of the variable may be reused later
5362 if it happens to be found in a register.
5364 You can prevent an @code{asm} instruction from being deleted
5365 by writing the keyword @code{volatile} after
5366 the @code{asm}.  For example:
5368 @smallexample
5369 #define get_and_set_priority(new)              \
5370 (@{ int __old;                                  \
5371    asm volatile ("get_and_set_priority %0, %1" \
5372                  : "=g" (__old) : "g" (new));  \
5373    __old; @})
5374 @end smallexample
5376 @noindent
5377 The @code{volatile} keyword indicates that the instruction has
5378 important side-effects.  GCC will not delete a volatile @code{asm} if
5379 it is reachable.  (The instruction can still be deleted if GCC can
5380 prove that control-flow will never reach the location of the
5381 instruction.)  Note that even a volatile @code{asm} instruction
5382 can be moved relative to other code, including across jump
5383 instructions.  For example, on many targets there is a system
5384 register which can be set to control the rounding mode of
5385 floating point operations.  You might try
5386 setting it with a volatile @code{asm}, like this PowerPC example:
5388 @smallexample
5389        asm volatile("mtfsf 255,%0" : : "f" (fpenv));
5390        sum = x + y;
5391 @end smallexample
5393 @noindent
5394 This will not work reliably, as the compiler may move the addition back
5395 before the volatile @code{asm}.  To make it work you need to add an
5396 artificial dependency to the @code{asm} referencing a variable in the code
5397 you don't want moved, for example:
5399 @smallexample
5400     asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
5401     sum = x + y;
5402 @end smallexample
5404 Similarly, you can't expect a
5405 sequence of volatile @code{asm} instructions to remain perfectly
5406 consecutive.  If you want consecutive output, use a single @code{asm}.
5407 Also, GCC will perform some optimizations across a volatile @code{asm}
5408 instruction; GCC does not ``forget everything'' when it encounters
5409 a volatile @code{asm} instruction the way some other compilers do.
5411 An @code{asm} instruction without any output operands will be treated
5412 identically to a volatile @code{asm} instruction.
5414 It is a natural idea to look for a way to give access to the condition
5415 code left by the assembler instruction.  However, when we attempted to
5416 implement this, we found no way to make it work reliably.  The problem
5417 is that output operands might need reloading, which would result in
5418 additional following ``store'' instructions.  On most machines, these
5419 instructions would alter the condition code before there was time to
5420 test it.  This problem doesn't arise for ordinary ``test'' and
5421 ``compare'' instructions because they don't have any output operands.
5423 For reasons similar to those described above, it is not possible to give
5424 an assembler instruction access to the condition code left by previous
5425 instructions.
5427 @anchor{Extended asm with goto}
5428 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
5429 jump to one or more C labels.  In this form, a fifth section after the
5430 clobber list contains a list of all C labels to which the assembly may jump.
5431 Each label operand is implicitly self-named.  The @code{asm} is also assumed
5432 to fall through to the next statement.
5434 This form of @code{asm} is restricted to not have outputs.  This is due
5435 to a internal restriction in the compiler that control transfer instructions
5436 cannot have outputs.  This restriction on @code{asm goto} may be lifted
5437 in some future version of the compiler.  In the mean time, @code{asm goto}
5438 may include a memory clobber, and so leave outputs in memory.
5440 @smallexample
5441 int frob(int x)
5443   int y;
5444   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
5445             : : "r"(x), "r"(&y) : "r5", "memory" : error);
5446   return y;
5447  error:
5448   return -1;
5450 @end smallexample
5452 In this (inefficient) example, the @code{frob} instruction sets the
5453 carry bit to indicate an error.  The @code{jc} instruction detects
5454 this and branches to the @code{error} label.  Finally, the output 
5455 of the @code{frob} instruction (@code{%r5}) is stored into the memory
5456 for variable @code{y}, which is later read by the @code{return} statement.
5458 @smallexample
5459 void doit(void)
5461   int i = 0;
5462   asm goto ("mfsr %%r1, 123; jmp %%r1;"
5463             ".pushsection doit_table;"
5464             ".long %l0, %l1, %l2, %l3;"
5465             ".popsection"
5466             : : : "r1" : label1, label2, label3, label4);
5467   __builtin_unreachable ();
5469  label1:
5470   f1();
5471   return;
5472  label2:
5473   f2();
5474   return;
5475  label3:
5476   i = 1;
5477  label4:
5478   f3(i);
5480 @end smallexample
5482 In this (also inefficient) example, the @code{mfsr} instruction reads
5483 an address from some out-of-band machine register, and the following
5484 @code{jmp} instruction branches to that address.  The address read by
5485 the @code{mfsr} instruction is assumed to have been previously set via
5486 some application-specific mechanism to be one of the four values stored
5487 in the @code{doit_table} section.  Finally, the @code{asm} is followed
5488 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
5489 does not in fact fall through.
5491 @smallexample
5492 #define TRACE1(NUM)                         \
5493   do @{                                      \
5494     asm goto ("0: nop;"                     \
5495               ".pushsection trace_table;"   \
5496               ".long 0b, %l0;"              \
5497               ".popsection"                 \
5498               : : : : trace#NUM);           \
5499     if (0) @{ trace#NUM: trace(); @}          \
5500   @} while (0)
5501 #define TRACE  TRACE1(__COUNTER__)
5502 @end smallexample
5504 In this example (which in fact inspired the @code{asm goto} feature)
5505 we want on rare occasions to call the @code{trace} function; on other
5506 occasions we'd like to keep the overhead to the absolute minimum.
5507 The normal code path consists of a single @code{nop} instruction.
5508 However, we record the address of this @code{nop} together with the
5509 address of a label that calls the @code{trace} function.  This allows
5510 the @code{nop} instruction to be patched at runtime to be an 
5511 unconditional branch to the stored label.  It is assumed that an
5512 optimizing compiler will move the labeled block out of line, to
5513 optimize the fall through path from the @code{asm}.
5515 If you are writing a header file that should be includable in ISO C
5516 programs, write @code{__asm__} instead of @code{asm}.  @xref{Alternate
5517 Keywords}.
5519 @subsection Size of an @code{asm}
5521 Some targets require that GCC track the size of each instruction used in
5522 order to generate correct code.  Because the final length of an
5523 @code{asm} is only known by the assembler, GCC must make an estimate as
5524 to how big it will be.  The estimate is formed by counting the number of
5525 statements in the pattern of the @code{asm} and multiplying that by the
5526 length of the longest instruction on that processor.  Statements in the
5527 @code{asm} are identified by newline characters and whatever statement
5528 separator characters are supported by the assembler; on most processors
5529 this is the `@code{;}' character.
5531 Normally, GCC's estimate is perfectly adequate to ensure that correct
5532 code is generated, but it is possible to confuse the compiler if you use
5533 pseudo instructions or assembler macros that expand into multiple real
5534 instructions or if you use assembler directives that expand to more
5535 space in the object file than would be needed for a single instruction.
5536 If this happens then the assembler will produce a diagnostic saying that
5537 a label is unreachable.
5539 @subsection i386 floating point asm operands
5541 There are several rules on the usage of stack-like regs in
5542 asm_operands insns.  These rules apply only to the operands that are
5543 stack-like regs:
5545 @enumerate
5546 @item
5547 Given a set of input regs that die in an asm_operands, it is
5548 necessary to know which are implicitly popped by the asm, and
5549 which must be explicitly popped by gcc.
5551 An input reg that is implicitly popped by the asm must be
5552 explicitly clobbered, unless it is constrained to match an
5553 output operand.
5555 @item
5556 For any input reg that is implicitly popped by an asm, it is
5557 necessary to know how to adjust the stack to compensate for the pop.
5558 If any non-popped input is closer to the top of the reg-stack than
5559 the implicitly popped reg, it would not be possible to know what the
5560 stack looked like---it's not clear how the rest of the stack ``slides
5561 up''.
5563 All implicitly popped input regs must be closer to the top of
5564 the reg-stack than any input that is not implicitly popped.
5566 It is possible that if an input dies in an insn, reload might
5567 use the input reg for an output reload.  Consider this example:
5569 @smallexample
5570 asm ("foo" : "=t" (a) : "f" (b));
5571 @end smallexample
5573 This asm says that input B is not popped by the asm, and that
5574 the asm pushes a result onto the reg-stack, i.e., the stack is one
5575 deeper after the asm than it was before.  But, it is possible that
5576 reload will think that it can use the same reg for both the input and
5577 the output, if input B dies in this insn.
5579 If any input operand uses the @code{f} constraint, all output reg
5580 constraints must use the @code{&} earlyclobber.
5582 The asm above would be written as
5584 @smallexample
5585 asm ("foo" : "=&t" (a) : "f" (b));
5586 @end smallexample
5588 @item
5589 Some operands need to be in particular places on the stack.  All
5590 output operands fall in this category---there is no other way to
5591 know which regs the outputs appear in unless the user indicates
5592 this in the constraints.
5594 Output operands must specifically indicate which reg an output
5595 appears in after an asm.  @code{=f} is not allowed: the operand
5596 constraints must select a class with a single reg.
5598 @item
5599 Output operands may not be ``inserted'' between existing stack regs.
5600 Since no 387 opcode uses a read/write operand, all output operands
5601 are dead before the asm_operands, and are pushed by the asm_operands.
5602 It makes no sense to push anywhere but the top of the reg-stack.
5604 Output operands must start at the top of the reg-stack: output
5605 operands may not ``skip'' a reg.
5607 @item
5608 Some asm statements may need extra stack space for internal
5609 calculations.  This can be guaranteed by clobbering stack registers
5610 unrelated to the inputs and outputs.
5612 @end enumerate
5614 Here are a couple of reasonable asms to want to write.  This asm
5615 takes one input, which is internally popped, and produces two outputs.
5617 @smallexample
5618 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
5619 @end smallexample
5621 This asm takes two inputs, which are popped by the @code{fyl2xp1} opcode,
5622 and replaces them with one output.  The user must code the @code{st(1)}
5623 clobber for reg-stack.c to know that @code{fyl2xp1} pops both inputs.
5625 @smallexample
5626 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
5627 @end smallexample
5629 @include md.texi
5631 @node Asm Labels
5632 @section Controlling Names Used in Assembler Code
5633 @cindex assembler names for identifiers
5634 @cindex names used in assembler code
5635 @cindex identifiers, names in assembler code
5637 You can specify the name to be used in the assembler code for a C
5638 function or variable by writing the @code{asm} (or @code{__asm__})
5639 keyword after the declarator as follows:
5641 @smallexample
5642 int foo asm ("myfoo") = 2;
5643 @end smallexample
5645 @noindent
5646 This specifies that the name to be used for the variable @code{foo} in
5647 the assembler code should be @samp{myfoo} rather than the usual
5648 @samp{_foo}.
5650 On systems where an underscore is normally prepended to the name of a C
5651 function or variable, this feature allows you to define names for the
5652 linker that do not start with an underscore.
5654 It does not make sense to use this feature with a non-static local
5655 variable since such variables do not have assembler names.  If you are
5656 trying to put the variable in a particular register, see @ref{Explicit
5657 Reg Vars}.  GCC presently accepts such code with a warning, but will
5658 probably be changed to issue an error, rather than a warning, in the
5659 future.
5661 You cannot use @code{asm} in this way in a function @emph{definition}; but
5662 you can get the same effect by writing a declaration for the function
5663 before its definition and putting @code{asm} there, like this:
5665 @smallexample
5666 extern func () asm ("FUNC");
5668 func (x, y)
5669      int x, y;
5670 /* @r{@dots{}} */
5671 @end smallexample
5673 It is up to you to make sure that the assembler names you choose do not
5674 conflict with any other assembler symbols.  Also, you must not use a
5675 register name; that would produce completely invalid assembler code.  GCC
5676 does not as yet have the ability to store static variables in registers.
5677 Perhaps that will be added.
5679 @node Explicit Reg Vars
5680 @section Variables in Specified Registers
5681 @cindex explicit register variables
5682 @cindex variables in specified registers
5683 @cindex specified registers
5684 @cindex registers, global allocation
5686 GNU C allows you to put a few global variables into specified hardware
5687 registers.  You can also specify the register in which an ordinary
5688 register variable should be allocated.
5690 @itemize @bullet
5691 @item
5692 Global register variables reserve registers throughout the program.
5693 This may be useful in programs such as programming language
5694 interpreters which have a couple of global variables that are accessed
5695 very often.
5697 @item
5698 Local register variables in specific registers do not reserve the
5699 registers, except at the point where they are used as input or output
5700 operands in an @code{asm} statement and the @code{asm} statement itself is
5701 not deleted.  The compiler's data flow analysis is capable of determining
5702 where the specified registers contain live values, and where they are
5703 available for other uses.  Stores into local register variables may be deleted
5704 when they appear to be dead according to dataflow analysis.  References
5705 to local register variables may be deleted or moved or simplified.
5707 These local variables are sometimes convenient for use with the extended
5708 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
5709 output of the assembler instruction directly into a particular register.
5710 (This will work provided the register you specify fits the constraints
5711 specified for that operand in the @code{asm}.)
5712 @end itemize
5714 @menu
5715 * Global Reg Vars::
5716 * Local Reg Vars::
5717 @end menu
5719 @node Global Reg Vars
5720 @subsection Defining Global Register Variables
5721 @cindex global register variables
5722 @cindex registers, global variables in
5724 You can define a global register variable in GNU C like this:
5726 @smallexample
5727 register int *foo asm ("a5");
5728 @end smallexample
5730 @noindent
5731 Here @code{a5} is the name of the register which should be used.  Choose a
5732 register which is normally saved and restored by function calls on your
5733 machine, so that library routines will not clobber it.
5735 Naturally the register name is cpu-dependent, so you would need to
5736 conditionalize your program according to cpu type.  The register
5737 @code{a5} would be a good choice on a 68000 for a variable of pointer
5738 type.  On machines with register windows, be sure to choose a ``global''
5739 register that is not affected magically by the function call mechanism.
5741 In addition, operating systems on one type of cpu may differ in how they
5742 name the registers; then you would need additional conditionals.  For
5743 example, some 68000 operating systems call this register @code{%a5}.
5745 Eventually there may be a way of asking the compiler to choose a register
5746 automatically, but first we need to figure out how it should choose and
5747 how to enable you to guide the choice.  No solution is evident.
5749 Defining a global register variable in a certain register reserves that
5750 register entirely for this use, at least within the current compilation.
5751 The register will not be allocated for any other purpose in the functions
5752 in the current compilation.  The register will not be saved and restored by
5753 these functions.  Stores into this register are never deleted even if they
5754 would appear to be dead, but references may be deleted or moved or
5755 simplified.
5757 It is not safe to access the global register variables from signal
5758 handlers, or from more than one thread of control, because the system
5759 library routines may temporarily use the register for other things (unless
5760 you recompile them specially for the task at hand).
5762 @cindex @code{qsort}, and global register variables
5763 It is not safe for one function that uses a global register variable to
5764 call another such function @code{foo} by way of a third function
5765 @code{lose} that was compiled without knowledge of this variable (i.e.@: in a
5766 different source file in which the variable wasn't declared).  This is
5767 because @code{lose} might save the register and put some other value there.
5768 For example, you can't expect a global register variable to be available in
5769 the comparison-function that you pass to @code{qsort}, since @code{qsort}
5770 might have put something else in that register.  (If you are prepared to
5771 recompile @code{qsort} with the same global register variable, you can
5772 solve this problem.)
5774 If you want to recompile @code{qsort} or other source files which do not
5775 actually use your global register variable, so that they will not use that
5776 register for any other purpose, then it suffices to specify the compiler
5777 option @option{-ffixed-@var{reg}}.  You need not actually add a global
5778 register declaration to their source code.
5780 A function which can alter the value of a global register variable cannot
5781 safely be called from a function compiled without this variable, because it
5782 could clobber the value the caller expects to find there on return.
5783 Therefore, the function which is the entry point into the part of the
5784 program that uses the global register variable must explicitly save and
5785 restore the value which belongs to its caller.
5787 @cindex register variable after @code{longjmp}
5788 @cindex global register after @code{longjmp}
5789 @cindex value after @code{longjmp}
5790 @findex longjmp
5791 @findex setjmp
5792 On most machines, @code{longjmp} will restore to each global register
5793 variable the value it had at the time of the @code{setjmp}.  On some
5794 machines, however, @code{longjmp} will not change the value of global
5795 register variables.  To be portable, the function that called @code{setjmp}
5796 should make other arrangements to save the values of the global register
5797 variables, and to restore them in a @code{longjmp}.  This way, the same
5798 thing will happen regardless of what @code{longjmp} does.
5800 All global register variable declarations must precede all function
5801 definitions.  If such a declaration could appear after function
5802 definitions, the declaration would be too late to prevent the register from
5803 being used for other purposes in the preceding functions.
5805 Global register variables may not have initial values, because an
5806 executable file has no means to supply initial contents for a register.
5808 On the SPARC, there are reports that g3 @dots{} g7 are suitable
5809 registers, but certain library functions, such as @code{getwd}, as well
5810 as the subroutines for division and remainder, modify g3 and g4.  g1 and
5811 g2 are local temporaries.
5813 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
5814 Of course, it will not do to use more than a few of those.
5816 @node Local Reg Vars
5817 @subsection Specifying Registers for Local Variables
5818 @cindex local variables, specifying registers
5819 @cindex specifying registers for local variables
5820 @cindex registers for local variables
5822 You can define a local register variable with a specified register
5823 like this:
5825 @smallexample
5826 register int *foo asm ("a5");
5827 @end smallexample
5829 @noindent
5830 Here @code{a5} is the name of the register which should be used.  Note
5831 that this is the same syntax used for defining global register
5832 variables, but for a local variable it would appear within a function.
5834 Naturally the register name is cpu-dependent, but this is not a
5835 problem, since specific registers are most often useful with explicit
5836 assembler instructions (@pxref{Extended Asm}).  Both of these things
5837 generally require that you conditionalize your program according to
5838 cpu type.
5840 In addition, operating systems on one type of cpu may differ in how they
5841 name the registers; then you would need additional conditionals.  For
5842 example, some 68000 operating systems call this register @code{%a5}.
5844 Defining such a register variable does not reserve the register; it
5845 remains available for other uses in places where flow control determines
5846 the variable's value is not live.
5848 This option does not guarantee that GCC will generate code that has
5849 this variable in the register you specify at all times.  You may not
5850 code an explicit reference to this register in the @emph{assembler
5851 instruction template} part of an @code{asm} statement and assume it will
5852 always refer to this variable.  However, using the variable as an
5853 @code{asm} @emph{operand} guarantees that the specified register is used
5854 for the operand.
5856 Stores into local register variables may be deleted when they appear to be dead
5857 according to dataflow analysis.  References to local register variables may
5858 be deleted or moved or simplified.
5860 As for global register variables, it's recommended that you choose a
5861 register which is normally saved and restored by function calls on
5862 your machine, so that library routines will not clobber it.  A common
5863 pitfall is to initialize multiple call-clobbered registers with
5864 arbitrary expressions, where a function call or library call for an
5865 arithmetic operator will overwrite a register value from a previous
5866 assignment, for example @code{r0} below:
5867 @smallexample
5868 register int *p1 asm ("r0") = @dots{};
5869 register int *p2 asm ("r1") = @dots{};
5870 @end smallexample
5871 In those cases, a solution is to use a temporary variable for
5872 each arbitrary expression.   @xref{Example of asm with clobbered asm reg}.
5874 @node Alternate Keywords
5875 @section Alternate Keywords
5876 @cindex alternate keywords
5877 @cindex keywords, alternate
5879 @option{-ansi} and the various @option{-std} options disable certain
5880 keywords.  This causes trouble when you want to use GNU C extensions, or
5881 a general-purpose header file that should be usable by all programs,
5882 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
5883 @code{inline} are not available in programs compiled with
5884 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
5885 program compiled with @option{-std=c99} or @option{-std=c1x}).  The
5886 ISO C99 keyword
5887 @code{restrict} is only available when @option{-std=gnu99} (which will
5888 eventually be the default) or @option{-std=c99} (or the equivalent
5889 @option{-std=iso9899:1999}), or an option for a later standard
5890 version, is used.
5892 The way to solve these problems is to put @samp{__} at the beginning and
5893 end of each problematical keyword.  For example, use @code{__asm__}
5894 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
5896 Other C compilers won't accept these alternative keywords; if you want to
5897 compile with another compiler, you can define the alternate keywords as
5898 macros to replace them with the customary keywords.  It looks like this:
5900 @smallexample
5901 #ifndef __GNUC__
5902 #define __asm__ asm
5903 #endif
5904 @end smallexample
5906 @findex __extension__
5907 @opindex pedantic
5908 @option{-pedantic} and other options cause warnings for many GNU C extensions.
5909 You can
5910 prevent such warnings within one expression by writing
5911 @code{__extension__} before the expression.  @code{__extension__} has no
5912 effect aside from this.
5914 @node Incomplete Enums
5915 @section Incomplete @code{enum} Types
5917 You can define an @code{enum} tag without specifying its possible values.
5918 This results in an incomplete type, much like what you get if you write
5919 @code{struct foo} without describing the elements.  A later declaration
5920 which does specify the possible values completes the type.
5922 You can't allocate variables or storage using the type while it is
5923 incomplete.  However, you can work with pointers to that type.
5925 This extension may not be very useful, but it makes the handling of
5926 @code{enum} more consistent with the way @code{struct} and @code{union}
5927 are handled.
5929 This extension is not supported by GNU C++.
5931 @node Function Names
5932 @section Function Names as Strings
5933 @cindex @code{__func__} identifier
5934 @cindex @code{__FUNCTION__} identifier
5935 @cindex @code{__PRETTY_FUNCTION__} identifier
5937 GCC provides three magic variables which hold the name of the current
5938 function, as a string.  The first of these is @code{__func__}, which
5939 is part of the C99 standard:
5941 The identifier @code{__func__} is implicitly declared by the translator
5942 as if, immediately following the opening brace of each function
5943 definition, the declaration
5945 @smallexample
5946 static const char __func__[] = "function-name";
5947 @end smallexample
5949 @noindent
5950 appeared, where function-name is the name of the lexically-enclosing
5951 function.  This name is the unadorned name of the function.
5953 @code{__FUNCTION__} is another name for @code{__func__}.  Older
5954 versions of GCC recognize only this name.  However, it is not
5955 standardized.  For maximum portability, we recommend you use
5956 @code{__func__}, but provide a fallback definition with the
5957 preprocessor:
5959 @smallexample
5960 #if __STDC_VERSION__ < 199901L
5961 # if __GNUC__ >= 2
5962 #  define __func__ __FUNCTION__
5963 # else
5964 #  define __func__ "<unknown>"
5965 # endif
5966 #endif
5967 @end smallexample
5969 In C, @code{__PRETTY_FUNCTION__} is yet another name for
5970 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
5971 the type signature of the function as well as its bare name.  For
5972 example, this program:
5974 @smallexample
5975 extern "C" @{
5976 extern int printf (char *, ...);
5979 class a @{
5980  public:
5981   void sub (int i)
5982     @{
5983       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
5984       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
5985     @}
5989 main (void)
5991   a ax;
5992   ax.sub (0);
5993   return 0;
5995 @end smallexample
5997 @noindent
5998 gives this output:
6000 @smallexample
6001 __FUNCTION__ = sub
6002 __PRETTY_FUNCTION__ = void a::sub(int)
6003 @end smallexample
6005 These identifiers are not preprocessor macros.  In GCC 3.3 and
6006 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6007 were treated as string literals; they could be used to initialize
6008 @code{char} arrays, and they could be concatenated with other string
6009 literals.  GCC 3.4 and later treat them as variables, like
6010 @code{__func__}.  In C++, @code{__FUNCTION__} and
6011 @code{__PRETTY_FUNCTION__} have always been variables.
6013 @node Return Address
6014 @section Getting the Return or Frame Address of a Function
6016 These functions may be used to get information about the callers of a
6017 function.
6019 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6020 This function returns the return address of the current function, or of
6021 one of its callers.  The @var{level} argument is number of frames to
6022 scan up the call stack.  A value of @code{0} yields the return address
6023 of the current function, a value of @code{1} yields the return address
6024 of the caller of the current function, and so forth.  When inlining
6025 the expected behavior is that the function will return the address of
6026 the function that will be returned to.  To work around this behavior use
6027 the @code{noinline} function attribute.
6029 The @var{level} argument must be a constant integer.
6031 On some machines it may be impossible to determine the return address of
6032 any function other than the current one; in such cases, or when the top
6033 of the stack has been reached, this function will return @code{0} or a
6034 random value.  In addition, @code{__builtin_frame_address} may be used
6035 to determine if the top of the stack has been reached.
6037 Additional post-processing of the returned value may be needed, see
6038 @code{__builtin_extract_return_address}.
6040 This function should only be used with a nonzero argument for debugging
6041 purposes.
6042 @end deftypefn
6044 @deftypefn {Built-in Function} {void *} __builtin_extract_return_address (void *@var{addr})
6045 The address as returned by @code{__builtin_return_address} may have to be fed
6046 through this function to get the actual encoded address.  For example, on the
6047 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6048 platforms an offset has to be added for the true next instruction to be
6049 executed.
6051 If no fixup is needed, this function simply passes through @var{addr}.
6052 @end deftypefn
6054 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6055 This function does the reverse of @code{__builtin_extract_return_address}.
6056 @end deftypefn
6058 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6059 This function is similar to @code{__builtin_return_address}, but it
6060 returns the address of the function frame rather than the return address
6061 of the function.  Calling @code{__builtin_frame_address} with a value of
6062 @code{0} yields the frame address of the current function, a value of
6063 @code{1} yields the frame address of the caller of the current function,
6064 and so forth.
6066 The frame is the area on the stack which holds local variables and saved
6067 registers.  The frame address is normally the address of the first word
6068 pushed on to the stack by the function.  However, the exact definition
6069 depends upon the processor and the calling convention.  If the processor
6070 has a dedicated frame pointer register, and the function has a frame,
6071 then @code{__builtin_frame_address} will return the value of the frame
6072 pointer register.
6074 On some machines it may be impossible to determine the frame address of
6075 any function other than the current one; in such cases, or when the top
6076 of the stack has been reached, this function will return @code{0} if
6077 the first frame pointer is properly initialized by the startup code.
6079 This function should only be used with a nonzero argument for debugging
6080 purposes.
6081 @end deftypefn
6083 @node Vector Extensions
6084 @section Using vector instructions through built-in functions
6086 On some targets, the instruction set contains SIMD vector instructions that
6087 operate on multiple values contained in one large register at the same time.
6088 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
6089 this way.
6091 The first step in using these extensions is to provide the necessary data
6092 types.  This should be done using an appropriate @code{typedef}:
6094 @smallexample
6095 typedef int v4si __attribute__ ((vector_size (16)));
6096 @end smallexample
6098 The @code{int} type specifies the base type, while the attribute specifies
6099 the vector size for the variable, measured in bytes.  For example, the
6100 declaration above causes the compiler to set the mode for the @code{v4si}
6101 type to be 16 bytes wide and divided into @code{int} sized units.  For
6102 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
6103 corresponding mode of @code{foo} will be @acronym{V4SI}.
6105 The @code{vector_size} attribute is only applicable to integral and
6106 float scalars, although arrays, pointers, and function return values
6107 are allowed in conjunction with this construct.
6109 All the basic integer types can be used as base types, both as signed
6110 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
6111 @code{long long}.  In addition, @code{float} and @code{double} can be
6112 used to build floating-point vector types.
6114 Specifying a combination that is not valid for the current architecture
6115 will cause GCC to synthesize the instructions using a narrower mode.
6116 For example, if you specify a variable of type @code{V4SI} and your
6117 architecture does not allow for this specific SIMD type, GCC will
6118 produce code that uses 4 @code{SIs}.
6120 The types defined in this manner can be used with a subset of normal C
6121 operations.  Currently, GCC will allow using the following operators
6122 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
6124 The operations behave like C++ @code{valarrays}.  Addition is defined as
6125 the addition of the corresponding elements of the operands.  For
6126 example, in the code below, each of the 4 elements in @var{a} will be
6127 added to the corresponding 4 elements in @var{b} and the resulting
6128 vector will be stored in @var{c}.
6130 @smallexample
6131 typedef int v4si __attribute__ ((vector_size (16)));
6133 v4si a, b, c;
6135 c = a + b;
6136 @end smallexample
6138 Subtraction, multiplication, division, and the logical operations
6139 operate in a similar manner.  Likewise, the result of using the unary
6140 minus or complement operators on a vector type is a vector whose
6141 elements are the negative or complemented values of the corresponding
6142 elements in the operand.
6144 You can declare variables and use them in function calls and returns, as
6145 well as in assignments and some casts.  You can specify a vector type as
6146 a return type for a function.  Vector types can also be used as function
6147 arguments.  It is possible to cast from one vector type to another,
6148 provided they are of the same size (in fact, you can also cast vectors
6149 to and from other datatypes of the same size).
6151 You cannot operate between vectors of different lengths or different
6152 signedness without a cast.
6154 A port that supports hardware vector operations, usually provides a set
6155 of built-in functions that can be used to operate on vectors.  For
6156 example, a function to add two vectors and multiply the result by a
6157 third could look like this:
6159 @smallexample
6160 v4si f (v4si a, v4si b, v4si c)
6162   v4si tmp = __builtin_addv4si (a, b);
6163   return __builtin_mulv4si (tmp, c);
6166 @end smallexample
6168 @node Offsetof
6169 @section Offsetof
6170 @findex __builtin_offsetof
6172 GCC implements for both C and C++ a syntactic extension to implement
6173 the @code{offsetof} macro.
6175 @smallexample
6176 primary:
6177         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
6179 offsetof_member_designator:
6180           @code{identifier}
6181         | offsetof_member_designator "." @code{identifier}
6182         | offsetof_member_designator "[" @code{expr} "]"
6183 @end smallexample
6185 This extension is sufficient such that
6187 @smallexample
6188 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
6189 @end smallexample
6191 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
6192 may be dependent.  In either case, @var{member} may consist of a single
6193 identifier, or a sequence of member accesses and array references.
6195 @node Atomic Builtins
6196 @section Built-in functions for atomic memory access
6198 The following builtins are intended to be compatible with those described
6199 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
6200 section 7.4.  As such, they depart from the normal GCC practice of using
6201 the ``__builtin_'' prefix, and further that they are overloaded such that
6202 they work on multiple types.
6204 The definition given in the Intel documentation allows only for the use of
6205 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
6206 counterparts.  GCC will allow any integral scalar or pointer type that is
6207 1, 2, 4 or 8 bytes in length.
6209 Not all operations are supported by all target processors.  If a particular
6210 operation cannot be implemented on the target processor, a warning will be
6211 generated and a call an external function will be generated.  The external
6212 function will carry the same name as the builtin, with an additional suffix
6213 @samp{_@var{n}} where @var{n} is the size of the data type.
6215 @c ??? Should we have a mechanism to suppress this warning?  This is almost
6216 @c useful for implementing the operation under the control of an external
6217 @c mutex.
6219 In most cases, these builtins are considered a @dfn{full barrier}.  That is,
6220 no memory operand will be moved across the operation, either forward or
6221 backward.  Further, instructions will be issued as necessary to prevent the
6222 processor from speculating loads across the operation and from queuing stores
6223 after the operation.
6225 All of the routines are described in the Intel documentation to take
6226 ``an optional list of variables protected by the memory barrier''.  It's
6227 not clear what is meant by that; it could mean that @emph{only} the
6228 following variables are protected, or it could mean that these variables
6229 should in addition be protected.  At present GCC ignores this list and
6230 protects all variables which are globally accessible.  If in the future
6231 we make some use of this list, an empty list will continue to mean all
6232 globally accessible variables.
6234 @table @code
6235 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
6236 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
6237 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
6238 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
6239 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
6240 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
6241 @findex __sync_fetch_and_add
6242 @findex __sync_fetch_and_sub
6243 @findex __sync_fetch_and_or
6244 @findex __sync_fetch_and_and
6245 @findex __sync_fetch_and_xor
6246 @findex __sync_fetch_and_nand
6247 These builtins perform the operation suggested by the name, and
6248 returns the value that had previously been in memory.  That is,
6250 @smallexample
6251 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
6252 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
6253 @end smallexample
6255 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
6256 builtin as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
6258 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
6259 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
6260 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
6261 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
6262 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
6263 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
6264 @findex __sync_add_and_fetch
6265 @findex __sync_sub_and_fetch
6266 @findex __sync_or_and_fetch
6267 @findex __sync_and_and_fetch
6268 @findex __sync_xor_and_fetch
6269 @findex __sync_nand_and_fetch
6270 These builtins perform the operation suggested by the name, and
6271 return the new value.  That is,
6273 @smallexample
6274 @{ *ptr @var{op}= value; return *ptr; @}
6275 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
6276 @end smallexample
6278 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
6279 builtin as @code{*ptr = ~(*ptr & value)} instead of
6280 @code{*ptr = ~*ptr & value}.
6282 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval @var{type} newval, ...)
6283 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval @var{type} newval, ...)
6284 @findex __sync_bool_compare_and_swap
6285 @findex __sync_val_compare_and_swap
6286 These builtins perform an atomic compare and swap.  That is, if the current
6287 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
6288 @code{*@var{ptr}}.
6290 The ``bool'' version returns true if the comparison is successful and
6291 @var{newval} was written.  The ``val'' version returns the contents
6292 of @code{*@var{ptr}} before the operation.
6294 @item __sync_synchronize (...)
6295 @findex __sync_synchronize
6296 This builtin issues a full memory barrier.
6298 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
6299 @findex __sync_lock_test_and_set
6300 This builtin, as described by Intel, is not a traditional test-and-set
6301 operation, but rather an atomic exchange operation.  It writes @var{value}
6302 into @code{*@var{ptr}}, and returns the previous contents of
6303 @code{*@var{ptr}}.
6305 Many targets have only minimal support for such locks, and do not support
6306 a full exchange operation.  In this case, a target may support reduced
6307 functionality here by which the @emph{only} valid value to store is the
6308 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
6309 is implementation defined.
6311 This builtin is not a full barrier, but rather an @dfn{acquire barrier}.
6312 This means that references after the builtin cannot move to (or be
6313 speculated to) before the builtin, but previous memory stores may not
6314 be globally visible yet, and previous memory loads may not yet be
6315 satisfied.
6317 @item void __sync_lock_release (@var{type} *ptr, ...)
6318 @findex __sync_lock_release
6319 This builtin releases the lock acquired by @code{__sync_lock_test_and_set}.
6320 Normally this means writing the constant 0 to @code{*@var{ptr}}.
6322 This builtin is not a full barrier, but rather a @dfn{release barrier}.
6323 This means that all previous memory stores are globally visible, and all
6324 previous memory loads have been satisfied, but following memory reads
6325 are not prevented from being speculated to before the barrier.
6326 @end table
6328 @node Object Size Checking
6329 @section Object Size Checking Builtins
6330 @findex __builtin_object_size
6331 @findex __builtin___memcpy_chk
6332 @findex __builtin___mempcpy_chk
6333 @findex __builtin___memmove_chk
6334 @findex __builtin___memset_chk
6335 @findex __builtin___strcpy_chk
6336 @findex __builtin___stpcpy_chk
6337 @findex __builtin___strncpy_chk
6338 @findex __builtin___strcat_chk
6339 @findex __builtin___strncat_chk
6340 @findex __builtin___sprintf_chk
6341 @findex __builtin___snprintf_chk
6342 @findex __builtin___vsprintf_chk
6343 @findex __builtin___vsnprintf_chk
6344 @findex __builtin___printf_chk
6345 @findex __builtin___vprintf_chk
6346 @findex __builtin___fprintf_chk
6347 @findex __builtin___vfprintf_chk
6349 GCC implements a limited buffer overflow protection mechanism
6350 that can prevent some buffer overflow attacks.
6352 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
6353 is a built-in construct that returns a constant number of bytes from
6354 @var{ptr} to the end of the object @var{ptr} pointer points to
6355 (if known at compile time).  @code{__builtin_object_size} never evaluates
6356 its arguments for side-effects.  If there are any side-effects in them, it
6357 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
6358 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
6359 point to and all of them are known at compile time, the returned number
6360 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
6361 0 and minimum if nonzero.  If it is not possible to determine which objects
6362 @var{ptr} points to at compile time, @code{__builtin_object_size} should
6363 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
6364 for @var{type} 2 or 3.
6366 @var{type} is an integer constant from 0 to 3.  If the least significant
6367 bit is clear, objects are whole variables, if it is set, a closest
6368 surrounding subobject is considered the object a pointer points to.
6369 The second bit determines if maximum or minimum of remaining bytes
6370 is computed.
6372 @smallexample
6373 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
6374 char *p = &var.buf1[1], *q = &var.b;
6376 /* Here the object p points to is var.  */
6377 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
6378 /* The subobject p points to is var.buf1.  */
6379 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
6380 /* The object q points to is var.  */
6381 assert (__builtin_object_size (q, 0)
6382         == (char *) (&var + 1) - (char *) &var.b);
6383 /* The subobject q points to is var.b.  */
6384 assert (__builtin_object_size (q, 1) == sizeof (var.b));
6385 @end smallexample
6386 @end deftypefn
6388 There are built-in functions added for many common string operation
6389 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
6390 built-in is provided.  This built-in has an additional last argument,
6391 which is the number of bytes remaining in object the @var{dest}
6392 argument points to or @code{(size_t) -1} if the size is not known.
6394 The built-in functions are optimized into the normal string functions
6395 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
6396 it is known at compile time that the destination object will not
6397 be overflown.  If the compiler can determine at compile time the
6398 object will be always overflown, it issues a warning.
6400 The intended use can be e.g.
6402 @smallexample
6403 #undef memcpy
6404 #define bos0(dest) __builtin_object_size (dest, 0)
6405 #define memcpy(dest, src, n) \
6406   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
6408 char *volatile p;
6409 char buf[10];
6410 /* It is unknown what object p points to, so this is optimized
6411    into plain memcpy - no checking is possible.  */
6412 memcpy (p, "abcde", n);
6413 /* Destination is known and length too.  It is known at compile
6414    time there will be no overflow.  */
6415 memcpy (&buf[5], "abcde", 5);
6416 /* Destination is known, but the length is not known at compile time.
6417    This will result in __memcpy_chk call that can check for overflow
6418    at runtime.  */
6419 memcpy (&buf[5], "abcde", n);
6420 /* Destination is known and it is known at compile time there will
6421    be overflow.  There will be a warning and __memcpy_chk call that
6422    will abort the program at runtime.  */
6423 memcpy (&buf[6], "abcde", 5);
6424 @end smallexample
6426 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
6427 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
6428 @code{strcat} and @code{strncat}.
6430 There are also checking built-in functions for formatted output functions.
6431 @smallexample
6432 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
6433 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
6434                               const char *fmt, ...);
6435 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
6436                               va_list ap);
6437 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
6438                                const char *fmt, va_list ap);
6439 @end smallexample
6441 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
6442 etc.@: functions and can contain implementation specific flags on what
6443 additional security measures the checking function might take, such as
6444 handling @code{%n} differently.
6446 The @var{os} argument is the object size @var{s} points to, like in the
6447 other built-in functions.  There is a small difference in the behavior
6448 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
6449 optimized into the non-checking functions only if @var{flag} is 0, otherwise
6450 the checking function is called with @var{os} argument set to
6451 @code{(size_t) -1}.
6453 In addition to this, there are checking built-in functions
6454 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
6455 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
6456 These have just one additional argument, @var{flag}, right before
6457 format string @var{fmt}.  If the compiler is able to optimize them to
6458 @code{fputc} etc.@: functions, it will, otherwise the checking function
6459 should be called and the @var{flag} argument passed to it.
6461 @node Other Builtins
6462 @section Other built-in functions provided by GCC
6463 @cindex built-in functions
6464 @findex __builtin_fpclassify
6465 @findex __builtin_isfinite
6466 @findex __builtin_isnormal
6467 @findex __builtin_isgreater
6468 @findex __builtin_isgreaterequal
6469 @findex __builtin_isinf_sign
6470 @findex __builtin_isless
6471 @findex __builtin_islessequal
6472 @findex __builtin_islessgreater
6473 @findex __builtin_isunordered
6474 @findex __builtin_powi
6475 @findex __builtin_powif
6476 @findex __builtin_powil
6477 @findex _Exit
6478 @findex _exit
6479 @findex abort
6480 @findex abs
6481 @findex acos
6482 @findex acosf
6483 @findex acosh
6484 @findex acoshf
6485 @findex acoshl
6486 @findex acosl
6487 @findex alloca
6488 @findex asin
6489 @findex asinf
6490 @findex asinh
6491 @findex asinhf
6492 @findex asinhl
6493 @findex asinl
6494 @findex atan
6495 @findex atan2
6496 @findex atan2f
6497 @findex atan2l
6498 @findex atanf
6499 @findex atanh
6500 @findex atanhf
6501 @findex atanhl
6502 @findex atanl
6503 @findex bcmp
6504 @findex bzero
6505 @findex cabs
6506 @findex cabsf
6507 @findex cabsl
6508 @findex cacos
6509 @findex cacosf
6510 @findex cacosh
6511 @findex cacoshf
6512 @findex cacoshl
6513 @findex cacosl
6514 @findex calloc
6515 @findex carg
6516 @findex cargf
6517 @findex cargl
6518 @findex casin
6519 @findex casinf
6520 @findex casinh
6521 @findex casinhf
6522 @findex casinhl
6523 @findex casinl
6524 @findex catan
6525 @findex catanf
6526 @findex catanh
6527 @findex catanhf
6528 @findex catanhl
6529 @findex catanl
6530 @findex cbrt
6531 @findex cbrtf
6532 @findex cbrtl
6533 @findex ccos
6534 @findex ccosf
6535 @findex ccosh
6536 @findex ccoshf
6537 @findex ccoshl
6538 @findex ccosl
6539 @findex ceil
6540 @findex ceilf
6541 @findex ceill
6542 @findex cexp
6543 @findex cexpf
6544 @findex cexpl
6545 @findex cimag
6546 @findex cimagf
6547 @findex cimagl
6548 @findex clog
6549 @findex clogf
6550 @findex clogl
6551 @findex conj
6552 @findex conjf
6553 @findex conjl
6554 @findex copysign
6555 @findex copysignf
6556 @findex copysignl
6557 @findex cos
6558 @findex cosf
6559 @findex cosh
6560 @findex coshf
6561 @findex coshl
6562 @findex cosl
6563 @findex cpow
6564 @findex cpowf
6565 @findex cpowl
6566 @findex cproj
6567 @findex cprojf
6568 @findex cprojl
6569 @findex creal
6570 @findex crealf
6571 @findex creall
6572 @findex csin
6573 @findex csinf
6574 @findex csinh
6575 @findex csinhf
6576 @findex csinhl
6577 @findex csinl
6578 @findex csqrt
6579 @findex csqrtf
6580 @findex csqrtl
6581 @findex ctan
6582 @findex ctanf
6583 @findex ctanh
6584 @findex ctanhf
6585 @findex ctanhl
6586 @findex ctanl
6587 @findex dcgettext
6588 @findex dgettext
6589 @findex drem
6590 @findex dremf
6591 @findex dreml
6592 @findex erf
6593 @findex erfc
6594 @findex erfcf
6595 @findex erfcl
6596 @findex erff
6597 @findex erfl
6598 @findex exit
6599 @findex exp
6600 @findex exp10
6601 @findex exp10f
6602 @findex exp10l
6603 @findex exp2
6604 @findex exp2f
6605 @findex exp2l
6606 @findex expf
6607 @findex expl
6608 @findex expm1
6609 @findex expm1f
6610 @findex expm1l
6611 @findex fabs
6612 @findex fabsf
6613 @findex fabsl
6614 @findex fdim
6615 @findex fdimf
6616 @findex fdiml
6617 @findex ffs
6618 @findex floor
6619 @findex floorf
6620 @findex floorl
6621 @findex fma
6622 @findex fmaf
6623 @findex fmal
6624 @findex fmax
6625 @findex fmaxf
6626 @findex fmaxl
6627 @findex fmin
6628 @findex fminf
6629 @findex fminl
6630 @findex fmod
6631 @findex fmodf
6632 @findex fmodl
6633 @findex fprintf
6634 @findex fprintf_unlocked
6635 @findex fputs
6636 @findex fputs_unlocked
6637 @findex frexp
6638 @findex frexpf
6639 @findex frexpl
6640 @findex fscanf
6641 @findex gamma
6642 @findex gammaf
6643 @findex gammal
6644 @findex gamma_r
6645 @findex gammaf_r
6646 @findex gammal_r
6647 @findex gettext
6648 @findex hypot
6649 @findex hypotf
6650 @findex hypotl
6651 @findex ilogb
6652 @findex ilogbf
6653 @findex ilogbl
6654 @findex imaxabs
6655 @findex index
6656 @findex isalnum
6657 @findex isalpha
6658 @findex isascii
6659 @findex isblank
6660 @findex iscntrl
6661 @findex isdigit
6662 @findex isgraph
6663 @findex islower
6664 @findex isprint
6665 @findex ispunct
6666 @findex isspace
6667 @findex isupper
6668 @findex iswalnum
6669 @findex iswalpha
6670 @findex iswblank
6671 @findex iswcntrl
6672 @findex iswdigit
6673 @findex iswgraph
6674 @findex iswlower
6675 @findex iswprint
6676 @findex iswpunct
6677 @findex iswspace
6678 @findex iswupper
6679 @findex iswxdigit
6680 @findex isxdigit
6681 @findex j0
6682 @findex j0f
6683 @findex j0l
6684 @findex j1
6685 @findex j1f
6686 @findex j1l
6687 @findex jn
6688 @findex jnf
6689 @findex jnl
6690 @findex labs
6691 @findex ldexp
6692 @findex ldexpf
6693 @findex ldexpl
6694 @findex lgamma
6695 @findex lgammaf
6696 @findex lgammal
6697 @findex lgamma_r
6698 @findex lgammaf_r
6699 @findex lgammal_r
6700 @findex llabs
6701 @findex llrint
6702 @findex llrintf
6703 @findex llrintl
6704 @findex llround
6705 @findex llroundf
6706 @findex llroundl
6707 @findex log
6708 @findex log10
6709 @findex log10f
6710 @findex log10l
6711 @findex log1p
6712 @findex log1pf
6713 @findex log1pl
6714 @findex log2
6715 @findex log2f
6716 @findex log2l
6717 @findex logb
6718 @findex logbf
6719 @findex logbl
6720 @findex logf
6721 @findex logl
6722 @findex lrint
6723 @findex lrintf
6724 @findex lrintl
6725 @findex lround
6726 @findex lroundf
6727 @findex lroundl
6728 @findex malloc
6729 @findex memchr
6730 @findex memcmp
6731 @findex memcpy
6732 @findex mempcpy
6733 @findex memset
6734 @findex modf
6735 @findex modff
6736 @findex modfl
6737 @findex nearbyint
6738 @findex nearbyintf
6739 @findex nearbyintl
6740 @findex nextafter
6741 @findex nextafterf
6742 @findex nextafterl
6743 @findex nexttoward
6744 @findex nexttowardf
6745 @findex nexttowardl
6746 @findex pow
6747 @findex pow10
6748 @findex pow10f
6749 @findex pow10l
6750 @findex powf
6751 @findex powl
6752 @findex printf
6753 @findex printf_unlocked
6754 @findex putchar
6755 @findex puts
6756 @findex remainder
6757 @findex remainderf
6758 @findex remainderl
6759 @findex remquo
6760 @findex remquof
6761 @findex remquol
6762 @findex rindex
6763 @findex rint
6764 @findex rintf
6765 @findex rintl
6766 @findex round
6767 @findex roundf
6768 @findex roundl
6769 @findex scalb
6770 @findex scalbf
6771 @findex scalbl
6772 @findex scalbln
6773 @findex scalblnf
6774 @findex scalblnf
6775 @findex scalbn
6776 @findex scalbnf
6777 @findex scanfnl
6778 @findex signbit
6779 @findex signbitf
6780 @findex signbitl
6781 @findex signbitd32
6782 @findex signbitd64
6783 @findex signbitd128
6784 @findex significand
6785 @findex significandf
6786 @findex significandl
6787 @findex sin
6788 @findex sincos
6789 @findex sincosf
6790 @findex sincosl
6791 @findex sinf
6792 @findex sinh
6793 @findex sinhf
6794 @findex sinhl
6795 @findex sinl
6796 @findex snprintf
6797 @findex sprintf
6798 @findex sqrt
6799 @findex sqrtf
6800 @findex sqrtl
6801 @findex sscanf
6802 @findex stpcpy
6803 @findex stpncpy
6804 @findex strcasecmp
6805 @findex strcat
6806 @findex strchr
6807 @findex strcmp
6808 @findex strcpy
6809 @findex strcspn
6810 @findex strdup
6811 @findex strfmon
6812 @findex strftime
6813 @findex strlen
6814 @findex strncasecmp
6815 @findex strncat
6816 @findex strncmp
6817 @findex strncpy
6818 @findex strndup
6819 @findex strpbrk
6820 @findex strrchr
6821 @findex strspn
6822 @findex strstr
6823 @findex tan
6824 @findex tanf
6825 @findex tanh
6826 @findex tanhf
6827 @findex tanhl
6828 @findex tanl
6829 @findex tgamma
6830 @findex tgammaf
6831 @findex tgammal
6832 @findex toascii
6833 @findex tolower
6834 @findex toupper
6835 @findex towlower
6836 @findex towupper
6837 @findex trunc
6838 @findex truncf
6839 @findex truncl
6840 @findex vfprintf
6841 @findex vfscanf
6842 @findex vprintf
6843 @findex vscanf
6844 @findex vsnprintf
6845 @findex vsprintf
6846 @findex vsscanf
6847 @findex y0
6848 @findex y0f
6849 @findex y0l
6850 @findex y1
6851 @findex y1f
6852 @findex y1l
6853 @findex yn
6854 @findex ynf
6855 @findex ynl
6857 GCC provides a large number of built-in functions other than the ones
6858 mentioned above.  Some of these are for internal use in the processing
6859 of exceptions or variable-length argument lists and will not be
6860 documented here because they may change from time to time; we do not
6861 recommend general use of these functions.
6863 The remaining functions are provided for optimization purposes.
6865 @opindex fno-builtin
6866 GCC includes built-in versions of many of the functions in the standard
6867 C library.  The versions prefixed with @code{__builtin_} will always be
6868 treated as having the same meaning as the C library function even if you
6869 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
6870 Many of these functions are only optimized in certain cases; if they are
6871 not optimized in a particular case, a call to the library function will
6872 be emitted.
6874 @opindex ansi
6875 @opindex std
6876 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
6877 @option{-std=c99} or @option{-std=c1x}), the functions
6878 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
6879 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
6880 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
6881 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
6882 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
6883 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
6884 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
6885 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
6886 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
6887 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
6888 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
6889 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
6890 @code{signbitd64}, @code{signbitd128}, @code{significandf},
6891 @code{significandl}, @code{significand}, @code{sincosf},
6892 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
6893 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
6894 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
6895 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
6896 @code{yn}
6897 may be handled as built-in functions.
6898 All these functions have corresponding versions
6899 prefixed with @code{__builtin_}, which may be used even in strict C90
6900 mode.
6902 The ISO C99 functions
6903 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
6904 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
6905 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
6906 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
6907 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
6908 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
6909 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
6910 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
6911 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
6912 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
6913 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
6914 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
6915 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
6916 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
6917 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
6918 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
6919 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
6920 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
6921 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
6922 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
6923 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
6924 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
6925 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
6926 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
6927 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
6928 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
6929 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
6930 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
6931 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
6932 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
6933 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
6934 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
6935 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
6936 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
6937 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
6938 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
6939 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
6940 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
6941 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
6942 are handled as built-in functions
6943 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
6945 There are also built-in versions of the ISO C99 functions
6946 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
6947 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
6948 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
6949 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
6950 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
6951 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
6952 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
6953 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
6954 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
6955 that are recognized in any mode since ISO C90 reserves these names for
6956 the purpose to which ISO C99 puts them.  All these functions have
6957 corresponding versions prefixed with @code{__builtin_}.
6959 The ISO C94 functions
6960 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
6961 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
6962 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
6963 @code{towupper}
6964 are handled as built-in functions
6965 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
6967 The ISO C90 functions
6968 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
6969 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
6970 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
6971 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
6972 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
6973 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
6974 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
6975 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
6976 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
6977 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
6978 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
6979 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
6980 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
6981 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
6982 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
6983 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
6984 are all recognized as built-in functions unless
6985 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
6986 is specified for an individual function).  All of these functions have
6987 corresponding versions prefixed with @code{__builtin_}.
6989 GCC provides built-in versions of the ISO C99 floating point comparison
6990 macros that avoid raising exceptions for unordered operands.  They have
6991 the same names as the standard macros ( @code{isgreater},
6992 @code{isgreaterequal}, @code{isless}, @code{islessequal},
6993 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
6994 prefixed.  We intend for a library implementor to be able to simply
6995 @code{#define} each standard macro to its built-in equivalent.
6996 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
6997 @code{isinf_sign} and @code{isnormal} built-ins used with
6998 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
6999 builtins appear both with and without the @code{__builtin_} prefix.
7001 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
7003 You can use the built-in function @code{__builtin_types_compatible_p} to
7004 determine whether two types are the same.
7006 This built-in function returns 1 if the unqualified versions of the
7007 types @var{type1} and @var{type2} (which are types, not expressions) are
7008 compatible, 0 otherwise.  The result of this built-in function can be
7009 used in integer constant expressions.
7011 This built-in function ignores top level qualifiers (e.g., @code{const},
7012 @code{volatile}).  For example, @code{int} is equivalent to @code{const
7013 int}.
7015 The type @code{int[]} and @code{int[5]} are compatible.  On the other
7016 hand, @code{int} and @code{char *} are not compatible, even if the size
7017 of their types, on the particular architecture are the same.  Also, the
7018 amount of pointer indirection is taken into account when determining
7019 similarity.  Consequently, @code{short *} is not similar to
7020 @code{short **}.  Furthermore, two types that are typedefed are
7021 considered compatible if their underlying types are compatible.
7023 An @code{enum} type is not considered to be compatible with another
7024 @code{enum} type even if both are compatible with the same integer
7025 type; this is what the C standard specifies.
7026 For example, @code{enum @{foo, bar@}} is not similar to
7027 @code{enum @{hot, dog@}}.
7029 You would typically use this function in code whose execution varies
7030 depending on the arguments' types.  For example:
7032 @smallexample
7033 #define foo(x)                                                  \
7034   (@{                                                           \
7035     typeof (x) tmp = (x);                                       \
7036     if (__builtin_types_compatible_p (typeof (x), long double)) \
7037       tmp = foo_long_double (tmp);                              \
7038     else if (__builtin_types_compatible_p (typeof (x), double)) \
7039       tmp = foo_double (tmp);                                   \
7040     else if (__builtin_types_compatible_p (typeof (x), float))  \
7041       tmp = foo_float (tmp);                                    \
7042     else                                                        \
7043       abort ();                                                 \
7044     tmp;                                                        \
7045   @})
7046 @end smallexample
7048 @emph{Note:} This construct is only available for C@.
7050 @end deftypefn
7052 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
7054 You can use the built-in function @code{__builtin_choose_expr} to
7055 evaluate code depending on the value of a constant expression.  This
7056 built-in function returns @var{exp1} if @var{const_exp}, which is an
7057 integer constant expression, is nonzero.  Otherwise it returns 0.
7059 This built-in function is analogous to the @samp{? :} operator in C,
7060 except that the expression returned has its type unaltered by promotion
7061 rules.  Also, the built-in function does not evaluate the expression
7062 that was not chosen.  For example, if @var{const_exp} evaluates to true,
7063 @var{exp2} is not evaluated even if it has side-effects.
7065 This built-in function can return an lvalue if the chosen argument is an
7066 lvalue.
7068 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
7069 type.  Similarly, if @var{exp2} is returned, its return type is the same
7070 as @var{exp2}.
7072 Example:
7074 @smallexample
7075 #define foo(x)                                                    \
7076   __builtin_choose_expr (                                         \
7077     __builtin_types_compatible_p (typeof (x), double),            \
7078     foo_double (x),                                               \
7079     __builtin_choose_expr (                                       \
7080       __builtin_types_compatible_p (typeof (x), float),           \
7081       foo_float (x),                                              \
7082       /* @r{The void expression results in a compile-time error}  \
7083          @r{when assigning the result to something.}  */          \
7084       (void)0))
7085 @end smallexample
7087 @emph{Note:} This construct is only available for C@.  Furthermore, the
7088 unused expression (@var{exp1} or @var{exp2} depending on the value of
7089 @var{const_exp}) may still generate syntax errors.  This may change in
7090 future revisions.
7092 @end deftypefn
7094 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
7095 You can use the built-in function @code{__builtin_constant_p} to
7096 determine if a value is known to be constant at compile-time and hence
7097 that GCC can perform constant-folding on expressions involving that
7098 value.  The argument of the function is the value to test.  The function
7099 returns the integer 1 if the argument is known to be a compile-time
7100 constant and 0 if it is not known to be a compile-time constant.  A
7101 return of 0 does not indicate that the value is @emph{not} a constant,
7102 but merely that GCC cannot prove it is a constant with the specified
7103 value of the @option{-O} option.
7105 You would typically use this function in an embedded application where
7106 memory was a critical resource.  If you have some complex calculation,
7107 you may want it to be folded if it involves constants, but need to call
7108 a function if it does not.  For example:
7110 @smallexample
7111 #define Scale_Value(X)      \
7112   (__builtin_constant_p (X) \
7113   ? ((X) * SCALE + OFFSET) : Scale (X))
7114 @end smallexample
7116 You may use this built-in function in either a macro or an inline
7117 function.  However, if you use it in an inlined function and pass an
7118 argument of the function as the argument to the built-in, GCC will
7119 never return 1 when you call the inline function with a string constant
7120 or compound literal (@pxref{Compound Literals}) and will not return 1
7121 when you pass a constant numeric value to the inline function unless you
7122 specify the @option{-O} option.
7124 You may also use @code{__builtin_constant_p} in initializers for static
7125 data.  For instance, you can write
7127 @smallexample
7128 static const int table[] = @{
7129    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
7130    /* @r{@dots{}} */
7132 @end smallexample
7134 @noindent
7135 This is an acceptable initializer even if @var{EXPRESSION} is not a
7136 constant expression, including the case where
7137 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
7138 folded to a constant but @var{EXPRESSION} contains operands that would
7139 not otherwise be permitted in a static initializer (for example,
7140 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
7141 built-in in this case, because it has no opportunity to perform
7142 optimization.
7144 Previous versions of GCC did not accept this built-in in data
7145 initializers.  The earliest version where it is completely safe is
7146 3.0.1.
7147 @end deftypefn
7149 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
7150 @opindex fprofile-arcs
7151 You may use @code{__builtin_expect} to provide the compiler with
7152 branch prediction information.  In general, you should prefer to
7153 use actual profile feedback for this (@option{-fprofile-arcs}), as
7154 programmers are notoriously bad at predicting how their programs
7155 actually perform.  However, there are applications in which this
7156 data is hard to collect.
7158 The return value is the value of @var{exp}, which should be an integral
7159 expression.  The semantics of the built-in are that it is expected that
7160 @var{exp} == @var{c}.  For example:
7162 @smallexample
7163 if (__builtin_expect (x, 0))
7164   foo ();
7165 @end smallexample
7167 @noindent
7168 would indicate that we do not expect to call @code{foo}, since
7169 we expect @code{x} to be zero.  Since you are limited to integral
7170 expressions for @var{exp}, you should use constructions such as
7172 @smallexample
7173 if (__builtin_expect (ptr != NULL, 1))
7174   error ();
7175 @end smallexample
7177 @noindent
7178 when testing pointer or floating-point values.
7179 @end deftypefn
7181 @deftypefn {Built-in Function} void __builtin_trap (void)
7182 This function causes the program to exit abnormally.  GCC implements
7183 this function by using a target-dependent mechanism (such as
7184 intentionally executing an illegal instruction) or by calling
7185 @code{abort}.  The mechanism used may vary from release to release so
7186 you should not rely on any particular implementation.
7187 @end deftypefn
7189 @deftypefn {Built-in Function} void __builtin_unreachable (void)
7190 If control flow reaches the point of the @code{__builtin_unreachable},
7191 the program is undefined.  It is useful in situations where the
7192 compiler cannot deduce the unreachability of the code.
7194 One such case is immediately following an @code{asm} statement that
7195 will either never terminate, or one that transfers control elsewhere
7196 and never returns.  In this example, without the
7197 @code{__builtin_unreachable}, GCC would issue a warning that control
7198 reaches the end of a non-void function.  It would also generate code
7199 to return after the @code{asm}.
7201 @smallexample
7202 int f (int c, int v)
7204   if (c)
7205     @{
7206       return v;
7207     @}
7208   else
7209     @{
7210       asm("jmp error_handler");
7211       __builtin_unreachable ();
7212     @}
7214 @end smallexample
7216 Because the @code{asm} statement unconditionally transfers control out
7217 of the function, control will never reach the end of the function
7218 body.  The @code{__builtin_unreachable} is in fact unreachable and
7219 communicates this fact to the compiler.
7221 Another use for @code{__builtin_unreachable} is following a call a
7222 function that never returns but that is not declared
7223 @code{__attribute__((noreturn))}, as in this example:
7225 @smallexample
7226 void function_that_never_returns (void);
7228 int g (int c)
7230   if (c)
7231     @{
7232       return 1;
7233     @}
7234   else
7235     @{
7236       function_that_never_returns ();
7237       __builtin_unreachable ();
7238     @}
7240 @end smallexample
7242 @end deftypefn
7244 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
7245 This function is used to flush the processor's instruction cache for
7246 the region of memory between @var{begin} inclusive and @var{end}
7247 exclusive.  Some targets require that the instruction cache be
7248 flushed, after modifying memory containing code, in order to obtain
7249 deterministic behavior.
7251 If the target does not require instruction cache flushes,
7252 @code{__builtin___clear_cache} has no effect.  Otherwise either
7253 instructions are emitted in-line to clear the instruction cache or a
7254 call to the @code{__clear_cache} function in libgcc is made.
7255 @end deftypefn
7257 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
7258 This function is used to minimize cache-miss latency by moving data into
7259 a cache before it is accessed.
7260 You can insert calls to @code{__builtin_prefetch} into code for which
7261 you know addresses of data in memory that is likely to be accessed soon.
7262 If the target supports them, data prefetch instructions will be generated.
7263 If the prefetch is done early enough before the access then the data will
7264 be in the cache by the time it is accessed.
7266 The value of @var{addr} is the address of the memory to prefetch.
7267 There are two optional arguments, @var{rw} and @var{locality}.
7268 The value of @var{rw} is a compile-time constant one or zero; one
7269 means that the prefetch is preparing for a write to the memory address
7270 and zero, the default, means that the prefetch is preparing for a read.
7271 The value @var{locality} must be a compile-time constant integer between
7272 zero and three.  A value of zero means that the data has no temporal
7273 locality, so it need not be left in the cache after the access.  A value
7274 of three means that the data has a high degree of temporal locality and
7275 should be left in all levels of cache possible.  Values of one and two
7276 mean, respectively, a low or moderate degree of temporal locality.  The
7277 default is three.
7279 @smallexample
7280 for (i = 0; i < n; i++)
7281   @{
7282     a[i] = a[i] + b[i];
7283     __builtin_prefetch (&a[i+j], 1, 1);
7284     __builtin_prefetch (&b[i+j], 0, 1);
7285     /* @r{@dots{}} */
7286   @}
7287 @end smallexample
7289 Data prefetch does not generate faults if @var{addr} is invalid, but
7290 the address expression itself must be valid.  For example, a prefetch
7291 of @code{p->next} will not fault if @code{p->next} is not a valid
7292 address, but evaluation will fault if @code{p} is not a valid address.
7294 If the target does not support data prefetch, the address expression
7295 is evaluated if it includes side effects but no other code is generated
7296 and GCC does not issue a warning.
7297 @end deftypefn
7299 @deftypefn {Built-in Function} double __builtin_huge_val (void)
7300 Returns a positive infinity, if supported by the floating-point format,
7301 else @code{DBL_MAX}.  This function is suitable for implementing the
7302 ISO C macro @code{HUGE_VAL}.
7303 @end deftypefn
7305 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
7306 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
7307 @end deftypefn
7309 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
7310 Similar to @code{__builtin_huge_val}, except the return
7311 type is @code{long double}.
7312 @end deftypefn
7314 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
7315 This built-in implements the C99 fpclassify functionality.  The first
7316 five int arguments should be the target library's notion of the
7317 possible FP classes and are used for return values.  They must be
7318 constant values and they must appear in this order: @code{FP_NAN},
7319 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
7320 @code{FP_ZERO}.  The ellipsis is for exactly one floating point value
7321 to classify.  GCC treats the last argument as type-generic, which
7322 means it does not do default promotion from float to double.
7323 @end deftypefn
7325 @deftypefn {Built-in Function} double __builtin_inf (void)
7326 Similar to @code{__builtin_huge_val}, except a warning is generated
7327 if the target floating-point format does not support infinities.
7328 @end deftypefn
7330 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
7331 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
7332 @end deftypefn
7334 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
7335 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
7336 @end deftypefn
7338 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
7339 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
7340 @end deftypefn
7342 @deftypefn {Built-in Function} float __builtin_inff (void)
7343 Similar to @code{__builtin_inf}, except the return type is @code{float}.
7344 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
7345 @end deftypefn
7347 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
7348 Similar to @code{__builtin_inf}, except the return
7349 type is @code{long double}.
7350 @end deftypefn
7352 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
7353 Similar to @code{isinf}, except the return value will be negative for
7354 an argument of @code{-Inf}.  Note while the parameter list is an
7355 ellipsis, this function only accepts exactly one floating point
7356 argument.  GCC treats this parameter as type-generic, which means it
7357 does not do default promotion from float to double.
7358 @end deftypefn
7360 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
7361 This is an implementation of the ISO C99 function @code{nan}.
7363 Since ISO C99 defines this function in terms of @code{strtod}, which we
7364 do not implement, a description of the parsing is in order.  The string
7365 is parsed as by @code{strtol}; that is, the base is recognized by
7366 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
7367 in the significand such that the least significant bit of the number
7368 is at the least significant bit of the significand.  The number is
7369 truncated to fit the significand field provided.  The significand is
7370 forced to be a quiet NaN@.
7372 This function, if given a string literal all of which would have been
7373 consumed by strtol, is evaluated early enough that it is considered a
7374 compile-time constant.
7375 @end deftypefn
7377 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
7378 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
7379 @end deftypefn
7381 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
7382 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
7383 @end deftypefn
7385 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
7386 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
7387 @end deftypefn
7389 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
7390 Similar to @code{__builtin_nan}, except the return type is @code{float}.
7391 @end deftypefn
7393 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
7394 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
7395 @end deftypefn
7397 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
7398 Similar to @code{__builtin_nan}, except the significand is forced
7399 to be a signaling NaN@.  The @code{nans} function is proposed by
7400 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
7401 @end deftypefn
7403 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
7404 Similar to @code{__builtin_nans}, except the return type is @code{float}.
7405 @end deftypefn
7407 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
7408 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
7409 @end deftypefn
7411 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
7412 Returns one plus the index of the least significant 1-bit of @var{x}, or
7413 if @var{x} is zero, returns zero.
7414 @end deftypefn
7416 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
7417 Returns the number of leading 0-bits in @var{x}, starting at the most
7418 significant bit position.  If @var{x} is 0, the result is undefined.
7419 @end deftypefn
7421 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
7422 Returns the number of trailing 0-bits in @var{x}, starting at the least
7423 significant bit position.  If @var{x} is 0, the result is undefined.
7424 @end deftypefn
7426 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
7427 Returns the number of 1-bits in @var{x}.
7428 @end deftypefn
7430 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
7431 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
7432 modulo 2.
7433 @end deftypefn
7435 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
7436 Similar to @code{__builtin_ffs}, except the argument type is
7437 @code{unsigned long}.
7438 @end deftypefn
7440 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
7441 Similar to @code{__builtin_clz}, except the argument type is
7442 @code{unsigned long}.
7443 @end deftypefn
7445 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
7446 Similar to @code{__builtin_ctz}, except the argument type is
7447 @code{unsigned long}.
7448 @end deftypefn
7450 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
7451 Similar to @code{__builtin_popcount}, except the argument type is
7452 @code{unsigned long}.
7453 @end deftypefn
7455 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
7456 Similar to @code{__builtin_parity}, except the argument type is
7457 @code{unsigned long}.
7458 @end deftypefn
7460 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
7461 Similar to @code{__builtin_ffs}, except the argument type is
7462 @code{unsigned long long}.
7463 @end deftypefn
7465 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
7466 Similar to @code{__builtin_clz}, except the argument type is
7467 @code{unsigned long long}.
7468 @end deftypefn
7470 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
7471 Similar to @code{__builtin_ctz}, except the argument type is
7472 @code{unsigned long long}.
7473 @end deftypefn
7475 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
7476 Similar to @code{__builtin_popcount}, except the argument type is
7477 @code{unsigned long long}.
7478 @end deftypefn
7480 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
7481 Similar to @code{__builtin_parity}, except the argument type is
7482 @code{unsigned long long}.
7483 @end deftypefn
7485 @deftypefn {Built-in Function} double __builtin_powi (double, int)
7486 Returns the first argument raised to the power of the second.  Unlike the
7487 @code{pow} function no guarantees about precision and rounding are made.
7488 @end deftypefn
7490 @deftypefn {Built-in Function} float __builtin_powif (float, int)
7491 Similar to @code{__builtin_powi}, except the argument and return types
7492 are @code{float}.
7493 @end deftypefn
7495 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
7496 Similar to @code{__builtin_powi}, except the argument and return types
7497 are @code{long double}.
7498 @end deftypefn
7500 @deftypefn {Built-in Function} int32_t __builtin_bswap32 (int32_t x)
7501 Returns @var{x} with the order of the bytes reversed; for example,
7502 @code{0xaabbccdd} becomes @code{0xddccbbaa}.  Byte here always means
7503 exactly 8 bits.
7504 @end deftypefn
7506 @deftypefn {Built-in Function} int64_t __builtin_bswap64 (int64_t x)
7507 Similar to @code{__builtin_bswap32}, except the argument and return types
7508 are 64-bit.
7509 @end deftypefn
7511 @node Target Builtins
7512 @section Built-in Functions Specific to Particular Target Machines
7514 On some target machines, GCC supports many built-in functions specific
7515 to those machines.  Generally these generate calls to specific machine
7516 instructions, but allow the compiler to schedule those calls.
7518 @menu
7519 * Alpha Built-in Functions::
7520 * ARM iWMMXt Built-in Functions::
7521 * ARM NEON Intrinsics::
7522 * Blackfin Built-in Functions::
7523 * FR-V Built-in Functions::
7524 * X86 Built-in Functions::
7525 * MIPS DSP Built-in Functions::
7526 * MIPS Paired-Single Support::
7527 * MIPS Loongson Built-in Functions::
7528 * Other MIPS Built-in Functions::
7529 * picoChip Built-in Functions::
7530 * PowerPC AltiVec/VSX Built-in Functions::
7531 * RX Built-in Functions::
7532 * SPARC VIS Built-in Functions::
7533 * SPU Built-in Functions::
7534 @end menu
7536 @node Alpha Built-in Functions
7537 @subsection Alpha Built-in Functions
7539 These built-in functions are available for the Alpha family of
7540 processors, depending on the command-line switches used.
7542 The following built-in functions are always available.  They
7543 all generate the machine instruction that is part of the name.
7545 @smallexample
7546 long __builtin_alpha_implver (void)
7547 long __builtin_alpha_rpcc (void)
7548 long __builtin_alpha_amask (long)
7549 long __builtin_alpha_cmpbge (long, long)
7550 long __builtin_alpha_extbl (long, long)
7551 long __builtin_alpha_extwl (long, long)
7552 long __builtin_alpha_extll (long, long)
7553 long __builtin_alpha_extql (long, long)
7554 long __builtin_alpha_extwh (long, long)
7555 long __builtin_alpha_extlh (long, long)
7556 long __builtin_alpha_extqh (long, long)
7557 long __builtin_alpha_insbl (long, long)
7558 long __builtin_alpha_inswl (long, long)
7559 long __builtin_alpha_insll (long, long)
7560 long __builtin_alpha_insql (long, long)
7561 long __builtin_alpha_inswh (long, long)
7562 long __builtin_alpha_inslh (long, long)
7563 long __builtin_alpha_insqh (long, long)
7564 long __builtin_alpha_mskbl (long, long)
7565 long __builtin_alpha_mskwl (long, long)
7566 long __builtin_alpha_mskll (long, long)
7567 long __builtin_alpha_mskql (long, long)
7568 long __builtin_alpha_mskwh (long, long)
7569 long __builtin_alpha_msklh (long, long)
7570 long __builtin_alpha_mskqh (long, long)
7571 long __builtin_alpha_umulh (long, long)
7572 long __builtin_alpha_zap (long, long)
7573 long __builtin_alpha_zapnot (long, long)
7574 @end smallexample
7576 The following built-in functions are always with @option{-mmax}
7577 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
7578 later.  They all generate the machine instruction that is part
7579 of the name.
7581 @smallexample
7582 long __builtin_alpha_pklb (long)
7583 long __builtin_alpha_pkwb (long)
7584 long __builtin_alpha_unpkbl (long)
7585 long __builtin_alpha_unpkbw (long)
7586 long __builtin_alpha_minub8 (long, long)
7587 long __builtin_alpha_minsb8 (long, long)
7588 long __builtin_alpha_minuw4 (long, long)
7589 long __builtin_alpha_minsw4 (long, long)
7590 long __builtin_alpha_maxub8 (long, long)
7591 long __builtin_alpha_maxsb8 (long, long)
7592 long __builtin_alpha_maxuw4 (long, long)
7593 long __builtin_alpha_maxsw4 (long, long)
7594 long __builtin_alpha_perr (long, long)
7595 @end smallexample
7597 The following built-in functions are always with @option{-mcix}
7598 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
7599 later.  They all generate the machine instruction that is part
7600 of the name.
7602 @smallexample
7603 long __builtin_alpha_cttz (long)
7604 long __builtin_alpha_ctlz (long)
7605 long __builtin_alpha_ctpop (long)
7606 @end smallexample
7608 The following builtins are available on systems that use the OSF/1
7609 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
7610 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
7611 @code{rdval} and @code{wrval}.
7613 @smallexample
7614 void *__builtin_thread_pointer (void)
7615 void __builtin_set_thread_pointer (void *)
7616 @end smallexample
7618 @node ARM iWMMXt Built-in Functions
7619 @subsection ARM iWMMXt Built-in Functions
7621 These built-in functions are available for the ARM family of
7622 processors when the @option{-mcpu=iwmmxt} switch is used:
7624 @smallexample
7625 typedef int v2si __attribute__ ((vector_size (8)));
7626 typedef short v4hi __attribute__ ((vector_size (8)));
7627 typedef char v8qi __attribute__ ((vector_size (8)));
7629 int __builtin_arm_getwcx (int)
7630 void __builtin_arm_setwcx (int, int)
7631 int __builtin_arm_textrmsb (v8qi, int)
7632 int __builtin_arm_textrmsh (v4hi, int)
7633 int __builtin_arm_textrmsw (v2si, int)
7634 int __builtin_arm_textrmub (v8qi, int)
7635 int __builtin_arm_textrmuh (v4hi, int)
7636 int __builtin_arm_textrmuw (v2si, int)
7637 v8qi __builtin_arm_tinsrb (v8qi, int)
7638 v4hi __builtin_arm_tinsrh (v4hi, int)
7639 v2si __builtin_arm_tinsrw (v2si, int)
7640 long long __builtin_arm_tmia (long long, int, int)
7641 long long __builtin_arm_tmiabb (long long, int, int)
7642 long long __builtin_arm_tmiabt (long long, int, int)
7643 long long __builtin_arm_tmiaph (long long, int, int)
7644 long long __builtin_arm_tmiatb (long long, int, int)
7645 long long __builtin_arm_tmiatt (long long, int, int)
7646 int __builtin_arm_tmovmskb (v8qi)
7647 int __builtin_arm_tmovmskh (v4hi)
7648 int __builtin_arm_tmovmskw (v2si)
7649 long long __builtin_arm_waccb (v8qi)
7650 long long __builtin_arm_wacch (v4hi)
7651 long long __builtin_arm_waccw (v2si)
7652 v8qi __builtin_arm_waddb (v8qi, v8qi)
7653 v8qi __builtin_arm_waddbss (v8qi, v8qi)
7654 v8qi __builtin_arm_waddbus (v8qi, v8qi)
7655 v4hi __builtin_arm_waddh (v4hi, v4hi)
7656 v4hi __builtin_arm_waddhss (v4hi, v4hi)
7657 v4hi __builtin_arm_waddhus (v4hi, v4hi)
7658 v2si __builtin_arm_waddw (v2si, v2si)
7659 v2si __builtin_arm_waddwss (v2si, v2si)
7660 v2si __builtin_arm_waddwus (v2si, v2si)
7661 v8qi __builtin_arm_walign (v8qi, v8qi, int)
7662 long long __builtin_arm_wand(long long, long long)
7663 long long __builtin_arm_wandn (long long, long long)
7664 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
7665 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
7666 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
7667 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
7668 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
7669 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
7670 v2si __builtin_arm_wcmpeqw (v2si, v2si)
7671 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
7672 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
7673 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
7674 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
7675 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
7676 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
7677 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
7678 long long __builtin_arm_wmacsz (v4hi, v4hi)
7679 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
7680 long long __builtin_arm_wmacuz (v4hi, v4hi)
7681 v4hi __builtin_arm_wmadds (v4hi, v4hi)
7682 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
7683 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
7684 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
7685 v2si __builtin_arm_wmaxsw (v2si, v2si)
7686 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
7687 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
7688 v2si __builtin_arm_wmaxuw (v2si, v2si)
7689 v8qi __builtin_arm_wminsb (v8qi, v8qi)
7690 v4hi __builtin_arm_wminsh (v4hi, v4hi)
7691 v2si __builtin_arm_wminsw (v2si, v2si)
7692 v8qi __builtin_arm_wminub (v8qi, v8qi)
7693 v4hi __builtin_arm_wminuh (v4hi, v4hi)
7694 v2si __builtin_arm_wminuw (v2si, v2si)
7695 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
7696 v4hi __builtin_arm_wmulul (v4hi, v4hi)
7697 v4hi __builtin_arm_wmulum (v4hi, v4hi)
7698 long long __builtin_arm_wor (long long, long long)
7699 v2si __builtin_arm_wpackdss (long long, long long)
7700 v2si __builtin_arm_wpackdus (long long, long long)
7701 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
7702 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
7703 v4hi __builtin_arm_wpackwss (v2si, v2si)
7704 v4hi __builtin_arm_wpackwus (v2si, v2si)
7705 long long __builtin_arm_wrord (long long, long long)
7706 long long __builtin_arm_wrordi (long long, int)
7707 v4hi __builtin_arm_wrorh (v4hi, long long)
7708 v4hi __builtin_arm_wrorhi (v4hi, int)
7709 v2si __builtin_arm_wrorw (v2si, long long)
7710 v2si __builtin_arm_wrorwi (v2si, int)
7711 v2si __builtin_arm_wsadb (v8qi, v8qi)
7712 v2si __builtin_arm_wsadbz (v8qi, v8qi)
7713 v2si __builtin_arm_wsadh (v4hi, v4hi)
7714 v2si __builtin_arm_wsadhz (v4hi, v4hi)
7715 v4hi __builtin_arm_wshufh (v4hi, int)
7716 long long __builtin_arm_wslld (long long, long long)
7717 long long __builtin_arm_wslldi (long long, int)
7718 v4hi __builtin_arm_wsllh (v4hi, long long)
7719 v4hi __builtin_arm_wsllhi (v4hi, int)
7720 v2si __builtin_arm_wsllw (v2si, long long)
7721 v2si __builtin_arm_wsllwi (v2si, int)
7722 long long __builtin_arm_wsrad (long long, long long)
7723 long long __builtin_arm_wsradi (long long, int)
7724 v4hi __builtin_arm_wsrah (v4hi, long long)
7725 v4hi __builtin_arm_wsrahi (v4hi, int)
7726 v2si __builtin_arm_wsraw (v2si, long long)
7727 v2si __builtin_arm_wsrawi (v2si, int)
7728 long long __builtin_arm_wsrld (long long, long long)
7729 long long __builtin_arm_wsrldi (long long, int)
7730 v4hi __builtin_arm_wsrlh (v4hi, long long)
7731 v4hi __builtin_arm_wsrlhi (v4hi, int)
7732 v2si __builtin_arm_wsrlw (v2si, long long)
7733 v2si __builtin_arm_wsrlwi (v2si, int)
7734 v8qi __builtin_arm_wsubb (v8qi, v8qi)
7735 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
7736 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
7737 v4hi __builtin_arm_wsubh (v4hi, v4hi)
7738 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
7739 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
7740 v2si __builtin_arm_wsubw (v2si, v2si)
7741 v2si __builtin_arm_wsubwss (v2si, v2si)
7742 v2si __builtin_arm_wsubwus (v2si, v2si)
7743 v4hi __builtin_arm_wunpckehsb (v8qi)
7744 v2si __builtin_arm_wunpckehsh (v4hi)
7745 long long __builtin_arm_wunpckehsw (v2si)
7746 v4hi __builtin_arm_wunpckehub (v8qi)
7747 v2si __builtin_arm_wunpckehuh (v4hi)
7748 long long __builtin_arm_wunpckehuw (v2si)
7749 v4hi __builtin_arm_wunpckelsb (v8qi)
7750 v2si __builtin_arm_wunpckelsh (v4hi)
7751 long long __builtin_arm_wunpckelsw (v2si)
7752 v4hi __builtin_arm_wunpckelub (v8qi)
7753 v2si __builtin_arm_wunpckeluh (v4hi)
7754 long long __builtin_arm_wunpckeluw (v2si)
7755 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
7756 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
7757 v2si __builtin_arm_wunpckihw (v2si, v2si)
7758 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
7759 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
7760 v2si __builtin_arm_wunpckilw (v2si, v2si)
7761 long long __builtin_arm_wxor (long long, long long)
7762 long long __builtin_arm_wzero ()
7763 @end smallexample
7765 @node ARM NEON Intrinsics
7766 @subsection ARM NEON Intrinsics
7768 These built-in intrinsics for the ARM Advanced SIMD extension are available
7769 when the @option{-mfpu=neon} switch is used:
7771 @include arm-neon-intrinsics.texi
7773 @node Blackfin Built-in Functions
7774 @subsection Blackfin Built-in Functions
7776 Currently, there are two Blackfin-specific built-in functions.  These are
7777 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
7778 using inline assembly; by using these built-in functions the compiler can
7779 automatically add workarounds for hardware errata involving these
7780 instructions.  These functions are named as follows:
7782 @smallexample
7783 void __builtin_bfin_csync (void)
7784 void __builtin_bfin_ssync (void)
7785 @end smallexample
7787 @node FR-V Built-in Functions
7788 @subsection FR-V Built-in Functions
7790 GCC provides many FR-V-specific built-in functions.  In general,
7791 these functions are intended to be compatible with those described
7792 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
7793 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
7794 @code{__MBTOHE}, the gcc forms of which pass 128-bit values by
7795 pointer rather than by value.
7797 Most of the functions are named after specific FR-V instructions.
7798 Such functions are said to be ``directly mapped'' and are summarized
7799 here in tabular form.
7801 @menu
7802 * Argument Types::
7803 * Directly-mapped Integer Functions::
7804 * Directly-mapped Media Functions::
7805 * Raw read/write Functions::
7806 * Other Built-in Functions::
7807 @end menu
7809 @node Argument Types
7810 @subsubsection Argument Types
7812 The arguments to the built-in functions can be divided into three groups:
7813 register numbers, compile-time constants and run-time values.  In order
7814 to make this classification clear at a glance, the arguments and return
7815 values are given the following pseudo types:
7817 @multitable @columnfractions .20 .30 .15 .35
7818 @item Pseudo type @tab Real C type @tab Constant? @tab Description
7819 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
7820 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
7821 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
7822 @item @code{uw2} @tab @code{unsigned long long} @tab No
7823 @tab an unsigned doubleword
7824 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
7825 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
7826 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
7827 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
7828 @end multitable
7830 These pseudo types are not defined by GCC, they are simply a notational
7831 convenience used in this manual.
7833 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
7834 and @code{sw2} are evaluated at run time.  They correspond to
7835 register operands in the underlying FR-V instructions.
7837 @code{const} arguments represent immediate operands in the underlying
7838 FR-V instructions.  They must be compile-time constants.
7840 @code{acc} arguments are evaluated at compile time and specify the number
7841 of an accumulator register.  For example, an @code{acc} argument of 2
7842 will select the ACC2 register.
7844 @code{iacc} arguments are similar to @code{acc} arguments but specify the
7845 number of an IACC register.  See @pxref{Other Built-in Functions}
7846 for more details.
7848 @node Directly-mapped Integer Functions
7849 @subsubsection Directly-mapped Integer Functions
7851 The functions listed below map directly to FR-V I-type instructions.
7853 @multitable @columnfractions .45 .32 .23
7854 @item Function prototype @tab Example usage @tab Assembly output
7855 @item @code{sw1 __ADDSS (sw1, sw1)}
7856 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
7857 @tab @code{ADDSS @var{a},@var{b},@var{c}}
7858 @item @code{sw1 __SCAN (sw1, sw1)}
7859 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
7860 @tab @code{SCAN @var{a},@var{b},@var{c}}
7861 @item @code{sw1 __SCUTSS (sw1)}
7862 @tab @code{@var{b} = __SCUTSS (@var{a})}
7863 @tab @code{SCUTSS @var{a},@var{b}}
7864 @item @code{sw1 __SLASS (sw1, sw1)}
7865 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
7866 @tab @code{SLASS @var{a},@var{b},@var{c}}
7867 @item @code{void __SMASS (sw1, sw1)}
7868 @tab @code{__SMASS (@var{a}, @var{b})}
7869 @tab @code{SMASS @var{a},@var{b}}
7870 @item @code{void __SMSSS (sw1, sw1)}
7871 @tab @code{__SMSSS (@var{a}, @var{b})}
7872 @tab @code{SMSSS @var{a},@var{b}}
7873 @item @code{void __SMU (sw1, sw1)}
7874 @tab @code{__SMU (@var{a}, @var{b})}
7875 @tab @code{SMU @var{a},@var{b}}
7876 @item @code{sw2 __SMUL (sw1, sw1)}
7877 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
7878 @tab @code{SMUL @var{a},@var{b},@var{c}}
7879 @item @code{sw1 __SUBSS (sw1, sw1)}
7880 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
7881 @tab @code{SUBSS @var{a},@var{b},@var{c}}
7882 @item @code{uw2 __UMUL (uw1, uw1)}
7883 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
7884 @tab @code{UMUL @var{a},@var{b},@var{c}}
7885 @end multitable
7887 @node Directly-mapped Media Functions
7888 @subsubsection Directly-mapped Media Functions
7890 The functions listed below map directly to FR-V M-type instructions.
7892 @multitable @columnfractions .45 .32 .23
7893 @item Function prototype @tab Example usage @tab Assembly output
7894 @item @code{uw1 __MABSHS (sw1)}
7895 @tab @code{@var{b} = __MABSHS (@var{a})}
7896 @tab @code{MABSHS @var{a},@var{b}}
7897 @item @code{void __MADDACCS (acc, acc)}
7898 @tab @code{__MADDACCS (@var{b}, @var{a})}
7899 @tab @code{MADDACCS @var{a},@var{b}}
7900 @item @code{sw1 __MADDHSS (sw1, sw1)}
7901 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
7902 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
7903 @item @code{uw1 __MADDHUS (uw1, uw1)}
7904 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
7905 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
7906 @item @code{uw1 __MAND (uw1, uw1)}
7907 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
7908 @tab @code{MAND @var{a},@var{b},@var{c}}
7909 @item @code{void __MASACCS (acc, acc)}
7910 @tab @code{__MASACCS (@var{b}, @var{a})}
7911 @tab @code{MASACCS @var{a},@var{b}}
7912 @item @code{uw1 __MAVEH (uw1, uw1)}
7913 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
7914 @tab @code{MAVEH @var{a},@var{b},@var{c}}
7915 @item @code{uw2 __MBTOH (uw1)}
7916 @tab @code{@var{b} = __MBTOH (@var{a})}
7917 @tab @code{MBTOH @var{a},@var{b}}
7918 @item @code{void __MBTOHE (uw1 *, uw1)}
7919 @tab @code{__MBTOHE (&@var{b}, @var{a})}
7920 @tab @code{MBTOHE @var{a},@var{b}}
7921 @item @code{void __MCLRACC (acc)}
7922 @tab @code{__MCLRACC (@var{a})}
7923 @tab @code{MCLRACC @var{a}}
7924 @item @code{void __MCLRACCA (void)}
7925 @tab @code{__MCLRACCA ()}
7926 @tab @code{MCLRACCA}
7927 @item @code{uw1 __Mcop1 (uw1, uw1)}
7928 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
7929 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
7930 @item @code{uw1 __Mcop2 (uw1, uw1)}
7931 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
7932 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
7933 @item @code{uw1 __MCPLHI (uw2, const)}
7934 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
7935 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
7936 @item @code{uw1 __MCPLI (uw2, const)}
7937 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
7938 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
7939 @item @code{void __MCPXIS (acc, sw1, sw1)}
7940 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
7941 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
7942 @item @code{void __MCPXIU (acc, uw1, uw1)}
7943 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
7944 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
7945 @item @code{void __MCPXRS (acc, sw1, sw1)}
7946 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
7947 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
7948 @item @code{void __MCPXRU (acc, uw1, uw1)}
7949 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
7950 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
7951 @item @code{uw1 __MCUT (acc, uw1)}
7952 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
7953 @tab @code{MCUT @var{a},@var{b},@var{c}}
7954 @item @code{uw1 __MCUTSS (acc, sw1)}
7955 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
7956 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
7957 @item @code{void __MDADDACCS (acc, acc)}
7958 @tab @code{__MDADDACCS (@var{b}, @var{a})}
7959 @tab @code{MDADDACCS @var{a},@var{b}}
7960 @item @code{void __MDASACCS (acc, acc)}
7961 @tab @code{__MDASACCS (@var{b}, @var{a})}
7962 @tab @code{MDASACCS @var{a},@var{b}}
7963 @item @code{uw2 __MDCUTSSI (acc, const)}
7964 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
7965 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
7966 @item @code{uw2 __MDPACKH (uw2, uw2)}
7967 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
7968 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
7969 @item @code{uw2 __MDROTLI (uw2, const)}
7970 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
7971 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
7972 @item @code{void __MDSUBACCS (acc, acc)}
7973 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
7974 @tab @code{MDSUBACCS @var{a},@var{b}}
7975 @item @code{void __MDUNPACKH (uw1 *, uw2)}
7976 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
7977 @tab @code{MDUNPACKH @var{a},@var{b}}
7978 @item @code{uw2 __MEXPDHD (uw1, const)}
7979 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
7980 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
7981 @item @code{uw1 __MEXPDHW (uw1, const)}
7982 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
7983 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
7984 @item @code{uw1 __MHDSETH (uw1, const)}
7985 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
7986 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
7987 @item @code{sw1 __MHDSETS (const)}
7988 @tab @code{@var{b} = __MHDSETS (@var{a})}
7989 @tab @code{MHDSETS #@var{a},@var{b}}
7990 @item @code{uw1 __MHSETHIH (uw1, const)}
7991 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
7992 @tab @code{MHSETHIH #@var{a},@var{b}}
7993 @item @code{sw1 __MHSETHIS (sw1, const)}
7994 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
7995 @tab @code{MHSETHIS #@var{a},@var{b}}
7996 @item @code{uw1 __MHSETLOH (uw1, const)}
7997 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
7998 @tab @code{MHSETLOH #@var{a},@var{b}}
7999 @item @code{sw1 __MHSETLOS (sw1, const)}
8000 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
8001 @tab @code{MHSETLOS #@var{a},@var{b}}
8002 @item @code{uw1 __MHTOB (uw2)}
8003 @tab @code{@var{b} = __MHTOB (@var{a})}
8004 @tab @code{MHTOB @var{a},@var{b}}
8005 @item @code{void __MMACHS (acc, sw1, sw1)}
8006 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
8007 @tab @code{MMACHS @var{a},@var{b},@var{c}}
8008 @item @code{void __MMACHU (acc, uw1, uw1)}
8009 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
8010 @tab @code{MMACHU @var{a},@var{b},@var{c}}
8011 @item @code{void __MMRDHS (acc, sw1, sw1)}
8012 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
8013 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
8014 @item @code{void __MMRDHU (acc, uw1, uw1)}
8015 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
8016 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
8017 @item @code{void __MMULHS (acc, sw1, sw1)}
8018 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
8019 @tab @code{MMULHS @var{a},@var{b},@var{c}}
8020 @item @code{void __MMULHU (acc, uw1, uw1)}
8021 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
8022 @tab @code{MMULHU @var{a},@var{b},@var{c}}
8023 @item @code{void __MMULXHS (acc, sw1, sw1)}
8024 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
8025 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
8026 @item @code{void __MMULXHU (acc, uw1, uw1)}
8027 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
8028 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
8029 @item @code{uw1 __MNOT (uw1)}
8030 @tab @code{@var{b} = __MNOT (@var{a})}
8031 @tab @code{MNOT @var{a},@var{b}}
8032 @item @code{uw1 __MOR (uw1, uw1)}
8033 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
8034 @tab @code{MOR @var{a},@var{b},@var{c}}
8035 @item @code{uw1 __MPACKH (uh, uh)}
8036 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
8037 @tab @code{MPACKH @var{a},@var{b},@var{c}}
8038 @item @code{sw2 __MQADDHSS (sw2, sw2)}
8039 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
8040 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
8041 @item @code{uw2 __MQADDHUS (uw2, uw2)}
8042 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
8043 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
8044 @item @code{void __MQCPXIS (acc, sw2, sw2)}
8045 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
8046 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
8047 @item @code{void __MQCPXIU (acc, uw2, uw2)}
8048 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
8049 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
8050 @item @code{void __MQCPXRS (acc, sw2, sw2)}
8051 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
8052 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
8053 @item @code{void __MQCPXRU (acc, uw2, uw2)}
8054 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
8055 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
8056 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
8057 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
8058 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
8059 @item @code{sw2 __MQLMTHS (sw2, sw2)}
8060 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
8061 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
8062 @item @code{void __MQMACHS (acc, sw2, sw2)}
8063 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
8064 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
8065 @item @code{void __MQMACHU (acc, uw2, uw2)}
8066 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
8067 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
8068 @item @code{void __MQMACXHS (acc, sw2, sw2)}
8069 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
8070 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
8071 @item @code{void __MQMULHS (acc, sw2, sw2)}
8072 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
8073 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
8074 @item @code{void __MQMULHU (acc, uw2, uw2)}
8075 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
8076 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
8077 @item @code{void __MQMULXHS (acc, sw2, sw2)}
8078 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
8079 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
8080 @item @code{void __MQMULXHU (acc, uw2, uw2)}
8081 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
8082 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
8083 @item @code{sw2 __MQSATHS (sw2, sw2)}
8084 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
8085 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
8086 @item @code{uw2 __MQSLLHI (uw2, int)}
8087 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
8088 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
8089 @item @code{sw2 __MQSRAHI (sw2, int)}
8090 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
8091 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
8092 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
8093 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
8094 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
8095 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
8096 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
8097 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
8098 @item @code{void __MQXMACHS (acc, sw2, sw2)}
8099 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
8100 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
8101 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
8102 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
8103 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
8104 @item @code{uw1 __MRDACC (acc)}
8105 @tab @code{@var{b} = __MRDACC (@var{a})}
8106 @tab @code{MRDACC @var{a},@var{b}}
8107 @item @code{uw1 __MRDACCG (acc)}
8108 @tab @code{@var{b} = __MRDACCG (@var{a})}
8109 @tab @code{MRDACCG @var{a},@var{b}}
8110 @item @code{uw1 __MROTLI (uw1, const)}
8111 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
8112 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
8113 @item @code{uw1 __MROTRI (uw1, const)}
8114 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
8115 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
8116 @item @code{sw1 __MSATHS (sw1, sw1)}
8117 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
8118 @tab @code{MSATHS @var{a},@var{b},@var{c}}
8119 @item @code{uw1 __MSATHU (uw1, uw1)}
8120 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
8121 @tab @code{MSATHU @var{a},@var{b},@var{c}}
8122 @item @code{uw1 __MSLLHI (uw1, const)}
8123 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
8124 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
8125 @item @code{sw1 __MSRAHI (sw1, const)}
8126 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
8127 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
8128 @item @code{uw1 __MSRLHI (uw1, const)}
8129 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
8130 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
8131 @item @code{void __MSUBACCS (acc, acc)}
8132 @tab @code{__MSUBACCS (@var{b}, @var{a})}
8133 @tab @code{MSUBACCS @var{a},@var{b}}
8134 @item @code{sw1 __MSUBHSS (sw1, sw1)}
8135 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
8136 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
8137 @item @code{uw1 __MSUBHUS (uw1, uw1)}
8138 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
8139 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
8140 @item @code{void __MTRAP (void)}
8141 @tab @code{__MTRAP ()}
8142 @tab @code{MTRAP}
8143 @item @code{uw2 __MUNPACKH (uw1)}
8144 @tab @code{@var{b} = __MUNPACKH (@var{a})}
8145 @tab @code{MUNPACKH @var{a},@var{b}}
8146 @item @code{uw1 __MWCUT (uw2, uw1)}
8147 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
8148 @tab @code{MWCUT @var{a},@var{b},@var{c}}
8149 @item @code{void __MWTACC (acc, uw1)}
8150 @tab @code{__MWTACC (@var{b}, @var{a})}
8151 @tab @code{MWTACC @var{a},@var{b}}
8152 @item @code{void __MWTACCG (acc, uw1)}
8153 @tab @code{__MWTACCG (@var{b}, @var{a})}
8154 @tab @code{MWTACCG @var{a},@var{b}}
8155 @item @code{uw1 __MXOR (uw1, uw1)}
8156 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
8157 @tab @code{MXOR @var{a},@var{b},@var{c}}
8158 @end multitable
8160 @node Raw read/write Functions
8161 @subsubsection Raw read/write Functions
8163 This sections describes built-in functions related to read and write
8164 instructions to access memory.  These functions generate
8165 @code{membar} instructions to flush the I/O load and stores where
8166 appropriate, as described in Fujitsu's manual described above.
8168 @table @code
8170 @item unsigned char __builtin_read8 (void *@var{data})
8171 @item unsigned short __builtin_read16 (void *@var{data})
8172 @item unsigned long __builtin_read32 (void *@var{data})
8173 @item unsigned long long __builtin_read64 (void *@var{data})
8175 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
8176 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
8177 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
8178 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
8179 @end table
8181 @node Other Built-in Functions
8182 @subsubsection Other Built-in Functions
8184 This section describes built-in functions that are not named after
8185 a specific FR-V instruction.
8187 @table @code
8188 @item sw2 __IACCreadll (iacc @var{reg})
8189 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
8190 for future expansion and must be 0.
8192 @item sw1 __IACCreadl (iacc @var{reg})
8193 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
8194 Other values of @var{reg} are rejected as invalid.
8196 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
8197 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
8198 is reserved for future expansion and must be 0.
8200 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
8201 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
8202 is 1.  Other values of @var{reg} are rejected as invalid.
8204 @item void __data_prefetch0 (const void *@var{x})
8205 Use the @code{dcpl} instruction to load the contents of address @var{x}
8206 into the data cache.
8208 @item void __data_prefetch (const void *@var{x})
8209 Use the @code{nldub} instruction to load the contents of address @var{x}
8210 into the data cache.  The instruction will be issued in slot I1@.
8211 @end table
8213 @node X86 Built-in Functions
8214 @subsection X86 Built-in Functions
8216 These built-in functions are available for the i386 and x86-64 family
8217 of computers, depending on the command-line switches used.
8219 Note that, if you specify command-line switches such as @option{-msse},
8220 the compiler could use the extended instruction sets even if the built-ins
8221 are not used explicitly in the program.  For this reason, applications
8222 which perform runtime CPU detection must compile separate files for each
8223 supported architecture, using the appropriate flags.  In particular,
8224 the file containing the CPU detection code should be compiled without
8225 these options.
8227 The following machine modes are available for use with MMX built-in functions
8228 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
8229 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
8230 vector of eight 8-bit integers.  Some of the built-in functions operate on
8231 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
8233 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
8234 of two 32-bit floating point values.
8236 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
8237 floating point values.  Some instructions use a vector of four 32-bit
8238 integers, these use @code{V4SI}.  Finally, some instructions operate on an
8239 entire vector register, interpreting it as a 128-bit integer, these use mode
8240 @code{TI}.
8242 In 64-bit mode, the x86-64 family of processors uses additional built-in
8243 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
8244 floating point and @code{TC} 128-bit complex floating point values.
8246 The following floating point built-in functions are available in 64-bit
8247 mode.  All of them implement the function that is part of the name.
8249 @smallexample
8250 __float128 __builtin_fabsq (__float128)
8251 __float128 __builtin_copysignq (__float128, __float128)
8252 @end smallexample
8254 The following floating point built-in functions are made available in the
8255 64-bit mode.
8257 @table @code
8258 @item __float128 __builtin_infq (void)
8259 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
8260 @findex __builtin_infq
8262 @item __float128 __builtin_huge_valq (void)
8263 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
8264 @findex __builtin_huge_valq
8265 @end table
8267 The following built-in functions are made available by @option{-mmmx}.
8268 All of them generate the machine instruction that is part of the name.
8270 @smallexample
8271 v8qi __builtin_ia32_paddb (v8qi, v8qi)
8272 v4hi __builtin_ia32_paddw (v4hi, v4hi)
8273 v2si __builtin_ia32_paddd (v2si, v2si)
8274 v8qi __builtin_ia32_psubb (v8qi, v8qi)
8275 v4hi __builtin_ia32_psubw (v4hi, v4hi)
8276 v2si __builtin_ia32_psubd (v2si, v2si)
8277 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
8278 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
8279 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
8280 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
8281 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
8282 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
8283 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
8284 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
8285 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
8286 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
8287 di __builtin_ia32_pand (di, di)
8288 di __builtin_ia32_pandn (di,di)
8289 di __builtin_ia32_por (di, di)
8290 di __builtin_ia32_pxor (di, di)
8291 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
8292 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
8293 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
8294 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
8295 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
8296 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
8297 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
8298 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
8299 v2si __builtin_ia32_punpckhdq (v2si, v2si)
8300 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
8301 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
8302 v2si __builtin_ia32_punpckldq (v2si, v2si)
8303 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
8304 v4hi __builtin_ia32_packssdw (v2si, v2si)
8305 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
8307 v4hi __builtin_ia32_psllw (v4hi, v4hi)
8308 v2si __builtin_ia32_pslld (v2si, v2si)
8309 v1di __builtin_ia32_psllq (v1di, v1di)
8310 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
8311 v2si __builtin_ia32_psrld (v2si, v2si)
8312 v1di __builtin_ia32_psrlq (v1di, v1di)
8313 v4hi __builtin_ia32_psraw (v4hi, v4hi)
8314 v2si __builtin_ia32_psrad (v2si, v2si)
8315 v4hi __builtin_ia32_psllwi (v4hi, int)
8316 v2si __builtin_ia32_pslldi (v2si, int)
8317 v1di __builtin_ia32_psllqi (v1di, int)
8318 v4hi __builtin_ia32_psrlwi (v4hi, int)
8319 v2si __builtin_ia32_psrldi (v2si, int)
8320 v1di __builtin_ia32_psrlqi (v1di, int)
8321 v4hi __builtin_ia32_psrawi (v4hi, int)
8322 v2si __builtin_ia32_psradi (v2si, int)
8324 @end smallexample
8326 The following built-in functions are made available either with
8327 @option{-msse}, or with a combination of @option{-m3dnow} and
8328 @option{-march=athlon}.  All of them generate the machine
8329 instruction that is part of the name.
8331 @smallexample
8332 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
8333 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
8334 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
8335 v1di __builtin_ia32_psadbw (v8qi, v8qi)
8336 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
8337 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
8338 v8qi __builtin_ia32_pminub (v8qi, v8qi)
8339 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
8340 int __builtin_ia32_pextrw (v4hi, int)
8341 v4hi __builtin_ia32_pinsrw (v4hi, int, int)
8342 int __builtin_ia32_pmovmskb (v8qi)
8343 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
8344 void __builtin_ia32_movntq (di *, di)
8345 void __builtin_ia32_sfence (void)
8346 @end smallexample
8348 The following built-in functions are available when @option{-msse} is used.
8349 All of them generate the machine instruction that is part of the name.
8351 @smallexample
8352 int __builtin_ia32_comieq (v4sf, v4sf)
8353 int __builtin_ia32_comineq (v4sf, v4sf)
8354 int __builtin_ia32_comilt (v4sf, v4sf)
8355 int __builtin_ia32_comile (v4sf, v4sf)
8356 int __builtin_ia32_comigt (v4sf, v4sf)
8357 int __builtin_ia32_comige (v4sf, v4sf)
8358 int __builtin_ia32_ucomieq (v4sf, v4sf)
8359 int __builtin_ia32_ucomineq (v4sf, v4sf)
8360 int __builtin_ia32_ucomilt (v4sf, v4sf)
8361 int __builtin_ia32_ucomile (v4sf, v4sf)
8362 int __builtin_ia32_ucomigt (v4sf, v4sf)
8363 int __builtin_ia32_ucomige (v4sf, v4sf)
8364 v4sf __builtin_ia32_addps (v4sf, v4sf)
8365 v4sf __builtin_ia32_subps (v4sf, v4sf)
8366 v4sf __builtin_ia32_mulps (v4sf, v4sf)
8367 v4sf __builtin_ia32_divps (v4sf, v4sf)
8368 v4sf __builtin_ia32_addss (v4sf, v4sf)
8369 v4sf __builtin_ia32_subss (v4sf, v4sf)
8370 v4sf __builtin_ia32_mulss (v4sf, v4sf)
8371 v4sf __builtin_ia32_divss (v4sf, v4sf)
8372 v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
8373 v4si __builtin_ia32_cmpltps (v4sf, v4sf)
8374 v4si __builtin_ia32_cmpleps (v4sf, v4sf)
8375 v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
8376 v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
8377 v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
8378 v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
8379 v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
8380 v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
8381 v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
8382 v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
8383 v4si __builtin_ia32_cmpordps (v4sf, v4sf)
8384 v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
8385 v4si __builtin_ia32_cmpltss (v4sf, v4sf)
8386 v4si __builtin_ia32_cmpless (v4sf, v4sf)
8387 v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
8388 v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
8389 v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
8390 v4si __builtin_ia32_cmpnless (v4sf, v4sf)
8391 v4si __builtin_ia32_cmpordss (v4sf, v4sf)
8392 v4sf __builtin_ia32_maxps (v4sf, v4sf)
8393 v4sf __builtin_ia32_maxss (v4sf, v4sf)
8394 v4sf __builtin_ia32_minps (v4sf, v4sf)
8395 v4sf __builtin_ia32_minss (v4sf, v4sf)
8396 v4sf __builtin_ia32_andps (v4sf, v4sf)
8397 v4sf __builtin_ia32_andnps (v4sf, v4sf)
8398 v4sf __builtin_ia32_orps (v4sf, v4sf)
8399 v4sf __builtin_ia32_xorps (v4sf, v4sf)
8400 v4sf __builtin_ia32_movss (v4sf, v4sf)
8401 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
8402 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
8403 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
8404 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
8405 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
8406 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
8407 v2si __builtin_ia32_cvtps2pi (v4sf)
8408 int __builtin_ia32_cvtss2si (v4sf)
8409 v2si __builtin_ia32_cvttps2pi (v4sf)
8410 int __builtin_ia32_cvttss2si (v4sf)
8411 v4sf __builtin_ia32_rcpps (v4sf)
8412 v4sf __builtin_ia32_rsqrtps (v4sf)
8413 v4sf __builtin_ia32_sqrtps (v4sf)
8414 v4sf __builtin_ia32_rcpss (v4sf)
8415 v4sf __builtin_ia32_rsqrtss (v4sf)
8416 v4sf __builtin_ia32_sqrtss (v4sf)
8417 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
8418 void __builtin_ia32_movntps (float *, v4sf)
8419 int __builtin_ia32_movmskps (v4sf)
8420 @end smallexample
8422 The following built-in functions are available when @option{-msse} is used.
8424 @table @code
8425 @item v4sf __builtin_ia32_loadaps (float *)
8426 Generates the @code{movaps} machine instruction as a load from memory.
8427 @item void __builtin_ia32_storeaps (float *, v4sf)
8428 Generates the @code{movaps} machine instruction as a store to memory.
8429 @item v4sf __builtin_ia32_loadups (float *)
8430 Generates the @code{movups} machine instruction as a load from memory.
8431 @item void __builtin_ia32_storeups (float *, v4sf)
8432 Generates the @code{movups} machine instruction as a store to memory.
8433 @item v4sf __builtin_ia32_loadsss (float *)
8434 Generates the @code{movss} machine instruction as a load from memory.
8435 @item void __builtin_ia32_storess (float *, v4sf)
8436 Generates the @code{movss} machine instruction as a store to memory.
8437 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
8438 Generates the @code{movhps} machine instruction as a load from memory.
8439 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
8440 Generates the @code{movlps} machine instruction as a load from memory
8441 @item void __builtin_ia32_storehps (v2sf *, v4sf)
8442 Generates the @code{movhps} machine instruction as a store to memory.
8443 @item void __builtin_ia32_storelps (v2sf *, v4sf)
8444 Generates the @code{movlps} machine instruction as a store to memory.
8445 @end table
8447 The following built-in functions are available when @option{-msse2} is used.
8448 All of them generate the machine instruction that is part of the name.
8450 @smallexample
8451 int __builtin_ia32_comisdeq (v2df, v2df)
8452 int __builtin_ia32_comisdlt (v2df, v2df)
8453 int __builtin_ia32_comisdle (v2df, v2df)
8454 int __builtin_ia32_comisdgt (v2df, v2df)
8455 int __builtin_ia32_comisdge (v2df, v2df)
8456 int __builtin_ia32_comisdneq (v2df, v2df)
8457 int __builtin_ia32_ucomisdeq (v2df, v2df)
8458 int __builtin_ia32_ucomisdlt (v2df, v2df)
8459 int __builtin_ia32_ucomisdle (v2df, v2df)
8460 int __builtin_ia32_ucomisdgt (v2df, v2df)
8461 int __builtin_ia32_ucomisdge (v2df, v2df)
8462 int __builtin_ia32_ucomisdneq (v2df, v2df)
8463 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
8464 v2df __builtin_ia32_cmpltpd (v2df, v2df)
8465 v2df __builtin_ia32_cmplepd (v2df, v2df)
8466 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
8467 v2df __builtin_ia32_cmpgepd (v2df, v2df)
8468 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
8469 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
8470 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
8471 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
8472 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
8473 v2df __builtin_ia32_cmpngepd (v2df, v2df)
8474 v2df __builtin_ia32_cmpordpd (v2df, v2df)
8475 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
8476 v2df __builtin_ia32_cmpltsd (v2df, v2df)
8477 v2df __builtin_ia32_cmplesd (v2df, v2df)
8478 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
8479 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
8480 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
8481 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
8482 v2df __builtin_ia32_cmpordsd (v2df, v2df)
8483 v2di __builtin_ia32_paddq (v2di, v2di)
8484 v2di __builtin_ia32_psubq (v2di, v2di)
8485 v2df __builtin_ia32_addpd (v2df, v2df)
8486 v2df __builtin_ia32_subpd (v2df, v2df)
8487 v2df __builtin_ia32_mulpd (v2df, v2df)
8488 v2df __builtin_ia32_divpd (v2df, v2df)
8489 v2df __builtin_ia32_addsd (v2df, v2df)
8490 v2df __builtin_ia32_subsd (v2df, v2df)
8491 v2df __builtin_ia32_mulsd (v2df, v2df)
8492 v2df __builtin_ia32_divsd (v2df, v2df)
8493 v2df __builtin_ia32_minpd (v2df, v2df)
8494 v2df __builtin_ia32_maxpd (v2df, v2df)
8495 v2df __builtin_ia32_minsd (v2df, v2df)
8496 v2df __builtin_ia32_maxsd (v2df, v2df)
8497 v2df __builtin_ia32_andpd (v2df, v2df)
8498 v2df __builtin_ia32_andnpd (v2df, v2df)
8499 v2df __builtin_ia32_orpd (v2df, v2df)
8500 v2df __builtin_ia32_xorpd (v2df, v2df)
8501 v2df __builtin_ia32_movsd (v2df, v2df)
8502 v2df __builtin_ia32_unpckhpd (v2df, v2df)
8503 v2df __builtin_ia32_unpcklpd (v2df, v2df)
8504 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
8505 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
8506 v4si __builtin_ia32_paddd128 (v4si, v4si)
8507 v2di __builtin_ia32_paddq128 (v2di, v2di)
8508 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
8509 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
8510 v4si __builtin_ia32_psubd128 (v4si, v4si)
8511 v2di __builtin_ia32_psubq128 (v2di, v2di)
8512 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
8513 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
8514 v2di __builtin_ia32_pand128 (v2di, v2di)
8515 v2di __builtin_ia32_pandn128 (v2di, v2di)
8516 v2di __builtin_ia32_por128 (v2di, v2di)
8517 v2di __builtin_ia32_pxor128 (v2di, v2di)
8518 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
8519 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
8520 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
8521 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
8522 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
8523 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
8524 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
8525 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
8526 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
8527 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
8528 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
8529 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
8530 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
8531 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
8532 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
8533 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
8534 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
8535 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
8536 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
8537 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
8538 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
8539 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
8540 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
8541 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
8542 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
8543 v2df __builtin_ia32_loadupd (double *)
8544 void __builtin_ia32_storeupd (double *, v2df)
8545 v2df __builtin_ia32_loadhpd (v2df, double const *)
8546 v2df __builtin_ia32_loadlpd (v2df, double const *)
8547 int __builtin_ia32_movmskpd (v2df)
8548 int __builtin_ia32_pmovmskb128 (v16qi)
8549 void __builtin_ia32_movnti (int *, int)
8550 void __builtin_ia32_movntpd (double *, v2df)
8551 void __builtin_ia32_movntdq (v2df *, v2df)
8552 v4si __builtin_ia32_pshufd (v4si, int)
8553 v8hi __builtin_ia32_pshuflw (v8hi, int)
8554 v8hi __builtin_ia32_pshufhw (v8hi, int)
8555 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
8556 v2df __builtin_ia32_sqrtpd (v2df)
8557 v2df __builtin_ia32_sqrtsd (v2df)
8558 v2df __builtin_ia32_shufpd (v2df, v2df, int)
8559 v2df __builtin_ia32_cvtdq2pd (v4si)
8560 v4sf __builtin_ia32_cvtdq2ps (v4si)
8561 v4si __builtin_ia32_cvtpd2dq (v2df)
8562 v2si __builtin_ia32_cvtpd2pi (v2df)
8563 v4sf __builtin_ia32_cvtpd2ps (v2df)
8564 v4si __builtin_ia32_cvttpd2dq (v2df)
8565 v2si __builtin_ia32_cvttpd2pi (v2df)
8566 v2df __builtin_ia32_cvtpi2pd (v2si)
8567 int __builtin_ia32_cvtsd2si (v2df)
8568 int __builtin_ia32_cvttsd2si (v2df)
8569 long long __builtin_ia32_cvtsd2si64 (v2df)
8570 long long __builtin_ia32_cvttsd2si64 (v2df)
8571 v4si __builtin_ia32_cvtps2dq (v4sf)
8572 v2df __builtin_ia32_cvtps2pd (v4sf)
8573 v4si __builtin_ia32_cvttps2dq (v4sf)
8574 v2df __builtin_ia32_cvtsi2sd (v2df, int)
8575 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
8576 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
8577 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
8578 void __builtin_ia32_clflush (const void *)
8579 void __builtin_ia32_lfence (void)
8580 void __builtin_ia32_mfence (void)
8581 v16qi __builtin_ia32_loaddqu (const char *)
8582 void __builtin_ia32_storedqu (char *, v16qi)
8583 v1di __builtin_ia32_pmuludq (v2si, v2si)
8584 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
8585 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
8586 v4si __builtin_ia32_pslld128 (v4si, v4si)
8587 v2di __builtin_ia32_psllq128 (v2di, v2di)
8588 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
8589 v4si __builtin_ia32_psrld128 (v4si, v4si)
8590 v2di __builtin_ia32_psrlq128 (v2di, v2di)
8591 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
8592 v4si __builtin_ia32_psrad128 (v4si, v4si)
8593 v2di __builtin_ia32_pslldqi128 (v2di, int)
8594 v8hi __builtin_ia32_psllwi128 (v8hi, int)
8595 v4si __builtin_ia32_pslldi128 (v4si, int)
8596 v2di __builtin_ia32_psllqi128 (v2di, int)
8597 v2di __builtin_ia32_psrldqi128 (v2di, int)
8598 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
8599 v4si __builtin_ia32_psrldi128 (v4si, int)
8600 v2di __builtin_ia32_psrlqi128 (v2di, int)
8601 v8hi __builtin_ia32_psrawi128 (v8hi, int)
8602 v4si __builtin_ia32_psradi128 (v4si, int)
8603 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
8604 v2di __builtin_ia32_movq128 (v2di)
8605 @end smallexample
8607 The following built-in functions are available when @option{-msse3} is used.
8608 All of them generate the machine instruction that is part of the name.
8610 @smallexample
8611 v2df __builtin_ia32_addsubpd (v2df, v2df)
8612 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
8613 v2df __builtin_ia32_haddpd (v2df, v2df)
8614 v4sf __builtin_ia32_haddps (v4sf, v4sf)
8615 v2df __builtin_ia32_hsubpd (v2df, v2df)
8616 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
8617 v16qi __builtin_ia32_lddqu (char const *)
8618 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
8619 v2df __builtin_ia32_movddup (v2df)
8620 v4sf __builtin_ia32_movshdup (v4sf)
8621 v4sf __builtin_ia32_movsldup (v4sf)
8622 void __builtin_ia32_mwait (unsigned int, unsigned int)
8623 @end smallexample
8625 The following built-in functions are available when @option{-msse3} is used.
8627 @table @code
8628 @item v2df __builtin_ia32_loadddup (double const *)
8629 Generates the @code{movddup} machine instruction as a load from memory.
8630 @end table
8632 The following built-in functions are available when @option{-mssse3} is used.
8633 All of them generate the machine instruction that is part of the name
8634 with MMX registers.
8636 @smallexample
8637 v2si __builtin_ia32_phaddd (v2si, v2si)
8638 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
8639 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
8640 v2si __builtin_ia32_phsubd (v2si, v2si)
8641 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
8642 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
8643 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
8644 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
8645 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
8646 v8qi __builtin_ia32_psignb (v8qi, v8qi)
8647 v2si __builtin_ia32_psignd (v2si, v2si)
8648 v4hi __builtin_ia32_psignw (v4hi, v4hi)
8649 v1di __builtin_ia32_palignr (v1di, v1di, int)
8650 v8qi __builtin_ia32_pabsb (v8qi)
8651 v2si __builtin_ia32_pabsd (v2si)
8652 v4hi __builtin_ia32_pabsw (v4hi)
8653 @end smallexample
8655 The following built-in functions are available when @option{-mssse3} is used.
8656 All of them generate the machine instruction that is part of the name
8657 with SSE registers.
8659 @smallexample
8660 v4si __builtin_ia32_phaddd128 (v4si, v4si)
8661 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
8662 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
8663 v4si __builtin_ia32_phsubd128 (v4si, v4si)
8664 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
8665 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
8666 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
8667 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
8668 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
8669 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
8670 v4si __builtin_ia32_psignd128 (v4si, v4si)
8671 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
8672 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
8673 v16qi __builtin_ia32_pabsb128 (v16qi)
8674 v4si __builtin_ia32_pabsd128 (v4si)
8675 v8hi __builtin_ia32_pabsw128 (v8hi)
8676 @end smallexample
8678 The following built-in functions are available when @option{-msse4.1} is
8679 used.  All of them generate the machine instruction that is part of the
8680 name.
8682 @smallexample
8683 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
8684 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
8685 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
8686 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
8687 v2df __builtin_ia32_dppd (v2df, v2df, const int)
8688 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
8689 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
8690 v2di __builtin_ia32_movntdqa (v2di *);
8691 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
8692 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
8693 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
8694 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
8695 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
8696 v8hi __builtin_ia32_phminposuw128 (v8hi)
8697 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
8698 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
8699 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
8700 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
8701 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
8702 v4si __builtin_ia32_pminsd128 (v4si, v4si)
8703 v4si __builtin_ia32_pminud128 (v4si, v4si)
8704 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
8705 v4si __builtin_ia32_pmovsxbd128 (v16qi)
8706 v2di __builtin_ia32_pmovsxbq128 (v16qi)
8707 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
8708 v2di __builtin_ia32_pmovsxdq128 (v4si)
8709 v4si __builtin_ia32_pmovsxwd128 (v8hi)
8710 v2di __builtin_ia32_pmovsxwq128 (v8hi)
8711 v4si __builtin_ia32_pmovzxbd128 (v16qi)
8712 v2di __builtin_ia32_pmovzxbq128 (v16qi)
8713 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
8714 v2di __builtin_ia32_pmovzxdq128 (v4si)
8715 v4si __builtin_ia32_pmovzxwd128 (v8hi)
8716 v2di __builtin_ia32_pmovzxwq128 (v8hi)
8717 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
8718 v4si __builtin_ia32_pmulld128 (v4si, v4si)
8719 int __builtin_ia32_ptestc128 (v2di, v2di)
8720 int __builtin_ia32_ptestnzc128 (v2di, v2di)
8721 int __builtin_ia32_ptestz128 (v2di, v2di)
8722 v2df __builtin_ia32_roundpd (v2df, const int)
8723 v4sf __builtin_ia32_roundps (v4sf, const int)
8724 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
8725 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
8726 @end smallexample
8728 The following built-in functions are available when @option{-msse4.1} is
8729 used.
8731 @table @code
8732 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
8733 Generates the @code{insertps} machine instruction.
8734 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
8735 Generates the @code{pextrb} machine instruction.
8736 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
8737 Generates the @code{pinsrb} machine instruction.
8738 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
8739 Generates the @code{pinsrd} machine instruction.
8740 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
8741 Generates the @code{pinsrq} machine instruction in 64bit mode.
8742 @end table
8744 The following built-in functions are changed to generate new SSE4.1
8745 instructions when @option{-msse4.1} is used.
8747 @table @code
8748 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
8749 Generates the @code{extractps} machine instruction.
8750 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
8751 Generates the @code{pextrd} machine instruction.
8752 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
8753 Generates the @code{pextrq} machine instruction in 64bit mode.
8754 @end table
8756 The following built-in functions are available when @option{-msse4.2} is
8757 used.  All of them generate the machine instruction that is part of the
8758 name.
8760 @smallexample
8761 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
8762 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
8763 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
8764 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
8765 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
8766 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
8767 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
8768 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
8769 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
8770 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
8771 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
8772 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
8773 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
8774 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
8775 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
8776 @end smallexample
8778 The following built-in functions are available when @option{-msse4.2} is
8779 used.
8781 @table @code
8782 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
8783 Generates the @code{crc32b} machine instruction.
8784 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
8785 Generates the @code{crc32w} machine instruction.
8786 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
8787 Generates the @code{crc32l} machine instruction.
8788 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
8789 Generates the @code{crc32q} machine instruction.
8790 @end table
8792 The following built-in functions are changed to generate new SSE4.2
8793 instructions when @option{-msse4.2} is used.
8795 @table @code
8796 @item int __builtin_popcount (unsigned int)
8797 Generates the @code{popcntl} machine instruction.
8798 @item int __builtin_popcountl (unsigned long)
8799 Generates the @code{popcntl} or @code{popcntq} machine instruction,
8800 depending on the size of @code{unsigned long}.
8801 @item int __builtin_popcountll (unsigned long long)
8802 Generates the @code{popcntq} machine instruction.
8803 @end table
8805 The following built-in functions are available when @option{-mavx} is
8806 used. All of them generate the machine instruction that is part of the
8807 name.
8809 @smallexample
8810 v4df __builtin_ia32_addpd256 (v4df,v4df)
8811 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
8812 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
8813 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
8814 v4df __builtin_ia32_andnpd256 (v4df,v4df)
8815 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
8816 v4df __builtin_ia32_andpd256 (v4df,v4df)
8817 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
8818 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
8819 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
8820 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
8821 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
8822 v2df __builtin_ia32_cmppd (v2df,v2df,int)
8823 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
8824 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
8825 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
8826 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
8827 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
8828 v4df __builtin_ia32_cvtdq2pd256 (v4si)
8829 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
8830 v4si __builtin_ia32_cvtpd2dq256 (v4df)
8831 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
8832 v8si __builtin_ia32_cvtps2dq256 (v8sf)
8833 v4df __builtin_ia32_cvtps2pd256 (v4sf)
8834 v4si __builtin_ia32_cvttpd2dq256 (v4df)
8835 v8si __builtin_ia32_cvttps2dq256 (v8sf)
8836 v4df __builtin_ia32_divpd256 (v4df,v4df)
8837 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
8838 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
8839 v4df __builtin_ia32_haddpd256 (v4df,v4df)
8840 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
8841 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
8842 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
8843 v32qi __builtin_ia32_lddqu256 (pcchar)
8844 v32qi __builtin_ia32_loaddqu256 (pcchar)
8845 v4df __builtin_ia32_loadupd256 (pcdouble)
8846 v8sf __builtin_ia32_loadups256 (pcfloat)
8847 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
8848 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
8849 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
8850 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
8851 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
8852 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
8853 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
8854 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
8855 v4df __builtin_ia32_maxpd256 (v4df,v4df)
8856 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
8857 v4df __builtin_ia32_minpd256 (v4df,v4df)
8858 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
8859 v4df __builtin_ia32_movddup256 (v4df)
8860 int __builtin_ia32_movmskpd256 (v4df)
8861 int __builtin_ia32_movmskps256 (v8sf)
8862 v8sf __builtin_ia32_movshdup256 (v8sf)
8863 v8sf __builtin_ia32_movsldup256 (v8sf)
8864 v4df __builtin_ia32_mulpd256 (v4df,v4df)
8865 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
8866 v4df __builtin_ia32_orpd256 (v4df,v4df)
8867 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
8868 v2df __builtin_ia32_pd_pd256 (v4df)
8869 v4df __builtin_ia32_pd256_pd (v2df)
8870 v4sf __builtin_ia32_ps_ps256 (v8sf)
8871 v8sf __builtin_ia32_ps256_ps (v4sf)
8872 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
8873 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
8874 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
8875 v8sf __builtin_ia32_rcpps256 (v8sf)
8876 v4df __builtin_ia32_roundpd256 (v4df,int)
8877 v8sf __builtin_ia32_roundps256 (v8sf,int)
8878 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
8879 v8sf __builtin_ia32_rsqrtps256 (v8sf)
8880 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
8881 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
8882 v4si __builtin_ia32_si_si256 (v8si)
8883 v8si __builtin_ia32_si256_si (v4si)
8884 v4df __builtin_ia32_sqrtpd256 (v4df)
8885 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
8886 v8sf __builtin_ia32_sqrtps256 (v8sf)
8887 void __builtin_ia32_storedqu256 (pchar,v32qi)
8888 void __builtin_ia32_storeupd256 (pdouble,v4df)
8889 void __builtin_ia32_storeups256 (pfloat,v8sf)
8890 v4df __builtin_ia32_subpd256 (v4df,v4df)
8891 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
8892 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
8893 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
8894 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
8895 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
8896 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
8897 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
8898 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
8899 v4sf __builtin_ia32_vbroadcastss (pcfloat)
8900 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
8901 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
8902 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
8903 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
8904 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
8905 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
8906 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
8907 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
8908 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
8909 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
8910 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
8911 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
8912 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
8913 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
8914 v2df __builtin_ia32_vpermilpd (v2df,int)
8915 v4df __builtin_ia32_vpermilpd256 (v4df,int)
8916 v4sf __builtin_ia32_vpermilps (v4sf,int)
8917 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
8918 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
8919 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
8920 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
8921 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
8922 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
8923 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
8924 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
8925 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
8926 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
8927 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
8928 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
8929 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
8930 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
8931 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
8932 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
8933 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
8934 void __builtin_ia32_vzeroall (void)
8935 void __builtin_ia32_vzeroupper (void)
8936 v4df __builtin_ia32_xorpd256 (v4df,v4df)
8937 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
8938 @end smallexample
8940 The following built-in functions are available when @option{-maes} is
8941 used.  All of them generate the machine instruction that is part of the
8942 name.
8944 @smallexample
8945 v2di __builtin_ia32_aesenc128 (v2di, v2di)
8946 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
8947 v2di __builtin_ia32_aesdec128 (v2di, v2di)
8948 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
8949 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
8950 v2di __builtin_ia32_aesimc128 (v2di)
8951 @end smallexample
8953 The following built-in function is available when @option{-mpclmul} is
8954 used.
8956 @table @code
8957 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
8958 Generates the @code{pclmulqdq} machine instruction.
8959 @end table
8961 The following built-in function is available when @option{-mfsgsbase} is
8962 used.  All of them generate the machine instruction that is part of the
8963 name.
8965 @smallexample
8966 unsigned int __builtin_ia32_rdfsbase32 (void)
8967 unsigned long long __builtin_ia32_rdfsbase64 (void)
8968 unsigned int __builtin_ia32_rdgsbase32 (void)
8969 unsigned long long __builtin_ia32_rdgsbase64 (void)
8970 void _writefsbase_u32 (unsigned int)
8971 void _writefsbase_u64 (unsigned long long)
8972 void _writegsbase_u32 (unsigned int)
8973 void _writegsbase_u64 (unsigned long long)
8974 @end smallexample
8976 The following built-in function is available when @option{-mrdrnd} is
8977 used.  All of them generate the machine instruction that is part of the
8978 name.
8980 @smallexample
8981 unsigned short __builtin_ia32_rdrand16 (void)
8982 unsigned int __builtin_ia32_rdrand32 (void)
8983 unsigned long long __builtin_ia32_rdrand64 (void)
8984 @end smallexample
8986 The following built-in functions are available when @option{-msse4a} is used.
8987 All of them generate the machine instruction that is part of the name.
8989 @smallexample
8990 void __builtin_ia32_movntsd (double *, v2df)
8991 void __builtin_ia32_movntss (float *, v4sf)
8992 v2di __builtin_ia32_extrq  (v2di, v16qi)
8993 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
8994 v2di __builtin_ia32_insertq (v2di, v2di)
8995 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
8996 @end smallexample
8998 The following built-in functions are available when @option{-mxop} is used.
8999 @smallexample
9000 v2df __builtin_ia32_vfrczpd (v2df)
9001 v4sf __builtin_ia32_vfrczps (v4sf)
9002 v2df __builtin_ia32_vfrczsd (v2df, v2df)
9003 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
9004 v4df __builtin_ia32_vfrczpd256 (v4df)
9005 v8sf __builtin_ia32_vfrczps256 (v8sf)
9006 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
9007 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
9008 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
9009 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
9010 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
9011 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
9012 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
9013 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
9014 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
9015 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
9016 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
9017 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
9018 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
9019 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
9020 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
9021 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
9022 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
9023 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
9024 v4si __builtin_ia32_vpcomequd (v4si, v4si)
9025 v2di __builtin_ia32_vpcomequq (v2di, v2di)
9026 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
9027 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
9028 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
9029 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
9030 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
9031 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
9032 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
9033 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
9034 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
9035 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
9036 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
9037 v4si __builtin_ia32_vpcomged (v4si, v4si)
9038 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
9039 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
9040 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
9041 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
9042 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
9043 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
9044 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
9045 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
9046 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
9047 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
9048 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
9049 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
9050 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
9051 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
9052 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
9053 v4si __builtin_ia32_vpcomled (v4si, v4si)
9054 v2di __builtin_ia32_vpcomleq (v2di, v2di)
9055 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
9056 v4si __builtin_ia32_vpcomleud (v4si, v4si)
9057 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
9058 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
9059 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
9060 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
9061 v4si __builtin_ia32_vpcomltd (v4si, v4si)
9062 v2di __builtin_ia32_vpcomltq (v2di, v2di)
9063 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
9064 v4si __builtin_ia32_vpcomltud (v4si, v4si)
9065 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
9066 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
9067 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
9068 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
9069 v4si __builtin_ia32_vpcomned (v4si, v4si)
9070 v2di __builtin_ia32_vpcomneq (v2di, v2di)
9071 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
9072 v4si __builtin_ia32_vpcomneud (v4si, v4si)
9073 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
9074 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
9075 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
9076 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
9077 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
9078 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
9079 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
9080 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
9081 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
9082 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
9083 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
9084 v4si __builtin_ia32_vphaddbd (v16qi)
9085 v2di __builtin_ia32_vphaddbq (v16qi)
9086 v8hi __builtin_ia32_vphaddbw (v16qi)
9087 v2di __builtin_ia32_vphadddq (v4si)
9088 v4si __builtin_ia32_vphaddubd (v16qi)
9089 v2di __builtin_ia32_vphaddubq (v16qi)
9090 v8hi __builtin_ia32_vphaddubw (v16qi)
9091 v2di __builtin_ia32_vphaddudq (v4si)
9092 v4si __builtin_ia32_vphadduwd (v8hi)
9093 v2di __builtin_ia32_vphadduwq (v8hi)
9094 v4si __builtin_ia32_vphaddwd (v8hi)
9095 v2di __builtin_ia32_vphaddwq (v8hi)
9096 v8hi __builtin_ia32_vphsubbw (v16qi)
9097 v2di __builtin_ia32_vphsubdq (v4si)
9098 v4si __builtin_ia32_vphsubwd (v8hi)
9099 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
9100 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
9101 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
9102 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
9103 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
9104 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
9105 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
9106 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
9107 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
9108 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
9109 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
9110 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
9111 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
9112 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
9113 v4si __builtin_ia32_vprotd (v4si, v4si)
9114 v2di __builtin_ia32_vprotq (v2di, v2di)
9115 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
9116 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
9117 v4si __builtin_ia32_vpshad (v4si, v4si)
9118 v2di __builtin_ia32_vpshaq (v2di, v2di)
9119 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
9120 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
9121 v4si __builtin_ia32_vpshld (v4si, v4si)
9122 v2di __builtin_ia32_vpshlq (v2di, v2di)
9123 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
9124 @end smallexample
9126 The following built-in functions are available when @option{-mfma4} is used.
9127 All of them generate the machine instruction that is part of the name
9128 with MMX registers.
9130 @smallexample
9131 v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df)
9132 v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf)
9133 v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df)
9134 v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf)
9135 v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df)
9136 v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf)
9137 v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df)
9138 v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf)
9139 v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df)
9140 v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf)
9141 v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df)
9142 v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf)
9143 v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df)
9144 v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf)
9145 v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df)
9146 v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf)
9147 v2df __builtin_ia32_fmaddsubpd  (v2df, v2df, v2df)
9148 v4sf __builtin_ia32_fmaddsubps  (v4sf, v4sf, v4sf)
9149 v2df __builtin_ia32_fmsubaddpd  (v2df, v2df, v2df)
9150 v4sf __builtin_ia32_fmsubaddps  (v4sf, v4sf, v4sf)
9151 v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df)
9152 v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf)
9153 v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df)
9154 v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf)
9155 v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df)
9156 v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf)
9157 v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df)
9158 v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf)
9159 v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df)
9160 v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf)
9161 v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df)
9162 v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf)
9164 @end smallexample
9166 The following built-in functions are available when @option{-mlwp} is used.
9168 @smallexample
9169 void __builtin_ia32_llwpcb16 (void *);
9170 void __builtin_ia32_llwpcb32 (void *);
9171 void __builtin_ia32_llwpcb64 (void *);
9172 void * __builtin_ia32_llwpcb16 (void);
9173 void * __builtin_ia32_llwpcb32 (void);
9174 void * __builtin_ia32_llwpcb64 (void);
9175 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
9176 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
9177 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
9178 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
9179 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
9180 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
9181 @end smallexample
9183 The following built-in functions are available when @option{-m3dnow} is used.
9184 All of them generate the machine instruction that is part of the name.
9186 @smallexample
9187 void __builtin_ia32_femms (void)
9188 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
9189 v2si __builtin_ia32_pf2id (v2sf)
9190 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
9191 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
9192 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
9193 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
9194 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
9195 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
9196 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
9197 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
9198 v2sf __builtin_ia32_pfrcp (v2sf)
9199 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
9200 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
9201 v2sf __builtin_ia32_pfrsqrt (v2sf)
9202 v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf)
9203 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
9204 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
9205 v2sf __builtin_ia32_pi2fd (v2si)
9206 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
9207 @end smallexample
9209 The following built-in functions are available when both @option{-m3dnow}
9210 and @option{-march=athlon} are used.  All of them generate the machine
9211 instruction that is part of the name.
9213 @smallexample
9214 v2si __builtin_ia32_pf2iw (v2sf)
9215 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
9216 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
9217 v2sf __builtin_ia32_pi2fw (v2si)
9218 v2sf __builtin_ia32_pswapdsf (v2sf)
9219 v2si __builtin_ia32_pswapdsi (v2si)
9220 @end smallexample
9222 @node MIPS DSP Built-in Functions
9223 @subsection MIPS DSP Built-in Functions
9225 The MIPS DSP Application-Specific Extension (ASE) includes new
9226 instructions that are designed to improve the performance of DSP and
9227 media applications.  It provides instructions that operate on packed
9228 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
9230 GCC supports MIPS DSP operations using both the generic
9231 vector extensions (@pxref{Vector Extensions}) and a collection of
9232 MIPS-specific built-in functions.  Both kinds of support are
9233 enabled by the @option{-mdsp} command-line option.
9235 Revision 2 of the ASE was introduced in the second half of 2006.
9236 This revision adds extra instructions to the original ASE, but is
9237 otherwise backwards-compatible with it.  You can select revision 2
9238 using the command-line option @option{-mdspr2}; this option implies
9239 @option{-mdsp}.
9241 The SCOUNT and POS bits of the DSP control register are global.  The
9242 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
9243 POS bits.  During optimization, the compiler will not delete these
9244 instructions and it will not delete calls to functions containing
9245 these instructions.
9247 At present, GCC only provides support for operations on 32-bit
9248 vectors.  The vector type associated with 8-bit integer data is
9249 usually called @code{v4i8}, the vector type associated with Q7
9250 is usually called @code{v4q7}, the vector type associated with 16-bit
9251 integer data is usually called @code{v2i16}, and the vector type
9252 associated with Q15 is usually called @code{v2q15}.  They can be
9253 defined in C as follows:
9255 @smallexample
9256 typedef signed char v4i8 __attribute__ ((vector_size(4)));
9257 typedef signed char v4q7 __attribute__ ((vector_size(4)));
9258 typedef short v2i16 __attribute__ ((vector_size(4)));
9259 typedef short v2q15 __attribute__ ((vector_size(4)));
9260 @end smallexample
9262 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
9263 initialized in the same way as aggregates.  For example:
9265 @smallexample
9266 v4i8 a = @{1, 2, 3, 4@};
9267 v4i8 b;
9268 b = (v4i8) @{5, 6, 7, 8@};
9270 v2q15 c = @{0x0fcb, 0x3a75@};
9271 v2q15 d;
9272 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
9273 @end smallexample
9275 @emph{Note:} The CPU's endianness determines the order in which values
9276 are packed.  On little-endian targets, the first value is the least
9277 significant and the last value is the most significant.  The opposite
9278 order applies to big-endian targets.  For example, the code above will
9279 set the lowest byte of @code{a} to @code{1} on little-endian targets
9280 and @code{4} on big-endian targets.
9282 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
9283 representation.  As shown in this example, the integer representation
9284 of a Q7 value can be obtained by multiplying the fractional value by
9285 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
9286 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
9287 @code{0x1.0p31}.
9289 The table below lists the @code{v4i8} and @code{v2q15} operations for which
9290 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
9291 and @code{c} and @code{d} are @code{v2q15} values.
9293 @multitable @columnfractions .50 .50
9294 @item C code @tab MIPS instruction
9295 @item @code{a + b} @tab @code{addu.qb}
9296 @item @code{c + d} @tab @code{addq.ph}
9297 @item @code{a - b} @tab @code{subu.qb}
9298 @item @code{c - d} @tab @code{subq.ph}
9299 @end multitable
9301 The table below lists the @code{v2i16} operation for which
9302 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
9303 @code{v2i16} values.
9305 @multitable @columnfractions .50 .50
9306 @item C code @tab MIPS instruction
9307 @item @code{e * f} @tab @code{mul.ph}
9308 @end multitable
9310 It is easier to describe the DSP built-in functions if we first define
9311 the following types:
9313 @smallexample
9314 typedef int q31;
9315 typedef int i32;
9316 typedef unsigned int ui32;
9317 typedef long long a64;
9318 @end smallexample
9320 @code{q31} and @code{i32} are actually the same as @code{int}, but we
9321 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
9322 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
9323 @code{long long}, but we use @code{a64} to indicate values that will
9324 be placed in one of the four DSP accumulators (@code{$ac0},
9325 @code{$ac1}, @code{$ac2} or @code{$ac3}).
9327 Also, some built-in functions prefer or require immediate numbers as
9328 parameters, because the corresponding DSP instructions accept both immediate
9329 numbers and register operands, or accept immediate numbers only.  The
9330 immediate parameters are listed as follows.
9332 @smallexample
9333 imm0_3: 0 to 3.
9334 imm0_7: 0 to 7.
9335 imm0_15: 0 to 15.
9336 imm0_31: 0 to 31.
9337 imm0_63: 0 to 63.
9338 imm0_255: 0 to 255.
9339 imm_n32_31: -32 to 31.
9340 imm_n512_511: -512 to 511.
9341 @end smallexample
9343 The following built-in functions map directly to a particular MIPS DSP
9344 instruction.  Please refer to the architecture specification
9345 for details on what each instruction does.
9347 @smallexample
9348 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
9349 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
9350 q31 __builtin_mips_addq_s_w (q31, q31)
9351 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
9352 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
9353 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
9354 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
9355 q31 __builtin_mips_subq_s_w (q31, q31)
9356 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
9357 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
9358 i32 __builtin_mips_addsc (i32, i32)
9359 i32 __builtin_mips_addwc (i32, i32)
9360 i32 __builtin_mips_modsub (i32, i32)
9361 i32 __builtin_mips_raddu_w_qb (v4i8)
9362 v2q15 __builtin_mips_absq_s_ph (v2q15)
9363 q31 __builtin_mips_absq_s_w (q31)
9364 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
9365 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
9366 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
9367 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
9368 q31 __builtin_mips_preceq_w_phl (v2q15)
9369 q31 __builtin_mips_preceq_w_phr (v2q15)
9370 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
9371 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
9372 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
9373 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
9374 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
9375 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
9376 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
9377 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
9378 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
9379 v4i8 __builtin_mips_shll_qb (v4i8, i32)
9380 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
9381 v2q15 __builtin_mips_shll_ph (v2q15, i32)
9382 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
9383 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
9384 q31 __builtin_mips_shll_s_w (q31, imm0_31)
9385 q31 __builtin_mips_shll_s_w (q31, i32)
9386 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
9387 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
9388 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
9389 v2q15 __builtin_mips_shra_ph (v2q15, i32)
9390 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
9391 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
9392 q31 __builtin_mips_shra_r_w (q31, imm0_31)
9393 q31 __builtin_mips_shra_r_w (q31, i32)
9394 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
9395 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
9396 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
9397 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
9398 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
9399 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
9400 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
9401 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
9402 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
9403 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
9404 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
9405 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
9406 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
9407 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
9408 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
9409 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
9410 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
9411 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
9412 i32 __builtin_mips_bitrev (i32)
9413 i32 __builtin_mips_insv (i32, i32)
9414 v4i8 __builtin_mips_repl_qb (imm0_255)
9415 v4i8 __builtin_mips_repl_qb (i32)
9416 v2q15 __builtin_mips_repl_ph (imm_n512_511)
9417 v2q15 __builtin_mips_repl_ph (i32)
9418 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
9419 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
9420 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
9421 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
9422 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
9423 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
9424 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
9425 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
9426 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
9427 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
9428 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
9429 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
9430 i32 __builtin_mips_extr_w (a64, imm0_31)
9431 i32 __builtin_mips_extr_w (a64, i32)
9432 i32 __builtin_mips_extr_r_w (a64, imm0_31)
9433 i32 __builtin_mips_extr_s_h (a64, i32)
9434 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
9435 i32 __builtin_mips_extr_rs_w (a64, i32)
9436 i32 __builtin_mips_extr_s_h (a64, imm0_31)
9437 i32 __builtin_mips_extr_r_w (a64, i32)
9438 i32 __builtin_mips_extp (a64, imm0_31)
9439 i32 __builtin_mips_extp (a64, i32)
9440 i32 __builtin_mips_extpdp (a64, imm0_31)
9441 i32 __builtin_mips_extpdp (a64, i32)
9442 a64 __builtin_mips_shilo (a64, imm_n32_31)
9443 a64 __builtin_mips_shilo (a64, i32)
9444 a64 __builtin_mips_mthlip (a64, i32)
9445 void __builtin_mips_wrdsp (i32, imm0_63)
9446 i32 __builtin_mips_rddsp (imm0_63)
9447 i32 __builtin_mips_lbux (void *, i32)
9448 i32 __builtin_mips_lhx (void *, i32)
9449 i32 __builtin_mips_lwx (void *, i32)
9450 i32 __builtin_mips_bposge32 (void)
9451 @end smallexample
9453 The following built-in functions map directly to a particular MIPS DSP REV 2
9454 instruction.  Please refer to the architecture specification
9455 for details on what each instruction does.
9457 @smallexample
9458 v4q7 __builtin_mips_absq_s_qb (v4q7);
9459 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
9460 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
9461 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
9462 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
9463 i32 __builtin_mips_append (i32, i32, imm0_31);
9464 i32 __builtin_mips_balign (i32, i32, imm0_3);
9465 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
9466 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
9467 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
9468 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
9469 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
9470 a64 __builtin_mips_madd (a64, i32, i32);
9471 a64 __builtin_mips_maddu (a64, ui32, ui32);
9472 a64 __builtin_mips_msub (a64, i32, i32);
9473 a64 __builtin_mips_msubu (a64, ui32, ui32);
9474 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
9475 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
9476 q31 __builtin_mips_mulq_rs_w (q31, q31);
9477 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
9478 q31 __builtin_mips_mulq_s_w (q31, q31);
9479 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
9480 a64 __builtin_mips_mult (i32, i32);
9481 a64 __builtin_mips_multu (ui32, ui32);
9482 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
9483 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
9484 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
9485 i32 __builtin_mips_prepend (i32, i32, imm0_31);
9486 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
9487 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
9488 v4i8 __builtin_mips_shra_qb (v4i8, i32);
9489 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
9490 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
9491 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
9492 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
9493 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
9494 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
9495 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
9496 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
9497 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
9498 q31 __builtin_mips_addqh_w (q31, q31);
9499 q31 __builtin_mips_addqh_r_w (q31, q31);
9500 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
9501 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
9502 q31 __builtin_mips_subqh_w (q31, q31);
9503 q31 __builtin_mips_subqh_r_w (q31, q31);
9504 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
9505 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
9506 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
9507 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
9508 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
9509 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
9510 @end smallexample
9513 @node MIPS Paired-Single Support
9514 @subsection MIPS Paired-Single Support
9516 The MIPS64 architecture includes a number of instructions that
9517 operate on pairs of single-precision floating-point values.
9518 Each pair is packed into a 64-bit floating-point register,
9519 with one element being designated the ``upper half'' and
9520 the other being designated the ``lower half''.
9522 GCC supports paired-single operations using both the generic
9523 vector extensions (@pxref{Vector Extensions}) and a collection of
9524 MIPS-specific built-in functions.  Both kinds of support are
9525 enabled by the @option{-mpaired-single} command-line option.
9527 The vector type associated with paired-single values is usually
9528 called @code{v2sf}.  It can be defined in C as follows:
9530 @smallexample
9531 typedef float v2sf __attribute__ ((vector_size (8)));
9532 @end smallexample
9534 @code{v2sf} values are initialized in the same way as aggregates.
9535 For example:
9537 @smallexample
9538 v2sf a = @{1.5, 9.1@};
9539 v2sf b;
9540 float e, f;
9541 b = (v2sf) @{e, f@};
9542 @end smallexample
9544 @emph{Note:} The CPU's endianness determines which value is stored in
9545 the upper half of a register and which value is stored in the lower half.
9546 On little-endian targets, the first value is the lower one and the second
9547 value is the upper one.  The opposite order applies to big-endian targets.
9548 For example, the code above will set the lower half of @code{a} to
9549 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
9551 @node MIPS Loongson Built-in Functions
9552 @subsection MIPS Loongson Built-in Functions
9554 GCC provides intrinsics to access the SIMD instructions provided by the
9555 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
9556 available after inclusion of the @code{loongson.h} header file,
9557 operate on the following 64-bit vector types:
9559 @itemize
9560 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
9561 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
9562 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
9563 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
9564 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
9565 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
9566 @end itemize
9568 The intrinsics provided are listed below; each is named after the
9569 machine instruction to which it corresponds, with suffixes added as
9570 appropriate to distinguish intrinsics that expand to the same machine
9571 instruction yet have different argument types.  Refer to the architecture
9572 documentation for a description of the functionality of each
9573 instruction.
9575 @smallexample
9576 int16x4_t packsswh (int32x2_t s, int32x2_t t);
9577 int8x8_t packsshb (int16x4_t s, int16x4_t t);
9578 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
9579 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
9580 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
9581 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
9582 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
9583 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
9584 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
9585 uint64_t paddd_u (uint64_t s, uint64_t t);
9586 int64_t paddd_s (int64_t s, int64_t t);
9587 int16x4_t paddsh (int16x4_t s, int16x4_t t);
9588 int8x8_t paddsb (int8x8_t s, int8x8_t t);
9589 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
9590 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
9591 uint64_t pandn_ud (uint64_t s, uint64_t t);
9592 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
9593 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
9594 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
9595 int64_t pandn_sd (int64_t s, int64_t t);
9596 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
9597 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
9598 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
9599 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
9600 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
9601 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
9602 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
9603 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
9604 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
9605 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
9606 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
9607 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
9608 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
9609 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
9610 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
9611 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
9612 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
9613 uint16x4_t pextrh_u (uint16x4_t s, int field);
9614 int16x4_t pextrh_s (int16x4_t s, int field);
9615 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
9616 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
9617 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
9618 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
9619 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
9620 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
9621 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
9622 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
9623 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
9624 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
9625 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
9626 int16x4_t pminsh (int16x4_t s, int16x4_t t);
9627 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
9628 uint8x8_t pmovmskb_u (uint8x8_t s);
9629 int8x8_t pmovmskb_s (int8x8_t s);
9630 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
9631 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
9632 int16x4_t pmullh (int16x4_t s, int16x4_t t);
9633 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
9634 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
9635 uint16x4_t biadd (uint8x8_t s);
9636 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
9637 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
9638 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
9639 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
9640 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
9641 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
9642 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
9643 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
9644 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
9645 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
9646 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
9647 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
9648 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
9649 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
9650 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
9651 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
9652 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
9653 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
9654 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
9655 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
9656 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
9657 uint64_t psubd_u (uint64_t s, uint64_t t);
9658 int64_t psubd_s (int64_t s, int64_t t);
9659 int16x4_t psubsh (int16x4_t s, int16x4_t t);
9660 int8x8_t psubsb (int8x8_t s, int8x8_t t);
9661 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
9662 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
9663 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
9664 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
9665 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
9666 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
9667 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
9668 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
9669 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
9670 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
9671 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
9672 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
9673 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
9674 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
9675 @end smallexample
9677 @menu
9678 * Paired-Single Arithmetic::
9679 * Paired-Single Built-in Functions::
9680 * MIPS-3D Built-in Functions::
9681 @end menu
9683 @node Paired-Single Arithmetic
9684 @subsubsection Paired-Single Arithmetic
9686 The table below lists the @code{v2sf} operations for which hardware
9687 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
9688 values and @code{x} is an integral value.
9690 @multitable @columnfractions .50 .50
9691 @item C code @tab MIPS instruction
9692 @item @code{a + b} @tab @code{add.ps}
9693 @item @code{a - b} @tab @code{sub.ps}
9694 @item @code{-a} @tab @code{neg.ps}
9695 @item @code{a * b} @tab @code{mul.ps}
9696 @item @code{a * b + c} @tab @code{madd.ps}
9697 @item @code{a * b - c} @tab @code{msub.ps}
9698 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
9699 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
9700 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
9701 @end multitable
9703 Note that the multiply-accumulate instructions can be disabled
9704 using the command-line option @code{-mno-fused-madd}.
9706 @node Paired-Single Built-in Functions
9707 @subsubsection Paired-Single Built-in Functions
9709 The following paired-single functions map directly to a particular
9710 MIPS instruction.  Please refer to the architecture specification
9711 for details on what each instruction does.
9713 @table @code
9714 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
9715 Pair lower lower (@code{pll.ps}).
9717 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
9718 Pair upper lower (@code{pul.ps}).
9720 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
9721 Pair lower upper (@code{plu.ps}).
9723 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
9724 Pair upper upper (@code{puu.ps}).
9726 @item v2sf __builtin_mips_cvt_ps_s (float, float)
9727 Convert pair to paired single (@code{cvt.ps.s}).
9729 @item float __builtin_mips_cvt_s_pl (v2sf)
9730 Convert pair lower to single (@code{cvt.s.pl}).
9732 @item float __builtin_mips_cvt_s_pu (v2sf)
9733 Convert pair upper to single (@code{cvt.s.pu}).
9735 @item v2sf __builtin_mips_abs_ps (v2sf)
9736 Absolute value (@code{abs.ps}).
9738 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
9739 Align variable (@code{alnv.ps}).
9741 @emph{Note:} The value of the third parameter must be 0 or 4
9742 modulo 8, otherwise the result will be unpredictable.  Please read the
9743 instruction description for details.
9744 @end table
9746 The following multi-instruction functions are also available.
9747 In each case, @var{cond} can be any of the 16 floating-point conditions:
9748 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
9749 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
9750 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
9752 @table @code
9753 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9754 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9755 Conditional move based on floating point comparison (@code{c.@var{cond}.ps},
9756 @code{movt.ps}/@code{movf.ps}).
9758 The @code{movt} functions return the value @var{x} computed by:
9760 @smallexample
9761 c.@var{cond}.ps @var{cc},@var{a},@var{b}
9762 mov.ps @var{x},@var{c}
9763 movt.ps @var{x},@var{d},@var{cc}
9764 @end smallexample
9766 The @code{movf} functions are similar but use @code{movf.ps} instead
9767 of @code{movt.ps}.
9769 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9770 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9771 Comparison of two paired-single values (@code{c.@var{cond}.ps},
9772 @code{bc1t}/@code{bc1f}).
9774 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
9775 and return either the upper or lower half of the result.  For example:
9777 @smallexample
9778 v2sf a, b;
9779 if (__builtin_mips_upper_c_eq_ps (a, b))
9780   upper_halves_are_equal ();
9781 else
9782   upper_halves_are_unequal ();
9784 if (__builtin_mips_lower_c_eq_ps (a, b))
9785   lower_halves_are_equal ();
9786 else
9787   lower_halves_are_unequal ();
9788 @end smallexample
9789 @end table
9791 @node MIPS-3D Built-in Functions
9792 @subsubsection MIPS-3D Built-in Functions
9794 The MIPS-3D Application-Specific Extension (ASE) includes additional
9795 paired-single instructions that are designed to improve the performance
9796 of 3D graphics operations.  Support for these instructions is controlled
9797 by the @option{-mips3d} command-line option.
9799 The functions listed below map directly to a particular MIPS-3D
9800 instruction.  Please refer to the architecture specification for
9801 more details on what each instruction does.
9803 @table @code
9804 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
9805 Reduction add (@code{addr.ps}).
9807 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
9808 Reduction multiply (@code{mulr.ps}).
9810 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
9811 Convert paired single to paired word (@code{cvt.pw.ps}).
9813 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
9814 Convert paired word to paired single (@code{cvt.ps.pw}).
9816 @item float __builtin_mips_recip1_s (float)
9817 @itemx double __builtin_mips_recip1_d (double)
9818 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
9819 Reduced precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
9821 @item float __builtin_mips_recip2_s (float, float)
9822 @itemx double __builtin_mips_recip2_d (double, double)
9823 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
9824 Reduced precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
9826 @item float __builtin_mips_rsqrt1_s (float)
9827 @itemx double __builtin_mips_rsqrt1_d (double)
9828 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
9829 Reduced precision reciprocal square root (sequence step 1)
9830 (@code{rsqrt1.@var{fmt}}).
9832 @item float __builtin_mips_rsqrt2_s (float, float)
9833 @itemx double __builtin_mips_rsqrt2_d (double, double)
9834 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
9835 Reduced precision reciprocal square root (sequence step 2)
9836 (@code{rsqrt2.@var{fmt}}).
9837 @end table
9839 The following multi-instruction functions are also available.
9840 In each case, @var{cond} can be any of the 16 floating-point conditions:
9841 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
9842 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
9843 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
9845 @table @code
9846 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
9847 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
9848 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
9849 @code{bc1t}/@code{bc1f}).
9851 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
9852 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
9853 For example:
9855 @smallexample
9856 float a, b;
9857 if (__builtin_mips_cabs_eq_s (a, b))
9858   true ();
9859 else
9860   false ();
9861 @end smallexample
9863 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9864 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9865 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
9866 @code{bc1t}/@code{bc1f}).
9868 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
9869 and return either the upper or lower half of the result.  For example:
9871 @smallexample
9872 v2sf a, b;
9873 if (__builtin_mips_upper_cabs_eq_ps (a, b))
9874   upper_halves_are_equal ();
9875 else
9876   upper_halves_are_unequal ();
9878 if (__builtin_mips_lower_cabs_eq_ps (a, b))
9879   lower_halves_are_equal ();
9880 else
9881   lower_halves_are_unequal ();
9882 @end smallexample
9884 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9885 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9886 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
9887 @code{movt.ps}/@code{movf.ps}).
9889 The @code{movt} functions return the value @var{x} computed by:
9891 @smallexample
9892 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
9893 mov.ps @var{x},@var{c}
9894 movt.ps @var{x},@var{d},@var{cc}
9895 @end smallexample
9897 The @code{movf} functions are similar but use @code{movf.ps} instead
9898 of @code{movt.ps}.
9900 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9901 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9902 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9903 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9904 Comparison of two paired-single values
9905 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
9906 @code{bc1any2t}/@code{bc1any2f}).
9908 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
9909 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
9910 result is true and the @code{all} forms return true if both results are true.
9911 For example:
9913 @smallexample
9914 v2sf a, b;
9915 if (__builtin_mips_any_c_eq_ps (a, b))
9916   one_is_true ();
9917 else
9918   both_are_false ();
9920 if (__builtin_mips_all_c_eq_ps (a, b))
9921   both_are_true ();
9922 else
9923   one_is_false ();
9924 @end smallexample
9926 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9927 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9928 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9929 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9930 Comparison of four paired-single values
9931 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
9932 @code{bc1any4t}/@code{bc1any4f}).
9934 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
9935 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
9936 The @code{any} forms return true if any of the four results are true
9937 and the @code{all} forms return true if all four results are true.
9938 For example:
9940 @smallexample
9941 v2sf a, b, c, d;
9942 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
9943   some_are_true ();
9944 else
9945   all_are_false ();
9947 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
9948   all_are_true ();
9949 else
9950   some_are_false ();
9951 @end smallexample
9952 @end table
9954 @node picoChip Built-in Functions
9955 @subsection picoChip Built-in Functions
9957 GCC provides an interface to selected machine instructions from the
9958 picoChip instruction set.
9960 @table @code
9961 @item int __builtin_sbc (int @var{value})
9962 Sign bit count.  Return the number of consecutive bits in @var{value}
9963 which have the same value as the sign-bit.  The result is the number of
9964 leading sign bits minus one, giving the number of redundant sign bits in
9965 @var{value}.
9967 @item int __builtin_byteswap (int @var{value})
9968 Byte swap.  Return the result of swapping the upper and lower bytes of
9969 @var{value}.
9971 @item int __builtin_brev (int @var{value})
9972 Bit reversal.  Return the result of reversing the bits in
9973 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
9974 and so on.
9976 @item int __builtin_adds (int @var{x}, int @var{y})
9977 Saturating addition.  Return the result of adding @var{x} and @var{y},
9978 storing the value 32767 if the result overflows.
9980 @item int __builtin_subs (int @var{x}, int @var{y})
9981 Saturating subtraction.  Return the result of subtracting @var{y} from
9982 @var{x}, storing the value @minus{}32768 if the result overflows.
9984 @item void __builtin_halt (void)
9985 Halt.  The processor will stop execution.  This built-in is useful for
9986 implementing assertions.
9988 @end table
9990 @node Other MIPS Built-in Functions
9991 @subsection Other MIPS Built-in Functions
9993 GCC provides other MIPS-specific built-in functions:
9995 @table @code
9996 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
9997 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
9998 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
9999 when this function is available.
10000 @end table
10002 @node PowerPC AltiVec/VSX Built-in Functions
10003 @subsection PowerPC AltiVec Built-in Functions
10005 GCC provides an interface for the PowerPC family of processors to access
10006 the AltiVec operations described in Motorola's AltiVec Programming
10007 Interface Manual.  The interface is made available by including
10008 @code{<altivec.h>} and using @option{-maltivec} and
10009 @option{-mabi=altivec}.  The interface supports the following vector
10010 types.
10012 @smallexample
10013 vector unsigned char
10014 vector signed char
10015 vector bool char
10017 vector unsigned short
10018 vector signed short
10019 vector bool short
10020 vector pixel
10022 vector unsigned int
10023 vector signed int
10024 vector bool int
10025 vector float
10026 @end smallexample
10028 If @option{-mvsx} is used the following additional vector types are
10029 implemented.
10031 @smallexample
10032 vector unsigned long
10033 vector signed long
10034 vector double
10035 @end smallexample
10037 The long types are only implemented for 64-bit code generation, and
10038 the long type is only used in the floating point/integer conversion
10039 instructions.
10041 GCC's implementation of the high-level language interface available from
10042 C and C++ code differs from Motorola's documentation in several ways.
10044 @itemize @bullet
10046 @item
10047 A vector constant is a list of constant expressions within curly braces.
10049 @item
10050 A vector initializer requires no cast if the vector constant is of the
10051 same type as the variable it is initializing.
10053 @item
10054 If @code{signed} or @code{unsigned} is omitted, the signedness of the
10055 vector type is the default signedness of the base type.  The default
10056 varies depending on the operating system, so a portable program should
10057 always specify the signedness.
10059 @item
10060 Compiling with @option{-maltivec} adds keywords @code{__vector},
10061 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
10062 @code{bool}.  When compiling ISO C, the context-sensitive substitution
10063 of the keywords @code{vector}, @code{pixel} and @code{bool} is
10064 disabled.  To use them, you must include @code{<altivec.h>} instead.
10066 @item
10067 GCC allows using a @code{typedef} name as the type specifier for a
10068 vector type.
10070 @item
10071 For C, overloaded functions are implemented with macros so the following
10072 does not work:
10074 @smallexample
10075   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
10076 @end smallexample
10078 Since @code{vec_add} is a macro, the vector constant in the example
10079 is treated as four separate arguments.  Wrap the entire argument in
10080 parentheses for this to work.
10081 @end itemize
10083 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
10084 Internally, GCC uses built-in functions to achieve the functionality in
10085 the aforementioned header file, but they are not supported and are
10086 subject to change without notice.
10088 The following interfaces are supported for the generic and specific
10089 AltiVec operations and the AltiVec predicates.  In cases where there
10090 is a direct mapping between generic and specific operations, only the
10091 generic names are shown here, although the specific operations can also
10092 be used.
10094 Arguments that are documented as @code{const int} require literal
10095 integral values within the range required for that operation.
10097 @smallexample
10098 vector signed char vec_abs (vector signed char);
10099 vector signed short vec_abs (vector signed short);
10100 vector signed int vec_abs (vector signed int);
10101 vector float vec_abs (vector float);
10103 vector signed char vec_abss (vector signed char);
10104 vector signed short vec_abss (vector signed short);
10105 vector signed int vec_abss (vector signed int);
10107 vector signed char vec_add (vector bool char, vector signed char);
10108 vector signed char vec_add (vector signed char, vector bool char);
10109 vector signed char vec_add (vector signed char, vector signed char);
10110 vector unsigned char vec_add (vector bool char, vector unsigned char);
10111 vector unsigned char vec_add (vector unsigned char, vector bool char);
10112 vector unsigned char vec_add (vector unsigned char,
10113                               vector unsigned char);
10114 vector signed short vec_add (vector bool short, vector signed short);
10115 vector signed short vec_add (vector signed short, vector bool short);
10116 vector signed short vec_add (vector signed short, vector signed short);
10117 vector unsigned short vec_add (vector bool short,
10118                                vector unsigned short);
10119 vector unsigned short vec_add (vector unsigned short,
10120                                vector bool short);
10121 vector unsigned short vec_add (vector unsigned short,
10122                                vector unsigned short);
10123 vector signed int vec_add (vector bool int, vector signed int);
10124 vector signed int vec_add (vector signed int, vector bool int);
10125 vector signed int vec_add (vector signed int, vector signed int);
10126 vector unsigned int vec_add (vector bool int, vector unsigned int);
10127 vector unsigned int vec_add (vector unsigned int, vector bool int);
10128 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
10129 vector float vec_add (vector float, vector float);
10131 vector float vec_vaddfp (vector float, vector float);
10133 vector signed int vec_vadduwm (vector bool int, vector signed int);
10134 vector signed int vec_vadduwm (vector signed int, vector bool int);
10135 vector signed int vec_vadduwm (vector signed int, vector signed int);
10136 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
10137 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
10138 vector unsigned int vec_vadduwm (vector unsigned int,
10139                                  vector unsigned int);
10141 vector signed short vec_vadduhm (vector bool short,
10142                                  vector signed short);
10143 vector signed short vec_vadduhm (vector signed short,
10144                                  vector bool short);
10145 vector signed short vec_vadduhm (vector signed short,
10146                                  vector signed short);
10147 vector unsigned short vec_vadduhm (vector bool short,
10148                                    vector unsigned short);
10149 vector unsigned short vec_vadduhm (vector unsigned short,
10150                                    vector bool short);
10151 vector unsigned short vec_vadduhm (vector unsigned short,
10152                                    vector unsigned short);
10154 vector signed char vec_vaddubm (vector bool char, vector signed char);
10155 vector signed char vec_vaddubm (vector signed char, vector bool char);
10156 vector signed char vec_vaddubm (vector signed char, vector signed char);
10157 vector unsigned char vec_vaddubm (vector bool char,
10158                                   vector unsigned char);
10159 vector unsigned char vec_vaddubm (vector unsigned char,
10160                                   vector bool char);
10161 vector unsigned char vec_vaddubm (vector unsigned char,
10162                                   vector unsigned char);
10164 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
10166 vector unsigned char vec_adds (vector bool char, vector unsigned char);
10167 vector unsigned char vec_adds (vector unsigned char, vector bool char);
10168 vector unsigned char vec_adds (vector unsigned char,
10169                                vector unsigned char);
10170 vector signed char vec_adds (vector bool char, vector signed char);
10171 vector signed char vec_adds (vector signed char, vector bool char);
10172 vector signed char vec_adds (vector signed char, vector signed char);
10173 vector unsigned short vec_adds (vector bool short,
10174                                 vector unsigned short);
10175 vector unsigned short vec_adds (vector unsigned short,
10176                                 vector bool short);
10177 vector unsigned short vec_adds (vector unsigned short,
10178                                 vector unsigned short);
10179 vector signed short vec_adds (vector bool short, vector signed short);
10180 vector signed short vec_adds (vector signed short, vector bool short);
10181 vector signed short vec_adds (vector signed short, vector signed short);
10182 vector unsigned int vec_adds (vector bool int, vector unsigned int);
10183 vector unsigned int vec_adds (vector unsigned int, vector bool int);
10184 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
10185 vector signed int vec_adds (vector bool int, vector signed int);
10186 vector signed int vec_adds (vector signed int, vector bool int);
10187 vector signed int vec_adds (vector signed int, vector signed int);
10189 vector signed int vec_vaddsws (vector bool int, vector signed int);
10190 vector signed int vec_vaddsws (vector signed int, vector bool int);
10191 vector signed int vec_vaddsws (vector signed int, vector signed int);
10193 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
10194 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
10195 vector unsigned int vec_vadduws (vector unsigned int,
10196                                  vector unsigned int);
10198 vector signed short vec_vaddshs (vector bool short,
10199                                  vector signed short);
10200 vector signed short vec_vaddshs (vector signed short,
10201                                  vector bool short);
10202 vector signed short vec_vaddshs (vector signed short,
10203                                  vector signed short);
10205 vector unsigned short vec_vadduhs (vector bool short,
10206                                    vector unsigned short);
10207 vector unsigned short vec_vadduhs (vector unsigned short,
10208                                    vector bool short);
10209 vector unsigned short vec_vadduhs (vector unsigned short,
10210                                    vector unsigned short);
10212 vector signed char vec_vaddsbs (vector bool char, vector signed char);
10213 vector signed char vec_vaddsbs (vector signed char, vector bool char);
10214 vector signed char vec_vaddsbs (vector signed char, vector signed char);
10216 vector unsigned char vec_vaddubs (vector bool char,
10217                                   vector unsigned char);
10218 vector unsigned char vec_vaddubs (vector unsigned char,
10219                                   vector bool char);
10220 vector unsigned char vec_vaddubs (vector unsigned char,
10221                                   vector unsigned char);
10223 vector float vec_and (vector float, vector float);
10224 vector float vec_and (vector float, vector bool int);
10225 vector float vec_and (vector bool int, vector float);
10226 vector bool int vec_and (vector bool int, vector bool int);
10227 vector signed int vec_and (vector bool int, vector signed int);
10228 vector signed int vec_and (vector signed int, vector bool int);
10229 vector signed int vec_and (vector signed int, vector signed int);
10230 vector unsigned int vec_and (vector bool int, vector unsigned int);
10231 vector unsigned int vec_and (vector unsigned int, vector bool int);
10232 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
10233 vector bool short vec_and (vector bool short, vector bool short);
10234 vector signed short vec_and (vector bool short, vector signed short);
10235 vector signed short vec_and (vector signed short, vector bool short);
10236 vector signed short vec_and (vector signed short, vector signed short);
10237 vector unsigned short vec_and (vector bool short,
10238                                vector unsigned short);
10239 vector unsigned short vec_and (vector unsigned short,
10240                                vector bool short);
10241 vector unsigned short vec_and (vector unsigned short,
10242                                vector unsigned short);
10243 vector signed char vec_and (vector bool char, vector signed char);
10244 vector bool char vec_and (vector bool char, vector bool char);
10245 vector signed char vec_and (vector signed char, vector bool char);
10246 vector signed char vec_and (vector signed char, vector signed char);
10247 vector unsigned char vec_and (vector bool char, vector unsigned char);
10248 vector unsigned char vec_and (vector unsigned char, vector bool char);
10249 vector unsigned char vec_and (vector unsigned char,
10250                               vector unsigned char);
10252 vector float vec_andc (vector float, vector float);
10253 vector float vec_andc (vector float, vector bool int);
10254 vector float vec_andc (vector bool int, vector float);
10255 vector bool int vec_andc (vector bool int, vector bool int);
10256 vector signed int vec_andc (vector bool int, vector signed int);
10257 vector signed int vec_andc (vector signed int, vector bool int);
10258 vector signed int vec_andc (vector signed int, vector signed int);
10259 vector unsigned int vec_andc (vector bool int, vector unsigned int);
10260 vector unsigned int vec_andc (vector unsigned int, vector bool int);
10261 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
10262 vector bool short vec_andc (vector bool short, vector bool short);
10263 vector signed short vec_andc (vector bool short, vector signed short);
10264 vector signed short vec_andc (vector signed short, vector bool short);
10265 vector signed short vec_andc (vector signed short, vector signed short);
10266 vector unsigned short vec_andc (vector bool short,
10267                                 vector unsigned short);
10268 vector unsigned short vec_andc (vector unsigned short,
10269                                 vector bool short);
10270 vector unsigned short vec_andc (vector unsigned short,
10271                                 vector unsigned short);
10272 vector signed char vec_andc (vector bool char, vector signed char);
10273 vector bool char vec_andc (vector bool char, vector bool char);
10274 vector signed char vec_andc (vector signed char, vector bool char);
10275 vector signed char vec_andc (vector signed char, vector signed char);
10276 vector unsigned char vec_andc (vector bool char, vector unsigned char);
10277 vector unsigned char vec_andc (vector unsigned char, vector bool char);
10278 vector unsigned char vec_andc (vector unsigned char,
10279                                vector unsigned char);
10281 vector unsigned char vec_avg (vector unsigned char,
10282                               vector unsigned char);
10283 vector signed char vec_avg (vector signed char, vector signed char);
10284 vector unsigned short vec_avg (vector unsigned short,
10285                                vector unsigned short);
10286 vector signed short vec_avg (vector signed short, vector signed short);
10287 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
10288 vector signed int vec_avg (vector signed int, vector signed int);
10290 vector signed int vec_vavgsw (vector signed int, vector signed int);
10292 vector unsigned int vec_vavguw (vector unsigned int,
10293                                 vector unsigned int);
10295 vector signed short vec_vavgsh (vector signed short,
10296                                 vector signed short);
10298 vector unsigned short vec_vavguh (vector unsigned short,
10299                                   vector unsigned short);
10301 vector signed char vec_vavgsb (vector signed char, vector signed char);
10303 vector unsigned char vec_vavgub (vector unsigned char,
10304                                  vector unsigned char);
10306 vector float vec_copysign (vector float);
10308 vector float vec_ceil (vector float);
10310 vector signed int vec_cmpb (vector float, vector float);
10312 vector bool char vec_cmpeq (vector signed char, vector signed char);
10313 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
10314 vector bool short vec_cmpeq (vector signed short, vector signed short);
10315 vector bool short vec_cmpeq (vector unsigned short,
10316                              vector unsigned short);
10317 vector bool int vec_cmpeq (vector signed int, vector signed int);
10318 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
10319 vector bool int vec_cmpeq (vector float, vector float);
10321 vector bool int vec_vcmpeqfp (vector float, vector float);
10323 vector bool int vec_vcmpequw (vector signed int, vector signed int);
10324 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
10326 vector bool short vec_vcmpequh (vector signed short,
10327                                 vector signed short);
10328 vector bool short vec_vcmpequh (vector unsigned short,
10329                                 vector unsigned short);
10331 vector bool char vec_vcmpequb (vector signed char, vector signed char);
10332 vector bool char vec_vcmpequb (vector unsigned char,
10333                                vector unsigned char);
10335 vector bool int vec_cmpge (vector float, vector float);
10337 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
10338 vector bool char vec_cmpgt (vector signed char, vector signed char);
10339 vector bool short vec_cmpgt (vector unsigned short,
10340                              vector unsigned short);
10341 vector bool short vec_cmpgt (vector signed short, vector signed short);
10342 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
10343 vector bool int vec_cmpgt (vector signed int, vector signed int);
10344 vector bool int vec_cmpgt (vector float, vector float);
10346 vector bool int vec_vcmpgtfp (vector float, vector float);
10348 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
10350 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
10352 vector bool short vec_vcmpgtsh (vector signed short,
10353                                 vector signed short);
10355 vector bool short vec_vcmpgtuh (vector unsigned short,
10356                                 vector unsigned short);
10358 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
10360 vector bool char vec_vcmpgtub (vector unsigned char,
10361                                vector unsigned char);
10363 vector bool int vec_cmple (vector float, vector float);
10365 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
10366 vector bool char vec_cmplt (vector signed char, vector signed char);
10367 vector bool short vec_cmplt (vector unsigned short,
10368                              vector unsigned short);
10369 vector bool short vec_cmplt (vector signed short, vector signed short);
10370 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
10371 vector bool int vec_cmplt (vector signed int, vector signed int);
10372 vector bool int vec_cmplt (vector float, vector float);
10374 vector float vec_ctf (vector unsigned int, const int);
10375 vector float vec_ctf (vector signed int, const int);
10377 vector float vec_vcfsx (vector signed int, const int);
10379 vector float vec_vcfux (vector unsigned int, const int);
10381 vector signed int vec_cts (vector float, const int);
10383 vector unsigned int vec_ctu (vector float, const int);
10385 void vec_dss (const int);
10387 void vec_dssall (void);
10389 void vec_dst (const vector unsigned char *, int, const int);
10390 void vec_dst (const vector signed char *, int, const int);
10391 void vec_dst (const vector bool char *, int, const int);
10392 void vec_dst (const vector unsigned short *, int, const int);
10393 void vec_dst (const vector signed short *, int, const int);
10394 void vec_dst (const vector bool short *, int, const int);
10395 void vec_dst (const vector pixel *, int, const int);
10396 void vec_dst (const vector unsigned int *, int, const int);
10397 void vec_dst (const vector signed int *, int, const int);
10398 void vec_dst (const vector bool int *, int, const int);
10399 void vec_dst (const vector float *, int, const int);
10400 void vec_dst (const unsigned char *, int, const int);
10401 void vec_dst (const signed char *, int, const int);
10402 void vec_dst (const unsigned short *, int, const int);
10403 void vec_dst (const short *, int, const int);
10404 void vec_dst (const unsigned int *, int, const int);
10405 void vec_dst (const int *, int, const int);
10406 void vec_dst (const unsigned long *, int, const int);
10407 void vec_dst (const long *, int, const int);
10408 void vec_dst (const float *, int, const int);
10410 void vec_dstst (const vector unsigned char *, int, const int);
10411 void vec_dstst (const vector signed char *, int, const int);
10412 void vec_dstst (const vector bool char *, int, const int);
10413 void vec_dstst (const vector unsigned short *, int, const int);
10414 void vec_dstst (const vector signed short *, int, const int);
10415 void vec_dstst (const vector bool short *, int, const int);
10416 void vec_dstst (const vector pixel *, int, const int);
10417 void vec_dstst (const vector unsigned int *, int, const int);
10418 void vec_dstst (const vector signed int *, int, const int);
10419 void vec_dstst (const vector bool int *, int, const int);
10420 void vec_dstst (const vector float *, int, const int);
10421 void vec_dstst (const unsigned char *, int, const int);
10422 void vec_dstst (const signed char *, int, const int);
10423 void vec_dstst (const unsigned short *, int, const int);
10424 void vec_dstst (const short *, int, const int);
10425 void vec_dstst (const unsigned int *, int, const int);
10426 void vec_dstst (const int *, int, const int);
10427 void vec_dstst (const unsigned long *, int, const int);
10428 void vec_dstst (const long *, int, const int);
10429 void vec_dstst (const float *, int, const int);
10431 void vec_dststt (const vector unsigned char *, int, const int);
10432 void vec_dststt (const vector signed char *, int, const int);
10433 void vec_dststt (const vector bool char *, int, const int);
10434 void vec_dststt (const vector unsigned short *, int, const int);
10435 void vec_dststt (const vector signed short *, int, const int);
10436 void vec_dststt (const vector bool short *, int, const int);
10437 void vec_dststt (const vector pixel *, int, const int);
10438 void vec_dststt (const vector unsigned int *, int, const int);
10439 void vec_dststt (const vector signed int *, int, const int);
10440 void vec_dststt (const vector bool int *, int, const int);
10441 void vec_dststt (const vector float *, int, const int);
10442 void vec_dststt (const unsigned char *, int, const int);
10443 void vec_dststt (const signed char *, int, const int);
10444 void vec_dststt (const unsigned short *, int, const int);
10445 void vec_dststt (const short *, int, const int);
10446 void vec_dststt (const unsigned int *, int, const int);
10447 void vec_dststt (const int *, int, const int);
10448 void vec_dststt (const unsigned long *, int, const int);
10449 void vec_dststt (const long *, int, const int);
10450 void vec_dststt (const float *, int, const int);
10452 void vec_dstt (const vector unsigned char *, int, const int);
10453 void vec_dstt (const vector signed char *, int, const int);
10454 void vec_dstt (const vector bool char *, int, const int);
10455 void vec_dstt (const vector unsigned short *, int, const int);
10456 void vec_dstt (const vector signed short *, int, const int);
10457 void vec_dstt (const vector bool short *, int, const int);
10458 void vec_dstt (const vector pixel *, int, const int);
10459 void vec_dstt (const vector unsigned int *, int, const int);
10460 void vec_dstt (const vector signed int *, int, const int);
10461 void vec_dstt (const vector bool int *, int, const int);
10462 void vec_dstt (const vector float *, int, const int);
10463 void vec_dstt (const unsigned char *, int, const int);
10464 void vec_dstt (const signed char *, int, const int);
10465 void vec_dstt (const unsigned short *, int, const int);
10466 void vec_dstt (const short *, int, const int);
10467 void vec_dstt (const unsigned int *, int, const int);
10468 void vec_dstt (const int *, int, const int);
10469 void vec_dstt (const unsigned long *, int, const int);
10470 void vec_dstt (const long *, int, const int);
10471 void vec_dstt (const float *, int, const int);
10473 vector float vec_expte (vector float);
10475 vector float vec_floor (vector float);
10477 vector float vec_ld (int, const vector float *);
10478 vector float vec_ld (int, const float *);
10479 vector bool int vec_ld (int, const vector bool int *);
10480 vector signed int vec_ld (int, const vector signed int *);
10481 vector signed int vec_ld (int, const int *);
10482 vector signed int vec_ld (int, const long *);
10483 vector unsigned int vec_ld (int, const vector unsigned int *);
10484 vector unsigned int vec_ld (int, const unsigned int *);
10485 vector unsigned int vec_ld (int, const unsigned long *);
10486 vector bool short vec_ld (int, const vector bool short *);
10487 vector pixel vec_ld (int, const vector pixel *);
10488 vector signed short vec_ld (int, const vector signed short *);
10489 vector signed short vec_ld (int, const short *);
10490 vector unsigned short vec_ld (int, const vector unsigned short *);
10491 vector unsigned short vec_ld (int, const unsigned short *);
10492 vector bool char vec_ld (int, const vector bool char *);
10493 vector signed char vec_ld (int, const vector signed char *);
10494 vector signed char vec_ld (int, const signed char *);
10495 vector unsigned char vec_ld (int, const vector unsigned char *);
10496 vector unsigned char vec_ld (int, const unsigned char *);
10498 vector signed char vec_lde (int, const signed char *);
10499 vector unsigned char vec_lde (int, const unsigned char *);
10500 vector signed short vec_lde (int, const short *);
10501 vector unsigned short vec_lde (int, const unsigned short *);
10502 vector float vec_lde (int, const float *);
10503 vector signed int vec_lde (int, const int *);
10504 vector unsigned int vec_lde (int, const unsigned int *);
10505 vector signed int vec_lde (int, const long *);
10506 vector unsigned int vec_lde (int, const unsigned long *);
10508 vector float vec_lvewx (int, float *);
10509 vector signed int vec_lvewx (int, int *);
10510 vector unsigned int vec_lvewx (int, unsigned int *);
10511 vector signed int vec_lvewx (int, long *);
10512 vector unsigned int vec_lvewx (int, unsigned long *);
10514 vector signed short vec_lvehx (int, short *);
10515 vector unsigned short vec_lvehx (int, unsigned short *);
10517 vector signed char vec_lvebx (int, char *);
10518 vector unsigned char vec_lvebx (int, unsigned char *);
10520 vector float vec_ldl (int, const vector float *);
10521 vector float vec_ldl (int, const float *);
10522 vector bool int vec_ldl (int, const vector bool int *);
10523 vector signed int vec_ldl (int, const vector signed int *);
10524 vector signed int vec_ldl (int, const int *);
10525 vector signed int vec_ldl (int, const long *);
10526 vector unsigned int vec_ldl (int, const vector unsigned int *);
10527 vector unsigned int vec_ldl (int, const unsigned int *);
10528 vector unsigned int vec_ldl (int, const unsigned long *);
10529 vector bool short vec_ldl (int, const vector bool short *);
10530 vector pixel vec_ldl (int, const vector pixel *);
10531 vector signed short vec_ldl (int, const vector signed short *);
10532 vector signed short vec_ldl (int, const short *);
10533 vector unsigned short vec_ldl (int, const vector unsigned short *);
10534 vector unsigned short vec_ldl (int, const unsigned short *);
10535 vector bool char vec_ldl (int, const vector bool char *);
10536 vector signed char vec_ldl (int, const vector signed char *);
10537 vector signed char vec_ldl (int, const signed char *);
10538 vector unsigned char vec_ldl (int, const vector unsigned char *);
10539 vector unsigned char vec_ldl (int, const unsigned char *);
10541 vector float vec_loge (vector float);
10543 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
10544 vector unsigned char vec_lvsl (int, const volatile signed char *);
10545 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
10546 vector unsigned char vec_lvsl (int, const volatile short *);
10547 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
10548 vector unsigned char vec_lvsl (int, const volatile int *);
10549 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
10550 vector unsigned char vec_lvsl (int, const volatile long *);
10551 vector unsigned char vec_lvsl (int, const volatile float *);
10553 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
10554 vector unsigned char vec_lvsr (int, const volatile signed char *);
10555 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
10556 vector unsigned char vec_lvsr (int, const volatile short *);
10557 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
10558 vector unsigned char vec_lvsr (int, const volatile int *);
10559 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
10560 vector unsigned char vec_lvsr (int, const volatile long *);
10561 vector unsigned char vec_lvsr (int, const volatile float *);
10563 vector float vec_madd (vector float, vector float, vector float);
10565 vector signed short vec_madds (vector signed short,
10566                                vector signed short,
10567                                vector signed short);
10569 vector unsigned char vec_max (vector bool char, vector unsigned char);
10570 vector unsigned char vec_max (vector unsigned char, vector bool char);
10571 vector unsigned char vec_max (vector unsigned char,
10572                               vector unsigned char);
10573 vector signed char vec_max (vector bool char, vector signed char);
10574 vector signed char vec_max (vector signed char, vector bool char);
10575 vector signed char vec_max (vector signed char, vector signed char);
10576 vector unsigned short vec_max (vector bool short,
10577                                vector unsigned short);
10578 vector unsigned short vec_max (vector unsigned short,
10579                                vector bool short);
10580 vector unsigned short vec_max (vector unsigned short,
10581                                vector unsigned short);
10582 vector signed short vec_max (vector bool short, vector signed short);
10583 vector signed short vec_max (vector signed short, vector bool short);
10584 vector signed short vec_max (vector signed short, vector signed short);
10585 vector unsigned int vec_max (vector bool int, vector unsigned int);
10586 vector unsigned int vec_max (vector unsigned int, vector bool int);
10587 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
10588 vector signed int vec_max (vector bool int, vector signed int);
10589 vector signed int vec_max (vector signed int, vector bool int);
10590 vector signed int vec_max (vector signed int, vector signed int);
10591 vector float vec_max (vector float, vector float);
10593 vector float vec_vmaxfp (vector float, vector float);
10595 vector signed int vec_vmaxsw (vector bool int, vector signed int);
10596 vector signed int vec_vmaxsw (vector signed int, vector bool int);
10597 vector signed int vec_vmaxsw (vector signed int, vector signed int);
10599 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
10600 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
10601 vector unsigned int vec_vmaxuw (vector unsigned int,
10602                                 vector unsigned int);
10604 vector signed short vec_vmaxsh (vector bool short, vector signed short);
10605 vector signed short vec_vmaxsh (vector signed short, vector bool short);
10606 vector signed short vec_vmaxsh (vector signed short,
10607                                 vector signed short);
10609 vector unsigned short vec_vmaxuh (vector bool short,
10610                                   vector unsigned short);
10611 vector unsigned short vec_vmaxuh (vector unsigned short,
10612                                   vector bool short);
10613 vector unsigned short vec_vmaxuh (vector unsigned short,
10614                                   vector unsigned short);
10616 vector signed char vec_vmaxsb (vector bool char, vector signed char);
10617 vector signed char vec_vmaxsb (vector signed char, vector bool char);
10618 vector signed char vec_vmaxsb (vector signed char, vector signed char);
10620 vector unsigned char vec_vmaxub (vector bool char,
10621                                  vector unsigned char);
10622 vector unsigned char vec_vmaxub (vector unsigned char,
10623                                  vector bool char);
10624 vector unsigned char vec_vmaxub (vector unsigned char,
10625                                  vector unsigned char);
10627 vector bool char vec_mergeh (vector bool char, vector bool char);
10628 vector signed char vec_mergeh (vector signed char, vector signed char);
10629 vector unsigned char vec_mergeh (vector unsigned char,
10630                                  vector unsigned char);
10631 vector bool short vec_mergeh (vector bool short, vector bool short);
10632 vector pixel vec_mergeh (vector pixel, vector pixel);
10633 vector signed short vec_mergeh (vector signed short,
10634                                 vector signed short);
10635 vector unsigned short vec_mergeh (vector unsigned short,
10636                                   vector unsigned short);
10637 vector float vec_mergeh (vector float, vector float);
10638 vector bool int vec_mergeh (vector bool int, vector bool int);
10639 vector signed int vec_mergeh (vector signed int, vector signed int);
10640 vector unsigned int vec_mergeh (vector unsigned int,
10641                                 vector unsigned int);
10643 vector float vec_vmrghw (vector float, vector float);
10644 vector bool int vec_vmrghw (vector bool int, vector bool int);
10645 vector signed int vec_vmrghw (vector signed int, vector signed int);
10646 vector unsigned int vec_vmrghw (vector unsigned int,
10647                                 vector unsigned int);
10649 vector bool short vec_vmrghh (vector bool short, vector bool short);
10650 vector signed short vec_vmrghh (vector signed short,
10651                                 vector signed short);
10652 vector unsigned short vec_vmrghh (vector unsigned short,
10653                                   vector unsigned short);
10654 vector pixel vec_vmrghh (vector pixel, vector pixel);
10656 vector bool char vec_vmrghb (vector bool char, vector bool char);
10657 vector signed char vec_vmrghb (vector signed char, vector signed char);
10658 vector unsigned char vec_vmrghb (vector unsigned char,
10659                                  vector unsigned char);
10661 vector bool char vec_mergel (vector bool char, vector bool char);
10662 vector signed char vec_mergel (vector signed char, vector signed char);
10663 vector unsigned char vec_mergel (vector unsigned char,
10664                                  vector unsigned char);
10665 vector bool short vec_mergel (vector bool short, vector bool short);
10666 vector pixel vec_mergel (vector pixel, vector pixel);
10667 vector signed short vec_mergel (vector signed short,
10668                                 vector signed short);
10669 vector unsigned short vec_mergel (vector unsigned short,
10670                                   vector unsigned short);
10671 vector float vec_mergel (vector float, vector float);
10672 vector bool int vec_mergel (vector bool int, vector bool int);
10673 vector signed int vec_mergel (vector signed int, vector signed int);
10674 vector unsigned int vec_mergel (vector unsigned int,
10675                                 vector unsigned int);
10677 vector float vec_vmrglw (vector float, vector float);
10678 vector signed int vec_vmrglw (vector signed int, vector signed int);
10679 vector unsigned int vec_vmrglw (vector unsigned int,
10680                                 vector unsigned int);
10681 vector bool int vec_vmrglw (vector bool int, vector bool int);
10683 vector bool short vec_vmrglh (vector bool short, vector bool short);
10684 vector signed short vec_vmrglh (vector signed short,
10685                                 vector signed short);
10686 vector unsigned short vec_vmrglh (vector unsigned short,
10687                                   vector unsigned short);
10688 vector pixel vec_vmrglh (vector pixel, vector pixel);
10690 vector bool char vec_vmrglb (vector bool char, vector bool char);
10691 vector signed char vec_vmrglb (vector signed char, vector signed char);
10692 vector unsigned char vec_vmrglb (vector unsigned char,
10693                                  vector unsigned char);
10695 vector unsigned short vec_mfvscr (void);
10697 vector unsigned char vec_min (vector bool char, vector unsigned char);
10698 vector unsigned char vec_min (vector unsigned char, vector bool char);
10699 vector unsigned char vec_min (vector unsigned char,
10700                               vector unsigned char);
10701 vector signed char vec_min (vector bool char, vector signed char);
10702 vector signed char vec_min (vector signed char, vector bool char);
10703 vector signed char vec_min (vector signed char, vector signed char);
10704 vector unsigned short vec_min (vector bool short,
10705                                vector unsigned short);
10706 vector unsigned short vec_min (vector unsigned short,
10707                                vector bool short);
10708 vector unsigned short vec_min (vector unsigned short,
10709                                vector unsigned short);
10710 vector signed short vec_min (vector bool short, vector signed short);
10711 vector signed short vec_min (vector signed short, vector bool short);
10712 vector signed short vec_min (vector signed short, vector signed short);
10713 vector unsigned int vec_min (vector bool int, vector unsigned int);
10714 vector unsigned int vec_min (vector unsigned int, vector bool int);
10715 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
10716 vector signed int vec_min (vector bool int, vector signed int);
10717 vector signed int vec_min (vector signed int, vector bool int);
10718 vector signed int vec_min (vector signed int, vector signed int);
10719 vector float vec_min (vector float, vector float);
10721 vector float vec_vminfp (vector float, vector float);
10723 vector signed int vec_vminsw (vector bool int, vector signed int);
10724 vector signed int vec_vminsw (vector signed int, vector bool int);
10725 vector signed int vec_vminsw (vector signed int, vector signed int);
10727 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
10728 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
10729 vector unsigned int vec_vminuw (vector unsigned int,
10730                                 vector unsigned int);
10732 vector signed short vec_vminsh (vector bool short, vector signed short);
10733 vector signed short vec_vminsh (vector signed short, vector bool short);
10734 vector signed short vec_vminsh (vector signed short,
10735                                 vector signed short);
10737 vector unsigned short vec_vminuh (vector bool short,
10738                                   vector unsigned short);
10739 vector unsigned short vec_vminuh (vector unsigned short,
10740                                   vector bool short);
10741 vector unsigned short vec_vminuh (vector unsigned short,
10742                                   vector unsigned short);
10744 vector signed char vec_vminsb (vector bool char, vector signed char);
10745 vector signed char vec_vminsb (vector signed char, vector bool char);
10746 vector signed char vec_vminsb (vector signed char, vector signed char);
10748 vector unsigned char vec_vminub (vector bool char,
10749                                  vector unsigned char);
10750 vector unsigned char vec_vminub (vector unsigned char,
10751                                  vector bool char);
10752 vector unsigned char vec_vminub (vector unsigned char,
10753                                  vector unsigned char);
10755 vector signed short vec_mladd (vector signed short,
10756                                vector signed short,
10757                                vector signed short);
10758 vector signed short vec_mladd (vector signed short,
10759                                vector unsigned short,
10760                                vector unsigned short);
10761 vector signed short vec_mladd (vector unsigned short,
10762                                vector signed short,
10763                                vector signed short);
10764 vector unsigned short vec_mladd (vector unsigned short,
10765                                  vector unsigned short,
10766                                  vector unsigned short);
10768 vector signed short vec_mradds (vector signed short,
10769                                 vector signed short,
10770                                 vector signed short);
10772 vector unsigned int vec_msum (vector unsigned char,
10773                               vector unsigned char,
10774                               vector unsigned int);
10775 vector signed int vec_msum (vector signed char,
10776                             vector unsigned char,
10777                             vector signed int);
10778 vector unsigned int vec_msum (vector unsigned short,
10779                               vector unsigned short,
10780                               vector unsigned int);
10781 vector signed int vec_msum (vector signed short,
10782                             vector signed short,
10783                             vector signed int);
10785 vector signed int vec_vmsumshm (vector signed short,
10786                                 vector signed short,
10787                                 vector signed int);
10789 vector unsigned int vec_vmsumuhm (vector unsigned short,
10790                                   vector unsigned short,
10791                                   vector unsigned int);
10793 vector signed int vec_vmsummbm (vector signed char,
10794                                 vector unsigned char,
10795                                 vector signed int);
10797 vector unsigned int vec_vmsumubm (vector unsigned char,
10798                                   vector unsigned char,
10799                                   vector unsigned int);
10801 vector unsigned int vec_msums (vector unsigned short,
10802                                vector unsigned short,
10803                                vector unsigned int);
10804 vector signed int vec_msums (vector signed short,
10805                              vector signed short,
10806                              vector signed int);
10808 vector signed int vec_vmsumshs (vector signed short,
10809                                 vector signed short,
10810                                 vector signed int);
10812 vector unsigned int vec_vmsumuhs (vector unsigned short,
10813                                   vector unsigned short,
10814                                   vector unsigned int);
10816 void vec_mtvscr (vector signed int);
10817 void vec_mtvscr (vector unsigned int);
10818 void vec_mtvscr (vector bool int);
10819 void vec_mtvscr (vector signed short);
10820 void vec_mtvscr (vector unsigned short);
10821 void vec_mtvscr (vector bool short);
10822 void vec_mtvscr (vector pixel);
10823 void vec_mtvscr (vector signed char);
10824 void vec_mtvscr (vector unsigned char);
10825 void vec_mtvscr (vector bool char);
10827 vector unsigned short vec_mule (vector unsigned char,
10828                                 vector unsigned char);
10829 vector signed short vec_mule (vector signed char,
10830                               vector signed char);
10831 vector unsigned int vec_mule (vector unsigned short,
10832                               vector unsigned short);
10833 vector signed int vec_mule (vector signed short, vector signed short);
10835 vector signed int vec_vmulesh (vector signed short,
10836                                vector signed short);
10838 vector unsigned int vec_vmuleuh (vector unsigned short,
10839                                  vector unsigned short);
10841 vector signed short vec_vmulesb (vector signed char,
10842                                  vector signed char);
10844 vector unsigned short vec_vmuleub (vector unsigned char,
10845                                   vector unsigned char);
10847 vector unsigned short vec_mulo (vector unsigned char,
10848                                 vector unsigned char);
10849 vector signed short vec_mulo (vector signed char, vector signed char);
10850 vector unsigned int vec_mulo (vector unsigned short,
10851                               vector unsigned short);
10852 vector signed int vec_mulo (vector signed short, vector signed short);
10854 vector signed int vec_vmulosh (vector signed short,
10855                                vector signed short);
10857 vector unsigned int vec_vmulouh (vector unsigned short,
10858                                  vector unsigned short);
10860 vector signed short vec_vmulosb (vector signed char,
10861                                  vector signed char);
10863 vector unsigned short vec_vmuloub (vector unsigned char,
10864                                    vector unsigned char);
10866 vector float vec_nmsub (vector float, vector float, vector float);
10868 vector float vec_nor (vector float, vector float);
10869 vector signed int vec_nor (vector signed int, vector signed int);
10870 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
10871 vector bool int vec_nor (vector bool int, vector bool int);
10872 vector signed short vec_nor (vector signed short, vector signed short);
10873 vector unsigned short vec_nor (vector unsigned short,
10874                                vector unsigned short);
10875 vector bool short vec_nor (vector bool short, vector bool short);
10876 vector signed char vec_nor (vector signed char, vector signed char);
10877 vector unsigned char vec_nor (vector unsigned char,
10878                               vector unsigned char);
10879 vector bool char vec_nor (vector bool char, vector bool char);
10881 vector float vec_or (vector float, vector float);
10882 vector float vec_or (vector float, vector bool int);
10883 vector float vec_or (vector bool int, vector float);
10884 vector bool int vec_or (vector bool int, vector bool int);
10885 vector signed int vec_or (vector bool int, vector signed int);
10886 vector signed int vec_or (vector signed int, vector bool int);
10887 vector signed int vec_or (vector signed int, vector signed int);
10888 vector unsigned int vec_or (vector bool int, vector unsigned int);
10889 vector unsigned int vec_or (vector unsigned int, vector bool int);
10890 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
10891 vector bool short vec_or (vector bool short, vector bool short);
10892 vector signed short vec_or (vector bool short, vector signed short);
10893 vector signed short vec_or (vector signed short, vector bool short);
10894 vector signed short vec_or (vector signed short, vector signed short);
10895 vector unsigned short vec_or (vector bool short, vector unsigned short);
10896 vector unsigned short vec_or (vector unsigned short, vector bool short);
10897 vector unsigned short vec_or (vector unsigned short,
10898                               vector unsigned short);
10899 vector signed char vec_or (vector bool char, vector signed char);
10900 vector bool char vec_or (vector bool char, vector bool char);
10901 vector signed char vec_or (vector signed char, vector bool char);
10902 vector signed char vec_or (vector signed char, vector signed char);
10903 vector unsigned char vec_or (vector bool char, vector unsigned char);
10904 vector unsigned char vec_or (vector unsigned char, vector bool char);
10905 vector unsigned char vec_or (vector unsigned char,
10906                              vector unsigned char);
10908 vector signed char vec_pack (vector signed short, vector signed short);
10909 vector unsigned char vec_pack (vector unsigned short,
10910                                vector unsigned short);
10911 vector bool char vec_pack (vector bool short, vector bool short);
10912 vector signed short vec_pack (vector signed int, vector signed int);
10913 vector unsigned short vec_pack (vector unsigned int,
10914                                 vector unsigned int);
10915 vector bool short vec_pack (vector bool int, vector bool int);
10917 vector bool short vec_vpkuwum (vector bool int, vector bool int);
10918 vector signed short vec_vpkuwum (vector signed int, vector signed int);
10919 vector unsigned short vec_vpkuwum (vector unsigned int,
10920                                    vector unsigned int);
10922 vector bool char vec_vpkuhum (vector bool short, vector bool short);
10923 vector signed char vec_vpkuhum (vector signed short,
10924                                 vector signed short);
10925 vector unsigned char vec_vpkuhum (vector unsigned short,
10926                                   vector unsigned short);
10928 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
10930 vector unsigned char vec_packs (vector unsigned short,
10931                                 vector unsigned short);
10932 vector signed char vec_packs (vector signed short, vector signed short);
10933 vector unsigned short vec_packs (vector unsigned int,
10934                                  vector unsigned int);
10935 vector signed short vec_packs (vector signed int, vector signed int);
10937 vector signed short vec_vpkswss (vector signed int, vector signed int);
10939 vector unsigned short vec_vpkuwus (vector unsigned int,
10940                                    vector unsigned int);
10942 vector signed char vec_vpkshss (vector signed short,
10943                                 vector signed short);
10945 vector unsigned char vec_vpkuhus (vector unsigned short,
10946                                   vector unsigned short);
10948 vector unsigned char vec_packsu (vector unsigned short,
10949                                  vector unsigned short);
10950 vector unsigned char vec_packsu (vector signed short,
10951                                  vector signed short);
10952 vector unsigned short vec_packsu (vector unsigned int,
10953                                   vector unsigned int);
10954 vector unsigned short vec_packsu (vector signed int, vector signed int);
10956 vector unsigned short vec_vpkswus (vector signed int,
10957                                    vector signed int);
10959 vector unsigned char vec_vpkshus (vector signed short,
10960                                   vector signed short);
10962 vector float vec_perm (vector float,
10963                        vector float,
10964                        vector unsigned char);
10965 vector signed int vec_perm (vector signed int,
10966                             vector signed int,
10967                             vector unsigned char);
10968 vector unsigned int vec_perm (vector unsigned int,
10969                               vector unsigned int,
10970                               vector unsigned char);
10971 vector bool int vec_perm (vector bool int,
10972                           vector bool int,
10973                           vector unsigned char);
10974 vector signed short vec_perm (vector signed short,
10975                               vector signed short,
10976                               vector unsigned char);
10977 vector unsigned short vec_perm (vector unsigned short,
10978                                 vector unsigned short,
10979                                 vector unsigned char);
10980 vector bool short vec_perm (vector bool short,
10981                             vector bool short,
10982                             vector unsigned char);
10983 vector pixel vec_perm (vector pixel,
10984                        vector pixel,
10985                        vector unsigned char);
10986 vector signed char vec_perm (vector signed char,
10987                              vector signed char,
10988                              vector unsigned char);
10989 vector unsigned char vec_perm (vector unsigned char,
10990                                vector unsigned char,
10991                                vector unsigned char);
10992 vector bool char vec_perm (vector bool char,
10993                            vector bool char,
10994                            vector unsigned char);
10996 vector float vec_re (vector float);
10998 vector signed char vec_rl (vector signed char,
10999                            vector unsigned char);
11000 vector unsigned char vec_rl (vector unsigned char,
11001                              vector unsigned char);
11002 vector signed short vec_rl (vector signed short, vector unsigned short);
11003 vector unsigned short vec_rl (vector unsigned short,
11004                               vector unsigned short);
11005 vector signed int vec_rl (vector signed int, vector unsigned int);
11006 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
11008 vector signed int vec_vrlw (vector signed int, vector unsigned int);
11009 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
11011 vector signed short vec_vrlh (vector signed short,
11012                               vector unsigned short);
11013 vector unsigned short vec_vrlh (vector unsigned short,
11014                                 vector unsigned short);
11016 vector signed char vec_vrlb (vector signed char, vector unsigned char);
11017 vector unsigned char vec_vrlb (vector unsigned char,
11018                                vector unsigned char);
11020 vector float vec_round (vector float);
11022 vector float vec_recip (vector float, vector float);
11024 vector float vec_rsqrt (vector float);
11026 vector float vec_rsqrte (vector float);
11028 vector float vec_sel (vector float, vector float, vector bool int);
11029 vector float vec_sel (vector float, vector float, vector unsigned int);
11030 vector signed int vec_sel (vector signed int,
11031                            vector signed int,
11032                            vector bool int);
11033 vector signed int vec_sel (vector signed int,
11034                            vector signed int,
11035                            vector unsigned int);
11036 vector unsigned int vec_sel (vector unsigned int,
11037                              vector unsigned int,
11038                              vector bool int);
11039 vector unsigned int vec_sel (vector unsigned int,
11040                              vector unsigned int,
11041                              vector unsigned int);
11042 vector bool int vec_sel (vector bool int,
11043                          vector bool int,
11044                          vector bool int);
11045 vector bool int vec_sel (vector bool int,
11046                          vector bool int,
11047                          vector unsigned int);
11048 vector signed short vec_sel (vector signed short,
11049                              vector signed short,
11050                              vector bool short);
11051 vector signed short vec_sel (vector signed short,
11052                              vector signed short,
11053                              vector unsigned short);
11054 vector unsigned short vec_sel (vector unsigned short,
11055                                vector unsigned short,
11056                                vector bool short);
11057 vector unsigned short vec_sel (vector unsigned short,
11058                                vector unsigned short,
11059                                vector unsigned short);
11060 vector bool short vec_sel (vector bool short,
11061                            vector bool short,
11062                            vector bool short);
11063 vector bool short vec_sel (vector bool short,
11064                            vector bool short,
11065                            vector unsigned short);
11066 vector signed char vec_sel (vector signed char,
11067                             vector signed char,
11068                             vector bool char);
11069 vector signed char vec_sel (vector signed char,
11070                             vector signed char,
11071                             vector unsigned char);
11072 vector unsigned char vec_sel (vector unsigned char,
11073                               vector unsigned char,
11074                               vector bool char);
11075 vector unsigned char vec_sel (vector unsigned char,
11076                               vector unsigned char,
11077                               vector unsigned char);
11078 vector bool char vec_sel (vector bool char,
11079                           vector bool char,
11080                           vector bool char);
11081 vector bool char vec_sel (vector bool char,
11082                           vector bool char,
11083                           vector unsigned char);
11085 vector signed char vec_sl (vector signed char,
11086                            vector unsigned char);
11087 vector unsigned char vec_sl (vector unsigned char,
11088                              vector unsigned char);
11089 vector signed short vec_sl (vector signed short, vector unsigned short);
11090 vector unsigned short vec_sl (vector unsigned short,
11091                               vector unsigned short);
11092 vector signed int vec_sl (vector signed int, vector unsigned int);
11093 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
11095 vector signed int vec_vslw (vector signed int, vector unsigned int);
11096 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
11098 vector signed short vec_vslh (vector signed short,
11099                               vector unsigned short);
11100 vector unsigned short vec_vslh (vector unsigned short,
11101                                 vector unsigned short);
11103 vector signed char vec_vslb (vector signed char, vector unsigned char);
11104 vector unsigned char vec_vslb (vector unsigned char,
11105                                vector unsigned char);
11107 vector float vec_sld (vector float, vector float, const int);
11108 vector signed int vec_sld (vector signed int,
11109                            vector signed int,
11110                            const int);
11111 vector unsigned int vec_sld (vector unsigned int,
11112                              vector unsigned int,
11113                              const int);
11114 vector bool int vec_sld (vector bool int,
11115                          vector bool int,
11116                          const int);
11117 vector signed short vec_sld (vector signed short,
11118                              vector signed short,
11119                              const int);
11120 vector unsigned short vec_sld (vector unsigned short,
11121                                vector unsigned short,
11122                                const int);
11123 vector bool short vec_sld (vector bool short,
11124                            vector bool short,
11125                            const int);
11126 vector pixel vec_sld (vector pixel,
11127                       vector pixel,
11128                       const int);
11129 vector signed char vec_sld (vector signed char,
11130                             vector signed char,
11131                             const int);
11132 vector unsigned char vec_sld (vector unsigned char,
11133                               vector unsigned char,
11134                               const int);
11135 vector bool char vec_sld (vector bool char,
11136                           vector bool char,
11137                           const int);
11139 vector signed int vec_sll (vector signed int,
11140                            vector unsigned int);
11141 vector signed int vec_sll (vector signed int,
11142                            vector unsigned short);
11143 vector signed int vec_sll (vector signed int,
11144                            vector unsigned char);
11145 vector unsigned int vec_sll (vector unsigned int,
11146                              vector unsigned int);
11147 vector unsigned int vec_sll (vector unsigned int,
11148                              vector unsigned short);
11149 vector unsigned int vec_sll (vector unsigned int,
11150                              vector unsigned char);
11151 vector bool int vec_sll (vector bool int,
11152                          vector unsigned int);
11153 vector bool int vec_sll (vector bool int,
11154                          vector unsigned short);
11155 vector bool int vec_sll (vector bool int,
11156                          vector unsigned char);
11157 vector signed short vec_sll (vector signed short,
11158                              vector unsigned int);
11159 vector signed short vec_sll (vector signed short,
11160                              vector unsigned short);
11161 vector signed short vec_sll (vector signed short,
11162                              vector unsigned char);
11163 vector unsigned short vec_sll (vector unsigned short,
11164                                vector unsigned int);
11165 vector unsigned short vec_sll (vector unsigned short,
11166                                vector unsigned short);
11167 vector unsigned short vec_sll (vector unsigned short,
11168                                vector unsigned char);
11169 vector bool short vec_sll (vector bool short, vector unsigned int);
11170 vector bool short vec_sll (vector bool short, vector unsigned short);
11171 vector bool short vec_sll (vector bool short, vector unsigned char);
11172 vector pixel vec_sll (vector pixel, vector unsigned int);
11173 vector pixel vec_sll (vector pixel, vector unsigned short);
11174 vector pixel vec_sll (vector pixel, vector unsigned char);
11175 vector signed char vec_sll (vector signed char, vector unsigned int);
11176 vector signed char vec_sll (vector signed char, vector unsigned short);
11177 vector signed char vec_sll (vector signed char, vector unsigned char);
11178 vector unsigned char vec_sll (vector unsigned char,
11179                               vector unsigned int);
11180 vector unsigned char vec_sll (vector unsigned char,
11181                               vector unsigned short);
11182 vector unsigned char vec_sll (vector unsigned char,
11183                               vector unsigned char);
11184 vector bool char vec_sll (vector bool char, vector unsigned int);
11185 vector bool char vec_sll (vector bool char, vector unsigned short);
11186 vector bool char vec_sll (vector bool char, vector unsigned char);
11188 vector float vec_slo (vector float, vector signed char);
11189 vector float vec_slo (vector float, vector unsigned char);
11190 vector signed int vec_slo (vector signed int, vector signed char);
11191 vector signed int vec_slo (vector signed int, vector unsigned char);
11192 vector unsigned int vec_slo (vector unsigned int, vector signed char);
11193 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
11194 vector signed short vec_slo (vector signed short, vector signed char);
11195 vector signed short vec_slo (vector signed short, vector unsigned char);
11196 vector unsigned short vec_slo (vector unsigned short,
11197                                vector signed char);
11198 vector unsigned short vec_slo (vector unsigned short,
11199                                vector unsigned char);
11200 vector pixel vec_slo (vector pixel, vector signed char);
11201 vector pixel vec_slo (vector pixel, vector unsigned char);
11202 vector signed char vec_slo (vector signed char, vector signed char);
11203 vector signed char vec_slo (vector signed char, vector unsigned char);
11204 vector unsigned char vec_slo (vector unsigned char, vector signed char);
11205 vector unsigned char vec_slo (vector unsigned char,
11206                               vector unsigned char);
11208 vector signed char vec_splat (vector signed char, const int);
11209 vector unsigned char vec_splat (vector unsigned char, const int);
11210 vector bool char vec_splat (vector bool char, const int);
11211 vector signed short vec_splat (vector signed short, const int);
11212 vector unsigned short vec_splat (vector unsigned short, const int);
11213 vector bool short vec_splat (vector bool short, const int);
11214 vector pixel vec_splat (vector pixel, const int);
11215 vector float vec_splat (vector float, const int);
11216 vector signed int vec_splat (vector signed int, const int);
11217 vector unsigned int vec_splat (vector unsigned int, const int);
11218 vector bool int vec_splat (vector bool int, const int);
11220 vector float vec_vspltw (vector float, const int);
11221 vector signed int vec_vspltw (vector signed int, const int);
11222 vector unsigned int vec_vspltw (vector unsigned int, const int);
11223 vector bool int vec_vspltw (vector bool int, const int);
11225 vector bool short vec_vsplth (vector bool short, const int);
11226 vector signed short vec_vsplth (vector signed short, const int);
11227 vector unsigned short vec_vsplth (vector unsigned short, const int);
11228 vector pixel vec_vsplth (vector pixel, const int);
11230 vector signed char vec_vspltb (vector signed char, const int);
11231 vector unsigned char vec_vspltb (vector unsigned char, const int);
11232 vector bool char vec_vspltb (vector bool char, const int);
11234 vector signed char vec_splat_s8 (const int);
11236 vector signed short vec_splat_s16 (const int);
11238 vector signed int vec_splat_s32 (const int);
11240 vector unsigned char vec_splat_u8 (const int);
11242 vector unsigned short vec_splat_u16 (const int);
11244 vector unsigned int vec_splat_u32 (const int);
11246 vector signed char vec_sr (vector signed char, vector unsigned char);
11247 vector unsigned char vec_sr (vector unsigned char,
11248                              vector unsigned char);
11249 vector signed short vec_sr (vector signed short,
11250                             vector unsigned short);
11251 vector unsigned short vec_sr (vector unsigned short,
11252                               vector unsigned short);
11253 vector signed int vec_sr (vector signed int, vector unsigned int);
11254 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
11256 vector signed int vec_vsrw (vector signed int, vector unsigned int);
11257 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
11259 vector signed short vec_vsrh (vector signed short,
11260                               vector unsigned short);
11261 vector unsigned short vec_vsrh (vector unsigned short,
11262                                 vector unsigned short);
11264 vector signed char vec_vsrb (vector signed char, vector unsigned char);
11265 vector unsigned char vec_vsrb (vector unsigned char,
11266                                vector unsigned char);
11268 vector signed char vec_sra (vector signed char, vector unsigned char);
11269 vector unsigned char vec_sra (vector unsigned char,
11270                               vector unsigned char);
11271 vector signed short vec_sra (vector signed short,
11272                              vector unsigned short);
11273 vector unsigned short vec_sra (vector unsigned short,
11274                                vector unsigned short);
11275 vector signed int vec_sra (vector signed int, vector unsigned int);
11276 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
11278 vector signed int vec_vsraw (vector signed int, vector unsigned int);
11279 vector unsigned int vec_vsraw (vector unsigned int,
11280                                vector unsigned int);
11282 vector signed short vec_vsrah (vector signed short,
11283                                vector unsigned short);
11284 vector unsigned short vec_vsrah (vector unsigned short,
11285                                  vector unsigned short);
11287 vector signed char vec_vsrab (vector signed char, vector unsigned char);
11288 vector unsigned char vec_vsrab (vector unsigned char,
11289                                 vector unsigned char);
11291 vector signed int vec_srl (vector signed int, vector unsigned int);
11292 vector signed int vec_srl (vector signed int, vector unsigned short);
11293 vector signed int vec_srl (vector signed int, vector unsigned char);
11294 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
11295 vector unsigned int vec_srl (vector unsigned int,
11296                              vector unsigned short);
11297 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
11298 vector bool int vec_srl (vector bool int, vector unsigned int);
11299 vector bool int vec_srl (vector bool int, vector unsigned short);
11300 vector bool int vec_srl (vector bool int, vector unsigned char);
11301 vector signed short vec_srl (vector signed short, vector unsigned int);
11302 vector signed short vec_srl (vector signed short,
11303                              vector unsigned short);
11304 vector signed short vec_srl (vector signed short, vector unsigned char);
11305 vector unsigned short vec_srl (vector unsigned short,
11306                                vector unsigned int);
11307 vector unsigned short vec_srl (vector unsigned short,
11308                                vector unsigned short);
11309 vector unsigned short vec_srl (vector unsigned short,
11310                                vector unsigned char);
11311 vector bool short vec_srl (vector bool short, vector unsigned int);
11312 vector bool short vec_srl (vector bool short, vector unsigned short);
11313 vector bool short vec_srl (vector bool short, vector unsigned char);
11314 vector pixel vec_srl (vector pixel, vector unsigned int);
11315 vector pixel vec_srl (vector pixel, vector unsigned short);
11316 vector pixel vec_srl (vector pixel, vector unsigned char);
11317 vector signed char vec_srl (vector signed char, vector unsigned int);
11318 vector signed char vec_srl (vector signed char, vector unsigned short);
11319 vector signed char vec_srl (vector signed char, vector unsigned char);
11320 vector unsigned char vec_srl (vector unsigned char,
11321                               vector unsigned int);
11322 vector unsigned char vec_srl (vector unsigned char,
11323                               vector unsigned short);
11324 vector unsigned char vec_srl (vector unsigned char,
11325                               vector unsigned char);
11326 vector bool char vec_srl (vector bool char, vector unsigned int);
11327 vector bool char vec_srl (vector bool char, vector unsigned short);
11328 vector bool char vec_srl (vector bool char, vector unsigned char);
11330 vector float vec_sro (vector float, vector signed char);
11331 vector float vec_sro (vector float, vector unsigned char);
11332 vector signed int vec_sro (vector signed int, vector signed char);
11333 vector signed int vec_sro (vector signed int, vector unsigned char);
11334 vector unsigned int vec_sro (vector unsigned int, vector signed char);
11335 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
11336 vector signed short vec_sro (vector signed short, vector signed char);
11337 vector signed short vec_sro (vector signed short, vector unsigned char);
11338 vector unsigned short vec_sro (vector unsigned short,
11339                                vector signed char);
11340 vector unsigned short vec_sro (vector unsigned short,
11341                                vector unsigned char);
11342 vector pixel vec_sro (vector pixel, vector signed char);
11343 vector pixel vec_sro (vector pixel, vector unsigned char);
11344 vector signed char vec_sro (vector signed char, vector signed char);
11345 vector signed char vec_sro (vector signed char, vector unsigned char);
11346 vector unsigned char vec_sro (vector unsigned char, vector signed char);
11347 vector unsigned char vec_sro (vector unsigned char,
11348                               vector unsigned char);
11350 void vec_st (vector float, int, vector float *);
11351 void vec_st (vector float, int, float *);
11352 void vec_st (vector signed int, int, vector signed int *);
11353 void vec_st (vector signed int, int, int *);
11354 void vec_st (vector unsigned int, int, vector unsigned int *);
11355 void vec_st (vector unsigned int, int, unsigned int *);
11356 void vec_st (vector bool int, int, vector bool int *);
11357 void vec_st (vector bool int, int, unsigned int *);
11358 void vec_st (vector bool int, int, int *);
11359 void vec_st (vector signed short, int, vector signed short *);
11360 void vec_st (vector signed short, int, short *);
11361 void vec_st (vector unsigned short, int, vector unsigned short *);
11362 void vec_st (vector unsigned short, int, unsigned short *);
11363 void vec_st (vector bool short, int, vector bool short *);
11364 void vec_st (vector bool short, int, unsigned short *);
11365 void vec_st (vector pixel, int, vector pixel *);
11366 void vec_st (vector pixel, int, unsigned short *);
11367 void vec_st (vector pixel, int, short *);
11368 void vec_st (vector bool short, int, short *);
11369 void vec_st (vector signed char, int, vector signed char *);
11370 void vec_st (vector signed char, int, signed char *);
11371 void vec_st (vector unsigned char, int, vector unsigned char *);
11372 void vec_st (vector unsigned char, int, unsigned char *);
11373 void vec_st (vector bool char, int, vector bool char *);
11374 void vec_st (vector bool char, int, unsigned char *);
11375 void vec_st (vector bool char, int, signed char *);
11377 void vec_ste (vector signed char, int, signed char *);
11378 void vec_ste (vector unsigned char, int, unsigned char *);
11379 void vec_ste (vector bool char, int, signed char *);
11380 void vec_ste (vector bool char, int, unsigned char *);
11381 void vec_ste (vector signed short, int, short *);
11382 void vec_ste (vector unsigned short, int, unsigned short *);
11383 void vec_ste (vector bool short, int, short *);
11384 void vec_ste (vector bool short, int, unsigned short *);
11385 void vec_ste (vector pixel, int, short *);
11386 void vec_ste (vector pixel, int, unsigned short *);
11387 void vec_ste (vector float, int, float *);
11388 void vec_ste (vector signed int, int, int *);
11389 void vec_ste (vector unsigned int, int, unsigned int *);
11390 void vec_ste (vector bool int, int, int *);
11391 void vec_ste (vector bool int, int, unsigned int *);
11393 void vec_stvewx (vector float, int, float *);
11394 void vec_stvewx (vector signed int, int, int *);
11395 void vec_stvewx (vector unsigned int, int, unsigned int *);
11396 void vec_stvewx (vector bool int, int, int *);
11397 void vec_stvewx (vector bool int, int, unsigned int *);
11399 void vec_stvehx (vector signed short, int, short *);
11400 void vec_stvehx (vector unsigned short, int, unsigned short *);
11401 void vec_stvehx (vector bool short, int, short *);
11402 void vec_stvehx (vector bool short, int, unsigned short *);
11403 void vec_stvehx (vector pixel, int, short *);
11404 void vec_stvehx (vector pixel, int, unsigned short *);
11406 void vec_stvebx (vector signed char, int, signed char *);
11407 void vec_stvebx (vector unsigned char, int, unsigned char *);
11408 void vec_stvebx (vector bool char, int, signed char *);
11409 void vec_stvebx (vector bool char, int, unsigned char *);
11411 void vec_stl (vector float, int, vector float *);
11412 void vec_stl (vector float, int, float *);
11413 void vec_stl (vector signed int, int, vector signed int *);
11414 void vec_stl (vector signed int, int, int *);
11415 void vec_stl (vector unsigned int, int, vector unsigned int *);
11416 void vec_stl (vector unsigned int, int, unsigned int *);
11417 void vec_stl (vector bool int, int, vector bool int *);
11418 void vec_stl (vector bool int, int, unsigned int *);
11419 void vec_stl (vector bool int, int, int *);
11420 void vec_stl (vector signed short, int, vector signed short *);
11421 void vec_stl (vector signed short, int, short *);
11422 void vec_stl (vector unsigned short, int, vector unsigned short *);
11423 void vec_stl (vector unsigned short, int, unsigned short *);
11424 void vec_stl (vector bool short, int, vector bool short *);
11425 void vec_stl (vector bool short, int, unsigned short *);
11426 void vec_stl (vector bool short, int, short *);
11427 void vec_stl (vector pixel, int, vector pixel *);
11428 void vec_stl (vector pixel, int, unsigned short *);
11429 void vec_stl (vector pixel, int, short *);
11430 void vec_stl (vector signed char, int, vector signed char *);
11431 void vec_stl (vector signed char, int, signed char *);
11432 void vec_stl (vector unsigned char, int, vector unsigned char *);
11433 void vec_stl (vector unsigned char, int, unsigned char *);
11434 void vec_stl (vector bool char, int, vector bool char *);
11435 void vec_stl (vector bool char, int, unsigned char *);
11436 void vec_stl (vector bool char, int, signed char *);
11438 vector signed char vec_sub (vector bool char, vector signed char);
11439 vector signed char vec_sub (vector signed char, vector bool char);
11440 vector signed char vec_sub (vector signed char, vector signed char);
11441 vector unsigned char vec_sub (vector bool char, vector unsigned char);
11442 vector unsigned char vec_sub (vector unsigned char, vector bool char);
11443 vector unsigned char vec_sub (vector unsigned char,
11444                               vector unsigned char);
11445 vector signed short vec_sub (vector bool short, vector signed short);
11446 vector signed short vec_sub (vector signed short, vector bool short);
11447 vector signed short vec_sub (vector signed short, vector signed short);
11448 vector unsigned short vec_sub (vector bool short,
11449                                vector unsigned short);
11450 vector unsigned short vec_sub (vector unsigned short,
11451                                vector bool short);
11452 vector unsigned short vec_sub (vector unsigned short,
11453                                vector unsigned short);
11454 vector signed int vec_sub (vector bool int, vector signed int);
11455 vector signed int vec_sub (vector signed int, vector bool int);
11456 vector signed int vec_sub (vector signed int, vector signed int);
11457 vector unsigned int vec_sub (vector bool int, vector unsigned int);
11458 vector unsigned int vec_sub (vector unsigned int, vector bool int);
11459 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
11460 vector float vec_sub (vector float, vector float);
11462 vector float vec_vsubfp (vector float, vector float);
11464 vector signed int vec_vsubuwm (vector bool int, vector signed int);
11465 vector signed int vec_vsubuwm (vector signed int, vector bool int);
11466 vector signed int vec_vsubuwm (vector signed int, vector signed int);
11467 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
11468 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
11469 vector unsigned int vec_vsubuwm (vector unsigned int,
11470                                  vector unsigned int);
11472 vector signed short vec_vsubuhm (vector bool short,
11473                                  vector signed short);
11474 vector signed short vec_vsubuhm (vector signed short,
11475                                  vector bool short);
11476 vector signed short vec_vsubuhm (vector signed short,
11477                                  vector signed short);
11478 vector unsigned short vec_vsubuhm (vector bool short,
11479                                    vector unsigned short);
11480 vector unsigned short vec_vsubuhm (vector unsigned short,
11481                                    vector bool short);
11482 vector unsigned short vec_vsubuhm (vector unsigned short,
11483                                    vector unsigned short);
11485 vector signed char vec_vsububm (vector bool char, vector signed char);
11486 vector signed char vec_vsububm (vector signed char, vector bool char);
11487 vector signed char vec_vsububm (vector signed char, vector signed char);
11488 vector unsigned char vec_vsububm (vector bool char,
11489                                   vector unsigned char);
11490 vector unsigned char vec_vsububm (vector unsigned char,
11491                                   vector bool char);
11492 vector unsigned char vec_vsububm (vector unsigned char,
11493                                   vector unsigned char);
11495 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
11497 vector unsigned char vec_subs (vector bool char, vector unsigned char);
11498 vector unsigned char vec_subs (vector unsigned char, vector bool char);
11499 vector unsigned char vec_subs (vector unsigned char,
11500                                vector unsigned char);
11501 vector signed char vec_subs (vector bool char, vector signed char);
11502 vector signed char vec_subs (vector signed char, vector bool char);
11503 vector signed char vec_subs (vector signed char, vector signed char);
11504 vector unsigned short vec_subs (vector bool short,
11505                                 vector unsigned short);
11506 vector unsigned short vec_subs (vector unsigned short,
11507                                 vector bool short);
11508 vector unsigned short vec_subs (vector unsigned short,
11509                                 vector unsigned short);
11510 vector signed short vec_subs (vector bool short, vector signed short);
11511 vector signed short vec_subs (vector signed short, vector bool short);
11512 vector signed short vec_subs (vector signed short, vector signed short);
11513 vector unsigned int vec_subs (vector bool int, vector unsigned int);
11514 vector unsigned int vec_subs (vector unsigned int, vector bool int);
11515 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
11516 vector signed int vec_subs (vector bool int, vector signed int);
11517 vector signed int vec_subs (vector signed int, vector bool int);
11518 vector signed int vec_subs (vector signed int, vector signed int);
11520 vector signed int vec_vsubsws (vector bool int, vector signed int);
11521 vector signed int vec_vsubsws (vector signed int, vector bool int);
11522 vector signed int vec_vsubsws (vector signed int, vector signed int);
11524 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
11525 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
11526 vector unsigned int vec_vsubuws (vector unsigned int,
11527                                  vector unsigned int);
11529 vector signed short vec_vsubshs (vector bool short,
11530                                  vector signed short);
11531 vector signed short vec_vsubshs (vector signed short,
11532                                  vector bool short);
11533 vector signed short vec_vsubshs (vector signed short,
11534                                  vector signed short);
11536 vector unsigned short vec_vsubuhs (vector bool short,
11537                                    vector unsigned short);
11538 vector unsigned short vec_vsubuhs (vector unsigned short,
11539                                    vector bool short);
11540 vector unsigned short vec_vsubuhs (vector unsigned short,
11541                                    vector unsigned short);
11543 vector signed char vec_vsubsbs (vector bool char, vector signed char);
11544 vector signed char vec_vsubsbs (vector signed char, vector bool char);
11545 vector signed char vec_vsubsbs (vector signed char, vector signed char);
11547 vector unsigned char vec_vsububs (vector bool char,
11548                                   vector unsigned char);
11549 vector unsigned char vec_vsububs (vector unsigned char,
11550                                   vector bool char);
11551 vector unsigned char vec_vsububs (vector unsigned char,
11552                                   vector unsigned char);
11554 vector unsigned int vec_sum4s (vector unsigned char,
11555                                vector unsigned int);
11556 vector signed int vec_sum4s (vector signed char, vector signed int);
11557 vector signed int vec_sum4s (vector signed short, vector signed int);
11559 vector signed int vec_vsum4shs (vector signed short, vector signed int);
11561 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
11563 vector unsigned int vec_vsum4ubs (vector unsigned char,
11564                                   vector unsigned int);
11566 vector signed int vec_sum2s (vector signed int, vector signed int);
11568 vector signed int vec_sums (vector signed int, vector signed int);
11570 vector float vec_trunc (vector float);
11572 vector signed short vec_unpackh (vector signed char);
11573 vector bool short vec_unpackh (vector bool char);
11574 vector signed int vec_unpackh (vector signed short);
11575 vector bool int vec_unpackh (vector bool short);
11576 vector unsigned int vec_unpackh (vector pixel);
11578 vector bool int vec_vupkhsh (vector bool short);
11579 vector signed int vec_vupkhsh (vector signed short);
11581 vector unsigned int vec_vupkhpx (vector pixel);
11583 vector bool short vec_vupkhsb (vector bool char);
11584 vector signed short vec_vupkhsb (vector signed char);
11586 vector signed short vec_unpackl (vector signed char);
11587 vector bool short vec_unpackl (vector bool char);
11588 vector unsigned int vec_unpackl (vector pixel);
11589 vector signed int vec_unpackl (vector signed short);
11590 vector bool int vec_unpackl (vector bool short);
11592 vector unsigned int vec_vupklpx (vector pixel);
11594 vector bool int vec_vupklsh (vector bool short);
11595 vector signed int vec_vupklsh (vector signed short);
11597 vector bool short vec_vupklsb (vector bool char);
11598 vector signed short vec_vupklsb (vector signed char);
11600 vector float vec_xor (vector float, vector float);
11601 vector float vec_xor (vector float, vector bool int);
11602 vector float vec_xor (vector bool int, vector float);
11603 vector bool int vec_xor (vector bool int, vector bool int);
11604 vector signed int vec_xor (vector bool int, vector signed int);
11605 vector signed int vec_xor (vector signed int, vector bool int);
11606 vector signed int vec_xor (vector signed int, vector signed int);
11607 vector unsigned int vec_xor (vector bool int, vector unsigned int);
11608 vector unsigned int vec_xor (vector unsigned int, vector bool int);
11609 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
11610 vector bool short vec_xor (vector bool short, vector bool short);
11611 vector signed short vec_xor (vector bool short, vector signed short);
11612 vector signed short vec_xor (vector signed short, vector bool short);
11613 vector signed short vec_xor (vector signed short, vector signed short);
11614 vector unsigned short vec_xor (vector bool short,
11615                                vector unsigned short);
11616 vector unsigned short vec_xor (vector unsigned short,
11617                                vector bool short);
11618 vector unsigned short vec_xor (vector unsigned short,
11619                                vector unsigned short);
11620 vector signed char vec_xor (vector bool char, vector signed char);
11621 vector bool char vec_xor (vector bool char, vector bool char);
11622 vector signed char vec_xor (vector signed char, vector bool char);
11623 vector signed char vec_xor (vector signed char, vector signed char);
11624 vector unsigned char vec_xor (vector bool char, vector unsigned char);
11625 vector unsigned char vec_xor (vector unsigned char, vector bool char);
11626 vector unsigned char vec_xor (vector unsigned char,
11627                               vector unsigned char);
11629 int vec_all_eq (vector signed char, vector bool char);
11630 int vec_all_eq (vector signed char, vector signed char);
11631 int vec_all_eq (vector unsigned char, vector bool char);
11632 int vec_all_eq (vector unsigned char, vector unsigned char);
11633 int vec_all_eq (vector bool char, vector bool char);
11634 int vec_all_eq (vector bool char, vector unsigned char);
11635 int vec_all_eq (vector bool char, vector signed char);
11636 int vec_all_eq (vector signed short, vector bool short);
11637 int vec_all_eq (vector signed short, vector signed short);
11638 int vec_all_eq (vector unsigned short, vector bool short);
11639 int vec_all_eq (vector unsigned short, vector unsigned short);
11640 int vec_all_eq (vector bool short, vector bool short);
11641 int vec_all_eq (vector bool short, vector unsigned short);
11642 int vec_all_eq (vector bool short, vector signed short);
11643 int vec_all_eq (vector pixel, vector pixel);
11644 int vec_all_eq (vector signed int, vector bool int);
11645 int vec_all_eq (vector signed int, vector signed int);
11646 int vec_all_eq (vector unsigned int, vector bool int);
11647 int vec_all_eq (vector unsigned int, vector unsigned int);
11648 int vec_all_eq (vector bool int, vector bool int);
11649 int vec_all_eq (vector bool int, vector unsigned int);
11650 int vec_all_eq (vector bool int, vector signed int);
11651 int vec_all_eq (vector float, vector float);
11653 int vec_all_ge (vector bool char, vector unsigned char);
11654 int vec_all_ge (vector unsigned char, vector bool char);
11655 int vec_all_ge (vector unsigned char, vector unsigned char);
11656 int vec_all_ge (vector bool char, vector signed char);
11657 int vec_all_ge (vector signed char, vector bool char);
11658 int vec_all_ge (vector signed char, vector signed char);
11659 int vec_all_ge (vector bool short, vector unsigned short);
11660 int vec_all_ge (vector unsigned short, vector bool short);
11661 int vec_all_ge (vector unsigned short, vector unsigned short);
11662 int vec_all_ge (vector signed short, vector signed short);
11663 int vec_all_ge (vector bool short, vector signed short);
11664 int vec_all_ge (vector signed short, vector bool short);
11665 int vec_all_ge (vector bool int, vector unsigned int);
11666 int vec_all_ge (vector unsigned int, vector bool int);
11667 int vec_all_ge (vector unsigned int, vector unsigned int);
11668 int vec_all_ge (vector bool int, vector signed int);
11669 int vec_all_ge (vector signed int, vector bool int);
11670 int vec_all_ge (vector signed int, vector signed int);
11671 int vec_all_ge (vector float, vector float);
11673 int vec_all_gt (vector bool char, vector unsigned char);
11674 int vec_all_gt (vector unsigned char, vector bool char);
11675 int vec_all_gt (vector unsigned char, vector unsigned char);
11676 int vec_all_gt (vector bool char, vector signed char);
11677 int vec_all_gt (vector signed char, vector bool char);
11678 int vec_all_gt (vector signed char, vector signed char);
11679 int vec_all_gt (vector bool short, vector unsigned short);
11680 int vec_all_gt (vector unsigned short, vector bool short);
11681 int vec_all_gt (vector unsigned short, vector unsigned short);
11682 int vec_all_gt (vector bool short, vector signed short);
11683 int vec_all_gt (vector signed short, vector bool short);
11684 int vec_all_gt (vector signed short, vector signed short);
11685 int vec_all_gt (vector bool int, vector unsigned int);
11686 int vec_all_gt (vector unsigned int, vector bool int);
11687 int vec_all_gt (vector unsigned int, vector unsigned int);
11688 int vec_all_gt (vector bool int, vector signed int);
11689 int vec_all_gt (vector signed int, vector bool int);
11690 int vec_all_gt (vector signed int, vector signed int);
11691 int vec_all_gt (vector float, vector float);
11693 int vec_all_in (vector float, vector float);
11695 int vec_all_le (vector bool char, vector unsigned char);
11696 int vec_all_le (vector unsigned char, vector bool char);
11697 int vec_all_le (vector unsigned char, vector unsigned char);
11698 int vec_all_le (vector bool char, vector signed char);
11699 int vec_all_le (vector signed char, vector bool char);
11700 int vec_all_le (vector signed char, vector signed char);
11701 int vec_all_le (vector bool short, vector unsigned short);
11702 int vec_all_le (vector unsigned short, vector bool short);
11703 int vec_all_le (vector unsigned short, vector unsigned short);
11704 int vec_all_le (vector bool short, vector signed short);
11705 int vec_all_le (vector signed short, vector bool short);
11706 int vec_all_le (vector signed short, vector signed short);
11707 int vec_all_le (vector bool int, vector unsigned int);
11708 int vec_all_le (vector unsigned int, vector bool int);
11709 int vec_all_le (vector unsigned int, vector unsigned int);
11710 int vec_all_le (vector bool int, vector signed int);
11711 int vec_all_le (vector signed int, vector bool int);
11712 int vec_all_le (vector signed int, vector signed int);
11713 int vec_all_le (vector float, vector float);
11715 int vec_all_lt (vector bool char, vector unsigned char);
11716 int vec_all_lt (vector unsigned char, vector bool char);
11717 int vec_all_lt (vector unsigned char, vector unsigned char);
11718 int vec_all_lt (vector bool char, vector signed char);
11719 int vec_all_lt (vector signed char, vector bool char);
11720 int vec_all_lt (vector signed char, vector signed char);
11721 int vec_all_lt (vector bool short, vector unsigned short);
11722 int vec_all_lt (vector unsigned short, vector bool short);
11723 int vec_all_lt (vector unsigned short, vector unsigned short);
11724 int vec_all_lt (vector bool short, vector signed short);
11725 int vec_all_lt (vector signed short, vector bool short);
11726 int vec_all_lt (vector signed short, vector signed short);
11727 int vec_all_lt (vector bool int, vector unsigned int);
11728 int vec_all_lt (vector unsigned int, vector bool int);
11729 int vec_all_lt (vector unsigned int, vector unsigned int);
11730 int vec_all_lt (vector bool int, vector signed int);
11731 int vec_all_lt (vector signed int, vector bool int);
11732 int vec_all_lt (vector signed int, vector signed int);
11733 int vec_all_lt (vector float, vector float);
11735 int vec_all_nan (vector float);
11737 int vec_all_ne (vector signed char, vector bool char);
11738 int vec_all_ne (vector signed char, vector signed char);
11739 int vec_all_ne (vector unsigned char, vector bool char);
11740 int vec_all_ne (vector unsigned char, vector unsigned char);
11741 int vec_all_ne (vector bool char, vector bool char);
11742 int vec_all_ne (vector bool char, vector unsigned char);
11743 int vec_all_ne (vector bool char, vector signed char);
11744 int vec_all_ne (vector signed short, vector bool short);
11745 int vec_all_ne (vector signed short, vector signed short);
11746 int vec_all_ne (vector unsigned short, vector bool short);
11747 int vec_all_ne (vector unsigned short, vector unsigned short);
11748 int vec_all_ne (vector bool short, vector bool short);
11749 int vec_all_ne (vector bool short, vector unsigned short);
11750 int vec_all_ne (vector bool short, vector signed short);
11751 int vec_all_ne (vector pixel, vector pixel);
11752 int vec_all_ne (vector signed int, vector bool int);
11753 int vec_all_ne (vector signed int, vector signed int);
11754 int vec_all_ne (vector unsigned int, vector bool int);
11755 int vec_all_ne (vector unsigned int, vector unsigned int);
11756 int vec_all_ne (vector bool int, vector bool int);
11757 int vec_all_ne (vector bool int, vector unsigned int);
11758 int vec_all_ne (vector bool int, vector signed int);
11759 int vec_all_ne (vector float, vector float);
11761 int vec_all_nge (vector float, vector float);
11763 int vec_all_ngt (vector float, vector float);
11765 int vec_all_nle (vector float, vector float);
11767 int vec_all_nlt (vector float, vector float);
11769 int vec_all_numeric (vector float);
11771 int vec_any_eq (vector signed char, vector bool char);
11772 int vec_any_eq (vector signed char, vector signed char);
11773 int vec_any_eq (vector unsigned char, vector bool char);
11774 int vec_any_eq (vector unsigned char, vector unsigned char);
11775 int vec_any_eq (vector bool char, vector bool char);
11776 int vec_any_eq (vector bool char, vector unsigned char);
11777 int vec_any_eq (vector bool char, vector signed char);
11778 int vec_any_eq (vector signed short, vector bool short);
11779 int vec_any_eq (vector signed short, vector signed short);
11780 int vec_any_eq (vector unsigned short, vector bool short);
11781 int vec_any_eq (vector unsigned short, vector unsigned short);
11782 int vec_any_eq (vector bool short, vector bool short);
11783 int vec_any_eq (vector bool short, vector unsigned short);
11784 int vec_any_eq (vector bool short, vector signed short);
11785 int vec_any_eq (vector pixel, vector pixel);
11786 int vec_any_eq (vector signed int, vector bool int);
11787 int vec_any_eq (vector signed int, vector signed int);
11788 int vec_any_eq (vector unsigned int, vector bool int);
11789 int vec_any_eq (vector unsigned int, vector unsigned int);
11790 int vec_any_eq (vector bool int, vector bool int);
11791 int vec_any_eq (vector bool int, vector unsigned int);
11792 int vec_any_eq (vector bool int, vector signed int);
11793 int vec_any_eq (vector float, vector float);
11795 int vec_any_ge (vector signed char, vector bool char);
11796 int vec_any_ge (vector unsigned char, vector bool char);
11797 int vec_any_ge (vector unsigned char, vector unsigned char);
11798 int vec_any_ge (vector signed char, vector signed char);
11799 int vec_any_ge (vector bool char, vector unsigned char);
11800 int vec_any_ge (vector bool char, vector signed char);
11801 int vec_any_ge (vector unsigned short, vector bool short);
11802 int vec_any_ge (vector unsigned short, vector unsigned short);
11803 int vec_any_ge (vector signed short, vector signed short);
11804 int vec_any_ge (vector signed short, vector bool short);
11805 int vec_any_ge (vector bool short, vector unsigned short);
11806 int vec_any_ge (vector bool short, vector signed short);
11807 int vec_any_ge (vector signed int, vector bool int);
11808 int vec_any_ge (vector unsigned int, vector bool int);
11809 int vec_any_ge (vector unsigned int, vector unsigned int);
11810 int vec_any_ge (vector signed int, vector signed int);
11811 int vec_any_ge (vector bool int, vector unsigned int);
11812 int vec_any_ge (vector bool int, vector signed int);
11813 int vec_any_ge (vector float, vector float);
11815 int vec_any_gt (vector bool char, vector unsigned char);
11816 int vec_any_gt (vector unsigned char, vector bool char);
11817 int vec_any_gt (vector unsigned char, vector unsigned char);
11818 int vec_any_gt (vector bool char, vector signed char);
11819 int vec_any_gt (vector signed char, vector bool char);
11820 int vec_any_gt (vector signed char, vector signed char);
11821 int vec_any_gt (vector bool short, vector unsigned short);
11822 int vec_any_gt (vector unsigned short, vector bool short);
11823 int vec_any_gt (vector unsigned short, vector unsigned short);
11824 int vec_any_gt (vector bool short, vector signed short);
11825 int vec_any_gt (vector signed short, vector bool short);
11826 int vec_any_gt (vector signed short, vector signed short);
11827 int vec_any_gt (vector bool int, vector unsigned int);
11828 int vec_any_gt (vector unsigned int, vector bool int);
11829 int vec_any_gt (vector unsigned int, vector unsigned int);
11830 int vec_any_gt (vector bool int, vector signed int);
11831 int vec_any_gt (vector signed int, vector bool int);
11832 int vec_any_gt (vector signed int, vector signed int);
11833 int vec_any_gt (vector float, vector float);
11835 int vec_any_le (vector bool char, vector unsigned char);
11836 int vec_any_le (vector unsigned char, vector bool char);
11837 int vec_any_le (vector unsigned char, vector unsigned char);
11838 int vec_any_le (vector bool char, vector signed char);
11839 int vec_any_le (vector signed char, vector bool char);
11840 int vec_any_le (vector signed char, vector signed char);
11841 int vec_any_le (vector bool short, vector unsigned short);
11842 int vec_any_le (vector unsigned short, vector bool short);
11843 int vec_any_le (vector unsigned short, vector unsigned short);
11844 int vec_any_le (vector bool short, vector signed short);
11845 int vec_any_le (vector signed short, vector bool short);
11846 int vec_any_le (vector signed short, vector signed short);
11847 int vec_any_le (vector bool int, vector unsigned int);
11848 int vec_any_le (vector unsigned int, vector bool int);
11849 int vec_any_le (vector unsigned int, vector unsigned int);
11850 int vec_any_le (vector bool int, vector signed int);
11851 int vec_any_le (vector signed int, vector bool int);
11852 int vec_any_le (vector signed int, vector signed int);
11853 int vec_any_le (vector float, vector float);
11855 int vec_any_lt (vector bool char, vector unsigned char);
11856 int vec_any_lt (vector unsigned char, vector bool char);
11857 int vec_any_lt (vector unsigned char, vector unsigned char);
11858 int vec_any_lt (vector bool char, vector signed char);
11859 int vec_any_lt (vector signed char, vector bool char);
11860 int vec_any_lt (vector signed char, vector signed char);
11861 int vec_any_lt (vector bool short, vector unsigned short);
11862 int vec_any_lt (vector unsigned short, vector bool short);
11863 int vec_any_lt (vector unsigned short, vector unsigned short);
11864 int vec_any_lt (vector bool short, vector signed short);
11865 int vec_any_lt (vector signed short, vector bool short);
11866 int vec_any_lt (vector signed short, vector signed short);
11867 int vec_any_lt (vector bool int, vector unsigned int);
11868 int vec_any_lt (vector unsigned int, vector bool int);
11869 int vec_any_lt (vector unsigned int, vector unsigned int);
11870 int vec_any_lt (vector bool int, vector signed int);
11871 int vec_any_lt (vector signed int, vector bool int);
11872 int vec_any_lt (vector signed int, vector signed int);
11873 int vec_any_lt (vector float, vector float);
11875 int vec_any_nan (vector float);
11877 int vec_any_ne (vector signed char, vector bool char);
11878 int vec_any_ne (vector signed char, vector signed char);
11879 int vec_any_ne (vector unsigned char, vector bool char);
11880 int vec_any_ne (vector unsigned char, vector unsigned char);
11881 int vec_any_ne (vector bool char, vector bool char);
11882 int vec_any_ne (vector bool char, vector unsigned char);
11883 int vec_any_ne (vector bool char, vector signed char);
11884 int vec_any_ne (vector signed short, vector bool short);
11885 int vec_any_ne (vector signed short, vector signed short);
11886 int vec_any_ne (vector unsigned short, vector bool short);
11887 int vec_any_ne (vector unsigned short, vector unsigned short);
11888 int vec_any_ne (vector bool short, vector bool short);
11889 int vec_any_ne (vector bool short, vector unsigned short);
11890 int vec_any_ne (vector bool short, vector signed short);
11891 int vec_any_ne (vector pixel, vector pixel);
11892 int vec_any_ne (vector signed int, vector bool int);
11893 int vec_any_ne (vector signed int, vector signed int);
11894 int vec_any_ne (vector unsigned int, vector bool int);
11895 int vec_any_ne (vector unsigned int, vector unsigned int);
11896 int vec_any_ne (vector bool int, vector bool int);
11897 int vec_any_ne (vector bool int, vector unsigned int);
11898 int vec_any_ne (vector bool int, vector signed int);
11899 int vec_any_ne (vector float, vector float);
11901 int vec_any_nge (vector float, vector float);
11903 int vec_any_ngt (vector float, vector float);
11905 int vec_any_nle (vector float, vector float);
11907 int vec_any_nlt (vector float, vector float);
11909 int vec_any_numeric (vector float);
11911 int vec_any_out (vector float, vector float);
11912 @end smallexample
11914 If the vector/scalar (VSX) instruction set is available, the following
11915 additional functions are available:
11917 @smallexample
11918 vector double vec_abs (vector double);
11919 vector double vec_add (vector double, vector double);
11920 vector double vec_and (vector double, vector double);
11921 vector double vec_and (vector double, vector bool long);
11922 vector double vec_and (vector bool long, vector double);
11923 vector double vec_andc (vector double, vector double);
11924 vector double vec_andc (vector double, vector bool long);
11925 vector double vec_andc (vector bool long, vector double);
11926 vector double vec_ceil (vector double);
11927 vector bool long vec_cmpeq (vector double, vector double);
11928 vector bool long vec_cmpge (vector double, vector double);
11929 vector bool long vec_cmpgt (vector double, vector double);
11930 vector bool long vec_cmple (vector double, vector double);
11931 vector bool long vec_cmplt (vector double, vector double);
11932 vector float vec_div (vector float, vector float);
11933 vector double vec_div (vector double, vector double);
11934 vector double vec_floor (vector double);
11935 vector double vec_madd (vector double, vector double, vector double);
11936 vector double vec_max (vector double, vector double);
11937 vector double vec_min (vector double, vector double);
11938 vector float vec_msub (vector float, vector float, vector float);
11939 vector double vec_msub (vector double, vector double, vector double);
11940 vector float vec_mul (vector float, vector float);
11941 vector double vec_mul (vector double, vector double);
11942 vector float vec_nearbyint (vector float);
11943 vector double vec_nearbyint (vector double);
11944 vector float vec_nmadd (vector float, vector float, vector float);
11945 vector double vec_nmadd (vector double, vector double, vector double);
11946 vector double vec_nmsub (vector double, vector double, vector double);
11947 vector double vec_nor (vector double, vector double);
11948 vector double vec_or (vector double, vector double);
11949 vector double vec_or (vector double, vector bool long);
11950 vector double vec_or (vector bool long, vector double);
11951 vector double vec_perm (vector double,
11952                         vector double,
11953                         vector unsigned char);
11954 vector double vec_rint (vector double);
11955 vector double vec_recip (vector double, vector double);
11956 vector double vec_rsqrt (vector double);
11957 vector double vec_rsqrte (vector double);
11958 vector double vec_sel (vector double, vector double, vector bool long);
11959 vector double vec_sel (vector double, vector double, vector unsigned long);
11960 vector double vec_sub (vector double, vector double);
11961 vector float vec_sqrt (vector float);
11962 vector double vec_sqrt (vector double);
11963 vector double vec_trunc (vector double);
11964 vector double vec_xor (vector double, vector double);
11965 vector double vec_xor (vector double, vector bool long);
11966 vector double vec_xor (vector bool long, vector double);
11967 int vec_all_eq (vector double, vector double);
11968 int vec_all_ge (vector double, vector double);
11969 int vec_all_gt (vector double, vector double);
11970 int vec_all_le (vector double, vector double);
11971 int vec_all_lt (vector double, vector double);
11972 int vec_all_nan (vector double);
11973 int vec_all_ne (vector double, vector double);
11974 int vec_all_nge (vector double, vector double);
11975 int vec_all_ngt (vector double, vector double);
11976 int vec_all_nle (vector double, vector double);
11977 int vec_all_nlt (vector double, vector double);
11978 int vec_all_numeric (vector double);
11979 int vec_any_eq (vector double, vector double);
11980 int vec_any_ge (vector double, vector double);
11981 int vec_any_gt (vector double, vector double);
11982 int vec_any_le (vector double, vector double);
11983 int vec_any_lt (vector double, vector double);
11984 int vec_any_nan (vector double);
11985 int vec_any_ne (vector double, vector double);
11986 int vec_any_nge (vector double, vector double);
11987 int vec_any_ngt (vector double, vector double);
11988 int vec_any_nle (vector double, vector double);
11989 int vec_any_nlt (vector double, vector double);
11990 int vec_any_numeric (vector double);
11991 @end smallexample
11993 GCC provides a few other builtins on Powerpc to access certain instructions:
11994 @smallexample
11995 float __builtin_recipdivf (float, float);
11996 float __builtin_rsqrtf (float);
11997 double __builtin_recipdiv (double, double);
11998 double __builtin_rsqrt (double);
11999 long __builtin_bpermd (long, long);
12000 int __builtin_bswap16 (int);
12001 @end smallexample
12003 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12004 @code{__builtin_rsqrtf} functions generate multiple instructions to
12005 implement the reciprocal sqrt functionality using reciprocal sqrt
12006 estimate instructions.
12008 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12009 functions generate multiple instructions to implement division using
12010 the reciprocal estimate instructions.
12012 @node RX Built-in Functions
12013 @subsection RX Built-in Functions
12014 GCC supports some of the RX instructions which cannot be expressed in
12015 the C programming language via the use of built-in functions.  The
12016 following functions are supported:
12018 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
12019 Generates the @code{brk} machine instruction.
12020 @end deftypefn
12022 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
12023 Generates the @code{clrpsw} machine instruction to clear the specified
12024 bit in the processor status word.
12025 @end deftypefn
12027 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
12028 Generates the @code{int} machine instruction to generate an interrupt
12029 with the specified value.
12030 @end deftypefn
12032 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
12033 Generates the @code{machi} machine instruction to add the result of
12034 multiplying the top 16-bits of the two arguments into the
12035 accumulator.
12036 @end deftypefn
12038 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
12039 Generates the @code{maclo} machine instruction to add the result of
12040 multiplying the bottom 16-bits of the two arguments into the
12041 accumulator.
12042 @end deftypefn
12044 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
12045 Generates the @code{mulhi} machine instruction to place the result of
12046 multiplying the top 16-bits of the two arguments into the
12047 accumulator.
12048 @end deftypefn
12050 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
12051 Generates the @code{mullo} machine instruction to place the result of
12052 multiplying the bottom 16-bits of the two arguments into the
12053 accumulator.
12054 @end deftypefn
12056 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
12057 Generates the @code{mvfachi} machine instruction to read the top
12058 32-bits of the accumulator.
12059 @end deftypefn
12061 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
12062 Generates the @code{mvfacmi} machine instruction to read the middle
12063 32-bits of the accumulator.
12064 @end deftypefn
12066 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
12067 Generates the @code{mvfc} machine instruction which reads the control
12068 register specified in its argument and returns its value.
12069 @end deftypefn
12071 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
12072 Generates the @code{mvtachi} machine instruction to set the top
12073 32-bits of the accumulator.
12074 @end deftypefn
12076 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
12077 Generates the @code{mvtaclo} machine instruction to set the bottom
12078 32-bits of the accumulator.
12079 @end deftypefn
12081 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
12082 Generates the @code{mvtc} machine instruction which sets control
12083 register number @code{reg} to @code{val}.
12084 @end deftypefn
12086 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
12087 Generates the @code{mvtipl} machine instruction set the interrupt
12088 priority level.
12089 @end deftypefn
12091 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
12092 Generates the @code{racw} machine instruction to round the accumulator
12093 according to the specified mode.
12094 @end deftypefn
12096 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
12097 Generates the @code{revw} machine instruction which swaps the bytes in
12098 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
12099 and also bits 16--23 occupy bits 24--31 and vice versa.
12100 @end deftypefn
12102 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
12103 Generates the @code{rmpa} machine instruction which initiates a
12104 repeated multiply and accumulate sequence.
12105 @end deftypefn
12107 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
12108 Generates the @code{round} machine instruction which returns the
12109 floating point argument rounded according to the current rounding mode
12110 set in the floating point status word register.
12111 @end deftypefn
12113 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
12114 Generates the @code{sat} machine instruction which returns the
12115 saturated value of the argument.
12116 @end deftypefn
12118 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
12119 Generates the @code{setpsw} machine instruction to set the specified
12120 bit in the processor status word.
12121 @end deftypefn
12123 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
12124 Generates the @code{wait} machine instruction.
12125 @end deftypefn
12127 @node SPARC VIS Built-in Functions
12128 @subsection SPARC VIS Built-in Functions
12130 GCC supports SIMD operations on the SPARC using both the generic vector
12131 extensions (@pxref{Vector Extensions}) as well as built-in functions for
12132 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
12133 switch, the VIS extension is exposed as the following built-in functions:
12135 @smallexample
12136 typedef int v2si __attribute__ ((vector_size (8)));
12137 typedef short v4hi __attribute__ ((vector_size (8)));
12138 typedef short v2hi __attribute__ ((vector_size (4)));
12139 typedef char v8qi __attribute__ ((vector_size (8)));
12140 typedef char v4qi __attribute__ ((vector_size (4)));
12142 void * __builtin_vis_alignaddr (void *, long);
12143 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
12144 v2si __builtin_vis_faligndatav2si (v2si, v2si);
12145 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
12146 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
12148 v4hi __builtin_vis_fexpand (v4qi);
12150 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
12151 v4hi __builtin_vis_fmul8x16au (v4qi, v4hi);
12152 v4hi __builtin_vis_fmul8x16al (v4qi, v4hi);
12153 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
12154 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
12155 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
12156 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
12158 v4qi __builtin_vis_fpack16 (v4hi);
12159 v8qi __builtin_vis_fpack32 (v2si, v2si);
12160 v2hi __builtin_vis_fpackfix (v2si);
12161 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
12163 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
12164 @end smallexample
12166 @node SPU Built-in Functions
12167 @subsection SPU Built-in Functions
12169 GCC provides extensions for the SPU processor as described in the
12170 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
12171 found at @uref{http://cell.scei.co.jp/} or
12172 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
12173 implementation differs in several ways.
12175 @itemize @bullet
12177 @item
12178 The optional extension of specifying vector constants in parentheses is
12179 not supported.
12181 @item
12182 A vector initializer requires no cast if the vector constant is of the
12183 same type as the variable it is initializing.
12185 @item
12186 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12187 vector type is the default signedness of the base type.  The default
12188 varies depending on the operating system, so a portable program should
12189 always specify the signedness.
12191 @item
12192 By default, the keyword @code{__vector} is added. The macro
12193 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
12194 undefined.
12196 @item
12197 GCC allows using a @code{typedef} name as the type specifier for a
12198 vector type.
12200 @item
12201 For C, overloaded functions are implemented with macros so the following
12202 does not work:
12204 @smallexample
12205   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12206 @end smallexample
12208 Since @code{spu_add} is a macro, the vector constant in the example
12209 is treated as four separate arguments.  Wrap the entire argument in
12210 parentheses for this to work.
12212 @item
12213 The extended version of @code{__builtin_expect} is not supported.
12215 @end itemize
12217 @emph{Note:} Only the interface described in the aforementioned
12218 specification is supported. Internally, GCC uses built-in functions to
12219 implement the required functionality, but these are not supported and
12220 are subject to change without notice.
12222 @node Target Format Checks
12223 @section Format Checks Specific to Particular Target Machines
12225 For some target machines, GCC supports additional options to the
12226 format attribute
12227 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
12229 @menu
12230 * Solaris Format Checks::
12231 @end menu
12233 @node Solaris Format Checks
12234 @subsection Solaris Format Checks
12236 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
12237 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
12238 conversions, and the two-argument @code{%b} conversion for displaying
12239 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
12241 @node Pragmas
12242 @section Pragmas Accepted by GCC
12243 @cindex pragmas
12244 @cindex #pragma
12246 GCC supports several types of pragmas, primarily in order to compile
12247 code originally written for other compilers.  Note that in general
12248 we do not recommend the use of pragmas; @xref{Function Attributes},
12249 for further explanation.
12251 @menu
12252 * ARM Pragmas::
12253 * M32C Pragmas::
12254 * MeP Pragmas::
12255 * RS/6000 and PowerPC Pragmas::
12256 * Darwin Pragmas::
12257 * Solaris Pragmas::
12258 * Symbol-Renaming Pragmas::
12259 * Structure-Packing Pragmas::
12260 * Weak Pragmas::
12261 * Diagnostic Pragmas::
12262 * Visibility Pragmas::
12263 * Push/Pop Macro Pragmas::
12264 * Function Specific Option Pragmas::
12265 @end menu
12267 @node ARM Pragmas
12268 @subsection ARM Pragmas
12270 The ARM target defines pragmas for controlling the default addition of
12271 @code{long_call} and @code{short_call} attributes to functions.
12272 @xref{Function Attributes}, for information about the effects of these
12273 attributes.
12275 @table @code
12276 @item long_calls
12277 @cindex pragma, long_calls
12278 Set all subsequent functions to have the @code{long_call} attribute.
12280 @item no_long_calls
12281 @cindex pragma, no_long_calls
12282 Set all subsequent functions to have the @code{short_call} attribute.
12284 @item long_calls_off
12285 @cindex pragma, long_calls_off
12286 Do not affect the @code{long_call} or @code{short_call} attributes of
12287 subsequent functions.
12288 @end table
12290 @node M32C Pragmas
12291 @subsection M32C Pragmas
12293 @table @code
12294 @item GCC memregs @var{number}
12295 @cindex pragma, memregs
12296 Overrides the command-line option @code{-memregs=} for the current
12297 file.  Use with care!  This pragma must be before any function in the
12298 file, and mixing different memregs values in different objects may
12299 make them incompatible.  This pragma is useful when a
12300 performance-critical function uses a memreg for temporary values,
12301 as it may allow you to reduce the number of memregs used.
12303 @item ADDRESS @var{name} @var{address}
12304 @cindex pragma, address
12305 For any declared symbols matching @var{name}, this does three things
12306 to that symbol: it forces the symbol to be located at the given
12307 address (a number), it forces the symbol to be volatile, and it
12308 changes the symbol's scope to be static.  This pragma exists for
12309 compatibility with other compilers, but note that the common
12310 @code{1234H} numeric syntax is not supported (use @code{0x1234}
12311 instead).  Example:
12313 @example
12314 #pragma ADDRESS port3 0x103
12315 char port3;
12316 @end example
12318 @end table
12320 @node MeP Pragmas
12321 @subsection MeP Pragmas
12323 @table @code
12325 @item custom io_volatile (on|off)
12326 @cindex pragma, custom io_volatile
12327 Overrides the command line option @code{-mio-volatile} for the current
12328 file.  Note that for compatibility with future GCC releases, this
12329 option should only be used once before any @code{io} variables in each
12330 file.
12332 @item GCC coprocessor available @var{registers}
12333 @cindex pragma, coprocessor available
12334 Specifies which coprocessor registers are available to the register
12335 allocator.  @var{registers} may be a single register, register range
12336 separated by ellipses, or comma-separated list of those.  Example:
12338 @example
12339 #pragma GCC coprocessor available $c0...$c10, $c28
12340 @end example
12342 @item GCC coprocessor call_saved @var{registers}
12343 @cindex pragma, coprocessor call_saved
12344 Specifies which coprocessor registers are to be saved and restored by
12345 any function using them.  @var{registers} may be a single register,
12346 register range separated by ellipses, or comma-separated list of
12347 those.  Example:
12349 @example
12350 #pragma GCC coprocessor call_saved $c4...$c6, $c31
12351 @end example
12353 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
12354 @cindex pragma, coprocessor subclass
12355 Creates and defines a register class.  These register classes can be
12356 used by inline @code{asm} constructs.  @var{registers} may be a single
12357 register, register range separated by ellipses, or comma-separated
12358 list of those.  Example:
12360 @example
12361 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
12363 asm ("cpfoo %0" : "=B" (x));
12364 @end example
12366 @item GCC disinterrupt @var{name} , @var{name} @dots{}
12367 @cindex pragma, disinterrupt
12368 For the named functions, the compiler adds code to disable interrupts
12369 for the duration of those functions.  Any functions so named, which
12370 are not encountered in the source, cause a warning that the pragma was
12371 not used.  Examples:
12373 @example
12374 #pragma disinterrupt foo
12375 #pragma disinterrupt bar, grill
12376 int foo () @{ @dots{} @}
12377 @end example
12379 @item GCC call @var{name} , @var{name} @dots{}
12380 @cindex pragma, call
12381 For the named functions, the compiler always uses a register-indirect
12382 call model when calling the named functions.  Examples:
12384 @example
12385 extern int foo ();
12386 #pragma call foo
12387 @end example
12389 @end table
12391 @node RS/6000 and PowerPC Pragmas
12392 @subsection RS/6000 and PowerPC Pragmas
12394 The RS/6000 and PowerPC targets define one pragma for controlling
12395 whether or not the @code{longcall} attribute is added to function
12396 declarations by default.  This pragma overrides the @option{-mlongcall}
12397 option, but not the @code{longcall} and @code{shortcall} attributes.
12398 @xref{RS/6000 and PowerPC Options}, for more information about when long
12399 calls are and are not necessary.
12401 @table @code
12402 @item longcall (1)
12403 @cindex pragma, longcall
12404 Apply the @code{longcall} attribute to all subsequent function
12405 declarations.
12407 @item longcall (0)
12408 Do not apply the @code{longcall} attribute to subsequent function
12409 declarations.
12410 @end table
12412 @c Describe h8300 pragmas here.
12413 @c Describe sh pragmas here.
12414 @c Describe v850 pragmas here.
12416 @node Darwin Pragmas
12417 @subsection Darwin Pragmas
12419 The following pragmas are available for all architectures running the
12420 Darwin operating system.  These are useful for compatibility with other
12421 Mac OS compilers.
12423 @table @code
12424 @item mark @var{tokens}@dots{}
12425 @cindex pragma, mark
12426 This pragma is accepted, but has no effect.
12428 @item options align=@var{alignment}
12429 @cindex pragma, options align
12430 This pragma sets the alignment of fields in structures.  The values of
12431 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
12432 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
12433 properly; to restore the previous setting, use @code{reset} for the
12434 @var{alignment}.
12436 @item segment @var{tokens}@dots{}
12437 @cindex pragma, segment
12438 This pragma is accepted, but has no effect.
12440 @item unused (@var{var} [, @var{var}]@dots{})
12441 @cindex pragma, unused
12442 This pragma declares variables to be possibly unused.  GCC will not
12443 produce warnings for the listed variables.  The effect is similar to
12444 that of the @code{unused} attribute, except that this pragma may appear
12445 anywhere within the variables' scopes.
12446 @end table
12448 @node Solaris Pragmas
12449 @subsection Solaris Pragmas
12451 The Solaris target supports @code{#pragma redefine_extname}
12452 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
12453 @code{#pragma} directives for compatibility with the system compiler.
12455 @table @code
12456 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
12457 @cindex pragma, align
12459 Increase the minimum alignment of each @var{variable} to @var{alignment}.
12460 This is the same as GCC's @code{aligned} attribute @pxref{Variable
12461 Attributes}).  Macro expansion occurs on the arguments to this pragma
12462 when compiling C and Objective-C@.  It does not currently occur when
12463 compiling C++, but this is a bug which may be fixed in a future
12464 release.
12466 @item fini (@var{function} [, @var{function}]...)
12467 @cindex pragma, fini
12469 This pragma causes each listed @var{function} to be called after
12470 main, or during shared module unloading, by adding a call to the
12471 @code{.fini} section.
12473 @item init (@var{function} [, @var{function}]...)
12474 @cindex pragma, init
12476 This pragma causes each listed @var{function} to be called during
12477 initialization (before @code{main}) or during shared module loading, by
12478 adding a call to the @code{.init} section.
12480 @end table
12482 @node Symbol-Renaming Pragmas
12483 @subsection Symbol-Renaming Pragmas
12485 For compatibility with the Solaris and Tru64 UNIX system headers, GCC
12486 supports two @code{#pragma} directives which change the name used in
12487 assembly for a given declaration.  @code{#pragma extern_prefix} is only 
12488 available on platforms whose system headers need it. To get this effect 
12489 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
12490 Labels}).
12492 @table @code
12493 @item redefine_extname @var{oldname} @var{newname}
12494 @cindex pragma, redefine_extname
12496 This pragma gives the C function @var{oldname} the assembly symbol
12497 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
12498 will be defined if this pragma is available (currently on all platforms).
12500 @item extern_prefix @var{string}
12501 @cindex pragma, extern_prefix
12503 This pragma causes all subsequent external function and variable
12504 declarations to have @var{string} prepended to their assembly symbols.
12505 This effect may be terminated with another @code{extern_prefix} pragma
12506 whose argument is an empty string.  The preprocessor macro
12507 @code{__PRAGMA_EXTERN_PREFIX} will be defined if this pragma is
12508 available (currently only on Tru64 UNIX)@.
12509 @end table
12511 These pragmas and the asm labels extension interact in a complicated
12512 manner.  Here are some corner cases you may want to be aware of.
12514 @enumerate
12515 @item Both pragmas silently apply only to declarations with external
12516 linkage.  Asm labels do not have this restriction.
12518 @item In C++, both pragmas silently apply only to declarations with
12519 ``C'' linkage.  Again, asm labels do not have this restriction.
12521 @item If any of the three ways of changing the assembly name of a
12522 declaration is applied to a declaration whose assembly name has
12523 already been determined (either by a previous use of one of these
12524 features, or because the compiler needed the assembly name in order to
12525 generate code), and the new name is different, a warning issues and
12526 the name does not change.
12528 @item The @var{oldname} used by @code{#pragma redefine_extname} is
12529 always the C-language name.
12531 @item If @code{#pragma extern_prefix} is in effect, and a declaration
12532 occurs with an asm label attached, the prefix is silently ignored for
12533 that declaration.
12535 @item If @code{#pragma extern_prefix} and @code{#pragma redefine_extname}
12536 apply to the same declaration, whichever triggered first wins, and a
12537 warning issues if they contradict each other.  (We would like to have
12538 @code{#pragma redefine_extname} always win, for consistency with asm
12539 labels, but if @code{#pragma extern_prefix} triggers first we have no
12540 way of knowing that that happened.)
12541 @end enumerate
12543 @node Structure-Packing Pragmas
12544 @subsection Structure-Packing Pragmas
12546 For compatibility with Microsoft Windows compilers, GCC supports a
12547 set of @code{#pragma} directives which change the maximum alignment of
12548 members of structures (other than zero-width bitfields), unions, and
12549 classes subsequently defined. The @var{n} value below always is required
12550 to be a small power of two and specifies the new alignment in bytes.
12552 @enumerate
12553 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
12554 @item @code{#pragma pack()} sets the alignment to the one that was in
12555 effect when compilation started (see also command-line option
12556 @option{-fpack-struct[=<n>]} @pxref{Code Gen Options}).
12557 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
12558 setting on an internal stack and then optionally sets the new alignment.
12559 @item @code{#pragma pack(pop)} restores the alignment setting to the one
12560 saved at the top of the internal stack (and removes that stack entry).
12561 Note that @code{#pragma pack([@var{n}])} does not influence this internal
12562 stack; thus it is possible to have @code{#pragma pack(push)} followed by
12563 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
12564 @code{#pragma pack(pop)}.
12565 @end enumerate
12567 Some targets, e.g.@: i386 and powerpc, support the @code{ms_struct}
12568 @code{#pragma} which lays out a structure as the documented
12569 @code{__attribute__ ((ms_struct))}.
12570 @enumerate
12571 @item @code{#pragma ms_struct on} turns on the layout for structures
12572 declared.
12573 @item @code{#pragma ms_struct off} turns off the layout for structures
12574 declared.
12575 @item @code{#pragma ms_struct reset} goes back to the default layout.
12576 @end enumerate
12578 @node Weak Pragmas
12579 @subsection Weak Pragmas
12581 For compatibility with SVR4, GCC supports a set of @code{#pragma}
12582 directives for declaring symbols to be weak, and defining weak
12583 aliases.
12585 @table @code
12586 @item #pragma weak @var{symbol}
12587 @cindex pragma, weak
12588 This pragma declares @var{symbol} to be weak, as if the declaration
12589 had the attribute of the same name.  The pragma may appear before
12590 or after the declaration of @var{symbol}, but must appear before
12591 either its first use or its definition.  It is not an error for
12592 @var{symbol} to never be defined at all.
12594 @item #pragma weak @var{symbol1} = @var{symbol2}
12595 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
12596 It is an error if @var{symbol2} is not defined in the current
12597 translation unit.
12598 @end table
12600 @node Diagnostic Pragmas
12601 @subsection Diagnostic Pragmas
12603 GCC allows the user to selectively enable or disable certain types of
12604 diagnostics, and change the kind of the diagnostic.  For example, a
12605 project's policy might require that all sources compile with
12606 @option{-Werror} but certain files might have exceptions allowing
12607 specific types of warnings.  Or, a project might selectively enable
12608 diagnostics and treat them as errors depending on which preprocessor
12609 macros are defined.
12611 @table @code
12612 @item #pragma GCC diagnostic @var{kind} @var{option}
12613 @cindex pragma, diagnostic
12615 Modifies the disposition of a diagnostic.  Note that not all
12616 diagnostics are modifiable; at the moment only warnings (normally
12617 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
12618 Use @option{-fdiagnostics-show-option} to determine which diagnostics
12619 are controllable and which option controls them.
12621 @var{kind} is @samp{error} to treat this diagnostic as an error,
12622 @samp{warning} to treat it like a warning (even if @option{-Werror} is
12623 in effect), or @samp{ignored} if the diagnostic is to be ignored.
12624 @var{option} is a double quoted string which matches the command-line
12625 option.
12627 @example
12628 #pragma GCC diagnostic warning "-Wformat"
12629 #pragma GCC diagnostic error "-Wformat"
12630 #pragma GCC diagnostic ignored "-Wformat"
12631 @end example
12633 Note that these pragmas override any command-line options.  GCC keeps
12634 track of the location of each pragma, and issues diagnostics according
12635 to the state as of that point in the source file.  Thus, pragmas occurring
12636 after a line do not affect diagnostics caused by that line.
12638 @item #pragma GCC diagnostic push
12639 @itemx #pragma GCC diagnostic pop
12641 Causes GCC to remember the state of the diagnostics as of each
12642 @code{push}, and restore to that point at each @code{pop}.  If a
12643 @code{pop} has no matching @code{push}, the command line options are
12644 restored.
12646 @example
12647 #pragma GCC diagnostic error "-Wuninitialized"
12648   foo(a);                       /* error is given for this one */
12649 #pragma GCC diagnostic push
12650 #pragma GCC diagnostic ignored "-Wuninitialized"
12651   foo(b);                       /* no diagnostic for this one */
12652 #pragma GCC diagnostic pop
12653   foo(c);                       /* error is given for this one */
12654 #pragma GCC diagnostic pop
12655   foo(d);                       /* depends on command line options */
12656 @end example
12658 @end table
12660 GCC also offers a simple mechanism for printing messages during
12661 compilation.
12663 @table @code
12664 @item #pragma message @var{string}
12665 @cindex pragma, diagnostic
12667 Prints @var{string} as a compiler message on compilation.  The message
12668 is informational only, and is neither a compilation warning nor an error.
12670 @smallexample
12671 #pragma message "Compiling " __FILE__ "..."
12672 @end smallexample
12674 @var{string} may be parenthesized, and is printed with location
12675 information.  For example,
12677 @smallexample
12678 #define DO_PRAGMA(x) _Pragma (#x)
12679 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
12681 TODO(Remember to fix this)
12682 @end smallexample
12684 prints @samp{/tmp/file.c:4: note: #pragma message:
12685 TODO - Remember to fix this}.
12687 @end table
12689 @node Visibility Pragmas
12690 @subsection Visibility Pragmas
12692 @table @code
12693 @item #pragma GCC visibility push(@var{visibility})
12694 @itemx #pragma GCC visibility pop
12695 @cindex pragma, visibility
12697 This pragma allows the user to set the visibility for multiple
12698 declarations without having to give each a visibility attribute
12699 @xref{Function Attributes}, for more information about visibility and
12700 the attribute syntax.
12702 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
12703 declarations.  Class members and template specializations are not
12704 affected; if you want to override the visibility for a particular
12705 member or instantiation, you must use an attribute.
12707 @end table
12710 @node Push/Pop Macro Pragmas
12711 @subsection Push/Pop Macro Pragmas
12713 For compatibility with Microsoft Windows compilers, GCC supports
12714 @samp{#pragma push_macro(@var{"macro_name"})}
12715 and @samp{#pragma pop_macro(@var{"macro_name"})}.
12717 @table @code
12718 @item #pragma push_macro(@var{"macro_name"})
12719 @cindex pragma, push_macro
12720 This pragma saves the value of the macro named as @var{macro_name} to
12721 the top of the stack for this macro.
12723 @item #pragma pop_macro(@var{"macro_name"})
12724 @cindex pragma, pop_macro
12725 This pragma sets the value of the macro named as @var{macro_name} to
12726 the value on top of the stack for this macro. If the stack for
12727 @var{macro_name} is empty, the value of the macro remains unchanged.
12728 @end table
12730 For example:
12732 @smallexample
12733 #define X  1
12734 #pragma push_macro("X")
12735 #undef X
12736 #define X -1
12737 #pragma pop_macro("X")
12738 int x [X]; 
12739 @end smallexample
12741 In this example, the definition of X as 1 is saved by @code{#pragma
12742 push_macro} and restored by @code{#pragma pop_macro}.
12744 @node Function Specific Option Pragmas
12745 @subsection Function Specific Option Pragmas
12747 @table @code
12748 @item #pragma GCC target (@var{"string"}...)
12749 @cindex pragma GCC target
12751 This pragma allows you to set target specific options for functions
12752 defined later in the source file.  One or more strings can be
12753 specified.  Each function that is defined after this point will be as
12754 if @code{attribute((target("STRING")))} was specified for that
12755 function.  The parenthesis around the options is optional.
12756 @xref{Function Attributes}, for more information about the
12757 @code{target} attribute and the attribute syntax.
12759 The @samp{#pragma GCC target} pragma is not implemented in GCC
12760 versions earlier than 4.4, and is currently only implemented for the
12761 386 and x86_64 backends.
12762 @end table
12764 @table @code
12765 @item #pragma GCC optimize (@var{"string"}...)
12766 @cindex pragma GCC optimize
12768 This pragma allows you to set global optimization options for functions
12769 defined later in the source file.  One or more strings can be
12770 specified.  Each function that is defined after this point will be as
12771 if @code{attribute((optimize("STRING")))} was specified for that
12772 function.  The parenthesis around the options is optional.
12773 @xref{Function Attributes}, for more information about the
12774 @code{optimize} attribute and the attribute syntax.
12776 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
12777 versions earlier than 4.4.
12778 @end table
12780 @table @code
12781 @item #pragma GCC push_options
12782 @itemx #pragma GCC pop_options
12783 @cindex pragma GCC push_options
12784 @cindex pragma GCC pop_options
12786 These pragmas maintain a stack of the current target and optimization
12787 options.  It is intended for include files where you temporarily want
12788 to switch to using a different @samp{#pragma GCC target} or
12789 @samp{#pragma GCC optimize} and then to pop back to the previous
12790 options.
12792 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
12793 pragmas are not implemented in GCC versions earlier than 4.4.
12794 @end table
12796 @table @code
12797 @item #pragma GCC reset_options
12798 @cindex pragma GCC reset_options
12800 This pragma clears the current @code{#pragma GCC target} and
12801 @code{#pragma GCC optimize} to use the default switches as specified
12802 on the command line.
12804 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
12805 versions earlier than 4.4.
12806 @end table
12808 @node Unnamed Fields
12809 @section Unnamed struct/union fields within structs/unions
12810 @cindex struct
12811 @cindex union
12813 As permitted by ISO C1X and for compatibility with other compilers,
12814 GCC allows you to define
12815 a structure or union that contains, as fields, structures and unions
12816 without names.  For example:
12818 @smallexample
12819 struct @{
12820   int a;
12821   union @{
12822     int b;
12823     float c;
12824   @};
12825   int d;
12826 @} foo;
12827 @end smallexample
12829 In this example, the user would be able to access members of the unnamed
12830 union with code like @samp{foo.b}.  Note that only unnamed structs and
12831 unions are allowed, you may not have, for example, an unnamed
12832 @code{int}.
12834 You must never create such structures that cause ambiguous field definitions.
12835 For example, this structure:
12837 @smallexample
12838 struct @{
12839   int a;
12840   struct @{
12841     int a;
12842   @};
12843 @} foo;
12844 @end smallexample
12846 It is ambiguous which @code{a} is being referred to with @samp{foo.a}.
12847 The compiler gives errors for such constructs.
12849 @opindex fms-extensions
12850 Unless @option{-fms-extensions} is used, the unnamed field must be a
12851 structure or union definition without a tag (for example, @samp{struct
12852 @{ int a; @};}), or a @code{typedef} name for such a structure or
12853 union.  If @option{-fms-extensions} is used, the field may
12854 also be a definition with a tag such as @samp{struct foo @{ int a;
12855 @};}, a reference to a previously defined structure or union such as
12856 @samp{struct foo;}, or a reference to a @code{typedef} name for a
12857 previously defined structure or union type with a tag.
12859 @node Thread-Local
12860 @section Thread-Local Storage
12861 @cindex Thread-Local Storage
12862 @cindex @acronym{TLS}
12863 @cindex __thread
12865 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
12866 are allocated such that there is one instance of the variable per extant
12867 thread.  The run-time model GCC uses to implement this originates
12868 in the IA-64 processor-specific ABI, but has since been migrated
12869 to other processors as well.  It requires significant support from
12870 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
12871 system libraries (@file{libc.so} and @file{libpthread.so}), so it
12872 is not available everywhere.
12874 At the user level, the extension is visible with a new storage
12875 class keyword: @code{__thread}.  For example:
12877 @smallexample
12878 __thread int i;
12879 extern __thread struct state s;
12880 static __thread char *p;
12881 @end smallexample
12883 The @code{__thread} specifier may be used alone, with the @code{extern}
12884 or @code{static} specifiers, but with no other storage class specifier.
12885 When used with @code{extern} or @code{static}, @code{__thread} must appear
12886 immediately after the other storage class specifier.
12888 The @code{__thread} specifier may be applied to any global, file-scoped
12889 static, function-scoped static, or static data member of a class.  It may
12890 not be applied to block-scoped automatic or non-static data member.
12892 When the address-of operator is applied to a thread-local variable, it is
12893 evaluated at run-time and returns the address of the current thread's
12894 instance of that variable.  An address so obtained may be used by any
12895 thread.  When a thread terminates, any pointers to thread-local variables
12896 in that thread become invalid.
12898 No static initialization may refer to the address of a thread-local variable.
12900 In C++, if an initializer is present for a thread-local variable, it must
12901 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
12902 standard.
12904 See @uref{http://people.redhat.com/drepper/tls.pdf,
12905 ELF Handling For Thread-Local Storage} for a detailed explanation of
12906 the four thread-local storage addressing models, and how the run-time
12907 is expected to function.
12909 @menu
12910 * C99 Thread-Local Edits::
12911 * C++98 Thread-Local Edits::
12912 @end menu
12914 @node C99 Thread-Local Edits
12915 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
12917 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
12918 that document the exact semantics of the language extension.
12920 @itemize @bullet
12921 @item
12922 @cite{5.1.2  Execution environments}
12924 Add new text after paragraph 1
12926 @quotation
12927 Within either execution environment, a @dfn{thread} is a flow of
12928 control within a program.  It is implementation defined whether
12929 or not there may be more than one thread associated with a program.
12930 It is implementation defined how threads beyond the first are
12931 created, the name and type of the function called at thread
12932 startup, and how threads may be terminated.  However, objects
12933 with thread storage duration shall be initialized before thread
12934 startup.
12935 @end quotation
12937 @item
12938 @cite{6.2.4  Storage durations of objects}
12940 Add new text before paragraph 3
12942 @quotation
12943 An object whose identifier is declared with the storage-class
12944 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
12945 Its lifetime is the entire execution of the thread, and its
12946 stored value is initialized only once, prior to thread startup.
12947 @end quotation
12949 @item
12950 @cite{6.4.1  Keywords}
12952 Add @code{__thread}.
12954 @item
12955 @cite{6.7.1  Storage-class specifiers}
12957 Add @code{__thread} to the list of storage class specifiers in
12958 paragraph 1.
12960 Change paragraph 2 to
12962 @quotation
12963 With the exception of @code{__thread}, at most one storage-class
12964 specifier may be given [@dots{}].  The @code{__thread} specifier may
12965 be used alone, or immediately following @code{extern} or
12966 @code{static}.
12967 @end quotation
12969 Add new text after paragraph 6
12971 @quotation
12972 The declaration of an identifier for a variable that has
12973 block scope that specifies @code{__thread} shall also
12974 specify either @code{extern} or @code{static}.
12976 The @code{__thread} specifier shall be used only with
12977 variables.
12978 @end quotation
12979 @end itemize
12981 @node C++98 Thread-Local Edits
12982 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
12984 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
12985 that document the exact semantics of the language extension.
12987 @itemize @bullet
12988 @item
12989 @b{[intro.execution]}
12991 New text after paragraph 4
12993 @quotation
12994 A @dfn{thread} is a flow of control within the abstract machine.
12995 It is implementation defined whether or not there may be more than
12996 one thread.
12997 @end quotation
12999 New text after paragraph 7
13001 @quotation
13002 It is unspecified whether additional action must be taken to
13003 ensure when and whether side effects are visible to other threads.
13004 @end quotation
13006 @item
13007 @b{[lex.key]}
13009 Add @code{__thread}.
13011 @item
13012 @b{[basic.start.main]}
13014 Add after paragraph 5
13016 @quotation
13017 The thread that begins execution at the @code{main} function is called
13018 the @dfn{main thread}.  It is implementation defined how functions
13019 beginning threads other than the main thread are designated or typed.
13020 A function so designated, as well as the @code{main} function, is called
13021 a @dfn{thread startup function}.  It is implementation defined what
13022 happens if a thread startup function returns.  It is implementation
13023 defined what happens to other threads when any thread calls @code{exit}.
13024 @end quotation
13026 @item
13027 @b{[basic.start.init]}
13029 Add after paragraph 4
13031 @quotation
13032 The storage for an object of thread storage duration shall be
13033 statically initialized before the first statement of the thread startup
13034 function.  An object of thread storage duration shall not require
13035 dynamic initialization.
13036 @end quotation
13038 @item
13039 @b{[basic.start.term]}
13041 Add after paragraph 3
13043 @quotation
13044 The type of an object with thread storage duration shall not have a
13045 non-trivial destructor, nor shall it be an array type whose elements
13046 (directly or indirectly) have non-trivial destructors.
13047 @end quotation
13049 @item
13050 @b{[basic.stc]}
13052 Add ``thread storage duration'' to the list in paragraph 1.
13054 Change paragraph 2
13056 @quotation
13057 Thread, static, and automatic storage durations are associated with
13058 objects introduced by declarations [@dots{}].
13059 @end quotation
13061 Add @code{__thread} to the list of specifiers in paragraph 3.
13063 @item
13064 @b{[basic.stc.thread]}
13066 New section before @b{[basic.stc.static]}
13068 @quotation
13069 The keyword @code{__thread} applied to a non-local object gives the
13070 object thread storage duration.
13072 A local variable or class data member declared both @code{static}
13073 and @code{__thread} gives the variable or member thread storage
13074 duration.
13075 @end quotation
13077 @item
13078 @b{[basic.stc.static]}
13080 Change paragraph 1
13082 @quotation
13083 All objects which have neither thread storage duration, dynamic
13084 storage duration nor are local [@dots{}].
13085 @end quotation
13087 @item
13088 @b{[dcl.stc]}
13090 Add @code{__thread} to the list in paragraph 1.
13092 Change paragraph 1
13094 @quotation
13095 With the exception of @code{__thread}, at most one
13096 @var{storage-class-specifier} shall appear in a given
13097 @var{decl-specifier-seq}.  The @code{__thread} specifier may
13098 be used alone, or immediately following the @code{extern} or
13099 @code{static} specifiers.  [@dots{}]
13100 @end quotation
13102 Add after paragraph 5
13104 @quotation
13105 The @code{__thread} specifier can be applied only to the names of objects
13106 and to anonymous unions.
13107 @end quotation
13109 @item
13110 @b{[class.mem]}
13112 Add after paragraph 6
13114 @quotation
13115 Non-@code{static} members shall not be @code{__thread}.
13116 @end quotation
13117 @end itemize
13119 @node Binary constants
13120 @section Binary constants using the @samp{0b} prefix
13121 @cindex Binary constants using the @samp{0b} prefix
13123 Integer constants can be written as binary constants, consisting of a
13124 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
13125 @samp{0B}.  This is particularly useful in environments that operate a
13126 lot on the bit-level (like microcontrollers).
13128 The following statements are identical:
13130 @smallexample
13131 i =       42;
13132 i =     0x2a;
13133 i =      052;
13134 i = 0b101010;
13135 @end smallexample
13137 The type of these constants follows the same rules as for octal or
13138 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
13139 can be applied.
13141 @node C++ Extensions
13142 @chapter Extensions to the C++ Language
13143 @cindex extensions, C++ language
13144 @cindex C++ language extensions
13146 The GNU compiler provides these extensions to the C++ language (and you
13147 can also use most of the C language extensions in your C++ programs).  If you
13148 want to write code that checks whether these features are available, you can
13149 test for the GNU compiler the same way as for C programs: check for a
13150 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
13151 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
13152 Predefined Macros,cpp,The GNU C Preprocessor}).
13154 @menu
13155 * Volatiles::           What constitutes an access to a volatile object.
13156 * Restricted Pointers:: C99 restricted pointers and references.
13157 * Vague Linkage::       Where G++ puts inlines, vtables and such.
13158 * C++ Interface::       You can use a single C++ header file for both
13159                         declarations and definitions.
13160 * Template Instantiation:: Methods for ensuring that exactly one copy of
13161                         each needed template instantiation is emitted.
13162 * Bound member functions:: You can extract a function pointer to the
13163                         method denoted by a @samp{->*} or @samp{.*} expression.
13164 * C++ Attributes::      Variable, function, and type attributes for C++ only.
13165 * Namespace Association:: Strong using-directives for namespace association.
13166 * Type Traits::         Compiler support for type traits
13167 * Java Exceptions::     Tweaking exception handling to work with Java.
13168 * Deprecated Features:: Things will disappear from g++.
13169 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
13170 @end menu
13172 @node Volatiles
13173 @section When is a Volatile Object Accessed?
13174 @cindex accessing volatiles
13175 @cindex volatile read
13176 @cindex volatile write
13177 @cindex volatile access
13179 Both the C and C++ standard have the concept of volatile objects.  These
13180 are normally accessed by pointers and used for accessing hardware.  The
13181 standards encourage compilers to refrain from optimizations concerning
13182 accesses to volatile objects.  The C standard leaves it implementation
13183 defined  as to what constitutes a volatile access.  The C++ standard omits
13184 to specify this, except to say that C++ should behave in a similar manner
13185 to C with respect to volatiles, where possible.  The minimum either
13186 standard specifies is that at a sequence point all previous accesses to
13187 volatile objects have stabilized and no subsequent accesses have
13188 occurred.  Thus an implementation is free to reorder and combine
13189 volatile accesses which occur between sequence points, but cannot do so
13190 for accesses across a sequence point.  The use of volatiles does not
13191 allow you to violate the restriction on updating objects multiple times
13192 within a sequence point.
13194 @xref{Qualifiers implementation, , Volatile qualifier and the C compiler}.
13196 The behavior differs slightly between C and C++ in the non-obvious cases:
13198 @smallexample
13199 volatile int *src = @var{somevalue};
13200 *src;
13201 @end smallexample
13203 With C, such expressions are rvalues, and GCC interprets this either as a
13204 read of the volatile object being pointed to or only as request to evaluate
13205 the side-effects.  The C++ standard specifies that such expressions do not
13206 undergo lvalue to rvalue conversion, and that the type of the dereferenced
13207 object may be incomplete.  The C++ standard does not specify explicitly
13208 that it is this lvalue to rvalue conversion which may be responsible for
13209 causing an access.  However, there is reason to believe that it is,
13210 because otherwise certain simple expressions become undefined.  However,
13211 because it would surprise most programmers, G++ treats dereferencing a
13212 pointer to volatile object of complete type when the value is unused as
13213 GCC would do for an equivalent type in C@.  When the object has incomplete
13214 type, G++ issues a warning; if you wish to force an error, you must
13215 force a conversion to rvalue with, for instance, a static cast.
13217 When using a reference to volatile, G++ does not treat equivalent
13218 expressions as accesses to volatiles, but instead issues a warning that
13219 no volatile is accessed.  The rationale for this is that otherwise it
13220 becomes difficult to determine where volatile access occur, and not
13221 possible to ignore the return value from functions returning volatile
13222 references.  Again, if you wish to force a read, cast the reference to
13223 an rvalue.
13225 @node Restricted Pointers
13226 @section Restricting Pointer Aliasing
13227 @cindex restricted pointers
13228 @cindex restricted references
13229 @cindex restricted this pointer
13231 As with the C front end, G++ understands the C99 feature of restricted pointers,
13232 specified with the @code{__restrict__}, or @code{__restrict} type
13233 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
13234 language flag, @code{restrict} is not a keyword in C++.
13236 In addition to allowing restricted pointers, you can specify restricted
13237 references, which indicate that the reference is not aliased in the local
13238 context.
13240 @smallexample
13241 void fn (int *__restrict__ rptr, int &__restrict__ rref)
13243   /* @r{@dots{}} */
13245 @end smallexample
13247 @noindent
13248 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
13249 @var{rref} refers to a (different) unaliased integer.
13251 You may also specify whether a member function's @var{this} pointer is
13252 unaliased by using @code{__restrict__} as a member function qualifier.
13254 @smallexample
13255 void T::fn () __restrict__
13257   /* @r{@dots{}} */
13259 @end smallexample
13261 @noindent
13262 Within the body of @code{T::fn}, @var{this} will have the effective
13263 definition @code{T *__restrict__ const this}.  Notice that the
13264 interpretation of a @code{__restrict__} member function qualifier is
13265 different to that of @code{const} or @code{volatile} qualifier, in that it
13266 is applied to the pointer rather than the object.  This is consistent with
13267 other compilers which implement restricted pointers.
13269 As with all outermost parameter qualifiers, @code{__restrict__} is
13270 ignored in function definition matching.  This means you only need to
13271 specify @code{__restrict__} in a function definition, rather than
13272 in a function prototype as well.
13274 @node Vague Linkage
13275 @section Vague Linkage
13276 @cindex vague linkage
13278 There are several constructs in C++ which require space in the object
13279 file but are not clearly tied to a single translation unit.  We say that
13280 these constructs have ``vague linkage''.  Typically such constructs are
13281 emitted wherever they are needed, though sometimes we can be more
13282 clever.
13284 @table @asis
13285 @item Inline Functions
13286 Inline functions are typically defined in a header file which can be
13287 included in many different compilations.  Hopefully they can usually be
13288 inlined, but sometimes an out-of-line copy is necessary, if the address
13289 of the function is taken or if inlining fails.  In general, we emit an
13290 out-of-line copy in all translation units where one is needed.  As an
13291 exception, we only emit inline virtual functions with the vtable, since
13292 it will always require a copy.
13294 Local static variables and string constants used in an inline function
13295 are also considered to have vague linkage, since they must be shared
13296 between all inlined and out-of-line instances of the function.
13298 @item VTables
13299 @cindex vtable
13300 C++ virtual functions are implemented in most compilers using a lookup
13301 table, known as a vtable.  The vtable contains pointers to the virtual
13302 functions provided by a class, and each object of the class contains a
13303 pointer to its vtable (or vtables, in some multiple-inheritance
13304 situations).  If the class declares any non-inline, non-pure virtual
13305 functions, the first one is chosen as the ``key method'' for the class,
13306 and the vtable is only emitted in the translation unit where the key
13307 method is defined.
13309 @emph{Note:} If the chosen key method is later defined as inline, the
13310 vtable will still be emitted in every translation unit which defines it.
13311 Make sure that any inline virtuals are declared inline in the class
13312 body, even if they are not defined there.
13314 @item type_info objects
13315 @cindex type_info
13316 @cindex RTTI
13317 C++ requires information about types to be written out in order to
13318 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
13319 For polymorphic classes (classes with virtual functions), the type_info
13320 object is written out along with the vtable so that @samp{dynamic_cast}
13321 can determine the dynamic type of a class object at runtime.  For all
13322 other types, we write out the type_info object when it is used: when
13323 applying @samp{typeid} to an expression, throwing an object, or
13324 referring to a type in a catch clause or exception specification.
13326 @item Template Instantiations
13327 Most everything in this section also applies to template instantiations,
13328 but there are other options as well.
13329 @xref{Template Instantiation,,Where's the Template?}.
13331 @end table
13333 When used with GNU ld version 2.8 or later on an ELF system such as
13334 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
13335 these constructs will be discarded at link time.  This is known as
13336 COMDAT support.
13338 On targets that don't support COMDAT, but do support weak symbols, GCC
13339 will use them.  This way one copy will override all the others, but
13340 the unused copies will still take up space in the executable.
13342 For targets which do not support either COMDAT or weak symbols,
13343 most entities with vague linkage will be emitted as local symbols to
13344 avoid duplicate definition errors from the linker.  This will not happen
13345 for local statics in inlines, however, as having multiple copies will
13346 almost certainly break things.
13348 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
13349 another way to control placement of these constructs.
13351 @node C++ Interface
13352 @section #pragma interface and implementation
13354 @cindex interface and implementation headers, C++
13355 @cindex C++ interface and implementation headers
13356 @cindex pragmas, interface and implementation
13358 @code{#pragma interface} and @code{#pragma implementation} provide the
13359 user with a way of explicitly directing the compiler to emit entities
13360 with vague linkage (and debugging information) in a particular
13361 translation unit.
13363 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
13364 most cases, because of COMDAT support and the ``key method'' heuristic
13365 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
13366 program to grow due to unnecessary out-of-line copies of inline
13367 functions.  Currently (3.4) the only benefit of these
13368 @code{#pragma}s is reduced duplication of debugging information, and
13369 that should be addressed soon on DWARF 2 targets with the use of
13370 COMDAT groups.
13372 @table @code
13373 @item #pragma interface
13374 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
13375 @kindex #pragma interface
13376 Use this directive in @emph{header files} that define object classes, to save
13377 space in most of the object files that use those classes.  Normally,
13378 local copies of certain information (backup copies of inline member
13379 functions, debugging information, and the internal tables that implement
13380 virtual functions) must be kept in each object file that includes class
13381 definitions.  You can use this pragma to avoid such duplication.  When a
13382 header file containing @samp{#pragma interface} is included in a
13383 compilation, this auxiliary information will not be generated (unless
13384 the main input source file itself uses @samp{#pragma implementation}).
13385 Instead, the object files will contain references to be resolved at link
13386 time.
13388 The second form of this directive is useful for the case where you have
13389 multiple headers with the same name in different directories.  If you
13390 use this form, you must specify the same string to @samp{#pragma
13391 implementation}.
13393 @item #pragma implementation
13394 @itemx #pragma implementation "@var{objects}.h"
13395 @kindex #pragma implementation
13396 Use this pragma in a @emph{main input file}, when you want full output from
13397 included header files to be generated (and made globally visible).  The
13398 included header file, in turn, should use @samp{#pragma interface}.
13399 Backup copies of inline member functions, debugging information, and the
13400 internal tables used to implement virtual functions are all generated in
13401 implementation files.
13403 @cindex implied @code{#pragma implementation}
13404 @cindex @code{#pragma implementation}, implied
13405 @cindex naming convention, implementation headers
13406 If you use @samp{#pragma implementation} with no argument, it applies to
13407 an include file with the same basename@footnote{A file's @dfn{basename}
13408 was the name stripped of all leading path information and of trailing
13409 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
13410 file.  For example, in @file{allclass.cc}, giving just
13411 @samp{#pragma implementation}
13412 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
13414 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
13415 an implementation file whenever you would include it from
13416 @file{allclass.cc} even if you never specified @samp{#pragma
13417 implementation}.  This was deemed to be more trouble than it was worth,
13418 however, and disabled.
13420 Use the string argument if you want a single implementation file to
13421 include code from multiple header files.  (You must also use
13422 @samp{#include} to include the header file; @samp{#pragma
13423 implementation} only specifies how to use the file---it doesn't actually
13424 include it.)
13426 There is no way to split up the contents of a single header file into
13427 multiple implementation files.
13428 @end table
13430 @cindex inlining and C++ pragmas
13431 @cindex C++ pragmas, effect on inlining
13432 @cindex pragmas in C++, effect on inlining
13433 @samp{#pragma implementation} and @samp{#pragma interface} also have an
13434 effect on function inlining.
13436 If you define a class in a header file marked with @samp{#pragma
13437 interface}, the effect on an inline function defined in that class is
13438 similar to an explicit @code{extern} declaration---the compiler emits
13439 no code at all to define an independent version of the function.  Its
13440 definition is used only for inlining with its callers.
13442 @opindex fno-implement-inlines
13443 Conversely, when you include the same header file in a main source file
13444 that declares it as @samp{#pragma implementation}, the compiler emits
13445 code for the function itself; this defines a version of the function
13446 that can be found via pointers (or by callers compiled without
13447 inlining).  If all calls to the function can be inlined, you can avoid
13448 emitting the function by compiling with @option{-fno-implement-inlines}.
13449 If any calls were not inlined, you will get linker errors.
13451 @node Template Instantiation
13452 @section Where's the Template?
13453 @cindex template instantiation
13455 C++ templates are the first language feature to require more
13456 intelligence from the environment than one usually finds on a UNIX
13457 system.  Somehow the compiler and linker have to make sure that each
13458 template instance occurs exactly once in the executable if it is needed,
13459 and not at all otherwise.  There are two basic approaches to this
13460 problem, which are referred to as the Borland model and the Cfront model.
13462 @table @asis
13463 @item Borland model
13464 Borland C++ solved the template instantiation problem by adding the code
13465 equivalent of common blocks to their linker; the compiler emits template
13466 instances in each translation unit that uses them, and the linker
13467 collapses them together.  The advantage of this model is that the linker
13468 only has to consider the object files themselves; there is no external
13469 complexity to worry about.  This disadvantage is that compilation time
13470 is increased because the template code is being compiled repeatedly.
13471 Code written for this model tends to include definitions of all
13472 templates in the header file, since they must be seen to be
13473 instantiated.
13475 @item Cfront model
13476 The AT&T C++ translator, Cfront, solved the template instantiation
13477 problem by creating the notion of a template repository, an
13478 automatically maintained place where template instances are stored.  A
13479 more modern version of the repository works as follows: As individual
13480 object files are built, the compiler places any template definitions and
13481 instantiations encountered in the repository.  At link time, the link
13482 wrapper adds in the objects in the repository and compiles any needed
13483 instances that were not previously emitted.  The advantages of this
13484 model are more optimal compilation speed and the ability to use the
13485 system linker; to implement the Borland model a compiler vendor also
13486 needs to replace the linker.  The disadvantages are vastly increased
13487 complexity, and thus potential for error; for some code this can be
13488 just as transparent, but in practice it can been very difficult to build
13489 multiple programs in one directory and one program in multiple
13490 directories.  Code written for this model tends to separate definitions
13491 of non-inline member templates into a separate file, which should be
13492 compiled separately.
13493 @end table
13495 When used with GNU ld version 2.8 or later on an ELF system such as
13496 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
13497 Borland model.  On other systems, G++ implements neither automatic
13498 model.
13500 A future version of G++ will support a hybrid model whereby the compiler
13501 will emit any instantiations for which the template definition is
13502 included in the compile, and store template definitions and
13503 instantiation context information into the object file for the rest.
13504 The link wrapper will extract that information as necessary and invoke
13505 the compiler to produce the remaining instantiations.  The linker will
13506 then combine duplicate instantiations.
13508 In the mean time, you have the following options for dealing with
13509 template instantiations:
13511 @enumerate
13512 @item
13513 @opindex frepo
13514 Compile your template-using code with @option{-frepo}.  The compiler will
13515 generate files with the extension @samp{.rpo} listing all of the
13516 template instantiations used in the corresponding object files which
13517 could be instantiated there; the link wrapper, @samp{collect2}, will
13518 then update the @samp{.rpo} files to tell the compiler where to place
13519 those instantiations and rebuild any affected object files.  The
13520 link-time overhead is negligible after the first pass, as the compiler
13521 will continue to place the instantiations in the same files.
13523 This is your best option for application code written for the Borland
13524 model, as it will just work.  Code written for the Cfront model will
13525 need to be modified so that the template definitions are available at
13526 one or more points of instantiation; usually this is as simple as adding
13527 @code{#include <tmethods.cc>} to the end of each template header.
13529 For library code, if you want the library to provide all of the template
13530 instantiations it needs, just try to link all of its object files
13531 together; the link will fail, but cause the instantiations to be
13532 generated as a side effect.  Be warned, however, that this may cause
13533 conflicts if multiple libraries try to provide the same instantiations.
13534 For greater control, use explicit instantiation as described in the next
13535 option.
13537 @item
13538 @opindex fno-implicit-templates
13539 Compile your code with @option{-fno-implicit-templates} to disable the
13540 implicit generation of template instances, and explicitly instantiate
13541 all the ones you use.  This approach requires more knowledge of exactly
13542 which instances you need than do the others, but it's less
13543 mysterious and allows greater control.  You can scatter the explicit
13544 instantiations throughout your program, perhaps putting them in the
13545 translation units where the instances are used or the translation units
13546 that define the templates themselves; you can put all of the explicit
13547 instantiations you need into one big file; or you can create small files
13548 like
13550 @smallexample
13551 #include "Foo.h"
13552 #include "Foo.cc"
13554 template class Foo<int>;
13555 template ostream& operator <<
13556                 (ostream&, const Foo<int>&);
13557 @end smallexample
13559 for each of the instances you need, and create a template instantiation
13560 library from those.
13562 If you are using Cfront-model code, you can probably get away with not
13563 using @option{-fno-implicit-templates} when compiling files that don't
13564 @samp{#include} the member template definitions.
13566 If you use one big file to do the instantiations, you may want to
13567 compile it without @option{-fno-implicit-templates} so you get all of the
13568 instances required by your explicit instantiations (but not by any
13569 other files) without having to specify them as well.
13571 G++ has extended the template instantiation syntax given in the ISO
13572 standard to allow forward declaration of explicit instantiations
13573 (with @code{extern}), instantiation of the compiler support data for a
13574 template class (i.e.@: the vtable) without instantiating any of its
13575 members (with @code{inline}), and instantiation of only the static data
13576 members of a template class, without the support data or member
13577 functions (with (@code{static}):
13579 @smallexample
13580 extern template int max (int, int);
13581 inline template class Foo<int>;
13582 static template class Foo<int>;
13583 @end smallexample
13585 @item
13586 Do nothing.  Pretend G++ does implement automatic instantiation
13587 management.  Code written for the Borland model will work fine, but
13588 each translation unit will contain instances of each of the templates it
13589 uses.  In a large program, this can lead to an unacceptable amount of code
13590 duplication.
13591 @end enumerate
13593 @node Bound member functions
13594 @section Extracting the function pointer from a bound pointer to member function
13595 @cindex pmf
13596 @cindex pointer to member function
13597 @cindex bound pointer to member function
13599 In C++, pointer to member functions (PMFs) are implemented using a wide
13600 pointer of sorts to handle all the possible call mechanisms; the PMF
13601 needs to store information about how to adjust the @samp{this} pointer,
13602 and if the function pointed to is virtual, where to find the vtable, and
13603 where in the vtable to look for the member function.  If you are using
13604 PMFs in an inner loop, you should really reconsider that decision.  If
13605 that is not an option, you can extract the pointer to the function that
13606 would be called for a given object/PMF pair and call it directly inside
13607 the inner loop, to save a bit of time.
13609 Note that you will still be paying the penalty for the call through a
13610 function pointer; on most modern architectures, such a call defeats the
13611 branch prediction features of the CPU@.  This is also true of normal
13612 virtual function calls.
13614 The syntax for this extension is
13616 @smallexample
13617 extern A a;
13618 extern int (A::*fp)();
13619 typedef int (*fptr)(A *);
13621 fptr p = (fptr)(a.*fp);
13622 @end smallexample
13624 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
13625 no object is needed to obtain the address of the function.  They can be
13626 converted to function pointers directly:
13628 @smallexample
13629 fptr p1 = (fptr)(&A::foo);
13630 @end smallexample
13632 @opindex Wno-pmf-conversions
13633 You must specify @option{-Wno-pmf-conversions} to use this extension.
13635 @node C++ Attributes
13636 @section C++-Specific Variable, Function, and Type Attributes
13638 Some attributes only make sense for C++ programs.
13640 @table @code
13641 @item init_priority (@var{priority})
13642 @cindex init_priority attribute
13645 In Standard C++, objects defined at namespace scope are guaranteed to be
13646 initialized in an order in strict accordance with that of their definitions
13647 @emph{in a given translation unit}.  No guarantee is made for initializations
13648 across translation units.  However, GNU C++ allows users to control the
13649 order of initialization of objects defined at namespace scope with the
13650 @code{init_priority} attribute by specifying a relative @var{priority},
13651 a constant integral expression currently bounded between 101 and 65535
13652 inclusive.  Lower numbers indicate a higher priority.
13654 In the following example, @code{A} would normally be created before
13655 @code{B}, but the @code{init_priority} attribute has reversed that order:
13657 @smallexample
13658 Some_Class  A  __attribute__ ((init_priority (2000)));
13659 Some_Class  B  __attribute__ ((init_priority (543)));
13660 @end smallexample
13662 @noindent
13663 Note that the particular values of @var{priority} do not matter; only their
13664 relative ordering.
13666 @item java_interface
13667 @cindex java_interface attribute
13669 This type attribute informs C++ that the class is a Java interface.  It may
13670 only be applied to classes declared within an @code{extern "Java"} block.
13671 Calls to methods declared in this interface will be dispatched using GCJ's
13672 interface table mechanism, instead of regular virtual table dispatch.
13674 @end table
13676 See also @ref{Namespace Association}.
13678 @node Namespace Association
13679 @section Namespace Association
13681 @strong{Caution:} The semantics of this extension are not fully
13682 defined.  Users should refrain from using this extension as its
13683 semantics may change subtly over time.  It is possible that this
13684 extension will be removed in future versions of G++.
13686 A using-directive with @code{__attribute ((strong))} is stronger
13687 than a normal using-directive in two ways:
13689 @itemize @bullet
13690 @item
13691 Templates from the used namespace can be specialized and explicitly
13692 instantiated as though they were members of the using namespace.
13694 @item
13695 The using namespace is considered an associated namespace of all
13696 templates in the used namespace for purposes of argument-dependent
13697 name lookup.
13698 @end itemize
13700 The used namespace must be nested within the using namespace so that
13701 normal unqualified lookup works properly.
13703 This is useful for composing a namespace transparently from
13704 implementation namespaces.  For example:
13706 @smallexample
13707 namespace std @{
13708   namespace debug @{
13709     template <class T> struct A @{ @};
13710   @}
13711   using namespace debug __attribute ((__strong__));
13712   template <> struct A<int> @{ @};   // @r{ok to specialize}
13714   template <class T> void f (A<T>);
13717 int main()
13719   f (std::A<float>());             // @r{lookup finds} std::f
13720   f (std::A<int>());
13722 @end smallexample
13724 @node Type Traits
13725 @section Type Traits
13727 The C++ front-end implements syntactic extensions that allow to
13728 determine at compile time various characteristics of a type (or of a
13729 pair of types).
13731 @table @code
13732 @item __has_nothrow_assign (type)
13733 If @code{type} is const qualified or is a reference type then the trait is
13734 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
13735 is true, else if @code{type} is a cv class or union type with copy assignment
13736 operators that are known not to throw an exception then the trait is true,
13737 else it is false.  Requires: @code{type} shall be a complete type, an array
13738 type of unknown bound, or is a @code{void} type.
13740 @item __has_nothrow_copy (type)
13741 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
13742 @code{type} is a cv class or union type with copy constructors that
13743 are known not to throw an exception then the trait is true, else it is false.
13744 Requires: @code{type} shall be a complete type, an array type of
13745 unknown bound, or is a @code{void} type.
13747 @item __has_nothrow_constructor (type)
13748 If @code{__has_trivial_constructor (type)} is true then the trait is
13749 true, else if @code{type} is a cv class or union type (or array
13750 thereof) with a default constructor that is known not to throw an
13751 exception then the trait is true, else it is false.  Requires:
13752 @code{type} shall be a complete type, an array type of unknown bound,
13753 or is a @code{void} type.
13755 @item __has_trivial_assign (type)
13756 If @code{type} is const qualified or is a reference type then the trait is
13757 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
13758 true, else if @code{type} is a cv class or union type with a trivial
13759 copy assignment ([class.copy]) then the trait is true, else it is
13760 false.  Requires: @code{type} shall be a complete type, an array type
13761 of unknown bound, or is a @code{void} type.
13763 @item __has_trivial_copy (type)
13764 If @code{__is_pod (type)} is true or @code{type} is a reference type 
13765 then the trait is true, else if @code{type} is a cv class or union type
13766 with a trivial copy constructor ([class.copy]) then the trait
13767 is true, else it is false.  Requires: @code{type} shall be a complete
13768 type, an array type of unknown bound, or is a @code{void} type.
13770 @item __has_trivial_constructor (type)
13771 If @code{__is_pod (type)} is true then the trait is true, else if
13772 @code{type} is a cv class or union type (or array thereof) with a
13773 trivial default constructor ([class.ctor]) then the trait is true,
13774 else it is false.  Requires: @code{type} shall be a complete type, an
13775 array type of unknown bound, or is a @code{void} type.
13777 @item __has_trivial_destructor (type)
13778 If @code{__is_pod (type)} is true or @code{type} is a reference type then
13779 the trait is true, else if @code{type} is a cv class or union type (or
13780 array thereof) with a trivial destructor ([class.dtor]) then the trait
13781 is true, else it is false.  Requires: @code{type} shall be a complete
13782 type, an array type of unknown bound, or is a @code{void} type.
13784 @item __has_virtual_destructor (type)
13785 If @code{type} is a class type with a virtual destructor
13786 ([class.dtor]) then the trait is true, else it is false.  Requires:
13787 @code{type}  shall be a complete type, an array type of unknown bound,
13788 or is a @code{void} type.
13790 @item __is_abstract (type)
13791 If @code{type} is an abstract class ([class.abstract]) then the trait
13792 is true, else it is false.  Requires: @code{type} shall be a complete
13793 type, an array type of unknown bound, or is a @code{void} type.
13795 @item __is_base_of (base_type, derived_type)
13796 If @code{base_type} is a base class of @code{derived_type}
13797 ([class.derived]) then the trait is true, otherwise it is false.
13798 Top-level cv qualifications of @code{base_type} and
13799 @code{derived_type} are ignored.  For the purposes of this trait, a
13800 class type is considered is own base.  Requires: if @code{__is_class
13801 (base_type)} and @code{__is_class (derived_type)} are true and
13802 @code{base_type} and @code{derived_type} are not the same type
13803 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
13804 type.  Diagnostic is produced if this requirement is not met.
13806 @item __is_class (type)
13807 If @code{type} is a cv class type, and not a union type
13808 ([basic.compound]) the trait is true, else it is false.
13810 @item __is_empty (type)
13811 If @code{__is_class (type)} is false then the trait is false.
13812 Otherwise @code{type} is considered empty if and only if: @code{type}
13813 has no non-static data members, or all non-static data members, if
13814 any, are bit-fields of length 0, and @code{type} has no virtual
13815 members, and @code{type} has no virtual base classes, and @code{type}
13816 has no base classes @code{base_type} for which 
13817 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
13818 be a complete type, an array type of unknown bound, or is a
13819 @code{void} type.
13821 @item __is_enum (type)
13822 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
13823 true, else it is false.
13825 @item __is_pod (type)
13826 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
13827 else it is false.  Requires: @code{type} shall be a complete type, 
13828 an array type of unknown bound, or is a @code{void} type.
13830 @item __is_polymorphic (type)
13831 If @code{type} is a polymorphic class ([class.virtual]) then the trait
13832 is true, else it is false.  Requires: @code{type} shall be a complete
13833 type, an array type of unknown bound, or is a @code{void} type.
13835 @item __is_union (type)
13836 If @code{type} is a cv union type ([basic.compound]) the trait is
13837 true, else it is false.
13839 @end table
13841 @node Java Exceptions
13842 @section Java Exceptions
13844 The Java language uses a slightly different exception handling model
13845 from C++.  Normally, GNU C++ will automatically detect when you are
13846 writing C++ code that uses Java exceptions, and handle them
13847 appropriately.  However, if C++ code only needs to execute destructors
13848 when Java exceptions are thrown through it, GCC will guess incorrectly.
13849 Sample problematic code is:
13851 @smallexample
13852   struct S @{ ~S(); @};
13853   extern void bar();    // @r{is written in Java, and may throw exceptions}
13854   void foo()
13855   @{
13856     S s;
13857     bar();
13858   @}
13859 @end smallexample
13861 @noindent
13862 The usual effect of an incorrect guess is a link failure, complaining of
13863 a missing routine called @samp{__gxx_personality_v0}.
13865 You can inform the compiler that Java exceptions are to be used in a
13866 translation unit, irrespective of what it might think, by writing
13867 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
13868 @samp{#pragma} must appear before any functions that throw or catch
13869 exceptions, or run destructors when exceptions are thrown through them.
13871 You cannot mix Java and C++ exceptions in the same translation unit.  It
13872 is believed to be safe to throw a C++ exception from one file through
13873 another file compiled for the Java exception model, or vice versa, but
13874 there may be bugs in this area.
13876 @node Deprecated Features
13877 @section Deprecated Features
13879 In the past, the GNU C++ compiler was extended to experiment with new
13880 features, at a time when the C++ language was still evolving.  Now that
13881 the C++ standard is complete, some of those features are superseded by
13882 superior alternatives.  Using the old features might cause a warning in
13883 some cases that the feature will be dropped in the future.  In other
13884 cases, the feature might be gone already.
13886 While the list below is not exhaustive, it documents some of the options
13887 that are now deprecated:
13889 @table @code
13890 @item -fexternal-templates
13891 @itemx -falt-external-templates
13892 These are two of the many ways for G++ to implement template
13893 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
13894 defines how template definitions have to be organized across
13895 implementation units.  G++ has an implicit instantiation mechanism that
13896 should work just fine for standard-conforming code.
13898 @item -fstrict-prototype
13899 @itemx -fno-strict-prototype
13900 Previously it was possible to use an empty prototype parameter list to
13901 indicate an unspecified number of parameters (like C), rather than no
13902 parameters, as C++ demands.  This feature has been removed, except where
13903 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
13904 @end table
13906 G++ allows a virtual function returning @samp{void *} to be overridden
13907 by one returning a different pointer type.  This extension to the
13908 covariant return type rules is now deprecated and will be removed from a
13909 future version.
13911 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
13912 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
13913 and are now removed from G++.  Code using these operators should be
13914 modified to use @code{std::min} and @code{std::max} instead.
13916 The named return value extension has been deprecated, and is now
13917 removed from G++.
13919 The use of initializer lists with new expressions has been deprecated,
13920 and is now removed from G++.
13922 Floating and complex non-type template parameters have been deprecated,
13923 and are now removed from G++.
13925 The implicit typename extension has been deprecated and is now
13926 removed from G++.
13928 The use of default arguments in function pointers, function typedefs
13929 and other places where they are not permitted by the standard is
13930 deprecated and will be removed from a future version of G++.
13932 G++ allows floating-point literals to appear in integral constant expressions,
13933 e.g. @samp{ enum E @{ e = int(2.2 * 3.7) @} }
13934 This extension is deprecated and will be removed from a future version.
13936 G++ allows static data members of const floating-point type to be declared
13937 with an initializer in a class definition. The standard only allows
13938 initializers for static members of const integral types and const
13939 enumeration types so this extension has been deprecated and will be removed
13940 from a future version.
13942 @node Backwards Compatibility
13943 @section Backwards Compatibility
13944 @cindex Backwards Compatibility
13945 @cindex ARM [Annotated C++ Reference Manual]
13947 Now that there is a definitive ISO standard C++, G++ has a specification
13948 to adhere to.  The C++ language evolved over time, and features that
13949 used to be acceptable in previous drafts of the standard, such as the ARM
13950 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
13951 compilation of C++ written to such drafts, G++ contains some backwards
13952 compatibilities.  @emph{All such backwards compatibility features are
13953 liable to disappear in future versions of G++.} They should be considered
13954 deprecated.   @xref{Deprecated Features}.
13956 @table @code
13957 @item For scope
13958 If a variable is declared at for scope, it used to remain in scope until
13959 the end of the scope which contained the for statement (rather than just
13960 within the for scope).  G++ retains this, but issues a warning, if such a
13961 variable is accessed outside the for scope.
13963 @item Implicit C language
13964 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
13965 scope to set the language.  On such systems, all header files are
13966 implicitly scoped inside a C language scope.  Also, an empty prototype
13967 @code{()} will be treated as an unspecified number of arguments, rather
13968 than no arguments, as C++ demands.
13969 @end table