Merged with trunk at revision 162480.
[official-gcc.git] / gcc / doc / extend.texi
blob0f64bcdadb0f0dd42749ab779569633517f2fb53
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 ifunc
1967 @cindex @code{ifunc} attribute
1968 The @code{ifunc} attribute only applies to a function definition, which
1969 causes the definition to be emitted as an indirect function.  For
1970 instance,
1972 @smallexample
1973 int f (int) __attribute__ ((ifunc));
1974 @end smallexample
1976 @noindent
1978 defines @samp{f} as an indirect function.  @samp{f} should return a
1979 pointer to the actual function that should be executed as @samp{f}.
1980 @samp{f} is called only by the dynamic linker without any arguments. 
1981 It is an error if @samp{f} is not defined in the same translation unit,
1982 or any parameters are used inside @samp{f}, or the return type isn't
1983 a pointer to @samp{f}.
1985 See @code{STT_GNU_IFUNC} specified in @file{ifunc.txt} at
1986 @uref{http://groups.google.com/group/generic-abi/files}.
1988 Not all targets support this attribute.
1990 @item aligned (@var{alignment})
1991 @cindex @code{aligned} attribute
1992 This attribute specifies a minimum alignment for the function,
1993 measured in bytes.
1995 You cannot use this attribute to decrease the alignment of a function,
1996 only to increase it.  However, when you explicitly specify a function
1997 alignment this will override the effect of the
1998 @option{-falign-functions} (@pxref{Optimize Options}) option for this
1999 function.
2001 Note that the effectiveness of @code{aligned} attributes may be
2002 limited by inherent limitations in your linker.  On many systems, the
2003 linker is only able to arrange for functions to be aligned up to a
2004 certain maximum alignment.  (For some linkers, the maximum supported
2005 alignment may be very very small.)  See your linker documentation for
2006 further information.
2008 The @code{aligned} attribute can also be used for variables and fields
2009 (@pxref{Variable Attributes}.)
2011 @item alloc_size
2012 @cindex @code{alloc_size} attribute
2013 The @code{alloc_size} attribute is used to tell the compiler that the
2014 function return value points to memory, where the size is given by
2015 one or two of the functions parameters.  GCC uses this 
2016 information to improve the correctness of @code{__builtin_object_size}.
2018 The function parameter(s) denoting the allocated size are specified by
2019 one or two integer arguments supplied to the attribute.  The allocated size
2020 is either the value of the single function argument specified or the product
2021 of the two function arguments specified.  Argument numbering starts at
2022 one.
2024 For instance, 
2026 @smallexample
2027 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2028 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2029 @end smallexample
2031 declares that my_calloc will return memory of the size given by
2032 the product of parameter 1 and 2 and that my_realloc will return memory
2033 of the size given by parameter 2.
2035 @item always_inline
2036 @cindex @code{always_inline} function attribute
2037 Generally, functions are not inlined unless optimization is specified.
2038 For functions declared inline, this attribute inlines the function even
2039 if no optimization level was specified.
2041 @item gnu_inline
2042 @cindex @code{gnu_inline} function attribute
2043 This attribute should be used with a function which is also declared
2044 with the @code{inline} keyword.  It directs GCC to treat the function
2045 as if it were defined in gnu90 mode even when compiling in C99 or
2046 gnu99 mode.
2048 If the function is declared @code{extern}, then this definition of the
2049 function is used only for inlining.  In no case is the function
2050 compiled as a standalone function, not even if you take its address
2051 explicitly.  Such an address becomes an external reference, as if you
2052 had only declared the function, and had not defined it.  This has
2053 almost the effect of a macro.  The way to use this is to put a
2054 function definition in a header file with this attribute, and put
2055 another copy of the function, without @code{extern}, in a library
2056 file.  The definition in the header file will cause most calls to the
2057 function to be inlined.  If any uses of the function remain, they will
2058 refer to the single copy in the library.  Note that the two
2059 definitions of the functions need not be precisely the same, although
2060 if they do not have the same effect your program may behave oddly.
2062 In C, if the function is neither @code{extern} nor @code{static}, then
2063 the function is compiled as a standalone function, as well as being
2064 inlined where possible.
2066 This is how GCC traditionally handled functions declared
2067 @code{inline}.  Since ISO C99 specifies a different semantics for
2068 @code{inline}, this function attribute is provided as a transition
2069 measure and as a useful feature in its own right.  This attribute is
2070 available in GCC 4.1.3 and later.  It is available if either of the
2071 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2072 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2073 Function is As Fast As a Macro}.
2075 In C++, this attribute does not depend on @code{extern} in any way,
2076 but it still requires the @code{inline} keyword to enable its special
2077 behavior.
2079 @item artificial
2080 @cindex @code{artificial} function attribute
2081 This attribute is useful for small inline wrappers which if possible
2082 should appear during debugging as a unit, depending on the debug
2083 info format it will either mean marking the function as artificial
2084 or using the caller location for all instructions within the inlined
2085 body.
2087 @item bank_switch
2088 @cindex interrupt handler functions
2089 When added to an interrupt handler with the M32C port, causes the
2090 prologue and epilogue to use bank switching to preserve the registers
2091 rather than saving them on the stack.
2093 @item flatten
2094 @cindex @code{flatten} function attribute
2095 Generally, inlining into a function is limited.  For a function marked with
2096 this attribute, every call inside this function will be inlined, if possible.
2097 Whether the function itself is considered for inlining depends on its size and
2098 the current inlining parameters.
2100 @item error ("@var{message}")
2101 @cindex @code{error} function attribute
2102 If this attribute is used on a function declaration and a call to such a function
2103 is not eliminated through dead code elimination or other optimizations, an error
2104 which will include @var{message} will be diagnosed.  This is useful
2105 for compile time checking, especially together with @code{__builtin_constant_p}
2106 and inline functions where checking the inline function arguments is not
2107 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2108 While it is possible to leave the function undefined and thus invoke
2109 a link failure, when using this attribute the problem will be diagnosed
2110 earlier and with exact location of the call even in presence of inline
2111 functions or when not emitting debugging information.
2113 @item warning ("@var{message}")
2114 @cindex @code{warning} function attribute
2115 If this attribute is used on a function declaration and a call to such a function
2116 is not eliminated through dead code elimination or other optimizations, a warning
2117 which will include @var{message} will be diagnosed.  This is useful
2118 for compile time checking, especially together with @code{__builtin_constant_p}
2119 and inline functions.  While it is possible to define the function with
2120 a message in @code{.gnu.warning*} section, when using this attribute the problem
2121 will be diagnosed earlier and with exact location of the call even in presence
2122 of inline functions or when not emitting debugging information.
2124 @item cdecl
2125 @cindex functions that do pop the argument stack on the 386
2126 @opindex mrtd
2127 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2128 assume that the calling function will pop off the stack space used to
2129 pass arguments.  This is
2130 useful to override the effects of the @option{-mrtd} switch.
2132 @item const
2133 @cindex @code{const} function attribute
2134 Many functions do not examine any values except their arguments, and
2135 have no effects except the return value.  Basically this is just slightly
2136 more strict class than the @code{pure} attribute below, since function is not
2137 allowed to read global memory.
2139 @cindex pointer arguments
2140 Note that a function that has pointer arguments and examines the data
2141 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2142 function that calls a non-@code{const} function usually must not be
2143 @code{const}.  It does not make sense for a @code{const} function to
2144 return @code{void}.
2146 The attribute @code{const} is not implemented in GCC versions earlier
2147 than 2.5.  An alternative way to declare that a function has no side
2148 effects, which works in the current version and in some older versions,
2149 is as follows:
2151 @smallexample
2152 typedef int intfn ();
2154 extern const intfn square;
2155 @end smallexample
2157 This approach does not work in GNU C++ from 2.6.0 on, since the language
2158 specifies that the @samp{const} must be attached to the return value.
2160 @item constructor
2161 @itemx destructor
2162 @itemx constructor (@var{priority})
2163 @itemx destructor (@var{priority})
2164 @cindex @code{constructor} function attribute
2165 @cindex @code{destructor} function attribute
2166 The @code{constructor} attribute causes the function to be called
2167 automatically before execution enters @code{main ()}.  Similarly, the
2168 @code{destructor} attribute causes the function to be called
2169 automatically after @code{main ()} has completed or @code{exit ()} has
2170 been called.  Functions with these attributes are useful for
2171 initializing data that will be used implicitly during the execution of
2172 the program.
2174 You may provide an optional integer priority to control the order in
2175 which constructor and destructor functions are run.  A constructor
2176 with a smaller priority number runs before a constructor with a larger
2177 priority number; the opposite relationship holds for destructors.  So,
2178 if you have a constructor that allocates a resource and a destructor
2179 that deallocates the same resource, both functions typically have the
2180 same priority.  The priorities for constructor and destructor
2181 functions are the same as those specified for namespace-scope C++
2182 objects (@pxref{C++ Attributes}).
2184 These attributes are not currently implemented for Objective-C@.
2186 @item deprecated
2187 @itemx deprecated (@var{msg})
2188 @cindex @code{deprecated} attribute.
2189 The @code{deprecated} attribute results in a warning if the function
2190 is used anywhere in the source file.  This is useful when identifying
2191 functions that are expected to be removed in a future version of a
2192 program.  The warning also includes the location of the declaration
2193 of the deprecated function, to enable users to easily find further
2194 information about why the function is deprecated, or what they should
2195 do instead.  Note that the warnings only occurs for uses:
2197 @smallexample
2198 int old_fn () __attribute__ ((deprecated));
2199 int old_fn ();
2200 int (*fn_ptr)() = old_fn;
2201 @end smallexample
2203 results in a warning on line 3 but not line 2.  The optional msg
2204 argument, which must be a string, will be printed in the warning if
2205 present.
2207 The @code{deprecated} attribute can also be used for variables and
2208 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2210 @item disinterrupt
2211 @cindex @code{disinterrupt} attribute
2212 On MeP targets, this attribute causes the compiler to emit
2213 instructions to disable interrupts for the duration of the given
2214 function.
2216 @item dllexport
2217 @cindex @code{__declspec(dllexport)}
2218 On Microsoft Windows targets and Symbian OS targets the
2219 @code{dllexport} attribute causes the compiler to provide a global
2220 pointer to a pointer in a DLL, so that it can be referenced with the
2221 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2222 name is formed by combining @code{_imp__} and the function or variable
2223 name.
2225 You can use @code{__declspec(dllexport)} as a synonym for
2226 @code{__attribute__ ((dllexport))} for compatibility with other
2227 compilers.
2229 On systems that support the @code{visibility} attribute, this
2230 attribute also implies ``default'' visibility.  It is an error to
2231 explicitly specify any other visibility.
2233 Currently, the @code{dllexport} attribute is ignored for inlined
2234 functions, unless the @option{-fkeep-inline-functions} flag has been
2235 used.  The attribute is also ignored for undefined symbols.
2237 When applied to C++ classes, the attribute marks defined non-inlined
2238 member functions and static data members as exports.  Static consts
2239 initialized in-class are not marked unless they are also defined
2240 out-of-class.
2242 For Microsoft Windows targets there are alternative methods for
2243 including the symbol in the DLL's export table such as using a
2244 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2245 the @option{--export-all} linker flag.
2247 @item dllimport
2248 @cindex @code{__declspec(dllimport)}
2249 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2250 attribute causes the compiler to reference a function or variable via
2251 a global pointer to a pointer that is set up by the DLL exporting the
2252 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2253 targets, the pointer name is formed by combining @code{_imp__} and the
2254 function or variable name.
2256 You can use @code{__declspec(dllimport)} as a synonym for
2257 @code{__attribute__ ((dllimport))} for compatibility with other
2258 compilers.
2260 On systems that support the @code{visibility} attribute, this
2261 attribute also implies ``default'' visibility.  It is an error to
2262 explicitly specify any other visibility.
2264 Currently, the attribute is ignored for inlined functions.  If the
2265 attribute is applied to a symbol @emph{definition}, an error is reported.
2266 If a symbol previously declared @code{dllimport} is later defined, the
2267 attribute is ignored in subsequent references, and a warning is emitted.
2268 The attribute is also overridden by a subsequent declaration as
2269 @code{dllexport}.
2271 When applied to C++ classes, the attribute marks non-inlined
2272 member functions and static data members as imports.  However, the
2273 attribute is ignored for virtual methods to allow creation of vtables
2274 using thunks.
2276 On the SH Symbian OS target the @code{dllimport} attribute also has
2277 another affect---it can cause the vtable and run-time type information
2278 for a class to be exported.  This happens when the class has a
2279 dllimport'ed constructor or a non-inline, non-pure virtual function
2280 and, for either of those two conditions, the class also has an inline
2281 constructor or destructor and has a key function that is defined in
2282 the current translation unit.
2284 For Microsoft Windows based targets the use of the @code{dllimport}
2285 attribute on functions is not necessary, but provides a small
2286 performance benefit by eliminating a thunk in the DLL@.  The use of the
2287 @code{dllimport} attribute on imported variables was required on older
2288 versions of the GNU linker, but can now be avoided by passing the
2289 @option{--enable-auto-import} switch to the GNU linker.  As with
2290 functions, using the attribute for a variable eliminates a thunk in
2291 the DLL@.
2293 One drawback to using this attribute is that a pointer to a
2294 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2295 address. However, a pointer to a @emph{function} with the
2296 @code{dllimport} attribute can be used as a constant initializer; in
2297 this case, the address of a stub function in the import lib is
2298 referenced.  On Microsoft Windows targets, the attribute can be disabled
2299 for functions by setting the @option{-mnop-fun-dllimport} flag.
2301 @item eightbit_data
2302 @cindex eight bit data on the H8/300, H8/300H, and H8S
2303 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2304 variable should be placed into the eight bit data section.
2305 The compiler will generate more efficient code for certain operations
2306 on data in the eight bit data area.  Note the eight bit data area is limited to
2307 256 bytes of data.
2309 You must use GAS and GLD from GNU binutils version 2.7 or later for
2310 this attribute to work correctly.
2312 @item exception_handler
2313 @cindex exception handler functions on the Blackfin processor
2314 Use this attribute on the Blackfin to indicate that the specified function
2315 is an exception handler.  The compiler will generate function entry and
2316 exit sequences suitable for use in an exception handler when this
2317 attribute is present.
2319 @item externally_visible
2320 @cindex @code{externally_visible} attribute.
2321 This attribute, attached to a global variable or function, nullifies
2322 the effect of the @option{-fwhole-program} command-line option, so the
2323 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.
2325 @item far
2326 @cindex functions which handle memory bank switching
2327 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2328 use a calling convention that takes care of switching memory banks when
2329 entering and leaving a function.  This calling convention is also the
2330 default when using the @option{-mlong-calls} option.
2332 On 68HC12 the compiler will use the @code{call} and @code{rtc} instructions
2333 to call and return from a function.
2335 On 68HC11 the compiler will generate a sequence of instructions
2336 to invoke a board-specific routine to switch the memory bank and call the
2337 real function.  The board-specific routine simulates a @code{call}.
2338 At the end of a function, it will jump to a board-specific routine
2339 instead of using @code{rts}.  The board-specific return routine simulates
2340 the @code{rtc}.
2342 On MeP targets this causes the compiler to use a calling convention
2343 which assumes the called function is too far away for the built-in
2344 addressing modes.
2346 @item fast_interrupt
2347 @cindex interrupt handler functions
2348 Use this attribute on the M32C and RX ports to indicate that the specified
2349 function is a fast interrupt handler.  This is just like the
2350 @code{interrupt} attribute, except that @code{freit} is used to return
2351 instead of @code{reit}.
2353 @item fastcall
2354 @cindex functions that pop the argument stack on the 386
2355 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2356 pass the first argument (if of integral type) in the register ECX and
2357 the second argument (if of integral type) in the register EDX@.  Subsequent
2358 and other typed arguments are passed on the stack.  The called function will
2359 pop the arguments off the stack.  If the number of arguments is variable all
2360 arguments are pushed on the stack.
2362 @item thiscall
2363 @cindex functions that pop the argument stack on the 386
2364 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2365 pass the first argument (if of integral type) in the register ECX.
2366 Subsequent and other typed arguments are passed on the stack. The called
2367 function will pop the arguments off the stack.
2368 If the number of arguments is variable all arguments are pushed on the
2369 stack.
2370 The @code{thiscall} attribute is intended for C++ non-static member functions.
2371 As gcc extension this calling convention can be used for C-functions
2372 and for static member methods.
2374 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2375 @cindex @code{format} function attribute
2376 @opindex Wformat
2377 The @code{format} attribute specifies that a function takes @code{printf},
2378 @code{scanf}, @code{strftime} or @code{strfmon} style arguments which
2379 should be type-checked against a format string.  For example, the
2380 declaration:
2382 @smallexample
2383 extern int
2384 my_printf (void *my_object, const char *my_format, ...)
2385       __attribute__ ((format (printf, 2, 3)));
2386 @end smallexample
2388 @noindent
2389 causes the compiler to check the arguments in calls to @code{my_printf}
2390 for consistency with the @code{printf} style format string argument
2391 @code{my_format}.
2393 The parameter @var{archetype} determines how the format string is
2394 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2395 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2396 @code{strfmon}.  (You can also use @code{__printf__},
2397 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2398 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2399 @code{ms_strftime} are also present.
2400 @var{archtype} values such as @code{printf} refer to the formats accepted
2401 by the system's C run-time library, while @code{gnu_} values always refer
2402 to the formats accepted by the GNU C Library.  On Microsoft Windows
2403 targets, @code{ms_} values refer to the formats accepted by the
2404 @file{msvcrt.dll} library.
2405 The parameter @var{string-index}
2406 specifies which argument is the format string argument (starting
2407 from 1), while @var{first-to-check} is the number of the first
2408 argument to check against the format string.  For functions
2409 where the arguments are not available to be checked (such as
2410 @code{vprintf}), specify the third parameter as zero.  In this case the
2411 compiler only checks the format string for consistency.  For
2412 @code{strftime} formats, the third parameter is required to be zero.
2413 Since non-static C++ methods have an implicit @code{this} argument, the
2414 arguments of such methods should be counted from two, not one, when
2415 giving values for @var{string-index} and @var{first-to-check}.
2417 In the example above, the format string (@code{my_format}) is the second
2418 argument of the function @code{my_print}, and the arguments to check
2419 start with the third argument, so the correct parameters for the format
2420 attribute are 2 and 3.
2422 @opindex ffreestanding
2423 @opindex fno-builtin
2424 The @code{format} attribute allows you to identify your own functions
2425 which take format strings as arguments, so that GCC can check the
2426 calls to these functions for errors.  The compiler always (unless
2427 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2428 for the standard library functions @code{printf}, @code{fprintf},
2429 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2430 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2431 warnings are requested (using @option{-Wformat}), so there is no need to
2432 modify the header file @file{stdio.h}.  In C99 mode, the functions
2433 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2434 @code{vsscanf} are also checked.  Except in strictly conforming C
2435 standard modes, the X/Open function @code{strfmon} is also checked as
2436 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2437 @xref{C Dialect Options,,Options Controlling C Dialect}.
2439 The target may provide additional types of format checks.
2440 @xref{Target Format Checks,,Format Checks Specific to Particular
2441 Target Machines}.
2443 @item format_arg (@var{string-index})
2444 @cindex @code{format_arg} function attribute
2445 @opindex Wformat-nonliteral
2446 The @code{format_arg} attribute specifies that a function takes a format
2447 string for a @code{printf}, @code{scanf}, @code{strftime} or
2448 @code{strfmon} style function and modifies it (for example, to translate
2449 it into another language), so the result can be passed to a
2450 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2451 function (with the remaining arguments to the format function the same
2452 as they would have been for the unmodified string).  For example, the
2453 declaration:
2455 @smallexample
2456 extern char *
2457 my_dgettext (char *my_domain, const char *my_format)
2458       __attribute__ ((format_arg (2)));
2459 @end smallexample
2461 @noindent
2462 causes the compiler to check the arguments in calls to a @code{printf},
2463 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2464 format string argument is a call to the @code{my_dgettext} function, for
2465 consistency with the format string argument @code{my_format}.  If the
2466 @code{format_arg} attribute had not been specified, all the compiler
2467 could tell in such calls to format functions would be that the format
2468 string argument is not constant; this would generate a warning when
2469 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2470 without the attribute.
2472 The parameter @var{string-index} specifies which argument is the format
2473 string argument (starting from one).  Since non-static C++ methods have
2474 an implicit @code{this} argument, the arguments of such methods should
2475 be counted from two.
2477 The @code{format-arg} attribute allows you to identify your own
2478 functions which modify format strings, so that GCC can check the
2479 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2480 type function whose operands are a call to one of your own function.
2481 The compiler always treats @code{gettext}, @code{dgettext}, and
2482 @code{dcgettext} in this manner except when strict ISO C support is
2483 requested by @option{-ansi} or an appropriate @option{-std} option, or
2484 @option{-ffreestanding} or @option{-fno-builtin}
2485 is used.  @xref{C Dialect Options,,Options
2486 Controlling C Dialect}.
2488 @item function_vector
2489 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2490 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2491 function should be called through the function vector.  Calling a
2492 function through the function vector will reduce code size, however;
2493 the function vector has a limited size (maximum 128 entries on the H8/300
2494 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2496 In SH2A target, this attribute declares a function to be called using the
2497 TBR relative addressing mode.  The argument to this attribute is the entry
2498 number of the same function in a vector table containing all the TBR
2499 relative addressable functions.  For the successful jump, register TBR
2500 should contain the start address of this TBR relative vector table.
2501 In the startup routine of the user application, user needs to care of this
2502 TBR register initialization.  The TBR relative vector table can have at
2503 max 256 function entries.  The jumps to these functions will be generated
2504 using a SH2A specific, non delayed branch instruction JSR/N @@(disp8,TBR).
2505 You must use GAS and GLD from GNU binutils version 2.7 or later for
2506 this attribute to work correctly.
2508 Please refer the example of M16C target, to see the use of this
2509 attribute while declaring a function,
2511 In an application, for a function being called once, this attribute will
2512 save at least 8 bytes of code; and if other successive calls are being
2513 made to the same function, it will save 2 bytes of code per each of these
2514 calls.
2516 On M16C/M32C targets, the @code{function_vector} attribute declares a
2517 special page subroutine call function. Use of this attribute reduces
2518 the code size by 2 bytes for each call generated to the
2519 subroutine. The argument to the attribute is the vector number entry
2520 from the special page vector table which contains the 16 low-order
2521 bits of the subroutine's entry address. Each vector table has special
2522 page number (18 to 255) which are used in @code{jsrs} instruction.
2523 Jump addresses of the routines are generated by adding 0x0F0000 (in
2524 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the 2
2525 byte addresses set in the vector table. Therefore you need to ensure
2526 that all the special page vector routines should get mapped within the
2527 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2528 (for M32C).
2530 In the following example 2 bytes will be saved for each call to
2531 function @code{foo}.
2533 @smallexample
2534 void foo (void) __attribute__((function_vector(0x18)));
2535 void foo (void)
2539 void bar (void)
2541     foo();
2543 @end smallexample
2545 If functions are defined in one file and are called in another file,
2546 then be sure to write this declaration in both files.
2548 This attribute is ignored for R8C target.
2550 @item interrupt
2551 @cindex interrupt handler functions
2552 Use this attribute on the ARM, AVR, CRX, M32C, M32R/D, m68k, MeP, MIPS,
2553 RX and Xstormy16 ports to indicate that the specified function is an
2554 interrupt handler.  The compiler will generate function entry and exit
2555 sequences suitable for use in an interrupt handler when this attribute
2556 is present.
2558 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, and
2559 SH processors can be specified via the @code{interrupt_handler} attribute.
2561 Note, on the AVR, interrupts will be enabled inside the function.
2563 Note, for the ARM, you can specify the kind of interrupt to be handled by
2564 adding an optional parameter to the interrupt attribute like this:
2566 @smallexample
2567 void f () __attribute__ ((interrupt ("IRQ")));
2568 @end smallexample
2570 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
2572 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2573 may be called with a word aligned stack pointer.
2575 On MIPS targets, you can use the following attributes to modify the behavior
2576 of an interrupt handler:
2577 @table @code
2578 @item use_shadow_register_set
2579 @cindex @code{use_shadow_register_set} attribute
2580 Assume that the handler uses a shadow register set, instead of
2581 the main general-purpose registers.
2583 @item keep_interrupts_masked
2584 @cindex @code{keep_interrupts_masked} attribute
2585 Keep interrupts masked for the whole function.  Without this attribute,
2586 GCC tries to reenable interrupts for as much of the function as it can.
2588 @item use_debug_exception_return
2589 @cindex @code{use_debug_exception_return} attribute
2590 Return using the @code{deret} instruction.  Interrupt handlers that don't
2591 have this attribute return using @code{eret} instead.
2592 @end table
2594 You can use any combination of these attributes, as shown below:
2595 @smallexample
2596 void __attribute__ ((interrupt)) v0 ();
2597 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2598 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2599 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2600 void __attribute__ ((interrupt, use_shadow_register_set,
2601                      keep_interrupts_masked)) v4 ();
2602 void __attribute__ ((interrupt, use_shadow_register_set,
2603                      use_debug_exception_return)) v5 ();
2604 void __attribute__ ((interrupt, keep_interrupts_masked,
2605                      use_debug_exception_return)) v6 ();
2606 void __attribute__ ((interrupt, use_shadow_register_set,
2607                      keep_interrupts_masked,
2608                      use_debug_exception_return)) v7 ();
2609 @end smallexample
2611 @item interrupt_handler
2612 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2613 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2614 indicate that the specified function is an interrupt handler.  The compiler
2615 will generate function entry and exit sequences suitable for use in an
2616 interrupt handler when this attribute is present.
2618 @item interrupt_thread
2619 @cindex interrupt thread functions on fido
2620 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2621 that the specified function is an interrupt handler that is designed
2622 to run as a thread.  The compiler omits generate prologue/epilogue
2623 sequences and replaces the return instruction with a @code{sleep}
2624 instruction.  This attribute is available only on fido.
2626 @item isr
2627 @cindex interrupt service routines on ARM
2628 Use this attribute on ARM to write Interrupt Service Routines. This is an
2629 alias to the @code{interrupt} attribute above.
2631 @item kspisusp
2632 @cindex User stack pointer in interrupts on the Blackfin
2633 When used together with @code{interrupt_handler}, @code{exception_handler}
2634 or @code{nmi_handler}, code will be generated to load the stack pointer
2635 from the USP register in the function prologue.
2637 @item l1_text
2638 @cindex @code{l1_text} function attribute
2639 This attribute specifies a function to be placed into L1 Instruction
2640 SRAM@. The function will be put into a specific section named @code{.l1.text}.
2641 With @option{-mfdpic}, function calls with a such function as the callee
2642 or caller will use inlined PLT.
2644 @item l2
2645 @cindex @code{l2} function attribute
2646 On the Blackfin, this attribute specifies a function to be placed into L2
2647 SRAM. The function will be put into a specific section named
2648 @code{.l1.text}. With @option{-mfdpic}, callers of such functions will use
2649 an inlined PLT.
2651 @item long_call/short_call
2652 @cindex indirect calls on ARM
2653 This attribute specifies how a particular function is called on
2654 ARM@.  Both attributes override the @option{-mlong-calls} (@pxref{ARM Options})
2655 command-line switch and @code{#pragma long_calls} settings.  The
2656 @code{long_call} attribute indicates that the function might be far
2657 away from the call site and require a different (more expensive)
2658 calling sequence.   The @code{short_call} attribute always places
2659 the offset to the function from the call site into the @samp{BL}
2660 instruction directly.
2662 @item longcall/shortcall
2663 @cindex functions called via pointer on the RS/6000 and PowerPC
2664 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
2665 indicates that the function might be far away from the call site and
2666 require a different (more expensive) calling sequence.  The
2667 @code{shortcall} attribute indicates that the function is always close
2668 enough for the shorter calling sequence to be used.  These attributes
2669 override both the @option{-mlongcall} switch and, on the RS/6000 and
2670 PowerPC, the @code{#pragma longcall} setting.
2672 @xref{RS/6000 and PowerPC Options}, for more information on whether long
2673 calls are necessary.
2675 @item long_call/near/far
2676 @cindex indirect calls on MIPS
2677 These attributes specify how a particular function is called on MIPS@.
2678 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
2679 command-line switch.  The @code{long_call} and @code{far} attributes are
2680 synonyms, and cause the compiler to always call
2681 the function by first loading its address into a register, and then using
2682 the contents of that register.  The @code{near} attribute has the opposite
2683 effect; it specifies that non-PIC calls should be made using the more 
2684 efficient @code{jal} instruction.
2686 @item malloc
2687 @cindex @code{malloc} attribute
2688 The @code{malloc} attribute is used to tell the compiler that a function
2689 may be treated as if any non-@code{NULL} pointer it returns cannot
2690 alias any other pointer valid when the function returns.
2691 This will often improve optimization.
2692 Standard functions with this property include @code{malloc} and
2693 @code{calloc}.  @code{realloc}-like functions have this property as
2694 long as the old pointer is never referred to (including comparing it
2695 to the new pointer) after the function returns a non-@code{NULL}
2696 value.
2698 @item mips16/nomips16
2699 @cindex @code{mips16} attribute
2700 @cindex @code{nomips16} attribute
2702 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
2703 function attributes to locally select or turn off MIPS16 code generation.
2704 A function with the @code{mips16} attribute is emitted as MIPS16 code, 
2705 while MIPS16 code generation is disabled for functions with the 
2706 @code{nomips16} attribute.  These attributes override the 
2707 @option{-mips16} and @option{-mno-mips16} options on the command line
2708 (@pxref{MIPS Options}).  
2710 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
2711 preprocessor symbol @code{__mips16} reflects the setting on the command line,
2712 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
2713 may interact badly with some GCC extensions such as @code{__builtin_apply}
2714 (@pxref{Constructing Calls}).
2716 @item model (@var{model-name})
2717 @cindex function addressability on the M32R/D
2718 @cindex variable addressability on the IA-64
2720 On the M32R/D, use this attribute to set the addressability of an
2721 object, and of the code generated for a function.  The identifier
2722 @var{model-name} is one of @code{small}, @code{medium}, or
2723 @code{large}, representing each of the code models.
2725 Small model objects live in the lower 16MB of memory (so that their
2726 addresses can be loaded with the @code{ld24} instruction), and are
2727 callable with the @code{bl} instruction.
2729 Medium model objects may live anywhere in the 32-bit address space (the
2730 compiler will generate @code{seth/add3} instructions to load their addresses),
2731 and are callable with the @code{bl} instruction.
2733 Large model objects may live anywhere in the 32-bit address space (the
2734 compiler will generate @code{seth/add3} instructions to load their addresses),
2735 and may not be reachable with the @code{bl} instruction (the compiler will
2736 generate the much slower @code{seth/add3/jl} instruction sequence).
2738 On IA-64, use this attribute to set the addressability of an object.
2739 At present, the only supported identifier for @var{model-name} is
2740 @code{small}, indicating addressability via ``small'' (22-bit)
2741 addresses (so that their addresses can be loaded with the @code{addl}
2742 instruction).  Caveat: such addressing is by definition not position
2743 independent and hence this attribute must not be used for objects
2744 defined by shared libraries.
2746 @item ms_abi/sysv_abi
2747 @cindex @code{ms_abi} attribute
2748 @cindex @code{sysv_abi} attribute
2750 On 64-bit x86_64-*-* targets, you can use an ABI attribute to indicate
2751 which calling convention should be used for a function.  The @code{ms_abi}
2752 attribute tells the compiler to use the Microsoft ABI, while the
2753 @code{sysv_abi} attribute tells the compiler to use the ABI used on
2754 GNU/Linux and other systems.  The default is to use the Microsoft ABI
2755 when targeting Windows.  On all other systems, the default is the AMD ABI.
2757 Note, the @code{ms_abi} attribute for Windows targets currently requires
2758 the @option{-maccumulate-outgoing-args} option.
2760 @item ms_hook_prologue
2761 @cindex @code{ms_hook_prologue} attribute
2763 On 32 bit i[34567]86-*-* targets and 64 bit x86_64-*-* targets, you can use
2764 this function attribute to make gcc generate the "hot-patching" function
2765 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
2766 and newer.
2768 @item naked
2769 @cindex function without a prologue/epilogue code
2770 Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that
2771 the specified function does not need prologue/epilogue sequences generated by
2772 the compiler.  It is up to the programmer to provide these sequences. The 
2773 only statements that can be safely included in naked functions are 
2774 @code{asm} statements that do not have operands.  All other statements,
2775 including declarations of local variables, @code{if} statements, and so 
2776 forth, should be avoided.  Naked functions should be used to implement the 
2777 body of an assembly function, while allowing the compiler to construct
2778 the requisite function declaration for the assembler.
2780 @item near
2781 @cindex functions which do not handle memory bank switching on 68HC11/68HC12
2782 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
2783 use the normal calling convention based on @code{jsr} and @code{rts}.
2784 This attribute can be used to cancel the effect of the @option{-mlong-calls}
2785 option.
2787 On MeP targets this attribute causes the compiler to assume the called
2788 function is close enough to use the normal calling convention,
2789 overriding the @code{-mtf} command line option.
2791 @item nesting
2792 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
2793 Use this attribute together with @code{interrupt_handler},
2794 @code{exception_handler} or @code{nmi_handler} to indicate that the function
2795 entry code should enable nested interrupts or exceptions.
2797 @item nmi_handler
2798 @cindex NMI handler functions on the Blackfin processor
2799 Use this attribute on the Blackfin to indicate that the specified function
2800 is an NMI handler.  The compiler will generate function entry and
2801 exit sequences suitable for use in an NMI handler when this
2802 attribute is present.
2804 @item no_instrument_function
2805 @cindex @code{no_instrument_function} function attribute
2806 @opindex finstrument-functions
2807 If @option{-finstrument-functions} is given, profiling function calls will
2808 be generated at entry and exit of most user-compiled functions.
2809 Functions with this attribute will not be so instrumented.
2811 @item noinline
2812 @cindex @code{noinline} function attribute
2813 This function attribute prevents a function from being considered for
2814 inlining.
2815 @c Don't enumerate the optimizations by name here; we try to be
2816 @c future-compatible with this mechanism.
2817 If the function does not have side-effects, there are optimizations
2818 other than inlining that causes function calls to be optimized away,
2819 although the function call is live.  To keep such calls from being
2820 optimized away, put
2821 @smallexample
2822 asm ("");
2823 @end smallexample
2824 (@pxref{Extended Asm}) in the called function, to serve as a special
2825 side-effect.
2827 @item noclone
2828 @cindex @code{noclone} function attribute
2829 This function attribute prevents a function from being considered for
2830 cloning - a mechanism which produces specialized copies of functions
2831 and which is (currently) performed by interprocedural constant
2832 propagation.
2834 @item nonnull (@var{arg-index}, @dots{})
2835 @cindex @code{nonnull} function attribute
2836 The @code{nonnull} attribute specifies that some function parameters should
2837 be non-null pointers.  For instance, the declaration:
2839 @smallexample
2840 extern void *
2841 my_memcpy (void *dest, const void *src, size_t len)
2842         __attribute__((nonnull (1, 2)));
2843 @end smallexample
2845 @noindent
2846 causes the compiler to check that, in calls to @code{my_memcpy},
2847 arguments @var{dest} and @var{src} are non-null.  If the compiler
2848 determines that a null pointer is passed in an argument slot marked
2849 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2850 is issued.  The compiler may also choose to make optimizations based
2851 on the knowledge that certain function arguments will not be null.
2853 If no argument index list is given to the @code{nonnull} attribute,
2854 all pointer arguments are marked as non-null.  To illustrate, the
2855 following declaration is equivalent to the previous example:
2857 @smallexample
2858 extern void *
2859 my_memcpy (void *dest, const void *src, size_t len)
2860         __attribute__((nonnull));
2861 @end smallexample
2863 @item noreturn
2864 @cindex @code{noreturn} function attribute
2865 A few standard library functions, such as @code{abort} and @code{exit},
2866 cannot return.  GCC knows this automatically.  Some programs define
2867 their own functions that never return.  You can declare them
2868 @code{noreturn} to tell the compiler this fact.  For example,
2870 @smallexample
2871 @group
2872 void fatal () __attribute__ ((noreturn));
2874 void
2875 fatal (/* @r{@dots{}} */)
2877   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2878   exit (1);
2880 @end group
2881 @end smallexample
2883 The @code{noreturn} keyword tells the compiler to assume that
2884 @code{fatal} cannot return.  It can then optimize without regard to what
2885 would happen if @code{fatal} ever did return.  This makes slightly
2886 better code.  More importantly, it helps avoid spurious warnings of
2887 uninitialized variables.
2889 The @code{noreturn} keyword does not affect the exceptional path when that
2890 applies: a @code{noreturn}-marked function may still return to the caller
2891 by throwing an exception or calling @code{longjmp}.
2893 Do not assume that registers saved by the calling function are
2894 restored before calling the @code{noreturn} function.
2896 It does not make sense for a @code{noreturn} function to have a return
2897 type other than @code{void}.
2899 The attribute @code{noreturn} is not implemented in GCC versions
2900 earlier than 2.5.  An alternative way to declare that a function does
2901 not return, which works in the current version and in some older
2902 versions, is as follows:
2904 @smallexample
2905 typedef void voidfn ();
2907 volatile voidfn fatal;
2908 @end smallexample
2910 This approach does not work in GNU C++.
2912 @item nothrow
2913 @cindex @code{nothrow} function attribute
2914 The @code{nothrow} attribute is used to inform the compiler that a
2915 function cannot throw an exception.  For example, most functions in
2916 the standard C library can be guaranteed not to throw an exception
2917 with the notable exceptions of @code{qsort} and @code{bsearch} that
2918 take function pointer arguments.  The @code{nothrow} attribute is not
2919 implemented in GCC versions earlier than 3.3.
2921 @item optimize
2922 @cindex @code{optimize} function attribute
2923 The @code{optimize} attribute is used to specify that a function is to
2924 be compiled with different optimization options than specified on the
2925 command line.  Arguments can either be numbers or strings.  Numbers
2926 are assumed to be an optimization level.  Strings that begin with
2927 @code{O} are assumed to be an optimization option, while other options
2928 are assumed to be used with a @code{-f} prefix.  You can also use the
2929 @samp{#pragma GCC optimize} pragma to set the optimization options
2930 that affect more than one function.
2931 @xref{Function Specific Option Pragmas}, for details about the
2932 @samp{#pragma GCC optimize} pragma.
2934 This can be used for instance to have frequently executed functions
2935 compiled with more aggressive optimization options that produce faster
2936 and larger code, while other functions can be called with less
2937 aggressive options.
2939 @item pcs
2940 @cindex @code{pcs} function attribute
2942 The @code{pcs} attribute can be used to control the calling convention
2943 used for a function on ARM.  The attribute takes an argument that specifies
2944 the calling convention to use.
2946 When compiling using the AAPCS ABI (or a variant of that) then valid
2947 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
2948 order to use a variant other than @code{"aapcs"} then the compiler must
2949 be permitted to use the appropriate co-processor registers (i.e., the
2950 VFP registers must be available in order to use @code{"aapcs-vfp"}).
2951 For example,
2953 @smallexample
2954 /* Argument passed in r0, and result returned in r0+r1.  */
2955 double f2d (float) __attribute__((pcs("aapcs")));
2956 @end smallexample
2958 Variadic functions always use the @code{"aapcs"} calling convention and
2959 the compiler will reject attempts to specify an alternative.
2961 @item pure
2962 @cindex @code{pure} function attribute
2963 Many functions have no effects except the return value and their
2964 return value depends only on the parameters and/or global variables.
2965 Such a function can be subject
2966 to common subexpression elimination and loop optimization just as an
2967 arithmetic operator would be.  These functions should be declared
2968 with the attribute @code{pure}.  For example,
2970 @smallexample
2971 int square (int) __attribute__ ((pure));
2972 @end smallexample
2974 @noindent
2975 says that the hypothetical function @code{square} is safe to call
2976 fewer times than the program says.
2978 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
2979 Interesting non-pure functions are functions with infinite loops or those
2980 depending on volatile memory or other system resource, that may change between
2981 two consecutive calls (such as @code{feof} in a multithreading environment).
2983 The attribute @code{pure} is not implemented in GCC versions earlier
2984 than 2.96.
2986 @item hot
2987 @cindex @code{hot} function attribute
2988 The @code{hot} attribute is used to inform the compiler that a function is a
2989 hot spot of the compiled program.  The function is optimized more aggressively
2990 and on many target it is placed into special subsection of the text section so
2991 all hot functions appears close together improving locality.
2993 When profile feedback is available, via @option{-fprofile-use}, hot functions
2994 are automatically detected and this attribute is ignored.
2996 The @code{hot} attribute is not implemented in GCC versions earlier
2997 than 4.3.
2999 @item cold
3000 @cindex @code{cold} function attribute
3001 The @code{cold} attribute is used to inform the compiler that a function is
3002 unlikely executed.  The function is optimized for size rather than speed and on
3003 many targets it is placed into special subsection of the text section so all
3004 cold functions appears close together improving code locality of non-cold parts
3005 of program.  The paths leading to call of cold functions within code are marked
3006 as unlikely by the branch prediction mechanism. It is thus useful to mark
3007 functions used to handle unlikely conditions, such as @code{perror}, as cold to
3008 improve optimization of hot functions that do call marked functions in rare
3009 occasions.
3011 When profile feedback is available, via @option{-fprofile-use}, hot functions
3012 are automatically detected and this attribute is ignored.
3014 The @code{cold} attribute is not implemented in GCC versions earlier than 4.3.
3016 @item regparm (@var{number})
3017 @cindex @code{regparm} attribute
3018 @cindex functions that are passed arguments in registers on the 386
3019 On the Intel 386, the @code{regparm} attribute causes the compiler to
3020 pass arguments number one to @var{number} if they are of integral type
3021 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3022 take a variable number of arguments will continue to be passed all of their
3023 arguments on the stack.
3025 Beware that on some ELF systems this attribute is unsuitable for
3026 global functions in shared libraries with lazy binding (which is the
3027 default).  Lazy binding will send the first call via resolving code in
3028 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3029 per the standard calling conventions.  Solaris 8 is affected by this.
3030 GNU systems with GLIBC 2.1 or higher, and FreeBSD, are believed to be
3031 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3032 disabled with the linker or the loader if desired, to avoid the
3033 problem.)
3035 @item sseregparm
3036 @cindex @code{sseregparm} attribute
3037 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3038 causes the compiler to pass up to 3 floating point arguments in
3039 SSE registers instead of on the stack.  Functions that take a
3040 variable number of arguments will continue to pass all of their
3041 floating point arguments on the stack.
3043 @item force_align_arg_pointer
3044 @cindex @code{force_align_arg_pointer} attribute
3045 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3046 applied to individual function definitions, generating an alternate
3047 prologue and epilogue that realigns the runtime stack if necessary.
3048 This supports mixing legacy codes that run with a 4-byte aligned stack
3049 with modern codes that keep a 16-byte stack for SSE compatibility.
3051 @item resbank
3052 @cindex @code{resbank} attribute
3053 On the SH2A target, this attribute enables the high-speed register
3054 saving and restoration using a register bank for @code{interrupt_handler}
3055 routines.  Saving to the bank is performed automatically after the CPU
3056 accepts an interrupt that uses a register bank.
3058 The nineteen 32-bit registers comprising general register R0 to R14,
3059 control register GBR, and system registers MACH, MACL, and PR and the
3060 vector table address offset are saved into a register bank.  Register
3061 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3062 from the bank is executed by issuing a RESBANK instruction.
3064 @item returns_twice
3065 @cindex @code{returns_twice} attribute
3066 The @code{returns_twice} attribute tells the compiler that a function may
3067 return more than one time.  The compiler will ensure that all registers
3068 are dead before calling such a function and will emit a warning about
3069 the variables that may be clobbered after the second return from the
3070 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3071 The @code{longjmp}-like counterpart of such function, if any, might need
3072 to be marked with the @code{noreturn} attribute.
3074 @item saveall
3075 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3076 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3077 all registers except the stack pointer should be saved in the prologue
3078 regardless of whether they are used or not.
3080 @item section ("@var{section-name}")
3081 @cindex @code{section} function attribute
3082 Normally, the compiler places the code it generates in the @code{text} section.
3083 Sometimes, however, you need additional sections, or you need certain
3084 particular functions to appear in special sections.  The @code{section}
3085 attribute specifies that a function lives in a particular section.
3086 For example, the declaration:
3088 @smallexample
3089 extern void foobar (void) __attribute__ ((section ("bar")));
3090 @end smallexample
3092 @noindent
3093 puts the function @code{foobar} in the @code{bar} section.
3095 Some file formats do not support arbitrary sections so the @code{section}
3096 attribute is not available on all platforms.
3097 If you need to map the entire contents of a module to a particular
3098 section, consider using the facilities of the linker instead.
3100 @item sentinel
3101 @cindex @code{sentinel} function attribute
3102 This function attribute ensures that a parameter in a function call is
3103 an explicit @code{NULL}.  The attribute is only valid on variadic
3104 functions.  By default, the sentinel is located at position zero, the
3105 last parameter of the function call.  If an optional integer position
3106 argument P is supplied to the attribute, the sentinel must be located at
3107 position P counting backwards from the end of the argument list.
3109 @smallexample
3110 __attribute__ ((sentinel))
3111 is equivalent to
3112 __attribute__ ((sentinel(0)))
3113 @end smallexample
3115 The attribute is automatically set with a position of 0 for the built-in
3116 functions @code{execl} and @code{execlp}.  The built-in function
3117 @code{execle} has the attribute set with a position of 1.
3119 A valid @code{NULL} in this context is defined as zero with any pointer
3120 type.  If your system defines the @code{NULL} macro with an integer type
3121 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3122 with a copy that redefines NULL appropriately.
3124 The warnings for missing or incorrect sentinels are enabled with
3125 @option{-Wformat}.
3127 @item short_call
3128 See long_call/short_call.
3130 @item shortcall
3131 See longcall/shortcall.
3133 @item signal
3134 @cindex signal handler functions on the AVR processors
3135 Use this attribute on the AVR to indicate that the specified
3136 function is a signal handler.  The compiler will generate function
3137 entry and exit sequences suitable for use in a signal handler when this
3138 attribute is present.  Interrupts will be disabled inside the function.
3140 @item sp_switch
3141 Use this attribute on the SH to indicate an @code{interrupt_handler}
3142 function should switch to an alternate stack.  It expects a string
3143 argument that names a global variable holding the address of the
3144 alternate stack.
3146 @smallexample
3147 void *alt_stack;
3148 void f () __attribute__ ((interrupt_handler,
3149                           sp_switch ("alt_stack")));
3150 @end smallexample
3152 @item stdcall
3153 @cindex functions that pop the argument stack on the 386
3154 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3155 assume that the called function will pop off the stack space used to
3156 pass arguments, unless it takes a variable number of arguments.
3158 @item syscall_linkage
3159 @cindex @code{syscall_linkage} attribute
3160 This attribute is used to modify the IA64 calling convention by marking
3161 all input registers as live at all function exits.  This makes it possible
3162 to restart a system call after an interrupt without having to save/restore
3163 the input registers.  This also prevents kernel data from leaking into
3164 application code.
3166 @item target
3167 @cindex @code{target} function attribute
3168 The @code{target} attribute is used to specify that a function is to
3169 be compiled with different target options than specified on the
3170 command line.  This can be used for instance to have functions
3171 compiled with a different ISA (instruction set architecture) than the
3172 default.  You can also use the @samp{#pragma GCC target} pragma to set
3173 more than one function to be compiled with specific target options.
3174 @xref{Function Specific Option Pragmas}, for details about the
3175 @samp{#pragma GCC target} pragma.
3177 For instance on a 386, you could compile one function with
3178 @code{target("sse4.1,arch=core2")} and another with
3179 @code{target("sse4a,arch=amdfam10")} that would be equivalent to
3180 compiling the first function with @option{-msse4.1} and
3181 @option{-march=core2} options, and the second function with
3182 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3183 user to make sure that a function is only invoked on a machine that
3184 supports the particular ISA it was compiled for (for example by using
3185 @code{cpuid} on 386 to determine what feature bits and architecture
3186 family are used).
3188 @smallexample
3189 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3190 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3191 @end smallexample
3193 On the 386, the following options are allowed:
3195 @table @samp
3196 @item abm
3197 @itemx no-abm
3198 @cindex @code{target("abm")} attribute
3199 Enable/disable the generation of the advanced bit instructions.
3201 @item aes
3202 @itemx no-aes
3203 @cindex @code{target("aes")} attribute
3204 Enable/disable the generation of the AES instructions.
3206 @item mmx
3207 @itemx no-mmx
3208 @cindex @code{target("mmx")} attribute
3209 Enable/disable the generation of the MMX instructions.
3211 @item pclmul
3212 @itemx no-pclmul
3213 @cindex @code{target("pclmul")} attribute
3214 Enable/disable the generation of the PCLMUL instructions.
3216 @item popcnt
3217 @itemx no-popcnt
3218 @cindex @code{target("popcnt")} attribute
3219 Enable/disable the generation of the POPCNT instruction.
3221 @item sse
3222 @itemx no-sse
3223 @cindex @code{target("sse")} attribute
3224 Enable/disable the generation of the SSE instructions.
3226 @item sse2
3227 @itemx no-sse2
3228 @cindex @code{target("sse2")} attribute
3229 Enable/disable the generation of the SSE2 instructions.
3231 @item sse3
3232 @itemx no-sse3
3233 @cindex @code{target("sse3")} attribute
3234 Enable/disable the generation of the SSE3 instructions.
3236 @item sse4
3237 @itemx no-sse4
3238 @cindex @code{target("sse4")} attribute
3239 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3240 and SSE4.2).
3242 @item sse4.1
3243 @itemx no-sse4.1
3244 @cindex @code{target("sse4.1")} attribute
3245 Enable/disable the generation of the sse4.1 instructions.
3247 @item sse4.2
3248 @itemx no-sse4.2
3249 @cindex @code{target("sse4.2")} attribute
3250 Enable/disable the generation of the sse4.2 instructions.
3252 @item sse4a
3253 @itemx no-sse4a
3254 @cindex @code{target("sse4a")} attribute
3255 Enable/disable the generation of the SSE4A instructions.
3257 @item fma4
3258 @itemx no-fma4
3259 @cindex @code{target("fma4")} attribute
3260 Enable/disable the generation of the FMA4 instructions.
3262 @item xop
3263 @itemx no-xop
3264 @cindex @code{target("xop")} attribute
3265 Enable/disable the generation of the XOP instructions.
3267 @item lwp
3268 @itemx no-lwp
3269 @cindex @code{target("lwp")} attribute
3270 Enable/disable the generation of the LWP instructions.
3272 @item ssse3
3273 @itemx no-ssse3
3274 @cindex @code{target("ssse3")} attribute
3275 Enable/disable the generation of the SSSE3 instructions.
3277 @item cld
3278 @itemx no-cld
3279 @cindex @code{target("cld")} attribute
3280 Enable/disable the generation of the CLD before string moves.
3282 @item fancy-math-387
3283 @itemx no-fancy-math-387
3284 @cindex @code{target("fancy-math-387")} attribute
3285 Enable/disable the generation of the @code{sin}, @code{cos}, and
3286 @code{sqrt} instructions on the 387 floating point unit.
3288 @item fused-madd
3289 @itemx no-fused-madd
3290 @cindex @code{target("fused-madd")} attribute
3291 Enable/disable the generation of the fused multiply/add instructions.
3293 @item ieee-fp
3294 @itemx no-ieee-fp
3295 @cindex @code{target("ieee-fp")} attribute
3296 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3298 @item inline-all-stringops
3299 @itemx no-inline-all-stringops
3300 @cindex @code{target("inline-all-stringops")} attribute
3301 Enable/disable inlining of string operations.
3303 @item inline-stringops-dynamically
3304 @itemx no-inline-stringops-dynamically
3305 @cindex @code{target("inline-stringops-dynamically")} attribute
3306 Enable/disable the generation of the inline code to do small string
3307 operations and calling the library routines for large operations.
3309 @item align-stringops
3310 @itemx no-align-stringops
3311 @cindex @code{target("align-stringops")} attribute
3312 Do/do not align destination of inlined string operations.
3314 @item recip
3315 @itemx no-recip
3316 @cindex @code{target("recip")} attribute
3317 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3318 instructions followed an additional Newton-Raphson step instead of
3319 doing a floating point division.
3321 @item arch=@var{ARCH}
3322 @cindex @code{target("arch=@var{ARCH}")} attribute
3323 Specify the architecture to generate code for in compiling the function.
3325 @item tune=@var{TUNE}
3326 @cindex @code{target("tune=@var{TUNE}")} attribute
3327 Specify the architecture to tune for in compiling the function.
3329 @item fpmath=@var{FPMATH}
3330 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3331 Specify which floating point unit to use.  The
3332 @code{target("fpmath=sse,387")} option must be specified as
3333 @code{target("fpmath=sse+387")} because the comma would separate
3334 different options.
3335 @end table
3337 On the 386, you can use either multiple strings to specify multiple
3338 options, or you can separate the option with a comma (@code{,}).
3340 On the 386, the inliner will not inline a function that has different
3341 target options than the caller, unless the callee has a subset of the
3342 target options of the caller.  For example a function declared with
3343 @code{target("sse3")} can inline a function with
3344 @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
3346 The @code{target} attribute is not implemented in GCC versions earlier
3347 than 4.4, and at present only the 386 uses it.
3349 @item tiny_data
3350 @cindex tiny data section on the H8/300H and H8S
3351 Use this attribute on the H8/300H and H8S to indicate that the specified
3352 variable should be placed into the tiny data section.
3353 The compiler will generate more efficient code for loads and stores
3354 on data in the tiny data section.  Note the tiny data area is limited to
3355 slightly under 32kbytes of data.
3357 @item trap_exit
3358 Use this attribute on the SH for an @code{interrupt_handler} to return using
3359 @code{trapa} instead of @code{rte}.  This attribute expects an integer
3360 argument specifying the trap number to be used.
3362 @item unused
3363 @cindex @code{unused} attribute.
3364 This attribute, attached to a function, means that the function is meant
3365 to be possibly unused.  GCC will not produce a warning for this
3366 function.
3368 @item used
3369 @cindex @code{used} attribute.
3370 This attribute, attached to a function, means that code must be emitted
3371 for the function even if it appears that the function is not referenced.
3372 This is useful, for example, when the function is referenced only in
3373 inline assembly.
3375 @item version_id
3376 @cindex @code{version_id} attribute
3377 This IA64 HP-UX attribute, attached to a global variable or function, renames a
3378 symbol to contain a version string, thus allowing for function level
3379 versioning.  HP-UX system header files may use version level functioning
3380 for some system calls.
3382 @smallexample
3383 extern int foo () __attribute__((version_id ("20040821")));
3384 @end smallexample
3386 Calls to @var{foo} will be mapped to calls to @var{foo@{20040821@}}.
3388 @item visibility ("@var{visibility_type}")
3389 @cindex @code{visibility} attribute
3390 This attribute affects the linkage of the declaration to which it is attached.
3391 There are four supported @var{visibility_type} values: default,
3392 hidden, protected or internal visibility.
3394 @smallexample
3395 void __attribute__ ((visibility ("protected")))
3396 f () @{ /* @r{Do something.} */; @}
3397 int i __attribute__ ((visibility ("hidden")));
3398 @end smallexample
3400 The possible values of @var{visibility_type} correspond to the
3401 visibility settings in the ELF gABI.
3403 @table @dfn
3404 @c keep this list of visibilities in alphabetical order.
3406 @item default
3407 Default visibility is the normal case for the object file format.
3408 This value is available for the visibility attribute to override other
3409 options that may change the assumed visibility of entities.
3411 On ELF, default visibility means that the declaration is visible to other
3412 modules and, in shared libraries, means that the declared entity may be
3413 overridden.
3415 On Darwin, default visibility means that the declaration is visible to
3416 other modules.
3418 Default visibility corresponds to ``external linkage'' in the language.
3420 @item hidden
3421 Hidden visibility indicates that the entity declared will have a new
3422 form of linkage, which we'll call ``hidden linkage''.  Two
3423 declarations of an object with hidden linkage refer to the same object
3424 if they are in the same shared object.
3426 @item internal
3427 Internal visibility is like hidden visibility, but with additional
3428 processor specific semantics.  Unless otherwise specified by the
3429 psABI, GCC defines internal visibility to mean that a function is
3430 @emph{never} called from another module.  Compare this with hidden
3431 functions which, while they cannot be referenced directly by other
3432 modules, can be referenced indirectly via function pointers.  By
3433 indicating that a function cannot be called from outside the module,
3434 GCC may for instance omit the load of a PIC register since it is known
3435 that the calling function loaded the correct value.
3437 @item protected
3438 Protected visibility is like default visibility except that it
3439 indicates that references within the defining module will bind to the
3440 definition in that module.  That is, the declared entity cannot be
3441 overridden by another module.
3443 @end table
3445 All visibilities are supported on many, but not all, ELF targets
3446 (supported when the assembler supports the @samp{.visibility}
3447 pseudo-op).  Default visibility is supported everywhere.  Hidden
3448 visibility is supported on Darwin targets.
3450 The visibility attribute should be applied only to declarations which
3451 would otherwise have external linkage.  The attribute should be applied
3452 consistently, so that the same entity should not be declared with
3453 different settings of the attribute.
3455 In C++, the visibility attribute applies to types as well as functions
3456 and objects, because in C++ types have linkage.  A class must not have
3457 greater visibility than its non-static data member types and bases,
3458 and class members default to the visibility of their class.  Also, a
3459 declaration without explicit visibility is limited to the visibility
3460 of its type.
3462 In C++, you can mark member functions and static member variables of a
3463 class with the visibility attribute.  This is useful if you know a
3464 particular method or static member variable should only be used from
3465 one shared object; then you can mark it hidden while the rest of the
3466 class has default visibility.  Care must be taken to avoid breaking
3467 the One Definition Rule; for example, it is usually not useful to mark
3468 an inline method as hidden without marking the whole class as hidden.
3470 A C++ namespace declaration can also have the visibility attribute.
3471 This attribute applies only to the particular namespace body, not to
3472 other definitions of the same namespace; it is equivalent to using
3473 @samp{#pragma GCC visibility} before and after the namespace
3474 definition (@pxref{Visibility Pragmas}).
3476 In C++, if a template argument has limited visibility, this
3477 restriction is implicitly propagated to the template instantiation.
3478 Otherwise, template instantiations and specializations default to the
3479 visibility of their template.
3481 If both the template and enclosing class have explicit visibility, the
3482 visibility from the template is used.
3484 @item vliw
3485 @cindex @code{vliw} attribute
3486 On MeP, the @code{vliw} attribute tells the compiler to emit
3487 instructions in VLIW mode instead of core mode.  Note that this
3488 attribute is not allowed unless a VLIW coprocessor has been configured
3489 and enabled through command line options.
3491 @item warn_unused_result
3492 @cindex @code{warn_unused_result} attribute
3493 The @code{warn_unused_result} attribute causes a warning to be emitted
3494 if a caller of the function with this attribute does not use its
3495 return value.  This is useful for functions where not checking
3496 the result is either a security problem or always a bug, such as
3497 @code{realloc}.
3499 @smallexample
3500 int fn () __attribute__ ((warn_unused_result));
3501 int foo ()
3503   if (fn () < 0) return -1;
3504   fn ();
3505   return 0;
3507 @end smallexample
3509 results in warning on line 5.
3511 @item weak
3512 @cindex @code{weak} attribute
3513 The @code{weak} attribute causes the declaration to be emitted as a weak
3514 symbol rather than a global.  This is primarily useful in defining
3515 library functions which can be overridden in user code, though it can
3516 also be used with non-function declarations.  Weak symbols are supported
3517 for ELF targets, and also for a.out targets when using the GNU assembler
3518 and linker.
3520 @item weakref
3521 @itemx weakref ("@var{target}")
3522 @cindex @code{weakref} attribute
3523 The @code{weakref} attribute marks a declaration as a weak reference.
3524 Without arguments, it should be accompanied by an @code{alias} attribute
3525 naming the target symbol.  Optionally, the @var{target} may be given as
3526 an argument to @code{weakref} itself.  In either case, @code{weakref}
3527 implicitly marks the declaration as @code{weak}.  Without a
3528 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3529 @code{weakref} is equivalent to @code{weak}.
3531 @smallexample
3532 static int x() __attribute__ ((weakref ("y")));
3533 /* is equivalent to... */
3534 static int x() __attribute__ ((weak, weakref, alias ("y")));
3535 /* and to... */
3536 static int x() __attribute__ ((weakref));
3537 static int x() __attribute__ ((alias ("y")));
3538 @end smallexample
3540 A weak reference is an alias that does not by itself require a
3541 definition to be given for the target symbol.  If the target symbol is
3542 only referenced through weak references, then it becomes a @code{weak}
3543 undefined symbol.  If it is directly referenced, however, then such
3544 strong references prevail, and a definition will be required for the
3545 symbol, not necessarily in the same translation unit.
3547 The effect is equivalent to moving all references to the alias to a
3548 separate translation unit, renaming the alias to the aliased symbol,
3549 declaring it as weak, compiling the two separate translation units and
3550 performing a reloadable link on them.
3552 At present, a declaration to which @code{weakref} is attached can
3553 only be @code{static}.
3555 @end table
3557 You can specify multiple attributes in a declaration by separating them
3558 by commas within the double parentheses or by immediately following an
3559 attribute declaration with another attribute declaration.
3561 @cindex @code{#pragma}, reason for not using
3562 @cindex pragma, reason for not using
3563 Some people object to the @code{__attribute__} feature, suggesting that
3564 ISO C's @code{#pragma} should be used instead.  At the time
3565 @code{__attribute__} was designed, there were two reasons for not doing
3566 this.
3568 @enumerate
3569 @item
3570 It is impossible to generate @code{#pragma} commands from a macro.
3572 @item
3573 There is no telling what the same @code{#pragma} might mean in another
3574 compiler.
3575 @end enumerate
3577 These two reasons applied to almost any application that might have been
3578 proposed for @code{#pragma}.  It was basically a mistake to use
3579 @code{#pragma} for @emph{anything}.
3581 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
3582 to be generated from macros.  In addition, a @code{#pragma GCC}
3583 namespace is now in use for GCC-specific pragmas.  However, it has been
3584 found convenient to use @code{__attribute__} to achieve a natural
3585 attachment of attributes to their corresponding declarations, whereas
3586 @code{#pragma GCC} is of use for constructs that do not naturally form
3587 part of the grammar.  @xref{Other Directives,,Miscellaneous
3588 Preprocessing Directives, cpp, The GNU C Preprocessor}.
3590 @node Attribute Syntax
3591 @section Attribute Syntax
3592 @cindex attribute syntax
3594 This section describes the syntax with which @code{__attribute__} may be
3595 used, and the constructs to which attribute specifiers bind, for the C
3596 language.  Some details may vary for C++ and Objective-C@.  Because of
3597 infelicities in the grammar for attributes, some forms described here
3598 may not be successfully parsed in all cases.
3600 There are some problems with the semantics of attributes in C++.  For
3601 example, there are no manglings for attributes, although they may affect
3602 code generation, so problems may arise when attributed types are used in
3603 conjunction with templates or overloading.  Similarly, @code{typeid}
3604 does not distinguish between types with different attributes.  Support
3605 for attributes in C++ may be restricted in future to attributes on
3606 declarations only, but not on nested declarators.
3608 @xref{Function Attributes}, for details of the semantics of attributes
3609 applying to functions.  @xref{Variable Attributes}, for details of the
3610 semantics of attributes applying to variables.  @xref{Type Attributes},
3611 for details of the semantics of attributes applying to structure, union
3612 and enumerated types.
3614 An @dfn{attribute specifier} is of the form
3615 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
3616 is a possibly empty comma-separated sequence of @dfn{attributes}, where
3617 each attribute is one of the following:
3619 @itemize @bullet
3620 @item
3621 Empty.  Empty attributes are ignored.
3623 @item
3624 A word (which may be an identifier such as @code{unused}, or a reserved
3625 word such as @code{const}).
3627 @item
3628 A word, followed by, in parentheses, parameters for the attribute.
3629 These parameters take one of the following forms:
3631 @itemize @bullet
3632 @item
3633 An identifier.  For example, @code{mode} attributes use this form.
3635 @item
3636 An identifier followed by a comma and a non-empty comma-separated list
3637 of expressions.  For example, @code{format} attributes use this form.
3639 @item
3640 A possibly empty comma-separated list of expressions.  For example,
3641 @code{format_arg} attributes use this form with the list being a single
3642 integer constant expression, and @code{alias} attributes use this form
3643 with the list being a single string constant.
3644 @end itemize
3645 @end itemize
3647 An @dfn{attribute specifier list} is a sequence of one or more attribute
3648 specifiers, not separated by any other tokens.
3650 In GNU C, an attribute specifier list may appear after the colon following a
3651 label, other than a @code{case} or @code{default} label.  The only
3652 attribute it makes sense to use after a label is @code{unused}.  This
3653 feature is intended for code generated by programs which contains labels
3654 that may be unused but which is compiled with @option{-Wall}.  It would
3655 not normally be appropriate to use in it human-written code, though it
3656 could be useful in cases where the code that jumps to the label is
3657 contained within an @code{#ifdef} conditional.  GNU C++ only permits
3658 attributes on labels if the attribute specifier is immediately
3659 followed by a semicolon (i.e., the label applies to an empty
3660 statement).  If the semicolon is missing, C++ label attributes are
3661 ambiguous, as it is permissible for a declaration, which could begin
3662 with an attribute list, to be labelled in C++.  Declarations cannot be
3663 labelled in C90 or C99, so the ambiguity does not arise there.
3665 An attribute specifier list may appear as part of a @code{struct},
3666 @code{union} or @code{enum} specifier.  It may go either immediately
3667 after the @code{struct}, @code{union} or @code{enum} keyword, or after
3668 the closing brace.  The former syntax is preferred.
3669 Where attribute specifiers follow the closing brace, they are considered
3670 to relate to the structure, union or enumerated type defined, not to any
3671 enclosing declaration the type specifier appears in, and the type
3672 defined is not complete until after the attribute specifiers.
3673 @c Otherwise, there would be the following problems: a shift/reduce
3674 @c conflict between attributes binding the struct/union/enum and
3675 @c binding to the list of specifiers/qualifiers; and "aligned"
3676 @c attributes could use sizeof for the structure, but the size could be
3677 @c changed later by "packed" attributes.
3679 Otherwise, an attribute specifier appears as part of a declaration,
3680 counting declarations of unnamed parameters and type names, and relates
3681 to that declaration (which may be nested in another declaration, for
3682 example in the case of a parameter declaration), or to a particular declarator
3683 within a declaration.  Where an
3684 attribute specifier is applied to a parameter declared as a function or
3685 an array, it should apply to the function or array rather than the
3686 pointer to which the parameter is implicitly converted, but this is not
3687 yet correctly implemented.
3689 Any list of specifiers and qualifiers at the start of a declaration may
3690 contain attribute specifiers, whether or not such a list may in that
3691 context contain storage class specifiers.  (Some attributes, however,
3692 are essentially in the nature of storage class specifiers, and only make
3693 sense where storage class specifiers may be used; for example,
3694 @code{section}.)  There is one necessary limitation to this syntax: the
3695 first old-style parameter declaration in a function definition cannot
3696 begin with an attribute specifier, because such an attribute applies to
3697 the function instead by syntax described below (which, however, is not
3698 yet implemented in this case).  In some other cases, attribute
3699 specifiers are permitted by this grammar but not yet supported by the
3700 compiler.  All attribute specifiers in this place relate to the
3701 declaration as a whole.  In the obsolescent usage where a type of
3702 @code{int} is implied by the absence of type specifiers, such a list of
3703 specifiers and qualifiers may be an attribute specifier list with no
3704 other specifiers or qualifiers.
3706 At present, the first parameter in a function prototype must have some
3707 type specifier which is not an attribute specifier; this resolves an
3708 ambiguity in the interpretation of @code{void f(int
3709 (__attribute__((foo)) x))}, but is subject to change.  At present, if
3710 the parentheses of a function declarator contain only attributes then
3711 those attributes are ignored, rather than yielding an error or warning
3712 or implying a single parameter of type int, but this is subject to
3713 change.
3715 An attribute specifier list may appear immediately before a declarator
3716 (other than the first) in a comma-separated list of declarators in a
3717 declaration of more than one identifier using a single list of
3718 specifiers and qualifiers.  Such attribute specifiers apply
3719 only to the identifier before whose declarator they appear.  For
3720 example, in
3722 @smallexample
3723 __attribute__((noreturn)) void d0 (void),
3724     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
3725      d2 (void)
3726 @end smallexample
3728 @noindent
3729 the @code{noreturn} attribute applies to all the functions
3730 declared; the @code{format} attribute only applies to @code{d1}.
3732 An attribute specifier list may appear immediately before the comma,
3733 @code{=} or semicolon terminating the declaration of an identifier other
3734 than a function definition.  Such attribute specifiers apply
3735 to the declared object or function.  Where an
3736 assembler name for an object or function is specified (@pxref{Asm
3737 Labels}), the attribute must follow the @code{asm}
3738 specification.
3740 An attribute specifier list may, in future, be permitted to appear after
3741 the declarator in a function definition (before any old-style parameter
3742 declarations or the function body).
3744 Attribute specifiers may be mixed with type qualifiers appearing inside
3745 the @code{[]} of a parameter array declarator, in the C99 construct by
3746 which such qualifiers are applied to the pointer to which the array is
3747 implicitly converted.  Such attribute specifiers apply to the pointer,
3748 not to the array, but at present this is not implemented and they are
3749 ignored.
3751 An attribute specifier list may appear at the start of a nested
3752 declarator.  At present, there are some limitations in this usage: the
3753 attributes correctly apply to the declarator, but for most individual
3754 attributes the semantics this implies are not implemented.
3755 When attribute specifiers follow the @code{*} of a pointer
3756 declarator, they may be mixed with any type qualifiers present.
3757 The following describes the formal semantics of this syntax.  It will make the
3758 most sense if you are familiar with the formal specification of
3759 declarators in the ISO C standard.
3761 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
3762 D1}, where @code{T} contains declaration specifiers that specify a type
3763 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
3764 contains an identifier @var{ident}.  The type specified for @var{ident}
3765 for derived declarators whose type does not include an attribute
3766 specifier is as in the ISO C standard.
3768 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
3769 and the declaration @code{T D} specifies the type
3770 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
3771 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
3772 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
3774 If @code{D1} has the form @code{*
3775 @var{type-qualifier-and-attribute-specifier-list} D}, and the
3776 declaration @code{T D} specifies the type
3777 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
3778 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
3779 @var{type-qualifier-and-attribute-specifier-list} @var{Type}'' for
3780 @var{ident}.
3782 For example,
3784 @smallexample
3785 void (__attribute__((noreturn)) ****f) (void);
3786 @end smallexample
3788 @noindent
3789 specifies the type ``pointer to pointer to pointer to pointer to
3790 non-returning function returning @code{void}''.  As another example,
3792 @smallexample
3793 char *__attribute__((aligned(8))) *f;
3794 @end smallexample
3796 @noindent
3797 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
3798 Note again that this does not work with most attributes; for example,
3799 the usage of @samp{aligned} and @samp{noreturn} attributes given above
3800 is not yet supported.
3802 For compatibility with existing code written for compiler versions that
3803 did not implement attributes on nested declarators, some laxity is
3804 allowed in the placing of attributes.  If an attribute that only applies
3805 to types is applied to a declaration, it will be treated as applying to
3806 the type of that declaration.  If an attribute that only applies to
3807 declarations is applied to the type of a declaration, it will be treated
3808 as applying to that declaration; and, for compatibility with code
3809 placing the attributes immediately before the identifier declared, such
3810 an attribute applied to a function return type will be treated as
3811 applying to the function type, and such an attribute applied to an array
3812 element type will be treated as applying to the array type.  If an
3813 attribute that only applies to function types is applied to a
3814 pointer-to-function type, it will be treated as applying to the pointer
3815 target type; if such an attribute is applied to a function return type
3816 that is not a pointer-to-function type, it will be treated as applying
3817 to the function type.
3819 @node Function Prototypes
3820 @section Prototypes and Old-Style Function Definitions
3821 @cindex function prototype declarations
3822 @cindex old-style function definitions
3823 @cindex promotion of formal parameters
3825 GNU C extends ISO C to allow a function prototype to override a later
3826 old-style non-prototype definition.  Consider the following example:
3828 @smallexample
3829 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
3830 #ifdef __STDC__
3831 #define P(x) x
3832 #else
3833 #define P(x) ()
3834 #endif
3836 /* @r{Prototype function declaration.}  */
3837 int isroot P((uid_t));
3839 /* @r{Old-style function definition.}  */
3841 isroot (x)   /* @r{??? lossage here ???} */
3842      uid_t x;
3844   return x == 0;
3846 @end smallexample
3848 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
3849 not allow this example, because subword arguments in old-style
3850 non-prototype definitions are promoted.  Therefore in this example the
3851 function definition's argument is really an @code{int}, which does not
3852 match the prototype argument type of @code{short}.
3854 This restriction of ISO C makes it hard to write code that is portable
3855 to traditional C compilers, because the programmer does not know
3856 whether the @code{uid_t} type is @code{short}, @code{int}, or
3857 @code{long}.  Therefore, in cases like these GNU C allows a prototype
3858 to override a later old-style definition.  More precisely, in GNU C, a
3859 function prototype argument type overrides the argument type specified
3860 by a later old-style definition if the former type is the same as the
3861 latter type before promotion.  Thus in GNU C the above example is
3862 equivalent to the following:
3864 @smallexample
3865 int isroot (uid_t);
3868 isroot (uid_t x)
3870   return x == 0;
3872 @end smallexample
3874 @noindent
3875 GNU C++ does not support old-style function definitions, so this
3876 extension is irrelevant.
3878 @node C++ Comments
3879 @section C++ Style Comments
3880 @cindex //
3881 @cindex C++ comments
3882 @cindex comments, C++ style
3884 In GNU C, you may use C++ style comments, which start with @samp{//} and
3885 continue until the end of the line.  Many other C implementations allow
3886 such comments, and they are included in the 1999 C standard.  However,
3887 C++ style comments are not recognized if you specify an @option{-std}
3888 option specifying a version of ISO C before C99, or @option{-ansi}
3889 (equivalent to @option{-std=c90}).
3891 @node Dollar Signs
3892 @section Dollar Signs in Identifier Names
3893 @cindex $
3894 @cindex dollar signs in identifier names
3895 @cindex identifier names, dollar signs in
3897 In GNU C, you may normally use dollar signs in identifier names.
3898 This is because many traditional C implementations allow such identifiers.
3899 However, dollar signs in identifiers are not supported on a few target
3900 machines, typically because the target assembler does not allow them.
3902 @node Character Escapes
3903 @section The Character @key{ESC} in Constants
3905 You can use the sequence @samp{\e} in a string or character constant to
3906 stand for the ASCII character @key{ESC}.
3908 @node Alignment
3909 @section Inquiring on Alignment of Types or Variables
3910 @cindex alignment
3911 @cindex type alignment
3912 @cindex variable alignment
3914 The keyword @code{__alignof__} allows you to inquire about how an object
3915 is aligned, or the minimum alignment usually required by a type.  Its
3916 syntax is just like @code{sizeof}.
3918 For example, if the target machine requires a @code{double} value to be
3919 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
3920 This is true on many RISC machines.  On more traditional machine
3921 designs, @code{__alignof__ (double)} is 4 or even 2.
3923 Some machines never actually require alignment; they allow reference to any
3924 data type even at an odd address.  For these machines, @code{__alignof__}
3925 reports the smallest alignment that GCC will give the data type, usually as
3926 mandated by the target ABI.
3928 If the operand of @code{__alignof__} is an lvalue rather than a type,
3929 its value is the required alignment for its type, taking into account
3930 any minimum alignment specified with GCC's @code{__attribute__}
3931 extension (@pxref{Variable Attributes}).  For example, after this
3932 declaration:
3934 @smallexample
3935 struct foo @{ int x; char y; @} foo1;
3936 @end smallexample
3938 @noindent
3939 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
3940 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
3942 It is an error to ask for the alignment of an incomplete type.
3944 @node Variable Attributes
3945 @section Specifying Attributes of Variables
3946 @cindex attribute of variables
3947 @cindex variable attributes
3949 The keyword @code{__attribute__} allows you to specify special
3950 attributes of variables or structure fields.  This keyword is followed
3951 by an attribute specification inside double parentheses.  Some
3952 attributes are currently defined generically for variables.
3953 Other attributes are defined for variables on particular target
3954 systems.  Other attributes are available for functions
3955 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
3956 Other front ends might define more attributes
3957 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
3959 You may also specify attributes with @samp{__} preceding and following
3960 each keyword.  This allows you to use them in header files without
3961 being concerned about a possible macro of the same name.  For example,
3962 you may use @code{__aligned__} instead of @code{aligned}.
3964 @xref{Attribute Syntax}, for details of the exact syntax for using
3965 attributes.
3967 @table @code
3968 @cindex @code{aligned} attribute
3969 @item aligned (@var{alignment})
3970 This attribute specifies a minimum alignment for the variable or
3971 structure field, measured in bytes.  For example, the declaration:
3973 @smallexample
3974 int x __attribute__ ((aligned (16))) = 0;
3975 @end smallexample
3977 @noindent
3978 causes the compiler to allocate the global variable @code{x} on a
3979 16-byte boundary.  On a 68040, this could be used in conjunction with
3980 an @code{asm} expression to access the @code{move16} instruction which
3981 requires 16-byte aligned operands.
3983 You can also specify the alignment of structure fields.  For example, to
3984 create a double-word aligned @code{int} pair, you could write:
3986 @smallexample
3987 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
3988 @end smallexample
3990 @noindent
3991 This is an alternative to creating a union with a @code{double} member
3992 that forces the union to be double-word aligned.
3994 As in the preceding examples, you can explicitly specify the alignment
3995 (in bytes) that you wish the compiler to use for a given variable or
3996 structure field.  Alternatively, you can leave out the alignment factor
3997 and just ask the compiler to align a variable or field to the
3998 default alignment for the target architecture you are compiling for.
3999 The default alignment is sufficient for all scalar types, but may not be
4000 enough for all vector types on a target which supports vector operations.
4001 The default alignment is fixed for a particular target ABI.
4003 Gcc also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4004 which is the largest alignment ever used for any data type on the
4005 target machine you are compiling for.  For example, you could write:
4007 @smallexample
4008 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4009 @end smallexample
4011 The compiler automatically sets the alignment for the declared
4012 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
4013 often make copy operations more efficient, because the compiler can
4014 use whatever instructions copy the biggest chunks of memory when
4015 performing copies to or from the variables or fields that you have
4016 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
4017 may change depending on command line options.
4019 When used on a struct, or struct member, the @code{aligned} attribute can
4020 only increase the alignment; in order to decrease it, the @code{packed}
4021 attribute must be specified as well.  When used as part of a typedef, the
4022 @code{aligned} attribute can both increase and decrease alignment, and
4023 specifying the @code{packed} attribute will generate a warning.
4025 Note that the effectiveness of @code{aligned} attributes may be limited
4026 by inherent limitations in your linker.  On many systems, the linker is
4027 only able to arrange for variables to be aligned up to a certain maximum
4028 alignment.  (For some linkers, the maximum supported alignment may
4029 be very very small.)  If your linker is only able to align variables
4030 up to a maximum of 8 byte alignment, then specifying @code{aligned(16)}
4031 in an @code{__attribute__} will still only provide you with 8 byte
4032 alignment.  See your linker documentation for further information.
4034 The @code{aligned} attribute can also be used for functions 
4035 (@pxref{Function Attributes}.)
4037 @item cleanup (@var{cleanup_function})
4038 @cindex @code{cleanup} attribute
4039 The @code{cleanup} attribute runs a function when the variable goes
4040 out of scope.  This attribute can only be applied to auto function
4041 scope variables; it may not be applied to parameters or variables
4042 with static storage duration.  The function must take one parameter,
4043 a pointer to a type compatible with the variable.  The return value
4044 of the function (if any) is ignored.
4046 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4047 will be run during the stack unwinding that happens during the
4048 processing of the exception.  Note that the @code{cleanup} attribute
4049 does not allow the exception to be caught, only to perform an action.
4050 It is undefined what happens if @var{cleanup_function} does not
4051 return normally.
4053 @item common
4054 @itemx nocommon
4055 @cindex @code{common} attribute
4056 @cindex @code{nocommon} attribute
4057 @opindex fcommon
4058 @opindex fno-common
4059 The @code{common} attribute requests GCC to place a variable in
4060 ``common'' storage.  The @code{nocommon} attribute requests the
4061 opposite---to allocate space for it directly.
4063 These attributes override the default chosen by the
4064 @option{-fno-common} and @option{-fcommon} flags respectively.
4066 @item deprecated
4067 @itemx deprecated (@var{msg})
4068 @cindex @code{deprecated} attribute
4069 The @code{deprecated} attribute results in a warning if the variable
4070 is used anywhere in the source file.  This is useful when identifying
4071 variables that are expected to be removed in a future version of a
4072 program.  The warning also includes the location of the declaration
4073 of the deprecated variable, to enable users to easily find further
4074 information about why the variable is deprecated, or what they should
4075 do instead.  Note that the warning only occurs for uses:
4077 @smallexample
4078 extern int old_var __attribute__ ((deprecated));
4079 extern int old_var;
4080 int new_fn () @{ return old_var; @}
4081 @end smallexample
4083 results in a warning on line 3 but not line 2.  The optional msg
4084 argument, which must be a string, will be printed in the warning if
4085 present.
4087 The @code{deprecated} attribute can also be used for functions and
4088 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4090 @item mode (@var{mode})
4091 @cindex @code{mode} attribute
4092 This attribute specifies the data type for the declaration---whichever
4093 type corresponds to the mode @var{mode}.  This in effect lets you
4094 request an integer or floating point type according to its width.
4096 You may also specify a mode of @samp{byte} or @samp{__byte__} to
4097 indicate the mode corresponding to a one-byte integer, @samp{word} or
4098 @samp{__word__} for the mode of a one-word integer, and @samp{pointer}
4099 or @samp{__pointer__} for the mode used to represent pointers.
4101 @item packed
4102 @cindex @code{packed} attribute
4103 The @code{packed} attribute specifies that a variable or structure field
4104 should have the smallest possible alignment---one byte for a variable,
4105 and one bit for a field, unless you specify a larger value with the
4106 @code{aligned} attribute.
4108 Here is a structure in which the field @code{x} is packed, so that it
4109 immediately follows @code{a}:
4111 @smallexample
4112 struct foo
4114   char a;
4115   int x[2] __attribute__ ((packed));
4117 @end smallexample
4119 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4120 @code{packed} attribute on bit-fields of type @code{char}.  This has
4121 been fixed in GCC 4.4 but the change can lead to differences in the
4122 structure layout.  See the documentation of
4123 @option{-Wpacked-bitfield-compat} for more information.
4125 @item section ("@var{section-name}")
4126 @cindex @code{section} variable attribute
4127 Normally, the compiler places the objects it generates in sections like
4128 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
4129 or you need certain particular variables to appear in special sections,
4130 for example to map to special hardware.  The @code{section}
4131 attribute specifies that a variable (or function) lives in a particular
4132 section.  For example, this small program uses several specific section names:
4134 @smallexample
4135 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4136 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4137 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4138 int init_data __attribute__ ((section ("INITDATA")));
4140 main()
4142   /* @r{Initialize stack pointer} */
4143   init_sp (stack + sizeof (stack));
4145   /* @r{Initialize initialized data} */
4146   memcpy (&init_data, &data, &edata - &data);
4148   /* @r{Turn on the serial ports} */
4149   init_duart (&a);
4150   init_duart (&b);
4152 @end smallexample
4154 @noindent
4155 Use the @code{section} attribute with
4156 @emph{global} variables and not @emph{local} variables,
4157 as shown in the example.
4159 You may use the @code{section} attribute with initialized or
4160 uninitialized global variables but the linker requires
4161 each object be defined once, with the exception that uninitialized
4162 variables tentatively go in the @code{common} (or @code{bss}) section
4163 and can be multiply ``defined''.  Using the @code{section} attribute
4164 will change what section the variable goes into and may cause the
4165 linker to issue an error if an uninitialized variable has multiple
4166 definitions.  You can force a variable to be initialized with the
4167 @option{-fno-common} flag or the @code{nocommon} attribute.
4169 Some file formats do not support arbitrary sections so the @code{section}
4170 attribute is not available on all platforms.
4171 If you need to map the entire contents of a module to a particular
4172 section, consider using the facilities of the linker instead.
4174 @item shared
4175 @cindex @code{shared} variable attribute
4176 On Microsoft Windows, in addition to putting variable definitions in a named
4177 section, the section can also be shared among all running copies of an
4178 executable or DLL@.  For example, this small program defines shared data
4179 by putting it in a named section @code{shared} and marking the section
4180 shareable:
4182 @smallexample
4183 int foo __attribute__((section ("shared"), shared)) = 0;
4186 main()
4188   /* @r{Read and write foo.  All running
4189      copies see the same value.}  */
4190   return 0;
4192 @end smallexample
4194 @noindent
4195 You may only use the @code{shared} attribute along with @code{section}
4196 attribute with a fully initialized global definition because of the way
4197 linkers work.  See @code{section} attribute for more information.
4199 The @code{shared} attribute is only available on Microsoft Windows@.
4201 @item tls_model ("@var{tls_model}")
4202 @cindex @code{tls_model} attribute
4203 The @code{tls_model} attribute sets thread-local storage model
4204 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4205 overriding @option{-ftls-model=} command-line switch on a per-variable
4206 basis.
4207 The @var{tls_model} argument should be one of @code{global-dynamic},
4208 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4210 Not all targets support this attribute.
4212 @item unused
4213 This attribute, attached to a variable, means that the variable is meant
4214 to be possibly unused.  GCC will not produce a warning for this
4215 variable.
4217 @item used
4218 This attribute, attached to a variable, means that the variable must be
4219 emitted even if it appears that the variable is not referenced.
4221 @item vector_size (@var{bytes})
4222 This attribute specifies the vector size for the variable, measured in
4223 bytes.  For example, the declaration:
4225 @smallexample
4226 int foo __attribute__ ((vector_size (16)));
4227 @end smallexample
4229 @noindent
4230 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4231 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
4232 4 units of 4 bytes), the corresponding mode of @code{foo} will be V4SI@.
4234 This attribute is only applicable to integral and float scalars,
4235 although arrays, pointers, and function return values are allowed in
4236 conjunction with this construct.
4238 Aggregates with this attribute are invalid, even if they are of the same
4239 size as a corresponding scalar.  For example, the declaration:
4241 @smallexample
4242 struct S @{ int a; @};
4243 struct S  __attribute__ ((vector_size (16))) foo;
4244 @end smallexample
4246 @noindent
4247 is invalid even if the size of the structure is the same as the size of
4248 the @code{int}.
4250 @item selectany
4251 The @code{selectany} attribute causes an initialized global variable to
4252 have link-once semantics.  When multiple definitions of the variable are
4253 encountered by the linker, the first is selected and the remainder are
4254 discarded.  Following usage by the Microsoft compiler, the linker is told
4255 @emph{not} to warn about size or content differences of the multiple
4256 definitions.
4258 Although the primary usage of this attribute is for POD types, the
4259 attribute can also be applied to global C++ objects that are initialized
4260 by a constructor.  In this case, the static initialization and destruction
4261 code for the object is emitted in each translation defining the object,
4262 but the calls to the constructor and destructor are protected by a
4263 link-once guard variable.
4265 The @code{selectany} attribute is only available on Microsoft Windows
4266 targets.  You can use @code{__declspec (selectany)} as a synonym for
4267 @code{__attribute__ ((selectany))} for compatibility with other
4268 compilers.
4270 @item weak
4271 The @code{weak} attribute is described in @ref{Function Attributes}.
4273 @item dllimport
4274 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4276 @item dllexport
4277 The @code{dllexport} attribute is described in @ref{Function Attributes}.
4279 @end table
4281 @subsection Blackfin Variable Attributes
4283 Three attributes are currently defined for the Blackfin.
4285 @table @code
4286 @item l1_data
4287 @itemx l1_data_A
4288 @itemx l1_data_B
4289 @cindex @code{l1_data} variable attribute
4290 @cindex @code{l1_data_A} variable attribute
4291 @cindex @code{l1_data_B} variable attribute
4292 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
4293 Variables with @code{l1_data} attribute will be put into the specific section
4294 named @code{.l1.data}. Those with @code{l1_data_A} attribute will be put into
4295 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
4296 attribute will be put into the specific section named @code{.l1.data.B}.
4298 @item l2
4299 @cindex @code{l2} variable attribute
4300 Use this attribute on the Blackfin to place the variable into L2 SRAM.
4301 Variables with @code{l2} attribute will be put into the specific section
4302 named @code{.l2.data}.
4303 @end table
4305 @subsection M32R/D Variable Attributes
4307 One attribute is currently defined for the M32R/D@.
4309 @table @code
4310 @item model (@var{model-name})
4311 @cindex variable addressability on the M32R/D
4312 Use this attribute on the M32R/D to set the addressability of an object.
4313 The identifier @var{model-name} is one of @code{small}, @code{medium},
4314 or @code{large}, representing each of the code models.
4316 Small model objects live in the lower 16MB of memory (so that their
4317 addresses can be loaded with the @code{ld24} instruction).
4319 Medium and large model objects may live anywhere in the 32-bit address space
4320 (the compiler will generate @code{seth/add3} instructions to load their
4321 addresses).
4322 @end table
4324 @anchor{MeP Variable Attributes}
4325 @subsection MeP Variable Attributes
4327 The MeP target has a number of addressing modes and busses.  The
4328 @code{near} space spans the standard memory space's first 16 megabytes
4329 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
4330 The @code{based} space is a 128 byte region in the memory space which
4331 is addressed relative to the @code{$tp} register.  The @code{tiny}
4332 space is a 65536 byte region relative to the @code{$gp} register.  In
4333 addition to these memory regions, the MeP target has a separate 16-bit
4334 control bus which is specified with @code{cb} attributes.
4336 @table @code
4338 @item based
4339 Any variable with the @code{based} attribute will be assigned to the
4340 @code{.based} section, and will be accessed with relative to the
4341 @code{$tp} register.
4343 @item tiny
4344 Likewise, the @code{tiny} attribute assigned variables to the
4345 @code{.tiny} section, relative to the @code{$gp} register.
4347 @item near
4348 Variables with the @code{near} attribute are assumed to have addresses
4349 that fit in a 24-bit addressing mode.  This is the default for large
4350 variables (@code{-mtiny=4} is the default) but this attribute can
4351 override @code{-mtiny=} for small variables, or override @code{-ml}.
4353 @item far
4354 Variables with the @code{far} attribute are addressed using a full
4355 32-bit address.  Since this covers the entire memory space, this
4356 allows modules to make no assumptions about where variables might be
4357 stored.
4359 @item io
4360 @itemx io (@var{addr})
4361 Variables with the @code{io} attribute are used to address
4362 memory-mapped peripherals.  If an address is specified, the variable
4363 is assigned that address, else it is not assigned an address (it is
4364 assumed some other module will assign an address).  Example:
4366 @example
4367 int timer_count __attribute__((io(0x123)));
4368 @end example
4370 @item cb
4371 @itemx cb (@var{addr})
4372 Variables with the @code{cb} attribute are used to access the control
4373 bus, using special instructions.  @code{addr} indicates the control bus
4374 address.  Example:
4376 @example
4377 int cpu_clock __attribute__((cb(0x123)));
4378 @end example
4380 @end table
4382 @anchor{i386 Variable Attributes}
4383 @subsection i386 Variable Attributes
4385 Two attributes are currently defined for i386 configurations:
4386 @code{ms_struct} and @code{gcc_struct}
4388 @table @code
4389 @item ms_struct
4390 @itemx gcc_struct
4391 @cindex @code{ms_struct} attribute
4392 @cindex @code{gcc_struct} attribute
4394 If @code{packed} is used on a structure, or if bit-fields are used
4395 it may be that the Microsoft ABI packs them differently
4396 than GCC would normally pack them.  Particularly when moving packed
4397 data between functions compiled with GCC and the native Microsoft compiler
4398 (either via function call or as data in a file), it may be necessary to access
4399 either format.
4401 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
4402 compilers to match the native Microsoft compiler.
4404 The Microsoft structure layout algorithm is fairly simple with the exception
4405 of the bitfield packing:
4407 The padding and alignment of members of structures and whether a bit field
4408 can straddle a storage-unit boundary
4410 @enumerate
4411 @item Structure members are stored sequentially in the order in which they are
4412 declared: the first member has the lowest memory address and the last member
4413 the highest.
4415 @item Every data object has an alignment-requirement. The alignment-requirement
4416 for all data except structures, unions, and arrays is either the size of the
4417 object or the current packing size (specified with either the aligned attribute
4418 or the pack pragma), whichever is less. For structures,  unions, and arrays,
4419 the alignment-requirement is the largest alignment-requirement of its members.
4420 Every object is allocated an offset so that:
4422 offset %  alignment-requirement == 0
4424 @item Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation
4425 unit if the integral types are the same size and if the next bit field fits
4426 into the current allocation unit without crossing the boundary imposed by the
4427 common alignment requirements of the bit fields.
4428 @end enumerate
4430 Handling of zero-length bitfields:
4432 MSVC interprets zero-length bitfields in the following ways:
4434 @enumerate
4435 @item If a zero-length bitfield is inserted between two bitfields that would
4436 normally be coalesced, the bitfields will not be coalesced.
4438 For example:
4440 @smallexample
4441 struct
4442  @{
4443    unsigned long bf_1 : 12;
4444    unsigned long : 0;
4445    unsigned long bf_2 : 12;
4446  @} t1;
4447 @end smallexample
4449 The size of @code{t1} would be 8 bytes with the zero-length bitfield.  If the
4450 zero-length bitfield were removed, @code{t1}'s size would be 4 bytes.
4452 @item If a zero-length bitfield is inserted after a bitfield, @code{foo}, and the
4453 alignment of the zero-length bitfield is greater than the member that follows it,
4454 @code{bar}, @code{bar} will be aligned as the type of the zero-length bitfield.
4456 For example:
4458 @smallexample
4459 struct
4460  @{
4461    char foo : 4;
4462    short : 0;
4463    char bar;
4464  @} t2;
4466 struct
4467  @{
4468    char foo : 4;
4469    short : 0;
4470    double bar;
4471  @} t3;
4472 @end smallexample
4474 For @code{t2}, @code{bar} will be placed at offset 2, rather than offset 1.
4475 Accordingly, the size of @code{t2} will be 4.  For @code{t3}, the zero-length
4476 bitfield will not affect the alignment of @code{bar} or, as a result, the size
4477 of the structure.
4479 Taking this into account, it is important to note the following:
4481 @enumerate
4482 @item If a zero-length bitfield follows a normal bitfield, the type of the
4483 zero-length bitfield may affect the alignment of the structure as whole. For
4484 example, @code{t2} has a size of 4 bytes, since the zero-length bitfield follows a
4485 normal bitfield, and is of type short.
4487 @item Even if a zero-length bitfield is not followed by a normal bitfield, it may
4488 still affect the alignment of the structure:
4490 @smallexample
4491 struct
4492  @{
4493    char foo : 6;
4494    long : 0;
4495  @} t4;
4496 @end smallexample
4498 Here, @code{t4} will take up 4 bytes.
4499 @end enumerate
4501 @item Zero-length bitfields following non-bitfield members are ignored:
4503 @smallexample
4504 struct
4505  @{
4506    char foo;
4507    long : 0;
4508    char bar;
4509  @} t5;
4510 @end smallexample
4512 Here, @code{t5} will take up 2 bytes.
4513 @end enumerate
4514 @end table
4516 @subsection PowerPC Variable Attributes
4518 Three attributes currently are defined for PowerPC configurations:
4519 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
4521 For full documentation of the struct attributes please see the
4522 documentation in @ref{i386 Variable Attributes}.
4524 For documentation of @code{altivec} attribute please see the
4525 documentation in @ref{PowerPC Type Attributes}.
4527 @subsection SPU Variable Attributes
4529 The SPU supports the @code{spu_vector} attribute for variables.  For
4530 documentation of this attribute please see the documentation in
4531 @ref{SPU Type Attributes}.
4533 @subsection Xstormy16 Variable Attributes
4535 One attribute is currently defined for xstormy16 configurations:
4536 @code{below100}.
4538 @table @code
4539 @item below100
4540 @cindex @code{below100} attribute
4542 If a variable has the @code{below100} attribute (@code{BELOW100} is
4543 allowed also), GCC will place the variable in the first 0x100 bytes of
4544 memory and use special opcodes to access it.  Such variables will be
4545 placed in either the @code{.bss_below100} section or the
4546 @code{.data_below100} section.
4548 @end table
4550 @subsection AVR Variable Attributes
4552 @table @code
4553 @item progmem
4554 @cindex @code{progmem} variable attribute
4555 The @code{progmem} attribute is used on the AVR to place data in the Program
4556 Memory address space. The AVR is a Harvard Architecture processor and data
4557 normally resides in the Data Memory address space.
4558 @end table
4560 @node Type Attributes
4561 @section Specifying Attributes of Types
4562 @cindex attribute of types
4563 @cindex type attributes
4565 The keyword @code{__attribute__} allows you to specify special
4566 attributes of @code{struct} and @code{union} types when you define
4567 such types.  This keyword is followed by an attribute specification
4568 inside double parentheses.  Seven attributes are currently defined for
4569 types: @code{aligned}, @code{packed}, @code{transparent_union},
4570 @code{unused}, @code{deprecated}, @code{visibility}, and
4571 @code{may_alias}.  Other attributes are defined for functions
4572 (@pxref{Function Attributes}) and for variables (@pxref{Variable
4573 Attributes}).
4575 You may also specify any one of these attributes with @samp{__}
4576 preceding and following its keyword.  This allows you to use these
4577 attributes in header files without being concerned about a possible
4578 macro of the same name.  For example, you may use @code{__aligned__}
4579 instead of @code{aligned}.
4581 You may specify type attributes in an enum, struct or union type
4582 declaration or definition, or for other types in a @code{typedef}
4583 declaration.
4585 For an enum, struct or union type, you may specify attributes either
4586 between the enum, struct or union tag and the name of the type, or
4587 just past the closing curly brace of the @emph{definition}.  The
4588 former syntax is preferred.
4590 @xref{Attribute Syntax}, for details of the exact syntax for using
4591 attributes.
4593 @table @code
4594 @cindex @code{aligned} attribute
4595 @item aligned (@var{alignment})
4596 This attribute specifies a minimum alignment (in bytes) for variables
4597 of the specified type.  For example, the declarations:
4599 @smallexample
4600 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
4601 typedef int more_aligned_int __attribute__ ((aligned (8)));
4602 @end smallexample
4604 @noindent
4605 force the compiler to insure (as far as it can) that each variable whose
4606 type is @code{struct S} or @code{more_aligned_int} will be allocated and
4607 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
4608 variables of type @code{struct S} aligned to 8-byte boundaries allows
4609 the compiler to use the @code{ldd} and @code{std} (doubleword load and
4610 store) instructions when copying one variable of type @code{struct S} to
4611 another, thus improving run-time efficiency.
4613 Note that the alignment of any given @code{struct} or @code{union} type
4614 is required by the ISO C standard to be at least a perfect multiple of
4615 the lowest common multiple of the alignments of all of the members of
4616 the @code{struct} or @code{union} in question.  This means that you @emph{can}
4617 effectively adjust the alignment of a @code{struct} or @code{union}
4618 type by attaching an @code{aligned} attribute to any one of the members
4619 of such a type, but the notation illustrated in the example above is a
4620 more obvious, intuitive, and readable way to request the compiler to
4621 adjust the alignment of an entire @code{struct} or @code{union} type.
4623 As in the preceding example, you can explicitly specify the alignment
4624 (in bytes) that you wish the compiler to use for a given @code{struct}
4625 or @code{union} type.  Alternatively, you can leave out the alignment factor
4626 and just ask the compiler to align a type to the maximum
4627 useful alignment for the target machine you are compiling for.  For
4628 example, you could write:
4630 @smallexample
4631 struct S @{ short f[3]; @} __attribute__ ((aligned));
4632 @end smallexample
4634 Whenever you leave out the alignment factor in an @code{aligned}
4635 attribute specification, the compiler automatically sets the alignment
4636 for the type to the largest alignment which is ever used for any data
4637 type on the target machine you are compiling for.  Doing this can often
4638 make copy operations more efficient, because the compiler can use
4639 whatever instructions copy the biggest chunks of memory when performing
4640 copies to or from the variables which have types that you have aligned
4641 this way.
4643 In the example above, if the size of each @code{short} is 2 bytes, then
4644 the size of the entire @code{struct S} type is 6 bytes.  The smallest
4645 power of two which is greater than or equal to that is 8, so the
4646 compiler sets the alignment for the entire @code{struct S} type to 8
4647 bytes.
4649 Note that although you can ask the compiler to select a time-efficient
4650 alignment for a given type and then declare only individual stand-alone
4651 objects of that type, the compiler's ability to select a time-efficient
4652 alignment is primarily useful only when you plan to create arrays of
4653 variables having the relevant (efficiently aligned) type.  If you
4654 declare or use arrays of variables of an efficiently-aligned type, then
4655 it is likely that your program will also be doing pointer arithmetic (or
4656 subscripting, which amounts to the same thing) on pointers to the
4657 relevant type, and the code that the compiler generates for these
4658 pointer arithmetic operations will often be more efficient for
4659 efficiently-aligned types than for other types.
4661 The @code{aligned} attribute can only increase the alignment; but you
4662 can decrease it by specifying @code{packed} as well.  See below.
4664 Note that the effectiveness of @code{aligned} attributes may be limited
4665 by inherent limitations in your linker.  On many systems, the linker is
4666 only able to arrange for variables to be aligned up to a certain maximum
4667 alignment.  (For some linkers, the maximum supported alignment may
4668 be very very small.)  If your linker is only able to align variables
4669 up to a maximum of 8 byte alignment, then specifying @code{aligned(16)}
4670 in an @code{__attribute__} will still only provide you with 8 byte
4671 alignment.  See your linker documentation for further information.
4673 @item packed
4674 This attribute, attached to @code{struct} or @code{union} type
4675 definition, specifies that each member (other than zero-width bitfields)
4676 of the structure or union is placed to minimize the memory required.  When
4677 attached to an @code{enum} definition, it indicates that the smallest
4678 integral type should be used.
4680 @opindex fshort-enums
4681 Specifying this attribute for @code{struct} and @code{union} types is
4682 equivalent to specifying the @code{packed} attribute on each of the
4683 structure or union members.  Specifying the @option{-fshort-enums}
4684 flag on the line is equivalent to specifying the @code{packed}
4685 attribute on all @code{enum} definitions.
4687 In the following example @code{struct my_packed_struct}'s members are
4688 packed closely together, but the internal layout of its @code{s} member
4689 is not packed---to do that, @code{struct my_unpacked_struct} would need to
4690 be packed too.
4692 @smallexample
4693 struct my_unpacked_struct
4694  @{
4695     char c;
4696     int i;
4697  @};
4699 struct __attribute__ ((__packed__)) my_packed_struct
4700   @{
4701      char c;
4702      int  i;
4703      struct my_unpacked_struct s;
4704   @};
4705 @end smallexample
4707 You may only specify this attribute on the definition of an @code{enum},
4708 @code{struct} or @code{union}, not on a @code{typedef} which does not
4709 also define the enumerated type, structure or union.
4711 @item transparent_union
4712 This attribute, attached to a @code{union} type definition, indicates
4713 that any function parameter having that union type causes calls to that
4714 function to be treated in a special way.
4716 First, the argument corresponding to a transparent union type can be of
4717 any type in the union; no cast is required.  Also, if the union contains
4718 a pointer type, the corresponding argument can be a null pointer
4719 constant or a void pointer expression; and if the union contains a void
4720 pointer type, the corresponding argument can be any pointer expression.
4721 If the union member type is a pointer, qualifiers like @code{const} on
4722 the referenced type must be respected, just as with normal pointer
4723 conversions.
4725 Second, the argument is passed to the function using the calling
4726 conventions of the first member of the transparent union, not the calling
4727 conventions of the union itself.  All members of the union must have the
4728 same machine representation; this is necessary for this argument passing
4729 to work properly.
4731 Transparent unions are designed for library functions that have multiple
4732 interfaces for compatibility reasons.  For example, suppose the
4733 @code{wait} function must accept either a value of type @code{int *} to
4734 comply with Posix, or a value of type @code{union wait *} to comply with
4735 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
4736 @code{wait} would accept both kinds of arguments, but it would also
4737 accept any other pointer type and this would make argument type checking
4738 less useful.  Instead, @code{<sys/wait.h>} might define the interface
4739 as follows:
4741 @smallexample
4742 typedef union __attribute__ ((__transparent_union__))
4743   @{
4744     int *__ip;
4745     union wait *__up;
4746   @} wait_status_ptr_t;
4748 pid_t wait (wait_status_ptr_t);
4749 @end smallexample
4751 This interface allows either @code{int *} or @code{union wait *}
4752 arguments to be passed, using the @code{int *} calling convention.
4753 The program can call @code{wait} with arguments of either type:
4755 @smallexample
4756 int w1 () @{ int w; return wait (&w); @}
4757 int w2 () @{ union wait w; return wait (&w); @}
4758 @end smallexample
4760 With this interface, @code{wait}'s implementation might look like this:
4762 @smallexample
4763 pid_t wait (wait_status_ptr_t p)
4765   return waitpid (-1, p.__ip, 0);
4767 @end smallexample
4769 @item unused
4770 When attached to a type (including a @code{union} or a @code{struct}),
4771 this attribute means that variables of that type are meant to appear
4772 possibly unused.  GCC will not produce a warning for any variables of
4773 that type, even if the variable appears to do nothing.  This is often
4774 the case with lock or thread classes, which are usually defined and then
4775 not referenced, but contain constructors and destructors that have
4776 nontrivial bookkeeping functions.
4778 @item deprecated
4779 @itemx deprecated (@var{msg})
4780 The @code{deprecated} attribute results in a warning if the type
4781 is used anywhere in the source file.  This is useful when identifying
4782 types that are expected to be removed in a future version of a program.
4783 If possible, the warning also includes the location of the declaration
4784 of the deprecated type, to enable users to easily find further
4785 information about why the type is deprecated, or what they should do
4786 instead.  Note that the warnings only occur for uses and then only
4787 if the type is being applied to an identifier that itself is not being
4788 declared as deprecated.
4790 @smallexample
4791 typedef int T1 __attribute__ ((deprecated));
4792 T1 x;
4793 typedef T1 T2;
4794 T2 y;
4795 typedef T1 T3 __attribute__ ((deprecated));
4796 T3 z __attribute__ ((deprecated));
4797 @end smallexample
4799 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
4800 warning is issued for line 4 because T2 is not explicitly
4801 deprecated.  Line 5 has no warning because T3 is explicitly
4802 deprecated.  Similarly for line 6.  The optional msg
4803 argument, which must be a string, will be printed in the warning if
4804 present.
4806 The @code{deprecated} attribute can also be used for functions and
4807 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
4809 @item may_alias
4810 Accesses through pointers to types with this attribute are not subject
4811 to type-based alias analysis, but are instead assumed to be able to alias
4812 any other type of objects.  In the context of 6.5/7 an lvalue expression
4813 dereferencing such a pointer is treated like having a character type.
4814 See @option{-fstrict-aliasing} for more information on aliasing issues.
4815 This extension exists to support some vector APIs, in which pointers to
4816 one vector type are permitted to alias pointers to a different vector type.
4818 Note that an object of a type with this attribute does not have any
4819 special semantics.
4821 Example of use:
4823 @smallexample
4824 typedef short __attribute__((__may_alias__)) short_a;
4827 main (void)
4829   int a = 0x12345678;
4830   short_a *b = (short_a *) &a;
4832   b[1] = 0;
4834   if (a == 0x12345678)
4835     abort();
4837   exit(0);
4839 @end smallexample
4841 If you replaced @code{short_a} with @code{short} in the variable
4842 declaration, the above program would abort when compiled with
4843 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
4844 above in recent GCC versions.
4846 @item visibility
4847 In C++, attribute visibility (@pxref{Function Attributes}) can also be
4848 applied to class, struct, union and enum types.  Unlike other type
4849 attributes, the attribute must appear between the initial keyword and
4850 the name of the type; it cannot appear after the body of the type.
4852 Note that the type visibility is applied to vague linkage entities
4853 associated with the class (vtable, typeinfo node, etc.).  In
4854 particular, if a class is thrown as an exception in one shared object
4855 and caught in another, the class must have default visibility.
4856 Otherwise the two shared objects will be unable to use the same
4857 typeinfo node and exception handling will break.
4859 @end table
4861 @subsection ARM Type Attributes
4863 On those ARM targets that support @code{dllimport} (such as Symbian
4864 OS), you can use the @code{notshared} attribute to indicate that the
4865 virtual table and other similar data for a class should not be
4866 exported from a DLL@.  For example:
4868 @smallexample
4869 class __declspec(notshared) C @{
4870 public:
4871   __declspec(dllimport) C();
4872   virtual void f();
4875 __declspec(dllexport)
4876 C::C() @{@}
4877 @end smallexample
4879 In this code, @code{C::C} is exported from the current DLL, but the
4880 virtual table for @code{C} is not exported.  (You can use
4881 @code{__attribute__} instead of @code{__declspec} if you prefer, but
4882 most Symbian OS code uses @code{__declspec}.)
4884 @anchor{MeP Type Attributes}
4885 @subsection MeP Type Attributes
4887 Many of the MeP variable attributes may be applied to types as well.
4888 Specifically, the @code{based}, @code{tiny}, @code{near}, and
4889 @code{far} attributes may be applied to either.  The @code{io} and
4890 @code{cb} attributes may not be applied to types.
4892 @anchor{i386 Type Attributes}
4893 @subsection i386 Type Attributes
4895 Two attributes are currently defined for i386 configurations:
4896 @code{ms_struct} and @code{gcc_struct}.
4898 @table @code
4900 @item ms_struct
4901 @itemx gcc_struct
4902 @cindex @code{ms_struct}
4903 @cindex @code{gcc_struct}
4905 If @code{packed} is used on a structure, or if bit-fields are used
4906 it may be that the Microsoft ABI packs them differently
4907 than GCC would normally pack them.  Particularly when moving packed
4908 data between functions compiled with GCC and the native Microsoft compiler
4909 (either via function call or as data in a file), it may be necessary to access
4910 either format.
4912 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
4913 compilers to match the native Microsoft compiler.
4914 @end table
4916 To specify multiple attributes, separate them by commas within the
4917 double parentheses: for example, @samp{__attribute__ ((aligned (16),
4918 packed))}.
4920 @anchor{PowerPC Type Attributes}
4921 @subsection PowerPC Type Attributes
4923 Three attributes currently are defined for PowerPC configurations:
4924 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
4926 For full documentation of the @code{ms_struct} and @code{gcc_struct} 
4927 attributes please see the documentation in @ref{i386 Type Attributes}.
4929 The @code{altivec} attribute allows one to declare AltiVec vector data
4930 types supported by the AltiVec Programming Interface Manual.  The
4931 attribute requires an argument to specify one of three vector types:
4932 @code{vector__}, @code{pixel__} (always followed by unsigned short),
4933 and @code{bool__} (always followed by unsigned).
4935 @smallexample
4936 __attribute__((altivec(vector__)))
4937 __attribute__((altivec(pixel__))) unsigned short
4938 __attribute__((altivec(bool__))) unsigned
4939 @end smallexample
4941 These attributes mainly are intended to support the @code{__vector},
4942 @code{__pixel}, and @code{__bool} AltiVec keywords.
4944 @anchor{SPU Type Attributes}
4945 @subsection SPU Type Attributes
4947 The SPU supports the @code{spu_vector} attribute for types.  This attribute
4948 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
4949 Language Extensions Specification.  It is intended to support the
4950 @code{__vector} keyword.
4953 @node Inline
4954 @section An Inline Function is As Fast As a Macro
4955 @cindex inline functions
4956 @cindex integrating function code
4957 @cindex open coding
4958 @cindex macros, inline alternative
4960 By declaring a function inline, you can direct GCC to make
4961 calls to that function faster.  One way GCC can achieve this is to
4962 integrate that function's code into the code for its callers.  This
4963 makes execution faster by eliminating the function-call overhead; in
4964 addition, if any of the actual argument values are constant, their
4965 known values may permit simplifications at compile time so that not
4966 all of the inline function's code needs to be included.  The effect on
4967 code size is less predictable; object code may be larger or smaller
4968 with function inlining, depending on the particular case.  You can
4969 also direct GCC to try to integrate all ``simple enough'' functions
4970 into their callers with the option @option{-finline-functions}.
4972 GCC implements three different semantics of declaring a function
4973 inline.  One is available with @option{-std=gnu89} or
4974 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
4975 on all inline declarations, another when
4976 @option{-std=c99}, @option{-std=c1x},
4977 @option{-std=gnu99} or @option{-std=gnu1x}
4978 (without @option{-fgnu89-inline}), and the third
4979 is used when compiling C++.
4981 To declare a function inline, use the @code{inline} keyword in its
4982 declaration, like this:
4984 @smallexample
4985 static inline int
4986 inc (int *a)
4988   return (*a)++;
4990 @end smallexample
4992 If you are writing a header file to be included in ISO C90 programs, write
4993 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
4995 The three types of inlining behave similarly in two important cases:
4996 when the @code{inline} keyword is used on a @code{static} function,
4997 like the example above, and when a function is first declared without
4998 using the @code{inline} keyword and then is defined with
4999 @code{inline}, like this:
5001 @smallexample
5002 extern int inc (int *a);
5003 inline int
5004 inc (int *a)
5006   return (*a)++;
5008 @end smallexample
5010 In both of these common cases, the program behaves the same as if you
5011 had not used the @code{inline} keyword, except for its speed.
5013 @cindex inline functions, omission of
5014 @opindex fkeep-inline-functions
5015 When a function is both inline and @code{static}, if all calls to the
5016 function are integrated into the caller, and the function's address is
5017 never used, then the function's own assembler code is never referenced.
5018 In this case, GCC does not actually output assembler code for the
5019 function, unless you specify the option @option{-fkeep-inline-functions}.
5020 Some calls cannot be integrated for various reasons (in particular,
5021 calls that precede the function's definition cannot be integrated, and
5022 neither can recursive calls within the definition).  If there is a
5023 nonintegrated call, then the function is compiled to assembler code as
5024 usual.  The function must also be compiled as usual if the program
5025 refers to its address, because that can't be inlined.
5027 @opindex Winline
5028 Note that certain usages in a function definition can make it unsuitable
5029 for inline substitution.  Among these usages are: use of varargs, use of
5030 alloca, use of variable sized data types (@pxref{Variable Length}),
5031 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5032 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
5033 will warn when a function marked @code{inline} could not be substituted,
5034 and will give the reason for the failure.
5036 @cindex automatic @code{inline} for C++ member fns
5037 @cindex @code{inline} automatic for C++ member fns
5038 @cindex member fns, automatically @code{inline}
5039 @cindex C++ member fns, automatically @code{inline}
5040 @opindex fno-default-inline
5041 As required by ISO C++, GCC considers member functions defined within
5042 the body of a class to be marked inline even if they are
5043 not explicitly declared with the @code{inline} keyword.  You can
5044 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5045 Options,,Options Controlling C++ Dialect}.
5047 GCC does not inline any functions when not optimizing unless you specify
5048 the @samp{always_inline} attribute for the function, like this:
5050 @smallexample
5051 /* @r{Prototype.}  */
5052 inline void foo (const char) __attribute__((always_inline));
5053 @end smallexample
5055 The remainder of this section is specific to GNU C90 inlining.
5057 @cindex non-static inline function
5058 When an inline function is not @code{static}, then the compiler must assume
5059 that there may be calls from other source files; since a global symbol can
5060 be defined only once in any program, the function must not be defined in
5061 the other source files, so the calls therein cannot be integrated.
5062 Therefore, a non-@code{static} inline function is always compiled on its
5063 own in the usual fashion.
5065 If you specify both @code{inline} and @code{extern} in the function
5066 definition, then the definition is used only for inlining.  In no case
5067 is the function compiled on its own, not even if you refer to its
5068 address explicitly.  Such an address becomes an external reference, as
5069 if you had only declared the function, and had not defined it.
5071 This combination of @code{inline} and @code{extern} has almost the
5072 effect of a macro.  The way to use it is to put a function definition in
5073 a header file with these keywords, and put another copy of the
5074 definition (lacking @code{inline} and @code{extern}) in a library file.
5075 The definition in the header file will cause most calls to the function
5076 to be inlined.  If any uses of the function remain, they will refer to
5077 the single copy in the library.
5079 @node Extended Asm
5080 @section Assembler Instructions with C Expression Operands
5081 @cindex extended @code{asm}
5082 @cindex @code{asm} expressions
5083 @cindex assembler instructions
5084 @cindex registers
5086 In an assembler instruction using @code{asm}, you can specify the
5087 operands of the instruction using C expressions.  This means you need not
5088 guess which registers or memory locations will contain the data you want
5089 to use.
5091 You must specify an assembler instruction template much like what
5092 appears in a machine description, plus an operand constraint string for
5093 each operand.
5095 For example, here is how to use the 68881's @code{fsinx} instruction:
5097 @smallexample
5098 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5099 @end smallexample
5101 @noindent
5102 Here @code{angle} is the C expression for the input operand while
5103 @code{result} is that of the output operand.  Each has @samp{"f"} as its
5104 operand constraint, saying that a floating point register is required.
5105 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5106 output operands' constraints must use @samp{=}.  The constraints use the
5107 same language used in the machine description (@pxref{Constraints}).
5109 Each operand is described by an operand-constraint string followed by
5110 the C expression in parentheses.  A colon separates the assembler
5111 template from the first output operand and another separates the last
5112 output operand from the first input, if any.  Commas separate the
5113 operands within each group.  The total number of operands is currently
5114 limited to 30; this limitation may be lifted in some future version of
5115 GCC@.
5117 If there are no output operands but there are input operands, you must
5118 place two consecutive colons surrounding the place where the output
5119 operands would go.
5121 As of GCC version 3.1, it is also possible to specify input and output
5122 operands using symbolic names which can be referenced within the
5123 assembler code.  These names are specified inside square brackets
5124 preceding the constraint string, and can be referenced inside the
5125 assembler code using @code{%[@var{name}]} instead of a percentage sign
5126 followed by the operand number.  Using named operands the above example
5127 could look like:
5129 @smallexample
5130 asm ("fsinx %[angle],%[output]"
5131      : [output] "=f" (result)
5132      : [angle] "f" (angle));
5133 @end smallexample
5135 @noindent
5136 Note that the symbolic operand names have no relation whatsoever to
5137 other C identifiers.  You may use any name you like, even those of
5138 existing C symbols, but you must ensure that no two operands within the same
5139 assembler construct use the same symbolic name.
5141 Output operand expressions must be lvalues; the compiler can check this.
5142 The input operands need not be lvalues.  The compiler cannot check
5143 whether the operands have data types that are reasonable for the
5144 instruction being executed.  It does not parse the assembler instruction
5145 template and does not know what it means or even whether it is valid
5146 assembler input.  The extended @code{asm} feature is most often used for
5147 machine instructions the compiler itself does not know exist.  If
5148 the output expression cannot be directly addressed (for example, it is a
5149 bit-field), your constraint must allow a register.  In that case, GCC
5150 will use the register as the output of the @code{asm}, and then store
5151 that register into the output.
5153 The ordinary output operands must be write-only; GCC will assume that
5154 the values in these operands before the instruction are dead and need
5155 not be generated.  Extended asm supports input-output or read-write
5156 operands.  Use the constraint character @samp{+} to indicate such an
5157 operand and list it with the output operands.  You should only use
5158 read-write operands when the constraints for the operand (or the
5159 operand in which only some of the bits are to be changed) allow a
5160 register.
5162 You may, as an alternative, logically split its function into two
5163 separate operands, one input operand and one write-only output
5164 operand.  The connection between them is expressed by constraints
5165 which say they need to be in the same location when the instruction
5166 executes.  You can use the same C expression for both operands, or
5167 different expressions.  For example, here we write the (fictitious)
5168 @samp{combine} instruction with @code{bar} as its read-only source
5169 operand and @code{foo} as its read-write destination:
5171 @smallexample
5172 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
5173 @end smallexample
5175 @noindent
5176 The constraint @samp{"0"} for operand 1 says that it must occupy the
5177 same location as operand 0.  A number in constraint is allowed only in
5178 an input operand and it must refer to an output operand.
5180 Only a number in the constraint can guarantee that one operand will be in
5181 the same place as another.  The mere fact that @code{foo} is the value
5182 of both operands is not enough to guarantee that they will be in the
5183 same place in the generated assembler code.  The following would not
5184 work reliably:
5186 @smallexample
5187 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
5188 @end smallexample
5190 Various optimizations or reloading could cause operands 0 and 1 to be in
5191 different registers; GCC knows no reason not to do so.  For example, the
5192 compiler might find a copy of the value of @code{foo} in one register and
5193 use it for operand 1, but generate the output operand 0 in a different
5194 register (copying it afterward to @code{foo}'s own address).  Of course,
5195 since the register for operand 1 is not even mentioned in the assembler
5196 code, the result will not work, but GCC can't tell that.
5198 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
5199 the operand number for a matching constraint.  For example:
5201 @smallexample
5202 asm ("cmoveq %1,%2,%[result]"
5203      : [result] "=r"(result)
5204      : "r" (test), "r"(new), "[result]"(old));
5205 @end smallexample
5207 Sometimes you need to make an @code{asm} operand be a specific register,
5208 but there's no matching constraint letter for that register @emph{by
5209 itself}.  To force the operand into that register, use a local variable
5210 for the operand and specify the register in the variable declaration.
5211 @xref{Explicit Reg Vars}.  Then for the @code{asm} operand, use any
5212 register constraint letter that matches the register:
5214 @smallexample
5215 register int *p1 asm ("r0") = @dots{};
5216 register int *p2 asm ("r1") = @dots{};
5217 register int *result asm ("r0");
5218 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5219 @end smallexample
5221 @anchor{Example of asm with clobbered asm reg}
5222 In the above example, beware that a register that is call-clobbered by
5223 the target ABI will be overwritten by any function call in the
5224 assignment, including library calls for arithmetic operators.
5225 Also a register may be clobbered when generating some operations,
5226 like variable shift, memory copy or memory move on x86.
5227 Assuming it is a call-clobbered register, this may happen to @code{r0}
5228 above by the assignment to @code{p2}.  If you have to use such a
5229 register, use temporary variables for expressions between the register
5230 assignment and use:
5232 @smallexample
5233 int t1 = @dots{};
5234 register int *p1 asm ("r0") = @dots{};
5235 register int *p2 asm ("r1") = t1;
5236 register int *result asm ("r0");
5237 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5238 @end smallexample
5240 Some instructions clobber specific hard registers.  To describe this,
5241 write a third colon after the input operands, followed by the names of
5242 the clobbered hard registers (given as strings).  Here is a realistic
5243 example for the VAX:
5245 @smallexample
5246 asm volatile ("movc3 %0,%1,%2"
5247               : /* @r{no outputs} */
5248               : "g" (from), "g" (to), "g" (count)
5249               : "r0", "r1", "r2", "r3", "r4", "r5");
5250 @end smallexample
5252 You may not write a clobber description in a way that overlaps with an
5253 input or output operand.  For example, you may not have an operand
5254 describing a register class with one member if you mention that register
5255 in the clobber list.  Variables declared to live in specific registers
5256 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
5257 have no part mentioned in the clobber description.
5258 There is no way for you to specify that an input
5259 operand is modified without also specifying it as an output
5260 operand.  Note that if all the output operands you specify are for this
5261 purpose (and hence unused), you will then also need to specify
5262 @code{volatile} for the @code{asm} construct, as described below, to
5263 prevent GCC from deleting the @code{asm} statement as unused.
5265 If you refer to a particular hardware register from the assembler code,
5266 you will probably have to list the register after the third colon to
5267 tell the compiler the register's value is modified.  In some assemblers,
5268 the register names begin with @samp{%}; to produce one @samp{%} in the
5269 assembler code, you must write @samp{%%} in the input.
5271 If your assembler instruction can alter the condition code register, add
5272 @samp{cc} to the list of clobbered registers.  GCC on some machines
5273 represents the condition codes as a specific hardware register;
5274 @samp{cc} serves to name this register.  On other machines, the
5275 condition code is handled differently, and specifying @samp{cc} has no
5276 effect.  But it is valid no matter what the machine.
5278 If your assembler instructions access memory in an unpredictable
5279 fashion, add @samp{memory} to the list of clobbered registers.  This
5280 will cause GCC to not keep memory values cached in registers across the
5281 assembler instruction and not optimize stores or loads to that memory.
5282 You will also want to add the @code{volatile} keyword if the memory
5283 affected is not listed in the inputs or outputs of the @code{asm}, as
5284 the @samp{memory} clobber does not count as a side-effect of the
5285 @code{asm}.  If you know how large the accessed memory is, you can add
5286 it as input or output but if this is not known, you should add
5287 @samp{memory}.  As an example, if you access ten bytes of a string, you
5288 can use a memory input like:
5290 @smallexample
5291 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
5292 @end smallexample
5294 Note that in the following example the memory input is necessary,
5295 otherwise GCC might optimize the store to @code{x} away:
5296 @smallexample
5297 int foo ()
5299   int x = 42;
5300   int *y = &x;
5301   int result;
5302   asm ("magic stuff accessing an 'int' pointed to by '%1'"
5303         "=&d" (r) : "a" (y), "m" (*y));
5304   return result;
5306 @end smallexample
5308 You can put multiple assembler instructions together in a single
5309 @code{asm} template, separated by the characters normally used in assembly
5310 code for the system.  A combination that works in most places is a newline
5311 to break the line, plus a tab character to move to the instruction field
5312 (written as @samp{\n\t}).  Sometimes semicolons can be used, if the
5313 assembler allows semicolons as a line-breaking character.  Note that some
5314 assembler dialects use semicolons to start a comment.
5315 The input operands are guaranteed not to use any of the clobbered
5316 registers, and neither will the output operands' addresses, so you can
5317 read and write the clobbered registers as many times as you like.  Here
5318 is an example of multiple instructions in a template; it assumes the
5319 subroutine @code{_foo} accepts arguments in registers 9 and 10:
5321 @smallexample
5322 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
5323      : /* no outputs */
5324      : "g" (from), "g" (to)
5325      : "r9", "r10");
5326 @end smallexample
5328 Unless an output operand has the @samp{&} constraint modifier, GCC
5329 may allocate it in the same register as an unrelated input operand, on
5330 the assumption the inputs are consumed before the outputs are produced.
5331 This assumption may be false if the assembler code actually consists of
5332 more than one instruction.  In such a case, use @samp{&} for each output
5333 operand that may not overlap an input.  @xref{Modifiers}.
5335 If you want to test the condition code produced by an assembler
5336 instruction, you must include a branch and a label in the @code{asm}
5337 construct, as follows:
5339 @smallexample
5340 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
5341      : "g" (result)
5342      : "g" (input));
5343 @end smallexample
5345 @noindent
5346 This assumes your assembler supports local labels, as the GNU assembler
5347 and most Unix assemblers do.
5349 Speaking of labels, jumps from one @code{asm} to another are not
5350 supported.  The compiler's optimizers do not know about these jumps, and
5351 therefore they cannot take account of them when deciding how to
5352 optimize.  @xref{Extended asm with goto}.
5354 @cindex macros containing @code{asm}
5355 Usually the most convenient way to use these @code{asm} instructions is to
5356 encapsulate them in macros that look like functions.  For example,
5358 @smallexample
5359 #define sin(x)       \
5360 (@{ double __value, __arg = (x);   \
5361    asm ("fsinx %1,%0": "=f" (__value): "f" (__arg));  \
5362    __value; @})
5363 @end smallexample
5365 @noindent
5366 Here the variable @code{__arg} is used to make sure that the instruction
5367 operates on a proper @code{double} value, and to accept only those
5368 arguments @code{x} which can convert automatically to a @code{double}.
5370 Another way to make sure the instruction operates on the correct data
5371 type is to use a cast in the @code{asm}.  This is different from using a
5372 variable @code{__arg} in that it converts more different types.  For
5373 example, if the desired type were @code{int}, casting the argument to
5374 @code{int} would accept a pointer with no complaint, while assigning the
5375 argument to an @code{int} variable named @code{__arg} would warn about
5376 using a pointer unless the caller explicitly casts it.
5378 If an @code{asm} has output operands, GCC assumes for optimization
5379 purposes the instruction has no side effects except to change the output
5380 operands.  This does not mean instructions with a side effect cannot be
5381 used, but you must be careful, because the compiler may eliminate them
5382 if the output operands aren't used, or move them out of loops, or
5383 replace two with one if they constitute a common subexpression.  Also,
5384 if your instruction does have a side effect on a variable that otherwise
5385 appears not to change, the old value of the variable may be reused later
5386 if it happens to be found in a register.
5388 You can prevent an @code{asm} instruction from being deleted
5389 by writing the keyword @code{volatile} after
5390 the @code{asm}.  For example:
5392 @smallexample
5393 #define get_and_set_priority(new)              \
5394 (@{ int __old;                                  \
5395    asm volatile ("get_and_set_priority %0, %1" \
5396                  : "=g" (__old) : "g" (new));  \
5397    __old; @})
5398 @end smallexample
5400 @noindent
5401 The @code{volatile} keyword indicates that the instruction has
5402 important side-effects.  GCC will not delete a volatile @code{asm} if
5403 it is reachable.  (The instruction can still be deleted if GCC can
5404 prove that control-flow will never reach the location of the
5405 instruction.)  Note that even a volatile @code{asm} instruction
5406 can be moved relative to other code, including across jump
5407 instructions.  For example, on many targets there is a system
5408 register which can be set to control the rounding mode of
5409 floating point operations.  You might try
5410 setting it with a volatile @code{asm}, like this PowerPC example:
5412 @smallexample
5413        asm volatile("mtfsf 255,%0" : : "f" (fpenv));
5414        sum = x + y;
5415 @end smallexample
5417 @noindent
5418 This will not work reliably, as the compiler may move the addition back
5419 before the volatile @code{asm}.  To make it work you need to add an
5420 artificial dependency to the @code{asm} referencing a variable in the code
5421 you don't want moved, for example:
5423 @smallexample
5424     asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
5425     sum = x + y;
5426 @end smallexample
5428 Similarly, you can't expect a
5429 sequence of volatile @code{asm} instructions to remain perfectly
5430 consecutive.  If you want consecutive output, use a single @code{asm}.
5431 Also, GCC will perform some optimizations across a volatile @code{asm}
5432 instruction; GCC does not ``forget everything'' when it encounters
5433 a volatile @code{asm} instruction the way some other compilers do.
5435 An @code{asm} instruction without any output operands will be treated
5436 identically to a volatile @code{asm} instruction.
5438 It is a natural idea to look for a way to give access to the condition
5439 code left by the assembler instruction.  However, when we attempted to
5440 implement this, we found no way to make it work reliably.  The problem
5441 is that output operands might need reloading, which would result in
5442 additional following ``store'' instructions.  On most machines, these
5443 instructions would alter the condition code before there was time to
5444 test it.  This problem doesn't arise for ordinary ``test'' and
5445 ``compare'' instructions because they don't have any output operands.
5447 For reasons similar to those described above, it is not possible to give
5448 an assembler instruction access to the condition code left by previous
5449 instructions.
5451 @anchor{Extended asm with goto}
5452 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
5453 jump to one or more C labels.  In this form, a fifth section after the
5454 clobber list contains a list of all C labels to which the assembly may jump.
5455 Each label operand is implicitly self-named.  The @code{asm} is also assumed
5456 to fall through to the next statement.
5458 This form of @code{asm} is restricted to not have outputs.  This is due
5459 to a internal restriction in the compiler that control transfer instructions
5460 cannot have outputs.  This restriction on @code{asm goto} may be lifted
5461 in some future version of the compiler.  In the mean time, @code{asm goto}
5462 may include a memory clobber, and so leave outputs in memory.
5464 @smallexample
5465 int frob(int x)
5467   int y;
5468   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
5469             : : "r"(x), "r"(&y) : "r5", "memory" : error);
5470   return y;
5471  error:
5472   return -1;
5474 @end smallexample
5476 In this (inefficient) example, the @code{frob} instruction sets the
5477 carry bit to indicate an error.  The @code{jc} instruction detects
5478 this and branches to the @code{error} label.  Finally, the output 
5479 of the @code{frob} instruction (@code{%r5}) is stored into the memory
5480 for variable @code{y}, which is later read by the @code{return} statement.
5482 @smallexample
5483 void doit(void)
5485   int i = 0;
5486   asm goto ("mfsr %%r1, 123; jmp %%r1;"
5487             ".pushsection doit_table;"
5488             ".long %l0, %l1, %l2, %l3;"
5489             ".popsection"
5490             : : : "r1" : label1, label2, label3, label4);
5491   __builtin_unreachable ();
5493  label1:
5494   f1();
5495   return;
5496  label2:
5497   f2();
5498   return;
5499  label3:
5500   i = 1;
5501  label4:
5502   f3(i);
5504 @end smallexample
5506 In this (also inefficient) example, the @code{mfsr} instruction reads
5507 an address from some out-of-band machine register, and the following
5508 @code{jmp} instruction branches to that address.  The address read by
5509 the @code{mfsr} instruction is assumed to have been previously set via
5510 some application-specific mechanism to be one of the four values stored
5511 in the @code{doit_table} section.  Finally, the @code{asm} is followed
5512 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
5513 does not in fact fall through.
5515 @smallexample
5516 #define TRACE1(NUM)                         \
5517   do @{                                      \
5518     asm goto ("0: nop;"                     \
5519               ".pushsection trace_table;"   \
5520               ".long 0b, %l0;"              \
5521               ".popsection"                 \
5522               : : : : trace#NUM);           \
5523     if (0) @{ trace#NUM: trace(); @}          \
5524   @} while (0)
5525 #define TRACE  TRACE1(__COUNTER__)
5526 @end smallexample
5528 In this example (which in fact inspired the @code{asm goto} feature)
5529 we want on rare occasions to call the @code{trace} function; on other
5530 occasions we'd like to keep the overhead to the absolute minimum.
5531 The normal code path consists of a single @code{nop} instruction.
5532 However, we record the address of this @code{nop} together with the
5533 address of a label that calls the @code{trace} function.  This allows
5534 the @code{nop} instruction to be patched at runtime to be an 
5535 unconditional branch to the stored label.  It is assumed that an
5536 optimizing compiler will move the labeled block out of line, to
5537 optimize the fall through path from the @code{asm}.
5539 If you are writing a header file that should be includable in ISO C
5540 programs, write @code{__asm__} instead of @code{asm}.  @xref{Alternate
5541 Keywords}.
5543 @subsection Size of an @code{asm}
5545 Some targets require that GCC track the size of each instruction used in
5546 order to generate correct code.  Because the final length of an
5547 @code{asm} is only known by the assembler, GCC must make an estimate as
5548 to how big it will be.  The estimate is formed by counting the number of
5549 statements in the pattern of the @code{asm} and multiplying that by the
5550 length of the longest instruction on that processor.  Statements in the
5551 @code{asm} are identified by newline characters and whatever statement
5552 separator characters are supported by the assembler; on most processors
5553 this is the `@code{;}' character.
5555 Normally, GCC's estimate is perfectly adequate to ensure that correct
5556 code is generated, but it is possible to confuse the compiler if you use
5557 pseudo instructions or assembler macros that expand into multiple real
5558 instructions or if you use assembler directives that expand to more
5559 space in the object file than would be needed for a single instruction.
5560 If this happens then the assembler will produce a diagnostic saying that
5561 a label is unreachable.
5563 @subsection i386 floating point asm operands
5565 There are several rules on the usage of stack-like regs in
5566 asm_operands insns.  These rules apply only to the operands that are
5567 stack-like regs:
5569 @enumerate
5570 @item
5571 Given a set of input regs that die in an asm_operands, it is
5572 necessary to know which are implicitly popped by the asm, and
5573 which must be explicitly popped by gcc.
5575 An input reg that is implicitly popped by the asm must be
5576 explicitly clobbered, unless it is constrained to match an
5577 output operand.
5579 @item
5580 For any input reg that is implicitly popped by an asm, it is
5581 necessary to know how to adjust the stack to compensate for the pop.
5582 If any non-popped input is closer to the top of the reg-stack than
5583 the implicitly popped reg, it would not be possible to know what the
5584 stack looked like---it's not clear how the rest of the stack ``slides
5585 up''.
5587 All implicitly popped input regs must be closer to the top of
5588 the reg-stack than any input that is not implicitly popped.
5590 It is possible that if an input dies in an insn, reload might
5591 use the input reg for an output reload.  Consider this example:
5593 @smallexample
5594 asm ("foo" : "=t" (a) : "f" (b));
5595 @end smallexample
5597 This asm says that input B is not popped by the asm, and that
5598 the asm pushes a result onto the reg-stack, i.e., the stack is one
5599 deeper after the asm than it was before.  But, it is possible that
5600 reload will think that it can use the same reg for both the input and
5601 the output, if input B dies in this insn.
5603 If any input operand uses the @code{f} constraint, all output reg
5604 constraints must use the @code{&} earlyclobber.
5606 The asm above would be written as
5608 @smallexample
5609 asm ("foo" : "=&t" (a) : "f" (b));
5610 @end smallexample
5612 @item
5613 Some operands need to be in particular places on the stack.  All
5614 output operands fall in this category---there is no other way to
5615 know which regs the outputs appear in unless the user indicates
5616 this in the constraints.
5618 Output operands must specifically indicate which reg an output
5619 appears in after an asm.  @code{=f} is not allowed: the operand
5620 constraints must select a class with a single reg.
5622 @item
5623 Output operands may not be ``inserted'' between existing stack regs.
5624 Since no 387 opcode uses a read/write operand, all output operands
5625 are dead before the asm_operands, and are pushed by the asm_operands.
5626 It makes no sense to push anywhere but the top of the reg-stack.
5628 Output operands must start at the top of the reg-stack: output
5629 operands may not ``skip'' a reg.
5631 @item
5632 Some asm statements may need extra stack space for internal
5633 calculations.  This can be guaranteed by clobbering stack registers
5634 unrelated to the inputs and outputs.
5636 @end enumerate
5638 Here are a couple of reasonable asms to want to write.  This asm
5639 takes one input, which is internally popped, and produces two outputs.
5641 @smallexample
5642 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
5643 @end smallexample
5645 This asm takes two inputs, which are popped by the @code{fyl2xp1} opcode,
5646 and replaces them with one output.  The user must code the @code{st(1)}
5647 clobber for reg-stack.c to know that @code{fyl2xp1} pops both inputs.
5649 @smallexample
5650 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
5651 @end smallexample
5653 @include md.texi
5655 @node Asm Labels
5656 @section Controlling Names Used in Assembler Code
5657 @cindex assembler names for identifiers
5658 @cindex names used in assembler code
5659 @cindex identifiers, names in assembler code
5661 You can specify the name to be used in the assembler code for a C
5662 function or variable by writing the @code{asm} (or @code{__asm__})
5663 keyword after the declarator as follows:
5665 @smallexample
5666 int foo asm ("myfoo") = 2;
5667 @end smallexample
5669 @noindent
5670 This specifies that the name to be used for the variable @code{foo} in
5671 the assembler code should be @samp{myfoo} rather than the usual
5672 @samp{_foo}.
5674 On systems where an underscore is normally prepended to the name of a C
5675 function or variable, this feature allows you to define names for the
5676 linker that do not start with an underscore.
5678 It does not make sense to use this feature with a non-static local
5679 variable since such variables do not have assembler names.  If you are
5680 trying to put the variable in a particular register, see @ref{Explicit
5681 Reg Vars}.  GCC presently accepts such code with a warning, but will
5682 probably be changed to issue an error, rather than a warning, in the
5683 future.
5685 You cannot use @code{asm} in this way in a function @emph{definition}; but
5686 you can get the same effect by writing a declaration for the function
5687 before its definition and putting @code{asm} there, like this:
5689 @smallexample
5690 extern func () asm ("FUNC");
5692 func (x, y)
5693      int x, y;
5694 /* @r{@dots{}} */
5695 @end smallexample
5697 It is up to you to make sure that the assembler names you choose do not
5698 conflict with any other assembler symbols.  Also, you must not use a
5699 register name; that would produce completely invalid assembler code.  GCC
5700 does not as yet have the ability to store static variables in registers.
5701 Perhaps that will be added.
5703 @node Explicit Reg Vars
5704 @section Variables in Specified Registers
5705 @cindex explicit register variables
5706 @cindex variables in specified registers
5707 @cindex specified registers
5708 @cindex registers, global allocation
5710 GNU C allows you to put a few global variables into specified hardware
5711 registers.  You can also specify the register in which an ordinary
5712 register variable should be allocated.
5714 @itemize @bullet
5715 @item
5716 Global register variables reserve registers throughout the program.
5717 This may be useful in programs such as programming language
5718 interpreters which have a couple of global variables that are accessed
5719 very often.
5721 @item
5722 Local register variables in specific registers do not reserve the
5723 registers, except at the point where they are used as input or output
5724 operands in an @code{asm} statement and the @code{asm} statement itself is
5725 not deleted.  The compiler's data flow analysis is capable of determining
5726 where the specified registers contain live values, and where they are
5727 available for other uses.  Stores into local register variables may be deleted
5728 when they appear to be dead according to dataflow analysis.  References
5729 to local register variables may be deleted or moved or simplified.
5731 These local variables are sometimes convenient for use with the extended
5732 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
5733 output of the assembler instruction directly into a particular register.
5734 (This will work provided the register you specify fits the constraints
5735 specified for that operand in the @code{asm}.)
5736 @end itemize
5738 @menu
5739 * Global Reg Vars::
5740 * Local Reg Vars::
5741 @end menu
5743 @node Global Reg Vars
5744 @subsection Defining Global Register Variables
5745 @cindex global register variables
5746 @cindex registers, global variables in
5748 You can define a global register variable in GNU C like this:
5750 @smallexample
5751 register int *foo asm ("a5");
5752 @end smallexample
5754 @noindent
5755 Here @code{a5} is the name of the register which should be used.  Choose a
5756 register which is normally saved and restored by function calls on your
5757 machine, so that library routines will not clobber it.
5759 Naturally the register name is cpu-dependent, so you would need to
5760 conditionalize your program according to cpu type.  The register
5761 @code{a5} would be a good choice on a 68000 for a variable of pointer
5762 type.  On machines with register windows, be sure to choose a ``global''
5763 register that is not affected magically by the function call mechanism.
5765 In addition, operating systems on one type of cpu may differ in how they
5766 name the registers; then you would need additional conditionals.  For
5767 example, some 68000 operating systems call this register @code{%a5}.
5769 Eventually there may be a way of asking the compiler to choose a register
5770 automatically, but first we need to figure out how it should choose and
5771 how to enable you to guide the choice.  No solution is evident.
5773 Defining a global register variable in a certain register reserves that
5774 register entirely for this use, at least within the current compilation.
5775 The register will not be allocated for any other purpose in the functions
5776 in the current compilation.  The register will not be saved and restored by
5777 these functions.  Stores into this register are never deleted even if they
5778 would appear to be dead, but references may be deleted or moved or
5779 simplified.
5781 It is not safe to access the global register variables from signal
5782 handlers, or from more than one thread of control, because the system
5783 library routines may temporarily use the register for other things (unless
5784 you recompile them specially for the task at hand).
5786 @cindex @code{qsort}, and global register variables
5787 It is not safe for one function that uses a global register variable to
5788 call another such function @code{foo} by way of a third function
5789 @code{lose} that was compiled without knowledge of this variable (i.e.@: in a
5790 different source file in which the variable wasn't declared).  This is
5791 because @code{lose} might save the register and put some other value there.
5792 For example, you can't expect a global register variable to be available in
5793 the comparison-function that you pass to @code{qsort}, since @code{qsort}
5794 might have put something else in that register.  (If you are prepared to
5795 recompile @code{qsort} with the same global register variable, you can
5796 solve this problem.)
5798 If you want to recompile @code{qsort} or other source files which do not
5799 actually use your global register variable, so that they will not use that
5800 register for any other purpose, then it suffices to specify the compiler
5801 option @option{-ffixed-@var{reg}}.  You need not actually add a global
5802 register declaration to their source code.
5804 A function which can alter the value of a global register variable cannot
5805 safely be called from a function compiled without this variable, because it
5806 could clobber the value the caller expects to find there on return.
5807 Therefore, the function which is the entry point into the part of the
5808 program that uses the global register variable must explicitly save and
5809 restore the value which belongs to its caller.
5811 @cindex register variable after @code{longjmp}
5812 @cindex global register after @code{longjmp}
5813 @cindex value after @code{longjmp}
5814 @findex longjmp
5815 @findex setjmp
5816 On most machines, @code{longjmp} will restore to each global register
5817 variable the value it had at the time of the @code{setjmp}.  On some
5818 machines, however, @code{longjmp} will not change the value of global
5819 register variables.  To be portable, the function that called @code{setjmp}
5820 should make other arrangements to save the values of the global register
5821 variables, and to restore them in a @code{longjmp}.  This way, the same
5822 thing will happen regardless of what @code{longjmp} does.
5824 All global register variable declarations must precede all function
5825 definitions.  If such a declaration could appear after function
5826 definitions, the declaration would be too late to prevent the register from
5827 being used for other purposes in the preceding functions.
5829 Global register variables may not have initial values, because an
5830 executable file has no means to supply initial contents for a register.
5832 On the SPARC, there are reports that g3 @dots{} g7 are suitable
5833 registers, but certain library functions, such as @code{getwd}, as well
5834 as the subroutines for division and remainder, modify g3 and g4.  g1 and
5835 g2 are local temporaries.
5837 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
5838 Of course, it will not do to use more than a few of those.
5840 @node Local Reg Vars
5841 @subsection Specifying Registers for Local Variables
5842 @cindex local variables, specifying registers
5843 @cindex specifying registers for local variables
5844 @cindex registers for local variables
5846 You can define a local register variable with a specified register
5847 like this:
5849 @smallexample
5850 register int *foo asm ("a5");
5851 @end smallexample
5853 @noindent
5854 Here @code{a5} is the name of the register which should be used.  Note
5855 that this is the same syntax used for defining global register
5856 variables, but for a local variable it would appear within a function.
5858 Naturally the register name is cpu-dependent, but this is not a
5859 problem, since specific registers are most often useful with explicit
5860 assembler instructions (@pxref{Extended Asm}).  Both of these things
5861 generally require that you conditionalize your program according to
5862 cpu type.
5864 In addition, operating systems on one type of cpu may differ in how they
5865 name the registers; then you would need additional conditionals.  For
5866 example, some 68000 operating systems call this register @code{%a5}.
5868 Defining such a register variable does not reserve the register; it
5869 remains available for other uses in places where flow control determines
5870 the variable's value is not live.
5872 This option does not guarantee that GCC will generate code that has
5873 this variable in the register you specify at all times.  You may not
5874 code an explicit reference to this register in the @emph{assembler
5875 instruction template} part of an @code{asm} statement and assume it will
5876 always refer to this variable.  However, using the variable as an
5877 @code{asm} @emph{operand} guarantees that the specified register is used
5878 for the operand.
5880 Stores into local register variables may be deleted when they appear to be dead
5881 according to dataflow analysis.  References to local register variables may
5882 be deleted or moved or simplified.
5884 As for global register variables, it's recommended that you choose a
5885 register which is normally saved and restored by function calls on
5886 your machine, so that library routines will not clobber it.  A common
5887 pitfall is to initialize multiple call-clobbered registers with
5888 arbitrary expressions, where a function call or library call for an
5889 arithmetic operator will overwrite a register value from a previous
5890 assignment, for example @code{r0} below:
5891 @smallexample
5892 register int *p1 asm ("r0") = @dots{};
5893 register int *p2 asm ("r1") = @dots{};
5894 @end smallexample
5895 In those cases, a solution is to use a temporary variable for
5896 each arbitrary expression.   @xref{Example of asm with clobbered asm reg}.
5898 @node Alternate Keywords
5899 @section Alternate Keywords
5900 @cindex alternate keywords
5901 @cindex keywords, alternate
5903 @option{-ansi} and the various @option{-std} options disable certain
5904 keywords.  This causes trouble when you want to use GNU C extensions, or
5905 a general-purpose header file that should be usable by all programs,
5906 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
5907 @code{inline} are not available in programs compiled with
5908 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
5909 program compiled with @option{-std=c99} or @option{-std=c1x}).  The
5910 ISO C99 keyword
5911 @code{restrict} is only available when @option{-std=gnu99} (which will
5912 eventually be the default) or @option{-std=c99} (or the equivalent
5913 @option{-std=iso9899:1999}), or an option for a later standard
5914 version, is used.
5916 The way to solve these problems is to put @samp{__} at the beginning and
5917 end of each problematical keyword.  For example, use @code{__asm__}
5918 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
5920 Other C compilers won't accept these alternative keywords; if you want to
5921 compile with another compiler, you can define the alternate keywords as
5922 macros to replace them with the customary keywords.  It looks like this:
5924 @smallexample
5925 #ifndef __GNUC__
5926 #define __asm__ asm
5927 #endif
5928 @end smallexample
5930 @findex __extension__
5931 @opindex pedantic
5932 @option{-pedantic} and other options cause warnings for many GNU C extensions.
5933 You can
5934 prevent such warnings within one expression by writing
5935 @code{__extension__} before the expression.  @code{__extension__} has no
5936 effect aside from this.
5938 @node Incomplete Enums
5939 @section Incomplete @code{enum} Types
5941 You can define an @code{enum} tag without specifying its possible values.
5942 This results in an incomplete type, much like what you get if you write
5943 @code{struct foo} without describing the elements.  A later declaration
5944 which does specify the possible values completes the type.
5946 You can't allocate variables or storage using the type while it is
5947 incomplete.  However, you can work with pointers to that type.
5949 This extension may not be very useful, but it makes the handling of
5950 @code{enum} more consistent with the way @code{struct} and @code{union}
5951 are handled.
5953 This extension is not supported by GNU C++.
5955 @node Function Names
5956 @section Function Names as Strings
5957 @cindex @code{__func__} identifier
5958 @cindex @code{__FUNCTION__} identifier
5959 @cindex @code{__PRETTY_FUNCTION__} identifier
5961 GCC provides three magic variables which hold the name of the current
5962 function, as a string.  The first of these is @code{__func__}, which
5963 is part of the C99 standard:
5965 The identifier @code{__func__} is implicitly declared by the translator
5966 as if, immediately following the opening brace of each function
5967 definition, the declaration
5969 @smallexample
5970 static const char __func__[] = "function-name";
5971 @end smallexample
5973 @noindent
5974 appeared, where function-name is the name of the lexically-enclosing
5975 function.  This name is the unadorned name of the function.
5977 @code{__FUNCTION__} is another name for @code{__func__}.  Older
5978 versions of GCC recognize only this name.  However, it is not
5979 standardized.  For maximum portability, we recommend you use
5980 @code{__func__}, but provide a fallback definition with the
5981 preprocessor:
5983 @smallexample
5984 #if __STDC_VERSION__ < 199901L
5985 # if __GNUC__ >= 2
5986 #  define __func__ __FUNCTION__
5987 # else
5988 #  define __func__ "<unknown>"
5989 # endif
5990 #endif
5991 @end smallexample
5993 In C, @code{__PRETTY_FUNCTION__} is yet another name for
5994 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
5995 the type signature of the function as well as its bare name.  For
5996 example, this program:
5998 @smallexample
5999 extern "C" @{
6000 extern int printf (char *, ...);
6003 class a @{
6004  public:
6005   void sub (int i)
6006     @{
6007       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6008       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6009     @}
6013 main (void)
6015   a ax;
6016   ax.sub (0);
6017   return 0;
6019 @end smallexample
6021 @noindent
6022 gives this output:
6024 @smallexample
6025 __FUNCTION__ = sub
6026 __PRETTY_FUNCTION__ = void a::sub(int)
6027 @end smallexample
6029 These identifiers are not preprocessor macros.  In GCC 3.3 and
6030 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6031 were treated as string literals; they could be used to initialize
6032 @code{char} arrays, and they could be concatenated with other string
6033 literals.  GCC 3.4 and later treat them as variables, like
6034 @code{__func__}.  In C++, @code{__FUNCTION__} and
6035 @code{__PRETTY_FUNCTION__} have always been variables.
6037 @node Return Address
6038 @section Getting the Return or Frame Address of a Function
6040 These functions may be used to get information about the callers of a
6041 function.
6043 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6044 This function returns the return address of the current function, or of
6045 one of its callers.  The @var{level} argument is number of frames to
6046 scan up the call stack.  A value of @code{0} yields the return address
6047 of the current function, a value of @code{1} yields the return address
6048 of the caller of the current function, and so forth.  When inlining
6049 the expected behavior is that the function will return the address of
6050 the function that will be returned to.  To work around this behavior use
6051 the @code{noinline} function attribute.
6053 The @var{level} argument must be a constant integer.
6055 On some machines it may be impossible to determine the return address of
6056 any function other than the current one; in such cases, or when the top
6057 of the stack has been reached, this function will return @code{0} or a
6058 random value.  In addition, @code{__builtin_frame_address} may be used
6059 to determine if the top of the stack has been reached.
6061 Additional post-processing of the returned value may be needed, see
6062 @code{__builtin_extract_return_address}.
6064 This function should only be used with a nonzero argument for debugging
6065 purposes.
6066 @end deftypefn
6068 @deftypefn {Built-in Function} {void *} __builtin_extract_return_address (void *@var{addr})
6069 The address as returned by @code{__builtin_return_address} may have to be fed
6070 through this function to get the actual encoded address.  For example, on the
6071 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6072 platforms an offset has to be added for the true next instruction to be
6073 executed.
6075 If no fixup is needed, this function simply passes through @var{addr}.
6076 @end deftypefn
6078 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6079 This function does the reverse of @code{__builtin_extract_return_address}.
6080 @end deftypefn
6082 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6083 This function is similar to @code{__builtin_return_address}, but it
6084 returns the address of the function frame rather than the return address
6085 of the function.  Calling @code{__builtin_frame_address} with a value of
6086 @code{0} yields the frame address of the current function, a value of
6087 @code{1} yields the frame address of the caller of the current function,
6088 and so forth.
6090 The frame is the area on the stack which holds local variables and saved
6091 registers.  The frame address is normally the address of the first word
6092 pushed on to the stack by the function.  However, the exact definition
6093 depends upon the processor and the calling convention.  If the processor
6094 has a dedicated frame pointer register, and the function has a frame,
6095 then @code{__builtin_frame_address} will return the value of the frame
6096 pointer register.
6098 On some machines it may be impossible to determine the frame address of
6099 any function other than the current one; in such cases, or when the top
6100 of the stack has been reached, this function will return @code{0} if
6101 the first frame pointer is properly initialized by the startup code.
6103 This function should only be used with a nonzero argument for debugging
6104 purposes.
6105 @end deftypefn
6107 @node Vector Extensions
6108 @section Using vector instructions through built-in functions
6110 On some targets, the instruction set contains SIMD vector instructions that
6111 operate on multiple values contained in one large register at the same time.
6112 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
6113 this way.
6115 The first step in using these extensions is to provide the necessary data
6116 types.  This should be done using an appropriate @code{typedef}:
6118 @smallexample
6119 typedef int v4si __attribute__ ((vector_size (16)));
6120 @end smallexample
6122 The @code{int} type specifies the base type, while the attribute specifies
6123 the vector size for the variable, measured in bytes.  For example, the
6124 declaration above causes the compiler to set the mode for the @code{v4si}
6125 type to be 16 bytes wide and divided into @code{int} sized units.  For
6126 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
6127 corresponding mode of @code{foo} will be @acronym{V4SI}.
6129 The @code{vector_size} attribute is only applicable to integral and
6130 float scalars, although arrays, pointers, and function return values
6131 are allowed in conjunction with this construct.
6133 All the basic integer types can be used as base types, both as signed
6134 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
6135 @code{long long}.  In addition, @code{float} and @code{double} can be
6136 used to build floating-point vector types.
6138 Specifying a combination that is not valid for the current architecture
6139 will cause GCC to synthesize the instructions using a narrower mode.
6140 For example, if you specify a variable of type @code{V4SI} and your
6141 architecture does not allow for this specific SIMD type, GCC will
6142 produce code that uses 4 @code{SIs}.
6144 The types defined in this manner can be used with a subset of normal C
6145 operations.  Currently, GCC will allow using the following operators
6146 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
6148 The operations behave like C++ @code{valarrays}.  Addition is defined as
6149 the addition of the corresponding elements of the operands.  For
6150 example, in the code below, each of the 4 elements in @var{a} will be
6151 added to the corresponding 4 elements in @var{b} and the resulting
6152 vector will be stored in @var{c}.
6154 @smallexample
6155 typedef int v4si __attribute__ ((vector_size (16)));
6157 v4si a, b, c;
6159 c = a + b;
6160 @end smallexample
6162 Subtraction, multiplication, division, and the logical operations
6163 operate in a similar manner.  Likewise, the result of using the unary
6164 minus or complement operators on a vector type is a vector whose
6165 elements are the negative or complemented values of the corresponding
6166 elements in the operand.
6168 You can declare variables and use them in function calls and returns, as
6169 well as in assignments and some casts.  You can specify a vector type as
6170 a return type for a function.  Vector types can also be used as function
6171 arguments.  It is possible to cast from one vector type to another,
6172 provided they are of the same size (in fact, you can also cast vectors
6173 to and from other datatypes of the same size).
6175 You cannot operate between vectors of different lengths or different
6176 signedness without a cast.
6178 A port that supports hardware vector operations, usually provides a set
6179 of built-in functions that can be used to operate on vectors.  For
6180 example, a function to add two vectors and multiply the result by a
6181 third could look like this:
6183 @smallexample
6184 v4si f (v4si a, v4si b, v4si c)
6186   v4si tmp = __builtin_addv4si (a, b);
6187   return __builtin_mulv4si (tmp, c);
6190 @end smallexample
6192 @node Offsetof
6193 @section Offsetof
6194 @findex __builtin_offsetof
6196 GCC implements for both C and C++ a syntactic extension to implement
6197 the @code{offsetof} macro.
6199 @smallexample
6200 primary:
6201         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
6203 offsetof_member_designator:
6204           @code{identifier}
6205         | offsetof_member_designator "." @code{identifier}
6206         | offsetof_member_designator "[" @code{expr} "]"
6207 @end smallexample
6209 This extension is sufficient such that
6211 @smallexample
6212 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
6213 @end smallexample
6215 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
6216 may be dependent.  In either case, @var{member} may consist of a single
6217 identifier, or a sequence of member accesses and array references.
6219 @node Atomic Builtins
6220 @section Built-in functions for atomic memory access
6222 The following builtins are intended to be compatible with those described
6223 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
6224 section 7.4.  As such, they depart from the normal GCC practice of using
6225 the ``__builtin_'' prefix, and further that they are overloaded such that
6226 they work on multiple types.
6228 The definition given in the Intel documentation allows only for the use of
6229 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
6230 counterparts.  GCC will allow any integral scalar or pointer type that is
6231 1, 2, 4 or 8 bytes in length.
6233 Not all operations are supported by all target processors.  If a particular
6234 operation cannot be implemented on the target processor, a warning will be
6235 generated and a call an external function will be generated.  The external
6236 function will carry the same name as the builtin, with an additional suffix
6237 @samp{_@var{n}} where @var{n} is the size of the data type.
6239 @c ??? Should we have a mechanism to suppress this warning?  This is almost
6240 @c useful for implementing the operation under the control of an external
6241 @c mutex.
6243 In most cases, these builtins are considered a @dfn{full barrier}.  That is,
6244 no memory operand will be moved across the operation, either forward or
6245 backward.  Further, instructions will be issued as necessary to prevent the
6246 processor from speculating loads across the operation and from queuing stores
6247 after the operation.
6249 All of the routines are described in the Intel documentation to take
6250 ``an optional list of variables protected by the memory barrier''.  It's
6251 not clear what is meant by that; it could mean that @emph{only} the
6252 following variables are protected, or it could mean that these variables
6253 should in addition be protected.  At present GCC ignores this list and
6254 protects all variables which are globally accessible.  If in the future
6255 we make some use of this list, an empty list will continue to mean all
6256 globally accessible variables.
6258 @table @code
6259 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
6260 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
6261 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
6262 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
6263 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
6264 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
6265 @findex __sync_fetch_and_add
6266 @findex __sync_fetch_and_sub
6267 @findex __sync_fetch_and_or
6268 @findex __sync_fetch_and_and
6269 @findex __sync_fetch_and_xor
6270 @findex __sync_fetch_and_nand
6271 These builtins perform the operation suggested by the name, and
6272 returns the value that had previously been in memory.  That is,
6274 @smallexample
6275 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
6276 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
6277 @end smallexample
6279 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
6280 builtin as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
6282 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
6283 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
6284 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
6285 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
6286 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
6287 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
6288 @findex __sync_add_and_fetch
6289 @findex __sync_sub_and_fetch
6290 @findex __sync_or_and_fetch
6291 @findex __sync_and_and_fetch
6292 @findex __sync_xor_and_fetch
6293 @findex __sync_nand_and_fetch
6294 These builtins perform the operation suggested by the name, and
6295 return the new value.  That is,
6297 @smallexample
6298 @{ *ptr @var{op}= value; return *ptr; @}
6299 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
6300 @end smallexample
6302 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
6303 builtin as @code{*ptr = ~(*ptr & value)} instead of
6304 @code{*ptr = ~*ptr & value}.
6306 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval @var{type} newval, ...)
6307 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval @var{type} newval, ...)
6308 @findex __sync_bool_compare_and_swap
6309 @findex __sync_val_compare_and_swap
6310 These builtins perform an atomic compare and swap.  That is, if the current
6311 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
6312 @code{*@var{ptr}}.
6314 The ``bool'' version returns true if the comparison is successful and
6315 @var{newval} was written.  The ``val'' version returns the contents
6316 of @code{*@var{ptr}} before the operation.
6318 @item __sync_synchronize (...)
6319 @findex __sync_synchronize
6320 This builtin issues a full memory barrier.
6322 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
6323 @findex __sync_lock_test_and_set
6324 This builtin, as described by Intel, is not a traditional test-and-set
6325 operation, but rather an atomic exchange operation.  It writes @var{value}
6326 into @code{*@var{ptr}}, and returns the previous contents of
6327 @code{*@var{ptr}}.
6329 Many targets have only minimal support for such locks, and do not support
6330 a full exchange operation.  In this case, a target may support reduced
6331 functionality here by which the @emph{only} valid value to store is the
6332 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
6333 is implementation defined.
6335 This builtin is not a full barrier, but rather an @dfn{acquire barrier}.
6336 This means that references after the builtin cannot move to (or be
6337 speculated to) before the builtin, but previous memory stores may not
6338 be globally visible yet, and previous memory loads may not yet be
6339 satisfied.
6341 @item void __sync_lock_release (@var{type} *ptr, ...)
6342 @findex __sync_lock_release
6343 This builtin releases the lock acquired by @code{__sync_lock_test_and_set}.
6344 Normally this means writing the constant 0 to @code{*@var{ptr}}.
6346 This builtin is not a full barrier, but rather a @dfn{release barrier}.
6347 This means that all previous memory stores are globally visible, and all
6348 previous memory loads have been satisfied, but following memory reads
6349 are not prevented from being speculated to before the barrier.
6350 @end table
6352 @node Object Size Checking
6353 @section Object Size Checking Builtins
6354 @findex __builtin_object_size
6355 @findex __builtin___memcpy_chk
6356 @findex __builtin___mempcpy_chk
6357 @findex __builtin___memmove_chk
6358 @findex __builtin___memset_chk
6359 @findex __builtin___strcpy_chk
6360 @findex __builtin___stpcpy_chk
6361 @findex __builtin___strncpy_chk
6362 @findex __builtin___strcat_chk
6363 @findex __builtin___strncat_chk
6364 @findex __builtin___sprintf_chk
6365 @findex __builtin___snprintf_chk
6366 @findex __builtin___vsprintf_chk
6367 @findex __builtin___vsnprintf_chk
6368 @findex __builtin___printf_chk
6369 @findex __builtin___vprintf_chk
6370 @findex __builtin___fprintf_chk
6371 @findex __builtin___vfprintf_chk
6373 GCC implements a limited buffer overflow protection mechanism
6374 that can prevent some buffer overflow attacks.
6376 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
6377 is a built-in construct that returns a constant number of bytes from
6378 @var{ptr} to the end of the object @var{ptr} pointer points to
6379 (if known at compile time).  @code{__builtin_object_size} never evaluates
6380 its arguments for side-effects.  If there are any side-effects in them, it
6381 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
6382 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
6383 point to and all of them are known at compile time, the returned number
6384 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
6385 0 and minimum if nonzero.  If it is not possible to determine which objects
6386 @var{ptr} points to at compile time, @code{__builtin_object_size} should
6387 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
6388 for @var{type} 2 or 3.
6390 @var{type} is an integer constant from 0 to 3.  If the least significant
6391 bit is clear, objects are whole variables, if it is set, a closest
6392 surrounding subobject is considered the object a pointer points to.
6393 The second bit determines if maximum or minimum of remaining bytes
6394 is computed.
6396 @smallexample
6397 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
6398 char *p = &var.buf1[1], *q = &var.b;
6400 /* Here the object p points to is var.  */
6401 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
6402 /* The subobject p points to is var.buf1.  */
6403 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
6404 /* The object q points to is var.  */
6405 assert (__builtin_object_size (q, 0)
6406         == (char *) (&var + 1) - (char *) &var.b);
6407 /* The subobject q points to is var.b.  */
6408 assert (__builtin_object_size (q, 1) == sizeof (var.b));
6409 @end smallexample
6410 @end deftypefn
6412 There are built-in functions added for many common string operation
6413 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
6414 built-in is provided.  This built-in has an additional last argument,
6415 which is the number of bytes remaining in object the @var{dest}
6416 argument points to or @code{(size_t) -1} if the size is not known.
6418 The built-in functions are optimized into the normal string functions
6419 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
6420 it is known at compile time that the destination object will not
6421 be overflown.  If the compiler can determine at compile time the
6422 object will be always overflown, it issues a warning.
6424 The intended use can be e.g.
6426 @smallexample
6427 #undef memcpy
6428 #define bos0(dest) __builtin_object_size (dest, 0)
6429 #define memcpy(dest, src, n) \
6430   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
6432 char *volatile p;
6433 char buf[10];
6434 /* It is unknown what object p points to, so this is optimized
6435    into plain memcpy - no checking is possible.  */
6436 memcpy (p, "abcde", n);
6437 /* Destination is known and length too.  It is known at compile
6438    time there will be no overflow.  */
6439 memcpy (&buf[5], "abcde", 5);
6440 /* Destination is known, but the length is not known at compile time.
6441    This will result in __memcpy_chk call that can check for overflow
6442    at runtime.  */
6443 memcpy (&buf[5], "abcde", n);
6444 /* Destination is known and it is known at compile time there will
6445    be overflow.  There will be a warning and __memcpy_chk call that
6446    will abort the program at runtime.  */
6447 memcpy (&buf[6], "abcde", 5);
6448 @end smallexample
6450 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
6451 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
6452 @code{strcat} and @code{strncat}.
6454 There are also checking built-in functions for formatted output functions.
6455 @smallexample
6456 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
6457 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
6458                               const char *fmt, ...);
6459 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
6460                               va_list ap);
6461 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
6462                                const char *fmt, va_list ap);
6463 @end smallexample
6465 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
6466 etc.@: functions and can contain implementation specific flags on what
6467 additional security measures the checking function might take, such as
6468 handling @code{%n} differently.
6470 The @var{os} argument is the object size @var{s} points to, like in the
6471 other built-in functions.  There is a small difference in the behavior
6472 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
6473 optimized into the non-checking functions only if @var{flag} is 0, otherwise
6474 the checking function is called with @var{os} argument set to
6475 @code{(size_t) -1}.
6477 In addition to this, there are checking built-in functions
6478 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
6479 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
6480 These have just one additional argument, @var{flag}, right before
6481 format string @var{fmt}.  If the compiler is able to optimize them to
6482 @code{fputc} etc.@: functions, it will, otherwise the checking function
6483 should be called and the @var{flag} argument passed to it.
6485 @node Other Builtins
6486 @section Other built-in functions provided by GCC
6487 @cindex built-in functions
6488 @findex __builtin_fpclassify
6489 @findex __builtin_isfinite
6490 @findex __builtin_isnormal
6491 @findex __builtin_isgreater
6492 @findex __builtin_isgreaterequal
6493 @findex __builtin_isinf_sign
6494 @findex __builtin_isless
6495 @findex __builtin_islessequal
6496 @findex __builtin_islessgreater
6497 @findex __builtin_isunordered
6498 @findex __builtin_powi
6499 @findex __builtin_powif
6500 @findex __builtin_powil
6501 @findex _Exit
6502 @findex _exit
6503 @findex abort
6504 @findex abs
6505 @findex acos
6506 @findex acosf
6507 @findex acosh
6508 @findex acoshf
6509 @findex acoshl
6510 @findex acosl
6511 @findex alloca
6512 @findex asin
6513 @findex asinf
6514 @findex asinh
6515 @findex asinhf
6516 @findex asinhl
6517 @findex asinl
6518 @findex atan
6519 @findex atan2
6520 @findex atan2f
6521 @findex atan2l
6522 @findex atanf
6523 @findex atanh
6524 @findex atanhf
6525 @findex atanhl
6526 @findex atanl
6527 @findex bcmp
6528 @findex bzero
6529 @findex cabs
6530 @findex cabsf
6531 @findex cabsl
6532 @findex cacos
6533 @findex cacosf
6534 @findex cacosh
6535 @findex cacoshf
6536 @findex cacoshl
6537 @findex cacosl
6538 @findex calloc
6539 @findex carg
6540 @findex cargf
6541 @findex cargl
6542 @findex casin
6543 @findex casinf
6544 @findex casinh
6545 @findex casinhf
6546 @findex casinhl
6547 @findex casinl
6548 @findex catan
6549 @findex catanf
6550 @findex catanh
6551 @findex catanhf
6552 @findex catanhl
6553 @findex catanl
6554 @findex cbrt
6555 @findex cbrtf
6556 @findex cbrtl
6557 @findex ccos
6558 @findex ccosf
6559 @findex ccosh
6560 @findex ccoshf
6561 @findex ccoshl
6562 @findex ccosl
6563 @findex ceil
6564 @findex ceilf
6565 @findex ceill
6566 @findex cexp
6567 @findex cexpf
6568 @findex cexpl
6569 @findex cimag
6570 @findex cimagf
6571 @findex cimagl
6572 @findex clog
6573 @findex clogf
6574 @findex clogl
6575 @findex conj
6576 @findex conjf
6577 @findex conjl
6578 @findex copysign
6579 @findex copysignf
6580 @findex copysignl
6581 @findex cos
6582 @findex cosf
6583 @findex cosh
6584 @findex coshf
6585 @findex coshl
6586 @findex cosl
6587 @findex cpow
6588 @findex cpowf
6589 @findex cpowl
6590 @findex cproj
6591 @findex cprojf
6592 @findex cprojl
6593 @findex creal
6594 @findex crealf
6595 @findex creall
6596 @findex csin
6597 @findex csinf
6598 @findex csinh
6599 @findex csinhf
6600 @findex csinhl
6601 @findex csinl
6602 @findex csqrt
6603 @findex csqrtf
6604 @findex csqrtl
6605 @findex ctan
6606 @findex ctanf
6607 @findex ctanh
6608 @findex ctanhf
6609 @findex ctanhl
6610 @findex ctanl
6611 @findex dcgettext
6612 @findex dgettext
6613 @findex drem
6614 @findex dremf
6615 @findex dreml
6616 @findex erf
6617 @findex erfc
6618 @findex erfcf
6619 @findex erfcl
6620 @findex erff
6621 @findex erfl
6622 @findex exit
6623 @findex exp
6624 @findex exp10
6625 @findex exp10f
6626 @findex exp10l
6627 @findex exp2
6628 @findex exp2f
6629 @findex exp2l
6630 @findex expf
6631 @findex expl
6632 @findex expm1
6633 @findex expm1f
6634 @findex expm1l
6635 @findex fabs
6636 @findex fabsf
6637 @findex fabsl
6638 @findex fdim
6639 @findex fdimf
6640 @findex fdiml
6641 @findex ffs
6642 @findex floor
6643 @findex floorf
6644 @findex floorl
6645 @findex fma
6646 @findex fmaf
6647 @findex fmal
6648 @findex fmax
6649 @findex fmaxf
6650 @findex fmaxl
6651 @findex fmin
6652 @findex fminf
6653 @findex fminl
6654 @findex fmod
6655 @findex fmodf
6656 @findex fmodl
6657 @findex fprintf
6658 @findex fprintf_unlocked
6659 @findex fputs
6660 @findex fputs_unlocked
6661 @findex frexp
6662 @findex frexpf
6663 @findex frexpl
6664 @findex fscanf
6665 @findex gamma
6666 @findex gammaf
6667 @findex gammal
6668 @findex gamma_r
6669 @findex gammaf_r
6670 @findex gammal_r
6671 @findex gettext
6672 @findex hypot
6673 @findex hypotf
6674 @findex hypotl
6675 @findex ilogb
6676 @findex ilogbf
6677 @findex ilogbl
6678 @findex imaxabs
6679 @findex index
6680 @findex isalnum
6681 @findex isalpha
6682 @findex isascii
6683 @findex isblank
6684 @findex iscntrl
6685 @findex isdigit
6686 @findex isgraph
6687 @findex islower
6688 @findex isprint
6689 @findex ispunct
6690 @findex isspace
6691 @findex isupper
6692 @findex iswalnum
6693 @findex iswalpha
6694 @findex iswblank
6695 @findex iswcntrl
6696 @findex iswdigit
6697 @findex iswgraph
6698 @findex iswlower
6699 @findex iswprint
6700 @findex iswpunct
6701 @findex iswspace
6702 @findex iswupper
6703 @findex iswxdigit
6704 @findex isxdigit
6705 @findex j0
6706 @findex j0f
6707 @findex j0l
6708 @findex j1
6709 @findex j1f
6710 @findex j1l
6711 @findex jn
6712 @findex jnf
6713 @findex jnl
6714 @findex labs
6715 @findex ldexp
6716 @findex ldexpf
6717 @findex ldexpl
6718 @findex lgamma
6719 @findex lgammaf
6720 @findex lgammal
6721 @findex lgamma_r
6722 @findex lgammaf_r
6723 @findex lgammal_r
6724 @findex llabs
6725 @findex llrint
6726 @findex llrintf
6727 @findex llrintl
6728 @findex llround
6729 @findex llroundf
6730 @findex llroundl
6731 @findex log
6732 @findex log10
6733 @findex log10f
6734 @findex log10l
6735 @findex log1p
6736 @findex log1pf
6737 @findex log1pl
6738 @findex log2
6739 @findex log2f
6740 @findex log2l
6741 @findex logb
6742 @findex logbf
6743 @findex logbl
6744 @findex logf
6745 @findex logl
6746 @findex lrint
6747 @findex lrintf
6748 @findex lrintl
6749 @findex lround
6750 @findex lroundf
6751 @findex lroundl
6752 @findex malloc
6753 @findex memchr
6754 @findex memcmp
6755 @findex memcpy
6756 @findex mempcpy
6757 @findex memset
6758 @findex modf
6759 @findex modff
6760 @findex modfl
6761 @findex nearbyint
6762 @findex nearbyintf
6763 @findex nearbyintl
6764 @findex nextafter
6765 @findex nextafterf
6766 @findex nextafterl
6767 @findex nexttoward
6768 @findex nexttowardf
6769 @findex nexttowardl
6770 @findex pow
6771 @findex pow10
6772 @findex pow10f
6773 @findex pow10l
6774 @findex powf
6775 @findex powl
6776 @findex printf
6777 @findex printf_unlocked
6778 @findex putchar
6779 @findex puts
6780 @findex remainder
6781 @findex remainderf
6782 @findex remainderl
6783 @findex remquo
6784 @findex remquof
6785 @findex remquol
6786 @findex rindex
6787 @findex rint
6788 @findex rintf
6789 @findex rintl
6790 @findex round
6791 @findex roundf
6792 @findex roundl
6793 @findex scalb
6794 @findex scalbf
6795 @findex scalbl
6796 @findex scalbln
6797 @findex scalblnf
6798 @findex scalblnf
6799 @findex scalbn
6800 @findex scalbnf
6801 @findex scanfnl
6802 @findex signbit
6803 @findex signbitf
6804 @findex signbitl
6805 @findex signbitd32
6806 @findex signbitd64
6807 @findex signbitd128
6808 @findex significand
6809 @findex significandf
6810 @findex significandl
6811 @findex sin
6812 @findex sincos
6813 @findex sincosf
6814 @findex sincosl
6815 @findex sinf
6816 @findex sinh
6817 @findex sinhf
6818 @findex sinhl
6819 @findex sinl
6820 @findex snprintf
6821 @findex sprintf
6822 @findex sqrt
6823 @findex sqrtf
6824 @findex sqrtl
6825 @findex sscanf
6826 @findex stpcpy
6827 @findex stpncpy
6828 @findex strcasecmp
6829 @findex strcat
6830 @findex strchr
6831 @findex strcmp
6832 @findex strcpy
6833 @findex strcspn
6834 @findex strdup
6835 @findex strfmon
6836 @findex strftime
6837 @findex strlen
6838 @findex strncasecmp
6839 @findex strncat
6840 @findex strncmp
6841 @findex strncpy
6842 @findex strndup
6843 @findex strpbrk
6844 @findex strrchr
6845 @findex strspn
6846 @findex strstr
6847 @findex tan
6848 @findex tanf
6849 @findex tanh
6850 @findex tanhf
6851 @findex tanhl
6852 @findex tanl
6853 @findex tgamma
6854 @findex tgammaf
6855 @findex tgammal
6856 @findex toascii
6857 @findex tolower
6858 @findex toupper
6859 @findex towlower
6860 @findex towupper
6861 @findex trunc
6862 @findex truncf
6863 @findex truncl
6864 @findex vfprintf
6865 @findex vfscanf
6866 @findex vprintf
6867 @findex vscanf
6868 @findex vsnprintf
6869 @findex vsprintf
6870 @findex vsscanf
6871 @findex y0
6872 @findex y0f
6873 @findex y0l
6874 @findex y1
6875 @findex y1f
6876 @findex y1l
6877 @findex yn
6878 @findex ynf
6879 @findex ynl
6881 GCC provides a large number of built-in functions other than the ones
6882 mentioned above.  Some of these are for internal use in the processing
6883 of exceptions or variable-length argument lists and will not be
6884 documented here because they may change from time to time; we do not
6885 recommend general use of these functions.
6887 The remaining functions are provided for optimization purposes.
6889 @opindex fno-builtin
6890 GCC includes built-in versions of many of the functions in the standard
6891 C library.  The versions prefixed with @code{__builtin_} will always be
6892 treated as having the same meaning as the C library function even if you
6893 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
6894 Many of these functions are only optimized in certain cases; if they are
6895 not optimized in a particular case, a call to the library function will
6896 be emitted.
6898 @opindex ansi
6899 @opindex std
6900 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
6901 @option{-std=c99} or @option{-std=c1x}), the functions
6902 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
6903 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
6904 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
6905 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
6906 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
6907 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
6908 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
6909 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
6910 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
6911 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
6912 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
6913 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
6914 @code{signbitd64}, @code{signbitd128}, @code{significandf},
6915 @code{significandl}, @code{significand}, @code{sincosf},
6916 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
6917 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
6918 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
6919 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
6920 @code{yn}
6921 may be handled as built-in functions.
6922 All these functions have corresponding versions
6923 prefixed with @code{__builtin_}, which may be used even in strict C90
6924 mode.
6926 The ISO C99 functions
6927 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
6928 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
6929 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
6930 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
6931 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
6932 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
6933 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
6934 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
6935 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
6936 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
6937 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
6938 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
6939 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
6940 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
6941 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
6942 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
6943 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
6944 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
6945 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
6946 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
6947 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
6948 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
6949 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
6950 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
6951 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
6952 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
6953 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
6954 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
6955 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
6956 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
6957 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
6958 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
6959 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
6960 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
6961 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
6962 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
6963 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
6964 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
6965 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
6966 are handled as built-in functions
6967 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
6969 There are also built-in versions of the ISO C99 functions
6970 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
6971 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
6972 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
6973 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
6974 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
6975 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
6976 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
6977 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
6978 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
6979 that are recognized in any mode since ISO C90 reserves these names for
6980 the purpose to which ISO C99 puts them.  All these functions have
6981 corresponding versions prefixed with @code{__builtin_}.
6983 The ISO C94 functions
6984 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
6985 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
6986 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
6987 @code{towupper}
6988 are handled as built-in functions
6989 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
6991 The ISO C90 functions
6992 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
6993 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
6994 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
6995 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
6996 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
6997 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
6998 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
6999 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
7000 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
7001 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
7002 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
7003 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
7004 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
7005 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
7006 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
7007 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
7008 are all recognized as built-in functions unless
7009 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
7010 is specified for an individual function).  All of these functions have
7011 corresponding versions prefixed with @code{__builtin_}.
7013 GCC provides built-in versions of the ISO C99 floating point comparison
7014 macros that avoid raising exceptions for unordered operands.  They have
7015 the same names as the standard macros ( @code{isgreater},
7016 @code{isgreaterequal}, @code{isless}, @code{islessequal},
7017 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
7018 prefixed.  We intend for a library implementor to be able to simply
7019 @code{#define} each standard macro to its built-in equivalent.
7020 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
7021 @code{isinf_sign} and @code{isnormal} built-ins used with
7022 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
7023 builtins appear both with and without the @code{__builtin_} prefix.
7025 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
7027 You can use the built-in function @code{__builtin_types_compatible_p} to
7028 determine whether two types are the same.
7030 This built-in function returns 1 if the unqualified versions of the
7031 types @var{type1} and @var{type2} (which are types, not expressions) are
7032 compatible, 0 otherwise.  The result of this built-in function can be
7033 used in integer constant expressions.
7035 This built-in function ignores top level qualifiers (e.g., @code{const},
7036 @code{volatile}).  For example, @code{int} is equivalent to @code{const
7037 int}.
7039 The type @code{int[]} and @code{int[5]} are compatible.  On the other
7040 hand, @code{int} and @code{char *} are not compatible, even if the size
7041 of their types, on the particular architecture are the same.  Also, the
7042 amount of pointer indirection is taken into account when determining
7043 similarity.  Consequently, @code{short *} is not similar to
7044 @code{short **}.  Furthermore, two types that are typedefed are
7045 considered compatible if their underlying types are compatible.
7047 An @code{enum} type is not considered to be compatible with another
7048 @code{enum} type even if both are compatible with the same integer
7049 type; this is what the C standard specifies.
7050 For example, @code{enum @{foo, bar@}} is not similar to
7051 @code{enum @{hot, dog@}}.
7053 You would typically use this function in code whose execution varies
7054 depending on the arguments' types.  For example:
7056 @smallexample
7057 #define foo(x)                                                  \
7058   (@{                                                           \
7059     typeof (x) tmp = (x);                                       \
7060     if (__builtin_types_compatible_p (typeof (x), long double)) \
7061       tmp = foo_long_double (tmp);                              \
7062     else if (__builtin_types_compatible_p (typeof (x), double)) \
7063       tmp = foo_double (tmp);                                   \
7064     else if (__builtin_types_compatible_p (typeof (x), float))  \
7065       tmp = foo_float (tmp);                                    \
7066     else                                                        \
7067       abort ();                                                 \
7068     tmp;                                                        \
7069   @})
7070 @end smallexample
7072 @emph{Note:} This construct is only available for C@.
7074 @end deftypefn
7076 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
7078 You can use the built-in function @code{__builtin_choose_expr} to
7079 evaluate code depending on the value of a constant expression.  This
7080 built-in function returns @var{exp1} if @var{const_exp}, which is an
7081 integer constant expression, is nonzero.  Otherwise it returns 0.
7083 This built-in function is analogous to the @samp{? :} operator in C,
7084 except that the expression returned has its type unaltered by promotion
7085 rules.  Also, the built-in function does not evaluate the expression
7086 that was not chosen.  For example, if @var{const_exp} evaluates to true,
7087 @var{exp2} is not evaluated even if it has side-effects.
7089 This built-in function can return an lvalue if the chosen argument is an
7090 lvalue.
7092 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
7093 type.  Similarly, if @var{exp2} is returned, its return type is the same
7094 as @var{exp2}.
7096 Example:
7098 @smallexample
7099 #define foo(x)                                                    \
7100   __builtin_choose_expr (                                         \
7101     __builtin_types_compatible_p (typeof (x), double),            \
7102     foo_double (x),                                               \
7103     __builtin_choose_expr (                                       \
7104       __builtin_types_compatible_p (typeof (x), float),           \
7105       foo_float (x),                                              \
7106       /* @r{The void expression results in a compile-time error}  \
7107          @r{when assigning the result to something.}  */          \
7108       (void)0))
7109 @end smallexample
7111 @emph{Note:} This construct is only available for C@.  Furthermore, the
7112 unused expression (@var{exp1} or @var{exp2} depending on the value of
7113 @var{const_exp}) may still generate syntax errors.  This may change in
7114 future revisions.
7116 @end deftypefn
7118 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
7119 You can use the built-in function @code{__builtin_constant_p} to
7120 determine if a value is known to be constant at compile-time and hence
7121 that GCC can perform constant-folding on expressions involving that
7122 value.  The argument of the function is the value to test.  The function
7123 returns the integer 1 if the argument is known to be a compile-time
7124 constant and 0 if it is not known to be a compile-time constant.  A
7125 return of 0 does not indicate that the value is @emph{not} a constant,
7126 but merely that GCC cannot prove it is a constant with the specified
7127 value of the @option{-O} option.
7129 You would typically use this function in an embedded application where
7130 memory was a critical resource.  If you have some complex calculation,
7131 you may want it to be folded if it involves constants, but need to call
7132 a function if it does not.  For example:
7134 @smallexample
7135 #define Scale_Value(X)      \
7136   (__builtin_constant_p (X) \
7137   ? ((X) * SCALE + OFFSET) : Scale (X))
7138 @end smallexample
7140 You may use this built-in function in either a macro or an inline
7141 function.  However, if you use it in an inlined function and pass an
7142 argument of the function as the argument to the built-in, GCC will
7143 never return 1 when you call the inline function with a string constant
7144 or compound literal (@pxref{Compound Literals}) and will not return 1
7145 when you pass a constant numeric value to the inline function unless you
7146 specify the @option{-O} option.
7148 You may also use @code{__builtin_constant_p} in initializers for static
7149 data.  For instance, you can write
7151 @smallexample
7152 static const int table[] = @{
7153    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
7154    /* @r{@dots{}} */
7156 @end smallexample
7158 @noindent
7159 This is an acceptable initializer even if @var{EXPRESSION} is not a
7160 constant expression, including the case where
7161 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
7162 folded to a constant but @var{EXPRESSION} contains operands that would
7163 not otherwise be permitted in a static initializer (for example,
7164 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
7165 built-in in this case, because it has no opportunity to perform
7166 optimization.
7168 Previous versions of GCC did not accept this built-in in data
7169 initializers.  The earliest version where it is completely safe is
7170 3.0.1.
7171 @end deftypefn
7173 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
7174 @opindex fprofile-arcs
7175 You may use @code{__builtin_expect} to provide the compiler with
7176 branch prediction information.  In general, you should prefer to
7177 use actual profile feedback for this (@option{-fprofile-arcs}), as
7178 programmers are notoriously bad at predicting how their programs
7179 actually perform.  However, there are applications in which this
7180 data is hard to collect.
7182 The return value is the value of @var{exp}, which should be an integral
7183 expression.  The semantics of the built-in are that it is expected that
7184 @var{exp} == @var{c}.  For example:
7186 @smallexample
7187 if (__builtin_expect (x, 0))
7188   foo ();
7189 @end smallexample
7191 @noindent
7192 would indicate that we do not expect to call @code{foo}, since
7193 we expect @code{x} to be zero.  Since you are limited to integral
7194 expressions for @var{exp}, you should use constructions such as
7196 @smallexample
7197 if (__builtin_expect (ptr != NULL, 1))
7198   error ();
7199 @end smallexample
7201 @noindent
7202 when testing pointer or floating-point values.
7203 @end deftypefn
7205 @deftypefn {Built-in Function} void __builtin_trap (void)
7206 This function causes the program to exit abnormally.  GCC implements
7207 this function by using a target-dependent mechanism (such as
7208 intentionally executing an illegal instruction) or by calling
7209 @code{abort}.  The mechanism used may vary from release to release so
7210 you should not rely on any particular implementation.
7211 @end deftypefn
7213 @deftypefn {Built-in Function} void __builtin_unreachable (void)
7214 If control flow reaches the point of the @code{__builtin_unreachable},
7215 the program is undefined.  It is useful in situations where the
7216 compiler cannot deduce the unreachability of the code.
7218 One such case is immediately following an @code{asm} statement that
7219 will either never terminate, or one that transfers control elsewhere
7220 and never returns.  In this example, without the
7221 @code{__builtin_unreachable}, GCC would issue a warning that control
7222 reaches the end of a non-void function.  It would also generate code
7223 to return after the @code{asm}.
7225 @smallexample
7226 int f (int c, int v)
7228   if (c)
7229     @{
7230       return v;
7231     @}
7232   else
7233     @{
7234       asm("jmp error_handler");
7235       __builtin_unreachable ();
7236     @}
7238 @end smallexample
7240 Because the @code{asm} statement unconditionally transfers control out
7241 of the function, control will never reach the end of the function
7242 body.  The @code{__builtin_unreachable} is in fact unreachable and
7243 communicates this fact to the compiler.
7245 Another use for @code{__builtin_unreachable} is following a call a
7246 function that never returns but that is not declared
7247 @code{__attribute__((noreturn))}, as in this example:
7249 @smallexample
7250 void function_that_never_returns (void);
7252 int g (int c)
7254   if (c)
7255     @{
7256       return 1;
7257     @}
7258   else
7259     @{
7260       function_that_never_returns ();
7261       __builtin_unreachable ();
7262     @}
7264 @end smallexample
7266 @end deftypefn
7268 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
7269 This function is used to flush the processor's instruction cache for
7270 the region of memory between @var{begin} inclusive and @var{end}
7271 exclusive.  Some targets require that the instruction cache be
7272 flushed, after modifying memory containing code, in order to obtain
7273 deterministic behavior.
7275 If the target does not require instruction cache flushes,
7276 @code{__builtin___clear_cache} has no effect.  Otherwise either
7277 instructions are emitted in-line to clear the instruction cache or a
7278 call to the @code{__clear_cache} function in libgcc is made.
7279 @end deftypefn
7281 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
7282 This function is used to minimize cache-miss latency by moving data into
7283 a cache before it is accessed.
7284 You can insert calls to @code{__builtin_prefetch} into code for which
7285 you know addresses of data in memory that is likely to be accessed soon.
7286 If the target supports them, data prefetch instructions will be generated.
7287 If the prefetch is done early enough before the access then the data will
7288 be in the cache by the time it is accessed.
7290 The value of @var{addr} is the address of the memory to prefetch.
7291 There are two optional arguments, @var{rw} and @var{locality}.
7292 The value of @var{rw} is a compile-time constant one or zero; one
7293 means that the prefetch is preparing for a write to the memory address
7294 and zero, the default, means that the prefetch is preparing for a read.
7295 The value @var{locality} must be a compile-time constant integer between
7296 zero and three.  A value of zero means that the data has no temporal
7297 locality, so it need not be left in the cache after the access.  A value
7298 of three means that the data has a high degree of temporal locality and
7299 should be left in all levels of cache possible.  Values of one and two
7300 mean, respectively, a low or moderate degree of temporal locality.  The
7301 default is three.
7303 @smallexample
7304 for (i = 0; i < n; i++)
7305   @{
7306     a[i] = a[i] + b[i];
7307     __builtin_prefetch (&a[i+j], 1, 1);
7308     __builtin_prefetch (&b[i+j], 0, 1);
7309     /* @r{@dots{}} */
7310   @}
7311 @end smallexample
7313 Data prefetch does not generate faults if @var{addr} is invalid, but
7314 the address expression itself must be valid.  For example, a prefetch
7315 of @code{p->next} will not fault if @code{p->next} is not a valid
7316 address, but evaluation will fault if @code{p} is not a valid address.
7318 If the target does not support data prefetch, the address expression
7319 is evaluated if it includes side effects but no other code is generated
7320 and GCC does not issue a warning.
7321 @end deftypefn
7323 @deftypefn {Built-in Function} double __builtin_huge_val (void)
7324 Returns a positive infinity, if supported by the floating-point format,
7325 else @code{DBL_MAX}.  This function is suitable for implementing the
7326 ISO C macro @code{HUGE_VAL}.
7327 @end deftypefn
7329 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
7330 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
7331 @end deftypefn
7333 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
7334 Similar to @code{__builtin_huge_val}, except the return
7335 type is @code{long double}.
7336 @end deftypefn
7338 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
7339 This built-in implements the C99 fpclassify functionality.  The first
7340 five int arguments should be the target library's notion of the
7341 possible FP classes and are used for return values.  They must be
7342 constant values and they must appear in this order: @code{FP_NAN},
7343 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
7344 @code{FP_ZERO}.  The ellipsis is for exactly one floating point value
7345 to classify.  GCC treats the last argument as type-generic, which
7346 means it does not do default promotion from float to double.
7347 @end deftypefn
7349 @deftypefn {Built-in Function} double __builtin_inf (void)
7350 Similar to @code{__builtin_huge_val}, except a warning is generated
7351 if the target floating-point format does not support infinities.
7352 @end deftypefn
7354 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
7355 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
7356 @end deftypefn
7358 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
7359 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
7360 @end deftypefn
7362 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
7363 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
7364 @end deftypefn
7366 @deftypefn {Built-in Function} float __builtin_inff (void)
7367 Similar to @code{__builtin_inf}, except the return type is @code{float}.
7368 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
7369 @end deftypefn
7371 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
7372 Similar to @code{__builtin_inf}, except the return
7373 type is @code{long double}.
7374 @end deftypefn
7376 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
7377 Similar to @code{isinf}, except the return value will be negative for
7378 an argument of @code{-Inf}.  Note while the parameter list is an
7379 ellipsis, this function only accepts exactly one floating point
7380 argument.  GCC treats this parameter as type-generic, which means it
7381 does not do default promotion from float to double.
7382 @end deftypefn
7384 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
7385 This is an implementation of the ISO C99 function @code{nan}.
7387 Since ISO C99 defines this function in terms of @code{strtod}, which we
7388 do not implement, a description of the parsing is in order.  The string
7389 is parsed as by @code{strtol}; that is, the base is recognized by
7390 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
7391 in the significand such that the least significant bit of the number
7392 is at the least significant bit of the significand.  The number is
7393 truncated to fit the significand field provided.  The significand is
7394 forced to be a quiet NaN@.
7396 This function, if given a string literal all of which would have been
7397 consumed by strtol, is evaluated early enough that it is considered a
7398 compile-time constant.
7399 @end deftypefn
7401 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
7402 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
7403 @end deftypefn
7405 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
7406 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
7407 @end deftypefn
7409 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
7410 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
7411 @end deftypefn
7413 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
7414 Similar to @code{__builtin_nan}, except the return type is @code{float}.
7415 @end deftypefn
7417 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
7418 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
7419 @end deftypefn
7421 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
7422 Similar to @code{__builtin_nan}, except the significand is forced
7423 to be a signaling NaN@.  The @code{nans} function is proposed by
7424 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
7425 @end deftypefn
7427 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
7428 Similar to @code{__builtin_nans}, except the return type is @code{float}.
7429 @end deftypefn
7431 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
7432 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
7433 @end deftypefn
7435 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
7436 Returns one plus the index of the least significant 1-bit of @var{x}, or
7437 if @var{x} is zero, returns zero.
7438 @end deftypefn
7440 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
7441 Returns the number of leading 0-bits in @var{x}, starting at the most
7442 significant bit position.  If @var{x} is 0, the result is undefined.
7443 @end deftypefn
7445 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
7446 Returns the number of trailing 0-bits in @var{x}, starting at the least
7447 significant bit position.  If @var{x} is 0, the result is undefined.
7448 @end deftypefn
7450 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
7451 Returns the number of 1-bits in @var{x}.
7452 @end deftypefn
7454 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
7455 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
7456 modulo 2.
7457 @end deftypefn
7459 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
7460 Similar to @code{__builtin_ffs}, except the argument type is
7461 @code{unsigned long}.
7462 @end deftypefn
7464 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
7465 Similar to @code{__builtin_clz}, except the argument type is
7466 @code{unsigned long}.
7467 @end deftypefn
7469 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
7470 Similar to @code{__builtin_ctz}, except the argument type is
7471 @code{unsigned long}.
7472 @end deftypefn
7474 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
7475 Similar to @code{__builtin_popcount}, except the argument type is
7476 @code{unsigned long}.
7477 @end deftypefn
7479 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
7480 Similar to @code{__builtin_parity}, except the argument type is
7481 @code{unsigned long}.
7482 @end deftypefn
7484 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
7485 Similar to @code{__builtin_ffs}, except the argument type is
7486 @code{unsigned long long}.
7487 @end deftypefn
7489 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
7490 Similar to @code{__builtin_clz}, except the argument type is
7491 @code{unsigned long long}.
7492 @end deftypefn
7494 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
7495 Similar to @code{__builtin_ctz}, except the argument type is
7496 @code{unsigned long long}.
7497 @end deftypefn
7499 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
7500 Similar to @code{__builtin_popcount}, except the argument type is
7501 @code{unsigned long long}.
7502 @end deftypefn
7504 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
7505 Similar to @code{__builtin_parity}, except the argument type is
7506 @code{unsigned long long}.
7507 @end deftypefn
7509 @deftypefn {Built-in Function} double __builtin_powi (double, int)
7510 Returns the first argument raised to the power of the second.  Unlike the
7511 @code{pow} function no guarantees about precision and rounding are made.
7512 @end deftypefn
7514 @deftypefn {Built-in Function} float __builtin_powif (float, int)
7515 Similar to @code{__builtin_powi}, except the argument and return types
7516 are @code{float}.
7517 @end deftypefn
7519 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
7520 Similar to @code{__builtin_powi}, except the argument and return types
7521 are @code{long double}.
7522 @end deftypefn
7524 @deftypefn {Built-in Function} int32_t __builtin_bswap32 (int32_t x)
7525 Returns @var{x} with the order of the bytes reversed; for example,
7526 @code{0xaabbccdd} becomes @code{0xddccbbaa}.  Byte here always means
7527 exactly 8 bits.
7528 @end deftypefn
7530 @deftypefn {Built-in Function} int64_t __builtin_bswap64 (int64_t x)
7531 Similar to @code{__builtin_bswap32}, except the argument and return types
7532 are 64-bit.
7533 @end deftypefn
7535 @node Target Builtins
7536 @section Built-in Functions Specific to Particular Target Machines
7538 On some target machines, GCC supports many built-in functions specific
7539 to those machines.  Generally these generate calls to specific machine
7540 instructions, but allow the compiler to schedule those calls.
7542 @menu
7543 * Alpha Built-in Functions::
7544 * ARM iWMMXt Built-in Functions::
7545 * ARM NEON Intrinsics::
7546 * Blackfin Built-in Functions::
7547 * FR-V Built-in Functions::
7548 * X86 Built-in Functions::
7549 * MIPS DSP Built-in Functions::
7550 * MIPS Paired-Single Support::
7551 * MIPS Loongson Built-in Functions::
7552 * Other MIPS Built-in Functions::
7553 * picoChip Built-in Functions::
7554 * PowerPC AltiVec/VSX Built-in Functions::
7555 * RX Built-in Functions::
7556 * SPARC VIS Built-in Functions::
7557 * SPU Built-in Functions::
7558 @end menu
7560 @node Alpha Built-in Functions
7561 @subsection Alpha Built-in Functions
7563 These built-in functions are available for the Alpha family of
7564 processors, depending on the command-line switches used.
7566 The following built-in functions are always available.  They
7567 all generate the machine instruction that is part of the name.
7569 @smallexample
7570 long __builtin_alpha_implver (void)
7571 long __builtin_alpha_rpcc (void)
7572 long __builtin_alpha_amask (long)
7573 long __builtin_alpha_cmpbge (long, long)
7574 long __builtin_alpha_extbl (long, long)
7575 long __builtin_alpha_extwl (long, long)
7576 long __builtin_alpha_extll (long, long)
7577 long __builtin_alpha_extql (long, long)
7578 long __builtin_alpha_extwh (long, long)
7579 long __builtin_alpha_extlh (long, long)
7580 long __builtin_alpha_extqh (long, long)
7581 long __builtin_alpha_insbl (long, long)
7582 long __builtin_alpha_inswl (long, long)
7583 long __builtin_alpha_insll (long, long)
7584 long __builtin_alpha_insql (long, long)
7585 long __builtin_alpha_inswh (long, long)
7586 long __builtin_alpha_inslh (long, long)
7587 long __builtin_alpha_insqh (long, long)
7588 long __builtin_alpha_mskbl (long, long)
7589 long __builtin_alpha_mskwl (long, long)
7590 long __builtin_alpha_mskll (long, long)
7591 long __builtin_alpha_mskql (long, long)
7592 long __builtin_alpha_mskwh (long, long)
7593 long __builtin_alpha_msklh (long, long)
7594 long __builtin_alpha_mskqh (long, long)
7595 long __builtin_alpha_umulh (long, long)
7596 long __builtin_alpha_zap (long, long)
7597 long __builtin_alpha_zapnot (long, long)
7598 @end smallexample
7600 The following built-in functions are always with @option{-mmax}
7601 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
7602 later.  They all generate the machine instruction that is part
7603 of the name.
7605 @smallexample
7606 long __builtin_alpha_pklb (long)
7607 long __builtin_alpha_pkwb (long)
7608 long __builtin_alpha_unpkbl (long)
7609 long __builtin_alpha_unpkbw (long)
7610 long __builtin_alpha_minub8 (long, long)
7611 long __builtin_alpha_minsb8 (long, long)
7612 long __builtin_alpha_minuw4 (long, long)
7613 long __builtin_alpha_minsw4 (long, long)
7614 long __builtin_alpha_maxub8 (long, long)
7615 long __builtin_alpha_maxsb8 (long, long)
7616 long __builtin_alpha_maxuw4 (long, long)
7617 long __builtin_alpha_maxsw4 (long, long)
7618 long __builtin_alpha_perr (long, long)
7619 @end smallexample
7621 The following built-in functions are always with @option{-mcix}
7622 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
7623 later.  They all generate the machine instruction that is part
7624 of the name.
7626 @smallexample
7627 long __builtin_alpha_cttz (long)
7628 long __builtin_alpha_ctlz (long)
7629 long __builtin_alpha_ctpop (long)
7630 @end smallexample
7632 The following builtins are available on systems that use the OSF/1
7633 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
7634 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
7635 @code{rdval} and @code{wrval}.
7637 @smallexample
7638 void *__builtin_thread_pointer (void)
7639 void __builtin_set_thread_pointer (void *)
7640 @end smallexample
7642 @node ARM iWMMXt Built-in Functions
7643 @subsection ARM iWMMXt Built-in Functions
7645 These built-in functions are available for the ARM family of
7646 processors when the @option{-mcpu=iwmmxt} switch is used:
7648 @smallexample
7649 typedef int v2si __attribute__ ((vector_size (8)));
7650 typedef short v4hi __attribute__ ((vector_size (8)));
7651 typedef char v8qi __attribute__ ((vector_size (8)));
7653 int __builtin_arm_getwcx (int)
7654 void __builtin_arm_setwcx (int, int)
7655 int __builtin_arm_textrmsb (v8qi, int)
7656 int __builtin_arm_textrmsh (v4hi, int)
7657 int __builtin_arm_textrmsw (v2si, int)
7658 int __builtin_arm_textrmub (v8qi, int)
7659 int __builtin_arm_textrmuh (v4hi, int)
7660 int __builtin_arm_textrmuw (v2si, int)
7661 v8qi __builtin_arm_tinsrb (v8qi, int)
7662 v4hi __builtin_arm_tinsrh (v4hi, int)
7663 v2si __builtin_arm_tinsrw (v2si, int)
7664 long long __builtin_arm_tmia (long long, int, int)
7665 long long __builtin_arm_tmiabb (long long, int, int)
7666 long long __builtin_arm_tmiabt (long long, int, int)
7667 long long __builtin_arm_tmiaph (long long, int, int)
7668 long long __builtin_arm_tmiatb (long long, int, int)
7669 long long __builtin_arm_tmiatt (long long, int, int)
7670 int __builtin_arm_tmovmskb (v8qi)
7671 int __builtin_arm_tmovmskh (v4hi)
7672 int __builtin_arm_tmovmskw (v2si)
7673 long long __builtin_arm_waccb (v8qi)
7674 long long __builtin_arm_wacch (v4hi)
7675 long long __builtin_arm_waccw (v2si)
7676 v8qi __builtin_arm_waddb (v8qi, v8qi)
7677 v8qi __builtin_arm_waddbss (v8qi, v8qi)
7678 v8qi __builtin_arm_waddbus (v8qi, v8qi)
7679 v4hi __builtin_arm_waddh (v4hi, v4hi)
7680 v4hi __builtin_arm_waddhss (v4hi, v4hi)
7681 v4hi __builtin_arm_waddhus (v4hi, v4hi)
7682 v2si __builtin_arm_waddw (v2si, v2si)
7683 v2si __builtin_arm_waddwss (v2si, v2si)
7684 v2si __builtin_arm_waddwus (v2si, v2si)
7685 v8qi __builtin_arm_walign (v8qi, v8qi, int)
7686 long long __builtin_arm_wand(long long, long long)
7687 long long __builtin_arm_wandn (long long, long long)
7688 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
7689 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
7690 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
7691 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
7692 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
7693 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
7694 v2si __builtin_arm_wcmpeqw (v2si, v2si)
7695 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
7696 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
7697 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
7698 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
7699 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
7700 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
7701 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
7702 long long __builtin_arm_wmacsz (v4hi, v4hi)
7703 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
7704 long long __builtin_arm_wmacuz (v4hi, v4hi)
7705 v4hi __builtin_arm_wmadds (v4hi, v4hi)
7706 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
7707 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
7708 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
7709 v2si __builtin_arm_wmaxsw (v2si, v2si)
7710 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
7711 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
7712 v2si __builtin_arm_wmaxuw (v2si, v2si)
7713 v8qi __builtin_arm_wminsb (v8qi, v8qi)
7714 v4hi __builtin_arm_wminsh (v4hi, v4hi)
7715 v2si __builtin_arm_wminsw (v2si, v2si)
7716 v8qi __builtin_arm_wminub (v8qi, v8qi)
7717 v4hi __builtin_arm_wminuh (v4hi, v4hi)
7718 v2si __builtin_arm_wminuw (v2si, v2si)
7719 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
7720 v4hi __builtin_arm_wmulul (v4hi, v4hi)
7721 v4hi __builtin_arm_wmulum (v4hi, v4hi)
7722 long long __builtin_arm_wor (long long, long long)
7723 v2si __builtin_arm_wpackdss (long long, long long)
7724 v2si __builtin_arm_wpackdus (long long, long long)
7725 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
7726 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
7727 v4hi __builtin_arm_wpackwss (v2si, v2si)
7728 v4hi __builtin_arm_wpackwus (v2si, v2si)
7729 long long __builtin_arm_wrord (long long, long long)
7730 long long __builtin_arm_wrordi (long long, int)
7731 v4hi __builtin_arm_wrorh (v4hi, long long)
7732 v4hi __builtin_arm_wrorhi (v4hi, int)
7733 v2si __builtin_arm_wrorw (v2si, long long)
7734 v2si __builtin_arm_wrorwi (v2si, int)
7735 v2si __builtin_arm_wsadb (v8qi, v8qi)
7736 v2si __builtin_arm_wsadbz (v8qi, v8qi)
7737 v2si __builtin_arm_wsadh (v4hi, v4hi)
7738 v2si __builtin_arm_wsadhz (v4hi, v4hi)
7739 v4hi __builtin_arm_wshufh (v4hi, int)
7740 long long __builtin_arm_wslld (long long, long long)
7741 long long __builtin_arm_wslldi (long long, int)
7742 v4hi __builtin_arm_wsllh (v4hi, long long)
7743 v4hi __builtin_arm_wsllhi (v4hi, int)
7744 v2si __builtin_arm_wsllw (v2si, long long)
7745 v2si __builtin_arm_wsllwi (v2si, int)
7746 long long __builtin_arm_wsrad (long long, long long)
7747 long long __builtin_arm_wsradi (long long, int)
7748 v4hi __builtin_arm_wsrah (v4hi, long long)
7749 v4hi __builtin_arm_wsrahi (v4hi, int)
7750 v2si __builtin_arm_wsraw (v2si, long long)
7751 v2si __builtin_arm_wsrawi (v2si, int)
7752 long long __builtin_arm_wsrld (long long, long long)
7753 long long __builtin_arm_wsrldi (long long, int)
7754 v4hi __builtin_arm_wsrlh (v4hi, long long)
7755 v4hi __builtin_arm_wsrlhi (v4hi, int)
7756 v2si __builtin_arm_wsrlw (v2si, long long)
7757 v2si __builtin_arm_wsrlwi (v2si, int)
7758 v8qi __builtin_arm_wsubb (v8qi, v8qi)
7759 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
7760 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
7761 v4hi __builtin_arm_wsubh (v4hi, v4hi)
7762 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
7763 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
7764 v2si __builtin_arm_wsubw (v2si, v2si)
7765 v2si __builtin_arm_wsubwss (v2si, v2si)
7766 v2si __builtin_arm_wsubwus (v2si, v2si)
7767 v4hi __builtin_arm_wunpckehsb (v8qi)
7768 v2si __builtin_arm_wunpckehsh (v4hi)
7769 long long __builtin_arm_wunpckehsw (v2si)
7770 v4hi __builtin_arm_wunpckehub (v8qi)
7771 v2si __builtin_arm_wunpckehuh (v4hi)
7772 long long __builtin_arm_wunpckehuw (v2si)
7773 v4hi __builtin_arm_wunpckelsb (v8qi)
7774 v2si __builtin_arm_wunpckelsh (v4hi)
7775 long long __builtin_arm_wunpckelsw (v2si)
7776 v4hi __builtin_arm_wunpckelub (v8qi)
7777 v2si __builtin_arm_wunpckeluh (v4hi)
7778 long long __builtin_arm_wunpckeluw (v2si)
7779 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
7780 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
7781 v2si __builtin_arm_wunpckihw (v2si, v2si)
7782 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
7783 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
7784 v2si __builtin_arm_wunpckilw (v2si, v2si)
7785 long long __builtin_arm_wxor (long long, long long)
7786 long long __builtin_arm_wzero ()
7787 @end smallexample
7789 @node ARM NEON Intrinsics
7790 @subsection ARM NEON Intrinsics
7792 These built-in intrinsics for the ARM Advanced SIMD extension are available
7793 when the @option{-mfpu=neon} switch is used:
7795 @include arm-neon-intrinsics.texi
7797 @node Blackfin Built-in Functions
7798 @subsection Blackfin Built-in Functions
7800 Currently, there are two Blackfin-specific built-in functions.  These are
7801 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
7802 using inline assembly; by using these built-in functions the compiler can
7803 automatically add workarounds for hardware errata involving these
7804 instructions.  These functions are named as follows:
7806 @smallexample
7807 void __builtin_bfin_csync (void)
7808 void __builtin_bfin_ssync (void)
7809 @end smallexample
7811 @node FR-V Built-in Functions
7812 @subsection FR-V Built-in Functions
7814 GCC provides many FR-V-specific built-in functions.  In general,
7815 these functions are intended to be compatible with those described
7816 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
7817 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
7818 @code{__MBTOHE}, the gcc forms of which pass 128-bit values by
7819 pointer rather than by value.
7821 Most of the functions are named after specific FR-V instructions.
7822 Such functions are said to be ``directly mapped'' and are summarized
7823 here in tabular form.
7825 @menu
7826 * Argument Types::
7827 * Directly-mapped Integer Functions::
7828 * Directly-mapped Media Functions::
7829 * Raw read/write Functions::
7830 * Other Built-in Functions::
7831 @end menu
7833 @node Argument Types
7834 @subsubsection Argument Types
7836 The arguments to the built-in functions can be divided into three groups:
7837 register numbers, compile-time constants and run-time values.  In order
7838 to make this classification clear at a glance, the arguments and return
7839 values are given the following pseudo types:
7841 @multitable @columnfractions .20 .30 .15 .35
7842 @item Pseudo type @tab Real C type @tab Constant? @tab Description
7843 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
7844 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
7845 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
7846 @item @code{uw2} @tab @code{unsigned long long} @tab No
7847 @tab an unsigned doubleword
7848 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
7849 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
7850 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
7851 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
7852 @end multitable
7854 These pseudo types are not defined by GCC, they are simply a notational
7855 convenience used in this manual.
7857 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
7858 and @code{sw2} are evaluated at run time.  They correspond to
7859 register operands in the underlying FR-V instructions.
7861 @code{const} arguments represent immediate operands in the underlying
7862 FR-V instructions.  They must be compile-time constants.
7864 @code{acc} arguments are evaluated at compile time and specify the number
7865 of an accumulator register.  For example, an @code{acc} argument of 2
7866 will select the ACC2 register.
7868 @code{iacc} arguments are similar to @code{acc} arguments but specify the
7869 number of an IACC register.  See @pxref{Other Built-in Functions}
7870 for more details.
7872 @node Directly-mapped Integer Functions
7873 @subsubsection Directly-mapped Integer Functions
7875 The functions listed below map directly to FR-V I-type instructions.
7877 @multitable @columnfractions .45 .32 .23
7878 @item Function prototype @tab Example usage @tab Assembly output
7879 @item @code{sw1 __ADDSS (sw1, sw1)}
7880 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
7881 @tab @code{ADDSS @var{a},@var{b},@var{c}}
7882 @item @code{sw1 __SCAN (sw1, sw1)}
7883 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
7884 @tab @code{SCAN @var{a},@var{b},@var{c}}
7885 @item @code{sw1 __SCUTSS (sw1)}
7886 @tab @code{@var{b} = __SCUTSS (@var{a})}
7887 @tab @code{SCUTSS @var{a},@var{b}}
7888 @item @code{sw1 __SLASS (sw1, sw1)}
7889 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
7890 @tab @code{SLASS @var{a},@var{b},@var{c}}
7891 @item @code{void __SMASS (sw1, sw1)}
7892 @tab @code{__SMASS (@var{a}, @var{b})}
7893 @tab @code{SMASS @var{a},@var{b}}
7894 @item @code{void __SMSSS (sw1, sw1)}
7895 @tab @code{__SMSSS (@var{a}, @var{b})}
7896 @tab @code{SMSSS @var{a},@var{b}}
7897 @item @code{void __SMU (sw1, sw1)}
7898 @tab @code{__SMU (@var{a}, @var{b})}
7899 @tab @code{SMU @var{a},@var{b}}
7900 @item @code{sw2 __SMUL (sw1, sw1)}
7901 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
7902 @tab @code{SMUL @var{a},@var{b},@var{c}}
7903 @item @code{sw1 __SUBSS (sw1, sw1)}
7904 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
7905 @tab @code{SUBSS @var{a},@var{b},@var{c}}
7906 @item @code{uw2 __UMUL (uw1, uw1)}
7907 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
7908 @tab @code{UMUL @var{a},@var{b},@var{c}}
7909 @end multitable
7911 @node Directly-mapped Media Functions
7912 @subsubsection Directly-mapped Media Functions
7914 The functions listed below map directly to FR-V M-type instructions.
7916 @multitable @columnfractions .45 .32 .23
7917 @item Function prototype @tab Example usage @tab Assembly output
7918 @item @code{uw1 __MABSHS (sw1)}
7919 @tab @code{@var{b} = __MABSHS (@var{a})}
7920 @tab @code{MABSHS @var{a},@var{b}}
7921 @item @code{void __MADDACCS (acc, acc)}
7922 @tab @code{__MADDACCS (@var{b}, @var{a})}
7923 @tab @code{MADDACCS @var{a},@var{b}}
7924 @item @code{sw1 __MADDHSS (sw1, sw1)}
7925 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
7926 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
7927 @item @code{uw1 __MADDHUS (uw1, uw1)}
7928 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
7929 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
7930 @item @code{uw1 __MAND (uw1, uw1)}
7931 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
7932 @tab @code{MAND @var{a},@var{b},@var{c}}
7933 @item @code{void __MASACCS (acc, acc)}
7934 @tab @code{__MASACCS (@var{b}, @var{a})}
7935 @tab @code{MASACCS @var{a},@var{b}}
7936 @item @code{uw1 __MAVEH (uw1, uw1)}
7937 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
7938 @tab @code{MAVEH @var{a},@var{b},@var{c}}
7939 @item @code{uw2 __MBTOH (uw1)}
7940 @tab @code{@var{b} = __MBTOH (@var{a})}
7941 @tab @code{MBTOH @var{a},@var{b}}
7942 @item @code{void __MBTOHE (uw1 *, uw1)}
7943 @tab @code{__MBTOHE (&@var{b}, @var{a})}
7944 @tab @code{MBTOHE @var{a},@var{b}}
7945 @item @code{void __MCLRACC (acc)}
7946 @tab @code{__MCLRACC (@var{a})}
7947 @tab @code{MCLRACC @var{a}}
7948 @item @code{void __MCLRACCA (void)}
7949 @tab @code{__MCLRACCA ()}
7950 @tab @code{MCLRACCA}
7951 @item @code{uw1 __Mcop1 (uw1, uw1)}
7952 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
7953 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
7954 @item @code{uw1 __Mcop2 (uw1, uw1)}
7955 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
7956 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
7957 @item @code{uw1 __MCPLHI (uw2, const)}
7958 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
7959 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
7960 @item @code{uw1 __MCPLI (uw2, const)}
7961 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
7962 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
7963 @item @code{void __MCPXIS (acc, sw1, sw1)}
7964 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
7965 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
7966 @item @code{void __MCPXIU (acc, uw1, uw1)}
7967 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
7968 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
7969 @item @code{void __MCPXRS (acc, sw1, sw1)}
7970 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
7971 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
7972 @item @code{void __MCPXRU (acc, uw1, uw1)}
7973 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
7974 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
7975 @item @code{uw1 __MCUT (acc, uw1)}
7976 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
7977 @tab @code{MCUT @var{a},@var{b},@var{c}}
7978 @item @code{uw1 __MCUTSS (acc, sw1)}
7979 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
7980 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
7981 @item @code{void __MDADDACCS (acc, acc)}
7982 @tab @code{__MDADDACCS (@var{b}, @var{a})}
7983 @tab @code{MDADDACCS @var{a},@var{b}}
7984 @item @code{void __MDASACCS (acc, acc)}
7985 @tab @code{__MDASACCS (@var{b}, @var{a})}
7986 @tab @code{MDASACCS @var{a},@var{b}}
7987 @item @code{uw2 __MDCUTSSI (acc, const)}
7988 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
7989 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
7990 @item @code{uw2 __MDPACKH (uw2, uw2)}
7991 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
7992 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
7993 @item @code{uw2 __MDROTLI (uw2, const)}
7994 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
7995 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
7996 @item @code{void __MDSUBACCS (acc, acc)}
7997 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
7998 @tab @code{MDSUBACCS @var{a},@var{b}}
7999 @item @code{void __MDUNPACKH (uw1 *, uw2)}
8000 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
8001 @tab @code{MDUNPACKH @var{a},@var{b}}
8002 @item @code{uw2 __MEXPDHD (uw1, const)}
8003 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
8004 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
8005 @item @code{uw1 __MEXPDHW (uw1, const)}
8006 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
8007 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
8008 @item @code{uw1 __MHDSETH (uw1, const)}
8009 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
8010 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
8011 @item @code{sw1 __MHDSETS (const)}
8012 @tab @code{@var{b} = __MHDSETS (@var{a})}
8013 @tab @code{MHDSETS #@var{a},@var{b}}
8014 @item @code{uw1 __MHSETHIH (uw1, const)}
8015 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
8016 @tab @code{MHSETHIH #@var{a},@var{b}}
8017 @item @code{sw1 __MHSETHIS (sw1, const)}
8018 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
8019 @tab @code{MHSETHIS #@var{a},@var{b}}
8020 @item @code{uw1 __MHSETLOH (uw1, const)}
8021 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
8022 @tab @code{MHSETLOH #@var{a},@var{b}}
8023 @item @code{sw1 __MHSETLOS (sw1, const)}
8024 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
8025 @tab @code{MHSETLOS #@var{a},@var{b}}
8026 @item @code{uw1 __MHTOB (uw2)}
8027 @tab @code{@var{b} = __MHTOB (@var{a})}
8028 @tab @code{MHTOB @var{a},@var{b}}
8029 @item @code{void __MMACHS (acc, sw1, sw1)}
8030 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
8031 @tab @code{MMACHS @var{a},@var{b},@var{c}}
8032 @item @code{void __MMACHU (acc, uw1, uw1)}
8033 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
8034 @tab @code{MMACHU @var{a},@var{b},@var{c}}
8035 @item @code{void __MMRDHS (acc, sw1, sw1)}
8036 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
8037 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
8038 @item @code{void __MMRDHU (acc, uw1, uw1)}
8039 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
8040 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
8041 @item @code{void __MMULHS (acc, sw1, sw1)}
8042 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
8043 @tab @code{MMULHS @var{a},@var{b},@var{c}}
8044 @item @code{void __MMULHU (acc, uw1, uw1)}
8045 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
8046 @tab @code{MMULHU @var{a},@var{b},@var{c}}
8047 @item @code{void __MMULXHS (acc, sw1, sw1)}
8048 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
8049 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
8050 @item @code{void __MMULXHU (acc, uw1, uw1)}
8051 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
8052 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
8053 @item @code{uw1 __MNOT (uw1)}
8054 @tab @code{@var{b} = __MNOT (@var{a})}
8055 @tab @code{MNOT @var{a},@var{b}}
8056 @item @code{uw1 __MOR (uw1, uw1)}
8057 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
8058 @tab @code{MOR @var{a},@var{b},@var{c}}
8059 @item @code{uw1 __MPACKH (uh, uh)}
8060 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
8061 @tab @code{MPACKH @var{a},@var{b},@var{c}}
8062 @item @code{sw2 __MQADDHSS (sw2, sw2)}
8063 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
8064 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
8065 @item @code{uw2 __MQADDHUS (uw2, uw2)}
8066 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
8067 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
8068 @item @code{void __MQCPXIS (acc, sw2, sw2)}
8069 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
8070 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
8071 @item @code{void __MQCPXIU (acc, uw2, uw2)}
8072 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
8073 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
8074 @item @code{void __MQCPXRS (acc, sw2, sw2)}
8075 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
8076 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
8077 @item @code{void __MQCPXRU (acc, uw2, uw2)}
8078 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
8079 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
8080 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
8081 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
8082 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
8083 @item @code{sw2 __MQLMTHS (sw2, sw2)}
8084 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
8085 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
8086 @item @code{void __MQMACHS (acc, sw2, sw2)}
8087 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
8088 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
8089 @item @code{void __MQMACHU (acc, uw2, uw2)}
8090 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
8091 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
8092 @item @code{void __MQMACXHS (acc, sw2, sw2)}
8093 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
8094 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
8095 @item @code{void __MQMULHS (acc, sw2, sw2)}
8096 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
8097 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
8098 @item @code{void __MQMULHU (acc, uw2, uw2)}
8099 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
8100 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
8101 @item @code{void __MQMULXHS (acc, sw2, sw2)}
8102 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
8103 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
8104 @item @code{void __MQMULXHU (acc, uw2, uw2)}
8105 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
8106 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
8107 @item @code{sw2 __MQSATHS (sw2, sw2)}
8108 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
8109 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
8110 @item @code{uw2 __MQSLLHI (uw2, int)}
8111 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
8112 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
8113 @item @code{sw2 __MQSRAHI (sw2, int)}
8114 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
8115 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
8116 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
8117 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
8118 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
8119 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
8120 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
8121 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
8122 @item @code{void __MQXMACHS (acc, sw2, sw2)}
8123 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
8124 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
8125 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
8126 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
8127 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
8128 @item @code{uw1 __MRDACC (acc)}
8129 @tab @code{@var{b} = __MRDACC (@var{a})}
8130 @tab @code{MRDACC @var{a},@var{b}}
8131 @item @code{uw1 __MRDACCG (acc)}
8132 @tab @code{@var{b} = __MRDACCG (@var{a})}
8133 @tab @code{MRDACCG @var{a},@var{b}}
8134 @item @code{uw1 __MROTLI (uw1, const)}
8135 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
8136 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
8137 @item @code{uw1 __MROTRI (uw1, const)}
8138 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
8139 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
8140 @item @code{sw1 __MSATHS (sw1, sw1)}
8141 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
8142 @tab @code{MSATHS @var{a},@var{b},@var{c}}
8143 @item @code{uw1 __MSATHU (uw1, uw1)}
8144 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
8145 @tab @code{MSATHU @var{a},@var{b},@var{c}}
8146 @item @code{uw1 __MSLLHI (uw1, const)}
8147 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
8148 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
8149 @item @code{sw1 __MSRAHI (sw1, const)}
8150 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
8151 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
8152 @item @code{uw1 __MSRLHI (uw1, const)}
8153 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
8154 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
8155 @item @code{void __MSUBACCS (acc, acc)}
8156 @tab @code{__MSUBACCS (@var{b}, @var{a})}
8157 @tab @code{MSUBACCS @var{a},@var{b}}
8158 @item @code{sw1 __MSUBHSS (sw1, sw1)}
8159 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
8160 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
8161 @item @code{uw1 __MSUBHUS (uw1, uw1)}
8162 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
8163 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
8164 @item @code{void __MTRAP (void)}
8165 @tab @code{__MTRAP ()}
8166 @tab @code{MTRAP}
8167 @item @code{uw2 __MUNPACKH (uw1)}
8168 @tab @code{@var{b} = __MUNPACKH (@var{a})}
8169 @tab @code{MUNPACKH @var{a},@var{b}}
8170 @item @code{uw1 __MWCUT (uw2, uw1)}
8171 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
8172 @tab @code{MWCUT @var{a},@var{b},@var{c}}
8173 @item @code{void __MWTACC (acc, uw1)}
8174 @tab @code{__MWTACC (@var{b}, @var{a})}
8175 @tab @code{MWTACC @var{a},@var{b}}
8176 @item @code{void __MWTACCG (acc, uw1)}
8177 @tab @code{__MWTACCG (@var{b}, @var{a})}
8178 @tab @code{MWTACCG @var{a},@var{b}}
8179 @item @code{uw1 __MXOR (uw1, uw1)}
8180 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
8181 @tab @code{MXOR @var{a},@var{b},@var{c}}
8182 @end multitable
8184 @node Raw read/write Functions
8185 @subsubsection Raw read/write Functions
8187 This sections describes built-in functions related to read and write
8188 instructions to access memory.  These functions generate
8189 @code{membar} instructions to flush the I/O load and stores where
8190 appropriate, as described in Fujitsu's manual described above.
8192 @table @code
8194 @item unsigned char __builtin_read8 (void *@var{data})
8195 @item unsigned short __builtin_read16 (void *@var{data})
8196 @item unsigned long __builtin_read32 (void *@var{data})
8197 @item unsigned long long __builtin_read64 (void *@var{data})
8199 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
8200 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
8201 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
8202 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
8203 @end table
8205 @node Other Built-in Functions
8206 @subsubsection Other Built-in Functions
8208 This section describes built-in functions that are not named after
8209 a specific FR-V instruction.
8211 @table @code
8212 @item sw2 __IACCreadll (iacc @var{reg})
8213 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
8214 for future expansion and must be 0.
8216 @item sw1 __IACCreadl (iacc @var{reg})
8217 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
8218 Other values of @var{reg} are rejected as invalid.
8220 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
8221 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
8222 is reserved for future expansion and must be 0.
8224 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
8225 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
8226 is 1.  Other values of @var{reg} are rejected as invalid.
8228 @item void __data_prefetch0 (const void *@var{x})
8229 Use the @code{dcpl} instruction to load the contents of address @var{x}
8230 into the data cache.
8232 @item void __data_prefetch (const void *@var{x})
8233 Use the @code{nldub} instruction to load the contents of address @var{x}
8234 into the data cache.  The instruction will be issued in slot I1@.
8235 @end table
8237 @node X86 Built-in Functions
8238 @subsection X86 Built-in Functions
8240 These built-in functions are available for the i386 and x86-64 family
8241 of computers, depending on the command-line switches used.
8243 Note that, if you specify command-line switches such as @option{-msse},
8244 the compiler could use the extended instruction sets even if the built-ins
8245 are not used explicitly in the program.  For this reason, applications
8246 which perform runtime CPU detection must compile separate files for each
8247 supported architecture, using the appropriate flags.  In particular,
8248 the file containing the CPU detection code should be compiled without
8249 these options.
8251 The following machine modes are available for use with MMX built-in functions
8252 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
8253 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
8254 vector of eight 8-bit integers.  Some of the built-in functions operate on
8255 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
8257 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
8258 of two 32-bit floating point values.
8260 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
8261 floating point values.  Some instructions use a vector of four 32-bit
8262 integers, these use @code{V4SI}.  Finally, some instructions operate on an
8263 entire vector register, interpreting it as a 128-bit integer, these use mode
8264 @code{TI}.
8266 In 64-bit mode, the x86-64 family of processors uses additional built-in
8267 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
8268 floating point and @code{TC} 128-bit complex floating point values.
8270 The following floating point built-in functions are available in 64-bit
8271 mode.  All of them implement the function that is part of the name.
8273 @smallexample
8274 __float128 __builtin_fabsq (__float128)
8275 __float128 __builtin_copysignq (__float128, __float128)
8276 @end smallexample
8278 The following floating point built-in functions are made available in the
8279 64-bit mode.
8281 @table @code
8282 @item __float128 __builtin_infq (void)
8283 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
8284 @findex __builtin_infq
8286 @item __float128 __builtin_huge_valq (void)
8287 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
8288 @findex __builtin_huge_valq
8289 @end table
8291 The following built-in functions are made available by @option{-mmmx}.
8292 All of them generate the machine instruction that is part of the name.
8294 @smallexample
8295 v8qi __builtin_ia32_paddb (v8qi, v8qi)
8296 v4hi __builtin_ia32_paddw (v4hi, v4hi)
8297 v2si __builtin_ia32_paddd (v2si, v2si)
8298 v8qi __builtin_ia32_psubb (v8qi, v8qi)
8299 v4hi __builtin_ia32_psubw (v4hi, v4hi)
8300 v2si __builtin_ia32_psubd (v2si, v2si)
8301 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
8302 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
8303 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
8304 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
8305 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
8306 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
8307 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
8308 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
8309 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
8310 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
8311 di __builtin_ia32_pand (di, di)
8312 di __builtin_ia32_pandn (di,di)
8313 di __builtin_ia32_por (di, di)
8314 di __builtin_ia32_pxor (di, di)
8315 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
8316 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
8317 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
8318 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
8319 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
8320 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
8321 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
8322 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
8323 v2si __builtin_ia32_punpckhdq (v2si, v2si)
8324 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
8325 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
8326 v2si __builtin_ia32_punpckldq (v2si, v2si)
8327 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
8328 v4hi __builtin_ia32_packssdw (v2si, v2si)
8329 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
8331 v4hi __builtin_ia32_psllw (v4hi, v4hi)
8332 v2si __builtin_ia32_pslld (v2si, v2si)
8333 v1di __builtin_ia32_psllq (v1di, v1di)
8334 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
8335 v2si __builtin_ia32_psrld (v2si, v2si)
8336 v1di __builtin_ia32_psrlq (v1di, v1di)
8337 v4hi __builtin_ia32_psraw (v4hi, v4hi)
8338 v2si __builtin_ia32_psrad (v2si, v2si)
8339 v4hi __builtin_ia32_psllwi (v4hi, int)
8340 v2si __builtin_ia32_pslldi (v2si, int)
8341 v1di __builtin_ia32_psllqi (v1di, int)
8342 v4hi __builtin_ia32_psrlwi (v4hi, int)
8343 v2si __builtin_ia32_psrldi (v2si, int)
8344 v1di __builtin_ia32_psrlqi (v1di, int)
8345 v4hi __builtin_ia32_psrawi (v4hi, int)
8346 v2si __builtin_ia32_psradi (v2si, int)
8348 @end smallexample
8350 The following built-in functions are made available either with
8351 @option{-msse}, or with a combination of @option{-m3dnow} and
8352 @option{-march=athlon}.  All of them generate the machine
8353 instruction that is part of the name.
8355 @smallexample
8356 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
8357 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
8358 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
8359 v1di __builtin_ia32_psadbw (v8qi, v8qi)
8360 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
8361 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
8362 v8qi __builtin_ia32_pminub (v8qi, v8qi)
8363 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
8364 int __builtin_ia32_pextrw (v4hi, int)
8365 v4hi __builtin_ia32_pinsrw (v4hi, int, int)
8366 int __builtin_ia32_pmovmskb (v8qi)
8367 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
8368 void __builtin_ia32_movntq (di *, di)
8369 void __builtin_ia32_sfence (void)
8370 @end smallexample
8372 The following built-in functions are available when @option{-msse} is used.
8373 All of them generate the machine instruction that is part of the name.
8375 @smallexample
8376 int __builtin_ia32_comieq (v4sf, v4sf)
8377 int __builtin_ia32_comineq (v4sf, v4sf)
8378 int __builtin_ia32_comilt (v4sf, v4sf)
8379 int __builtin_ia32_comile (v4sf, v4sf)
8380 int __builtin_ia32_comigt (v4sf, v4sf)
8381 int __builtin_ia32_comige (v4sf, v4sf)
8382 int __builtin_ia32_ucomieq (v4sf, v4sf)
8383 int __builtin_ia32_ucomineq (v4sf, v4sf)
8384 int __builtin_ia32_ucomilt (v4sf, v4sf)
8385 int __builtin_ia32_ucomile (v4sf, v4sf)
8386 int __builtin_ia32_ucomigt (v4sf, v4sf)
8387 int __builtin_ia32_ucomige (v4sf, v4sf)
8388 v4sf __builtin_ia32_addps (v4sf, v4sf)
8389 v4sf __builtin_ia32_subps (v4sf, v4sf)
8390 v4sf __builtin_ia32_mulps (v4sf, v4sf)
8391 v4sf __builtin_ia32_divps (v4sf, v4sf)
8392 v4sf __builtin_ia32_addss (v4sf, v4sf)
8393 v4sf __builtin_ia32_subss (v4sf, v4sf)
8394 v4sf __builtin_ia32_mulss (v4sf, v4sf)
8395 v4sf __builtin_ia32_divss (v4sf, v4sf)
8396 v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
8397 v4si __builtin_ia32_cmpltps (v4sf, v4sf)
8398 v4si __builtin_ia32_cmpleps (v4sf, v4sf)
8399 v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
8400 v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
8401 v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
8402 v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
8403 v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
8404 v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
8405 v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
8406 v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
8407 v4si __builtin_ia32_cmpordps (v4sf, v4sf)
8408 v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
8409 v4si __builtin_ia32_cmpltss (v4sf, v4sf)
8410 v4si __builtin_ia32_cmpless (v4sf, v4sf)
8411 v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
8412 v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
8413 v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
8414 v4si __builtin_ia32_cmpnless (v4sf, v4sf)
8415 v4si __builtin_ia32_cmpordss (v4sf, v4sf)
8416 v4sf __builtin_ia32_maxps (v4sf, v4sf)
8417 v4sf __builtin_ia32_maxss (v4sf, v4sf)
8418 v4sf __builtin_ia32_minps (v4sf, v4sf)
8419 v4sf __builtin_ia32_minss (v4sf, v4sf)
8420 v4sf __builtin_ia32_andps (v4sf, v4sf)
8421 v4sf __builtin_ia32_andnps (v4sf, v4sf)
8422 v4sf __builtin_ia32_orps (v4sf, v4sf)
8423 v4sf __builtin_ia32_xorps (v4sf, v4sf)
8424 v4sf __builtin_ia32_movss (v4sf, v4sf)
8425 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
8426 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
8427 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
8428 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
8429 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
8430 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
8431 v2si __builtin_ia32_cvtps2pi (v4sf)
8432 int __builtin_ia32_cvtss2si (v4sf)
8433 v2si __builtin_ia32_cvttps2pi (v4sf)
8434 int __builtin_ia32_cvttss2si (v4sf)
8435 v4sf __builtin_ia32_rcpps (v4sf)
8436 v4sf __builtin_ia32_rsqrtps (v4sf)
8437 v4sf __builtin_ia32_sqrtps (v4sf)
8438 v4sf __builtin_ia32_rcpss (v4sf)
8439 v4sf __builtin_ia32_rsqrtss (v4sf)
8440 v4sf __builtin_ia32_sqrtss (v4sf)
8441 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
8442 void __builtin_ia32_movntps (float *, v4sf)
8443 int __builtin_ia32_movmskps (v4sf)
8444 @end smallexample
8446 The following built-in functions are available when @option{-msse} is used.
8448 @table @code
8449 @item v4sf __builtin_ia32_loadaps (float *)
8450 Generates the @code{movaps} machine instruction as a load from memory.
8451 @item void __builtin_ia32_storeaps (float *, v4sf)
8452 Generates the @code{movaps} machine instruction as a store to memory.
8453 @item v4sf __builtin_ia32_loadups (float *)
8454 Generates the @code{movups} machine instruction as a load from memory.
8455 @item void __builtin_ia32_storeups (float *, v4sf)
8456 Generates the @code{movups} machine instruction as a store to memory.
8457 @item v4sf __builtin_ia32_loadsss (float *)
8458 Generates the @code{movss} machine instruction as a load from memory.
8459 @item void __builtin_ia32_storess (float *, v4sf)
8460 Generates the @code{movss} machine instruction as a store to memory.
8461 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
8462 Generates the @code{movhps} machine instruction as a load from memory.
8463 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
8464 Generates the @code{movlps} machine instruction as a load from memory
8465 @item void __builtin_ia32_storehps (v2sf *, v4sf)
8466 Generates the @code{movhps} machine instruction as a store to memory.
8467 @item void __builtin_ia32_storelps (v2sf *, v4sf)
8468 Generates the @code{movlps} machine instruction as a store to memory.
8469 @end table
8471 The following built-in functions are available when @option{-msse2} is used.
8472 All of them generate the machine instruction that is part of the name.
8474 @smallexample
8475 int __builtin_ia32_comisdeq (v2df, v2df)
8476 int __builtin_ia32_comisdlt (v2df, v2df)
8477 int __builtin_ia32_comisdle (v2df, v2df)
8478 int __builtin_ia32_comisdgt (v2df, v2df)
8479 int __builtin_ia32_comisdge (v2df, v2df)
8480 int __builtin_ia32_comisdneq (v2df, v2df)
8481 int __builtin_ia32_ucomisdeq (v2df, v2df)
8482 int __builtin_ia32_ucomisdlt (v2df, v2df)
8483 int __builtin_ia32_ucomisdle (v2df, v2df)
8484 int __builtin_ia32_ucomisdgt (v2df, v2df)
8485 int __builtin_ia32_ucomisdge (v2df, v2df)
8486 int __builtin_ia32_ucomisdneq (v2df, v2df)
8487 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
8488 v2df __builtin_ia32_cmpltpd (v2df, v2df)
8489 v2df __builtin_ia32_cmplepd (v2df, v2df)
8490 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
8491 v2df __builtin_ia32_cmpgepd (v2df, v2df)
8492 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
8493 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
8494 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
8495 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
8496 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
8497 v2df __builtin_ia32_cmpngepd (v2df, v2df)
8498 v2df __builtin_ia32_cmpordpd (v2df, v2df)
8499 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
8500 v2df __builtin_ia32_cmpltsd (v2df, v2df)
8501 v2df __builtin_ia32_cmplesd (v2df, v2df)
8502 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
8503 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
8504 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
8505 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
8506 v2df __builtin_ia32_cmpordsd (v2df, v2df)
8507 v2di __builtin_ia32_paddq (v2di, v2di)
8508 v2di __builtin_ia32_psubq (v2di, v2di)
8509 v2df __builtin_ia32_addpd (v2df, v2df)
8510 v2df __builtin_ia32_subpd (v2df, v2df)
8511 v2df __builtin_ia32_mulpd (v2df, v2df)
8512 v2df __builtin_ia32_divpd (v2df, v2df)
8513 v2df __builtin_ia32_addsd (v2df, v2df)
8514 v2df __builtin_ia32_subsd (v2df, v2df)
8515 v2df __builtin_ia32_mulsd (v2df, v2df)
8516 v2df __builtin_ia32_divsd (v2df, v2df)
8517 v2df __builtin_ia32_minpd (v2df, v2df)
8518 v2df __builtin_ia32_maxpd (v2df, v2df)
8519 v2df __builtin_ia32_minsd (v2df, v2df)
8520 v2df __builtin_ia32_maxsd (v2df, v2df)
8521 v2df __builtin_ia32_andpd (v2df, v2df)
8522 v2df __builtin_ia32_andnpd (v2df, v2df)
8523 v2df __builtin_ia32_orpd (v2df, v2df)
8524 v2df __builtin_ia32_xorpd (v2df, v2df)
8525 v2df __builtin_ia32_movsd (v2df, v2df)
8526 v2df __builtin_ia32_unpckhpd (v2df, v2df)
8527 v2df __builtin_ia32_unpcklpd (v2df, v2df)
8528 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
8529 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
8530 v4si __builtin_ia32_paddd128 (v4si, v4si)
8531 v2di __builtin_ia32_paddq128 (v2di, v2di)
8532 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
8533 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
8534 v4si __builtin_ia32_psubd128 (v4si, v4si)
8535 v2di __builtin_ia32_psubq128 (v2di, v2di)
8536 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
8537 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
8538 v2di __builtin_ia32_pand128 (v2di, v2di)
8539 v2di __builtin_ia32_pandn128 (v2di, v2di)
8540 v2di __builtin_ia32_por128 (v2di, v2di)
8541 v2di __builtin_ia32_pxor128 (v2di, v2di)
8542 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
8543 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
8544 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
8545 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
8546 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
8547 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
8548 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
8549 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
8550 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
8551 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
8552 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
8553 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
8554 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
8555 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
8556 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
8557 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
8558 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
8559 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
8560 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
8561 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
8562 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
8563 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
8564 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
8565 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
8566 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
8567 v2df __builtin_ia32_loadupd (double *)
8568 void __builtin_ia32_storeupd (double *, v2df)
8569 v2df __builtin_ia32_loadhpd (v2df, double const *)
8570 v2df __builtin_ia32_loadlpd (v2df, double const *)
8571 int __builtin_ia32_movmskpd (v2df)
8572 int __builtin_ia32_pmovmskb128 (v16qi)
8573 void __builtin_ia32_movnti (int *, int)
8574 void __builtin_ia32_movntpd (double *, v2df)
8575 void __builtin_ia32_movntdq (v2df *, v2df)
8576 v4si __builtin_ia32_pshufd (v4si, int)
8577 v8hi __builtin_ia32_pshuflw (v8hi, int)
8578 v8hi __builtin_ia32_pshufhw (v8hi, int)
8579 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
8580 v2df __builtin_ia32_sqrtpd (v2df)
8581 v2df __builtin_ia32_sqrtsd (v2df)
8582 v2df __builtin_ia32_shufpd (v2df, v2df, int)
8583 v2df __builtin_ia32_cvtdq2pd (v4si)
8584 v4sf __builtin_ia32_cvtdq2ps (v4si)
8585 v4si __builtin_ia32_cvtpd2dq (v2df)
8586 v2si __builtin_ia32_cvtpd2pi (v2df)
8587 v4sf __builtin_ia32_cvtpd2ps (v2df)
8588 v4si __builtin_ia32_cvttpd2dq (v2df)
8589 v2si __builtin_ia32_cvttpd2pi (v2df)
8590 v2df __builtin_ia32_cvtpi2pd (v2si)
8591 int __builtin_ia32_cvtsd2si (v2df)
8592 int __builtin_ia32_cvttsd2si (v2df)
8593 long long __builtin_ia32_cvtsd2si64 (v2df)
8594 long long __builtin_ia32_cvttsd2si64 (v2df)
8595 v4si __builtin_ia32_cvtps2dq (v4sf)
8596 v2df __builtin_ia32_cvtps2pd (v4sf)
8597 v4si __builtin_ia32_cvttps2dq (v4sf)
8598 v2df __builtin_ia32_cvtsi2sd (v2df, int)
8599 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
8600 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
8601 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
8602 void __builtin_ia32_clflush (const void *)
8603 void __builtin_ia32_lfence (void)
8604 void __builtin_ia32_mfence (void)
8605 v16qi __builtin_ia32_loaddqu (const char *)
8606 void __builtin_ia32_storedqu (char *, v16qi)
8607 v1di __builtin_ia32_pmuludq (v2si, v2si)
8608 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
8609 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
8610 v4si __builtin_ia32_pslld128 (v4si, v4si)
8611 v2di __builtin_ia32_psllq128 (v2di, v2di)
8612 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
8613 v4si __builtin_ia32_psrld128 (v4si, v4si)
8614 v2di __builtin_ia32_psrlq128 (v2di, v2di)
8615 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
8616 v4si __builtin_ia32_psrad128 (v4si, v4si)
8617 v2di __builtin_ia32_pslldqi128 (v2di, int)
8618 v8hi __builtin_ia32_psllwi128 (v8hi, int)
8619 v4si __builtin_ia32_pslldi128 (v4si, int)
8620 v2di __builtin_ia32_psllqi128 (v2di, int)
8621 v2di __builtin_ia32_psrldqi128 (v2di, int)
8622 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
8623 v4si __builtin_ia32_psrldi128 (v4si, int)
8624 v2di __builtin_ia32_psrlqi128 (v2di, int)
8625 v8hi __builtin_ia32_psrawi128 (v8hi, int)
8626 v4si __builtin_ia32_psradi128 (v4si, int)
8627 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
8628 v2di __builtin_ia32_movq128 (v2di)
8629 @end smallexample
8631 The following built-in functions are available when @option{-msse3} is used.
8632 All of them generate the machine instruction that is part of the name.
8634 @smallexample
8635 v2df __builtin_ia32_addsubpd (v2df, v2df)
8636 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
8637 v2df __builtin_ia32_haddpd (v2df, v2df)
8638 v4sf __builtin_ia32_haddps (v4sf, v4sf)
8639 v2df __builtin_ia32_hsubpd (v2df, v2df)
8640 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
8641 v16qi __builtin_ia32_lddqu (char const *)
8642 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
8643 v2df __builtin_ia32_movddup (v2df)
8644 v4sf __builtin_ia32_movshdup (v4sf)
8645 v4sf __builtin_ia32_movsldup (v4sf)
8646 void __builtin_ia32_mwait (unsigned int, unsigned int)
8647 @end smallexample
8649 The following built-in functions are available when @option{-msse3} is used.
8651 @table @code
8652 @item v2df __builtin_ia32_loadddup (double const *)
8653 Generates the @code{movddup} machine instruction as a load from memory.
8654 @end table
8656 The following built-in functions are available when @option{-mssse3} is used.
8657 All of them generate the machine instruction that is part of the name
8658 with MMX registers.
8660 @smallexample
8661 v2si __builtin_ia32_phaddd (v2si, v2si)
8662 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
8663 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
8664 v2si __builtin_ia32_phsubd (v2si, v2si)
8665 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
8666 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
8667 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
8668 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
8669 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
8670 v8qi __builtin_ia32_psignb (v8qi, v8qi)
8671 v2si __builtin_ia32_psignd (v2si, v2si)
8672 v4hi __builtin_ia32_psignw (v4hi, v4hi)
8673 v1di __builtin_ia32_palignr (v1di, v1di, int)
8674 v8qi __builtin_ia32_pabsb (v8qi)
8675 v2si __builtin_ia32_pabsd (v2si)
8676 v4hi __builtin_ia32_pabsw (v4hi)
8677 @end smallexample
8679 The following built-in functions are available when @option{-mssse3} is used.
8680 All of them generate the machine instruction that is part of the name
8681 with SSE registers.
8683 @smallexample
8684 v4si __builtin_ia32_phaddd128 (v4si, v4si)
8685 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
8686 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
8687 v4si __builtin_ia32_phsubd128 (v4si, v4si)
8688 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
8689 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
8690 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
8691 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
8692 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
8693 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
8694 v4si __builtin_ia32_psignd128 (v4si, v4si)
8695 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
8696 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
8697 v16qi __builtin_ia32_pabsb128 (v16qi)
8698 v4si __builtin_ia32_pabsd128 (v4si)
8699 v8hi __builtin_ia32_pabsw128 (v8hi)
8700 @end smallexample
8702 The following built-in functions are available when @option{-msse4.1} is
8703 used.  All of them generate the machine instruction that is part of the
8704 name.
8706 @smallexample
8707 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
8708 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
8709 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
8710 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
8711 v2df __builtin_ia32_dppd (v2df, v2df, const int)
8712 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
8713 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
8714 v2di __builtin_ia32_movntdqa (v2di *);
8715 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
8716 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
8717 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
8718 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
8719 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
8720 v8hi __builtin_ia32_phminposuw128 (v8hi)
8721 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
8722 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
8723 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
8724 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
8725 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
8726 v4si __builtin_ia32_pminsd128 (v4si, v4si)
8727 v4si __builtin_ia32_pminud128 (v4si, v4si)
8728 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
8729 v4si __builtin_ia32_pmovsxbd128 (v16qi)
8730 v2di __builtin_ia32_pmovsxbq128 (v16qi)
8731 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
8732 v2di __builtin_ia32_pmovsxdq128 (v4si)
8733 v4si __builtin_ia32_pmovsxwd128 (v8hi)
8734 v2di __builtin_ia32_pmovsxwq128 (v8hi)
8735 v4si __builtin_ia32_pmovzxbd128 (v16qi)
8736 v2di __builtin_ia32_pmovzxbq128 (v16qi)
8737 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
8738 v2di __builtin_ia32_pmovzxdq128 (v4si)
8739 v4si __builtin_ia32_pmovzxwd128 (v8hi)
8740 v2di __builtin_ia32_pmovzxwq128 (v8hi)
8741 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
8742 v4si __builtin_ia32_pmulld128 (v4si, v4si)
8743 int __builtin_ia32_ptestc128 (v2di, v2di)
8744 int __builtin_ia32_ptestnzc128 (v2di, v2di)
8745 int __builtin_ia32_ptestz128 (v2di, v2di)
8746 v2df __builtin_ia32_roundpd (v2df, const int)
8747 v4sf __builtin_ia32_roundps (v4sf, const int)
8748 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
8749 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
8750 @end smallexample
8752 The following built-in functions are available when @option{-msse4.1} is
8753 used.
8755 @table @code
8756 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
8757 Generates the @code{insertps} machine instruction.
8758 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
8759 Generates the @code{pextrb} machine instruction.
8760 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
8761 Generates the @code{pinsrb} machine instruction.
8762 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
8763 Generates the @code{pinsrd} machine instruction.
8764 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
8765 Generates the @code{pinsrq} machine instruction in 64bit mode.
8766 @end table
8768 The following built-in functions are changed to generate new SSE4.1
8769 instructions when @option{-msse4.1} is used.
8771 @table @code
8772 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
8773 Generates the @code{extractps} machine instruction.
8774 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
8775 Generates the @code{pextrd} machine instruction.
8776 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
8777 Generates the @code{pextrq} machine instruction in 64bit mode.
8778 @end table
8780 The following built-in functions are available when @option{-msse4.2} is
8781 used.  All of them generate the machine instruction that is part of the
8782 name.
8784 @smallexample
8785 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
8786 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
8787 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
8788 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
8789 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
8790 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
8791 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
8792 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
8793 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
8794 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
8795 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
8796 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
8797 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
8798 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
8799 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
8800 @end smallexample
8802 The following built-in functions are available when @option{-msse4.2} is
8803 used.
8805 @table @code
8806 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
8807 Generates the @code{crc32b} machine instruction.
8808 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
8809 Generates the @code{crc32w} machine instruction.
8810 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
8811 Generates the @code{crc32l} machine instruction.
8812 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
8813 Generates the @code{crc32q} machine instruction.
8814 @end table
8816 The following built-in functions are changed to generate new SSE4.2
8817 instructions when @option{-msse4.2} is used.
8819 @table @code
8820 @item int __builtin_popcount (unsigned int)
8821 Generates the @code{popcntl} machine instruction.
8822 @item int __builtin_popcountl (unsigned long)
8823 Generates the @code{popcntl} or @code{popcntq} machine instruction,
8824 depending on the size of @code{unsigned long}.
8825 @item int __builtin_popcountll (unsigned long long)
8826 Generates the @code{popcntq} machine instruction.
8827 @end table
8829 The following built-in functions are available when @option{-mavx} is
8830 used. All of them generate the machine instruction that is part of the
8831 name.
8833 @smallexample
8834 v4df __builtin_ia32_addpd256 (v4df,v4df)
8835 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
8836 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
8837 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
8838 v4df __builtin_ia32_andnpd256 (v4df,v4df)
8839 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
8840 v4df __builtin_ia32_andpd256 (v4df,v4df)
8841 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
8842 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
8843 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
8844 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
8845 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
8846 v2df __builtin_ia32_cmppd (v2df,v2df,int)
8847 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
8848 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
8849 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
8850 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
8851 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
8852 v4df __builtin_ia32_cvtdq2pd256 (v4si)
8853 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
8854 v4si __builtin_ia32_cvtpd2dq256 (v4df)
8855 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
8856 v8si __builtin_ia32_cvtps2dq256 (v8sf)
8857 v4df __builtin_ia32_cvtps2pd256 (v4sf)
8858 v4si __builtin_ia32_cvttpd2dq256 (v4df)
8859 v8si __builtin_ia32_cvttps2dq256 (v8sf)
8860 v4df __builtin_ia32_divpd256 (v4df,v4df)
8861 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
8862 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
8863 v4df __builtin_ia32_haddpd256 (v4df,v4df)
8864 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
8865 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
8866 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
8867 v32qi __builtin_ia32_lddqu256 (pcchar)
8868 v32qi __builtin_ia32_loaddqu256 (pcchar)
8869 v4df __builtin_ia32_loadupd256 (pcdouble)
8870 v8sf __builtin_ia32_loadups256 (pcfloat)
8871 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
8872 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
8873 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
8874 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
8875 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
8876 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
8877 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
8878 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
8879 v4df __builtin_ia32_maxpd256 (v4df,v4df)
8880 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
8881 v4df __builtin_ia32_minpd256 (v4df,v4df)
8882 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
8883 v4df __builtin_ia32_movddup256 (v4df)
8884 int __builtin_ia32_movmskpd256 (v4df)
8885 int __builtin_ia32_movmskps256 (v8sf)
8886 v8sf __builtin_ia32_movshdup256 (v8sf)
8887 v8sf __builtin_ia32_movsldup256 (v8sf)
8888 v4df __builtin_ia32_mulpd256 (v4df,v4df)
8889 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
8890 v4df __builtin_ia32_orpd256 (v4df,v4df)
8891 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
8892 v2df __builtin_ia32_pd_pd256 (v4df)
8893 v4df __builtin_ia32_pd256_pd (v2df)
8894 v4sf __builtin_ia32_ps_ps256 (v8sf)
8895 v8sf __builtin_ia32_ps256_ps (v4sf)
8896 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
8897 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
8898 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
8899 v8sf __builtin_ia32_rcpps256 (v8sf)
8900 v4df __builtin_ia32_roundpd256 (v4df,int)
8901 v8sf __builtin_ia32_roundps256 (v8sf,int)
8902 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
8903 v8sf __builtin_ia32_rsqrtps256 (v8sf)
8904 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
8905 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
8906 v4si __builtin_ia32_si_si256 (v8si)
8907 v8si __builtin_ia32_si256_si (v4si)
8908 v4df __builtin_ia32_sqrtpd256 (v4df)
8909 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
8910 v8sf __builtin_ia32_sqrtps256 (v8sf)
8911 void __builtin_ia32_storedqu256 (pchar,v32qi)
8912 void __builtin_ia32_storeupd256 (pdouble,v4df)
8913 void __builtin_ia32_storeups256 (pfloat,v8sf)
8914 v4df __builtin_ia32_subpd256 (v4df,v4df)
8915 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
8916 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
8917 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
8918 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
8919 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
8920 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
8921 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
8922 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
8923 v4sf __builtin_ia32_vbroadcastss (pcfloat)
8924 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
8925 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
8926 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
8927 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
8928 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
8929 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
8930 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
8931 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
8932 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
8933 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
8934 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
8935 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
8936 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
8937 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
8938 v2df __builtin_ia32_vpermilpd (v2df,int)
8939 v4df __builtin_ia32_vpermilpd256 (v4df,int)
8940 v4sf __builtin_ia32_vpermilps (v4sf,int)
8941 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
8942 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
8943 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
8944 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
8945 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
8946 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
8947 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
8948 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
8949 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
8950 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
8951 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
8952 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
8953 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
8954 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
8955 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
8956 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
8957 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
8958 void __builtin_ia32_vzeroall (void)
8959 void __builtin_ia32_vzeroupper (void)
8960 v4df __builtin_ia32_xorpd256 (v4df,v4df)
8961 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
8962 @end smallexample
8964 The following built-in functions are available when @option{-maes} is
8965 used.  All of them generate the machine instruction that is part of the
8966 name.
8968 @smallexample
8969 v2di __builtin_ia32_aesenc128 (v2di, v2di)
8970 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
8971 v2di __builtin_ia32_aesdec128 (v2di, v2di)
8972 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
8973 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
8974 v2di __builtin_ia32_aesimc128 (v2di)
8975 @end smallexample
8977 The following built-in function is available when @option{-mpclmul} is
8978 used.
8980 @table @code
8981 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
8982 Generates the @code{pclmulqdq} machine instruction.
8983 @end table
8985 The following built-in function is available when @option{-mfsgsbase} is
8986 used.  All of them generate the machine instruction that is part of the
8987 name.
8989 @smallexample
8990 unsigned int __builtin_ia32_rdfsbase32 (void)
8991 unsigned long long __builtin_ia32_rdfsbase64 (void)
8992 unsigned int __builtin_ia32_rdgsbase32 (void)
8993 unsigned long long __builtin_ia32_rdgsbase64 (void)
8994 void _writefsbase_u32 (unsigned int)
8995 void _writefsbase_u64 (unsigned long long)
8996 void _writegsbase_u32 (unsigned int)
8997 void _writegsbase_u64 (unsigned long long)
8998 @end smallexample
9000 The following built-in function is available when @option{-mrdrnd} is
9001 used.  All of them generate the machine instruction that is part of the
9002 name.
9004 @smallexample
9005 unsigned short __builtin_ia32_rdrand16 (void)
9006 unsigned int __builtin_ia32_rdrand32 (void)
9007 unsigned long long __builtin_ia32_rdrand64 (void)
9008 @end smallexample
9010 The following built-in functions are available when @option{-msse4a} is used.
9011 All of them generate the machine instruction that is part of the name.
9013 @smallexample
9014 void __builtin_ia32_movntsd (double *, v2df)
9015 void __builtin_ia32_movntss (float *, v4sf)
9016 v2di __builtin_ia32_extrq  (v2di, v16qi)
9017 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
9018 v2di __builtin_ia32_insertq (v2di, v2di)
9019 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
9020 @end smallexample
9022 The following built-in functions are available when @option{-mxop} is used.
9023 @smallexample
9024 v2df __builtin_ia32_vfrczpd (v2df)
9025 v4sf __builtin_ia32_vfrczps (v4sf)
9026 v2df __builtin_ia32_vfrczsd (v2df, v2df)
9027 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
9028 v4df __builtin_ia32_vfrczpd256 (v4df)
9029 v8sf __builtin_ia32_vfrczps256 (v8sf)
9030 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
9031 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
9032 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
9033 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
9034 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
9035 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
9036 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
9037 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
9038 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
9039 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
9040 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
9041 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
9042 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
9043 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
9044 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
9045 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
9046 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
9047 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
9048 v4si __builtin_ia32_vpcomequd (v4si, v4si)
9049 v2di __builtin_ia32_vpcomequq (v2di, v2di)
9050 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
9051 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
9052 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
9053 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
9054 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
9055 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
9056 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
9057 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
9058 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
9059 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
9060 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
9061 v4si __builtin_ia32_vpcomged (v4si, v4si)
9062 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
9063 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
9064 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
9065 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
9066 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
9067 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
9068 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
9069 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
9070 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
9071 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
9072 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
9073 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
9074 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
9075 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
9076 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
9077 v4si __builtin_ia32_vpcomled (v4si, v4si)
9078 v2di __builtin_ia32_vpcomleq (v2di, v2di)
9079 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
9080 v4si __builtin_ia32_vpcomleud (v4si, v4si)
9081 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
9082 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
9083 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
9084 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
9085 v4si __builtin_ia32_vpcomltd (v4si, v4si)
9086 v2di __builtin_ia32_vpcomltq (v2di, v2di)
9087 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
9088 v4si __builtin_ia32_vpcomltud (v4si, v4si)
9089 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
9090 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
9091 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
9092 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
9093 v4si __builtin_ia32_vpcomned (v4si, v4si)
9094 v2di __builtin_ia32_vpcomneq (v2di, v2di)
9095 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
9096 v4si __builtin_ia32_vpcomneud (v4si, v4si)
9097 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
9098 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
9099 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
9100 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
9101 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
9102 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
9103 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
9104 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
9105 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
9106 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
9107 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
9108 v4si __builtin_ia32_vphaddbd (v16qi)
9109 v2di __builtin_ia32_vphaddbq (v16qi)
9110 v8hi __builtin_ia32_vphaddbw (v16qi)
9111 v2di __builtin_ia32_vphadddq (v4si)
9112 v4si __builtin_ia32_vphaddubd (v16qi)
9113 v2di __builtin_ia32_vphaddubq (v16qi)
9114 v8hi __builtin_ia32_vphaddubw (v16qi)
9115 v2di __builtin_ia32_vphaddudq (v4si)
9116 v4si __builtin_ia32_vphadduwd (v8hi)
9117 v2di __builtin_ia32_vphadduwq (v8hi)
9118 v4si __builtin_ia32_vphaddwd (v8hi)
9119 v2di __builtin_ia32_vphaddwq (v8hi)
9120 v8hi __builtin_ia32_vphsubbw (v16qi)
9121 v2di __builtin_ia32_vphsubdq (v4si)
9122 v4si __builtin_ia32_vphsubwd (v8hi)
9123 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
9124 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
9125 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
9126 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
9127 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
9128 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
9129 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
9130 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
9131 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
9132 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
9133 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
9134 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
9135 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
9136 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
9137 v4si __builtin_ia32_vprotd (v4si, v4si)
9138 v2di __builtin_ia32_vprotq (v2di, v2di)
9139 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
9140 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
9141 v4si __builtin_ia32_vpshad (v4si, v4si)
9142 v2di __builtin_ia32_vpshaq (v2di, v2di)
9143 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
9144 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
9145 v4si __builtin_ia32_vpshld (v4si, v4si)
9146 v2di __builtin_ia32_vpshlq (v2di, v2di)
9147 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
9148 @end smallexample
9150 The following built-in functions are available when @option{-mfma4} is used.
9151 All of them generate the machine instruction that is part of the name
9152 with MMX registers.
9154 @smallexample
9155 v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df)
9156 v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf)
9157 v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df)
9158 v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf)
9159 v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df)
9160 v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf)
9161 v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df)
9162 v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf)
9163 v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df)
9164 v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf)
9165 v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df)
9166 v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf)
9167 v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df)
9168 v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf)
9169 v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df)
9170 v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf)
9171 v2df __builtin_ia32_fmaddsubpd  (v2df, v2df, v2df)
9172 v4sf __builtin_ia32_fmaddsubps  (v4sf, v4sf, v4sf)
9173 v2df __builtin_ia32_fmsubaddpd  (v2df, v2df, v2df)
9174 v4sf __builtin_ia32_fmsubaddps  (v4sf, v4sf, v4sf)
9175 v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df)
9176 v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf)
9177 v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df)
9178 v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf)
9179 v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df)
9180 v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf)
9181 v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df)
9182 v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf)
9183 v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df)
9184 v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf)
9185 v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df)
9186 v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf)
9188 @end smallexample
9190 The following built-in functions are available when @option{-mlwp} is used.
9192 @smallexample
9193 void __builtin_ia32_llwpcb16 (void *);
9194 void __builtin_ia32_llwpcb32 (void *);
9195 void __builtin_ia32_llwpcb64 (void *);
9196 void * __builtin_ia32_llwpcb16 (void);
9197 void * __builtin_ia32_llwpcb32 (void);
9198 void * __builtin_ia32_llwpcb64 (void);
9199 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
9200 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
9201 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
9202 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
9203 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
9204 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
9205 @end smallexample
9207 The following built-in functions are available when @option{-m3dnow} is used.
9208 All of them generate the machine instruction that is part of the name.
9210 @smallexample
9211 void __builtin_ia32_femms (void)
9212 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
9213 v2si __builtin_ia32_pf2id (v2sf)
9214 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
9215 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
9216 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
9217 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
9218 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
9219 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
9220 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
9221 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
9222 v2sf __builtin_ia32_pfrcp (v2sf)
9223 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
9224 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
9225 v2sf __builtin_ia32_pfrsqrt (v2sf)
9226 v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf)
9227 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
9228 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
9229 v2sf __builtin_ia32_pi2fd (v2si)
9230 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
9231 @end smallexample
9233 The following built-in functions are available when both @option{-m3dnow}
9234 and @option{-march=athlon} are used.  All of them generate the machine
9235 instruction that is part of the name.
9237 @smallexample
9238 v2si __builtin_ia32_pf2iw (v2sf)
9239 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
9240 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
9241 v2sf __builtin_ia32_pi2fw (v2si)
9242 v2sf __builtin_ia32_pswapdsf (v2sf)
9243 v2si __builtin_ia32_pswapdsi (v2si)
9244 @end smallexample
9246 @node MIPS DSP Built-in Functions
9247 @subsection MIPS DSP Built-in Functions
9249 The MIPS DSP Application-Specific Extension (ASE) includes new
9250 instructions that are designed to improve the performance of DSP and
9251 media applications.  It provides instructions that operate on packed
9252 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
9254 GCC supports MIPS DSP operations using both the generic
9255 vector extensions (@pxref{Vector Extensions}) and a collection of
9256 MIPS-specific built-in functions.  Both kinds of support are
9257 enabled by the @option{-mdsp} command-line option.
9259 Revision 2 of the ASE was introduced in the second half of 2006.
9260 This revision adds extra instructions to the original ASE, but is
9261 otherwise backwards-compatible with it.  You can select revision 2
9262 using the command-line option @option{-mdspr2}; this option implies
9263 @option{-mdsp}.
9265 The SCOUNT and POS bits of the DSP control register are global.  The
9266 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
9267 POS bits.  During optimization, the compiler will not delete these
9268 instructions and it will not delete calls to functions containing
9269 these instructions.
9271 At present, GCC only provides support for operations on 32-bit
9272 vectors.  The vector type associated with 8-bit integer data is
9273 usually called @code{v4i8}, the vector type associated with Q7
9274 is usually called @code{v4q7}, the vector type associated with 16-bit
9275 integer data is usually called @code{v2i16}, and the vector type
9276 associated with Q15 is usually called @code{v2q15}.  They can be
9277 defined in C as follows:
9279 @smallexample
9280 typedef signed char v4i8 __attribute__ ((vector_size(4)));
9281 typedef signed char v4q7 __attribute__ ((vector_size(4)));
9282 typedef short v2i16 __attribute__ ((vector_size(4)));
9283 typedef short v2q15 __attribute__ ((vector_size(4)));
9284 @end smallexample
9286 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
9287 initialized in the same way as aggregates.  For example:
9289 @smallexample
9290 v4i8 a = @{1, 2, 3, 4@};
9291 v4i8 b;
9292 b = (v4i8) @{5, 6, 7, 8@};
9294 v2q15 c = @{0x0fcb, 0x3a75@};
9295 v2q15 d;
9296 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
9297 @end smallexample
9299 @emph{Note:} The CPU's endianness determines the order in which values
9300 are packed.  On little-endian targets, the first value is the least
9301 significant and the last value is the most significant.  The opposite
9302 order applies to big-endian targets.  For example, the code above will
9303 set the lowest byte of @code{a} to @code{1} on little-endian targets
9304 and @code{4} on big-endian targets.
9306 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
9307 representation.  As shown in this example, the integer representation
9308 of a Q7 value can be obtained by multiplying the fractional value by
9309 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
9310 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
9311 @code{0x1.0p31}.
9313 The table below lists the @code{v4i8} and @code{v2q15} operations for which
9314 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
9315 and @code{c} and @code{d} are @code{v2q15} values.
9317 @multitable @columnfractions .50 .50
9318 @item C code @tab MIPS instruction
9319 @item @code{a + b} @tab @code{addu.qb}
9320 @item @code{c + d} @tab @code{addq.ph}
9321 @item @code{a - b} @tab @code{subu.qb}
9322 @item @code{c - d} @tab @code{subq.ph}
9323 @end multitable
9325 The table below lists the @code{v2i16} operation for which
9326 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
9327 @code{v2i16} values.
9329 @multitable @columnfractions .50 .50
9330 @item C code @tab MIPS instruction
9331 @item @code{e * f} @tab @code{mul.ph}
9332 @end multitable
9334 It is easier to describe the DSP built-in functions if we first define
9335 the following types:
9337 @smallexample
9338 typedef int q31;
9339 typedef int i32;
9340 typedef unsigned int ui32;
9341 typedef long long a64;
9342 @end smallexample
9344 @code{q31} and @code{i32} are actually the same as @code{int}, but we
9345 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
9346 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
9347 @code{long long}, but we use @code{a64} to indicate values that will
9348 be placed in one of the four DSP accumulators (@code{$ac0},
9349 @code{$ac1}, @code{$ac2} or @code{$ac3}).
9351 Also, some built-in functions prefer or require immediate numbers as
9352 parameters, because the corresponding DSP instructions accept both immediate
9353 numbers and register operands, or accept immediate numbers only.  The
9354 immediate parameters are listed as follows.
9356 @smallexample
9357 imm0_3: 0 to 3.
9358 imm0_7: 0 to 7.
9359 imm0_15: 0 to 15.
9360 imm0_31: 0 to 31.
9361 imm0_63: 0 to 63.
9362 imm0_255: 0 to 255.
9363 imm_n32_31: -32 to 31.
9364 imm_n512_511: -512 to 511.
9365 @end smallexample
9367 The following built-in functions map directly to a particular MIPS DSP
9368 instruction.  Please refer to the architecture specification
9369 for details on what each instruction does.
9371 @smallexample
9372 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
9373 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
9374 q31 __builtin_mips_addq_s_w (q31, q31)
9375 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
9376 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
9377 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
9378 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
9379 q31 __builtin_mips_subq_s_w (q31, q31)
9380 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
9381 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
9382 i32 __builtin_mips_addsc (i32, i32)
9383 i32 __builtin_mips_addwc (i32, i32)
9384 i32 __builtin_mips_modsub (i32, i32)
9385 i32 __builtin_mips_raddu_w_qb (v4i8)
9386 v2q15 __builtin_mips_absq_s_ph (v2q15)
9387 q31 __builtin_mips_absq_s_w (q31)
9388 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
9389 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
9390 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
9391 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
9392 q31 __builtin_mips_preceq_w_phl (v2q15)
9393 q31 __builtin_mips_preceq_w_phr (v2q15)
9394 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
9395 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
9396 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
9397 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
9398 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
9399 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
9400 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
9401 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
9402 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
9403 v4i8 __builtin_mips_shll_qb (v4i8, i32)
9404 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
9405 v2q15 __builtin_mips_shll_ph (v2q15, i32)
9406 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
9407 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
9408 q31 __builtin_mips_shll_s_w (q31, imm0_31)
9409 q31 __builtin_mips_shll_s_w (q31, i32)
9410 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
9411 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
9412 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
9413 v2q15 __builtin_mips_shra_ph (v2q15, i32)
9414 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
9415 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
9416 q31 __builtin_mips_shra_r_w (q31, imm0_31)
9417 q31 __builtin_mips_shra_r_w (q31, i32)
9418 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
9419 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
9420 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
9421 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
9422 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
9423 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
9424 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
9425 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
9426 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
9427 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
9428 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
9429 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
9430 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
9431 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
9432 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
9433 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
9434 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
9435 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
9436 i32 __builtin_mips_bitrev (i32)
9437 i32 __builtin_mips_insv (i32, i32)
9438 v4i8 __builtin_mips_repl_qb (imm0_255)
9439 v4i8 __builtin_mips_repl_qb (i32)
9440 v2q15 __builtin_mips_repl_ph (imm_n512_511)
9441 v2q15 __builtin_mips_repl_ph (i32)
9442 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
9443 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
9444 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
9445 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
9446 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
9447 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
9448 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
9449 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
9450 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
9451 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
9452 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
9453 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
9454 i32 __builtin_mips_extr_w (a64, imm0_31)
9455 i32 __builtin_mips_extr_w (a64, i32)
9456 i32 __builtin_mips_extr_r_w (a64, imm0_31)
9457 i32 __builtin_mips_extr_s_h (a64, i32)
9458 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
9459 i32 __builtin_mips_extr_rs_w (a64, i32)
9460 i32 __builtin_mips_extr_s_h (a64, imm0_31)
9461 i32 __builtin_mips_extr_r_w (a64, i32)
9462 i32 __builtin_mips_extp (a64, imm0_31)
9463 i32 __builtin_mips_extp (a64, i32)
9464 i32 __builtin_mips_extpdp (a64, imm0_31)
9465 i32 __builtin_mips_extpdp (a64, i32)
9466 a64 __builtin_mips_shilo (a64, imm_n32_31)
9467 a64 __builtin_mips_shilo (a64, i32)
9468 a64 __builtin_mips_mthlip (a64, i32)
9469 void __builtin_mips_wrdsp (i32, imm0_63)
9470 i32 __builtin_mips_rddsp (imm0_63)
9471 i32 __builtin_mips_lbux (void *, i32)
9472 i32 __builtin_mips_lhx (void *, i32)
9473 i32 __builtin_mips_lwx (void *, i32)
9474 i32 __builtin_mips_bposge32 (void)
9475 @end smallexample
9477 The following built-in functions map directly to a particular MIPS DSP REV 2
9478 instruction.  Please refer to the architecture specification
9479 for details on what each instruction does.
9481 @smallexample
9482 v4q7 __builtin_mips_absq_s_qb (v4q7);
9483 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
9484 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
9485 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
9486 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
9487 i32 __builtin_mips_append (i32, i32, imm0_31);
9488 i32 __builtin_mips_balign (i32, i32, imm0_3);
9489 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
9490 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
9491 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
9492 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
9493 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
9494 a64 __builtin_mips_madd (a64, i32, i32);
9495 a64 __builtin_mips_maddu (a64, ui32, ui32);
9496 a64 __builtin_mips_msub (a64, i32, i32);
9497 a64 __builtin_mips_msubu (a64, ui32, ui32);
9498 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
9499 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
9500 q31 __builtin_mips_mulq_rs_w (q31, q31);
9501 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
9502 q31 __builtin_mips_mulq_s_w (q31, q31);
9503 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
9504 a64 __builtin_mips_mult (i32, i32);
9505 a64 __builtin_mips_multu (ui32, ui32);
9506 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
9507 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
9508 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
9509 i32 __builtin_mips_prepend (i32, i32, imm0_31);
9510 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
9511 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
9512 v4i8 __builtin_mips_shra_qb (v4i8, i32);
9513 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
9514 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
9515 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
9516 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
9517 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
9518 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
9519 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
9520 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
9521 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
9522 q31 __builtin_mips_addqh_w (q31, q31);
9523 q31 __builtin_mips_addqh_r_w (q31, q31);
9524 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
9525 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
9526 q31 __builtin_mips_subqh_w (q31, q31);
9527 q31 __builtin_mips_subqh_r_w (q31, q31);
9528 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
9529 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
9530 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
9531 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
9532 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
9533 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
9534 @end smallexample
9537 @node MIPS Paired-Single Support
9538 @subsection MIPS Paired-Single Support
9540 The MIPS64 architecture includes a number of instructions that
9541 operate on pairs of single-precision floating-point values.
9542 Each pair is packed into a 64-bit floating-point register,
9543 with one element being designated the ``upper half'' and
9544 the other being designated the ``lower half''.
9546 GCC supports paired-single operations using both the generic
9547 vector extensions (@pxref{Vector Extensions}) and a collection of
9548 MIPS-specific built-in functions.  Both kinds of support are
9549 enabled by the @option{-mpaired-single} command-line option.
9551 The vector type associated with paired-single values is usually
9552 called @code{v2sf}.  It can be defined in C as follows:
9554 @smallexample
9555 typedef float v2sf __attribute__ ((vector_size (8)));
9556 @end smallexample
9558 @code{v2sf} values are initialized in the same way as aggregates.
9559 For example:
9561 @smallexample
9562 v2sf a = @{1.5, 9.1@};
9563 v2sf b;
9564 float e, f;
9565 b = (v2sf) @{e, f@};
9566 @end smallexample
9568 @emph{Note:} The CPU's endianness determines which value is stored in
9569 the upper half of a register and which value is stored in the lower half.
9570 On little-endian targets, the first value is the lower one and the second
9571 value is the upper one.  The opposite order applies to big-endian targets.
9572 For example, the code above will set the lower half of @code{a} to
9573 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
9575 @node MIPS Loongson Built-in Functions
9576 @subsection MIPS Loongson Built-in Functions
9578 GCC provides intrinsics to access the SIMD instructions provided by the
9579 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
9580 available after inclusion of the @code{loongson.h} header file,
9581 operate on the following 64-bit vector types:
9583 @itemize
9584 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
9585 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
9586 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
9587 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
9588 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
9589 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
9590 @end itemize
9592 The intrinsics provided are listed below; each is named after the
9593 machine instruction to which it corresponds, with suffixes added as
9594 appropriate to distinguish intrinsics that expand to the same machine
9595 instruction yet have different argument types.  Refer to the architecture
9596 documentation for a description of the functionality of each
9597 instruction.
9599 @smallexample
9600 int16x4_t packsswh (int32x2_t s, int32x2_t t);
9601 int8x8_t packsshb (int16x4_t s, int16x4_t t);
9602 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
9603 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
9604 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
9605 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
9606 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
9607 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
9608 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
9609 uint64_t paddd_u (uint64_t s, uint64_t t);
9610 int64_t paddd_s (int64_t s, int64_t t);
9611 int16x4_t paddsh (int16x4_t s, int16x4_t t);
9612 int8x8_t paddsb (int8x8_t s, int8x8_t t);
9613 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
9614 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
9615 uint64_t pandn_ud (uint64_t s, uint64_t t);
9616 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
9617 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
9618 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
9619 int64_t pandn_sd (int64_t s, int64_t t);
9620 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
9621 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
9622 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
9623 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
9624 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
9625 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
9626 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
9627 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
9628 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
9629 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
9630 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
9631 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
9632 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
9633 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
9634 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
9635 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
9636 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
9637 uint16x4_t pextrh_u (uint16x4_t s, int field);
9638 int16x4_t pextrh_s (int16x4_t s, int field);
9639 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
9640 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
9641 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
9642 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
9643 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
9644 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
9645 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
9646 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
9647 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
9648 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
9649 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
9650 int16x4_t pminsh (int16x4_t s, int16x4_t t);
9651 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
9652 uint8x8_t pmovmskb_u (uint8x8_t s);
9653 int8x8_t pmovmskb_s (int8x8_t s);
9654 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
9655 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
9656 int16x4_t pmullh (int16x4_t s, int16x4_t t);
9657 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
9658 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
9659 uint16x4_t biadd (uint8x8_t s);
9660 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
9661 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
9662 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
9663 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
9664 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
9665 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
9666 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
9667 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
9668 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
9669 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
9670 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
9671 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
9672 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
9673 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
9674 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
9675 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
9676 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
9677 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
9678 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
9679 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
9680 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
9681 uint64_t psubd_u (uint64_t s, uint64_t t);
9682 int64_t psubd_s (int64_t s, int64_t t);
9683 int16x4_t psubsh (int16x4_t s, int16x4_t t);
9684 int8x8_t psubsb (int8x8_t s, int8x8_t t);
9685 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
9686 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
9687 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
9688 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
9689 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
9690 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
9691 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
9692 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
9693 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
9694 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
9695 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
9696 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
9697 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
9698 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
9699 @end smallexample
9701 @menu
9702 * Paired-Single Arithmetic::
9703 * Paired-Single Built-in Functions::
9704 * MIPS-3D Built-in Functions::
9705 @end menu
9707 @node Paired-Single Arithmetic
9708 @subsubsection Paired-Single Arithmetic
9710 The table below lists the @code{v2sf} operations for which hardware
9711 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
9712 values and @code{x} is an integral value.
9714 @multitable @columnfractions .50 .50
9715 @item C code @tab MIPS instruction
9716 @item @code{a + b} @tab @code{add.ps}
9717 @item @code{a - b} @tab @code{sub.ps}
9718 @item @code{-a} @tab @code{neg.ps}
9719 @item @code{a * b} @tab @code{mul.ps}
9720 @item @code{a * b + c} @tab @code{madd.ps}
9721 @item @code{a * b - c} @tab @code{msub.ps}
9722 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
9723 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
9724 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
9725 @end multitable
9727 Note that the multiply-accumulate instructions can be disabled
9728 using the command-line option @code{-mno-fused-madd}.
9730 @node Paired-Single Built-in Functions
9731 @subsubsection Paired-Single Built-in Functions
9733 The following paired-single functions map directly to a particular
9734 MIPS instruction.  Please refer to the architecture specification
9735 for details on what each instruction does.
9737 @table @code
9738 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
9739 Pair lower lower (@code{pll.ps}).
9741 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
9742 Pair upper lower (@code{pul.ps}).
9744 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
9745 Pair lower upper (@code{plu.ps}).
9747 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
9748 Pair upper upper (@code{puu.ps}).
9750 @item v2sf __builtin_mips_cvt_ps_s (float, float)
9751 Convert pair to paired single (@code{cvt.ps.s}).
9753 @item float __builtin_mips_cvt_s_pl (v2sf)
9754 Convert pair lower to single (@code{cvt.s.pl}).
9756 @item float __builtin_mips_cvt_s_pu (v2sf)
9757 Convert pair upper to single (@code{cvt.s.pu}).
9759 @item v2sf __builtin_mips_abs_ps (v2sf)
9760 Absolute value (@code{abs.ps}).
9762 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
9763 Align variable (@code{alnv.ps}).
9765 @emph{Note:} The value of the third parameter must be 0 or 4
9766 modulo 8, otherwise the result will be unpredictable.  Please read the
9767 instruction description for details.
9768 @end table
9770 The following multi-instruction functions are also available.
9771 In each case, @var{cond} can be any of the 16 floating-point conditions:
9772 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
9773 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
9774 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
9776 @table @code
9777 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9778 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9779 Conditional move based on floating point comparison (@code{c.@var{cond}.ps},
9780 @code{movt.ps}/@code{movf.ps}).
9782 The @code{movt} functions return the value @var{x} computed by:
9784 @smallexample
9785 c.@var{cond}.ps @var{cc},@var{a},@var{b}
9786 mov.ps @var{x},@var{c}
9787 movt.ps @var{x},@var{d},@var{cc}
9788 @end smallexample
9790 The @code{movf} functions are similar but use @code{movf.ps} instead
9791 of @code{movt.ps}.
9793 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9794 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9795 Comparison of two paired-single values (@code{c.@var{cond}.ps},
9796 @code{bc1t}/@code{bc1f}).
9798 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
9799 and return either the upper or lower half of the result.  For example:
9801 @smallexample
9802 v2sf a, b;
9803 if (__builtin_mips_upper_c_eq_ps (a, b))
9804   upper_halves_are_equal ();
9805 else
9806   upper_halves_are_unequal ();
9808 if (__builtin_mips_lower_c_eq_ps (a, b))
9809   lower_halves_are_equal ();
9810 else
9811   lower_halves_are_unequal ();
9812 @end smallexample
9813 @end table
9815 @node MIPS-3D Built-in Functions
9816 @subsubsection MIPS-3D Built-in Functions
9818 The MIPS-3D Application-Specific Extension (ASE) includes additional
9819 paired-single instructions that are designed to improve the performance
9820 of 3D graphics operations.  Support for these instructions is controlled
9821 by the @option{-mips3d} command-line option.
9823 The functions listed below map directly to a particular MIPS-3D
9824 instruction.  Please refer to the architecture specification for
9825 more details on what each instruction does.
9827 @table @code
9828 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
9829 Reduction add (@code{addr.ps}).
9831 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
9832 Reduction multiply (@code{mulr.ps}).
9834 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
9835 Convert paired single to paired word (@code{cvt.pw.ps}).
9837 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
9838 Convert paired word to paired single (@code{cvt.ps.pw}).
9840 @item float __builtin_mips_recip1_s (float)
9841 @itemx double __builtin_mips_recip1_d (double)
9842 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
9843 Reduced precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
9845 @item float __builtin_mips_recip2_s (float, float)
9846 @itemx double __builtin_mips_recip2_d (double, double)
9847 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
9848 Reduced precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
9850 @item float __builtin_mips_rsqrt1_s (float)
9851 @itemx double __builtin_mips_rsqrt1_d (double)
9852 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
9853 Reduced precision reciprocal square root (sequence step 1)
9854 (@code{rsqrt1.@var{fmt}}).
9856 @item float __builtin_mips_rsqrt2_s (float, float)
9857 @itemx double __builtin_mips_rsqrt2_d (double, double)
9858 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
9859 Reduced precision reciprocal square root (sequence step 2)
9860 (@code{rsqrt2.@var{fmt}}).
9861 @end table
9863 The following multi-instruction functions are also available.
9864 In each case, @var{cond} can be any of the 16 floating-point conditions:
9865 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
9866 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
9867 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
9869 @table @code
9870 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
9871 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
9872 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
9873 @code{bc1t}/@code{bc1f}).
9875 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
9876 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
9877 For example:
9879 @smallexample
9880 float a, b;
9881 if (__builtin_mips_cabs_eq_s (a, b))
9882   true ();
9883 else
9884   false ();
9885 @end smallexample
9887 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9888 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9889 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
9890 @code{bc1t}/@code{bc1f}).
9892 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
9893 and return either the upper or lower half of the result.  For example:
9895 @smallexample
9896 v2sf a, b;
9897 if (__builtin_mips_upper_cabs_eq_ps (a, b))
9898   upper_halves_are_equal ();
9899 else
9900   upper_halves_are_unequal ();
9902 if (__builtin_mips_lower_cabs_eq_ps (a, b))
9903   lower_halves_are_equal ();
9904 else
9905   lower_halves_are_unequal ();
9906 @end smallexample
9908 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9909 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9910 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
9911 @code{movt.ps}/@code{movf.ps}).
9913 The @code{movt} functions return the value @var{x} computed by:
9915 @smallexample
9916 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
9917 mov.ps @var{x},@var{c}
9918 movt.ps @var{x},@var{d},@var{cc}
9919 @end smallexample
9921 The @code{movf} functions are similar but use @code{movf.ps} instead
9922 of @code{movt.ps}.
9924 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9925 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9926 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9927 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
9928 Comparison of two paired-single values
9929 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
9930 @code{bc1any2t}/@code{bc1any2f}).
9932 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
9933 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
9934 result is true and the @code{all} forms return true if both results are true.
9935 For example:
9937 @smallexample
9938 v2sf a, b;
9939 if (__builtin_mips_any_c_eq_ps (a, b))
9940   one_is_true ();
9941 else
9942   both_are_false ();
9944 if (__builtin_mips_all_c_eq_ps (a, b))
9945   both_are_true ();
9946 else
9947   one_is_false ();
9948 @end smallexample
9950 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9951 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9952 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9953 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
9954 Comparison of four paired-single values
9955 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
9956 @code{bc1any4t}/@code{bc1any4f}).
9958 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
9959 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
9960 The @code{any} forms return true if any of the four results are true
9961 and the @code{all} forms return true if all four results are true.
9962 For example:
9964 @smallexample
9965 v2sf a, b, c, d;
9966 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
9967   some_are_true ();
9968 else
9969   all_are_false ();
9971 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
9972   all_are_true ();
9973 else
9974   some_are_false ();
9975 @end smallexample
9976 @end table
9978 @node picoChip Built-in Functions
9979 @subsection picoChip Built-in Functions
9981 GCC provides an interface to selected machine instructions from the
9982 picoChip instruction set.
9984 @table @code
9985 @item int __builtin_sbc (int @var{value})
9986 Sign bit count.  Return the number of consecutive bits in @var{value}
9987 which have the same value as the sign-bit.  The result is the number of
9988 leading sign bits minus one, giving the number of redundant sign bits in
9989 @var{value}.
9991 @item int __builtin_byteswap (int @var{value})
9992 Byte swap.  Return the result of swapping the upper and lower bytes of
9993 @var{value}.
9995 @item int __builtin_brev (int @var{value})
9996 Bit reversal.  Return the result of reversing the bits in
9997 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
9998 and so on.
10000 @item int __builtin_adds (int @var{x}, int @var{y})
10001 Saturating addition.  Return the result of adding @var{x} and @var{y},
10002 storing the value 32767 if the result overflows.
10004 @item int __builtin_subs (int @var{x}, int @var{y})
10005 Saturating subtraction.  Return the result of subtracting @var{y} from
10006 @var{x}, storing the value @minus{}32768 if the result overflows.
10008 @item void __builtin_halt (void)
10009 Halt.  The processor will stop execution.  This built-in is useful for
10010 implementing assertions.
10012 @end table
10014 @node Other MIPS Built-in Functions
10015 @subsection Other MIPS Built-in Functions
10017 GCC provides other MIPS-specific built-in functions:
10019 @table @code
10020 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
10021 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
10022 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
10023 when this function is available.
10024 @end table
10026 @node PowerPC AltiVec/VSX Built-in Functions
10027 @subsection PowerPC AltiVec Built-in Functions
10029 GCC provides an interface for the PowerPC family of processors to access
10030 the AltiVec operations described in Motorola's AltiVec Programming
10031 Interface Manual.  The interface is made available by including
10032 @code{<altivec.h>} and using @option{-maltivec} and
10033 @option{-mabi=altivec}.  The interface supports the following vector
10034 types.
10036 @smallexample
10037 vector unsigned char
10038 vector signed char
10039 vector bool char
10041 vector unsigned short
10042 vector signed short
10043 vector bool short
10044 vector pixel
10046 vector unsigned int
10047 vector signed int
10048 vector bool int
10049 vector float
10050 @end smallexample
10052 If @option{-mvsx} is used the following additional vector types are
10053 implemented.
10055 @smallexample
10056 vector unsigned long
10057 vector signed long
10058 vector double
10059 @end smallexample
10061 The long types are only implemented for 64-bit code generation, and
10062 the long type is only used in the floating point/integer conversion
10063 instructions.
10065 GCC's implementation of the high-level language interface available from
10066 C and C++ code differs from Motorola's documentation in several ways.
10068 @itemize @bullet
10070 @item
10071 A vector constant is a list of constant expressions within curly braces.
10073 @item
10074 A vector initializer requires no cast if the vector constant is of the
10075 same type as the variable it is initializing.
10077 @item
10078 If @code{signed} or @code{unsigned} is omitted, the signedness of the
10079 vector type is the default signedness of the base type.  The default
10080 varies depending on the operating system, so a portable program should
10081 always specify the signedness.
10083 @item
10084 Compiling with @option{-maltivec} adds keywords @code{__vector},
10085 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
10086 @code{bool}.  When compiling ISO C, the context-sensitive substitution
10087 of the keywords @code{vector}, @code{pixel} and @code{bool} is
10088 disabled.  To use them, you must include @code{<altivec.h>} instead.
10090 @item
10091 GCC allows using a @code{typedef} name as the type specifier for a
10092 vector type.
10094 @item
10095 For C, overloaded functions are implemented with macros so the following
10096 does not work:
10098 @smallexample
10099   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
10100 @end smallexample
10102 Since @code{vec_add} is a macro, the vector constant in the example
10103 is treated as four separate arguments.  Wrap the entire argument in
10104 parentheses for this to work.
10105 @end itemize
10107 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
10108 Internally, GCC uses built-in functions to achieve the functionality in
10109 the aforementioned header file, but they are not supported and are
10110 subject to change without notice.
10112 The following interfaces are supported for the generic and specific
10113 AltiVec operations and the AltiVec predicates.  In cases where there
10114 is a direct mapping between generic and specific operations, only the
10115 generic names are shown here, although the specific operations can also
10116 be used.
10118 Arguments that are documented as @code{const int} require literal
10119 integral values within the range required for that operation.
10121 @smallexample
10122 vector signed char vec_abs (vector signed char);
10123 vector signed short vec_abs (vector signed short);
10124 vector signed int vec_abs (vector signed int);
10125 vector float vec_abs (vector float);
10127 vector signed char vec_abss (vector signed char);
10128 vector signed short vec_abss (vector signed short);
10129 vector signed int vec_abss (vector signed int);
10131 vector signed char vec_add (vector bool char, vector signed char);
10132 vector signed char vec_add (vector signed char, vector bool char);
10133 vector signed char vec_add (vector signed char, vector signed char);
10134 vector unsigned char vec_add (vector bool char, vector unsigned char);
10135 vector unsigned char vec_add (vector unsigned char, vector bool char);
10136 vector unsigned char vec_add (vector unsigned char,
10137                               vector unsigned char);
10138 vector signed short vec_add (vector bool short, vector signed short);
10139 vector signed short vec_add (vector signed short, vector bool short);
10140 vector signed short vec_add (vector signed short, vector signed short);
10141 vector unsigned short vec_add (vector bool short,
10142                                vector unsigned short);
10143 vector unsigned short vec_add (vector unsigned short,
10144                                vector bool short);
10145 vector unsigned short vec_add (vector unsigned short,
10146                                vector unsigned short);
10147 vector signed int vec_add (vector bool int, vector signed int);
10148 vector signed int vec_add (vector signed int, vector bool int);
10149 vector signed int vec_add (vector signed int, vector signed int);
10150 vector unsigned int vec_add (vector bool int, vector unsigned int);
10151 vector unsigned int vec_add (vector unsigned int, vector bool int);
10152 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
10153 vector float vec_add (vector float, vector float);
10155 vector float vec_vaddfp (vector float, vector float);
10157 vector signed int vec_vadduwm (vector bool int, vector signed int);
10158 vector signed int vec_vadduwm (vector signed int, vector bool int);
10159 vector signed int vec_vadduwm (vector signed int, vector signed int);
10160 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
10161 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
10162 vector unsigned int vec_vadduwm (vector unsigned int,
10163                                  vector unsigned int);
10165 vector signed short vec_vadduhm (vector bool short,
10166                                  vector signed short);
10167 vector signed short vec_vadduhm (vector signed short,
10168                                  vector bool short);
10169 vector signed short vec_vadduhm (vector signed short,
10170                                  vector signed short);
10171 vector unsigned short vec_vadduhm (vector bool short,
10172                                    vector unsigned short);
10173 vector unsigned short vec_vadduhm (vector unsigned short,
10174                                    vector bool short);
10175 vector unsigned short vec_vadduhm (vector unsigned short,
10176                                    vector unsigned short);
10178 vector signed char vec_vaddubm (vector bool char, vector signed char);
10179 vector signed char vec_vaddubm (vector signed char, vector bool char);
10180 vector signed char vec_vaddubm (vector signed char, vector signed char);
10181 vector unsigned char vec_vaddubm (vector bool char,
10182                                   vector unsigned char);
10183 vector unsigned char vec_vaddubm (vector unsigned char,
10184                                   vector bool char);
10185 vector unsigned char vec_vaddubm (vector unsigned char,
10186                                   vector unsigned char);
10188 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
10190 vector unsigned char vec_adds (vector bool char, vector unsigned char);
10191 vector unsigned char vec_adds (vector unsigned char, vector bool char);
10192 vector unsigned char vec_adds (vector unsigned char,
10193                                vector unsigned char);
10194 vector signed char vec_adds (vector bool char, vector signed char);
10195 vector signed char vec_adds (vector signed char, vector bool char);
10196 vector signed char vec_adds (vector signed char, vector signed char);
10197 vector unsigned short vec_adds (vector bool short,
10198                                 vector unsigned short);
10199 vector unsigned short vec_adds (vector unsigned short,
10200                                 vector bool short);
10201 vector unsigned short vec_adds (vector unsigned short,
10202                                 vector unsigned short);
10203 vector signed short vec_adds (vector bool short, vector signed short);
10204 vector signed short vec_adds (vector signed short, vector bool short);
10205 vector signed short vec_adds (vector signed short, vector signed short);
10206 vector unsigned int vec_adds (vector bool int, vector unsigned int);
10207 vector unsigned int vec_adds (vector unsigned int, vector bool int);
10208 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
10209 vector signed int vec_adds (vector bool int, vector signed int);
10210 vector signed int vec_adds (vector signed int, vector bool int);
10211 vector signed int vec_adds (vector signed int, vector signed int);
10213 vector signed int vec_vaddsws (vector bool int, vector signed int);
10214 vector signed int vec_vaddsws (vector signed int, vector bool int);
10215 vector signed int vec_vaddsws (vector signed int, vector signed int);
10217 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
10218 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
10219 vector unsigned int vec_vadduws (vector unsigned int,
10220                                  vector unsigned int);
10222 vector signed short vec_vaddshs (vector bool short,
10223                                  vector signed short);
10224 vector signed short vec_vaddshs (vector signed short,
10225                                  vector bool short);
10226 vector signed short vec_vaddshs (vector signed short,
10227                                  vector signed short);
10229 vector unsigned short vec_vadduhs (vector bool short,
10230                                    vector unsigned short);
10231 vector unsigned short vec_vadduhs (vector unsigned short,
10232                                    vector bool short);
10233 vector unsigned short vec_vadduhs (vector unsigned short,
10234                                    vector unsigned short);
10236 vector signed char vec_vaddsbs (vector bool char, vector signed char);
10237 vector signed char vec_vaddsbs (vector signed char, vector bool char);
10238 vector signed char vec_vaddsbs (vector signed char, vector signed char);
10240 vector unsigned char vec_vaddubs (vector bool char,
10241                                   vector unsigned char);
10242 vector unsigned char vec_vaddubs (vector unsigned char,
10243                                   vector bool char);
10244 vector unsigned char vec_vaddubs (vector unsigned char,
10245                                   vector unsigned char);
10247 vector float vec_and (vector float, vector float);
10248 vector float vec_and (vector float, vector bool int);
10249 vector float vec_and (vector bool int, vector float);
10250 vector bool int vec_and (vector bool int, vector bool int);
10251 vector signed int vec_and (vector bool int, vector signed int);
10252 vector signed int vec_and (vector signed int, vector bool int);
10253 vector signed int vec_and (vector signed int, vector signed int);
10254 vector unsigned int vec_and (vector bool int, vector unsigned int);
10255 vector unsigned int vec_and (vector unsigned int, vector bool int);
10256 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
10257 vector bool short vec_and (vector bool short, vector bool short);
10258 vector signed short vec_and (vector bool short, vector signed short);
10259 vector signed short vec_and (vector signed short, vector bool short);
10260 vector signed short vec_and (vector signed short, vector signed short);
10261 vector unsigned short vec_and (vector bool short,
10262                                vector unsigned short);
10263 vector unsigned short vec_and (vector unsigned short,
10264                                vector bool short);
10265 vector unsigned short vec_and (vector unsigned short,
10266                                vector unsigned short);
10267 vector signed char vec_and (vector bool char, vector signed char);
10268 vector bool char vec_and (vector bool char, vector bool char);
10269 vector signed char vec_and (vector signed char, vector bool char);
10270 vector signed char vec_and (vector signed char, vector signed char);
10271 vector unsigned char vec_and (vector bool char, vector unsigned char);
10272 vector unsigned char vec_and (vector unsigned char, vector bool char);
10273 vector unsigned char vec_and (vector unsigned char,
10274                               vector unsigned char);
10276 vector float vec_andc (vector float, vector float);
10277 vector float vec_andc (vector float, vector bool int);
10278 vector float vec_andc (vector bool int, vector float);
10279 vector bool int vec_andc (vector bool int, vector bool int);
10280 vector signed int vec_andc (vector bool int, vector signed int);
10281 vector signed int vec_andc (vector signed int, vector bool int);
10282 vector signed int vec_andc (vector signed int, vector signed int);
10283 vector unsigned int vec_andc (vector bool int, vector unsigned int);
10284 vector unsigned int vec_andc (vector unsigned int, vector bool int);
10285 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
10286 vector bool short vec_andc (vector bool short, vector bool short);
10287 vector signed short vec_andc (vector bool short, vector signed short);
10288 vector signed short vec_andc (vector signed short, vector bool short);
10289 vector signed short vec_andc (vector signed short, vector signed short);
10290 vector unsigned short vec_andc (vector bool short,
10291                                 vector unsigned short);
10292 vector unsigned short vec_andc (vector unsigned short,
10293                                 vector bool short);
10294 vector unsigned short vec_andc (vector unsigned short,
10295                                 vector unsigned short);
10296 vector signed char vec_andc (vector bool char, vector signed char);
10297 vector bool char vec_andc (vector bool char, vector bool char);
10298 vector signed char vec_andc (vector signed char, vector bool char);
10299 vector signed char vec_andc (vector signed char, vector signed char);
10300 vector unsigned char vec_andc (vector bool char, vector unsigned char);
10301 vector unsigned char vec_andc (vector unsigned char, vector bool char);
10302 vector unsigned char vec_andc (vector unsigned char,
10303                                vector unsigned char);
10305 vector unsigned char vec_avg (vector unsigned char,
10306                               vector unsigned char);
10307 vector signed char vec_avg (vector signed char, vector signed char);
10308 vector unsigned short vec_avg (vector unsigned short,
10309                                vector unsigned short);
10310 vector signed short vec_avg (vector signed short, vector signed short);
10311 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
10312 vector signed int vec_avg (vector signed int, vector signed int);
10314 vector signed int vec_vavgsw (vector signed int, vector signed int);
10316 vector unsigned int vec_vavguw (vector unsigned int,
10317                                 vector unsigned int);
10319 vector signed short vec_vavgsh (vector signed short,
10320                                 vector signed short);
10322 vector unsigned short vec_vavguh (vector unsigned short,
10323                                   vector unsigned short);
10325 vector signed char vec_vavgsb (vector signed char, vector signed char);
10327 vector unsigned char vec_vavgub (vector unsigned char,
10328                                  vector unsigned char);
10330 vector float vec_copysign (vector float);
10332 vector float vec_ceil (vector float);
10334 vector signed int vec_cmpb (vector float, vector float);
10336 vector bool char vec_cmpeq (vector signed char, vector signed char);
10337 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
10338 vector bool short vec_cmpeq (vector signed short, vector signed short);
10339 vector bool short vec_cmpeq (vector unsigned short,
10340                              vector unsigned short);
10341 vector bool int vec_cmpeq (vector signed int, vector signed int);
10342 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
10343 vector bool int vec_cmpeq (vector float, vector float);
10345 vector bool int vec_vcmpeqfp (vector float, vector float);
10347 vector bool int vec_vcmpequw (vector signed int, vector signed int);
10348 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
10350 vector bool short vec_vcmpequh (vector signed short,
10351                                 vector signed short);
10352 vector bool short vec_vcmpequh (vector unsigned short,
10353                                 vector unsigned short);
10355 vector bool char vec_vcmpequb (vector signed char, vector signed char);
10356 vector bool char vec_vcmpequb (vector unsigned char,
10357                                vector unsigned char);
10359 vector bool int vec_cmpge (vector float, vector float);
10361 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
10362 vector bool char vec_cmpgt (vector signed char, vector signed char);
10363 vector bool short vec_cmpgt (vector unsigned short,
10364                              vector unsigned short);
10365 vector bool short vec_cmpgt (vector signed short, vector signed short);
10366 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
10367 vector bool int vec_cmpgt (vector signed int, vector signed int);
10368 vector bool int vec_cmpgt (vector float, vector float);
10370 vector bool int vec_vcmpgtfp (vector float, vector float);
10372 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
10374 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
10376 vector bool short vec_vcmpgtsh (vector signed short,
10377                                 vector signed short);
10379 vector bool short vec_vcmpgtuh (vector unsigned short,
10380                                 vector unsigned short);
10382 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
10384 vector bool char vec_vcmpgtub (vector unsigned char,
10385                                vector unsigned char);
10387 vector bool int vec_cmple (vector float, vector float);
10389 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
10390 vector bool char vec_cmplt (vector signed char, vector signed char);
10391 vector bool short vec_cmplt (vector unsigned short,
10392                              vector unsigned short);
10393 vector bool short vec_cmplt (vector signed short, vector signed short);
10394 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
10395 vector bool int vec_cmplt (vector signed int, vector signed int);
10396 vector bool int vec_cmplt (vector float, vector float);
10398 vector float vec_ctf (vector unsigned int, const int);
10399 vector float vec_ctf (vector signed int, const int);
10401 vector float vec_vcfsx (vector signed int, const int);
10403 vector float vec_vcfux (vector unsigned int, const int);
10405 vector signed int vec_cts (vector float, const int);
10407 vector unsigned int vec_ctu (vector float, const int);
10409 void vec_dss (const int);
10411 void vec_dssall (void);
10413 void vec_dst (const vector unsigned char *, int, const int);
10414 void vec_dst (const vector signed char *, int, const int);
10415 void vec_dst (const vector bool char *, int, const int);
10416 void vec_dst (const vector unsigned short *, int, const int);
10417 void vec_dst (const vector signed short *, int, const int);
10418 void vec_dst (const vector bool short *, int, const int);
10419 void vec_dst (const vector pixel *, int, const int);
10420 void vec_dst (const vector unsigned int *, int, const int);
10421 void vec_dst (const vector signed int *, int, const int);
10422 void vec_dst (const vector bool int *, int, const int);
10423 void vec_dst (const vector float *, int, const int);
10424 void vec_dst (const unsigned char *, int, const int);
10425 void vec_dst (const signed char *, int, const int);
10426 void vec_dst (const unsigned short *, int, const int);
10427 void vec_dst (const short *, int, const int);
10428 void vec_dst (const unsigned int *, int, const int);
10429 void vec_dst (const int *, int, const int);
10430 void vec_dst (const unsigned long *, int, const int);
10431 void vec_dst (const long *, int, const int);
10432 void vec_dst (const float *, int, const int);
10434 void vec_dstst (const vector unsigned char *, int, const int);
10435 void vec_dstst (const vector signed char *, int, const int);
10436 void vec_dstst (const vector bool char *, int, const int);
10437 void vec_dstst (const vector unsigned short *, int, const int);
10438 void vec_dstst (const vector signed short *, int, const int);
10439 void vec_dstst (const vector bool short *, int, const int);
10440 void vec_dstst (const vector pixel *, int, const int);
10441 void vec_dstst (const vector unsigned int *, int, const int);
10442 void vec_dstst (const vector signed int *, int, const int);
10443 void vec_dstst (const vector bool int *, int, const int);
10444 void vec_dstst (const vector float *, int, const int);
10445 void vec_dstst (const unsigned char *, int, const int);
10446 void vec_dstst (const signed char *, int, const int);
10447 void vec_dstst (const unsigned short *, int, const int);
10448 void vec_dstst (const short *, int, const int);
10449 void vec_dstst (const unsigned int *, int, const int);
10450 void vec_dstst (const int *, int, const int);
10451 void vec_dstst (const unsigned long *, int, const int);
10452 void vec_dstst (const long *, int, const int);
10453 void vec_dstst (const float *, int, const int);
10455 void vec_dststt (const vector unsigned char *, int, const int);
10456 void vec_dststt (const vector signed char *, int, const int);
10457 void vec_dststt (const vector bool char *, int, const int);
10458 void vec_dststt (const vector unsigned short *, int, const int);
10459 void vec_dststt (const vector signed short *, int, const int);
10460 void vec_dststt (const vector bool short *, int, const int);
10461 void vec_dststt (const vector pixel *, int, const int);
10462 void vec_dststt (const vector unsigned int *, int, const int);
10463 void vec_dststt (const vector signed int *, int, const int);
10464 void vec_dststt (const vector bool int *, int, const int);
10465 void vec_dststt (const vector float *, int, const int);
10466 void vec_dststt (const unsigned char *, int, const int);
10467 void vec_dststt (const signed char *, int, const int);
10468 void vec_dststt (const unsigned short *, int, const int);
10469 void vec_dststt (const short *, int, const int);
10470 void vec_dststt (const unsigned int *, int, const int);
10471 void vec_dststt (const int *, int, const int);
10472 void vec_dststt (const unsigned long *, int, const int);
10473 void vec_dststt (const long *, int, const int);
10474 void vec_dststt (const float *, int, const int);
10476 void vec_dstt (const vector unsigned char *, int, const int);
10477 void vec_dstt (const vector signed char *, int, const int);
10478 void vec_dstt (const vector bool char *, int, const int);
10479 void vec_dstt (const vector unsigned short *, int, const int);
10480 void vec_dstt (const vector signed short *, int, const int);
10481 void vec_dstt (const vector bool short *, int, const int);
10482 void vec_dstt (const vector pixel *, int, const int);
10483 void vec_dstt (const vector unsigned int *, int, const int);
10484 void vec_dstt (const vector signed int *, int, const int);
10485 void vec_dstt (const vector bool int *, int, const int);
10486 void vec_dstt (const vector float *, int, const int);
10487 void vec_dstt (const unsigned char *, int, const int);
10488 void vec_dstt (const signed char *, int, const int);
10489 void vec_dstt (const unsigned short *, int, const int);
10490 void vec_dstt (const short *, int, const int);
10491 void vec_dstt (const unsigned int *, int, const int);
10492 void vec_dstt (const int *, int, const int);
10493 void vec_dstt (const unsigned long *, int, const int);
10494 void vec_dstt (const long *, int, const int);
10495 void vec_dstt (const float *, int, const int);
10497 vector float vec_expte (vector float);
10499 vector float vec_floor (vector float);
10501 vector float vec_ld (int, const vector float *);
10502 vector float vec_ld (int, const float *);
10503 vector bool int vec_ld (int, const vector bool int *);
10504 vector signed int vec_ld (int, const vector signed int *);
10505 vector signed int vec_ld (int, const int *);
10506 vector signed int vec_ld (int, const long *);
10507 vector unsigned int vec_ld (int, const vector unsigned int *);
10508 vector unsigned int vec_ld (int, const unsigned int *);
10509 vector unsigned int vec_ld (int, const unsigned long *);
10510 vector bool short vec_ld (int, const vector bool short *);
10511 vector pixel vec_ld (int, const vector pixel *);
10512 vector signed short vec_ld (int, const vector signed short *);
10513 vector signed short vec_ld (int, const short *);
10514 vector unsigned short vec_ld (int, const vector unsigned short *);
10515 vector unsigned short vec_ld (int, const unsigned short *);
10516 vector bool char vec_ld (int, const vector bool char *);
10517 vector signed char vec_ld (int, const vector signed char *);
10518 vector signed char vec_ld (int, const signed char *);
10519 vector unsigned char vec_ld (int, const vector unsigned char *);
10520 vector unsigned char vec_ld (int, const unsigned char *);
10522 vector signed char vec_lde (int, const signed char *);
10523 vector unsigned char vec_lde (int, const unsigned char *);
10524 vector signed short vec_lde (int, const short *);
10525 vector unsigned short vec_lde (int, const unsigned short *);
10526 vector float vec_lde (int, const float *);
10527 vector signed int vec_lde (int, const int *);
10528 vector unsigned int vec_lde (int, const unsigned int *);
10529 vector signed int vec_lde (int, const long *);
10530 vector unsigned int vec_lde (int, const unsigned long *);
10532 vector float vec_lvewx (int, float *);
10533 vector signed int vec_lvewx (int, int *);
10534 vector unsigned int vec_lvewx (int, unsigned int *);
10535 vector signed int vec_lvewx (int, long *);
10536 vector unsigned int vec_lvewx (int, unsigned long *);
10538 vector signed short vec_lvehx (int, short *);
10539 vector unsigned short vec_lvehx (int, unsigned short *);
10541 vector signed char vec_lvebx (int, char *);
10542 vector unsigned char vec_lvebx (int, unsigned char *);
10544 vector float vec_ldl (int, const vector float *);
10545 vector float vec_ldl (int, const float *);
10546 vector bool int vec_ldl (int, const vector bool int *);
10547 vector signed int vec_ldl (int, const vector signed int *);
10548 vector signed int vec_ldl (int, const int *);
10549 vector signed int vec_ldl (int, const long *);
10550 vector unsigned int vec_ldl (int, const vector unsigned int *);
10551 vector unsigned int vec_ldl (int, const unsigned int *);
10552 vector unsigned int vec_ldl (int, const unsigned long *);
10553 vector bool short vec_ldl (int, const vector bool short *);
10554 vector pixel vec_ldl (int, const vector pixel *);
10555 vector signed short vec_ldl (int, const vector signed short *);
10556 vector signed short vec_ldl (int, const short *);
10557 vector unsigned short vec_ldl (int, const vector unsigned short *);
10558 vector unsigned short vec_ldl (int, const unsigned short *);
10559 vector bool char vec_ldl (int, const vector bool char *);
10560 vector signed char vec_ldl (int, const vector signed char *);
10561 vector signed char vec_ldl (int, const signed char *);
10562 vector unsigned char vec_ldl (int, const vector unsigned char *);
10563 vector unsigned char vec_ldl (int, const unsigned char *);
10565 vector float vec_loge (vector float);
10567 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
10568 vector unsigned char vec_lvsl (int, const volatile signed char *);
10569 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
10570 vector unsigned char vec_lvsl (int, const volatile short *);
10571 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
10572 vector unsigned char vec_lvsl (int, const volatile int *);
10573 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
10574 vector unsigned char vec_lvsl (int, const volatile long *);
10575 vector unsigned char vec_lvsl (int, const volatile float *);
10577 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
10578 vector unsigned char vec_lvsr (int, const volatile signed char *);
10579 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
10580 vector unsigned char vec_lvsr (int, const volatile short *);
10581 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
10582 vector unsigned char vec_lvsr (int, const volatile int *);
10583 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
10584 vector unsigned char vec_lvsr (int, const volatile long *);
10585 vector unsigned char vec_lvsr (int, const volatile float *);
10587 vector float vec_madd (vector float, vector float, vector float);
10589 vector signed short vec_madds (vector signed short,
10590                                vector signed short,
10591                                vector signed short);
10593 vector unsigned char vec_max (vector bool char, vector unsigned char);
10594 vector unsigned char vec_max (vector unsigned char, vector bool char);
10595 vector unsigned char vec_max (vector unsigned char,
10596                               vector unsigned char);
10597 vector signed char vec_max (vector bool char, vector signed char);
10598 vector signed char vec_max (vector signed char, vector bool char);
10599 vector signed char vec_max (vector signed char, vector signed char);
10600 vector unsigned short vec_max (vector bool short,
10601                                vector unsigned short);
10602 vector unsigned short vec_max (vector unsigned short,
10603                                vector bool short);
10604 vector unsigned short vec_max (vector unsigned short,
10605                                vector unsigned short);
10606 vector signed short vec_max (vector bool short, vector signed short);
10607 vector signed short vec_max (vector signed short, vector bool short);
10608 vector signed short vec_max (vector signed short, vector signed short);
10609 vector unsigned int vec_max (vector bool int, vector unsigned int);
10610 vector unsigned int vec_max (vector unsigned int, vector bool int);
10611 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
10612 vector signed int vec_max (vector bool int, vector signed int);
10613 vector signed int vec_max (vector signed int, vector bool int);
10614 vector signed int vec_max (vector signed int, vector signed int);
10615 vector float vec_max (vector float, vector float);
10617 vector float vec_vmaxfp (vector float, vector float);
10619 vector signed int vec_vmaxsw (vector bool int, vector signed int);
10620 vector signed int vec_vmaxsw (vector signed int, vector bool int);
10621 vector signed int vec_vmaxsw (vector signed int, vector signed int);
10623 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
10624 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
10625 vector unsigned int vec_vmaxuw (vector unsigned int,
10626                                 vector unsigned int);
10628 vector signed short vec_vmaxsh (vector bool short, vector signed short);
10629 vector signed short vec_vmaxsh (vector signed short, vector bool short);
10630 vector signed short vec_vmaxsh (vector signed short,
10631                                 vector signed short);
10633 vector unsigned short vec_vmaxuh (vector bool short,
10634                                   vector unsigned short);
10635 vector unsigned short vec_vmaxuh (vector unsigned short,
10636                                   vector bool short);
10637 vector unsigned short vec_vmaxuh (vector unsigned short,
10638                                   vector unsigned short);
10640 vector signed char vec_vmaxsb (vector bool char, vector signed char);
10641 vector signed char vec_vmaxsb (vector signed char, vector bool char);
10642 vector signed char vec_vmaxsb (vector signed char, vector signed char);
10644 vector unsigned char vec_vmaxub (vector bool char,
10645                                  vector unsigned char);
10646 vector unsigned char vec_vmaxub (vector unsigned char,
10647                                  vector bool char);
10648 vector unsigned char vec_vmaxub (vector unsigned char,
10649                                  vector unsigned char);
10651 vector bool char vec_mergeh (vector bool char, vector bool char);
10652 vector signed char vec_mergeh (vector signed char, vector signed char);
10653 vector unsigned char vec_mergeh (vector unsigned char,
10654                                  vector unsigned char);
10655 vector bool short vec_mergeh (vector bool short, vector bool short);
10656 vector pixel vec_mergeh (vector pixel, vector pixel);
10657 vector signed short vec_mergeh (vector signed short,
10658                                 vector signed short);
10659 vector unsigned short vec_mergeh (vector unsigned short,
10660                                   vector unsigned short);
10661 vector float vec_mergeh (vector float, vector float);
10662 vector bool int vec_mergeh (vector bool int, vector bool int);
10663 vector signed int vec_mergeh (vector signed int, vector signed int);
10664 vector unsigned int vec_mergeh (vector unsigned int,
10665                                 vector unsigned int);
10667 vector float vec_vmrghw (vector float, vector float);
10668 vector bool int vec_vmrghw (vector bool int, vector bool int);
10669 vector signed int vec_vmrghw (vector signed int, vector signed int);
10670 vector unsigned int vec_vmrghw (vector unsigned int,
10671                                 vector unsigned int);
10673 vector bool short vec_vmrghh (vector bool short, vector bool short);
10674 vector signed short vec_vmrghh (vector signed short,
10675                                 vector signed short);
10676 vector unsigned short vec_vmrghh (vector unsigned short,
10677                                   vector unsigned short);
10678 vector pixel vec_vmrghh (vector pixel, vector pixel);
10680 vector bool char vec_vmrghb (vector bool char, vector bool char);
10681 vector signed char vec_vmrghb (vector signed char, vector signed char);
10682 vector unsigned char vec_vmrghb (vector unsigned char,
10683                                  vector unsigned char);
10685 vector bool char vec_mergel (vector bool char, vector bool char);
10686 vector signed char vec_mergel (vector signed char, vector signed char);
10687 vector unsigned char vec_mergel (vector unsigned char,
10688                                  vector unsigned char);
10689 vector bool short vec_mergel (vector bool short, vector bool short);
10690 vector pixel vec_mergel (vector pixel, vector pixel);
10691 vector signed short vec_mergel (vector signed short,
10692                                 vector signed short);
10693 vector unsigned short vec_mergel (vector unsigned short,
10694                                   vector unsigned short);
10695 vector float vec_mergel (vector float, vector float);
10696 vector bool int vec_mergel (vector bool int, vector bool int);
10697 vector signed int vec_mergel (vector signed int, vector signed int);
10698 vector unsigned int vec_mergel (vector unsigned int,
10699                                 vector unsigned int);
10701 vector float vec_vmrglw (vector float, vector float);
10702 vector signed int vec_vmrglw (vector signed int, vector signed int);
10703 vector unsigned int vec_vmrglw (vector unsigned int,
10704                                 vector unsigned int);
10705 vector bool int vec_vmrglw (vector bool int, vector bool int);
10707 vector bool short vec_vmrglh (vector bool short, vector bool short);
10708 vector signed short vec_vmrglh (vector signed short,
10709                                 vector signed short);
10710 vector unsigned short vec_vmrglh (vector unsigned short,
10711                                   vector unsigned short);
10712 vector pixel vec_vmrglh (vector pixel, vector pixel);
10714 vector bool char vec_vmrglb (vector bool char, vector bool char);
10715 vector signed char vec_vmrglb (vector signed char, vector signed char);
10716 vector unsigned char vec_vmrglb (vector unsigned char,
10717                                  vector unsigned char);
10719 vector unsigned short vec_mfvscr (void);
10721 vector unsigned char vec_min (vector bool char, vector unsigned char);
10722 vector unsigned char vec_min (vector unsigned char, vector bool char);
10723 vector unsigned char vec_min (vector unsigned char,
10724                               vector unsigned char);
10725 vector signed char vec_min (vector bool char, vector signed char);
10726 vector signed char vec_min (vector signed char, vector bool char);
10727 vector signed char vec_min (vector signed char, vector signed char);
10728 vector unsigned short vec_min (vector bool short,
10729                                vector unsigned short);
10730 vector unsigned short vec_min (vector unsigned short,
10731                                vector bool short);
10732 vector unsigned short vec_min (vector unsigned short,
10733                                vector unsigned short);
10734 vector signed short vec_min (vector bool short, vector signed short);
10735 vector signed short vec_min (vector signed short, vector bool short);
10736 vector signed short vec_min (vector signed short, vector signed short);
10737 vector unsigned int vec_min (vector bool int, vector unsigned int);
10738 vector unsigned int vec_min (vector unsigned int, vector bool int);
10739 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
10740 vector signed int vec_min (vector bool int, vector signed int);
10741 vector signed int vec_min (vector signed int, vector bool int);
10742 vector signed int vec_min (vector signed int, vector signed int);
10743 vector float vec_min (vector float, vector float);
10745 vector float vec_vminfp (vector float, vector float);
10747 vector signed int vec_vminsw (vector bool int, vector signed int);
10748 vector signed int vec_vminsw (vector signed int, vector bool int);
10749 vector signed int vec_vminsw (vector signed int, vector signed int);
10751 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
10752 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
10753 vector unsigned int vec_vminuw (vector unsigned int,
10754                                 vector unsigned int);
10756 vector signed short vec_vminsh (vector bool short, vector signed short);
10757 vector signed short vec_vminsh (vector signed short, vector bool short);
10758 vector signed short vec_vminsh (vector signed short,
10759                                 vector signed short);
10761 vector unsigned short vec_vminuh (vector bool short,
10762                                   vector unsigned short);
10763 vector unsigned short vec_vminuh (vector unsigned short,
10764                                   vector bool short);
10765 vector unsigned short vec_vminuh (vector unsigned short,
10766                                   vector unsigned short);
10768 vector signed char vec_vminsb (vector bool char, vector signed char);
10769 vector signed char vec_vminsb (vector signed char, vector bool char);
10770 vector signed char vec_vminsb (vector signed char, vector signed char);
10772 vector unsigned char vec_vminub (vector bool char,
10773                                  vector unsigned char);
10774 vector unsigned char vec_vminub (vector unsigned char,
10775                                  vector bool char);
10776 vector unsigned char vec_vminub (vector unsigned char,
10777                                  vector unsigned char);
10779 vector signed short vec_mladd (vector signed short,
10780                                vector signed short,
10781                                vector signed short);
10782 vector signed short vec_mladd (vector signed short,
10783                                vector unsigned short,
10784                                vector unsigned short);
10785 vector signed short vec_mladd (vector unsigned short,
10786                                vector signed short,
10787                                vector signed short);
10788 vector unsigned short vec_mladd (vector unsigned short,
10789                                  vector unsigned short,
10790                                  vector unsigned short);
10792 vector signed short vec_mradds (vector signed short,
10793                                 vector signed short,
10794                                 vector signed short);
10796 vector unsigned int vec_msum (vector unsigned char,
10797                               vector unsigned char,
10798                               vector unsigned int);
10799 vector signed int vec_msum (vector signed char,
10800                             vector unsigned char,
10801                             vector signed int);
10802 vector unsigned int vec_msum (vector unsigned short,
10803                               vector unsigned short,
10804                               vector unsigned int);
10805 vector signed int vec_msum (vector signed short,
10806                             vector signed short,
10807                             vector signed int);
10809 vector signed int vec_vmsumshm (vector signed short,
10810                                 vector signed short,
10811                                 vector signed int);
10813 vector unsigned int vec_vmsumuhm (vector unsigned short,
10814                                   vector unsigned short,
10815                                   vector unsigned int);
10817 vector signed int vec_vmsummbm (vector signed char,
10818                                 vector unsigned char,
10819                                 vector signed int);
10821 vector unsigned int vec_vmsumubm (vector unsigned char,
10822                                   vector unsigned char,
10823                                   vector unsigned int);
10825 vector unsigned int vec_msums (vector unsigned short,
10826                                vector unsigned short,
10827                                vector unsigned int);
10828 vector signed int vec_msums (vector signed short,
10829                              vector signed short,
10830                              vector signed int);
10832 vector signed int vec_vmsumshs (vector signed short,
10833                                 vector signed short,
10834                                 vector signed int);
10836 vector unsigned int vec_vmsumuhs (vector unsigned short,
10837                                   vector unsigned short,
10838                                   vector unsigned int);
10840 void vec_mtvscr (vector signed int);
10841 void vec_mtvscr (vector unsigned int);
10842 void vec_mtvscr (vector bool int);
10843 void vec_mtvscr (vector signed short);
10844 void vec_mtvscr (vector unsigned short);
10845 void vec_mtvscr (vector bool short);
10846 void vec_mtvscr (vector pixel);
10847 void vec_mtvscr (vector signed char);
10848 void vec_mtvscr (vector unsigned char);
10849 void vec_mtvscr (vector bool char);
10851 vector unsigned short vec_mule (vector unsigned char,
10852                                 vector unsigned char);
10853 vector signed short vec_mule (vector signed char,
10854                               vector signed char);
10855 vector unsigned int vec_mule (vector unsigned short,
10856                               vector unsigned short);
10857 vector signed int vec_mule (vector signed short, vector signed short);
10859 vector signed int vec_vmulesh (vector signed short,
10860                                vector signed short);
10862 vector unsigned int vec_vmuleuh (vector unsigned short,
10863                                  vector unsigned short);
10865 vector signed short vec_vmulesb (vector signed char,
10866                                  vector signed char);
10868 vector unsigned short vec_vmuleub (vector unsigned char,
10869                                   vector unsigned char);
10871 vector unsigned short vec_mulo (vector unsigned char,
10872                                 vector unsigned char);
10873 vector signed short vec_mulo (vector signed char, vector signed char);
10874 vector unsigned int vec_mulo (vector unsigned short,
10875                               vector unsigned short);
10876 vector signed int vec_mulo (vector signed short, vector signed short);
10878 vector signed int vec_vmulosh (vector signed short,
10879                                vector signed short);
10881 vector unsigned int vec_vmulouh (vector unsigned short,
10882                                  vector unsigned short);
10884 vector signed short vec_vmulosb (vector signed char,
10885                                  vector signed char);
10887 vector unsigned short vec_vmuloub (vector unsigned char,
10888                                    vector unsigned char);
10890 vector float vec_nmsub (vector float, vector float, vector float);
10892 vector float vec_nor (vector float, vector float);
10893 vector signed int vec_nor (vector signed int, vector signed int);
10894 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
10895 vector bool int vec_nor (vector bool int, vector bool int);
10896 vector signed short vec_nor (vector signed short, vector signed short);
10897 vector unsigned short vec_nor (vector unsigned short,
10898                                vector unsigned short);
10899 vector bool short vec_nor (vector bool short, vector bool short);
10900 vector signed char vec_nor (vector signed char, vector signed char);
10901 vector unsigned char vec_nor (vector unsigned char,
10902                               vector unsigned char);
10903 vector bool char vec_nor (vector bool char, vector bool char);
10905 vector float vec_or (vector float, vector float);
10906 vector float vec_or (vector float, vector bool int);
10907 vector float vec_or (vector bool int, vector float);
10908 vector bool int vec_or (vector bool int, vector bool int);
10909 vector signed int vec_or (vector bool int, vector signed int);
10910 vector signed int vec_or (vector signed int, vector bool int);
10911 vector signed int vec_or (vector signed int, vector signed int);
10912 vector unsigned int vec_or (vector bool int, vector unsigned int);
10913 vector unsigned int vec_or (vector unsigned int, vector bool int);
10914 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
10915 vector bool short vec_or (vector bool short, vector bool short);
10916 vector signed short vec_or (vector bool short, vector signed short);
10917 vector signed short vec_or (vector signed short, vector bool short);
10918 vector signed short vec_or (vector signed short, vector signed short);
10919 vector unsigned short vec_or (vector bool short, vector unsigned short);
10920 vector unsigned short vec_or (vector unsigned short, vector bool short);
10921 vector unsigned short vec_or (vector unsigned short,
10922                               vector unsigned short);
10923 vector signed char vec_or (vector bool char, vector signed char);
10924 vector bool char vec_or (vector bool char, vector bool char);
10925 vector signed char vec_or (vector signed char, vector bool char);
10926 vector signed char vec_or (vector signed char, vector signed char);
10927 vector unsigned char vec_or (vector bool char, vector unsigned char);
10928 vector unsigned char vec_or (vector unsigned char, vector bool char);
10929 vector unsigned char vec_or (vector unsigned char,
10930                              vector unsigned char);
10932 vector signed char vec_pack (vector signed short, vector signed short);
10933 vector unsigned char vec_pack (vector unsigned short,
10934                                vector unsigned short);
10935 vector bool char vec_pack (vector bool short, vector bool short);
10936 vector signed short vec_pack (vector signed int, vector signed int);
10937 vector unsigned short vec_pack (vector unsigned int,
10938                                 vector unsigned int);
10939 vector bool short vec_pack (vector bool int, vector bool int);
10941 vector bool short vec_vpkuwum (vector bool int, vector bool int);
10942 vector signed short vec_vpkuwum (vector signed int, vector signed int);
10943 vector unsigned short vec_vpkuwum (vector unsigned int,
10944                                    vector unsigned int);
10946 vector bool char vec_vpkuhum (vector bool short, vector bool short);
10947 vector signed char vec_vpkuhum (vector signed short,
10948                                 vector signed short);
10949 vector unsigned char vec_vpkuhum (vector unsigned short,
10950                                   vector unsigned short);
10952 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
10954 vector unsigned char vec_packs (vector unsigned short,
10955                                 vector unsigned short);
10956 vector signed char vec_packs (vector signed short, vector signed short);
10957 vector unsigned short vec_packs (vector unsigned int,
10958                                  vector unsigned int);
10959 vector signed short vec_packs (vector signed int, vector signed int);
10961 vector signed short vec_vpkswss (vector signed int, vector signed int);
10963 vector unsigned short vec_vpkuwus (vector unsigned int,
10964                                    vector unsigned int);
10966 vector signed char vec_vpkshss (vector signed short,
10967                                 vector signed short);
10969 vector unsigned char vec_vpkuhus (vector unsigned short,
10970                                   vector unsigned short);
10972 vector unsigned char vec_packsu (vector unsigned short,
10973                                  vector unsigned short);
10974 vector unsigned char vec_packsu (vector signed short,
10975                                  vector signed short);
10976 vector unsigned short vec_packsu (vector unsigned int,
10977                                   vector unsigned int);
10978 vector unsigned short vec_packsu (vector signed int, vector signed int);
10980 vector unsigned short vec_vpkswus (vector signed int,
10981                                    vector signed int);
10983 vector unsigned char vec_vpkshus (vector signed short,
10984                                   vector signed short);
10986 vector float vec_perm (vector float,
10987                        vector float,
10988                        vector unsigned char);
10989 vector signed int vec_perm (vector signed int,
10990                             vector signed int,
10991                             vector unsigned char);
10992 vector unsigned int vec_perm (vector unsigned int,
10993                               vector unsigned int,
10994                               vector unsigned char);
10995 vector bool int vec_perm (vector bool int,
10996                           vector bool int,
10997                           vector unsigned char);
10998 vector signed short vec_perm (vector signed short,
10999                               vector signed short,
11000                               vector unsigned char);
11001 vector unsigned short vec_perm (vector unsigned short,
11002                                 vector unsigned short,
11003                                 vector unsigned char);
11004 vector bool short vec_perm (vector bool short,
11005                             vector bool short,
11006                             vector unsigned char);
11007 vector pixel vec_perm (vector pixel,
11008                        vector pixel,
11009                        vector unsigned char);
11010 vector signed char vec_perm (vector signed char,
11011                              vector signed char,
11012                              vector unsigned char);
11013 vector unsigned char vec_perm (vector unsigned char,
11014                                vector unsigned char,
11015                                vector unsigned char);
11016 vector bool char vec_perm (vector bool char,
11017                            vector bool char,
11018                            vector unsigned char);
11020 vector float vec_re (vector float);
11022 vector signed char vec_rl (vector signed char,
11023                            vector unsigned char);
11024 vector unsigned char vec_rl (vector unsigned char,
11025                              vector unsigned char);
11026 vector signed short vec_rl (vector signed short, vector unsigned short);
11027 vector unsigned short vec_rl (vector unsigned short,
11028                               vector unsigned short);
11029 vector signed int vec_rl (vector signed int, vector unsigned int);
11030 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
11032 vector signed int vec_vrlw (vector signed int, vector unsigned int);
11033 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
11035 vector signed short vec_vrlh (vector signed short,
11036                               vector unsigned short);
11037 vector unsigned short vec_vrlh (vector unsigned short,
11038                                 vector unsigned short);
11040 vector signed char vec_vrlb (vector signed char, vector unsigned char);
11041 vector unsigned char vec_vrlb (vector unsigned char,
11042                                vector unsigned char);
11044 vector float vec_round (vector float);
11046 vector float vec_recip (vector float, vector float);
11048 vector float vec_rsqrt (vector float);
11050 vector float vec_rsqrte (vector float);
11052 vector float vec_sel (vector float, vector float, vector bool int);
11053 vector float vec_sel (vector float, vector float, vector unsigned int);
11054 vector signed int vec_sel (vector signed int,
11055                            vector signed int,
11056                            vector bool int);
11057 vector signed int vec_sel (vector signed int,
11058                            vector signed int,
11059                            vector unsigned int);
11060 vector unsigned int vec_sel (vector unsigned int,
11061                              vector unsigned int,
11062                              vector bool int);
11063 vector unsigned int vec_sel (vector unsigned int,
11064                              vector unsigned int,
11065                              vector unsigned int);
11066 vector bool int vec_sel (vector bool int,
11067                          vector bool int,
11068                          vector bool int);
11069 vector bool int vec_sel (vector bool int,
11070                          vector bool int,
11071                          vector unsigned int);
11072 vector signed short vec_sel (vector signed short,
11073                              vector signed short,
11074                              vector bool short);
11075 vector signed short vec_sel (vector signed short,
11076                              vector signed short,
11077                              vector unsigned short);
11078 vector unsigned short vec_sel (vector unsigned short,
11079                                vector unsigned short,
11080                                vector bool short);
11081 vector unsigned short vec_sel (vector unsigned short,
11082                                vector unsigned short,
11083                                vector unsigned short);
11084 vector bool short vec_sel (vector bool short,
11085                            vector bool short,
11086                            vector bool short);
11087 vector bool short vec_sel (vector bool short,
11088                            vector bool short,
11089                            vector unsigned short);
11090 vector signed char vec_sel (vector signed char,
11091                             vector signed char,
11092                             vector bool char);
11093 vector signed char vec_sel (vector signed char,
11094                             vector signed char,
11095                             vector unsigned char);
11096 vector unsigned char vec_sel (vector unsigned char,
11097                               vector unsigned char,
11098                               vector bool char);
11099 vector unsigned char vec_sel (vector unsigned char,
11100                               vector unsigned char,
11101                               vector unsigned char);
11102 vector bool char vec_sel (vector bool char,
11103                           vector bool char,
11104                           vector bool char);
11105 vector bool char vec_sel (vector bool char,
11106                           vector bool char,
11107                           vector unsigned char);
11109 vector signed char vec_sl (vector signed char,
11110                            vector unsigned char);
11111 vector unsigned char vec_sl (vector unsigned char,
11112                              vector unsigned char);
11113 vector signed short vec_sl (vector signed short, vector unsigned short);
11114 vector unsigned short vec_sl (vector unsigned short,
11115                               vector unsigned short);
11116 vector signed int vec_sl (vector signed int, vector unsigned int);
11117 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
11119 vector signed int vec_vslw (vector signed int, vector unsigned int);
11120 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
11122 vector signed short vec_vslh (vector signed short,
11123                               vector unsigned short);
11124 vector unsigned short vec_vslh (vector unsigned short,
11125                                 vector unsigned short);
11127 vector signed char vec_vslb (vector signed char, vector unsigned char);
11128 vector unsigned char vec_vslb (vector unsigned char,
11129                                vector unsigned char);
11131 vector float vec_sld (vector float, vector float, const int);
11132 vector signed int vec_sld (vector signed int,
11133                            vector signed int,
11134                            const int);
11135 vector unsigned int vec_sld (vector unsigned int,
11136                              vector unsigned int,
11137                              const int);
11138 vector bool int vec_sld (vector bool int,
11139                          vector bool int,
11140                          const int);
11141 vector signed short vec_sld (vector signed short,
11142                              vector signed short,
11143                              const int);
11144 vector unsigned short vec_sld (vector unsigned short,
11145                                vector unsigned short,
11146                                const int);
11147 vector bool short vec_sld (vector bool short,
11148                            vector bool short,
11149                            const int);
11150 vector pixel vec_sld (vector pixel,
11151                       vector pixel,
11152                       const int);
11153 vector signed char vec_sld (vector signed char,
11154                             vector signed char,
11155                             const int);
11156 vector unsigned char vec_sld (vector unsigned char,
11157                               vector unsigned char,
11158                               const int);
11159 vector bool char vec_sld (vector bool char,
11160                           vector bool char,
11161                           const int);
11163 vector signed int vec_sll (vector signed int,
11164                            vector unsigned int);
11165 vector signed int vec_sll (vector signed int,
11166                            vector unsigned short);
11167 vector signed int vec_sll (vector signed int,
11168                            vector unsigned char);
11169 vector unsigned int vec_sll (vector unsigned int,
11170                              vector unsigned int);
11171 vector unsigned int vec_sll (vector unsigned int,
11172                              vector unsigned short);
11173 vector unsigned int vec_sll (vector unsigned int,
11174                              vector unsigned char);
11175 vector bool int vec_sll (vector bool int,
11176                          vector unsigned int);
11177 vector bool int vec_sll (vector bool int,
11178                          vector unsigned short);
11179 vector bool int vec_sll (vector bool int,
11180                          vector unsigned char);
11181 vector signed short vec_sll (vector signed short,
11182                              vector unsigned int);
11183 vector signed short vec_sll (vector signed short,
11184                              vector unsigned short);
11185 vector signed short vec_sll (vector signed short,
11186                              vector unsigned char);
11187 vector unsigned short vec_sll (vector unsigned short,
11188                                vector unsigned int);
11189 vector unsigned short vec_sll (vector unsigned short,
11190                                vector unsigned short);
11191 vector unsigned short vec_sll (vector unsigned short,
11192                                vector unsigned char);
11193 vector bool short vec_sll (vector bool short, vector unsigned int);
11194 vector bool short vec_sll (vector bool short, vector unsigned short);
11195 vector bool short vec_sll (vector bool short, vector unsigned char);
11196 vector pixel vec_sll (vector pixel, vector unsigned int);
11197 vector pixel vec_sll (vector pixel, vector unsigned short);
11198 vector pixel vec_sll (vector pixel, vector unsigned char);
11199 vector signed char vec_sll (vector signed char, vector unsigned int);
11200 vector signed char vec_sll (vector signed char, vector unsigned short);
11201 vector signed char vec_sll (vector signed char, vector unsigned char);
11202 vector unsigned char vec_sll (vector unsigned char,
11203                               vector unsigned int);
11204 vector unsigned char vec_sll (vector unsigned char,
11205                               vector unsigned short);
11206 vector unsigned char vec_sll (vector unsigned char,
11207                               vector unsigned char);
11208 vector bool char vec_sll (vector bool char, vector unsigned int);
11209 vector bool char vec_sll (vector bool char, vector unsigned short);
11210 vector bool char vec_sll (vector bool char, vector unsigned char);
11212 vector float vec_slo (vector float, vector signed char);
11213 vector float vec_slo (vector float, vector unsigned char);
11214 vector signed int vec_slo (vector signed int, vector signed char);
11215 vector signed int vec_slo (vector signed int, vector unsigned char);
11216 vector unsigned int vec_slo (vector unsigned int, vector signed char);
11217 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
11218 vector signed short vec_slo (vector signed short, vector signed char);
11219 vector signed short vec_slo (vector signed short, vector unsigned char);
11220 vector unsigned short vec_slo (vector unsigned short,
11221                                vector signed char);
11222 vector unsigned short vec_slo (vector unsigned short,
11223                                vector unsigned char);
11224 vector pixel vec_slo (vector pixel, vector signed char);
11225 vector pixel vec_slo (vector pixel, vector unsigned char);
11226 vector signed char vec_slo (vector signed char, vector signed char);
11227 vector signed char vec_slo (vector signed char, vector unsigned char);
11228 vector unsigned char vec_slo (vector unsigned char, vector signed char);
11229 vector unsigned char vec_slo (vector unsigned char,
11230                               vector unsigned char);
11232 vector signed char vec_splat (vector signed char, const int);
11233 vector unsigned char vec_splat (vector unsigned char, const int);
11234 vector bool char vec_splat (vector bool char, const int);
11235 vector signed short vec_splat (vector signed short, const int);
11236 vector unsigned short vec_splat (vector unsigned short, const int);
11237 vector bool short vec_splat (vector bool short, const int);
11238 vector pixel vec_splat (vector pixel, const int);
11239 vector float vec_splat (vector float, const int);
11240 vector signed int vec_splat (vector signed int, const int);
11241 vector unsigned int vec_splat (vector unsigned int, const int);
11242 vector bool int vec_splat (vector bool int, const int);
11244 vector float vec_vspltw (vector float, const int);
11245 vector signed int vec_vspltw (vector signed int, const int);
11246 vector unsigned int vec_vspltw (vector unsigned int, const int);
11247 vector bool int vec_vspltw (vector bool int, const int);
11249 vector bool short vec_vsplth (vector bool short, const int);
11250 vector signed short vec_vsplth (vector signed short, const int);
11251 vector unsigned short vec_vsplth (vector unsigned short, const int);
11252 vector pixel vec_vsplth (vector pixel, const int);
11254 vector signed char vec_vspltb (vector signed char, const int);
11255 vector unsigned char vec_vspltb (vector unsigned char, const int);
11256 vector bool char vec_vspltb (vector bool char, const int);
11258 vector signed char vec_splat_s8 (const int);
11260 vector signed short vec_splat_s16 (const int);
11262 vector signed int vec_splat_s32 (const int);
11264 vector unsigned char vec_splat_u8 (const int);
11266 vector unsigned short vec_splat_u16 (const int);
11268 vector unsigned int vec_splat_u32 (const int);
11270 vector signed char vec_sr (vector signed char, vector unsigned char);
11271 vector unsigned char vec_sr (vector unsigned char,
11272                              vector unsigned char);
11273 vector signed short vec_sr (vector signed short,
11274                             vector unsigned short);
11275 vector unsigned short vec_sr (vector unsigned short,
11276                               vector unsigned short);
11277 vector signed int vec_sr (vector signed int, vector unsigned int);
11278 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
11280 vector signed int vec_vsrw (vector signed int, vector unsigned int);
11281 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
11283 vector signed short vec_vsrh (vector signed short,
11284                               vector unsigned short);
11285 vector unsigned short vec_vsrh (vector unsigned short,
11286                                 vector unsigned short);
11288 vector signed char vec_vsrb (vector signed char, vector unsigned char);
11289 vector unsigned char vec_vsrb (vector unsigned char,
11290                                vector unsigned char);
11292 vector signed char vec_sra (vector signed char, vector unsigned char);
11293 vector unsigned char vec_sra (vector unsigned char,
11294                               vector unsigned char);
11295 vector signed short vec_sra (vector signed short,
11296                              vector unsigned short);
11297 vector unsigned short vec_sra (vector unsigned short,
11298                                vector unsigned short);
11299 vector signed int vec_sra (vector signed int, vector unsigned int);
11300 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
11302 vector signed int vec_vsraw (vector signed int, vector unsigned int);
11303 vector unsigned int vec_vsraw (vector unsigned int,
11304                                vector unsigned int);
11306 vector signed short vec_vsrah (vector signed short,
11307                                vector unsigned short);
11308 vector unsigned short vec_vsrah (vector unsigned short,
11309                                  vector unsigned short);
11311 vector signed char vec_vsrab (vector signed char, vector unsigned char);
11312 vector unsigned char vec_vsrab (vector unsigned char,
11313                                 vector unsigned char);
11315 vector signed int vec_srl (vector signed int, vector unsigned int);
11316 vector signed int vec_srl (vector signed int, vector unsigned short);
11317 vector signed int vec_srl (vector signed int, vector unsigned char);
11318 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
11319 vector unsigned int vec_srl (vector unsigned int,
11320                              vector unsigned short);
11321 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
11322 vector bool int vec_srl (vector bool int, vector unsigned int);
11323 vector bool int vec_srl (vector bool int, vector unsigned short);
11324 vector bool int vec_srl (vector bool int, vector unsigned char);
11325 vector signed short vec_srl (vector signed short, vector unsigned int);
11326 vector signed short vec_srl (vector signed short,
11327                              vector unsigned short);
11328 vector signed short vec_srl (vector signed short, vector unsigned char);
11329 vector unsigned short vec_srl (vector unsigned short,
11330                                vector unsigned int);
11331 vector unsigned short vec_srl (vector unsigned short,
11332                                vector unsigned short);
11333 vector unsigned short vec_srl (vector unsigned short,
11334                                vector unsigned char);
11335 vector bool short vec_srl (vector bool short, vector unsigned int);
11336 vector bool short vec_srl (vector bool short, vector unsigned short);
11337 vector bool short vec_srl (vector bool short, vector unsigned char);
11338 vector pixel vec_srl (vector pixel, vector unsigned int);
11339 vector pixel vec_srl (vector pixel, vector unsigned short);
11340 vector pixel vec_srl (vector pixel, vector unsigned char);
11341 vector signed char vec_srl (vector signed char, vector unsigned int);
11342 vector signed char vec_srl (vector signed char, vector unsigned short);
11343 vector signed char vec_srl (vector signed char, vector unsigned char);
11344 vector unsigned char vec_srl (vector unsigned char,
11345                               vector unsigned int);
11346 vector unsigned char vec_srl (vector unsigned char,
11347                               vector unsigned short);
11348 vector unsigned char vec_srl (vector unsigned char,
11349                               vector unsigned char);
11350 vector bool char vec_srl (vector bool char, vector unsigned int);
11351 vector bool char vec_srl (vector bool char, vector unsigned short);
11352 vector bool char vec_srl (vector bool char, vector unsigned char);
11354 vector float vec_sro (vector float, vector signed char);
11355 vector float vec_sro (vector float, vector unsigned char);
11356 vector signed int vec_sro (vector signed int, vector signed char);
11357 vector signed int vec_sro (vector signed int, vector unsigned char);
11358 vector unsigned int vec_sro (vector unsigned int, vector signed char);
11359 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
11360 vector signed short vec_sro (vector signed short, vector signed char);
11361 vector signed short vec_sro (vector signed short, vector unsigned char);
11362 vector unsigned short vec_sro (vector unsigned short,
11363                                vector signed char);
11364 vector unsigned short vec_sro (vector unsigned short,
11365                                vector unsigned char);
11366 vector pixel vec_sro (vector pixel, vector signed char);
11367 vector pixel vec_sro (vector pixel, vector unsigned char);
11368 vector signed char vec_sro (vector signed char, vector signed char);
11369 vector signed char vec_sro (vector signed char, vector unsigned char);
11370 vector unsigned char vec_sro (vector unsigned char, vector signed char);
11371 vector unsigned char vec_sro (vector unsigned char,
11372                               vector unsigned char);
11374 void vec_st (vector float, int, vector float *);
11375 void vec_st (vector float, int, float *);
11376 void vec_st (vector signed int, int, vector signed int *);
11377 void vec_st (vector signed int, int, int *);
11378 void vec_st (vector unsigned int, int, vector unsigned int *);
11379 void vec_st (vector unsigned int, int, unsigned int *);
11380 void vec_st (vector bool int, int, vector bool int *);
11381 void vec_st (vector bool int, int, unsigned int *);
11382 void vec_st (vector bool int, int, int *);
11383 void vec_st (vector signed short, int, vector signed short *);
11384 void vec_st (vector signed short, int, short *);
11385 void vec_st (vector unsigned short, int, vector unsigned short *);
11386 void vec_st (vector unsigned short, int, unsigned short *);
11387 void vec_st (vector bool short, int, vector bool short *);
11388 void vec_st (vector bool short, int, unsigned short *);
11389 void vec_st (vector pixel, int, vector pixel *);
11390 void vec_st (vector pixel, int, unsigned short *);
11391 void vec_st (vector pixel, int, short *);
11392 void vec_st (vector bool short, int, short *);
11393 void vec_st (vector signed char, int, vector signed char *);
11394 void vec_st (vector signed char, int, signed char *);
11395 void vec_st (vector unsigned char, int, vector unsigned char *);
11396 void vec_st (vector unsigned char, int, unsigned char *);
11397 void vec_st (vector bool char, int, vector bool char *);
11398 void vec_st (vector bool char, int, unsigned char *);
11399 void vec_st (vector bool char, int, signed char *);
11401 void vec_ste (vector signed char, int, signed char *);
11402 void vec_ste (vector unsigned char, int, unsigned char *);
11403 void vec_ste (vector bool char, int, signed char *);
11404 void vec_ste (vector bool char, int, unsigned char *);
11405 void vec_ste (vector signed short, int, short *);
11406 void vec_ste (vector unsigned short, int, unsigned short *);
11407 void vec_ste (vector bool short, int, short *);
11408 void vec_ste (vector bool short, int, unsigned short *);
11409 void vec_ste (vector pixel, int, short *);
11410 void vec_ste (vector pixel, int, unsigned short *);
11411 void vec_ste (vector float, int, float *);
11412 void vec_ste (vector signed int, int, int *);
11413 void vec_ste (vector unsigned int, int, unsigned int *);
11414 void vec_ste (vector bool int, int, int *);
11415 void vec_ste (vector bool int, int, unsigned int *);
11417 void vec_stvewx (vector float, int, float *);
11418 void vec_stvewx (vector signed int, int, int *);
11419 void vec_stvewx (vector unsigned int, int, unsigned int *);
11420 void vec_stvewx (vector bool int, int, int *);
11421 void vec_stvewx (vector bool int, int, unsigned int *);
11423 void vec_stvehx (vector signed short, int, short *);
11424 void vec_stvehx (vector unsigned short, int, unsigned short *);
11425 void vec_stvehx (vector bool short, int, short *);
11426 void vec_stvehx (vector bool short, int, unsigned short *);
11427 void vec_stvehx (vector pixel, int, short *);
11428 void vec_stvehx (vector pixel, int, unsigned short *);
11430 void vec_stvebx (vector signed char, int, signed char *);
11431 void vec_stvebx (vector unsigned char, int, unsigned char *);
11432 void vec_stvebx (vector bool char, int, signed char *);
11433 void vec_stvebx (vector bool char, int, unsigned char *);
11435 void vec_stl (vector float, int, vector float *);
11436 void vec_stl (vector float, int, float *);
11437 void vec_stl (vector signed int, int, vector signed int *);
11438 void vec_stl (vector signed int, int, int *);
11439 void vec_stl (vector unsigned int, int, vector unsigned int *);
11440 void vec_stl (vector unsigned int, int, unsigned int *);
11441 void vec_stl (vector bool int, int, vector bool int *);
11442 void vec_stl (vector bool int, int, unsigned int *);
11443 void vec_stl (vector bool int, int, int *);
11444 void vec_stl (vector signed short, int, vector signed short *);
11445 void vec_stl (vector signed short, int, short *);
11446 void vec_stl (vector unsigned short, int, vector unsigned short *);
11447 void vec_stl (vector unsigned short, int, unsigned short *);
11448 void vec_stl (vector bool short, int, vector bool short *);
11449 void vec_stl (vector bool short, int, unsigned short *);
11450 void vec_stl (vector bool short, int, short *);
11451 void vec_stl (vector pixel, int, vector pixel *);
11452 void vec_stl (vector pixel, int, unsigned short *);
11453 void vec_stl (vector pixel, int, short *);
11454 void vec_stl (vector signed char, int, vector signed char *);
11455 void vec_stl (vector signed char, int, signed char *);
11456 void vec_stl (vector unsigned char, int, vector unsigned char *);
11457 void vec_stl (vector unsigned char, int, unsigned char *);
11458 void vec_stl (vector bool char, int, vector bool char *);
11459 void vec_stl (vector bool char, int, unsigned char *);
11460 void vec_stl (vector bool char, int, signed char *);
11462 vector signed char vec_sub (vector bool char, vector signed char);
11463 vector signed char vec_sub (vector signed char, vector bool char);
11464 vector signed char vec_sub (vector signed char, vector signed char);
11465 vector unsigned char vec_sub (vector bool char, vector unsigned char);
11466 vector unsigned char vec_sub (vector unsigned char, vector bool char);
11467 vector unsigned char vec_sub (vector unsigned char,
11468                               vector unsigned char);
11469 vector signed short vec_sub (vector bool short, vector signed short);
11470 vector signed short vec_sub (vector signed short, vector bool short);
11471 vector signed short vec_sub (vector signed short, vector signed short);
11472 vector unsigned short vec_sub (vector bool short,
11473                                vector unsigned short);
11474 vector unsigned short vec_sub (vector unsigned short,
11475                                vector bool short);
11476 vector unsigned short vec_sub (vector unsigned short,
11477                                vector unsigned short);
11478 vector signed int vec_sub (vector bool int, vector signed int);
11479 vector signed int vec_sub (vector signed int, vector bool int);
11480 vector signed int vec_sub (vector signed int, vector signed int);
11481 vector unsigned int vec_sub (vector bool int, vector unsigned int);
11482 vector unsigned int vec_sub (vector unsigned int, vector bool int);
11483 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
11484 vector float vec_sub (vector float, vector float);
11486 vector float vec_vsubfp (vector float, vector float);
11488 vector signed int vec_vsubuwm (vector bool int, vector signed int);
11489 vector signed int vec_vsubuwm (vector signed int, vector bool int);
11490 vector signed int vec_vsubuwm (vector signed int, vector signed int);
11491 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
11492 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
11493 vector unsigned int vec_vsubuwm (vector unsigned int,
11494                                  vector unsigned int);
11496 vector signed short vec_vsubuhm (vector bool short,
11497                                  vector signed short);
11498 vector signed short vec_vsubuhm (vector signed short,
11499                                  vector bool short);
11500 vector signed short vec_vsubuhm (vector signed short,
11501                                  vector signed short);
11502 vector unsigned short vec_vsubuhm (vector bool short,
11503                                    vector unsigned short);
11504 vector unsigned short vec_vsubuhm (vector unsigned short,
11505                                    vector bool short);
11506 vector unsigned short vec_vsubuhm (vector unsigned short,
11507                                    vector unsigned short);
11509 vector signed char vec_vsububm (vector bool char, vector signed char);
11510 vector signed char vec_vsububm (vector signed char, vector bool char);
11511 vector signed char vec_vsububm (vector signed char, vector signed char);
11512 vector unsigned char vec_vsububm (vector bool char,
11513                                   vector unsigned char);
11514 vector unsigned char vec_vsububm (vector unsigned char,
11515                                   vector bool char);
11516 vector unsigned char vec_vsububm (vector unsigned char,
11517                                   vector unsigned char);
11519 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
11521 vector unsigned char vec_subs (vector bool char, vector unsigned char);
11522 vector unsigned char vec_subs (vector unsigned char, vector bool char);
11523 vector unsigned char vec_subs (vector unsigned char,
11524                                vector unsigned char);
11525 vector signed char vec_subs (vector bool char, vector signed char);
11526 vector signed char vec_subs (vector signed char, vector bool char);
11527 vector signed char vec_subs (vector signed char, vector signed char);
11528 vector unsigned short vec_subs (vector bool short,
11529                                 vector unsigned short);
11530 vector unsigned short vec_subs (vector unsigned short,
11531                                 vector bool short);
11532 vector unsigned short vec_subs (vector unsigned short,
11533                                 vector unsigned short);
11534 vector signed short vec_subs (vector bool short, vector signed short);
11535 vector signed short vec_subs (vector signed short, vector bool short);
11536 vector signed short vec_subs (vector signed short, vector signed short);
11537 vector unsigned int vec_subs (vector bool int, vector unsigned int);
11538 vector unsigned int vec_subs (vector unsigned int, vector bool int);
11539 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
11540 vector signed int vec_subs (vector bool int, vector signed int);
11541 vector signed int vec_subs (vector signed int, vector bool int);
11542 vector signed int vec_subs (vector signed int, vector signed int);
11544 vector signed int vec_vsubsws (vector bool int, vector signed int);
11545 vector signed int vec_vsubsws (vector signed int, vector bool int);
11546 vector signed int vec_vsubsws (vector signed int, vector signed int);
11548 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
11549 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
11550 vector unsigned int vec_vsubuws (vector unsigned int,
11551                                  vector unsigned int);
11553 vector signed short vec_vsubshs (vector bool short,
11554                                  vector signed short);
11555 vector signed short vec_vsubshs (vector signed short,
11556                                  vector bool short);
11557 vector signed short vec_vsubshs (vector signed short,
11558                                  vector signed short);
11560 vector unsigned short vec_vsubuhs (vector bool short,
11561                                    vector unsigned short);
11562 vector unsigned short vec_vsubuhs (vector unsigned short,
11563                                    vector bool short);
11564 vector unsigned short vec_vsubuhs (vector unsigned short,
11565                                    vector unsigned short);
11567 vector signed char vec_vsubsbs (vector bool char, vector signed char);
11568 vector signed char vec_vsubsbs (vector signed char, vector bool char);
11569 vector signed char vec_vsubsbs (vector signed char, vector signed char);
11571 vector unsigned char vec_vsububs (vector bool char,
11572                                   vector unsigned char);
11573 vector unsigned char vec_vsububs (vector unsigned char,
11574                                   vector bool char);
11575 vector unsigned char vec_vsububs (vector unsigned char,
11576                                   vector unsigned char);
11578 vector unsigned int vec_sum4s (vector unsigned char,
11579                                vector unsigned int);
11580 vector signed int vec_sum4s (vector signed char, vector signed int);
11581 vector signed int vec_sum4s (vector signed short, vector signed int);
11583 vector signed int vec_vsum4shs (vector signed short, vector signed int);
11585 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
11587 vector unsigned int vec_vsum4ubs (vector unsigned char,
11588                                   vector unsigned int);
11590 vector signed int vec_sum2s (vector signed int, vector signed int);
11592 vector signed int vec_sums (vector signed int, vector signed int);
11594 vector float vec_trunc (vector float);
11596 vector signed short vec_unpackh (vector signed char);
11597 vector bool short vec_unpackh (vector bool char);
11598 vector signed int vec_unpackh (vector signed short);
11599 vector bool int vec_unpackh (vector bool short);
11600 vector unsigned int vec_unpackh (vector pixel);
11602 vector bool int vec_vupkhsh (vector bool short);
11603 vector signed int vec_vupkhsh (vector signed short);
11605 vector unsigned int vec_vupkhpx (vector pixel);
11607 vector bool short vec_vupkhsb (vector bool char);
11608 vector signed short vec_vupkhsb (vector signed char);
11610 vector signed short vec_unpackl (vector signed char);
11611 vector bool short vec_unpackl (vector bool char);
11612 vector unsigned int vec_unpackl (vector pixel);
11613 vector signed int vec_unpackl (vector signed short);
11614 vector bool int vec_unpackl (vector bool short);
11616 vector unsigned int vec_vupklpx (vector pixel);
11618 vector bool int vec_vupklsh (vector bool short);
11619 vector signed int vec_vupklsh (vector signed short);
11621 vector bool short vec_vupklsb (vector bool char);
11622 vector signed short vec_vupklsb (vector signed char);
11624 vector float vec_xor (vector float, vector float);
11625 vector float vec_xor (vector float, vector bool int);
11626 vector float vec_xor (vector bool int, vector float);
11627 vector bool int vec_xor (vector bool int, vector bool int);
11628 vector signed int vec_xor (vector bool int, vector signed int);
11629 vector signed int vec_xor (vector signed int, vector bool int);
11630 vector signed int vec_xor (vector signed int, vector signed int);
11631 vector unsigned int vec_xor (vector bool int, vector unsigned int);
11632 vector unsigned int vec_xor (vector unsigned int, vector bool int);
11633 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
11634 vector bool short vec_xor (vector bool short, vector bool short);
11635 vector signed short vec_xor (vector bool short, vector signed short);
11636 vector signed short vec_xor (vector signed short, vector bool short);
11637 vector signed short vec_xor (vector signed short, vector signed short);
11638 vector unsigned short vec_xor (vector bool short,
11639                                vector unsigned short);
11640 vector unsigned short vec_xor (vector unsigned short,
11641                                vector bool short);
11642 vector unsigned short vec_xor (vector unsigned short,
11643                                vector unsigned short);
11644 vector signed char vec_xor (vector bool char, vector signed char);
11645 vector bool char vec_xor (vector bool char, vector bool char);
11646 vector signed char vec_xor (vector signed char, vector bool char);
11647 vector signed char vec_xor (vector signed char, vector signed char);
11648 vector unsigned char vec_xor (vector bool char, vector unsigned char);
11649 vector unsigned char vec_xor (vector unsigned char, vector bool char);
11650 vector unsigned char vec_xor (vector unsigned char,
11651                               vector unsigned char);
11653 int vec_all_eq (vector signed char, vector bool char);
11654 int vec_all_eq (vector signed char, vector signed char);
11655 int vec_all_eq (vector unsigned char, vector bool char);
11656 int vec_all_eq (vector unsigned char, vector unsigned char);
11657 int vec_all_eq (vector bool char, vector bool char);
11658 int vec_all_eq (vector bool char, vector unsigned char);
11659 int vec_all_eq (vector bool char, vector signed char);
11660 int vec_all_eq (vector signed short, vector bool short);
11661 int vec_all_eq (vector signed short, vector signed short);
11662 int vec_all_eq (vector unsigned short, vector bool short);
11663 int vec_all_eq (vector unsigned short, vector unsigned short);
11664 int vec_all_eq (vector bool short, vector bool short);
11665 int vec_all_eq (vector bool short, vector unsigned short);
11666 int vec_all_eq (vector bool short, vector signed short);
11667 int vec_all_eq (vector pixel, vector pixel);
11668 int vec_all_eq (vector signed int, vector bool int);
11669 int vec_all_eq (vector signed int, vector signed int);
11670 int vec_all_eq (vector unsigned int, vector bool int);
11671 int vec_all_eq (vector unsigned int, vector unsigned int);
11672 int vec_all_eq (vector bool int, vector bool int);
11673 int vec_all_eq (vector bool int, vector unsigned int);
11674 int vec_all_eq (vector bool int, vector signed int);
11675 int vec_all_eq (vector float, vector float);
11677 int vec_all_ge (vector bool char, vector unsigned char);
11678 int vec_all_ge (vector unsigned char, vector bool char);
11679 int vec_all_ge (vector unsigned char, vector unsigned char);
11680 int vec_all_ge (vector bool char, vector signed char);
11681 int vec_all_ge (vector signed char, vector bool char);
11682 int vec_all_ge (vector signed char, vector signed char);
11683 int vec_all_ge (vector bool short, vector unsigned short);
11684 int vec_all_ge (vector unsigned short, vector bool short);
11685 int vec_all_ge (vector unsigned short, vector unsigned short);
11686 int vec_all_ge (vector signed short, vector signed short);
11687 int vec_all_ge (vector bool short, vector signed short);
11688 int vec_all_ge (vector signed short, vector bool short);
11689 int vec_all_ge (vector bool int, vector unsigned int);
11690 int vec_all_ge (vector unsigned int, vector bool int);
11691 int vec_all_ge (vector unsigned int, vector unsigned int);
11692 int vec_all_ge (vector bool int, vector signed int);
11693 int vec_all_ge (vector signed int, vector bool int);
11694 int vec_all_ge (vector signed int, vector signed int);
11695 int vec_all_ge (vector float, vector float);
11697 int vec_all_gt (vector bool char, vector unsigned char);
11698 int vec_all_gt (vector unsigned char, vector bool char);
11699 int vec_all_gt (vector unsigned char, vector unsigned char);
11700 int vec_all_gt (vector bool char, vector signed char);
11701 int vec_all_gt (vector signed char, vector bool char);
11702 int vec_all_gt (vector signed char, vector signed char);
11703 int vec_all_gt (vector bool short, vector unsigned short);
11704 int vec_all_gt (vector unsigned short, vector bool short);
11705 int vec_all_gt (vector unsigned short, vector unsigned short);
11706 int vec_all_gt (vector bool short, vector signed short);
11707 int vec_all_gt (vector signed short, vector bool short);
11708 int vec_all_gt (vector signed short, vector signed short);
11709 int vec_all_gt (vector bool int, vector unsigned int);
11710 int vec_all_gt (vector unsigned int, vector bool int);
11711 int vec_all_gt (vector unsigned int, vector unsigned int);
11712 int vec_all_gt (vector bool int, vector signed int);
11713 int vec_all_gt (vector signed int, vector bool int);
11714 int vec_all_gt (vector signed int, vector signed int);
11715 int vec_all_gt (vector float, vector float);
11717 int vec_all_in (vector float, vector float);
11719 int vec_all_le (vector bool char, vector unsigned char);
11720 int vec_all_le (vector unsigned char, vector bool char);
11721 int vec_all_le (vector unsigned char, vector unsigned char);
11722 int vec_all_le (vector bool char, vector signed char);
11723 int vec_all_le (vector signed char, vector bool char);
11724 int vec_all_le (vector signed char, vector signed char);
11725 int vec_all_le (vector bool short, vector unsigned short);
11726 int vec_all_le (vector unsigned short, vector bool short);
11727 int vec_all_le (vector unsigned short, vector unsigned short);
11728 int vec_all_le (vector bool short, vector signed short);
11729 int vec_all_le (vector signed short, vector bool short);
11730 int vec_all_le (vector signed short, vector signed short);
11731 int vec_all_le (vector bool int, vector unsigned int);
11732 int vec_all_le (vector unsigned int, vector bool int);
11733 int vec_all_le (vector unsigned int, vector unsigned int);
11734 int vec_all_le (vector bool int, vector signed int);
11735 int vec_all_le (vector signed int, vector bool int);
11736 int vec_all_le (vector signed int, vector signed int);
11737 int vec_all_le (vector float, vector float);
11739 int vec_all_lt (vector bool char, vector unsigned char);
11740 int vec_all_lt (vector unsigned char, vector bool char);
11741 int vec_all_lt (vector unsigned char, vector unsigned char);
11742 int vec_all_lt (vector bool char, vector signed char);
11743 int vec_all_lt (vector signed char, vector bool char);
11744 int vec_all_lt (vector signed char, vector signed char);
11745 int vec_all_lt (vector bool short, vector unsigned short);
11746 int vec_all_lt (vector unsigned short, vector bool short);
11747 int vec_all_lt (vector unsigned short, vector unsigned short);
11748 int vec_all_lt (vector bool short, vector signed short);
11749 int vec_all_lt (vector signed short, vector bool short);
11750 int vec_all_lt (vector signed short, vector signed short);
11751 int vec_all_lt (vector bool int, vector unsigned int);
11752 int vec_all_lt (vector unsigned int, vector bool int);
11753 int vec_all_lt (vector unsigned int, vector unsigned int);
11754 int vec_all_lt (vector bool int, vector signed int);
11755 int vec_all_lt (vector signed int, vector bool int);
11756 int vec_all_lt (vector signed int, vector signed int);
11757 int vec_all_lt (vector float, vector float);
11759 int vec_all_nan (vector float);
11761 int vec_all_ne (vector signed char, vector bool char);
11762 int vec_all_ne (vector signed char, vector signed char);
11763 int vec_all_ne (vector unsigned char, vector bool char);
11764 int vec_all_ne (vector unsigned char, vector unsigned char);
11765 int vec_all_ne (vector bool char, vector bool char);
11766 int vec_all_ne (vector bool char, vector unsigned char);
11767 int vec_all_ne (vector bool char, vector signed char);
11768 int vec_all_ne (vector signed short, vector bool short);
11769 int vec_all_ne (vector signed short, vector signed short);
11770 int vec_all_ne (vector unsigned short, vector bool short);
11771 int vec_all_ne (vector unsigned short, vector unsigned short);
11772 int vec_all_ne (vector bool short, vector bool short);
11773 int vec_all_ne (vector bool short, vector unsigned short);
11774 int vec_all_ne (vector bool short, vector signed short);
11775 int vec_all_ne (vector pixel, vector pixel);
11776 int vec_all_ne (vector signed int, vector bool int);
11777 int vec_all_ne (vector signed int, vector signed int);
11778 int vec_all_ne (vector unsigned int, vector bool int);
11779 int vec_all_ne (vector unsigned int, vector unsigned int);
11780 int vec_all_ne (vector bool int, vector bool int);
11781 int vec_all_ne (vector bool int, vector unsigned int);
11782 int vec_all_ne (vector bool int, vector signed int);
11783 int vec_all_ne (vector float, vector float);
11785 int vec_all_nge (vector float, vector float);
11787 int vec_all_ngt (vector float, vector float);
11789 int vec_all_nle (vector float, vector float);
11791 int vec_all_nlt (vector float, vector float);
11793 int vec_all_numeric (vector float);
11795 int vec_any_eq (vector signed char, vector bool char);
11796 int vec_any_eq (vector signed char, vector signed char);
11797 int vec_any_eq (vector unsigned char, vector bool char);
11798 int vec_any_eq (vector unsigned char, vector unsigned char);
11799 int vec_any_eq (vector bool char, vector bool char);
11800 int vec_any_eq (vector bool char, vector unsigned char);
11801 int vec_any_eq (vector bool char, vector signed char);
11802 int vec_any_eq (vector signed short, vector bool short);
11803 int vec_any_eq (vector signed short, vector signed short);
11804 int vec_any_eq (vector unsigned short, vector bool short);
11805 int vec_any_eq (vector unsigned short, vector unsigned short);
11806 int vec_any_eq (vector bool short, vector bool short);
11807 int vec_any_eq (vector bool short, vector unsigned short);
11808 int vec_any_eq (vector bool short, vector signed short);
11809 int vec_any_eq (vector pixel, vector pixel);
11810 int vec_any_eq (vector signed int, vector bool int);
11811 int vec_any_eq (vector signed int, vector signed int);
11812 int vec_any_eq (vector unsigned int, vector bool int);
11813 int vec_any_eq (vector unsigned int, vector unsigned int);
11814 int vec_any_eq (vector bool int, vector bool int);
11815 int vec_any_eq (vector bool int, vector unsigned int);
11816 int vec_any_eq (vector bool int, vector signed int);
11817 int vec_any_eq (vector float, vector float);
11819 int vec_any_ge (vector signed char, vector bool char);
11820 int vec_any_ge (vector unsigned char, vector bool char);
11821 int vec_any_ge (vector unsigned char, vector unsigned char);
11822 int vec_any_ge (vector signed char, vector signed char);
11823 int vec_any_ge (vector bool char, vector unsigned char);
11824 int vec_any_ge (vector bool char, vector signed char);
11825 int vec_any_ge (vector unsigned short, vector bool short);
11826 int vec_any_ge (vector unsigned short, vector unsigned short);
11827 int vec_any_ge (vector signed short, vector signed short);
11828 int vec_any_ge (vector signed short, vector bool short);
11829 int vec_any_ge (vector bool short, vector unsigned short);
11830 int vec_any_ge (vector bool short, vector signed short);
11831 int vec_any_ge (vector signed int, vector bool int);
11832 int vec_any_ge (vector unsigned int, vector bool int);
11833 int vec_any_ge (vector unsigned int, vector unsigned int);
11834 int vec_any_ge (vector signed int, vector signed int);
11835 int vec_any_ge (vector bool int, vector unsigned int);
11836 int vec_any_ge (vector bool int, vector signed int);
11837 int vec_any_ge (vector float, vector float);
11839 int vec_any_gt (vector bool char, vector unsigned char);
11840 int vec_any_gt (vector unsigned char, vector bool char);
11841 int vec_any_gt (vector unsigned char, vector unsigned char);
11842 int vec_any_gt (vector bool char, vector signed char);
11843 int vec_any_gt (vector signed char, vector bool char);
11844 int vec_any_gt (vector signed char, vector signed char);
11845 int vec_any_gt (vector bool short, vector unsigned short);
11846 int vec_any_gt (vector unsigned short, vector bool short);
11847 int vec_any_gt (vector unsigned short, vector unsigned short);
11848 int vec_any_gt (vector bool short, vector signed short);
11849 int vec_any_gt (vector signed short, vector bool short);
11850 int vec_any_gt (vector signed short, vector signed short);
11851 int vec_any_gt (vector bool int, vector unsigned int);
11852 int vec_any_gt (vector unsigned int, vector bool int);
11853 int vec_any_gt (vector unsigned int, vector unsigned int);
11854 int vec_any_gt (vector bool int, vector signed int);
11855 int vec_any_gt (vector signed int, vector bool int);
11856 int vec_any_gt (vector signed int, vector signed int);
11857 int vec_any_gt (vector float, vector float);
11859 int vec_any_le (vector bool char, vector unsigned char);
11860 int vec_any_le (vector unsigned char, vector bool char);
11861 int vec_any_le (vector unsigned char, vector unsigned char);
11862 int vec_any_le (vector bool char, vector signed char);
11863 int vec_any_le (vector signed char, vector bool char);
11864 int vec_any_le (vector signed char, vector signed char);
11865 int vec_any_le (vector bool short, vector unsigned short);
11866 int vec_any_le (vector unsigned short, vector bool short);
11867 int vec_any_le (vector unsigned short, vector unsigned short);
11868 int vec_any_le (vector bool short, vector signed short);
11869 int vec_any_le (vector signed short, vector bool short);
11870 int vec_any_le (vector signed short, vector signed short);
11871 int vec_any_le (vector bool int, vector unsigned int);
11872 int vec_any_le (vector unsigned int, vector bool int);
11873 int vec_any_le (vector unsigned int, vector unsigned int);
11874 int vec_any_le (vector bool int, vector signed int);
11875 int vec_any_le (vector signed int, vector bool int);
11876 int vec_any_le (vector signed int, vector signed int);
11877 int vec_any_le (vector float, vector float);
11879 int vec_any_lt (vector bool char, vector unsigned char);
11880 int vec_any_lt (vector unsigned char, vector bool char);
11881 int vec_any_lt (vector unsigned char, vector unsigned char);
11882 int vec_any_lt (vector bool char, vector signed char);
11883 int vec_any_lt (vector signed char, vector bool char);
11884 int vec_any_lt (vector signed char, vector signed char);
11885 int vec_any_lt (vector bool short, vector unsigned short);
11886 int vec_any_lt (vector unsigned short, vector bool short);
11887 int vec_any_lt (vector unsigned short, vector unsigned short);
11888 int vec_any_lt (vector bool short, vector signed short);
11889 int vec_any_lt (vector signed short, vector bool short);
11890 int vec_any_lt (vector signed short, vector signed short);
11891 int vec_any_lt (vector bool int, vector unsigned int);
11892 int vec_any_lt (vector unsigned int, vector bool int);
11893 int vec_any_lt (vector unsigned int, vector unsigned int);
11894 int vec_any_lt (vector bool int, vector signed int);
11895 int vec_any_lt (vector signed int, vector bool int);
11896 int vec_any_lt (vector signed int, vector signed int);
11897 int vec_any_lt (vector float, vector float);
11899 int vec_any_nan (vector float);
11901 int vec_any_ne (vector signed char, vector bool char);
11902 int vec_any_ne (vector signed char, vector signed char);
11903 int vec_any_ne (vector unsigned char, vector bool char);
11904 int vec_any_ne (vector unsigned char, vector unsigned char);
11905 int vec_any_ne (vector bool char, vector bool char);
11906 int vec_any_ne (vector bool char, vector unsigned char);
11907 int vec_any_ne (vector bool char, vector signed char);
11908 int vec_any_ne (vector signed short, vector bool short);
11909 int vec_any_ne (vector signed short, vector signed short);
11910 int vec_any_ne (vector unsigned short, vector bool short);
11911 int vec_any_ne (vector unsigned short, vector unsigned short);
11912 int vec_any_ne (vector bool short, vector bool short);
11913 int vec_any_ne (vector bool short, vector unsigned short);
11914 int vec_any_ne (vector bool short, vector signed short);
11915 int vec_any_ne (vector pixel, vector pixel);
11916 int vec_any_ne (vector signed int, vector bool int);
11917 int vec_any_ne (vector signed int, vector signed int);
11918 int vec_any_ne (vector unsigned int, vector bool int);
11919 int vec_any_ne (vector unsigned int, vector unsigned int);
11920 int vec_any_ne (vector bool int, vector bool int);
11921 int vec_any_ne (vector bool int, vector unsigned int);
11922 int vec_any_ne (vector bool int, vector signed int);
11923 int vec_any_ne (vector float, vector float);
11925 int vec_any_nge (vector float, vector float);
11927 int vec_any_ngt (vector float, vector float);
11929 int vec_any_nle (vector float, vector float);
11931 int vec_any_nlt (vector float, vector float);
11933 int vec_any_numeric (vector float);
11935 int vec_any_out (vector float, vector float);
11936 @end smallexample
11938 If the vector/scalar (VSX) instruction set is available, the following
11939 additional functions are available:
11941 @smallexample
11942 vector double vec_abs (vector double);
11943 vector double vec_add (vector double, vector double);
11944 vector double vec_and (vector double, vector double);
11945 vector double vec_and (vector double, vector bool long);
11946 vector double vec_and (vector bool long, vector double);
11947 vector double vec_andc (vector double, vector double);
11948 vector double vec_andc (vector double, vector bool long);
11949 vector double vec_andc (vector bool long, vector double);
11950 vector double vec_ceil (vector double);
11951 vector bool long vec_cmpeq (vector double, vector double);
11952 vector bool long vec_cmpge (vector double, vector double);
11953 vector bool long vec_cmpgt (vector double, vector double);
11954 vector bool long vec_cmple (vector double, vector double);
11955 vector bool long vec_cmplt (vector double, vector double);
11956 vector float vec_div (vector float, vector float);
11957 vector double vec_div (vector double, vector double);
11958 vector double vec_floor (vector double);
11959 vector double vec_madd (vector double, vector double, vector double);
11960 vector double vec_max (vector double, vector double);
11961 vector double vec_min (vector double, vector double);
11962 vector float vec_msub (vector float, vector float, vector float);
11963 vector double vec_msub (vector double, vector double, vector double);
11964 vector float vec_mul (vector float, vector float);
11965 vector double vec_mul (vector double, vector double);
11966 vector float vec_nearbyint (vector float);
11967 vector double vec_nearbyint (vector double);
11968 vector float vec_nmadd (vector float, vector float, vector float);
11969 vector double vec_nmadd (vector double, vector double, vector double);
11970 vector double vec_nmsub (vector double, vector double, vector double);
11971 vector double vec_nor (vector double, vector double);
11972 vector double vec_or (vector double, vector double);
11973 vector double vec_or (vector double, vector bool long);
11974 vector double vec_or (vector bool long, vector double);
11975 vector double vec_perm (vector double,
11976                         vector double,
11977                         vector unsigned char);
11978 vector double vec_rint (vector double);
11979 vector double vec_recip (vector double, vector double);
11980 vector double vec_rsqrt (vector double);
11981 vector double vec_rsqrte (vector double);
11982 vector double vec_sel (vector double, vector double, vector bool long);
11983 vector double vec_sel (vector double, vector double, vector unsigned long);
11984 vector double vec_sub (vector double, vector double);
11985 vector float vec_sqrt (vector float);
11986 vector double vec_sqrt (vector double);
11987 vector double vec_trunc (vector double);
11988 vector double vec_xor (vector double, vector double);
11989 vector double vec_xor (vector double, vector bool long);
11990 vector double vec_xor (vector bool long, vector double);
11991 int vec_all_eq (vector double, vector double);
11992 int vec_all_ge (vector double, vector double);
11993 int vec_all_gt (vector double, vector double);
11994 int vec_all_le (vector double, vector double);
11995 int vec_all_lt (vector double, vector double);
11996 int vec_all_nan (vector double);
11997 int vec_all_ne (vector double, vector double);
11998 int vec_all_nge (vector double, vector double);
11999 int vec_all_ngt (vector double, vector double);
12000 int vec_all_nle (vector double, vector double);
12001 int vec_all_nlt (vector double, vector double);
12002 int vec_all_numeric (vector double);
12003 int vec_any_eq (vector double, vector double);
12004 int vec_any_ge (vector double, vector double);
12005 int vec_any_gt (vector double, vector double);
12006 int vec_any_le (vector double, vector double);
12007 int vec_any_lt (vector double, vector double);
12008 int vec_any_nan (vector double);
12009 int vec_any_ne (vector double, vector double);
12010 int vec_any_nge (vector double, vector double);
12011 int vec_any_ngt (vector double, vector double);
12012 int vec_any_nle (vector double, vector double);
12013 int vec_any_nlt (vector double, vector double);
12014 int vec_any_numeric (vector double);
12015 @end smallexample
12017 GCC provides a few other builtins on Powerpc to access certain instructions:
12018 @smallexample
12019 float __builtin_recipdivf (float, float);
12020 float __builtin_rsqrtf (float);
12021 double __builtin_recipdiv (double, double);
12022 double __builtin_rsqrt (double);
12023 long __builtin_bpermd (long, long);
12024 int __builtin_bswap16 (int);
12025 @end smallexample
12027 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12028 @code{__builtin_rsqrtf} functions generate multiple instructions to
12029 implement the reciprocal sqrt functionality using reciprocal sqrt
12030 estimate instructions.
12032 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12033 functions generate multiple instructions to implement division using
12034 the reciprocal estimate instructions.
12036 @node RX Built-in Functions
12037 @subsection RX Built-in Functions
12038 GCC supports some of the RX instructions which cannot be expressed in
12039 the C programming language via the use of built-in functions.  The
12040 following functions are supported:
12042 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
12043 Generates the @code{brk} machine instruction.
12044 @end deftypefn
12046 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
12047 Generates the @code{clrpsw} machine instruction to clear the specified
12048 bit in the processor status word.
12049 @end deftypefn
12051 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
12052 Generates the @code{int} machine instruction to generate an interrupt
12053 with the specified value.
12054 @end deftypefn
12056 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
12057 Generates the @code{machi} machine instruction to add the result of
12058 multiplying the top 16-bits of the two arguments into the
12059 accumulator.
12060 @end deftypefn
12062 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
12063 Generates the @code{maclo} machine instruction to add the result of
12064 multiplying the bottom 16-bits of the two arguments into the
12065 accumulator.
12066 @end deftypefn
12068 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
12069 Generates the @code{mulhi} machine instruction to place the result of
12070 multiplying the top 16-bits of the two arguments into the
12071 accumulator.
12072 @end deftypefn
12074 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
12075 Generates the @code{mullo} machine instruction to place the result of
12076 multiplying the bottom 16-bits of the two arguments into the
12077 accumulator.
12078 @end deftypefn
12080 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
12081 Generates the @code{mvfachi} machine instruction to read the top
12082 32-bits of the accumulator.
12083 @end deftypefn
12085 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
12086 Generates the @code{mvfacmi} machine instruction to read the middle
12087 32-bits of the accumulator.
12088 @end deftypefn
12090 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
12091 Generates the @code{mvfc} machine instruction which reads the control
12092 register specified in its argument and returns its value.
12093 @end deftypefn
12095 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
12096 Generates the @code{mvtachi} machine instruction to set the top
12097 32-bits of the accumulator.
12098 @end deftypefn
12100 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
12101 Generates the @code{mvtaclo} machine instruction to set the bottom
12102 32-bits of the accumulator.
12103 @end deftypefn
12105 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
12106 Generates the @code{mvtc} machine instruction which sets control
12107 register number @code{reg} to @code{val}.
12108 @end deftypefn
12110 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
12111 Generates the @code{mvtipl} machine instruction set the interrupt
12112 priority level.
12113 @end deftypefn
12115 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
12116 Generates the @code{racw} machine instruction to round the accumulator
12117 according to the specified mode.
12118 @end deftypefn
12120 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
12121 Generates the @code{revw} machine instruction which swaps the bytes in
12122 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
12123 and also bits 16--23 occupy bits 24--31 and vice versa.
12124 @end deftypefn
12126 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
12127 Generates the @code{rmpa} machine instruction which initiates a
12128 repeated multiply and accumulate sequence.
12129 @end deftypefn
12131 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
12132 Generates the @code{round} machine instruction which returns the
12133 floating point argument rounded according to the current rounding mode
12134 set in the floating point status word register.
12135 @end deftypefn
12137 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
12138 Generates the @code{sat} machine instruction which returns the
12139 saturated value of the argument.
12140 @end deftypefn
12142 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
12143 Generates the @code{setpsw} machine instruction to set the specified
12144 bit in the processor status word.
12145 @end deftypefn
12147 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
12148 Generates the @code{wait} machine instruction.
12149 @end deftypefn
12151 @node SPARC VIS Built-in Functions
12152 @subsection SPARC VIS Built-in Functions
12154 GCC supports SIMD operations on the SPARC using both the generic vector
12155 extensions (@pxref{Vector Extensions}) as well as built-in functions for
12156 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
12157 switch, the VIS extension is exposed as the following built-in functions:
12159 @smallexample
12160 typedef int v2si __attribute__ ((vector_size (8)));
12161 typedef short v4hi __attribute__ ((vector_size (8)));
12162 typedef short v2hi __attribute__ ((vector_size (4)));
12163 typedef char v8qi __attribute__ ((vector_size (8)));
12164 typedef char v4qi __attribute__ ((vector_size (4)));
12166 void * __builtin_vis_alignaddr (void *, long);
12167 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
12168 v2si __builtin_vis_faligndatav2si (v2si, v2si);
12169 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
12170 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
12172 v4hi __builtin_vis_fexpand (v4qi);
12174 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
12175 v4hi __builtin_vis_fmul8x16au (v4qi, v4hi);
12176 v4hi __builtin_vis_fmul8x16al (v4qi, v4hi);
12177 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
12178 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
12179 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
12180 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
12182 v4qi __builtin_vis_fpack16 (v4hi);
12183 v8qi __builtin_vis_fpack32 (v2si, v2si);
12184 v2hi __builtin_vis_fpackfix (v2si);
12185 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
12187 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
12188 @end smallexample
12190 @node SPU Built-in Functions
12191 @subsection SPU Built-in Functions
12193 GCC provides extensions for the SPU processor as described in the
12194 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
12195 found at @uref{http://cell.scei.co.jp/} or
12196 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
12197 implementation differs in several ways.
12199 @itemize @bullet
12201 @item
12202 The optional extension of specifying vector constants in parentheses is
12203 not supported.
12205 @item
12206 A vector initializer requires no cast if the vector constant is of the
12207 same type as the variable it is initializing.
12209 @item
12210 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12211 vector type is the default signedness of the base type.  The default
12212 varies depending on the operating system, so a portable program should
12213 always specify the signedness.
12215 @item
12216 By default, the keyword @code{__vector} is added. The macro
12217 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
12218 undefined.
12220 @item
12221 GCC allows using a @code{typedef} name as the type specifier for a
12222 vector type.
12224 @item
12225 For C, overloaded functions are implemented with macros so the following
12226 does not work:
12228 @smallexample
12229   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12230 @end smallexample
12232 Since @code{spu_add} is a macro, the vector constant in the example
12233 is treated as four separate arguments.  Wrap the entire argument in
12234 parentheses for this to work.
12236 @item
12237 The extended version of @code{__builtin_expect} is not supported.
12239 @end itemize
12241 @emph{Note:} Only the interface described in the aforementioned
12242 specification is supported. Internally, GCC uses built-in functions to
12243 implement the required functionality, but these are not supported and
12244 are subject to change without notice.
12246 @node Target Format Checks
12247 @section Format Checks Specific to Particular Target Machines
12249 For some target machines, GCC supports additional options to the
12250 format attribute
12251 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
12253 @menu
12254 * Solaris Format Checks::
12255 @end menu
12257 @node Solaris Format Checks
12258 @subsection Solaris Format Checks
12260 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
12261 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
12262 conversions, and the two-argument @code{%b} conversion for displaying
12263 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
12265 @node Pragmas
12266 @section Pragmas Accepted by GCC
12267 @cindex pragmas
12268 @cindex #pragma
12270 GCC supports several types of pragmas, primarily in order to compile
12271 code originally written for other compilers.  Note that in general
12272 we do not recommend the use of pragmas; @xref{Function Attributes},
12273 for further explanation.
12275 @menu
12276 * ARM Pragmas::
12277 * M32C Pragmas::
12278 * MeP Pragmas::
12279 * RS/6000 and PowerPC Pragmas::
12280 * Darwin Pragmas::
12281 * Solaris Pragmas::
12282 * Symbol-Renaming Pragmas::
12283 * Structure-Packing Pragmas::
12284 * Weak Pragmas::
12285 * Diagnostic Pragmas::
12286 * Visibility Pragmas::
12287 * Push/Pop Macro Pragmas::
12288 * Function Specific Option Pragmas::
12289 @end menu
12291 @node ARM Pragmas
12292 @subsection ARM Pragmas
12294 The ARM target defines pragmas for controlling the default addition of
12295 @code{long_call} and @code{short_call} attributes to functions.
12296 @xref{Function Attributes}, for information about the effects of these
12297 attributes.
12299 @table @code
12300 @item long_calls
12301 @cindex pragma, long_calls
12302 Set all subsequent functions to have the @code{long_call} attribute.
12304 @item no_long_calls
12305 @cindex pragma, no_long_calls
12306 Set all subsequent functions to have the @code{short_call} attribute.
12308 @item long_calls_off
12309 @cindex pragma, long_calls_off
12310 Do not affect the @code{long_call} or @code{short_call} attributes of
12311 subsequent functions.
12312 @end table
12314 @node M32C Pragmas
12315 @subsection M32C Pragmas
12317 @table @code
12318 @item GCC memregs @var{number}
12319 @cindex pragma, memregs
12320 Overrides the command-line option @code{-memregs=} for the current
12321 file.  Use with care!  This pragma must be before any function in the
12322 file, and mixing different memregs values in different objects may
12323 make them incompatible.  This pragma is useful when a
12324 performance-critical function uses a memreg for temporary values,
12325 as it may allow you to reduce the number of memregs used.
12327 @item ADDRESS @var{name} @var{address}
12328 @cindex pragma, address
12329 For any declared symbols matching @var{name}, this does three things
12330 to that symbol: it forces the symbol to be located at the given
12331 address (a number), it forces the symbol to be volatile, and it
12332 changes the symbol's scope to be static.  This pragma exists for
12333 compatibility with other compilers, but note that the common
12334 @code{1234H} numeric syntax is not supported (use @code{0x1234}
12335 instead).  Example:
12337 @example
12338 #pragma ADDRESS port3 0x103
12339 char port3;
12340 @end example
12342 @end table
12344 @node MeP Pragmas
12345 @subsection MeP Pragmas
12347 @table @code
12349 @item custom io_volatile (on|off)
12350 @cindex pragma, custom io_volatile
12351 Overrides the command line option @code{-mio-volatile} for the current
12352 file.  Note that for compatibility with future GCC releases, this
12353 option should only be used once before any @code{io} variables in each
12354 file.
12356 @item GCC coprocessor available @var{registers}
12357 @cindex pragma, coprocessor available
12358 Specifies which coprocessor registers are available to the register
12359 allocator.  @var{registers} may be a single register, register range
12360 separated by ellipses, or comma-separated list of those.  Example:
12362 @example
12363 #pragma GCC coprocessor available $c0...$c10, $c28
12364 @end example
12366 @item GCC coprocessor call_saved @var{registers}
12367 @cindex pragma, coprocessor call_saved
12368 Specifies which coprocessor registers are to be saved and restored by
12369 any function using them.  @var{registers} may be a single register,
12370 register range separated by ellipses, or comma-separated list of
12371 those.  Example:
12373 @example
12374 #pragma GCC coprocessor call_saved $c4...$c6, $c31
12375 @end example
12377 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
12378 @cindex pragma, coprocessor subclass
12379 Creates and defines a register class.  These register classes can be
12380 used by inline @code{asm} constructs.  @var{registers} may be a single
12381 register, register range separated by ellipses, or comma-separated
12382 list of those.  Example:
12384 @example
12385 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
12387 asm ("cpfoo %0" : "=B" (x));
12388 @end example
12390 @item GCC disinterrupt @var{name} , @var{name} @dots{}
12391 @cindex pragma, disinterrupt
12392 For the named functions, the compiler adds code to disable interrupts
12393 for the duration of those functions.  Any functions so named, which
12394 are not encountered in the source, cause a warning that the pragma was
12395 not used.  Examples:
12397 @example
12398 #pragma disinterrupt foo
12399 #pragma disinterrupt bar, grill
12400 int foo () @{ @dots{} @}
12401 @end example
12403 @item GCC call @var{name} , @var{name} @dots{}
12404 @cindex pragma, call
12405 For the named functions, the compiler always uses a register-indirect
12406 call model when calling the named functions.  Examples:
12408 @example
12409 extern int foo ();
12410 #pragma call foo
12411 @end example
12413 @end table
12415 @node RS/6000 and PowerPC Pragmas
12416 @subsection RS/6000 and PowerPC Pragmas
12418 The RS/6000 and PowerPC targets define one pragma for controlling
12419 whether or not the @code{longcall} attribute is added to function
12420 declarations by default.  This pragma overrides the @option{-mlongcall}
12421 option, but not the @code{longcall} and @code{shortcall} attributes.
12422 @xref{RS/6000 and PowerPC Options}, for more information about when long
12423 calls are and are not necessary.
12425 @table @code
12426 @item longcall (1)
12427 @cindex pragma, longcall
12428 Apply the @code{longcall} attribute to all subsequent function
12429 declarations.
12431 @item longcall (0)
12432 Do not apply the @code{longcall} attribute to subsequent function
12433 declarations.
12434 @end table
12436 @c Describe h8300 pragmas here.
12437 @c Describe sh pragmas here.
12438 @c Describe v850 pragmas here.
12440 @node Darwin Pragmas
12441 @subsection Darwin Pragmas
12443 The following pragmas are available for all architectures running the
12444 Darwin operating system.  These are useful for compatibility with other
12445 Mac OS compilers.
12447 @table @code
12448 @item mark @var{tokens}@dots{}
12449 @cindex pragma, mark
12450 This pragma is accepted, but has no effect.
12452 @item options align=@var{alignment}
12453 @cindex pragma, options align
12454 This pragma sets the alignment of fields in structures.  The values of
12455 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
12456 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
12457 properly; to restore the previous setting, use @code{reset} for the
12458 @var{alignment}.
12460 @item segment @var{tokens}@dots{}
12461 @cindex pragma, segment
12462 This pragma is accepted, but has no effect.
12464 @item unused (@var{var} [, @var{var}]@dots{})
12465 @cindex pragma, unused
12466 This pragma declares variables to be possibly unused.  GCC will not
12467 produce warnings for the listed variables.  The effect is similar to
12468 that of the @code{unused} attribute, except that this pragma may appear
12469 anywhere within the variables' scopes.
12470 @end table
12472 @node Solaris Pragmas
12473 @subsection Solaris Pragmas
12475 The Solaris target supports @code{#pragma redefine_extname}
12476 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
12477 @code{#pragma} directives for compatibility with the system compiler.
12479 @table @code
12480 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
12481 @cindex pragma, align
12483 Increase the minimum alignment of each @var{variable} to @var{alignment}.
12484 This is the same as GCC's @code{aligned} attribute @pxref{Variable
12485 Attributes}).  Macro expansion occurs on the arguments to this pragma
12486 when compiling C and Objective-C@.  It does not currently occur when
12487 compiling C++, but this is a bug which may be fixed in a future
12488 release.
12490 @item fini (@var{function} [, @var{function}]...)
12491 @cindex pragma, fini
12493 This pragma causes each listed @var{function} to be called after
12494 main, or during shared module unloading, by adding a call to the
12495 @code{.fini} section.
12497 @item init (@var{function} [, @var{function}]...)
12498 @cindex pragma, init
12500 This pragma causes each listed @var{function} to be called during
12501 initialization (before @code{main}) or during shared module loading, by
12502 adding a call to the @code{.init} section.
12504 @end table
12506 @node Symbol-Renaming Pragmas
12507 @subsection Symbol-Renaming Pragmas
12509 For compatibility with the Solaris and Tru64 UNIX system headers, GCC
12510 supports two @code{#pragma} directives which change the name used in
12511 assembly for a given declaration.  @code{#pragma extern_prefix} is only 
12512 available on platforms whose system headers need it. To get this effect 
12513 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
12514 Labels}).
12516 @table @code
12517 @item redefine_extname @var{oldname} @var{newname}
12518 @cindex pragma, redefine_extname
12520 This pragma gives the C function @var{oldname} the assembly symbol
12521 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
12522 will be defined if this pragma is available (currently on all platforms).
12524 @item extern_prefix @var{string}
12525 @cindex pragma, extern_prefix
12527 This pragma causes all subsequent external function and variable
12528 declarations to have @var{string} prepended to their assembly symbols.
12529 This effect may be terminated with another @code{extern_prefix} pragma
12530 whose argument is an empty string.  The preprocessor macro
12531 @code{__PRAGMA_EXTERN_PREFIX} will be defined if this pragma is
12532 available (currently only on Tru64 UNIX)@.
12533 @end table
12535 These pragmas and the asm labels extension interact in a complicated
12536 manner.  Here are some corner cases you may want to be aware of.
12538 @enumerate
12539 @item Both pragmas silently apply only to declarations with external
12540 linkage.  Asm labels do not have this restriction.
12542 @item In C++, both pragmas silently apply only to declarations with
12543 ``C'' linkage.  Again, asm labels do not have this restriction.
12545 @item If any of the three ways of changing the assembly name of a
12546 declaration is applied to a declaration whose assembly name has
12547 already been determined (either by a previous use of one of these
12548 features, or because the compiler needed the assembly name in order to
12549 generate code), and the new name is different, a warning issues and
12550 the name does not change.
12552 @item The @var{oldname} used by @code{#pragma redefine_extname} is
12553 always the C-language name.
12555 @item If @code{#pragma extern_prefix} is in effect, and a declaration
12556 occurs with an asm label attached, the prefix is silently ignored for
12557 that declaration.
12559 @item If @code{#pragma extern_prefix} and @code{#pragma redefine_extname}
12560 apply to the same declaration, whichever triggered first wins, and a
12561 warning issues if they contradict each other.  (We would like to have
12562 @code{#pragma redefine_extname} always win, for consistency with asm
12563 labels, but if @code{#pragma extern_prefix} triggers first we have no
12564 way of knowing that that happened.)
12565 @end enumerate
12567 @node Structure-Packing Pragmas
12568 @subsection Structure-Packing Pragmas
12570 For compatibility with Microsoft Windows compilers, GCC supports a
12571 set of @code{#pragma} directives which change the maximum alignment of
12572 members of structures (other than zero-width bitfields), unions, and
12573 classes subsequently defined. The @var{n} value below always is required
12574 to be a small power of two and specifies the new alignment in bytes.
12576 @enumerate
12577 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
12578 @item @code{#pragma pack()} sets the alignment to the one that was in
12579 effect when compilation started (see also command-line option
12580 @option{-fpack-struct[=<n>]} @pxref{Code Gen Options}).
12581 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
12582 setting on an internal stack and then optionally sets the new alignment.
12583 @item @code{#pragma pack(pop)} restores the alignment setting to the one
12584 saved at the top of the internal stack (and removes that stack entry).
12585 Note that @code{#pragma pack([@var{n}])} does not influence this internal
12586 stack; thus it is possible to have @code{#pragma pack(push)} followed by
12587 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
12588 @code{#pragma pack(pop)}.
12589 @end enumerate
12591 Some targets, e.g.@: i386 and powerpc, support the @code{ms_struct}
12592 @code{#pragma} which lays out a structure as the documented
12593 @code{__attribute__ ((ms_struct))}.
12594 @enumerate
12595 @item @code{#pragma ms_struct on} turns on the layout for structures
12596 declared.
12597 @item @code{#pragma ms_struct off} turns off the layout for structures
12598 declared.
12599 @item @code{#pragma ms_struct reset} goes back to the default layout.
12600 @end enumerate
12602 @node Weak Pragmas
12603 @subsection Weak Pragmas
12605 For compatibility with SVR4, GCC supports a set of @code{#pragma}
12606 directives for declaring symbols to be weak, and defining weak
12607 aliases.
12609 @table @code
12610 @item #pragma weak @var{symbol}
12611 @cindex pragma, weak
12612 This pragma declares @var{symbol} to be weak, as if the declaration
12613 had the attribute of the same name.  The pragma may appear before
12614 or after the declaration of @var{symbol}, but must appear before
12615 either its first use or its definition.  It is not an error for
12616 @var{symbol} to never be defined at all.
12618 @item #pragma weak @var{symbol1} = @var{symbol2}
12619 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
12620 It is an error if @var{symbol2} is not defined in the current
12621 translation unit.
12622 @end table
12624 @node Diagnostic Pragmas
12625 @subsection Diagnostic Pragmas
12627 GCC allows the user to selectively enable or disable certain types of
12628 diagnostics, and change the kind of the diagnostic.  For example, a
12629 project's policy might require that all sources compile with
12630 @option{-Werror} but certain files might have exceptions allowing
12631 specific types of warnings.  Or, a project might selectively enable
12632 diagnostics and treat them as errors depending on which preprocessor
12633 macros are defined.
12635 @table @code
12636 @item #pragma GCC diagnostic @var{kind} @var{option}
12637 @cindex pragma, diagnostic
12639 Modifies the disposition of a diagnostic.  Note that not all
12640 diagnostics are modifiable; at the moment only warnings (normally
12641 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
12642 Use @option{-fdiagnostics-show-option} to determine which diagnostics
12643 are controllable and which option controls them.
12645 @var{kind} is @samp{error} to treat this diagnostic as an error,
12646 @samp{warning} to treat it like a warning (even if @option{-Werror} is
12647 in effect), or @samp{ignored} if the diagnostic is to be ignored.
12648 @var{option} is a double quoted string which matches the command-line
12649 option.
12651 @example
12652 #pragma GCC diagnostic warning "-Wformat"
12653 #pragma GCC diagnostic error "-Wformat"
12654 #pragma GCC diagnostic ignored "-Wformat"
12655 @end example
12657 Note that these pragmas override any command-line options.  GCC keeps
12658 track of the location of each pragma, and issues diagnostics according
12659 to the state as of that point in the source file.  Thus, pragmas occurring
12660 after a line do not affect diagnostics caused by that line.
12662 @item #pragma GCC diagnostic push
12663 @itemx #pragma GCC diagnostic pop
12665 Causes GCC to remember the state of the diagnostics as of each
12666 @code{push}, and restore to that point at each @code{pop}.  If a
12667 @code{pop} has no matching @code{push}, the command line options are
12668 restored.
12670 @example
12671 #pragma GCC diagnostic error "-Wuninitialized"
12672   foo(a);                       /* error is given for this one */
12673 #pragma GCC diagnostic push
12674 #pragma GCC diagnostic ignored "-Wuninitialized"
12675   foo(b);                       /* no diagnostic for this one */
12676 #pragma GCC diagnostic pop
12677   foo(c);                       /* error is given for this one */
12678 #pragma GCC diagnostic pop
12679   foo(d);                       /* depends on command line options */
12680 @end example
12682 @end table
12684 GCC also offers a simple mechanism for printing messages during
12685 compilation.
12687 @table @code
12688 @item #pragma message @var{string}
12689 @cindex pragma, diagnostic
12691 Prints @var{string} as a compiler message on compilation.  The message
12692 is informational only, and is neither a compilation warning nor an error.
12694 @smallexample
12695 #pragma message "Compiling " __FILE__ "..."
12696 @end smallexample
12698 @var{string} may be parenthesized, and is printed with location
12699 information.  For example,
12701 @smallexample
12702 #define DO_PRAGMA(x) _Pragma (#x)
12703 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
12705 TODO(Remember to fix this)
12706 @end smallexample
12708 prints @samp{/tmp/file.c:4: note: #pragma message:
12709 TODO - Remember to fix this}.
12711 @end table
12713 @node Visibility Pragmas
12714 @subsection Visibility Pragmas
12716 @table @code
12717 @item #pragma GCC visibility push(@var{visibility})
12718 @itemx #pragma GCC visibility pop
12719 @cindex pragma, visibility
12721 This pragma allows the user to set the visibility for multiple
12722 declarations without having to give each a visibility attribute
12723 @xref{Function Attributes}, for more information about visibility and
12724 the attribute syntax.
12726 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
12727 declarations.  Class members and template specializations are not
12728 affected; if you want to override the visibility for a particular
12729 member or instantiation, you must use an attribute.
12731 @end table
12734 @node Push/Pop Macro Pragmas
12735 @subsection Push/Pop Macro Pragmas
12737 For compatibility with Microsoft Windows compilers, GCC supports
12738 @samp{#pragma push_macro(@var{"macro_name"})}
12739 and @samp{#pragma pop_macro(@var{"macro_name"})}.
12741 @table @code
12742 @item #pragma push_macro(@var{"macro_name"})
12743 @cindex pragma, push_macro
12744 This pragma saves the value of the macro named as @var{macro_name} to
12745 the top of the stack for this macro.
12747 @item #pragma pop_macro(@var{"macro_name"})
12748 @cindex pragma, pop_macro
12749 This pragma sets the value of the macro named as @var{macro_name} to
12750 the value on top of the stack for this macro. If the stack for
12751 @var{macro_name} is empty, the value of the macro remains unchanged.
12752 @end table
12754 For example:
12756 @smallexample
12757 #define X  1
12758 #pragma push_macro("X")
12759 #undef X
12760 #define X -1
12761 #pragma pop_macro("X")
12762 int x [X]; 
12763 @end smallexample
12765 In this example, the definition of X as 1 is saved by @code{#pragma
12766 push_macro} and restored by @code{#pragma pop_macro}.
12768 @node Function Specific Option Pragmas
12769 @subsection Function Specific Option Pragmas
12771 @table @code
12772 @item #pragma GCC target (@var{"string"}...)
12773 @cindex pragma GCC target
12775 This pragma allows you to set target specific options for functions
12776 defined later in the source file.  One or more strings can be
12777 specified.  Each function that is defined after this point will be as
12778 if @code{attribute((target("STRING")))} was specified for that
12779 function.  The parenthesis around the options is optional.
12780 @xref{Function Attributes}, for more information about the
12781 @code{target} attribute and the attribute syntax.
12783 The @samp{#pragma GCC target} pragma is not implemented in GCC
12784 versions earlier than 4.4, and is currently only implemented for the
12785 386 and x86_64 backends.
12786 @end table
12788 @table @code
12789 @item #pragma GCC optimize (@var{"string"}...)
12790 @cindex pragma GCC optimize
12792 This pragma allows you to set global optimization options for functions
12793 defined later in the source file.  One or more strings can be
12794 specified.  Each function that is defined after this point will be as
12795 if @code{attribute((optimize("STRING")))} was specified for that
12796 function.  The parenthesis around the options is optional.
12797 @xref{Function Attributes}, for more information about the
12798 @code{optimize} attribute and the attribute syntax.
12800 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
12801 versions earlier than 4.4.
12802 @end table
12804 @table @code
12805 @item #pragma GCC push_options
12806 @itemx #pragma GCC pop_options
12807 @cindex pragma GCC push_options
12808 @cindex pragma GCC pop_options
12810 These pragmas maintain a stack of the current target and optimization
12811 options.  It is intended for include files where you temporarily want
12812 to switch to using a different @samp{#pragma GCC target} or
12813 @samp{#pragma GCC optimize} and then to pop back to the previous
12814 options.
12816 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
12817 pragmas are not implemented in GCC versions earlier than 4.4.
12818 @end table
12820 @table @code
12821 @item #pragma GCC reset_options
12822 @cindex pragma GCC reset_options
12824 This pragma clears the current @code{#pragma GCC target} and
12825 @code{#pragma GCC optimize} to use the default switches as specified
12826 on the command line.
12828 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
12829 versions earlier than 4.4.
12830 @end table
12832 @node Unnamed Fields
12833 @section Unnamed struct/union fields within structs/unions
12834 @cindex struct
12835 @cindex union
12837 As permitted by ISO C1X and for compatibility with other compilers,
12838 GCC allows you to define
12839 a structure or union that contains, as fields, structures and unions
12840 without names.  For example:
12842 @smallexample
12843 struct @{
12844   int a;
12845   union @{
12846     int b;
12847     float c;
12848   @};
12849   int d;
12850 @} foo;
12851 @end smallexample
12853 In this example, the user would be able to access members of the unnamed
12854 union with code like @samp{foo.b}.  Note that only unnamed structs and
12855 unions are allowed, you may not have, for example, an unnamed
12856 @code{int}.
12858 You must never create such structures that cause ambiguous field definitions.
12859 For example, this structure:
12861 @smallexample
12862 struct @{
12863   int a;
12864   struct @{
12865     int a;
12866   @};
12867 @} foo;
12868 @end smallexample
12870 It is ambiguous which @code{a} is being referred to with @samp{foo.a}.
12871 The compiler gives errors for such constructs.
12873 @opindex fms-extensions
12874 Unless @option{-fms-extensions} is used, the unnamed field must be a
12875 structure or union definition without a tag (for example, @samp{struct
12876 @{ int a; @};}), or a @code{typedef} name for such a structure or
12877 union.  If @option{-fms-extensions} is used, the field may
12878 also be a definition with a tag such as @samp{struct foo @{ int a;
12879 @};}, a reference to a previously defined structure or union such as
12880 @samp{struct foo;}, or a reference to a @code{typedef} name for a
12881 previously defined structure or union type with a tag.
12883 @node Thread-Local
12884 @section Thread-Local Storage
12885 @cindex Thread-Local Storage
12886 @cindex @acronym{TLS}
12887 @cindex __thread
12889 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
12890 are allocated such that there is one instance of the variable per extant
12891 thread.  The run-time model GCC uses to implement this originates
12892 in the IA-64 processor-specific ABI, but has since been migrated
12893 to other processors as well.  It requires significant support from
12894 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
12895 system libraries (@file{libc.so} and @file{libpthread.so}), so it
12896 is not available everywhere.
12898 At the user level, the extension is visible with a new storage
12899 class keyword: @code{__thread}.  For example:
12901 @smallexample
12902 __thread int i;
12903 extern __thread struct state s;
12904 static __thread char *p;
12905 @end smallexample
12907 The @code{__thread} specifier may be used alone, with the @code{extern}
12908 or @code{static} specifiers, but with no other storage class specifier.
12909 When used with @code{extern} or @code{static}, @code{__thread} must appear
12910 immediately after the other storage class specifier.
12912 The @code{__thread} specifier may be applied to any global, file-scoped
12913 static, function-scoped static, or static data member of a class.  It may
12914 not be applied to block-scoped automatic or non-static data member.
12916 When the address-of operator is applied to a thread-local variable, it is
12917 evaluated at run-time and returns the address of the current thread's
12918 instance of that variable.  An address so obtained may be used by any
12919 thread.  When a thread terminates, any pointers to thread-local variables
12920 in that thread become invalid.
12922 No static initialization may refer to the address of a thread-local variable.
12924 In C++, if an initializer is present for a thread-local variable, it must
12925 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
12926 standard.
12928 See @uref{http://people.redhat.com/drepper/tls.pdf,
12929 ELF Handling For Thread-Local Storage} for a detailed explanation of
12930 the four thread-local storage addressing models, and how the run-time
12931 is expected to function.
12933 @menu
12934 * C99 Thread-Local Edits::
12935 * C++98 Thread-Local Edits::
12936 @end menu
12938 @node C99 Thread-Local Edits
12939 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
12941 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
12942 that document the exact semantics of the language extension.
12944 @itemize @bullet
12945 @item
12946 @cite{5.1.2  Execution environments}
12948 Add new text after paragraph 1
12950 @quotation
12951 Within either execution environment, a @dfn{thread} is a flow of
12952 control within a program.  It is implementation defined whether
12953 or not there may be more than one thread associated with a program.
12954 It is implementation defined how threads beyond the first are
12955 created, the name and type of the function called at thread
12956 startup, and how threads may be terminated.  However, objects
12957 with thread storage duration shall be initialized before thread
12958 startup.
12959 @end quotation
12961 @item
12962 @cite{6.2.4  Storage durations of objects}
12964 Add new text before paragraph 3
12966 @quotation
12967 An object whose identifier is declared with the storage-class
12968 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
12969 Its lifetime is the entire execution of the thread, and its
12970 stored value is initialized only once, prior to thread startup.
12971 @end quotation
12973 @item
12974 @cite{6.4.1  Keywords}
12976 Add @code{__thread}.
12978 @item
12979 @cite{6.7.1  Storage-class specifiers}
12981 Add @code{__thread} to the list of storage class specifiers in
12982 paragraph 1.
12984 Change paragraph 2 to
12986 @quotation
12987 With the exception of @code{__thread}, at most one storage-class
12988 specifier may be given [@dots{}].  The @code{__thread} specifier may
12989 be used alone, or immediately following @code{extern} or
12990 @code{static}.
12991 @end quotation
12993 Add new text after paragraph 6
12995 @quotation
12996 The declaration of an identifier for a variable that has
12997 block scope that specifies @code{__thread} shall also
12998 specify either @code{extern} or @code{static}.
13000 The @code{__thread} specifier shall be used only with
13001 variables.
13002 @end quotation
13003 @end itemize
13005 @node C++98 Thread-Local Edits
13006 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
13008 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
13009 that document the exact semantics of the language extension.
13011 @itemize @bullet
13012 @item
13013 @b{[intro.execution]}
13015 New text after paragraph 4
13017 @quotation
13018 A @dfn{thread} is a flow of control within the abstract machine.
13019 It is implementation defined whether or not there may be more than
13020 one thread.
13021 @end quotation
13023 New text after paragraph 7
13025 @quotation
13026 It is unspecified whether additional action must be taken to
13027 ensure when and whether side effects are visible to other threads.
13028 @end quotation
13030 @item
13031 @b{[lex.key]}
13033 Add @code{__thread}.
13035 @item
13036 @b{[basic.start.main]}
13038 Add after paragraph 5
13040 @quotation
13041 The thread that begins execution at the @code{main} function is called
13042 the @dfn{main thread}.  It is implementation defined how functions
13043 beginning threads other than the main thread are designated or typed.
13044 A function so designated, as well as the @code{main} function, is called
13045 a @dfn{thread startup function}.  It is implementation defined what
13046 happens if a thread startup function returns.  It is implementation
13047 defined what happens to other threads when any thread calls @code{exit}.
13048 @end quotation
13050 @item
13051 @b{[basic.start.init]}
13053 Add after paragraph 4
13055 @quotation
13056 The storage for an object of thread storage duration shall be
13057 statically initialized before the first statement of the thread startup
13058 function.  An object of thread storage duration shall not require
13059 dynamic initialization.
13060 @end quotation
13062 @item
13063 @b{[basic.start.term]}
13065 Add after paragraph 3
13067 @quotation
13068 The type of an object with thread storage duration shall not have a
13069 non-trivial destructor, nor shall it be an array type whose elements
13070 (directly or indirectly) have non-trivial destructors.
13071 @end quotation
13073 @item
13074 @b{[basic.stc]}
13076 Add ``thread storage duration'' to the list in paragraph 1.
13078 Change paragraph 2
13080 @quotation
13081 Thread, static, and automatic storage durations are associated with
13082 objects introduced by declarations [@dots{}].
13083 @end quotation
13085 Add @code{__thread} to the list of specifiers in paragraph 3.
13087 @item
13088 @b{[basic.stc.thread]}
13090 New section before @b{[basic.stc.static]}
13092 @quotation
13093 The keyword @code{__thread} applied to a non-local object gives the
13094 object thread storage duration.
13096 A local variable or class data member declared both @code{static}
13097 and @code{__thread} gives the variable or member thread storage
13098 duration.
13099 @end quotation
13101 @item
13102 @b{[basic.stc.static]}
13104 Change paragraph 1
13106 @quotation
13107 All objects which have neither thread storage duration, dynamic
13108 storage duration nor are local [@dots{}].
13109 @end quotation
13111 @item
13112 @b{[dcl.stc]}
13114 Add @code{__thread} to the list in paragraph 1.
13116 Change paragraph 1
13118 @quotation
13119 With the exception of @code{__thread}, at most one
13120 @var{storage-class-specifier} shall appear in a given
13121 @var{decl-specifier-seq}.  The @code{__thread} specifier may
13122 be used alone, or immediately following the @code{extern} or
13123 @code{static} specifiers.  [@dots{}]
13124 @end quotation
13126 Add after paragraph 5
13128 @quotation
13129 The @code{__thread} specifier can be applied only to the names of objects
13130 and to anonymous unions.
13131 @end quotation
13133 @item
13134 @b{[class.mem]}
13136 Add after paragraph 6
13138 @quotation
13139 Non-@code{static} members shall not be @code{__thread}.
13140 @end quotation
13141 @end itemize
13143 @node Binary constants
13144 @section Binary constants using the @samp{0b} prefix
13145 @cindex Binary constants using the @samp{0b} prefix
13147 Integer constants can be written as binary constants, consisting of a
13148 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
13149 @samp{0B}.  This is particularly useful in environments that operate a
13150 lot on the bit-level (like microcontrollers).
13152 The following statements are identical:
13154 @smallexample
13155 i =       42;
13156 i =     0x2a;
13157 i =      052;
13158 i = 0b101010;
13159 @end smallexample
13161 The type of these constants follows the same rules as for octal or
13162 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
13163 can be applied.
13165 @node C++ Extensions
13166 @chapter Extensions to the C++ Language
13167 @cindex extensions, C++ language
13168 @cindex C++ language extensions
13170 The GNU compiler provides these extensions to the C++ language (and you
13171 can also use most of the C language extensions in your C++ programs).  If you
13172 want to write code that checks whether these features are available, you can
13173 test for the GNU compiler the same way as for C programs: check for a
13174 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
13175 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
13176 Predefined Macros,cpp,The GNU C Preprocessor}).
13178 @menu
13179 * Volatiles::           What constitutes an access to a volatile object.
13180 * Restricted Pointers:: C99 restricted pointers and references.
13181 * Vague Linkage::       Where G++ puts inlines, vtables and such.
13182 * C++ Interface::       You can use a single C++ header file for both
13183                         declarations and definitions.
13184 * Template Instantiation:: Methods for ensuring that exactly one copy of
13185                         each needed template instantiation is emitted.
13186 * Bound member functions:: You can extract a function pointer to the
13187                         method denoted by a @samp{->*} or @samp{.*} expression.
13188 * C++ Attributes::      Variable, function, and type attributes for C++ only.
13189 * Namespace Association:: Strong using-directives for namespace association.
13190 * Type Traits::         Compiler support for type traits
13191 * Java Exceptions::     Tweaking exception handling to work with Java.
13192 * Deprecated Features:: Things will disappear from g++.
13193 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
13194 @end menu
13196 @node Volatiles
13197 @section When is a Volatile Object Accessed?
13198 @cindex accessing volatiles
13199 @cindex volatile read
13200 @cindex volatile write
13201 @cindex volatile access
13203 Both the C and C++ standard have the concept of volatile objects.  These
13204 are normally accessed by pointers and used for accessing hardware.  The
13205 standards encourage compilers to refrain from optimizations concerning
13206 accesses to volatile objects.  The C standard leaves it implementation
13207 defined  as to what constitutes a volatile access.  The C++ standard omits
13208 to specify this, except to say that C++ should behave in a similar manner
13209 to C with respect to volatiles, where possible.  The minimum either
13210 standard specifies is that at a sequence point all previous accesses to
13211 volatile objects have stabilized and no subsequent accesses have
13212 occurred.  Thus an implementation is free to reorder and combine
13213 volatile accesses which occur between sequence points, but cannot do so
13214 for accesses across a sequence point.  The use of volatiles does not
13215 allow you to violate the restriction on updating objects multiple times
13216 within a sequence point.
13218 @xref{Qualifiers implementation, , Volatile qualifier and the C compiler}.
13220 The behavior differs slightly between C and C++ in the non-obvious cases:
13222 @smallexample
13223 volatile int *src = @var{somevalue};
13224 *src;
13225 @end smallexample
13227 With C, such expressions are rvalues, and GCC interprets this either as a
13228 read of the volatile object being pointed to or only as request to evaluate
13229 the side-effects.  The C++ standard specifies that such expressions do not
13230 undergo lvalue to rvalue conversion, and that the type of the dereferenced
13231 object may be incomplete.  The C++ standard does not specify explicitly
13232 that it is this lvalue to rvalue conversion which may be responsible for
13233 causing an access.  However, there is reason to believe that it is,
13234 because otherwise certain simple expressions become undefined.  However,
13235 because it would surprise most programmers, G++ treats dereferencing a
13236 pointer to volatile object of complete type when the value is unused as
13237 GCC would do for an equivalent type in C@.  When the object has incomplete
13238 type, G++ issues a warning; if you wish to force an error, you must
13239 force a conversion to rvalue with, for instance, a static cast.
13241 When using a reference to volatile, G++ does not treat equivalent
13242 expressions as accesses to volatiles, but instead issues a warning that
13243 no volatile is accessed.  The rationale for this is that otherwise it
13244 becomes difficult to determine where volatile access occur, and not
13245 possible to ignore the return value from functions returning volatile
13246 references.  Again, if you wish to force a read, cast the reference to
13247 an rvalue.
13249 @node Restricted Pointers
13250 @section Restricting Pointer Aliasing
13251 @cindex restricted pointers
13252 @cindex restricted references
13253 @cindex restricted this pointer
13255 As with the C front end, G++ understands the C99 feature of restricted pointers,
13256 specified with the @code{__restrict__}, or @code{__restrict} type
13257 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
13258 language flag, @code{restrict} is not a keyword in C++.
13260 In addition to allowing restricted pointers, you can specify restricted
13261 references, which indicate that the reference is not aliased in the local
13262 context.
13264 @smallexample
13265 void fn (int *__restrict__ rptr, int &__restrict__ rref)
13267   /* @r{@dots{}} */
13269 @end smallexample
13271 @noindent
13272 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
13273 @var{rref} refers to a (different) unaliased integer.
13275 You may also specify whether a member function's @var{this} pointer is
13276 unaliased by using @code{__restrict__} as a member function qualifier.
13278 @smallexample
13279 void T::fn () __restrict__
13281   /* @r{@dots{}} */
13283 @end smallexample
13285 @noindent
13286 Within the body of @code{T::fn}, @var{this} will have the effective
13287 definition @code{T *__restrict__ const this}.  Notice that the
13288 interpretation of a @code{__restrict__} member function qualifier is
13289 different to that of @code{const} or @code{volatile} qualifier, in that it
13290 is applied to the pointer rather than the object.  This is consistent with
13291 other compilers which implement restricted pointers.
13293 As with all outermost parameter qualifiers, @code{__restrict__} is
13294 ignored in function definition matching.  This means you only need to
13295 specify @code{__restrict__} in a function definition, rather than
13296 in a function prototype as well.
13298 @node Vague Linkage
13299 @section Vague Linkage
13300 @cindex vague linkage
13302 There are several constructs in C++ which require space in the object
13303 file but are not clearly tied to a single translation unit.  We say that
13304 these constructs have ``vague linkage''.  Typically such constructs are
13305 emitted wherever they are needed, though sometimes we can be more
13306 clever.
13308 @table @asis
13309 @item Inline Functions
13310 Inline functions are typically defined in a header file which can be
13311 included in many different compilations.  Hopefully they can usually be
13312 inlined, but sometimes an out-of-line copy is necessary, if the address
13313 of the function is taken or if inlining fails.  In general, we emit an
13314 out-of-line copy in all translation units where one is needed.  As an
13315 exception, we only emit inline virtual functions with the vtable, since
13316 it will always require a copy.
13318 Local static variables and string constants used in an inline function
13319 are also considered to have vague linkage, since they must be shared
13320 between all inlined and out-of-line instances of the function.
13322 @item VTables
13323 @cindex vtable
13324 C++ virtual functions are implemented in most compilers using a lookup
13325 table, known as a vtable.  The vtable contains pointers to the virtual
13326 functions provided by a class, and each object of the class contains a
13327 pointer to its vtable (or vtables, in some multiple-inheritance
13328 situations).  If the class declares any non-inline, non-pure virtual
13329 functions, the first one is chosen as the ``key method'' for the class,
13330 and the vtable is only emitted in the translation unit where the key
13331 method is defined.
13333 @emph{Note:} If the chosen key method is later defined as inline, the
13334 vtable will still be emitted in every translation unit which defines it.
13335 Make sure that any inline virtuals are declared inline in the class
13336 body, even if they are not defined there.
13338 @item type_info objects
13339 @cindex type_info
13340 @cindex RTTI
13341 C++ requires information about types to be written out in order to
13342 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
13343 For polymorphic classes (classes with virtual functions), the type_info
13344 object is written out along with the vtable so that @samp{dynamic_cast}
13345 can determine the dynamic type of a class object at runtime.  For all
13346 other types, we write out the type_info object when it is used: when
13347 applying @samp{typeid} to an expression, throwing an object, or
13348 referring to a type in a catch clause or exception specification.
13350 @item Template Instantiations
13351 Most everything in this section also applies to template instantiations,
13352 but there are other options as well.
13353 @xref{Template Instantiation,,Where's the Template?}.
13355 @end table
13357 When used with GNU ld version 2.8 or later on an ELF system such as
13358 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
13359 these constructs will be discarded at link time.  This is known as
13360 COMDAT support.
13362 On targets that don't support COMDAT, but do support weak symbols, GCC
13363 will use them.  This way one copy will override all the others, but
13364 the unused copies will still take up space in the executable.
13366 For targets which do not support either COMDAT or weak symbols,
13367 most entities with vague linkage will be emitted as local symbols to
13368 avoid duplicate definition errors from the linker.  This will not happen
13369 for local statics in inlines, however, as having multiple copies will
13370 almost certainly break things.
13372 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
13373 another way to control placement of these constructs.
13375 @node C++ Interface
13376 @section #pragma interface and implementation
13378 @cindex interface and implementation headers, C++
13379 @cindex C++ interface and implementation headers
13380 @cindex pragmas, interface and implementation
13382 @code{#pragma interface} and @code{#pragma implementation} provide the
13383 user with a way of explicitly directing the compiler to emit entities
13384 with vague linkage (and debugging information) in a particular
13385 translation unit.
13387 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
13388 most cases, because of COMDAT support and the ``key method'' heuristic
13389 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
13390 program to grow due to unnecessary out-of-line copies of inline
13391 functions.  Currently (3.4) the only benefit of these
13392 @code{#pragma}s is reduced duplication of debugging information, and
13393 that should be addressed soon on DWARF 2 targets with the use of
13394 COMDAT groups.
13396 @table @code
13397 @item #pragma interface
13398 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
13399 @kindex #pragma interface
13400 Use this directive in @emph{header files} that define object classes, to save
13401 space in most of the object files that use those classes.  Normally,
13402 local copies of certain information (backup copies of inline member
13403 functions, debugging information, and the internal tables that implement
13404 virtual functions) must be kept in each object file that includes class
13405 definitions.  You can use this pragma to avoid such duplication.  When a
13406 header file containing @samp{#pragma interface} is included in a
13407 compilation, this auxiliary information will not be generated (unless
13408 the main input source file itself uses @samp{#pragma implementation}).
13409 Instead, the object files will contain references to be resolved at link
13410 time.
13412 The second form of this directive is useful for the case where you have
13413 multiple headers with the same name in different directories.  If you
13414 use this form, you must specify the same string to @samp{#pragma
13415 implementation}.
13417 @item #pragma implementation
13418 @itemx #pragma implementation "@var{objects}.h"
13419 @kindex #pragma implementation
13420 Use this pragma in a @emph{main input file}, when you want full output from
13421 included header files to be generated (and made globally visible).  The
13422 included header file, in turn, should use @samp{#pragma interface}.
13423 Backup copies of inline member functions, debugging information, and the
13424 internal tables used to implement virtual functions are all generated in
13425 implementation files.
13427 @cindex implied @code{#pragma implementation}
13428 @cindex @code{#pragma implementation}, implied
13429 @cindex naming convention, implementation headers
13430 If you use @samp{#pragma implementation} with no argument, it applies to
13431 an include file with the same basename@footnote{A file's @dfn{basename}
13432 was the name stripped of all leading path information and of trailing
13433 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
13434 file.  For example, in @file{allclass.cc}, giving just
13435 @samp{#pragma implementation}
13436 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
13438 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
13439 an implementation file whenever you would include it from
13440 @file{allclass.cc} even if you never specified @samp{#pragma
13441 implementation}.  This was deemed to be more trouble than it was worth,
13442 however, and disabled.
13444 Use the string argument if you want a single implementation file to
13445 include code from multiple header files.  (You must also use
13446 @samp{#include} to include the header file; @samp{#pragma
13447 implementation} only specifies how to use the file---it doesn't actually
13448 include it.)
13450 There is no way to split up the contents of a single header file into
13451 multiple implementation files.
13452 @end table
13454 @cindex inlining and C++ pragmas
13455 @cindex C++ pragmas, effect on inlining
13456 @cindex pragmas in C++, effect on inlining
13457 @samp{#pragma implementation} and @samp{#pragma interface} also have an
13458 effect on function inlining.
13460 If you define a class in a header file marked with @samp{#pragma
13461 interface}, the effect on an inline function defined in that class is
13462 similar to an explicit @code{extern} declaration---the compiler emits
13463 no code at all to define an independent version of the function.  Its
13464 definition is used only for inlining with its callers.
13466 @opindex fno-implement-inlines
13467 Conversely, when you include the same header file in a main source file
13468 that declares it as @samp{#pragma implementation}, the compiler emits
13469 code for the function itself; this defines a version of the function
13470 that can be found via pointers (or by callers compiled without
13471 inlining).  If all calls to the function can be inlined, you can avoid
13472 emitting the function by compiling with @option{-fno-implement-inlines}.
13473 If any calls were not inlined, you will get linker errors.
13475 @node Template Instantiation
13476 @section Where's the Template?
13477 @cindex template instantiation
13479 C++ templates are the first language feature to require more
13480 intelligence from the environment than one usually finds on a UNIX
13481 system.  Somehow the compiler and linker have to make sure that each
13482 template instance occurs exactly once in the executable if it is needed,
13483 and not at all otherwise.  There are two basic approaches to this
13484 problem, which are referred to as the Borland model and the Cfront model.
13486 @table @asis
13487 @item Borland model
13488 Borland C++ solved the template instantiation problem by adding the code
13489 equivalent of common blocks to their linker; the compiler emits template
13490 instances in each translation unit that uses them, and the linker
13491 collapses them together.  The advantage of this model is that the linker
13492 only has to consider the object files themselves; there is no external
13493 complexity to worry about.  This disadvantage is that compilation time
13494 is increased because the template code is being compiled repeatedly.
13495 Code written for this model tends to include definitions of all
13496 templates in the header file, since they must be seen to be
13497 instantiated.
13499 @item Cfront model
13500 The AT&T C++ translator, Cfront, solved the template instantiation
13501 problem by creating the notion of a template repository, an
13502 automatically maintained place where template instances are stored.  A
13503 more modern version of the repository works as follows: As individual
13504 object files are built, the compiler places any template definitions and
13505 instantiations encountered in the repository.  At link time, the link
13506 wrapper adds in the objects in the repository and compiles any needed
13507 instances that were not previously emitted.  The advantages of this
13508 model are more optimal compilation speed and the ability to use the
13509 system linker; to implement the Borland model a compiler vendor also
13510 needs to replace the linker.  The disadvantages are vastly increased
13511 complexity, and thus potential for error; for some code this can be
13512 just as transparent, but in practice it can been very difficult to build
13513 multiple programs in one directory and one program in multiple
13514 directories.  Code written for this model tends to separate definitions
13515 of non-inline member templates into a separate file, which should be
13516 compiled separately.
13517 @end table
13519 When used with GNU ld version 2.8 or later on an ELF system such as
13520 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
13521 Borland model.  On other systems, G++ implements neither automatic
13522 model.
13524 A future version of G++ will support a hybrid model whereby the compiler
13525 will emit any instantiations for which the template definition is
13526 included in the compile, and store template definitions and
13527 instantiation context information into the object file for the rest.
13528 The link wrapper will extract that information as necessary and invoke
13529 the compiler to produce the remaining instantiations.  The linker will
13530 then combine duplicate instantiations.
13532 In the mean time, you have the following options for dealing with
13533 template instantiations:
13535 @enumerate
13536 @item
13537 @opindex frepo
13538 Compile your template-using code with @option{-frepo}.  The compiler will
13539 generate files with the extension @samp{.rpo} listing all of the
13540 template instantiations used in the corresponding object files which
13541 could be instantiated there; the link wrapper, @samp{collect2}, will
13542 then update the @samp{.rpo} files to tell the compiler where to place
13543 those instantiations and rebuild any affected object files.  The
13544 link-time overhead is negligible after the first pass, as the compiler
13545 will continue to place the instantiations in the same files.
13547 This is your best option for application code written for the Borland
13548 model, as it will just work.  Code written for the Cfront model will
13549 need to be modified so that the template definitions are available at
13550 one or more points of instantiation; usually this is as simple as adding
13551 @code{#include <tmethods.cc>} to the end of each template header.
13553 For library code, if you want the library to provide all of the template
13554 instantiations it needs, just try to link all of its object files
13555 together; the link will fail, but cause the instantiations to be
13556 generated as a side effect.  Be warned, however, that this may cause
13557 conflicts if multiple libraries try to provide the same instantiations.
13558 For greater control, use explicit instantiation as described in the next
13559 option.
13561 @item
13562 @opindex fno-implicit-templates
13563 Compile your code with @option{-fno-implicit-templates} to disable the
13564 implicit generation of template instances, and explicitly instantiate
13565 all the ones you use.  This approach requires more knowledge of exactly
13566 which instances you need than do the others, but it's less
13567 mysterious and allows greater control.  You can scatter the explicit
13568 instantiations throughout your program, perhaps putting them in the
13569 translation units where the instances are used or the translation units
13570 that define the templates themselves; you can put all of the explicit
13571 instantiations you need into one big file; or you can create small files
13572 like
13574 @smallexample
13575 #include "Foo.h"
13576 #include "Foo.cc"
13578 template class Foo<int>;
13579 template ostream& operator <<
13580                 (ostream&, const Foo<int>&);
13581 @end smallexample
13583 for each of the instances you need, and create a template instantiation
13584 library from those.
13586 If you are using Cfront-model code, you can probably get away with not
13587 using @option{-fno-implicit-templates} when compiling files that don't
13588 @samp{#include} the member template definitions.
13590 If you use one big file to do the instantiations, you may want to
13591 compile it without @option{-fno-implicit-templates} so you get all of the
13592 instances required by your explicit instantiations (but not by any
13593 other files) without having to specify them as well.
13595 G++ has extended the template instantiation syntax given in the ISO
13596 standard to allow forward declaration of explicit instantiations
13597 (with @code{extern}), instantiation of the compiler support data for a
13598 template class (i.e.@: the vtable) without instantiating any of its
13599 members (with @code{inline}), and instantiation of only the static data
13600 members of a template class, without the support data or member
13601 functions (with (@code{static}):
13603 @smallexample
13604 extern template int max (int, int);
13605 inline template class Foo<int>;
13606 static template class Foo<int>;
13607 @end smallexample
13609 @item
13610 Do nothing.  Pretend G++ does implement automatic instantiation
13611 management.  Code written for the Borland model will work fine, but
13612 each translation unit will contain instances of each of the templates it
13613 uses.  In a large program, this can lead to an unacceptable amount of code
13614 duplication.
13615 @end enumerate
13617 @node Bound member functions
13618 @section Extracting the function pointer from a bound pointer to member function
13619 @cindex pmf
13620 @cindex pointer to member function
13621 @cindex bound pointer to member function
13623 In C++, pointer to member functions (PMFs) are implemented using a wide
13624 pointer of sorts to handle all the possible call mechanisms; the PMF
13625 needs to store information about how to adjust the @samp{this} pointer,
13626 and if the function pointed to is virtual, where to find the vtable, and
13627 where in the vtable to look for the member function.  If you are using
13628 PMFs in an inner loop, you should really reconsider that decision.  If
13629 that is not an option, you can extract the pointer to the function that
13630 would be called for a given object/PMF pair and call it directly inside
13631 the inner loop, to save a bit of time.
13633 Note that you will still be paying the penalty for the call through a
13634 function pointer; on most modern architectures, such a call defeats the
13635 branch prediction features of the CPU@.  This is also true of normal
13636 virtual function calls.
13638 The syntax for this extension is
13640 @smallexample
13641 extern A a;
13642 extern int (A::*fp)();
13643 typedef int (*fptr)(A *);
13645 fptr p = (fptr)(a.*fp);
13646 @end smallexample
13648 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
13649 no object is needed to obtain the address of the function.  They can be
13650 converted to function pointers directly:
13652 @smallexample
13653 fptr p1 = (fptr)(&A::foo);
13654 @end smallexample
13656 @opindex Wno-pmf-conversions
13657 You must specify @option{-Wno-pmf-conversions} to use this extension.
13659 @node C++ Attributes
13660 @section C++-Specific Variable, Function, and Type Attributes
13662 Some attributes only make sense for C++ programs.
13664 @table @code
13665 @item init_priority (@var{priority})
13666 @cindex init_priority attribute
13669 In Standard C++, objects defined at namespace scope are guaranteed to be
13670 initialized in an order in strict accordance with that of their definitions
13671 @emph{in a given translation unit}.  No guarantee is made for initializations
13672 across translation units.  However, GNU C++ allows users to control the
13673 order of initialization of objects defined at namespace scope with the
13674 @code{init_priority} attribute by specifying a relative @var{priority},
13675 a constant integral expression currently bounded between 101 and 65535
13676 inclusive.  Lower numbers indicate a higher priority.
13678 In the following example, @code{A} would normally be created before
13679 @code{B}, but the @code{init_priority} attribute has reversed that order:
13681 @smallexample
13682 Some_Class  A  __attribute__ ((init_priority (2000)));
13683 Some_Class  B  __attribute__ ((init_priority (543)));
13684 @end smallexample
13686 @noindent
13687 Note that the particular values of @var{priority} do not matter; only their
13688 relative ordering.
13690 @item java_interface
13691 @cindex java_interface attribute
13693 This type attribute informs C++ that the class is a Java interface.  It may
13694 only be applied to classes declared within an @code{extern "Java"} block.
13695 Calls to methods declared in this interface will be dispatched using GCJ's
13696 interface table mechanism, instead of regular virtual table dispatch.
13698 @end table
13700 See also @ref{Namespace Association}.
13702 @node Namespace Association
13703 @section Namespace Association
13705 @strong{Caution:} The semantics of this extension are not fully
13706 defined.  Users should refrain from using this extension as its
13707 semantics may change subtly over time.  It is possible that this
13708 extension will be removed in future versions of G++.
13710 A using-directive with @code{__attribute ((strong))} is stronger
13711 than a normal using-directive in two ways:
13713 @itemize @bullet
13714 @item
13715 Templates from the used namespace can be specialized and explicitly
13716 instantiated as though they were members of the using namespace.
13718 @item
13719 The using namespace is considered an associated namespace of all
13720 templates in the used namespace for purposes of argument-dependent
13721 name lookup.
13722 @end itemize
13724 The used namespace must be nested within the using namespace so that
13725 normal unqualified lookup works properly.
13727 This is useful for composing a namespace transparently from
13728 implementation namespaces.  For example:
13730 @smallexample
13731 namespace std @{
13732   namespace debug @{
13733     template <class T> struct A @{ @};
13734   @}
13735   using namespace debug __attribute ((__strong__));
13736   template <> struct A<int> @{ @};   // @r{ok to specialize}
13738   template <class T> void f (A<T>);
13741 int main()
13743   f (std::A<float>());             // @r{lookup finds} std::f
13744   f (std::A<int>());
13746 @end smallexample
13748 @node Type Traits
13749 @section Type Traits
13751 The C++ front-end implements syntactic extensions that allow to
13752 determine at compile time various characteristics of a type (or of a
13753 pair of types).
13755 @table @code
13756 @item __has_nothrow_assign (type)
13757 If @code{type} is const qualified or is a reference type then the trait is
13758 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
13759 is true, else if @code{type} is a cv class or union type with copy assignment
13760 operators that are known not to throw an exception then the trait is true,
13761 else it is false.  Requires: @code{type} shall be a complete type, an array
13762 type of unknown bound, or is a @code{void} type.
13764 @item __has_nothrow_copy (type)
13765 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
13766 @code{type} is a cv class or union type with copy constructors that
13767 are known not to throw an exception then the trait is true, else it is false.
13768 Requires: @code{type} shall be a complete type, an array type of
13769 unknown bound, or is a @code{void} type.
13771 @item __has_nothrow_constructor (type)
13772 If @code{__has_trivial_constructor (type)} is true then the trait is
13773 true, else if @code{type} is a cv class or union type (or array
13774 thereof) with a default constructor that is known not to throw an
13775 exception then the trait is true, else it is false.  Requires:
13776 @code{type} shall be a complete type, an array type of unknown bound,
13777 or is a @code{void} type.
13779 @item __has_trivial_assign (type)
13780 If @code{type} is const qualified or is a reference type then the trait is
13781 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
13782 true, else if @code{type} is a cv class or union type with a trivial
13783 copy assignment ([class.copy]) then the trait is true, else it is
13784 false.  Requires: @code{type} shall be a complete type, an array type
13785 of unknown bound, or is a @code{void} type.
13787 @item __has_trivial_copy (type)
13788 If @code{__is_pod (type)} is true or @code{type} is a reference type 
13789 then the trait is true, else if @code{type} is a cv class or union type
13790 with a trivial copy constructor ([class.copy]) then the trait
13791 is true, else it is false.  Requires: @code{type} shall be a complete
13792 type, an array type of unknown bound, or is a @code{void} type.
13794 @item __has_trivial_constructor (type)
13795 If @code{__is_pod (type)} is true then the trait is true, else if
13796 @code{type} is a cv class or union type (or array thereof) with a
13797 trivial default constructor ([class.ctor]) then the trait is true,
13798 else it is false.  Requires: @code{type} shall be a complete type, an
13799 array type of unknown bound, or is a @code{void} type.
13801 @item __has_trivial_destructor (type)
13802 If @code{__is_pod (type)} is true or @code{type} is a reference type then
13803 the trait is true, else if @code{type} is a cv class or union type (or
13804 array thereof) with a trivial destructor ([class.dtor]) then the trait
13805 is true, else it is false.  Requires: @code{type} shall be a complete
13806 type, an array type of unknown bound, or is a @code{void} type.
13808 @item __has_virtual_destructor (type)
13809 If @code{type} is a class type with a virtual destructor
13810 ([class.dtor]) then the trait is true, else it is false.  Requires:
13811 @code{type}  shall be a complete type, an array type of unknown bound,
13812 or is a @code{void} type.
13814 @item __is_abstract (type)
13815 If @code{type} is an abstract class ([class.abstract]) then the trait
13816 is true, else it is false.  Requires: @code{type} shall be a complete
13817 type, an array type of unknown bound, or is a @code{void} type.
13819 @item __is_base_of (base_type, derived_type)
13820 If @code{base_type} is a base class of @code{derived_type}
13821 ([class.derived]) then the trait is true, otherwise it is false.
13822 Top-level cv qualifications of @code{base_type} and
13823 @code{derived_type} are ignored.  For the purposes of this trait, a
13824 class type is considered is own base.  Requires: if @code{__is_class
13825 (base_type)} and @code{__is_class (derived_type)} are true and
13826 @code{base_type} and @code{derived_type} are not the same type
13827 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
13828 type.  Diagnostic is produced if this requirement is not met.
13830 @item __is_class (type)
13831 If @code{type} is a cv class type, and not a union type
13832 ([basic.compound]) the trait is true, else it is false.
13834 @item __is_empty (type)
13835 If @code{__is_class (type)} is false then the trait is false.
13836 Otherwise @code{type} is considered empty if and only if: @code{type}
13837 has no non-static data members, or all non-static data members, if
13838 any, are bit-fields of length 0, and @code{type} has no virtual
13839 members, and @code{type} has no virtual base classes, and @code{type}
13840 has no base classes @code{base_type} for which 
13841 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
13842 be a complete type, an array type of unknown bound, or is a
13843 @code{void} type.
13845 @item __is_enum (type)
13846 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
13847 true, else it is false.
13849 @item __is_pod (type)
13850 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
13851 else it is false.  Requires: @code{type} shall be a complete type, 
13852 an array type of unknown bound, or is a @code{void} type.
13854 @item __is_polymorphic (type)
13855 If @code{type} is a polymorphic class ([class.virtual]) then the trait
13856 is true, else it is false.  Requires: @code{type} shall be a complete
13857 type, an array type of unknown bound, or is a @code{void} type.
13859 @item __is_union (type)
13860 If @code{type} is a cv union type ([basic.compound]) the trait is
13861 true, else it is false.
13863 @end table
13865 @node Java Exceptions
13866 @section Java Exceptions
13868 The Java language uses a slightly different exception handling model
13869 from C++.  Normally, GNU C++ will automatically detect when you are
13870 writing C++ code that uses Java exceptions, and handle them
13871 appropriately.  However, if C++ code only needs to execute destructors
13872 when Java exceptions are thrown through it, GCC will guess incorrectly.
13873 Sample problematic code is:
13875 @smallexample
13876   struct S @{ ~S(); @};
13877   extern void bar();    // @r{is written in Java, and may throw exceptions}
13878   void foo()
13879   @{
13880     S s;
13881     bar();
13882   @}
13883 @end smallexample
13885 @noindent
13886 The usual effect of an incorrect guess is a link failure, complaining of
13887 a missing routine called @samp{__gxx_personality_v0}.
13889 You can inform the compiler that Java exceptions are to be used in a
13890 translation unit, irrespective of what it might think, by writing
13891 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
13892 @samp{#pragma} must appear before any functions that throw or catch
13893 exceptions, or run destructors when exceptions are thrown through them.
13895 You cannot mix Java and C++ exceptions in the same translation unit.  It
13896 is believed to be safe to throw a C++ exception from one file through
13897 another file compiled for the Java exception model, or vice versa, but
13898 there may be bugs in this area.
13900 @node Deprecated Features
13901 @section Deprecated Features
13903 In the past, the GNU C++ compiler was extended to experiment with new
13904 features, at a time when the C++ language was still evolving.  Now that
13905 the C++ standard is complete, some of those features are superseded by
13906 superior alternatives.  Using the old features might cause a warning in
13907 some cases that the feature will be dropped in the future.  In other
13908 cases, the feature might be gone already.
13910 While the list below is not exhaustive, it documents some of the options
13911 that are now deprecated:
13913 @table @code
13914 @item -fexternal-templates
13915 @itemx -falt-external-templates
13916 These are two of the many ways for G++ to implement template
13917 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
13918 defines how template definitions have to be organized across
13919 implementation units.  G++ has an implicit instantiation mechanism that
13920 should work just fine for standard-conforming code.
13922 @item -fstrict-prototype
13923 @itemx -fno-strict-prototype
13924 Previously it was possible to use an empty prototype parameter list to
13925 indicate an unspecified number of parameters (like C), rather than no
13926 parameters, as C++ demands.  This feature has been removed, except where
13927 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
13928 @end table
13930 G++ allows a virtual function returning @samp{void *} to be overridden
13931 by one returning a different pointer type.  This extension to the
13932 covariant return type rules is now deprecated and will be removed from a
13933 future version.
13935 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
13936 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
13937 and are now removed from G++.  Code using these operators should be
13938 modified to use @code{std::min} and @code{std::max} instead.
13940 The named return value extension has been deprecated, and is now
13941 removed from G++.
13943 The use of initializer lists with new expressions has been deprecated,
13944 and is now removed from G++.
13946 Floating and complex non-type template parameters have been deprecated,
13947 and are now removed from G++.
13949 The implicit typename extension has been deprecated and is now
13950 removed from G++.
13952 The use of default arguments in function pointers, function typedefs
13953 and other places where they are not permitted by the standard is
13954 deprecated and will be removed from a future version of G++.
13956 G++ allows floating-point literals to appear in integral constant expressions,
13957 e.g. @samp{ enum E @{ e = int(2.2 * 3.7) @} }
13958 This extension is deprecated and will be removed from a future version.
13960 G++ allows static data members of const floating-point type to be declared
13961 with an initializer in a class definition. The standard only allows
13962 initializers for static members of const integral types and const
13963 enumeration types so this extension has been deprecated and will be removed
13964 from a future version.
13966 @node Backwards Compatibility
13967 @section Backwards Compatibility
13968 @cindex Backwards Compatibility
13969 @cindex ARM [Annotated C++ Reference Manual]
13971 Now that there is a definitive ISO standard C++, G++ has a specification
13972 to adhere to.  The C++ language evolved over time, and features that
13973 used to be acceptable in previous drafts of the standard, such as the ARM
13974 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
13975 compilation of C++ written to such drafts, G++ contains some backwards
13976 compatibilities.  @emph{All such backwards compatibility features are
13977 liable to disappear in future versions of G++.} They should be considered
13978 deprecated.   @xref{Deprecated Features}.
13980 @table @code
13981 @item For scope
13982 If a variable is declared at for scope, it used to remain in scope until
13983 the end of the scope which contained the for statement (rather than just
13984 within the for scope).  G++ retains this, but issues a warning, if such a
13985 variable is accessed outside the for scope.
13987 @item Implicit C language
13988 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
13989 scope to set the language.  On such systems, all header files are
13990 implicitly scoped inside a C language scope.  Also, an empty prototype
13991 @code{()} will be treated as an unspecified number of arguments, rather
13992 than no arguments, as C++ demands.
13993 @end table