Merge from trunk @217148.
[official-gcc.git] / gcc / doc / extend.texi
blob3c5227e2d97d051761c09ebdef1e7c9425933714
1 @c Copyright (C) 1988-2014 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Label Attributes::    Specifying attributes on labels.
59 * Attribute Syntax::    Formal syntax for attributes.
60 * Function Prototypes:: Prototype declarations and old-style definitions.
61 * C++ Comments::        C++ comments are recognized.
62 * Dollar Signs::        Dollar sign is allowed in identifiers.
63 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
64 * Variable Attributes:: Specifying attributes of variables.
65 * Type Attributes::     Specifying attributes of types.
66 * Alignment::           Inquiring about the alignment of a type or variable.
67 * Inline::              Defining inline functions (as fast as macros).
68 * Volatiles::           What constitutes an access to a volatile object.
69 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
70 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
71 * Incomplete Enums::    @code{enum foo;}, with details to follow.
72 * Function Names::      Printable strings which are the name of the current
73                         function.
74 * Return Address::      Getting the return or frame address of a function.
75 * Vector Extensions::   Using vector instructions through built-in functions.
76 * Offsetof::            Special syntax for implementing @code{offsetof}.
77 * __sync Builtins::     Legacy built-in functions for atomic memory access.
78 * __atomic Builtins::   Atomic built-in functions with memory model.
79 * x86 specific memory model extensions for transactional memory:: x86 memory models.
80 * Object Size Checking:: Built-in functions for limited buffer overflow
81                         checking.
82 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
83 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
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} or @code{__auto_type} (@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 constructs a temporary @code{A} object to hold the result of the
167 statement expression, and that is used to invoke @code{Foo}.
168 Therefore the @code{this} pointer observed by @code{Foo} is not the
169 address of @code{a}.
171 In a statement expression, any temporaries created within a statement
172 are destroyed at that 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 are
175 destroyed at the end of the statement that includes the function
176 call.  In the statement expression case they are 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 has different places where temporaries are destroyed.  For the
192 @code{macro} case, the temporary @code{X} is destroyed just after
193 the initialization of @code{b}.  In the @code{function} case that
194 temporary is 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 expressions 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}) has 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 calls @code{foo} and @code{bar1} and does not call @code{baz} but
222 may or may not call @code{bar2}.  If @code{bar2} is called, it is
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 is 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 is 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 serves as a jump table:
336 @smallexample
337 static void *array[] = @{ &&foo, &&bar, &&hack @};
338 @end smallexample
340 @noindent
341 Then you can select a label with indexing, like this:
343 @smallexample
344 goto *array[i];
345 @end smallexample
347 @noindent
348 Note that this does not check whether the subscript is in bounds---array
349 indexing in C never does that.
351 Such an array of label values serves a purpose much like that of the
352 @code{switch} statement.  The @code{switch} statement is cleaner, so
353 use that rather than an array unless the problem does not fit a
354 @code{switch} statement very well.
356 Another use of label values is in an interpreter for threaded code.
357 The labels within the interpreter function can be stored in the
358 threaded code for super-fast dispatching.
360 You may not use this mechanism to jump to code in a different function.
361 If you do that, totally unpredictable things happen.  The best way to
362 avoid this is to store the label address only in automatic variables and
363 never pass it as an argument.
365 An alternate way to write the above example is
367 @smallexample
368 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
369                              &&hack - &&foo @};
370 goto *(&&foo + array[i]);
371 @end smallexample
373 @noindent
374 This is more friendly to code living in shared libraries, as it reduces
375 the number of dynamic relocations that are needed, and by consequence,
376 allows the data to be read-only.
377 This alternative with label differences is not supported for the AVR target,
378 please use the first approach for AVR programs.
380 The @code{&&foo} expressions for the same label might have different
381 values if the containing function is inlined or cloned.  If a program
382 relies on them being always the same,
383 @code{__attribute__((__noinline__,__noclone__))} should be used to
384 prevent inlining and cloning.  If @code{&&foo} is used in a static
385 variable initializer, inlining and cloning is forbidden.
387 @node Nested Functions
388 @section Nested Functions
389 @cindex nested functions
390 @cindex downward funargs
391 @cindex thunks
393 A @dfn{nested function} is a function defined inside another function.
394 Nested functions are supported as an extension in GNU C, but are not
395 supported by GNU C++.
397 The nested function's name is local to the block where it is defined.
398 For example, here we define a nested function named @code{square}, and
399 call it twice:
401 @smallexample
402 @group
403 foo (double a, double b)
405   double square (double z) @{ return z * z; @}
407   return square (a) + square (b);
409 @end group
410 @end smallexample
412 The nested function can access all the variables of the containing
413 function that are visible at the point of its definition.  This is
414 called @dfn{lexical scoping}.  For example, here we show a nested
415 function which uses an inherited variable named @code{offset}:
417 @smallexample
418 @group
419 bar (int *array, int offset, int size)
421   int access (int *array, int index)
422     @{ return array[index + offset]; @}
423   int i;
424   /* @r{@dots{}} */
425   for (i = 0; i < size; i++)
426     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
428 @end group
429 @end smallexample
431 Nested function definitions are permitted within functions in the places
432 where variable definitions are allowed; that is, in any block, mixed
433 with the other declarations and statements in the block.
435 It is possible to call the nested function from outside the scope of its
436 name by storing its address or passing the address to another function:
438 @smallexample
439 hack (int *array, int size)
441   void store (int index, int value)
442     @{ array[index] = value; @}
444   intermediate (store, size);
446 @end smallexample
448 Here, the function @code{intermediate} receives the address of
449 @code{store} as an argument.  If @code{intermediate} calls @code{store},
450 the arguments given to @code{store} are used to store into @code{array}.
451 But this technique works only so long as the containing function
452 (@code{hack}, in this example) does not exit.
454 If you try to call the nested function through its address after the
455 containing function exits, all hell breaks loose.  If you try
456 to call it after a containing scope level exits, and if it refers
457 to some of the variables that are no longer in scope, you may be lucky,
458 but it's not wise to take the risk.  If, however, the nested function
459 does not refer to anything that has gone out of scope, you should be
460 safe.
462 GCC implements taking the address of a nested function using a technique
463 called @dfn{trampolines}.  This technique was described in
464 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
465 C++ Conference Proceedings, October 17-21, 1988).
467 A nested function can jump to a label inherited from a containing
468 function, provided the label is explicitly declared in the containing
469 function (@pxref{Local Labels}).  Such a jump returns instantly to the
470 containing function, exiting the nested function that did the
471 @code{goto} and any intermediate functions as well.  Here is an example:
473 @smallexample
474 @group
475 bar (int *array, int offset, int size)
477   __label__ failure;
478   int access (int *array, int index)
479     @{
480       if (index > size)
481         goto failure;
482       return array[index + offset];
483     @}
484   int i;
485   /* @r{@dots{}} */
486   for (i = 0; i < size; i++)
487     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
488   /* @r{@dots{}} */
489   return 0;
491  /* @r{Control comes here from @code{access}
492     if it detects an error.}  */
493  failure:
494   return -1;
496 @end group
497 @end smallexample
499 A nested function always has no linkage.  Declaring one with
500 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
501 before its definition, use @code{auto} (which is otherwise meaningless
502 for function declarations).
504 @smallexample
505 bar (int *array, int offset, int size)
507   __label__ failure;
508   auto int access (int *, int);
509   /* @r{@dots{}} */
510   int access (int *array, int index)
511     @{
512       if (index > size)
513         goto failure;
514       return array[index + offset];
515     @}
516   /* @r{@dots{}} */
518 @end smallexample
520 @node Constructing Calls
521 @section Constructing Function Calls
522 @cindex constructing calls
523 @cindex forwarding calls
525 Using the built-in functions described below, you can record
526 the arguments a function received, and call another function
527 with the same arguments, without knowing the number or types
528 of the arguments.
530 You can also record the return value of that function call,
531 and later return that value, without knowing what data type
532 the function tried to return (as long as your caller expects
533 that data type).
535 However, these built-in functions may interact badly with some
536 sophisticated features or other extensions of the language.  It
537 is, therefore, not recommended to use them outside very simple
538 functions acting as mere forwarders for their arguments.
540 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
541 This built-in function returns a pointer to data
542 describing how to perform a call with the same arguments as are passed
543 to the current function.
545 The function saves the arg pointer register, structure value address,
546 and all registers that might be used to pass arguments to a function
547 into a block of memory allocated on the stack.  Then it returns the
548 address of that block.
549 @end deftypefn
551 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
552 This built-in function invokes @var{function}
553 with a copy of the parameters described by @var{arguments}
554 and @var{size}.
556 The value of @var{arguments} should be the value returned by
557 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
558 of the stack argument data, in bytes.
560 This function returns a pointer to data describing
561 how to return whatever value is returned by @var{function}.  The data
562 is saved in a block of memory allocated on the stack.
564 It is not always simple to compute the proper value for @var{size}.  The
565 value is used by @code{__builtin_apply} to compute the amount of data
566 that should be pushed on the stack and copied from the incoming argument
567 area.
568 @end deftypefn
570 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
571 This built-in function returns the value described by @var{result} from
572 the containing function.  You should specify, for @var{result}, a value
573 returned by @code{__builtin_apply}.
574 @end deftypefn
576 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
577 This built-in function represents all anonymous arguments of an inline
578 function.  It can be used only in inline functions that are always
579 inlined, never compiled as a separate function, such as those using
580 @code{__attribute__ ((__always_inline__))} or
581 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
582 It must be only passed as last argument to some other function
583 with variable arguments.  This is useful for writing small wrapper
584 inlines for variable argument functions, when using preprocessor
585 macros is undesirable.  For example:
586 @smallexample
587 extern int myprintf (FILE *f, const char *format, ...);
588 extern inline __attribute__ ((__gnu_inline__)) int
589 myprintf (FILE *f, const char *format, ...)
591   int r = fprintf (f, "myprintf: ");
592   if (r < 0)
593     return r;
594   int s = fprintf (f, format, __builtin_va_arg_pack ());
595   if (s < 0)
596     return s;
597   return r + s;
599 @end smallexample
600 @end deftypefn
602 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
603 This built-in function returns the number of anonymous arguments of
604 an inline function.  It can be used only in inline functions that
605 are always inlined, never compiled as a separate function, such
606 as those using @code{__attribute__ ((__always_inline__))} or
607 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
608 For example following does link- or run-time checking of open
609 arguments for optimized code:
610 @smallexample
611 #ifdef __OPTIMIZE__
612 extern inline __attribute__((__gnu_inline__)) int
613 myopen (const char *path, int oflag, ...)
615   if (__builtin_va_arg_pack_len () > 1)
616     warn_open_too_many_arguments ();
618   if (__builtin_constant_p (oflag))
619     @{
620       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
621         @{
622           warn_open_missing_mode ();
623           return __open_2 (path, oflag);
624         @}
625       return open (path, oflag, __builtin_va_arg_pack ());
626     @}
628   if (__builtin_va_arg_pack_len () < 1)
629     return __open_2 (path, oflag);
631   return open (path, oflag, __builtin_va_arg_pack ());
633 #endif
634 @end smallexample
635 @end deftypefn
637 @node Typeof
638 @section Referring to a Type with @code{typeof}
639 @findex typeof
640 @findex sizeof
641 @cindex macros, types of arguments
643 Another way to refer to the type of an expression is with @code{typeof}.
644 The syntax of using of this keyword looks like @code{sizeof}, but the
645 construct acts semantically like a type name defined with @code{typedef}.
647 There are two ways of writing the argument to @code{typeof}: with an
648 expression or with a type.  Here is an example with an expression:
650 @smallexample
651 typeof (x[0](1))
652 @end smallexample
654 @noindent
655 This assumes that @code{x} is an array of pointers to functions;
656 the type described is that of the values of the functions.
658 Here is an example with a typename as the argument:
660 @smallexample
661 typeof (int *)
662 @end smallexample
664 @noindent
665 Here the type described is that of pointers to @code{int}.
667 If you are writing a header file that must work when included in ISO C
668 programs, write @code{__typeof__} instead of @code{typeof}.
669 @xref{Alternate Keywords}.
671 A @code{typeof} construct can be used anywhere a typedef name can be
672 used.  For example, you can use it in a declaration, in a cast, or inside
673 of @code{sizeof} or @code{typeof}.
675 The operand of @code{typeof} is evaluated for its side effects if and
676 only if it is an expression of variably modified type or the name of
677 such a type.
679 @code{typeof} is often useful in conjunction with
680 statement expressions (@pxref{Statement Exprs}).
681 Here is how the two together can
682 be used to define a safe ``maximum'' macro which operates on any
683 arithmetic type and evaluates each of its arguments exactly once:
685 @smallexample
686 #define max(a,b) \
687   (@{ typeof (a) _a = (a); \
688       typeof (b) _b = (b); \
689     _a > _b ? _a : _b; @})
690 @end smallexample
692 @cindex underscores in variables in macros
693 @cindex @samp{_} in variables in macros
694 @cindex local variables in macros
695 @cindex variables, local, in macros
696 @cindex macros, local variables in
698 The reason for using names that start with underscores for the local
699 variables is to avoid conflicts with variable names that occur within the
700 expressions that are substituted for @code{a} and @code{b}.  Eventually we
701 hope to design a new form of declaration syntax that allows you to declare
702 variables whose scopes start only after their initializers; this will be a
703 more reliable way to prevent such conflicts.
705 @noindent
706 Some more examples of the use of @code{typeof}:
708 @itemize @bullet
709 @item
710 This declares @code{y} with the type of what @code{x} points to.
712 @smallexample
713 typeof (*x) y;
714 @end smallexample
716 @item
717 This declares @code{y} as an array of such values.
719 @smallexample
720 typeof (*x) y[4];
721 @end smallexample
723 @item
724 This declares @code{y} as an array of pointers to characters:
726 @smallexample
727 typeof (typeof (char *)[4]) y;
728 @end smallexample
730 @noindent
731 It is equivalent to the following traditional C declaration:
733 @smallexample
734 char *y[4];
735 @end smallexample
737 To see the meaning of the declaration using @code{typeof}, and why it
738 might be a useful way to write, rewrite it with these macros:
740 @smallexample
741 #define pointer(T)  typeof(T *)
742 #define array(T, N) typeof(T [N])
743 @end smallexample
745 @noindent
746 Now the declaration can be rewritten this way:
748 @smallexample
749 array (pointer (char), 4) y;
750 @end smallexample
752 @noindent
753 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
754 pointers to @code{char}.
755 @end itemize
757 In GNU C, but not GNU C++, you may also declare the type of a variable
758 as @code{__auto_type}.  In that case, the declaration must declare
759 only one variable, whose declarator must just be an identifier, the
760 declaration must be initialized, and the type of the variable is
761 determined by the initializer; the name of the variable is not in
762 scope until after the initializer.  (In C++, you should use C++11
763 @code{auto} for this purpose.)  Using @code{__auto_type}, the
764 ``maximum'' macro above could be written as:
766 @smallexample
767 #define max(a,b) \
768   (@{ __auto_type _a = (a); \
769       __auto_type _b = (b); \
770     _a > _b ? _a : _b; @})
771 @end smallexample
773 Using @code{__auto_type} instead of @code{typeof} has two advantages:
775 @itemize @bullet
776 @item Each argument to the macro appears only once in the expansion of
777 the macro.  This prevents the size of the macro expansion growing
778 exponentially when calls to such macros are nested inside arguments of
779 such macros.
781 @item If the argument to the macro has variably modified type, it is
782 evaluated only once when using @code{__auto_type}, but twice if
783 @code{typeof} is used.
784 @end itemize
786 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
787 a more limited extension that permitted one to write
789 @smallexample
790 typedef @var{T} = @var{expr};
791 @end smallexample
793 @noindent
794 with the effect of declaring @var{T} to have the type of the expression
795 @var{expr}.  This extension does not work with GCC 3 (versions between
796 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
797 relies on it should be rewritten to use @code{typeof}:
799 @smallexample
800 typedef typeof(@var{expr}) @var{T};
801 @end smallexample
803 @noindent
804 This works with all versions of GCC@.
806 @node Conditionals
807 @section Conditionals with Omitted Operands
808 @cindex conditional expressions, extensions
809 @cindex omitted middle-operands
810 @cindex middle-operands, omitted
811 @cindex extensions, @code{?:}
812 @cindex @code{?:} extensions
814 The middle operand in a conditional expression may be omitted.  Then
815 if the first operand is nonzero, its value is the value of the conditional
816 expression.
818 Therefore, the expression
820 @smallexample
821 x ? : y
822 @end smallexample
824 @noindent
825 has the value of @code{x} if that is nonzero; otherwise, the value of
826 @code{y}.
828 This example is perfectly equivalent to
830 @smallexample
831 x ? x : y
832 @end smallexample
834 @cindex side effect in @code{?:}
835 @cindex @code{?:} side effect
836 @noindent
837 In this simple case, the ability to omit the middle operand is not
838 especially useful.  When it becomes useful is when the first operand does,
839 or may (if it is a macro argument), contain a side effect.  Then repeating
840 the operand in the middle would perform the side effect twice.  Omitting
841 the middle operand uses the value already computed without the undesirable
842 effects of recomputing it.
844 @node __int128
845 @section 128-bit integers
846 @cindex @code{__int128} data types
848 As an extension the integer scalar type @code{__int128} is supported for
849 targets which have an integer mode wide enough to hold 128 bits.
850 Simply write @code{__int128} for a signed 128-bit integer, or
851 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
852 support in GCC for expressing an integer constant of type @code{__int128}
853 for targets with @code{long long} integer less than 128 bits wide.
855 @node Long Long
856 @section Double-Word Integers
857 @cindex @code{long long} data types
858 @cindex double-word arithmetic
859 @cindex multiprecision arithmetic
860 @cindex @code{LL} integer suffix
861 @cindex @code{ULL} integer suffix
863 ISO C99 supports data types for integers that are at least 64 bits wide,
864 and as an extension GCC supports them in C90 mode and in C++.
865 Simply write @code{long long int} for a signed integer, or
866 @code{unsigned long long int} for an unsigned integer.  To make an
867 integer constant of type @code{long long int}, add the suffix @samp{LL}
868 to the integer.  To make an integer constant of type @code{unsigned long
869 long int}, add the suffix @samp{ULL} to the integer.
871 You can use these types in arithmetic like any other integer types.
872 Addition, subtraction, and bitwise boolean operations on these types
873 are open-coded on all types of machines.  Multiplication is open-coded
874 if the machine supports a fullword-to-doubleword widening multiply
875 instruction.  Division and shifts are open-coded only on machines that
876 provide special support.  The operations that are not open-coded use
877 special library routines that come with GCC@.
879 There may be pitfalls when you use @code{long long} types for function
880 arguments without function prototypes.  If a function
881 expects type @code{int} for its argument, and you pass a value of type
882 @code{long long int}, confusion results because the caller and the
883 subroutine disagree about the number of bytes for the argument.
884 Likewise, if the function expects @code{long long int} and you pass
885 @code{int}.  The best way to avoid such problems is to use prototypes.
887 @node Complex
888 @section Complex Numbers
889 @cindex complex numbers
890 @cindex @code{_Complex} keyword
891 @cindex @code{__complex__} keyword
893 ISO C99 supports complex floating data types, and as an extension GCC
894 supports them in C90 mode and in C++.  GCC also supports complex integer data
895 types which are not part of ISO C99.  You can declare complex types
896 using the keyword @code{_Complex}.  As an extension, the older GNU
897 keyword @code{__complex__} is also supported.
899 For example, @samp{_Complex double x;} declares @code{x} as a
900 variable whose real part and imaginary part are both of type
901 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
902 have real and imaginary parts of type @code{short int}; this is not
903 likely to be useful, but it shows that the set of complex types is
904 complete.
906 To write a constant with a complex data type, use the suffix @samp{i} or
907 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
908 has type @code{_Complex float} and @code{3i} has type
909 @code{_Complex int}.  Such a constant always has a pure imaginary
910 value, but you can form any complex value you like by adding one to a
911 real constant.  This is a GNU extension; if you have an ISO C99
912 conforming C library (such as the GNU C Library), and want to construct complex
913 constants of floating type, you should include @code{<complex.h>} and
914 use the macros @code{I} or @code{_Complex_I} instead.
916 @cindex @code{__real__} keyword
917 @cindex @code{__imag__} keyword
918 To extract the real part of a complex-valued expression @var{exp}, write
919 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
920 extract the imaginary part.  This is a GNU extension; for values of
921 floating type, you should use the ISO C99 functions @code{crealf},
922 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
923 @code{cimagl}, declared in @code{<complex.h>} and also provided as
924 built-in functions by GCC@.
926 @cindex complex conjugation
927 The operator @samp{~} performs complex conjugation when used on a value
928 with a complex type.  This is a GNU extension; for values of
929 floating type, you should use the ISO C99 functions @code{conjf},
930 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
931 provided as built-in functions by GCC@.
933 GCC can allocate complex automatic variables in a noncontiguous
934 fashion; it's even possible for the real part to be in a register while
935 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
936 debug info format can represent this, so use of DWARF 2 is recommended.
937 If you are using the stabs debug info format, GCC describes a noncontiguous
938 complex variable as if it were two separate variables of noncomplex type.
939 If the variable's actual name is @code{foo}, the two fictitious
940 variables are named @code{foo$real} and @code{foo$imag}.  You can
941 examine and set these two fictitious variables with your debugger.
943 @node Floating Types
944 @section Additional Floating Types
945 @cindex additional floating types
946 @cindex @code{__float80} data type
947 @cindex @code{__float128} data type
948 @cindex @code{w} floating point suffix
949 @cindex @code{q} floating point suffix
950 @cindex @code{W} floating point suffix
951 @cindex @code{Q} floating point suffix
953 As an extension, GNU C supports additional floating
954 types, @code{__float80} and @code{__float128} to support 80-bit
955 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
956 Support for additional types includes the arithmetic operators:
957 add, subtract, multiply, divide; unary arithmetic operators;
958 relational operators; equality operators; and conversions to and from
959 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
960 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
961 for @code{_float128}.  You can declare complex types using the
962 corresponding internal complex type, @code{XCmode} for @code{__float80}
963 type and @code{TCmode} for @code{__float128} type:
965 @smallexample
966 typedef _Complex float __attribute__((mode(TC))) _Complex128;
967 typedef _Complex float __attribute__((mode(XC))) _Complex80;
968 @end smallexample
970 Not all targets support additional floating-point types.  @code{__float80}
971 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
972 The @code{__float128} type is supported on hppa HP-UX targets.
974 @node Half-Precision
975 @section Half-Precision Floating Point
976 @cindex half-precision floating point
977 @cindex @code{__fp16} data type
979 On ARM targets, GCC supports half-precision (16-bit) floating point via
980 the @code{__fp16} type.  You must enable this type explicitly
981 with the @option{-mfp16-format} command-line option in order to use it.
983 ARM supports two incompatible representations for half-precision
984 floating-point values.  You must choose one of the representations and
985 use it consistently in your program.
987 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
988 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
989 There are 11 bits of significand precision, approximately 3
990 decimal digits.
992 Specifying @option{-mfp16-format=alternative} selects the ARM
993 alternative format.  This representation is similar to the IEEE
994 format, but does not support infinities or NaNs.  Instead, the range
995 of exponents is extended, so that this format can represent normalized
996 values in the range of @math{2^{-14}} to 131008.
998 The @code{__fp16} type is a storage format only.  For purposes
999 of arithmetic and other operations, @code{__fp16} values in C or C++
1000 expressions are automatically promoted to @code{float}.  In addition,
1001 you cannot declare a function with a return value or parameters
1002 of type @code{__fp16}.
1004 Note that conversions from @code{double} to @code{__fp16}
1005 involve an intermediate conversion to @code{float}.  Because
1006 of rounding, this can sometimes produce a different result than a
1007 direct conversion.
1009 ARM provides hardware support for conversions between
1010 @code{__fp16} and @code{float} values
1011 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1012 code using these hardware instructions if you compile with
1013 options to select an FPU that provides them;
1014 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1015 in addition to the @option{-mfp16-format} option to select
1016 a half-precision format.
1018 Language-level support for the @code{__fp16} data type is
1019 independent of whether GCC generates code using hardware floating-point
1020 instructions.  In cases where hardware support is not specified, GCC
1021 implements conversions between @code{__fp16} and @code{float} values
1022 as library calls.
1024 @node Decimal Float
1025 @section Decimal Floating Types
1026 @cindex decimal floating types
1027 @cindex @code{_Decimal32} data type
1028 @cindex @code{_Decimal64} data type
1029 @cindex @code{_Decimal128} data type
1030 @cindex @code{df} integer suffix
1031 @cindex @code{dd} integer suffix
1032 @cindex @code{dl} integer suffix
1033 @cindex @code{DF} integer suffix
1034 @cindex @code{DD} integer suffix
1035 @cindex @code{DL} integer suffix
1037 As an extension, GNU C supports decimal floating types as
1038 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1039 floating types in GCC will evolve as the draft technical report changes.
1040 Calling conventions for any target might also change.  Not all targets
1041 support decimal floating types.
1043 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1044 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1045 @code{float}, @code{double}, and @code{long double} whose radix is not
1046 specified by the C standard but is usually two.
1048 Support for decimal floating types includes the arithmetic operators
1049 add, subtract, multiply, divide; unary arithmetic operators;
1050 relational operators; equality operators; and conversions to and from
1051 integer and other floating types.  Use a suffix @samp{df} or
1052 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1053 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1054 @code{_Decimal128}.
1056 GCC support of decimal float as specified by the draft technical report
1057 is incomplete:
1059 @itemize @bullet
1060 @item
1061 When the value of a decimal floating type cannot be represented in the
1062 integer type to which it is being converted, the result is undefined
1063 rather than the result value specified by the draft technical report.
1065 @item
1066 GCC does not provide the C library functionality associated with
1067 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1068 @file{wchar.h}, which must come from a separate C library implementation.
1069 Because of this the GNU C compiler does not define macro
1070 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1071 the technical report.
1072 @end itemize
1074 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1075 are supported by the DWARF 2 debug information format.
1077 @node Hex Floats
1078 @section Hex Floats
1079 @cindex hex floats
1081 ISO C99 supports floating-point numbers written not only in the usual
1082 decimal notation, such as @code{1.55e1}, but also numbers such as
1083 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1084 supports this in C90 mode (except in some cases when strictly
1085 conforming) and in C++.  In that format the
1086 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1087 mandatory.  The exponent is a decimal number that indicates the power of
1088 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1089 @tex
1090 $1 {15\over16}$,
1091 @end tex
1092 @ifnottex
1093 1 15/16,
1094 @end ifnottex
1095 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1096 is the same as @code{1.55e1}.
1098 Unlike for floating-point numbers in the decimal notation the exponent
1099 is always required in the hexadecimal notation.  Otherwise the compiler
1100 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1101 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1102 extension for floating-point constants of type @code{float}.
1104 @node Fixed-Point
1105 @section Fixed-Point Types
1106 @cindex fixed-point types
1107 @cindex @code{_Fract} data type
1108 @cindex @code{_Accum} data type
1109 @cindex @code{_Sat} data type
1110 @cindex @code{hr} fixed-suffix
1111 @cindex @code{r} fixed-suffix
1112 @cindex @code{lr} fixed-suffix
1113 @cindex @code{llr} fixed-suffix
1114 @cindex @code{uhr} fixed-suffix
1115 @cindex @code{ur} fixed-suffix
1116 @cindex @code{ulr} fixed-suffix
1117 @cindex @code{ullr} fixed-suffix
1118 @cindex @code{hk} fixed-suffix
1119 @cindex @code{k} fixed-suffix
1120 @cindex @code{lk} fixed-suffix
1121 @cindex @code{llk} fixed-suffix
1122 @cindex @code{uhk} fixed-suffix
1123 @cindex @code{uk} fixed-suffix
1124 @cindex @code{ulk} fixed-suffix
1125 @cindex @code{ullk} fixed-suffix
1126 @cindex @code{HR} fixed-suffix
1127 @cindex @code{R} fixed-suffix
1128 @cindex @code{LR} fixed-suffix
1129 @cindex @code{LLR} fixed-suffix
1130 @cindex @code{UHR} fixed-suffix
1131 @cindex @code{UR} fixed-suffix
1132 @cindex @code{ULR} fixed-suffix
1133 @cindex @code{ULLR} fixed-suffix
1134 @cindex @code{HK} fixed-suffix
1135 @cindex @code{K} fixed-suffix
1136 @cindex @code{LK} fixed-suffix
1137 @cindex @code{LLK} fixed-suffix
1138 @cindex @code{UHK} fixed-suffix
1139 @cindex @code{UK} fixed-suffix
1140 @cindex @code{ULK} fixed-suffix
1141 @cindex @code{ULLK} fixed-suffix
1143 As an extension, GNU C supports fixed-point types as
1144 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1145 types in GCC will evolve as the draft technical report changes.
1146 Calling conventions for any target might also change.  Not all targets
1147 support fixed-point types.
1149 The fixed-point types are
1150 @code{short _Fract},
1151 @code{_Fract},
1152 @code{long _Fract},
1153 @code{long long _Fract},
1154 @code{unsigned short _Fract},
1155 @code{unsigned _Fract},
1156 @code{unsigned long _Fract},
1157 @code{unsigned long long _Fract},
1158 @code{_Sat short _Fract},
1159 @code{_Sat _Fract},
1160 @code{_Sat long _Fract},
1161 @code{_Sat long long _Fract},
1162 @code{_Sat unsigned short _Fract},
1163 @code{_Sat unsigned _Fract},
1164 @code{_Sat unsigned long _Fract},
1165 @code{_Sat unsigned long long _Fract},
1166 @code{short _Accum},
1167 @code{_Accum},
1168 @code{long _Accum},
1169 @code{long long _Accum},
1170 @code{unsigned short _Accum},
1171 @code{unsigned _Accum},
1172 @code{unsigned long _Accum},
1173 @code{unsigned long long _Accum},
1174 @code{_Sat short _Accum},
1175 @code{_Sat _Accum},
1176 @code{_Sat long _Accum},
1177 @code{_Sat long long _Accum},
1178 @code{_Sat unsigned short _Accum},
1179 @code{_Sat unsigned _Accum},
1180 @code{_Sat unsigned long _Accum},
1181 @code{_Sat unsigned long long _Accum}.
1183 Fixed-point data values contain fractional and optional integral parts.
1184 The format of fixed-point data varies and depends on the target machine.
1186 Support for fixed-point types includes:
1187 @itemize @bullet
1188 @item
1189 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1190 @item
1191 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1192 @item
1193 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1194 @item
1195 binary shift operators (@code{<<}, @code{>>})
1196 @item
1197 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1198 @item
1199 equality operators (@code{==}, @code{!=})
1200 @item
1201 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1202 @code{<<=}, @code{>>=})
1203 @item
1204 conversions to and from integer, floating-point, or fixed-point types
1205 @end itemize
1207 Use a suffix in a fixed-point literal constant:
1208 @itemize
1209 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1210 @code{_Sat short _Fract}
1211 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1212 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1213 @code{_Sat long _Fract}
1214 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1215 @code{_Sat long long _Fract}
1216 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1217 @code{_Sat unsigned short _Fract}
1218 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1219 @code{_Sat unsigned _Fract}
1220 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1221 @code{_Sat unsigned long _Fract}
1222 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1223 and @code{_Sat unsigned long long _Fract}
1224 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1225 @code{_Sat short _Accum}
1226 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1227 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1228 @code{_Sat long _Accum}
1229 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1230 @code{_Sat long long _Accum}
1231 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1232 @code{_Sat unsigned short _Accum}
1233 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1234 @code{_Sat unsigned _Accum}
1235 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1236 @code{_Sat unsigned long _Accum}
1237 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1238 and @code{_Sat unsigned long long _Accum}
1239 @end itemize
1241 GCC support of fixed-point types as specified by the draft technical report
1242 is incomplete:
1244 @itemize @bullet
1245 @item
1246 Pragmas to control overflow and rounding behaviors are not implemented.
1247 @end itemize
1249 Fixed-point types are supported by the DWARF 2 debug information format.
1251 @node Named Address Spaces
1252 @section Named Address Spaces
1253 @cindex Named Address Spaces
1255 As an extension, GNU C supports named address spaces as
1256 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1257 address spaces in GCC will evolve as the draft technical report
1258 changes.  Calling conventions for any target might also change.  At
1259 present, only the AVR, SPU, M32C, and RL78 targets support address
1260 spaces other than the generic address space.
1262 Address space identifiers may be used exactly like any other C type
1263 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1264 document for more details.
1266 @anchor{AVR Named Address Spaces}
1267 @subsection AVR Named Address Spaces
1269 On the AVR target, there are several address spaces that can be used
1270 in order to put read-only data into the flash memory and access that
1271 data by means of the special instructions @code{LPM} or @code{ELPM}
1272 needed to read from flash.
1274 Per default, any data including read-only data is located in RAM
1275 (the generic address space) so that non-generic address spaces are
1276 needed to locate read-only data in flash memory
1277 @emph{and} to generate the right instructions to access this data
1278 without using (inline) assembler code.
1280 @table @code
1281 @item __flash
1282 @cindex @code{__flash} AVR Named Address Spaces
1283 The @code{__flash} qualifier locates data in the
1284 @code{.progmem.data} section. Data is read using the @code{LPM}
1285 instruction. Pointers to this address space are 16 bits wide.
1287 @item __flash1
1288 @itemx __flash2
1289 @itemx __flash3
1290 @itemx __flash4
1291 @itemx __flash5
1292 @cindex @code{__flash1} AVR Named Address Spaces
1293 @cindex @code{__flash2} AVR Named Address Spaces
1294 @cindex @code{__flash3} AVR Named Address Spaces
1295 @cindex @code{__flash4} AVR Named Address Spaces
1296 @cindex @code{__flash5} AVR Named Address Spaces
1297 These are 16-bit address spaces locating data in section
1298 @code{.progmem@var{N}.data} where @var{N} refers to
1299 address space @code{__flash@var{N}}.
1300 The compiler sets the @code{RAMPZ} segment register appropriately 
1301 before reading data by means of the @code{ELPM} instruction.
1303 @item __memx
1304 @cindex @code{__memx} AVR Named Address Spaces
1305 This is a 24-bit address space that linearizes flash and RAM:
1306 If the high bit of the address is set, data is read from
1307 RAM using the lower two bytes as RAM address.
1308 If the high bit of the address is clear, data is read from flash
1309 with @code{RAMPZ} set according to the high byte of the address.
1310 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1312 Objects in this address space are located in @code{.progmemx.data}.
1313 @end table
1315 @b{Example}
1317 @smallexample
1318 char my_read (const __flash char ** p)
1320     /* p is a pointer to RAM that points to a pointer to flash.
1321        The first indirection of p reads that flash pointer
1322        from RAM and the second indirection reads a char from this
1323        flash address.  */
1325     return **p;
1328 /* Locate array[] in flash memory */
1329 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1331 int i = 1;
1333 int main (void)
1335    /* Return 17 by reading from flash memory */
1336    return array[array[i]];
1338 @end smallexample
1340 @noindent
1341 For each named address space supported by avr-gcc there is an equally
1342 named but uppercase built-in macro defined. 
1343 The purpose is to facilitate testing if respective address space
1344 support is available or not:
1346 @smallexample
1347 #ifdef __FLASH
1348 const __flash int var = 1;
1350 int read_var (void)
1352     return var;
1354 #else
1355 #include <avr/pgmspace.h> /* From AVR-LibC */
1357 const int var PROGMEM = 1;
1359 int read_var (void)
1361     return (int) pgm_read_word (&var);
1363 #endif /* __FLASH */
1364 @end smallexample
1366 @noindent
1367 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1368 locates data in flash but
1369 accesses to these data read from generic address space, i.e.@:
1370 from RAM,
1371 so that you need special accessors like @code{pgm_read_byte}
1372 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1373 together with attribute @code{progmem}.
1375 @noindent
1376 @b{Limitations and caveats}
1378 @itemize
1379 @item
1380 Reading across the 64@tie{}KiB section boundary of
1381 the @code{__flash} or @code{__flash@var{N}} address spaces
1382 shows undefined behavior. The only address space that
1383 supports reading across the 64@tie{}KiB flash segment boundaries is
1384 @code{__memx}.
1386 @item
1387 If you use one of the @code{__flash@var{N}} address spaces
1388 you must arrange your linker script to locate the
1389 @code{.progmem@var{N}.data} sections according to your needs.
1391 @item
1392 Any data or pointers to the non-generic address spaces must
1393 be qualified as @code{const}, i.e.@: as read-only data.
1394 This still applies if the data in one of these address
1395 spaces like software version number or calibration lookup table are intended to
1396 be changed after load time by, say, a boot loader. In this case
1397 the right qualification is @code{const} @code{volatile} so that the compiler
1398 must not optimize away known values or insert them
1399 as immediates into operands of instructions.
1401 @item
1402 The following code initializes a variable @code{pfoo}
1403 located in static storage with a 24-bit address:
1404 @smallexample
1405 extern const __memx char foo;
1406 const __memx void *pfoo = &foo;
1407 @end smallexample
1409 @noindent
1410 Such code requires at least binutils 2.23, see
1411 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1413 @end itemize
1415 @subsection M32C Named Address Spaces
1416 @cindex @code{__far} M32C Named Address Spaces
1418 On the M32C target, with the R8C and M16C CPU variants, variables
1419 qualified with @code{__far} are accessed using 32-bit addresses in
1420 order to access memory beyond the first 64@tie{}Ki bytes.  If
1421 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1422 effect.
1424 @subsection RL78 Named Address Spaces
1425 @cindex @code{__far} RL78 Named Address Spaces
1427 On the RL78 target, variables qualified with @code{__far} are accessed
1428 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1429 addresses.  Non-far variables are assumed to appear in the topmost
1430 64@tie{}KiB of the address space.
1432 @subsection SPU Named Address Spaces
1433 @cindex @code{__ea} SPU Named Address Spaces
1435 On the SPU target variables may be declared as
1436 belonging to another address space by qualifying the type with the
1437 @code{__ea} address space identifier:
1439 @smallexample
1440 extern int __ea i;
1441 @end smallexample
1443 @noindent 
1444 The compiler generates special code to access the variable @code{i}.
1445 It may use runtime library
1446 support, or generate special machine instructions to access that address
1447 space.
1449 @node Zero Length
1450 @section Arrays of Length Zero
1451 @cindex arrays of length zero
1452 @cindex zero-length arrays
1453 @cindex length-zero arrays
1454 @cindex flexible array members
1456 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1457 last element of a structure that is really a header for a variable-length
1458 object:
1460 @smallexample
1461 struct line @{
1462   int length;
1463   char contents[0];
1466 struct line *thisline = (struct line *)
1467   malloc (sizeof (struct line) + this_length);
1468 thisline->length = this_length;
1469 @end smallexample
1471 In ISO C90, you would have to give @code{contents} a length of 1, which
1472 means either you waste space or complicate the argument to @code{malloc}.
1474 In ISO C99, you would use a @dfn{flexible array member}, which is
1475 slightly different in syntax and semantics:
1477 @itemize @bullet
1478 @item
1479 Flexible array members are written as @code{contents[]} without
1480 the @code{0}.
1482 @item
1483 Flexible array members have incomplete type, and so the @code{sizeof}
1484 operator may not be applied.  As a quirk of the original implementation
1485 of zero-length arrays, @code{sizeof} evaluates to zero.
1487 @item
1488 Flexible array members may only appear as the last member of a
1489 @code{struct} that is otherwise non-empty.
1491 @item
1492 A structure containing a flexible array member, or a union containing
1493 such a structure (possibly recursively), may not be a member of a
1494 structure or an element of an array.  (However, these uses are
1495 permitted by GCC as extensions.)
1496 @end itemize
1498 GCC versions before 3.0 allowed zero-length arrays to be statically
1499 initialized, as if they were flexible arrays.  In addition to those
1500 cases that were useful, it also allowed initializations in situations
1501 that would corrupt later data.  Non-empty initialization of zero-length
1502 arrays is now treated like any case where there are more initializer
1503 elements than the array holds, in that a suitable warning about ``excess
1504 elements in array'' is given, and the excess elements (all of them, in
1505 this case) are ignored.
1507 Instead GCC allows static initialization of flexible array members.
1508 This is equivalent to defining a new structure containing the original
1509 structure followed by an array of sufficient size to contain the data.
1510 E.g.@: in the following, @code{f1} is constructed as if it were declared
1511 like @code{f2}.
1513 @smallexample
1514 struct f1 @{
1515   int x; int y[];
1516 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1518 struct f2 @{
1519   struct f1 f1; int data[3];
1520 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1521 @end smallexample
1523 @noindent
1524 The convenience of this extension is that @code{f1} has the desired
1525 type, eliminating the need to consistently refer to @code{f2.f1}.
1527 This has symmetry with normal static arrays, in that an array of
1528 unknown size is also written with @code{[]}.
1530 Of course, this extension only makes sense if the extra data comes at
1531 the end of a top-level object, as otherwise we would be overwriting
1532 data at subsequent offsets.  To avoid undue complication and confusion
1533 with initialization of deeply nested arrays, we simply disallow any
1534 non-empty initialization except when the structure is the top-level
1535 object.  For example:
1537 @smallexample
1538 struct foo @{ int x; int y[]; @};
1539 struct bar @{ struct foo z; @};
1541 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1542 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1543 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1544 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1545 @end smallexample
1547 @node Empty Structures
1548 @section Structures With No Members
1549 @cindex empty structures
1550 @cindex zero-size structures
1552 GCC permits a C structure to have no members:
1554 @smallexample
1555 struct empty @{
1557 @end smallexample
1559 The structure has size zero.  In C++, empty structures are part
1560 of the language.  G++ treats empty structures as if they had a single
1561 member of type @code{char}.
1563 @node Variable Length
1564 @section Arrays of Variable Length
1565 @cindex variable-length arrays
1566 @cindex arrays of variable length
1567 @cindex VLAs
1569 Variable-length automatic arrays are allowed in ISO C99, and as an
1570 extension GCC accepts them in C90 mode and in C++.  These arrays are
1571 declared like any other automatic arrays, but with a length that is not
1572 a constant expression.  The storage is allocated at the point of
1573 declaration and deallocated when the block scope containing the declaration
1574 exits.  For
1575 example:
1577 @smallexample
1578 FILE *
1579 concat_fopen (char *s1, char *s2, char *mode)
1581   char str[strlen (s1) + strlen (s2) + 1];
1582   strcpy (str, s1);
1583   strcat (str, s2);
1584   return fopen (str, mode);
1586 @end smallexample
1588 @cindex scope of a variable length array
1589 @cindex variable-length array scope
1590 @cindex deallocating variable length arrays
1591 Jumping or breaking out of the scope of the array name deallocates the
1592 storage.  Jumping into the scope is not allowed; you get an error
1593 message for it.
1595 @cindex variable-length array in a structure
1596 As an extension, GCC accepts variable-length arrays as a member of
1597 a structure or a union.  For example:
1599 @smallexample
1600 void
1601 foo (int n)
1603   struct S @{ int x[n]; @};
1605 @end smallexample
1607 @cindex @code{alloca} vs variable-length arrays
1608 You can use the function @code{alloca} to get an effect much like
1609 variable-length arrays.  The function @code{alloca} is available in
1610 many other C implementations (but not in all).  On the other hand,
1611 variable-length arrays are more elegant.
1613 There are other differences between these two methods.  Space allocated
1614 with @code{alloca} exists until the containing @emph{function} returns.
1615 The space for a variable-length array is deallocated as soon as the array
1616 name's scope ends.  (If you use both variable-length arrays and
1617 @code{alloca} in the same function, deallocation of a variable-length array
1618 also deallocates anything more recently allocated with @code{alloca}.)
1620 You can also use variable-length arrays as arguments to functions:
1622 @smallexample
1623 struct entry
1624 tester (int len, char data[len][len])
1626   /* @r{@dots{}} */
1628 @end smallexample
1630 The length of an array is computed once when the storage is allocated
1631 and is remembered for the scope of the array in case you access it with
1632 @code{sizeof}.
1634 If you want to pass the array first and the length afterward, you can
1635 use a forward declaration in the parameter list---another GNU extension.
1637 @smallexample
1638 struct entry
1639 tester (int len; char data[len][len], int len)
1641   /* @r{@dots{}} */
1643 @end smallexample
1645 @cindex parameter forward declaration
1646 The @samp{int len} before the semicolon is a @dfn{parameter forward
1647 declaration}, and it serves the purpose of making the name @code{len}
1648 known when the declaration of @code{data} is parsed.
1650 You can write any number of such parameter forward declarations in the
1651 parameter list.  They can be separated by commas or semicolons, but the
1652 last one must end with a semicolon, which is followed by the ``real''
1653 parameter declarations.  Each forward declaration must match a ``real''
1654 declaration in parameter name and data type.  ISO C99 does not support
1655 parameter forward declarations.
1657 @node Variadic Macros
1658 @section Macros with a Variable Number of Arguments.
1659 @cindex variable number of arguments
1660 @cindex macro with variable arguments
1661 @cindex rest argument (in macro)
1662 @cindex variadic macros
1664 In the ISO C standard of 1999, a macro can be declared to accept a
1665 variable number of arguments much as a function can.  The syntax for
1666 defining the macro is similar to that of a function.  Here is an
1667 example:
1669 @smallexample
1670 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1671 @end smallexample
1673 @noindent
1674 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1675 such a macro, it represents the zero or more tokens until the closing
1676 parenthesis that ends the invocation, including any commas.  This set of
1677 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1678 wherever it appears.  See the CPP manual for more information.
1680 GCC has long supported variadic macros, and used a different syntax that
1681 allowed you to give a name to the variable arguments just like any other
1682 argument.  Here is an example:
1684 @smallexample
1685 #define debug(format, args...) fprintf (stderr, format, args)
1686 @end smallexample
1688 @noindent
1689 This is in all ways equivalent to the ISO C example above, but arguably
1690 more readable and descriptive.
1692 GNU CPP has two further variadic macro extensions, and permits them to
1693 be used with either of the above forms of macro definition.
1695 In standard C, you are not allowed to leave the variable argument out
1696 entirely; but you are allowed to pass an empty argument.  For example,
1697 this invocation is invalid in ISO C, because there is no comma after
1698 the string:
1700 @smallexample
1701 debug ("A message")
1702 @end smallexample
1704 GNU CPP permits you to completely omit the variable arguments in this
1705 way.  In the above examples, the compiler would complain, though since
1706 the expansion of the macro still has the extra comma after the format
1707 string.
1709 To help solve this problem, CPP behaves specially for variable arguments
1710 used with the token paste operator, @samp{##}.  If instead you write
1712 @smallexample
1713 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1714 @end smallexample
1716 @noindent
1717 and if the variable arguments are omitted or empty, the @samp{##}
1718 operator causes the preprocessor to remove the comma before it.  If you
1719 do provide some variable arguments in your macro invocation, GNU CPP
1720 does not complain about the paste operation and instead places the
1721 variable arguments after the comma.  Just like any other pasted macro
1722 argument, these arguments are not macro expanded.
1724 @node Escaped Newlines
1725 @section Slightly Looser Rules for Escaped Newlines
1726 @cindex escaped newlines
1727 @cindex newlines (escaped)
1729 Recently, the preprocessor has relaxed its treatment of escaped
1730 newlines.  Previously, the newline had to immediately follow a
1731 backslash.  The current implementation allows whitespace in the form
1732 of spaces, horizontal and vertical tabs, and form feeds between the
1733 backslash and the subsequent newline.  The preprocessor issues a
1734 warning, but treats it as a valid escaped newline and combines the two
1735 lines to form a single logical line.  This works within comments and
1736 tokens, as well as between tokens.  Comments are @emph{not} treated as
1737 whitespace for the purposes of this relaxation, since they have not
1738 yet been replaced with spaces.
1740 @node Subscripting
1741 @section Non-Lvalue Arrays May Have Subscripts
1742 @cindex subscripting
1743 @cindex arrays, non-lvalue
1745 @cindex subscripting and function values
1746 In ISO C99, arrays that are not lvalues still decay to pointers, and
1747 may be subscripted, although they may not be modified or used after
1748 the next sequence point and the unary @samp{&} operator may not be
1749 applied to them.  As an extension, GNU C allows such arrays to be
1750 subscripted in C90 mode, though otherwise they do not decay to
1751 pointers outside C99 mode.  For example,
1752 this is valid in GNU C though not valid in C90:
1754 @smallexample
1755 @group
1756 struct foo @{int a[4];@};
1758 struct foo f();
1760 bar (int index)
1762   return f().a[index];
1764 @end group
1765 @end smallexample
1767 @node Pointer Arith
1768 @section Arithmetic on @code{void}- and Function-Pointers
1769 @cindex void pointers, arithmetic
1770 @cindex void, size of pointer to
1771 @cindex function pointers, arithmetic
1772 @cindex function, size of pointer to
1774 In GNU C, addition and subtraction operations are supported on pointers to
1775 @code{void} and on pointers to functions.  This is done by treating the
1776 size of a @code{void} or of a function as 1.
1778 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1779 and on function types, and returns 1.
1781 @opindex Wpointer-arith
1782 The option @option{-Wpointer-arith} requests a warning if these extensions
1783 are used.
1785 @node Initializers
1786 @section Non-Constant Initializers
1787 @cindex initializers, non-constant
1788 @cindex non-constant initializers
1790 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1791 automatic variable are not required to be constant expressions in GNU C@.
1792 Here is an example of an initializer with run-time varying elements:
1794 @smallexample
1795 foo (float f, float g)
1797   float beat_freqs[2] = @{ f-g, f+g @};
1798   /* @r{@dots{}} */
1800 @end smallexample
1802 @node Compound Literals
1803 @section Compound Literals
1804 @cindex constructor expressions
1805 @cindex initializations in expressions
1806 @cindex structures, constructor expression
1807 @cindex expressions, constructor
1808 @cindex compound literals
1809 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1811 ISO C99 supports compound literals.  A compound literal looks like
1812 a cast containing an initializer.  Its value is an object of the
1813 type specified in the cast, containing the elements specified in
1814 the initializer; it is an lvalue.  As an extension, GCC supports
1815 compound literals in C90 mode and in C++, though the semantics are
1816 somewhat different in C++.
1818 Usually, the specified type is a structure.  Assume that
1819 @code{struct foo} and @code{structure} are declared as shown:
1821 @smallexample
1822 struct foo @{int a; char b[2];@} structure;
1823 @end smallexample
1825 @noindent
1826 Here is an example of constructing a @code{struct foo} with a compound literal:
1828 @smallexample
1829 structure = ((struct foo) @{x + y, 'a', 0@});
1830 @end smallexample
1832 @noindent
1833 This is equivalent to writing the following:
1835 @smallexample
1837   struct foo temp = @{x + y, 'a', 0@};
1838   structure = temp;
1840 @end smallexample
1842 You can also construct an array, though this is dangerous in C++, as
1843 explained below.  If all the elements of the compound literal are
1844 (made up of) simple constant expressions, suitable for use in
1845 initializers of objects of static storage duration, then the compound
1846 literal can be coerced to a pointer to its first element and used in
1847 such an initializer, as shown here:
1849 @smallexample
1850 char **foo = (char *[]) @{ "x", "y", "z" @};
1851 @end smallexample
1853 Compound literals for scalar types and union types are
1854 also allowed, but then the compound literal is equivalent
1855 to a cast.
1857 As a GNU extension, GCC allows initialization of objects with static storage
1858 duration by compound literals (which is not possible in ISO C99, because
1859 the initializer is not a constant).
1860 It is handled as if the object is initialized only with the bracket
1861 enclosed list if the types of the compound literal and the object match.
1862 The initializer list of the compound literal must be constant.
1863 If the object being initialized has array type of unknown size, the size is
1864 determined by compound literal size.
1866 @smallexample
1867 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1868 static int y[] = (int []) @{1, 2, 3@};
1869 static int z[] = (int [3]) @{1@};
1870 @end smallexample
1872 @noindent
1873 The above lines are equivalent to the following:
1874 @smallexample
1875 static struct foo x = @{1, 'a', 'b'@};
1876 static int y[] = @{1, 2, 3@};
1877 static int z[] = @{1, 0, 0@};
1878 @end smallexample
1880 In C, a compound literal designates an unnamed object with static or
1881 automatic storage duration.  In C++, a compound literal designates a
1882 temporary object, which only lives until the end of its
1883 full-expression.  As a result, well-defined C code that takes the
1884 address of a subobject of a compound literal can be undefined in C++.
1885 For instance, if the array compound literal example above appeared
1886 inside a function, any subsequent use of @samp{foo} in C++ has
1887 undefined behavior because the lifetime of the array ends after the
1888 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1889 the conversion of a temporary array to a pointer.
1891 As an optimization, the C++ compiler sometimes gives array compound
1892 literals longer lifetimes: when the array either appears outside a
1893 function or has const-qualified type.  If @samp{foo} and its
1894 initializer had elements of @samp{char *const} type rather than
1895 @samp{char *}, or if @samp{foo} were a global variable, the array
1896 would have static storage duration.  But it is probably safest just to
1897 avoid the use of array compound literals in code compiled as C++.
1899 @node Designated Inits
1900 @section Designated Initializers
1901 @cindex initializers with labeled elements
1902 @cindex labeled elements in initializers
1903 @cindex case labels in initializers
1904 @cindex designated initializers
1906 Standard C90 requires the elements of an initializer to appear in a fixed
1907 order, the same as the order of the elements in the array or structure
1908 being initialized.
1910 In ISO C99 you can give the elements in any order, specifying the array
1911 indices or structure field names they apply to, and GNU C allows this as
1912 an extension in C90 mode as well.  This extension is not
1913 implemented in GNU C++.
1915 To specify an array index, write
1916 @samp{[@var{index}] =} before the element value.  For example,
1918 @smallexample
1919 int a[6] = @{ [4] = 29, [2] = 15 @};
1920 @end smallexample
1922 @noindent
1923 is equivalent to
1925 @smallexample
1926 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1927 @end smallexample
1929 @noindent
1930 The index values must be constant expressions, even if the array being
1931 initialized is automatic.
1933 An alternative syntax for this that has been obsolete since GCC 2.5 but
1934 GCC still accepts is to write @samp{[@var{index}]} before the element
1935 value, with no @samp{=}.
1937 To initialize a range of elements to the same value, write
1938 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1939 extension.  For example,
1941 @smallexample
1942 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1943 @end smallexample
1945 @noindent
1946 If the value in it has side-effects, the side-effects happen only once,
1947 not for each initialized field by the range initializer.
1949 @noindent
1950 Note that the length of the array is the highest value specified
1951 plus one.
1953 In a structure initializer, specify the name of a field to initialize
1954 with @samp{.@var{fieldname} =} before the element value.  For example,
1955 given the following structure,
1957 @smallexample
1958 struct point @{ int x, y; @};
1959 @end smallexample
1961 @noindent
1962 the following initialization
1964 @smallexample
1965 struct point p = @{ .y = yvalue, .x = xvalue @};
1966 @end smallexample
1968 @noindent
1969 is equivalent to
1971 @smallexample
1972 struct point p = @{ xvalue, yvalue @};
1973 @end smallexample
1975 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1976 @samp{@var{fieldname}:}, as shown here:
1978 @smallexample
1979 struct point p = @{ y: yvalue, x: xvalue @};
1980 @end smallexample
1982 Omitted field members are implicitly initialized the same as objects
1983 that have static storage duration.
1985 @cindex designators
1986 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1987 @dfn{designator}.  You can also use a designator (or the obsolete colon
1988 syntax) when initializing a union, to specify which element of the union
1989 should be used.  For example,
1991 @smallexample
1992 union foo @{ int i; double d; @};
1994 union foo f = @{ .d = 4 @};
1995 @end smallexample
1997 @noindent
1998 converts 4 to a @code{double} to store it in the union using
1999 the second element.  By contrast, casting 4 to type @code{union foo}
2000 stores it into the union as the integer @code{i}, since it is
2001 an integer.  (@xref{Cast to Union}.)
2003 You can combine this technique of naming elements with ordinary C
2004 initialization of successive elements.  Each initializer element that
2005 does not have a designator applies to the next consecutive element of the
2006 array or structure.  For example,
2008 @smallexample
2009 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2010 @end smallexample
2012 @noindent
2013 is equivalent to
2015 @smallexample
2016 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2017 @end smallexample
2019 Labeling the elements of an array initializer is especially useful
2020 when the indices are characters or belong to an @code{enum} type.
2021 For example:
2023 @smallexample
2024 int whitespace[256]
2025   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2026       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2027 @end smallexample
2029 @cindex designator lists
2030 You can also write a series of @samp{.@var{fieldname}} and
2031 @samp{[@var{index}]} designators before an @samp{=} to specify a
2032 nested subobject to initialize; the list is taken relative to the
2033 subobject corresponding to the closest surrounding brace pair.  For
2034 example, with the @samp{struct point} declaration above:
2036 @smallexample
2037 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2038 @end smallexample
2040 @noindent
2041 If the same field is initialized multiple times, it has the value from
2042 the last initialization.  If any such overridden initialization has
2043 side-effect, it is unspecified whether the side-effect happens or not.
2044 Currently, GCC discards them and issues a warning.
2046 @node Case Ranges
2047 @section Case Ranges
2048 @cindex case ranges
2049 @cindex ranges in case statements
2051 You can specify a range of consecutive values in a single @code{case} label,
2052 like this:
2054 @smallexample
2055 case @var{low} ... @var{high}:
2056 @end smallexample
2058 @noindent
2059 This has the same effect as the proper number of individual @code{case}
2060 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2062 This feature is especially useful for ranges of ASCII character codes:
2064 @smallexample
2065 case 'A' ... 'Z':
2066 @end smallexample
2068 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2069 it may be parsed wrong when you use it with integer values.  For example,
2070 write this:
2072 @smallexample
2073 case 1 ... 5:
2074 @end smallexample
2076 @noindent
2077 rather than this:
2079 @smallexample
2080 case 1...5:
2081 @end smallexample
2083 @node Cast to Union
2084 @section Cast to a Union Type
2085 @cindex cast to a union
2086 @cindex union, casting to a
2088 A cast to union type is similar to other casts, except that the type
2089 specified is a union type.  You can specify the type either with
2090 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2091 a constructor, not a cast, and hence does not yield an lvalue like
2092 normal casts.  (@xref{Compound Literals}.)
2094 The types that may be cast to the union type are those of the members
2095 of the union.  Thus, given the following union and variables:
2097 @smallexample
2098 union foo @{ int i; double d; @};
2099 int x;
2100 double y;
2101 @end smallexample
2103 @noindent
2104 both @code{x} and @code{y} can be cast to type @code{union foo}.
2106 Using the cast as the right-hand side of an assignment to a variable of
2107 union type is equivalent to storing in a member of the union:
2109 @smallexample
2110 union foo u;
2111 /* @r{@dots{}} */
2112 u = (union foo) x  @equiv{}  u.i = x
2113 u = (union foo) y  @equiv{}  u.d = y
2114 @end smallexample
2116 You can also use the union cast as a function argument:
2118 @smallexample
2119 void hack (union foo);
2120 /* @r{@dots{}} */
2121 hack ((union foo) x);
2122 @end smallexample
2124 @node Mixed Declarations
2125 @section Mixed Declarations and Code
2126 @cindex mixed declarations and code
2127 @cindex declarations, mixed with code
2128 @cindex code, mixed with declarations
2130 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2131 within compound statements.  As an extension, GNU C also allows this in
2132 C90 mode.  For example, you could do:
2134 @smallexample
2135 int i;
2136 /* @r{@dots{}} */
2137 i++;
2138 int j = i + 2;
2139 @end smallexample
2141 Each identifier is visible from where it is declared until the end of
2142 the enclosing block.
2144 @node Function Attributes
2145 @section Declaring Attributes of Functions
2146 @cindex function attributes
2147 @cindex declaring attributes of functions
2148 @cindex functions that never return
2149 @cindex functions that return more than once
2150 @cindex functions that have no side effects
2151 @cindex functions in arbitrary sections
2152 @cindex functions that behave like malloc
2153 @cindex @code{volatile} applied to function
2154 @cindex @code{const} applied to function
2155 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2156 @cindex functions with non-null pointer arguments
2157 @cindex functions that are passed arguments in registers on the 386
2158 @cindex functions that pop the argument stack on the 386
2159 @cindex functions that do not pop the argument stack on the 386
2160 @cindex functions that have different compilation options on the 386
2161 @cindex functions that have different optimization options
2162 @cindex functions that are dynamically resolved
2164 In GNU C, you declare certain things about functions called in your program
2165 which help the compiler optimize function calls and check your code more
2166 carefully.
2168 The keyword @code{__attribute__} allows you to specify special
2169 attributes when making a declaration.  This keyword is followed by an
2170 attribute specification inside double parentheses.  The following
2171 attributes are currently defined for functions on all targets:
2172 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2173 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2174 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2175 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2176 @code{no_instrument_function}, @code{no_split_stack},
2177 @code{section}, @code{constructor},
2178 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2179 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2180 @code{warn_unused_result}, @code{nonnull},
2181 @code{returns_nonnull}, @code{gnu_inline},
2182 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2183 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2184 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2185 @code{bnd_instrument},
2186 @code{error} and @code{warning}.
2187 Several other attributes are defined for functions on particular
2188 target systems.  Other attributes, including @code{section} are
2189 supported for variables declarations (@pxref{Variable Attributes}),
2190 labels (@pxref{Label Attributes})
2191 and for types (@pxref{Type Attributes}).
2193 GCC plugins may provide their own attributes.
2195 You may also specify attributes with @samp{__} preceding and following
2196 each keyword.  This allows you to use them in header files without
2197 being concerned about a possible macro of the same name.  For example,
2198 you may use @code{__noreturn__} instead of @code{noreturn}.
2200 @xref{Attribute Syntax}, for details of the exact syntax for using
2201 attributes.
2203 @table @code
2204 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2206 @item alias ("@var{target}")
2207 @cindex @code{alias} attribute
2208 The @code{alias} attribute causes the declaration to be emitted as an
2209 alias for another symbol, which must be specified.  For instance,
2211 @smallexample
2212 void __f () @{ /* @r{Do something.} */; @}
2213 void f () __attribute__ ((weak, alias ("__f")));
2214 @end smallexample
2216 @noindent
2217 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2218 mangled name for the target must be used.  It is an error if @samp{__f}
2219 is not defined in the same translation unit.
2221 Not all target machines support this attribute.
2223 @item aligned (@var{alignment})
2224 @cindex @code{aligned} attribute
2225 This attribute specifies a minimum alignment for the function,
2226 measured in bytes.
2228 You cannot use this attribute to decrease the alignment of a function,
2229 only to increase it.  However, when you explicitly specify a function
2230 alignment this overrides the effect of the
2231 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2232 function.
2234 Note that the effectiveness of @code{aligned} attributes may be
2235 limited by inherent limitations in your linker.  On many systems, the
2236 linker is only able to arrange for functions to be aligned up to a
2237 certain maximum alignment.  (For some linkers, the maximum supported
2238 alignment may be very very small.)  See your linker documentation for
2239 further information.
2241 The @code{aligned} attribute can also be used for variables and fields
2242 (@pxref{Variable Attributes}.)
2244 @item alloc_size
2245 @cindex @code{alloc_size} attribute
2246 The @code{alloc_size} attribute is used to tell the compiler that the
2247 function return value points to memory, where the size is given by
2248 one or two of the functions parameters.  GCC uses this
2249 information to improve the correctness of @code{__builtin_object_size}.
2251 The function parameter(s) denoting the allocated size are specified by
2252 one or two integer arguments supplied to the attribute.  The allocated size
2253 is either the value of the single function argument specified or the product
2254 of the two function arguments specified.  Argument numbering starts at
2255 one.
2257 For instance,
2259 @smallexample
2260 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2261 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2262 @end smallexample
2264 @noindent
2265 declares that @code{my_calloc} returns memory of the size given by
2266 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2267 of the size given by parameter 2.
2269 @item alloc_align
2270 @cindex @code{alloc_align} attribute
2271 The @code{alloc_align} attribute is used to tell the compiler that the
2272 function return value points to memory, where the returned pointer minimum
2273 alignment is given by one of the functions parameters.  GCC uses this
2274 information to improve pointer alignment analysis.
2276 The function parameter denoting the allocated alignment is specified by
2277 one integer argument, whose number is the argument of the attribute.
2278 Argument numbering starts at one.
2280 For instance,
2282 @smallexample
2283 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2284 @end smallexample
2286 @noindent
2287 declares that @code{my_memalign} returns memory with minimum alignment
2288 given by parameter 1.
2290 @item assume_aligned
2291 @cindex @code{assume_aligned} attribute
2292 The @code{assume_aligned} attribute is used to tell the compiler that the
2293 function return value points to memory, where the returned pointer minimum
2294 alignment is given by the first argument.
2295 If the attribute has two arguments, the second argument is misalignment offset.
2297 For instance
2299 @smallexample
2300 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2301 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2302 @end smallexample
2304 @noindent
2305 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2306 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2307 to 8.
2309 @item always_inline
2310 @cindex @code{always_inline} function attribute
2311 Generally, functions are not inlined unless optimization is specified.
2312 For functions declared inline, this attribute inlines the function
2313 independent of any restrictions that otherwise apply to inlining.
2314 Failure to inline such a function is diagnosed as an error.
2315 Note that if such a function is called indirectly the compiler may
2316 or may not inline it depending on optimization level and a failure
2317 to inline an indirect call may or may not be diagnosed.
2319 @item gnu_inline
2320 @cindex @code{gnu_inline} function attribute
2321 This attribute should be used with a function that is also declared
2322 with the @code{inline} keyword.  It directs GCC to treat the function
2323 as if it were defined in gnu90 mode even when compiling in C99 or
2324 gnu99 mode.
2326 If the function is declared @code{extern}, then this definition of the
2327 function is used only for inlining.  In no case is the function
2328 compiled as a standalone function, not even if you take its address
2329 explicitly.  Such an address becomes an external reference, as if you
2330 had only declared the function, and had not defined it.  This has
2331 almost the effect of a macro.  The way to use this is to put a
2332 function definition in a header file with this attribute, and put
2333 another copy of the function, without @code{extern}, in a library
2334 file.  The definition in the header file causes most calls to the
2335 function to be inlined.  If any uses of the function remain, they
2336 refer to the single copy in the library.  Note that the two
2337 definitions of the functions need not be precisely the same, although
2338 if they do not have the same effect your program may behave oddly.
2340 In C, if the function is neither @code{extern} nor @code{static}, then
2341 the function is compiled as a standalone function, as well as being
2342 inlined where possible.
2344 This is how GCC traditionally handled functions declared
2345 @code{inline}.  Since ISO C99 specifies a different semantics for
2346 @code{inline}, this function attribute is provided as a transition
2347 measure and as a useful feature in its own right.  This attribute is
2348 available in GCC 4.1.3 and later.  It is available if either of the
2349 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2350 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2351 Function is As Fast As a Macro}.
2353 In C++, this attribute does not depend on @code{extern} in any way,
2354 but it still requires the @code{inline} keyword to enable its special
2355 behavior.
2357 @item artificial
2358 @cindex @code{artificial} function attribute
2359 This attribute is useful for small inline wrappers that if possible
2360 should appear during debugging as a unit.  Depending on the debug
2361 info format it either means marking the function as artificial
2362 or using the caller location for all instructions within the inlined
2363 body.
2365 @item bank_switch
2366 @cindex interrupt handler functions
2367 When added to an interrupt handler with the M32C port, causes the
2368 prologue and epilogue to use bank switching to preserve the registers
2369 rather than saving them on the stack.
2371 @item flatten
2372 @cindex @code{flatten} function attribute
2373 Generally, inlining into a function is limited.  For a function marked with
2374 this attribute, every call inside this function is inlined, if possible.
2375 Whether the function itself is considered for inlining depends on its size and
2376 the current inlining parameters.
2378 @item error ("@var{message}")
2379 @cindex @code{error} function attribute
2380 If this attribute is used on a function declaration and a call to such a function
2381 is not eliminated through dead code elimination or other optimizations, an error
2382 that includes @var{message} is diagnosed.  This is useful
2383 for compile-time checking, especially together with @code{__builtin_constant_p}
2384 and inline functions where checking the inline function arguments is not
2385 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2386 While it is possible to leave the function undefined and thus invoke
2387 a link failure, when using this attribute the problem is diagnosed
2388 earlier and with exact location of the call even in presence of inline
2389 functions or when not emitting debugging information.
2391 @item warning ("@var{message}")
2392 @cindex @code{warning} function attribute
2393 If this attribute is used on a function declaration and a call to such a function
2394 is not eliminated through dead code elimination or other optimizations, a warning
2395 that includes @var{message} is diagnosed.  This is useful
2396 for compile-time checking, especially together with @code{__builtin_constant_p}
2397 and inline functions.  While it is possible to define the function with
2398 a message in @code{.gnu.warning*} section, when using this attribute the problem
2399 is diagnosed earlier and with exact location of the call even in presence
2400 of inline functions or when not emitting debugging information.
2402 @item cdecl
2403 @cindex functions that do pop the argument stack on the 386
2404 @opindex mrtd
2405 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2406 assume that the calling function pops off the stack space used to
2407 pass arguments.  This is
2408 useful to override the effects of the @option{-mrtd} switch.
2410 @item const
2411 @cindex @code{const} function attribute
2412 Many functions do not examine any values except their arguments, and
2413 have no effects except the return value.  Basically this is just slightly
2414 more strict class than the @code{pure} attribute below, since function is not
2415 allowed to read global memory.
2417 @cindex pointer arguments
2418 Note that a function that has pointer arguments and examines the data
2419 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2420 function that calls a non-@code{const} function usually must not be
2421 @code{const}.  It does not make sense for a @code{const} function to
2422 return @code{void}.
2424 The attribute @code{const} is not implemented in GCC versions earlier
2425 than 2.5.  An alternative way to declare that a function has no side
2426 effects, which works in the current version and in some older versions,
2427 is as follows:
2429 @smallexample
2430 typedef int intfn ();
2432 extern const intfn square;
2433 @end smallexample
2435 @noindent
2436 This approach does not work in GNU C++ from 2.6.0 on, since the language
2437 specifies that the @samp{const} must be attached to the return value.
2439 @item constructor
2440 @itemx destructor
2441 @itemx constructor (@var{priority})
2442 @itemx destructor (@var{priority})
2443 @cindex @code{constructor} function attribute
2444 @cindex @code{destructor} function attribute
2445 The @code{constructor} attribute causes the function to be called
2446 automatically before execution enters @code{main ()}.  Similarly, the
2447 @code{destructor} attribute causes the function to be called
2448 automatically after @code{main ()} completes or @code{exit ()} is
2449 called.  Functions with these attributes are useful for
2450 initializing data that is used implicitly during the execution of
2451 the program.
2453 You may provide an optional integer priority to control the order in
2454 which constructor and destructor functions are run.  A constructor
2455 with a smaller priority number runs before a constructor with a larger
2456 priority number; the opposite relationship holds for destructors.  So,
2457 if you have a constructor that allocates a resource and a destructor
2458 that deallocates the same resource, both functions typically have the
2459 same priority.  The priorities for constructor and destructor
2460 functions are the same as those specified for namespace-scope C++
2461 objects (@pxref{C++ Attributes}).
2463 These attributes are not currently implemented for Objective-C@.
2465 @item deprecated
2466 @itemx deprecated (@var{msg})
2467 @cindex @code{deprecated} attribute.
2468 The @code{deprecated} attribute results in a warning if the function
2469 is used anywhere in the source file.  This is useful when identifying
2470 functions that are expected to be removed in a future version of a
2471 program.  The warning also includes the location of the declaration
2472 of the deprecated function, to enable users to easily find further
2473 information about why the function is deprecated, or what they should
2474 do instead.  Note that the warnings only occurs for uses:
2476 @smallexample
2477 int old_fn () __attribute__ ((deprecated));
2478 int old_fn ();
2479 int (*fn_ptr)() = old_fn;
2480 @end smallexample
2482 @noindent
2483 results in a warning on line 3 but not line 2.  The optional @var{msg}
2484 argument, which must be a string, is printed in the warning if
2485 present.
2487 The @code{deprecated} attribute can also be used for variables and
2488 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2490 @item disinterrupt
2491 @cindex @code{disinterrupt} attribute
2492 On Epiphany and MeP targets, this attribute causes the compiler to emit
2493 instructions to disable interrupts for the duration of the given
2494 function.
2496 @item dllexport
2497 @cindex @code{__declspec(dllexport)}
2498 On Microsoft Windows targets and Symbian OS targets the
2499 @code{dllexport} attribute causes the compiler to provide a global
2500 pointer to a pointer in a DLL, so that it can be referenced with the
2501 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2502 name is formed by combining @code{_imp__} and the function or variable
2503 name.
2505 You can use @code{__declspec(dllexport)} as a synonym for
2506 @code{__attribute__ ((dllexport))} for compatibility with other
2507 compilers.
2509 On systems that support the @code{visibility} attribute, this
2510 attribute also implies ``default'' visibility.  It is an error to
2511 explicitly specify any other visibility.
2513 In previous versions of GCC, the @code{dllexport} attribute was ignored
2514 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2515 had been used.  The default behavior now is to emit all dllexported
2516 inline functions; however, this can cause object file-size bloat, in
2517 which case the old behavior can be restored by using
2518 @option{-fno-keep-inline-dllexport}.
2520 The attribute is also ignored for undefined symbols.
2522 When applied to C++ classes, the attribute marks defined non-inlined
2523 member functions and static data members as exports.  Static consts
2524 initialized in-class are not marked unless they are also defined
2525 out-of-class.
2527 For Microsoft Windows targets there are alternative methods for
2528 including the symbol in the DLL's export table such as using a
2529 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2530 the @option{--export-all} linker flag.
2532 @item dllimport
2533 @cindex @code{__declspec(dllimport)}
2534 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2535 attribute causes the compiler to reference a function or variable via
2536 a global pointer to a pointer that is set up by the DLL exporting the
2537 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2538 targets, the pointer name is formed by combining @code{_imp__} and the
2539 function or variable name.
2541 You can use @code{__declspec(dllimport)} as a synonym for
2542 @code{__attribute__ ((dllimport))} for compatibility with other
2543 compilers.
2545 On systems that support the @code{visibility} attribute, this
2546 attribute also implies ``default'' visibility.  It is an error to
2547 explicitly specify any other visibility.
2549 Currently, the attribute is ignored for inlined functions.  If the
2550 attribute is applied to a symbol @emph{definition}, an error is reported.
2551 If a symbol previously declared @code{dllimport} is later defined, the
2552 attribute is ignored in subsequent references, and a warning is emitted.
2553 The attribute is also overridden by a subsequent declaration as
2554 @code{dllexport}.
2556 When applied to C++ classes, the attribute marks non-inlined
2557 member functions and static data members as imports.  However, the
2558 attribute is ignored for virtual methods to allow creation of vtables
2559 using thunks.
2561 On the SH Symbian OS target the @code{dllimport} attribute also has
2562 another affect---it can cause the vtable and run-time type information
2563 for a class to be exported.  This happens when the class has a
2564 dllimported constructor or a non-inline, non-pure virtual function
2565 and, for either of those two conditions, the class also has an inline
2566 constructor or destructor and has a key function that is defined in
2567 the current translation unit.
2569 For Microsoft Windows targets the use of the @code{dllimport}
2570 attribute on functions is not necessary, but provides a small
2571 performance benefit by eliminating a thunk in the DLL@.  The use of the
2572 @code{dllimport} attribute on imported variables was required on older
2573 versions of the GNU linker, but can now be avoided by passing the
2574 @option{--enable-auto-import} switch to the GNU linker.  As with
2575 functions, using the attribute for a variable eliminates a thunk in
2576 the DLL@.
2578 One drawback to using this attribute is that a pointer to a
2579 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2580 address. However, a pointer to a @emph{function} with the
2581 @code{dllimport} attribute can be used as a constant initializer; in
2582 this case, the address of a stub function in the import lib is
2583 referenced.  On Microsoft Windows targets, the attribute can be disabled
2584 for functions by setting the @option{-mnop-fun-dllimport} flag.
2586 @item eightbit_data
2587 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2588 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2589 variable should be placed into the eight-bit data section.
2590 The compiler generates more efficient code for certain operations
2591 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2592 256 bytes of data.
2594 You must use GAS and GLD from GNU binutils version 2.7 or later for
2595 this attribute to work correctly.
2597 @item exception
2598 @cindex exception handler functions
2599 Use this attribute on the NDS32 target to indicate that the specified function
2600 is an exception handler.  The compiler will generate corresponding sections
2601 for use in an exception handler.
2603 @item exception_handler
2604 @cindex exception handler functions on the Blackfin processor
2605 Use this attribute on the Blackfin to indicate that the specified function
2606 is an exception handler.  The compiler generates function entry and
2607 exit sequences suitable for use in an exception handler when this
2608 attribute is present.
2610 @item externally_visible
2611 @cindex @code{externally_visible} attribute.
2612 This attribute, attached to a global variable or function, nullifies
2613 the effect of the @option{-fwhole-program} command-line option, so the
2614 object remains visible outside the current compilation unit.
2616 If @option{-fwhole-program} is used together with @option{-flto} and 
2617 @command{gold} is used as the linker plugin, 
2618 @code{externally_visible} attributes are automatically added to functions 
2619 (not variable yet due to a current @command{gold} issue) 
2620 that are accessed outside of LTO objects according to resolution file
2621 produced by @command{gold}.
2622 For other linkers that cannot generate resolution file,
2623 explicit @code{externally_visible} attributes are still necessary.
2625 @item far
2626 @cindex functions that handle memory bank switching
2627 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2628 use a calling convention that takes care of switching memory banks when
2629 entering and leaving a function.  This calling convention is also the
2630 default when using the @option{-mlong-calls} option.
2632 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2633 to call and return from a function.
2635 On 68HC11 the compiler generates a sequence of instructions
2636 to invoke a board-specific routine to switch the memory bank and call the
2637 real function.  The board-specific routine simulates a @code{call}.
2638 At the end of a function, it jumps to a board-specific routine
2639 instead of using @code{rts}.  The board-specific return routine simulates
2640 the @code{rtc}.
2642 On MeP targets this causes the compiler to use a calling convention
2643 that assumes the called function is too far away for the built-in
2644 addressing modes.
2646 @item fast_interrupt
2647 @cindex interrupt handler functions
2648 Use this attribute on the M32C and RX ports to indicate that the specified
2649 function is a fast interrupt handler.  This is just like the
2650 @code{interrupt} attribute, except that @code{freit} is used to return
2651 instead of @code{reit}.
2653 @item fastcall
2654 @cindex functions that pop the argument stack on the 386
2655 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2656 pass the first argument (if of integral type) in the register ECX and
2657 the second argument (if of integral type) in the register EDX@.  Subsequent
2658 and other typed arguments are passed on the stack.  The called function
2659 pops the arguments off the stack.  If the number of arguments is variable all
2660 arguments are pushed on the stack.
2662 @item thiscall
2663 @cindex functions that pop the argument stack on the 386
2664 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2665 pass the first argument (if of integral type) in the register ECX.
2666 Subsequent and other typed arguments are passed on the stack. The called
2667 function pops the arguments off the stack.
2668 If the number of arguments is variable all arguments are pushed on the
2669 stack.
2670 The @code{thiscall} attribute is intended for C++ non-static member functions.
2671 As a GCC extension, this calling convention can be used for C functions
2672 and for static member methods.
2674 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2675 @cindex @code{format} function attribute
2676 @opindex Wformat
2677 The @code{format} attribute specifies that a function takes @code{printf},
2678 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2679 should be type-checked against a format string.  For example, the
2680 declaration:
2682 @smallexample
2683 extern int
2684 my_printf (void *my_object, const char *my_format, ...)
2685       __attribute__ ((format (printf, 2, 3)));
2686 @end smallexample
2688 @noindent
2689 causes the compiler to check the arguments in calls to @code{my_printf}
2690 for consistency with the @code{printf} style format string argument
2691 @code{my_format}.
2693 The parameter @var{archetype} determines how the format string is
2694 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2695 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2696 @code{strfmon}.  (You can also use @code{__printf__},
2697 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2698 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2699 @code{ms_strftime} are also present.
2700 @var{archetype} values such as @code{printf} refer to the formats accepted
2701 by the system's C runtime library,
2702 while values prefixed with @samp{gnu_} always refer
2703 to the formats accepted by the GNU C Library.  On Microsoft Windows
2704 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2705 @file{msvcrt.dll} library.
2706 The parameter @var{string-index}
2707 specifies which argument is the format string argument (starting
2708 from 1), while @var{first-to-check} is the number of the first
2709 argument to check against the format string.  For functions
2710 where the arguments are not available to be checked (such as
2711 @code{vprintf}), specify the third parameter as zero.  In this case the
2712 compiler only checks the format string for consistency.  For
2713 @code{strftime} formats, the third parameter is required to be zero.
2714 Since non-static C++ methods have an implicit @code{this} argument, the
2715 arguments of such methods should be counted from two, not one, when
2716 giving values for @var{string-index} and @var{first-to-check}.
2718 In the example above, the format string (@code{my_format}) is the second
2719 argument of the function @code{my_print}, and the arguments to check
2720 start with the third argument, so the correct parameters for the format
2721 attribute are 2 and 3.
2723 @opindex ffreestanding
2724 @opindex fno-builtin
2725 The @code{format} attribute allows you to identify your own functions
2726 that take format strings as arguments, so that GCC can check the
2727 calls to these functions for errors.  The compiler always (unless
2728 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2729 for the standard library functions @code{printf}, @code{fprintf},
2730 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2731 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2732 warnings are requested (using @option{-Wformat}), so there is no need to
2733 modify the header file @file{stdio.h}.  In C99 mode, the functions
2734 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2735 @code{vsscanf} are also checked.  Except in strictly conforming C
2736 standard modes, the X/Open function @code{strfmon} is also checked as
2737 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2738 @xref{C Dialect Options,,Options Controlling C Dialect}.
2740 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2741 recognized in the same context.  Declarations including these format attributes
2742 are parsed for correct syntax, however the result of checking of such format
2743 strings is not yet defined, and is not carried out by this version of the
2744 compiler.
2746 The target may also provide additional types of format checks.
2747 @xref{Target Format Checks,,Format Checks Specific to Particular
2748 Target Machines}.
2750 @item format_arg (@var{string-index})
2751 @cindex @code{format_arg} function attribute
2752 @opindex Wformat-nonliteral
2753 The @code{format_arg} attribute specifies that a function takes a format
2754 string for a @code{printf}, @code{scanf}, @code{strftime} or
2755 @code{strfmon} style function and modifies it (for example, to translate
2756 it into another language), so the result can be passed to a
2757 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2758 function (with the remaining arguments to the format function the same
2759 as they would have been for the unmodified string).  For example, the
2760 declaration:
2762 @smallexample
2763 extern char *
2764 my_dgettext (char *my_domain, const char *my_format)
2765       __attribute__ ((format_arg (2)));
2766 @end smallexample
2768 @noindent
2769 causes the compiler to check the arguments in calls to a @code{printf},
2770 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2771 format string argument is a call to the @code{my_dgettext} function, for
2772 consistency with the format string argument @code{my_format}.  If the
2773 @code{format_arg} attribute had not been specified, all the compiler
2774 could tell in such calls to format functions would be that the format
2775 string argument is not constant; this would generate a warning when
2776 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2777 without the attribute.
2779 The parameter @var{string-index} specifies which argument is the format
2780 string argument (starting from one).  Since non-static C++ methods have
2781 an implicit @code{this} argument, the arguments of such methods should
2782 be counted from two.
2784 The @code{format_arg} attribute allows you to identify your own
2785 functions that modify format strings, so that GCC can check the
2786 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2787 type function whose operands are a call to one of your own function.
2788 The compiler always treats @code{gettext}, @code{dgettext}, and
2789 @code{dcgettext} in this manner except when strict ISO C support is
2790 requested by @option{-ansi} or an appropriate @option{-std} option, or
2791 @option{-ffreestanding} or @option{-fno-builtin}
2792 is used.  @xref{C Dialect Options,,Options
2793 Controlling C Dialect}.
2795 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2796 @code{NSString} reference for compatibility with the @code{format} attribute
2797 above.
2799 The target may also allow additional types in @code{format-arg} attributes.
2800 @xref{Target Format Checks,,Format Checks Specific to Particular
2801 Target Machines}.
2803 @item function_vector
2804 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2805 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2806 function should be called through the function vector.  Calling a
2807 function through the function vector reduces code size, however;
2808 the function vector has a limited size (maximum 128 entries on the H8/300
2809 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2811 On SH2A targets, this attribute declares a function to be called using the
2812 TBR relative addressing mode.  The argument to this attribute is the entry
2813 number of the same function in a vector table containing all the TBR
2814 relative addressable functions.  For correct operation the TBR must be setup
2815 accordingly to point to the start of the vector table before any functions with
2816 this attribute are invoked.  Usually a good place to do the initialization is
2817 the startup routine.  The TBR relative vector table can have at max 256 function
2818 entries.  The jumps to these functions are generated using a SH2A specific,
2819 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2820 from GNU binutils version 2.7 or later for this attribute to work correctly.
2822 Please refer the example of M16C target, to see the use of this
2823 attribute while declaring a function,
2825 In an application, for a function being called once, this attribute
2826 saves at least 8 bytes of code; and if other successive calls are being
2827 made to the same function, it saves 2 bytes of code per each of these
2828 calls.
2830 On M16C/M32C targets, the @code{function_vector} attribute declares a
2831 special page subroutine call function. Use of this attribute reduces
2832 the code size by 2 bytes for each call generated to the
2833 subroutine. The argument to the attribute is the vector number entry
2834 from the special page vector table which contains the 16 low-order
2835 bits of the subroutine's entry address. Each vector table has special
2836 page number (18 to 255) that is used in @code{jsrs} instructions.
2837 Jump addresses of the routines are generated by adding 0x0F0000 (in
2838 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2839 2-byte addresses set in the vector table. Therefore you need to ensure
2840 that all the special page vector routines should get mapped within the
2841 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2842 (for M32C).
2844 In the following example 2 bytes are saved for each call to
2845 function @code{foo}.
2847 @smallexample
2848 void foo (void) __attribute__((function_vector(0x18)));
2849 void foo (void)
2853 void bar (void)
2855     foo();
2857 @end smallexample
2859 If functions are defined in one file and are called in another file,
2860 then be sure to write this declaration in both files.
2862 This attribute is ignored for R8C target.
2864 @item ifunc ("@var{resolver}")
2865 @cindex @code{ifunc} attribute
2866 The @code{ifunc} attribute is used to mark a function as an indirect
2867 function using the STT_GNU_IFUNC symbol type extension to the ELF
2868 standard.  This allows the resolution of the symbol value to be
2869 determined dynamically at load time, and an optimized version of the
2870 routine can be selected for the particular processor or other system
2871 characteristics determined then.  To use this attribute, first define
2872 the implementation functions available, and a resolver function that
2873 returns a pointer to the selected implementation function.  The
2874 implementation functions' declarations must match the API of the
2875 function being implemented, the resolver's declaration is be a
2876 function returning pointer to void function returning void:
2878 @smallexample
2879 void *my_memcpy (void *dst, const void *src, size_t len)
2881   @dots{}
2884 static void (*resolve_memcpy (void)) (void)
2886   return my_memcpy; // we'll just always select this routine
2888 @end smallexample
2890 @noindent
2891 The exported header file declaring the function the user calls would
2892 contain:
2894 @smallexample
2895 extern void *memcpy (void *, const void *, size_t);
2896 @end smallexample
2898 @noindent
2899 allowing the user to call this as a regular function, unaware of the
2900 implementation.  Finally, the indirect function needs to be defined in
2901 the same translation unit as the resolver function:
2903 @smallexample
2904 void *memcpy (void *, const void *, size_t)
2905      __attribute__ ((ifunc ("resolve_memcpy")));
2906 @end smallexample
2908 Indirect functions cannot be weak, and require a recent binutils (at
2909 least version 2.20.1), and GNU C library (at least version 2.11.1).
2911 @item interrupt
2912 @cindex interrupt handler functions
2913 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2914 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2915 the specified function is an
2916 interrupt handler.  The compiler generates function entry and exit
2917 sequences suitable for use in an interrupt handler when this attribute
2918 is present.  With Epiphany targets it may also generate a special section with
2919 code to initialize the interrupt vector table.
2921 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2922 and SH processors can be specified via the @code{interrupt_handler} attribute.
2924 Note, on the ARC, you must specify the kind of interrupt to be handled
2925 in a parameter to the interrupt attribute like this:
2927 @smallexample
2928 void f () __attribute__ ((interrupt ("ilink1")));
2929 @end smallexample
2931 Permissible values for this parameter are: @w{@code{ilink1}} and
2932 @w{@code{ilink2}}.
2934 Note, on the AVR, the hardware globally disables interrupts when an
2935 interrupt is executed.  The first instruction of an interrupt handler
2936 declared with this attribute is a @code{SEI} instruction to
2937 re-enable interrupts.  See also the @code{signal} function attribute
2938 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2939 @code{interrupt} are specified for the same function, @code{signal}
2940 is silently ignored.
2942 Note, for the ARM, you can specify the kind of interrupt to be handled by
2943 adding an optional parameter to the interrupt attribute like this:
2945 @smallexample
2946 void f () __attribute__ ((interrupt ("IRQ")));
2947 @end smallexample
2949 @noindent
2950 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2951 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2953 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2954 may be called with a word-aligned stack pointer.
2956 Note, for the MSP430 you can provide an argument to the interrupt
2957 attribute which specifies a name or number.  If the argument is a
2958 number it indicates the slot in the interrupt vector table (0 - 31) to
2959 which this handler should be assigned.  If the argument is a name it
2960 is treated as a symbolic name for the vector slot.  These names should
2961 match up with appropriate entries in the linker script.  By default
2962 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2963 @code{reset} for vector 31 are recognised.
2965 You can also use the following function attributes to modify how
2966 normal functions interact with interrupt functions:
2968 @table @code
2969 @item critical
2970 @cindex @code{critical} attribute
2971 Critical functions disable interrupts upon entry and restore the
2972 previous interrupt state upon exit.  Critical functions cannot also
2973 have the @code{naked} or @code{reentrant} attributes.  They can have
2974 the @code{interrupt} attribute.
2976 @item reentrant
2977 @cindex @code{reentrant} attribute
2978 Reentrant functions disable interrupts upon entry and enable them
2979 upon exit.  Reentrant functions cannot also have the @code{naked}
2980 or @code{critical} attributes.  They can have the @code{interrupt}
2981 attribute.
2983 @item wakeup
2984 @cindex @code{wakeup} attribute
2985 This attribute only applies to interrupt functions.  It is silently
2986 ignored if applied to a non-interrupt function.  A wakeup interrupt
2987 function will rouse the processor from any low-power state that it
2988 might be in when the function exits.
2990 @end table
2992 On Epiphany targets one or more optional parameters can be added like this:
2994 @smallexample
2995 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2996 @end smallexample
2998 Permissible values for these parameters are: @w{@code{reset}},
2999 @w{@code{software_exception}}, @w{@code{page_miss}},
3000 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3001 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3002 Multiple parameters indicate that multiple entries in the interrupt
3003 vector table should be initialized for this function, i.e.@: for each
3004 parameter @w{@var{name}}, a jump to the function is emitted in
3005 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3006 entirely, in which case no interrupt vector table entry is provided.
3008 Note, on Epiphany targets, interrupts are enabled inside the function
3009 unless the @code{disinterrupt} attribute is also specified.
3011 On Epiphany targets, you can also use the following attribute to
3012 modify the behavior of an interrupt handler:
3013 @table @code
3014 @item forwarder_section
3015 @cindex @code{forwarder_section} attribute
3016 The interrupt handler may be in external memory which cannot be
3017 reached by a branch instruction, so generate a local memory trampoline
3018 to transfer control.  The single parameter identifies the section where
3019 the trampoline is placed.
3020 @end table
3022 The following examples are all valid uses of these attributes on
3023 Epiphany targets:
3024 @smallexample
3025 void __attribute__ ((interrupt)) universal_handler ();
3026 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3027 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3028 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3029   fast_timer_handler ();
3030 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3031   external_dma_handler ();
3032 @end smallexample
3034 On MIPS targets, you can use the following attributes to modify the behavior
3035 of an interrupt handler:
3036 @table @code
3037 @item use_shadow_register_set
3038 @cindex @code{use_shadow_register_set} attribute
3039 Assume that the handler uses a shadow register set, instead of
3040 the main general-purpose registers.
3042 @item keep_interrupts_masked
3043 @cindex @code{keep_interrupts_masked} attribute
3044 Keep interrupts masked for the whole function.  Without this attribute,
3045 GCC tries to reenable interrupts for as much of the function as it can.
3047 @item use_debug_exception_return
3048 @cindex @code{use_debug_exception_return} attribute
3049 Return using the @code{deret} instruction.  Interrupt handlers that don't
3050 have this attribute return using @code{eret} instead.
3051 @end table
3053 You can use any combination of these attributes, as shown below:
3054 @smallexample
3055 void __attribute__ ((interrupt)) v0 ();
3056 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3057 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3058 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3059 void __attribute__ ((interrupt, use_shadow_register_set,
3060                      keep_interrupts_masked)) v4 ();
3061 void __attribute__ ((interrupt, use_shadow_register_set,
3062                      use_debug_exception_return)) v5 ();
3063 void __attribute__ ((interrupt, keep_interrupts_masked,
3064                      use_debug_exception_return)) v6 ();
3065 void __attribute__ ((interrupt, use_shadow_register_set,
3066                      keep_interrupts_masked,
3067                      use_debug_exception_return)) v7 ();
3068 @end smallexample
3070 On NDS32 target, this attribute is to indicate that the specified function
3071 is an interrupt handler.  The compiler will generate corresponding sections
3072 for use in an interrupt handler.  You can use the following attributes
3073 to modify the behavior:
3074 @table @code
3075 @item nested
3076 @cindex @code{nested} attribute
3077 This interrupt service routine is interruptible.
3078 @item not_nested
3079 @cindex @code{not_nested} attribute
3080 This interrupt service routine is not interruptible.
3081 @item nested_ready
3082 @cindex @code{nested_ready} attribute
3083 This interrupt service routine is interruptible after @code{PSW.GIE}
3084 (global interrupt enable) is set.  This allows interrupt service routine to
3085 finish some short critical code before enabling interrupts.
3086 @item save_all
3087 @cindex @code{save_all} attribute
3088 The system will help save all registers into stack before entering
3089 interrupt handler.
3090 @item partial_save
3091 @cindex @code{partial_save} attribute
3092 The system will help save caller registers into stack before entering
3093 interrupt handler.
3094 @end table
3096 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3097 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3098 that must end with @code{RETB} instead of @code{RETI}).
3100 On RX targets, you may specify one or more vector numbers as arguments
3101 to the attribute, as well as naming an alternate table name.
3102 Parameters are handled sequentially, so one handler can be assigned to
3103 multiple entries in multiple tables.  One may also pass the magic
3104 string @code{"$default"} which causes the function to be used for any
3105 unfilled slots in the current table.
3107 This example shows a simple assignment of a function to one vector in
3108 the default table (note that preprocessor macros may be used for
3109 chip-specific symbolic vector names):
3110 @smallexample
3111 void __attribute__ ((interrupt (5))) txd1_handler ();
3112 @end smallexample
3114 This example assigns a function to two slots in the default table
3115 (using preprocessor macros defined elsewhere) and makes it the default
3116 for the @code{dct} table:
3117 @smallexample
3118 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3119         txd1_handler ();
3120 @end smallexample
3122 @item interrupt_handler
3123 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3124 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3125 indicate that the specified function is an interrupt handler.  The compiler
3126 generates function entry and exit sequences suitable for use in an
3127 interrupt handler when this attribute is present.
3129 @item interrupt_thread
3130 @cindex interrupt thread functions on fido
3131 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3132 that the specified function is an interrupt handler that is designed
3133 to run as a thread.  The compiler omits generate prologue/epilogue
3134 sequences and replaces the return instruction with a @code{sleep}
3135 instruction.  This attribute is available only on fido.
3137 @item isr
3138 @cindex interrupt service routines on ARM
3139 Use this attribute on ARM to write Interrupt Service Routines. This is an
3140 alias to the @code{interrupt} attribute above.
3142 @item kspisusp
3143 @cindex User stack pointer in interrupts on the Blackfin
3144 When used together with @code{interrupt_handler}, @code{exception_handler}
3145 or @code{nmi_handler}, code is generated to load the stack pointer
3146 from the USP register in the function prologue.
3148 @item l1_text
3149 @cindex @code{l1_text} function attribute
3150 This attribute specifies a function to be placed into L1 Instruction
3151 SRAM@. The function is put into a specific section named @code{.l1.text}.
3152 With @option{-mfdpic}, function calls with a such function as the callee
3153 or caller uses inlined PLT.
3155 @item l2
3156 @cindex @code{l2} function attribute
3157 On the Blackfin, this attribute specifies a function to be placed into L2
3158 SRAM. The function is put into a specific section named
3159 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3160 an inlined PLT.
3162 @item leaf
3163 @cindex @code{leaf} function attribute
3164 Calls to external functions with this attribute must return to the current
3165 compilation unit only by return or by exception handling.  In particular, leaf
3166 functions are not allowed to call callback function passed to it from the current
3167 compilation unit or directly call functions exported by the unit or longjmp
3168 into the unit.  Leaf function might still call functions from other compilation
3169 units and thus they are not necessarily leaf in the sense that they contain no
3170 function calls at all.
3172 The attribute is intended for library functions to improve dataflow analysis.
3173 The compiler takes the hint that any data not escaping the current compilation unit can
3174 not be used or modified by the leaf function.  For example, the @code{sin} function
3175 is a leaf function, but @code{qsort} is not.
3177 Note that leaf functions might invoke signals and signal handlers might be
3178 defined in the current compilation unit and use static variables.  The only
3179 compliant way to write such a signal handler is to declare such variables
3180 @code{volatile}.
3182 The attribute has no effect on functions defined within the current compilation
3183 unit.  This is to allow easy merging of multiple compilation units into one,
3184 for example, by using the link-time optimization.  For this reason the
3185 attribute is not allowed on types to annotate indirect calls.
3187 @item long_call/medium_call/short_call
3188 @cindex indirect calls on ARC
3189 @cindex indirect calls on ARM
3190 @cindex indirect calls on Epiphany
3191 These attributes specify how a particular function is called on
3192 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3193 These attributes override the
3194 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3195 and @option{-mmedium-calls} (@pxref{ARC Options})
3196 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3197 @code{long_call} attribute indicates that the function might be far
3198 away from the call site and require a different (more expensive)
3199 calling sequence.   The @code{short_call} attribute always places
3200 the offset to the function from the call site into the @samp{BL}
3201 instruction directly.
3203 For ARC, a function marked with the @code{long_call} attribute is
3204 always called using register-indirect jump-and-link instructions,
3205 thereby enabling the called function to be placed anywhere within the
3206 32-bit address space.  A function marked with the @code{medium_call}
3207 attribute will always be close enough to be called with an unconditional
3208 branch-and-link instruction, which has a 25-bit offset from
3209 the call site.  A function marked with the @code{short_call}
3210 attribute will always be close enough to be called with a conditional
3211 branch-and-link instruction, which has a 21-bit offset from
3212 the call site.
3214 @item longcall/shortcall
3215 @cindex functions called via pointer on the RS/6000 and PowerPC
3216 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3217 indicates that the function might be far away from the call site and
3218 require a different (more expensive) calling sequence.  The
3219 @code{shortcall} attribute indicates that the function is always close
3220 enough for the shorter calling sequence to be used.  These attributes
3221 override both the @option{-mlongcall} switch and, on the RS/6000 and
3222 PowerPC, the @code{#pragma longcall} setting.
3224 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3225 calls are necessary.
3227 @item long_call/near/far
3228 @cindex indirect calls on MIPS
3229 These attributes specify how a particular function is called on MIPS@.
3230 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3231 command-line switch.  The @code{long_call} and @code{far} attributes are
3232 synonyms, and cause the compiler to always call
3233 the function by first loading its address into a register, and then using
3234 the contents of that register.  The @code{near} attribute has the opposite
3235 effect; it specifies that non-PIC calls should be made using the more
3236 efficient @code{jal} instruction.
3238 @item malloc
3239 @cindex @code{malloc} attribute
3240 This tells the compiler that a function is @code{malloc}-like, i.e.,
3241 that the pointer @var{P} returned by the function cannot alias any
3242 other pointer valid when the function returns, and moreover no
3243 pointers to valid objects occur in any storage addressed by @var{P}.
3245 Using this attribute can improve optimization.  Functions like
3246 @code{malloc} and @code{calloc} have this property because they return
3247 a pointer to uninitialized or zeroed-out storage.  However, functions
3248 like @code{realloc} do not have this property, as they can return a
3249 pointer to storage containing pointers.
3251 @item mips16/nomips16
3252 @cindex @code{mips16} attribute
3253 @cindex @code{nomips16} attribute
3255 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3256 function attributes to locally select or turn off MIPS16 code generation.
3257 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3258 while MIPS16 code generation is disabled for functions with the
3259 @code{nomips16} attribute.  These attributes override the
3260 @option{-mips16} and @option{-mno-mips16} options on the command line
3261 (@pxref{MIPS Options}).
3263 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3264 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3265 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3266 may interact badly with some GCC extensions such as @code{__builtin_apply}
3267 (@pxref{Constructing Calls}).
3269 @item micromips/nomicromips
3270 @cindex @code{micromips} attribute
3271 @cindex @code{nomicromips} attribute
3273 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3274 function attributes to locally select or turn off microMIPS code generation.
3275 A function with the @code{micromips} attribute is emitted as microMIPS code,
3276 while microMIPS code generation is disabled for functions with the
3277 @code{nomicromips} attribute.  These attributes override the
3278 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3279 (@pxref{MIPS Options}).
3281 When compiling files containing mixed microMIPS and non-microMIPS code, the
3282 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3283 command line,
3284 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3285 may interact badly with some GCC extensions such as @code{__builtin_apply}
3286 (@pxref{Constructing Calls}).
3288 @item model (@var{model-name})
3289 @cindex function addressability on the M32R/D
3290 @cindex variable addressability on the IA-64
3292 On the M32R/D, use this attribute to set the addressability of an
3293 object, and of the code generated for a function.  The identifier
3294 @var{model-name} is one of @code{small}, @code{medium}, or
3295 @code{large}, representing each of the code models.
3297 Small model objects live in the lower 16MB of memory (so that their
3298 addresses can be loaded with the @code{ld24} instruction), and are
3299 callable with the @code{bl} instruction.
3301 Medium model objects may live anywhere in the 32-bit address space (the
3302 compiler generates @code{seth/add3} instructions to load their addresses),
3303 and are callable with the @code{bl} instruction.
3305 Large model objects may live anywhere in the 32-bit address space (the
3306 compiler generates @code{seth/add3} instructions to load their addresses),
3307 and may not be reachable with the @code{bl} instruction (the compiler
3308 generates the much slower @code{seth/add3/jl} instruction sequence).
3310 On IA-64, use this attribute to set the addressability of an object.
3311 At present, the only supported identifier for @var{model-name} is
3312 @code{small}, indicating addressability via ``small'' (22-bit)
3313 addresses (so that their addresses can be loaded with the @code{addl}
3314 instruction).  Caveat: such addressing is by definition not position
3315 independent and hence this attribute must not be used for objects
3316 defined by shared libraries.
3318 @item ms_abi/sysv_abi
3319 @cindex @code{ms_abi} attribute
3320 @cindex @code{sysv_abi} attribute
3322 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3323 to indicate which calling convention should be used for a function.  The
3324 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3325 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3326 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3327 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3329 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3330 requires the @option{-maccumulate-outgoing-args} option.
3332 @item callee_pop_aggregate_return (@var{number})
3333 @cindex @code{callee_pop_aggregate_return} attribute
3335 On 32-bit i?86-*-* targets, you can use this attribute to control how
3336 aggregates are returned in memory.  If the caller is responsible for
3337 popping the hidden pointer together with the rest of the arguments, specify
3338 @var{number} equal to zero.  If callee is responsible for popping the
3339 hidden pointer, specify @var{number} equal to one.  
3341 The default i386 ABI assumes that the callee pops the
3342 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3343 the compiler assumes that the
3344 caller pops the stack for hidden pointer.
3346 @item ms_hook_prologue
3347 @cindex @code{ms_hook_prologue} attribute
3349 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3350 this function attribute to make GCC generate the ``hot-patching'' function
3351 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3352 and newer.
3354 @item hotpatch [(@var{prologue-halfwords})]
3355 @cindex @code{hotpatch} attribute
3357 On S/390 System z targets, you can use this function attribute to
3358 make GCC generate a ``hot-patching'' function prologue.  The
3359 @code{hotpatch} has no effect on funtions that are explicitly
3360 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3361 command-line option is used at the same time, the @code{hotpatch}
3362 attribute takes precedence.  If an argument is given, the maximum
3363 allowed value is 1000000.
3365 @item naked
3366 @cindex function without a prologue/epilogue code
3367 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3368 RL78, RX and SPU ports.  It allows the compiler to construct the
3369 requisite function declaration, while allowing the body of the
3370 function to be assembly code. The specified function will not have
3371 prologue/epilogue sequences generated by the compiler. Only Basic
3372 @code{asm} statements can safely be included in naked functions
3373 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3374 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3375 depended upon to work reliably and are not supported.
3377 @item near
3378 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3379 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3380 use the normal calling convention based on @code{jsr} and @code{rts}.
3381 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3382 option.
3384 On MeP targets this attribute causes the compiler to assume the called
3385 function is close enough to use the normal calling convention,
3386 overriding the @option{-mtf} command-line option.
3388 @item nesting
3389 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3390 Use this attribute together with @code{interrupt_handler},
3391 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3392 entry code should enable nested interrupts or exceptions.
3394 @item nmi_handler
3395 @cindex NMI handler functions on the Blackfin processor
3396 Use this attribute on the Blackfin to indicate that the specified function
3397 is an NMI handler.  The compiler generates function entry and
3398 exit sequences suitable for use in an NMI handler when this
3399 attribute is present.
3401 @item nocompression
3402 @cindex @code{nocompression} attribute
3403 On MIPS targets, you can use the @code{nocompression} function attribute
3404 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3405 overrides the @option{-mips16} and @option{-mmicromips} options on the
3406 command line (@pxref{MIPS Options}).
3408 @item no_instrument_function
3409 @cindex @code{no_instrument_function} function attribute
3410 @opindex finstrument-functions
3411 If @option{-finstrument-functions} is given, profiling function calls are
3412 generated at entry and exit of most user-compiled functions.
3413 Functions with this attribute are not so instrumented.
3415 @item no_split_stack
3416 @cindex @code{no_split_stack} function attribute
3417 @opindex fsplit-stack
3418 If @option{-fsplit-stack} is given, functions have a small
3419 prologue which decides whether to split the stack.  Functions with the
3420 @code{no_split_stack} attribute do not have that prologue, and thus
3421 may run with only a small amount of stack space available.
3423 @item noinline
3424 @cindex @code{noinline} function attribute
3425 This function attribute prevents a function from being considered for
3426 inlining.
3427 @c Don't enumerate the optimizations by name here; we try to be
3428 @c future-compatible with this mechanism.
3429 If the function does not have side-effects, there are optimizations
3430 other than inlining that cause function calls to be optimized away,
3431 although the function call is live.  To keep such calls from being
3432 optimized away, put
3433 @smallexample
3434 asm ("");
3435 @end smallexample
3437 @noindent
3438 (@pxref{Extended Asm}) in the called function, to serve as a special
3439 side-effect.
3441 @item noclone
3442 @cindex @code{noclone} function attribute
3443 This function attribute prevents a function from being considered for
3444 cloning---a mechanism that produces specialized copies of functions
3445 and which is (currently) performed by interprocedural constant
3446 propagation.
3448 @item nonnull (@var{arg-index}, @dots{})
3449 @cindex @code{nonnull} function attribute
3450 The @code{nonnull} attribute specifies that some function parameters should
3451 be non-null pointers.  For instance, the declaration:
3453 @smallexample
3454 extern void *
3455 my_memcpy (void *dest, const void *src, size_t len)
3456         __attribute__((nonnull (1, 2)));
3457 @end smallexample
3459 @noindent
3460 causes the compiler to check that, in calls to @code{my_memcpy},
3461 arguments @var{dest} and @var{src} are non-null.  If the compiler
3462 determines that a null pointer is passed in an argument slot marked
3463 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3464 is issued.  The compiler may also choose to make optimizations based
3465 on the knowledge that certain function arguments will never be null.
3467 If no argument index list is given to the @code{nonnull} attribute,
3468 all pointer arguments are marked as non-null.  To illustrate, the
3469 following declaration is equivalent to the previous example:
3471 @smallexample
3472 extern void *
3473 my_memcpy (void *dest, const void *src, size_t len)
3474         __attribute__((nonnull));
3475 @end smallexample
3477 @item no_reorder
3478 @cindex @code{no_reorder} function or variable attribute
3479 Do not reorder functions or variables marked @code{no_reorder}
3480 against each other or top level assembler statements the executable.
3481 The actual order in the program will depend on the linker command
3482 line. Static variables marked like this are also not removed.
3483 This has a similar effect
3484 as the @option{-fno-toplevel-reorder} option, but only applies to the
3485 marked symbols.
3487 @item returns_nonnull
3488 @cindex @code{returns_nonnull} function attribute
3489 The @code{returns_nonnull} attribute specifies that the function
3490 return value should be a non-null pointer.  For instance, the declaration:
3492 @smallexample
3493 extern void *
3494 mymalloc (size_t len) __attribute__((returns_nonnull));
3495 @end smallexample
3497 @noindent
3498 lets the compiler optimize callers based on the knowledge
3499 that the return value will never be null.
3501 @item noreturn
3502 @cindex @code{noreturn} function attribute
3503 A few standard library functions, such as @code{abort} and @code{exit},
3504 cannot return.  GCC knows this automatically.  Some programs define
3505 their own functions that never return.  You can declare them
3506 @code{noreturn} to tell the compiler this fact.  For example,
3508 @smallexample
3509 @group
3510 void fatal () __attribute__ ((noreturn));
3512 void
3513 fatal (/* @r{@dots{}} */)
3515   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3516   exit (1);
3518 @end group
3519 @end smallexample
3521 The @code{noreturn} keyword tells the compiler to assume that
3522 @code{fatal} cannot return.  It can then optimize without regard to what
3523 would happen if @code{fatal} ever did return.  This makes slightly
3524 better code.  More importantly, it helps avoid spurious warnings of
3525 uninitialized variables.
3527 The @code{noreturn} keyword does not affect the exceptional path when that
3528 applies: a @code{noreturn}-marked function may still return to the caller
3529 by throwing an exception or calling @code{longjmp}.
3531 Do not assume that registers saved by the calling function are
3532 restored before calling the @code{noreturn} function.
3534 It does not make sense for a @code{noreturn} function to have a return
3535 type other than @code{void}.
3537 The attribute @code{noreturn} is not implemented in GCC versions
3538 earlier than 2.5.  An alternative way to declare that a function does
3539 not return, which works in the current version and in some older
3540 versions, is as follows:
3542 @smallexample
3543 typedef void voidfn ();
3545 volatile voidfn fatal;
3546 @end smallexample
3548 @noindent
3549 This approach does not work in GNU C++.
3551 @item nothrow
3552 @cindex @code{nothrow} function attribute
3553 The @code{nothrow} attribute is used to inform the compiler that a
3554 function cannot throw an exception.  For example, most functions in
3555 the standard C library can be guaranteed not to throw an exception
3556 with the notable exceptions of @code{qsort} and @code{bsearch} that
3557 take function pointer arguments.  The @code{nothrow} attribute is not
3558 implemented in GCC versions earlier than 3.3.
3560 @item nosave_low_regs
3561 @cindex @code{nosave_low_regs} attribute
3562 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3563 function should not save and restore registers R0..R7.  This can be used on SH3*
3564 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3565 interrupt handlers.
3567 @item optimize
3568 @cindex @code{optimize} function attribute
3569 The @code{optimize} attribute is used to specify that a function is to
3570 be compiled with different optimization options than specified on the
3571 command line.  Arguments can either be numbers or strings.  Numbers
3572 are assumed to be an optimization level.  Strings that begin with
3573 @code{O} are assumed to be an optimization option, while other options
3574 are assumed to be used with a @code{-f} prefix.  You can also use the
3575 @samp{#pragma GCC optimize} pragma to set the optimization options
3576 that affect more than one function.
3577 @xref{Function Specific Option Pragmas}, for details about the
3578 @samp{#pragma GCC optimize} pragma.
3580 This can be used for instance to have frequently-executed functions
3581 compiled with more aggressive optimization options that produce faster
3582 and larger code, while other functions can be compiled with less
3583 aggressive options.
3585 @item OS_main/OS_task
3586 @cindex @code{OS_main} AVR function attribute
3587 @cindex @code{OS_task} AVR function attribute
3588 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3589 do not save/restore any call-saved register in their prologue/epilogue.
3591 The @code{OS_main} attribute can be used when there @emph{is
3592 guarantee} that interrupts are disabled at the time when the function
3593 is entered.  This saves resources when the stack pointer has to be
3594 changed to set up a frame for local variables.
3596 The @code{OS_task} attribute can be used when there is @emph{no
3597 guarantee} that interrupts are disabled at that time when the function
3598 is entered like for, e@.g@. task functions in a multi-threading operating
3599 system. In that case, changing the stack pointer register is
3600 guarded by save/clear/restore of the global interrupt enable flag.
3602 The differences to the @code{naked} function attribute are:
3603 @itemize @bullet
3604 @item @code{naked} functions do not have a return instruction whereas 
3605 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3606 @code{RETI} return instruction.
3607 @item @code{naked} functions do not set up a frame for local variables
3608 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3609 as needed.
3610 @end itemize
3612 @item pcs
3613 @cindex @code{pcs} function attribute
3615 The @code{pcs} attribute can be used to control the calling convention
3616 used for a function on ARM.  The attribute takes an argument that specifies
3617 the calling convention to use.
3619 When compiling using the AAPCS ABI (or a variant of it) then valid
3620 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3621 order to use a variant other than @code{"aapcs"} then the compiler must
3622 be permitted to use the appropriate co-processor registers (i.e., the
3623 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3624 For example,
3626 @smallexample
3627 /* Argument passed in r0, and result returned in r0+r1.  */
3628 double f2d (float) __attribute__((pcs("aapcs")));
3629 @end smallexample
3631 Variadic functions always use the @code{"aapcs"} calling convention and
3632 the compiler rejects attempts to specify an alternative.
3634 @item pure
3635 @cindex @code{pure} function attribute
3636 Many functions have no effects except the return value and their
3637 return value depends only on the parameters and/or global variables.
3638 Such a function can be subject
3639 to common subexpression elimination and loop optimization just as an
3640 arithmetic operator would be.  These functions should be declared
3641 with the attribute @code{pure}.  For example,
3643 @smallexample
3644 int square (int) __attribute__ ((pure));
3645 @end smallexample
3647 @noindent
3648 says that the hypothetical function @code{square} is safe to call
3649 fewer times than the program says.
3651 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3652 Interesting non-pure functions are functions with infinite loops or those
3653 depending on volatile memory or other system resource, that may change between
3654 two consecutive calls (such as @code{feof} in a multithreading environment).
3656 The attribute @code{pure} is not implemented in GCC versions earlier
3657 than 2.96.
3659 @item hot
3660 @cindex @code{hot} function attribute
3661 The @code{hot} attribute on a function is used to inform the compiler that
3662 the function is a hot spot of the compiled program.  The function is
3663 optimized more aggressively and on many targets it is placed into a special
3664 subsection of the text section so all hot functions appear close together,
3665 improving locality.
3667 When profile feedback is available, via @option{-fprofile-use}, hot functions
3668 are automatically detected and this attribute is ignored.
3670 The @code{hot} attribute on functions is not implemented in GCC versions
3671 earlier than 4.3.
3673 @item cold
3674 @cindex @code{cold} function attribute
3675 The @code{cold} attribute on functions is used to inform the compiler that
3676 the function is unlikely to be executed.  The function is optimized for
3677 size rather than speed and on many targets it is placed into a special
3678 subsection of the text section so all cold functions appear close together,
3679 improving code locality of non-cold parts of program.  The paths leading
3680 to calls of cold functions within code are marked as unlikely by the branch
3681 prediction mechanism.  It is thus useful to mark functions used to handle
3682 unlikely conditions, such as @code{perror}, as cold to improve optimization
3683 of hot functions that do call marked functions in rare occasions.
3685 When profile feedback is available, via @option{-fprofile-use}, cold functions
3686 are automatically detected and this attribute is ignored.
3688 The @code{cold} attribute on functions is not implemented in GCC versions
3689 earlier than 4.3.
3691 @item no_sanitize_address
3692 @itemx no_address_safety_analysis
3693 @cindex @code{no_sanitize_address} function attribute
3694 The @code{no_sanitize_address} attribute on functions is used
3695 to inform the compiler that it should not instrument memory accesses
3696 in the function when compiling with the @option{-fsanitize=address} option.
3697 The @code{no_address_safety_analysis} is a deprecated alias of the
3698 @code{no_sanitize_address} attribute, new code should use
3699 @code{no_sanitize_address}.
3701 @item no_sanitize_undefined
3702 @cindex @code{no_sanitize_undefined} function attribute
3703 The @code{no_sanitize_undefined} attribute on functions is used
3704 to inform the compiler that it should not check for undefined behavior
3705 in the function when compiling with the @option{-fsanitize=undefined} option.
3707 @item bnd_legacy
3708 @cindex @code{bnd_legacy} function attribute
3709 The @code{bnd_legacy} attribute on functions is used to inform
3710 compiler that function should not be instrumented when compiled
3711 with @option{-fcheck-pointer-bounds} option.
3713 @item bnd_instrument
3714 @cindex @code{bnd_instrument} function attribute
3715 The @code{bnd_instrument} attribute on functions is used to inform
3716 compiler that function should be instrumented when compiled
3717 with @option{-fchkp-instrument-marked-only} option.
3719 @item regparm (@var{number})
3720 @cindex @code{regparm} attribute
3721 @cindex functions that are passed arguments in registers on the 386
3722 On the Intel 386, the @code{regparm} attribute causes the compiler to
3723 pass arguments number one to @var{number} if they are of integral type
3724 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3725 take a variable number of arguments continue to be passed all of their
3726 arguments on the stack.
3728 Beware that on some ELF systems this attribute is unsuitable for
3729 global functions in shared libraries with lazy binding (which is the
3730 default).  Lazy binding sends the first call via resolving code in
3731 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3732 per the standard calling conventions.  Solaris 8 is affected by this.
3733 Systems with the GNU C Library version 2.1 or higher
3734 and FreeBSD are believed to be
3735 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3736 disabled with the linker or the loader if desired, to avoid the
3737 problem.)
3739 @item reset
3740 @cindex reset handler functions
3741 Use this attribute on the NDS32 target to indicate that the specified function
3742 is a reset handler.  The compiler will generate corresponding sections
3743 for use in a reset handler.  You can use the following attributes
3744 to provide extra exception handling:
3745 @table @code
3746 @item nmi
3747 @cindex @code{nmi} attribute
3748 Provide a user-defined function to handle NMI exception.
3749 @item warm
3750 @cindex @code{warm} attribute
3751 Provide a user-defined function to handle warm reset exception.
3752 @end table
3754 @item sseregparm
3755 @cindex @code{sseregparm} attribute
3756 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3757 causes the compiler to pass up to 3 floating-point arguments in
3758 SSE registers instead of on the stack.  Functions that take a
3759 variable number of arguments continue to pass all of their
3760 floating-point arguments on the stack.
3762 @item force_align_arg_pointer
3763 @cindex @code{force_align_arg_pointer} attribute
3764 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3765 applied to individual function definitions, generating an alternate
3766 prologue and epilogue that realigns the run-time stack if necessary.
3767 This supports mixing legacy codes that run with a 4-byte aligned stack
3768 with modern codes that keep a 16-byte stack for SSE compatibility.
3770 @item renesas
3771 @cindex @code{renesas} attribute
3772 On SH targets this attribute specifies that the function or struct follows the
3773 Renesas ABI.
3775 @item resbank
3776 @cindex @code{resbank} attribute
3777 On the SH2A target, this attribute enables the high-speed register
3778 saving and restoration using a register bank for @code{interrupt_handler}
3779 routines.  Saving to the bank is performed automatically after the CPU
3780 accepts an interrupt that uses a register bank.
3782 The nineteen 32-bit registers comprising general register R0 to R14,
3783 control register GBR, and system registers MACH, MACL, and PR and the
3784 vector table address offset are saved into a register bank.  Register
3785 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3786 from the bank is executed by issuing a RESBANK instruction.
3788 @item returns_twice
3789 @cindex @code{returns_twice} attribute
3790 The @code{returns_twice} attribute tells the compiler that a function may
3791 return more than one time.  The compiler ensures that all registers
3792 are dead before calling such a function and emits a warning about
3793 the variables that may be clobbered after the second return from the
3794 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3795 The @code{longjmp}-like counterpart of such function, if any, might need
3796 to be marked with the @code{noreturn} attribute.
3798 @item saveall
3799 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3800 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3801 all registers except the stack pointer should be saved in the prologue
3802 regardless of whether they are used or not.
3804 @item save_volatiles
3805 @cindex save volatile registers on the MicroBlaze
3806 Use this attribute on the MicroBlaze to indicate that the function is
3807 an interrupt handler.  All volatile registers (in addition to non-volatile
3808 registers) are saved in the function prologue.  If the function is a leaf
3809 function, only volatiles used by the function are saved.  A normal function
3810 return is generated instead of a return from interrupt.
3812 @item break_handler
3813 @cindex break handler functions
3814 Use this attribute on the MicroBlaze ports to indicate that
3815 the specified function is an break handler.  The compiler generates function
3816 entry and exit sequences suitable for use in an break handler when this
3817 attribute is present. The return from @code{break_handler} is done through
3818 the @code{rtbd} instead of @code{rtsd}.
3820 @smallexample
3821 void f () __attribute__ ((break_handler));
3822 @end smallexample
3824 @item section ("@var{section-name}")
3825 @cindex @code{section} function attribute
3826 Normally, the compiler places the code it generates in the @code{text} section.
3827 Sometimes, however, you need additional sections, or you need certain
3828 particular functions to appear in special sections.  The @code{section}
3829 attribute specifies that a function lives in a particular section.
3830 For example, the declaration:
3832 @smallexample
3833 extern void foobar (void) __attribute__ ((section ("bar")));
3834 @end smallexample
3836 @noindent
3837 puts the function @code{foobar} in the @code{bar} section.
3839 Some file formats do not support arbitrary sections so the @code{section}
3840 attribute is not available on all platforms.
3841 If you need to map the entire contents of a module to a particular
3842 section, consider using the facilities of the linker instead.
3844 @item sentinel
3845 @cindex @code{sentinel} function attribute
3846 This function attribute ensures that a parameter in a function call is
3847 an explicit @code{NULL}.  The attribute is only valid on variadic
3848 functions.  By default, the sentinel is located at position zero, the
3849 last parameter of the function call.  If an optional integer position
3850 argument P is supplied to the attribute, the sentinel must be located at
3851 position P counting backwards from the end of the argument list.
3853 @smallexample
3854 __attribute__ ((sentinel))
3855 is equivalent to
3856 __attribute__ ((sentinel(0)))
3857 @end smallexample
3859 The attribute is automatically set with a position of 0 for the built-in
3860 functions @code{execl} and @code{execlp}.  The built-in function
3861 @code{execle} has the attribute set with a position of 1.
3863 A valid @code{NULL} in this context is defined as zero with any pointer
3864 type.  If your system defines the @code{NULL} macro with an integer type
3865 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3866 with a copy that redefines NULL appropriately.
3868 The warnings for missing or incorrect sentinels are enabled with
3869 @option{-Wformat}.
3871 @item short_call
3872 See @code{long_call/short_call}.
3874 @item shortcall
3875 See @code{longcall/shortcall}.
3877 @item signal
3878 @cindex interrupt handler functions on the AVR processors
3879 Use this attribute on the AVR to indicate that the specified
3880 function is an interrupt handler.  The compiler generates function
3881 entry and exit sequences suitable for use in an interrupt handler when this
3882 attribute is present.
3884 See also the @code{interrupt} function attribute. 
3886 The AVR hardware globally disables interrupts when an interrupt is executed.
3887 Interrupt handler functions defined with the @code{signal} attribute
3888 do not re-enable interrupts.  It is save to enable interrupts in a
3889 @code{signal} handler.  This ``save'' only applies to the code
3890 generated by the compiler and not to the IRQ layout of the
3891 application which is responsibility of the application.
3893 If both @code{signal} and @code{interrupt} are specified for the same
3894 function, @code{signal} is silently ignored.
3896 @item sp_switch
3897 @cindex @code{sp_switch} attribute
3898 Use this attribute on the SH to indicate an @code{interrupt_handler}
3899 function should switch to an alternate stack.  It expects a string
3900 argument that names a global variable holding the address of the
3901 alternate stack.
3903 @smallexample
3904 void *alt_stack;
3905 void f () __attribute__ ((interrupt_handler,
3906                           sp_switch ("alt_stack")));
3907 @end smallexample
3909 @item stdcall
3910 @cindex functions that pop the argument stack on the 386
3911 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3912 assume that the called function pops off the stack space used to
3913 pass arguments, unless it takes a variable number of arguments.
3915 @item syscall_linkage
3916 @cindex @code{syscall_linkage} attribute
3917 This attribute is used to modify the IA-64 calling convention by marking
3918 all input registers as live at all function exits.  This makes it possible
3919 to restart a system call after an interrupt without having to save/restore
3920 the input registers.  This also prevents kernel data from leaking into
3921 application code.
3923 @item target
3924 @cindex @code{target} function attribute
3925 The @code{target} attribute is used to specify that a function is to
3926 be compiled with different target options than specified on the
3927 command line.  This can be used for instance to have functions
3928 compiled with a different ISA (instruction set architecture) than the
3929 default.  You can also use the @samp{#pragma GCC target} pragma to set
3930 more than one function to be compiled with specific target options.
3931 @xref{Function Specific Option Pragmas}, for details about the
3932 @samp{#pragma GCC target} pragma.
3934 For instance on a 386, you could compile one function with
3935 @code{target("sse4.1,arch=core2")} and another with
3936 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3937 compiling the first function with @option{-msse4.1} and
3938 @option{-march=core2} options, and the second function with
3939 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3940 user to make sure that a function is only invoked on a machine that
3941 supports the particular ISA it is compiled for (for example by using
3942 @code{cpuid} on 386 to determine what feature bits and architecture
3943 family are used).
3945 @smallexample
3946 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3947 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3948 @end smallexample
3950 You can either use multiple
3951 strings to specify multiple options, or separate the options
3952 with a comma (@samp{,}).
3954 The @code{target} attribute is presently implemented for
3955 i386/x86_64, PowerPC, and Nios II targets only.
3956 The options supported are specific to each target.
3958 On the 386, the following options are allowed:
3960 @table @samp
3961 @item abm
3962 @itemx no-abm
3963 @cindex @code{target("abm")} attribute
3964 Enable/disable the generation of the advanced bit instructions.
3966 @item aes
3967 @itemx no-aes
3968 @cindex @code{target("aes")} attribute
3969 Enable/disable the generation of the AES instructions.
3971 @item default
3972 @cindex @code{target("default")} attribute
3973 @xref{Function Multiversioning}, where it is used to specify the
3974 default function version.
3976 @item mmx
3977 @itemx no-mmx
3978 @cindex @code{target("mmx")} attribute
3979 Enable/disable the generation of the MMX instructions.
3981 @item pclmul
3982 @itemx no-pclmul
3983 @cindex @code{target("pclmul")} attribute
3984 Enable/disable the generation of the PCLMUL instructions.
3986 @item popcnt
3987 @itemx no-popcnt
3988 @cindex @code{target("popcnt")} attribute
3989 Enable/disable the generation of the POPCNT instruction.
3991 @item sse
3992 @itemx no-sse
3993 @cindex @code{target("sse")} attribute
3994 Enable/disable the generation of the SSE instructions.
3996 @item sse2
3997 @itemx no-sse2
3998 @cindex @code{target("sse2")} attribute
3999 Enable/disable the generation of the SSE2 instructions.
4001 @item sse3
4002 @itemx no-sse3
4003 @cindex @code{target("sse3")} attribute
4004 Enable/disable the generation of the SSE3 instructions.
4006 @item sse4
4007 @itemx no-sse4
4008 @cindex @code{target("sse4")} attribute
4009 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4010 and SSE4.2).
4012 @item sse4.1
4013 @itemx no-sse4.1
4014 @cindex @code{target("sse4.1")} attribute
4015 Enable/disable the generation of the sse4.1 instructions.
4017 @item sse4.2
4018 @itemx no-sse4.2
4019 @cindex @code{target("sse4.2")} attribute
4020 Enable/disable the generation of the sse4.2 instructions.
4022 @item sse4a
4023 @itemx no-sse4a
4024 @cindex @code{target("sse4a")} attribute
4025 Enable/disable the generation of the SSE4A instructions.
4027 @item fma4
4028 @itemx no-fma4
4029 @cindex @code{target("fma4")} attribute
4030 Enable/disable the generation of the FMA4 instructions.
4032 @item xop
4033 @itemx no-xop
4034 @cindex @code{target("xop")} attribute
4035 Enable/disable the generation of the XOP instructions.
4037 @item lwp
4038 @itemx no-lwp
4039 @cindex @code{target("lwp")} attribute
4040 Enable/disable the generation of the LWP instructions.
4042 @item ssse3
4043 @itemx no-ssse3
4044 @cindex @code{target("ssse3")} attribute
4045 Enable/disable the generation of the SSSE3 instructions.
4047 @item cld
4048 @itemx no-cld
4049 @cindex @code{target("cld")} attribute
4050 Enable/disable the generation of the CLD before string moves.
4052 @item fancy-math-387
4053 @itemx no-fancy-math-387
4054 @cindex @code{target("fancy-math-387")} attribute
4055 Enable/disable the generation of the @code{sin}, @code{cos}, and
4056 @code{sqrt} instructions on the 387 floating-point unit.
4058 @item fused-madd
4059 @itemx no-fused-madd
4060 @cindex @code{target("fused-madd")} attribute
4061 Enable/disable the generation of the fused multiply/add instructions.
4063 @item ieee-fp
4064 @itemx no-ieee-fp
4065 @cindex @code{target("ieee-fp")} attribute
4066 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4068 @item inline-all-stringops
4069 @itemx no-inline-all-stringops
4070 @cindex @code{target("inline-all-stringops")} attribute
4071 Enable/disable inlining of string operations.
4073 @item inline-stringops-dynamically
4074 @itemx no-inline-stringops-dynamically
4075 @cindex @code{target("inline-stringops-dynamically")} attribute
4076 Enable/disable the generation of the inline code to do small string
4077 operations and calling the library routines for large operations.
4079 @item align-stringops
4080 @itemx no-align-stringops
4081 @cindex @code{target("align-stringops")} attribute
4082 Do/do not align destination of inlined string operations.
4084 @item recip
4085 @itemx no-recip
4086 @cindex @code{target("recip")} attribute
4087 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4088 instructions followed an additional Newton-Raphson step instead of
4089 doing a floating-point division.
4091 @item arch=@var{ARCH}
4092 @cindex @code{target("arch=@var{ARCH}")} attribute
4093 Specify the architecture to generate code for in compiling the function.
4095 @item tune=@var{TUNE}
4096 @cindex @code{target("tune=@var{TUNE}")} attribute
4097 Specify the architecture to tune for in compiling the function.
4099 @item fpmath=@var{FPMATH}
4100 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4101 Specify which floating-point unit to use.  The
4102 @code{target("fpmath=sse,387")} option must be specified as
4103 @code{target("fpmath=sse+387")} because the comma would separate
4104 different options.
4105 @end table
4107 On the PowerPC, the following options are allowed:
4109 @table @samp
4110 @item altivec
4111 @itemx no-altivec
4112 @cindex @code{target("altivec")} attribute
4113 Generate code that uses (does not use) AltiVec instructions.  In
4114 32-bit code, you cannot enable AltiVec instructions unless
4115 @option{-mabi=altivec} is used on the command line.
4117 @item cmpb
4118 @itemx no-cmpb
4119 @cindex @code{target("cmpb")} attribute
4120 Generate code that uses (does not use) the compare bytes instruction
4121 implemented on the POWER6 processor and other processors that support
4122 the PowerPC V2.05 architecture.
4124 @item dlmzb
4125 @itemx no-dlmzb
4126 @cindex @code{target("dlmzb")} attribute
4127 Generate code that uses (does not use) the string-search @samp{dlmzb}
4128 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4129 generated by default when targeting those processors.
4131 @item fprnd
4132 @itemx no-fprnd
4133 @cindex @code{target("fprnd")} attribute
4134 Generate code that uses (does not use) the FP round to integer
4135 instructions implemented on the POWER5+ processor and other processors
4136 that support the PowerPC V2.03 architecture.
4138 @item hard-dfp
4139 @itemx no-hard-dfp
4140 @cindex @code{target("hard-dfp")} attribute
4141 Generate code that uses (does not use) the decimal floating-point
4142 instructions implemented on some POWER processors.
4144 @item isel
4145 @itemx no-isel
4146 @cindex @code{target("isel")} attribute
4147 Generate code that uses (does not use) ISEL instruction.
4149 @item mfcrf
4150 @itemx no-mfcrf
4151 @cindex @code{target("mfcrf")} attribute
4152 Generate code that uses (does not use) the move from condition
4153 register field instruction implemented on the POWER4 processor and
4154 other processors that support the PowerPC V2.01 architecture.
4156 @item mfpgpr
4157 @itemx no-mfpgpr
4158 @cindex @code{target("mfpgpr")} attribute
4159 Generate code that uses (does not use) the FP move to/from general
4160 purpose register instructions implemented on the POWER6X processor and
4161 other processors that support the extended PowerPC V2.05 architecture.
4163 @item mulhw
4164 @itemx no-mulhw
4165 @cindex @code{target("mulhw")} attribute
4166 Generate code that uses (does not use) the half-word multiply and
4167 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4168 These instructions are generated by default when targeting those
4169 processors.
4171 @item multiple
4172 @itemx no-multiple
4173 @cindex @code{target("multiple")} attribute
4174 Generate code that uses (does not use) the load multiple word
4175 instructions and the store multiple word instructions.
4177 @item update
4178 @itemx no-update
4179 @cindex @code{target("update")} attribute
4180 Generate code that uses (does not use) the load or store instructions
4181 that update the base register to the address of the calculated memory
4182 location.
4184 @item popcntb
4185 @itemx no-popcntb
4186 @cindex @code{target("popcntb")} attribute
4187 Generate code that uses (does not use) the popcount and double-precision
4188 FP reciprocal estimate instruction implemented on the POWER5
4189 processor and other processors that support the PowerPC V2.02
4190 architecture.
4192 @item popcntd
4193 @itemx no-popcntd
4194 @cindex @code{target("popcntd")} attribute
4195 Generate code that uses (does not use) the popcount instruction
4196 implemented on the POWER7 processor and other processors that support
4197 the PowerPC V2.06 architecture.
4199 @item powerpc-gfxopt
4200 @itemx no-powerpc-gfxopt
4201 @cindex @code{target("powerpc-gfxopt")} attribute
4202 Generate code that uses (does not use) the optional PowerPC
4203 architecture instructions in the Graphics group, including
4204 floating-point select.
4206 @item powerpc-gpopt
4207 @itemx no-powerpc-gpopt
4208 @cindex @code{target("powerpc-gpopt")} attribute
4209 Generate code that uses (does not use) the optional PowerPC
4210 architecture instructions in the General Purpose group, including
4211 floating-point square root.
4213 @item recip-precision
4214 @itemx no-recip-precision
4215 @cindex @code{target("recip-precision")} attribute
4216 Assume (do not assume) that the reciprocal estimate instructions
4217 provide higher-precision estimates than is mandated by the powerpc
4218 ABI.
4220 @item string
4221 @itemx no-string
4222 @cindex @code{target("string")} attribute
4223 Generate code that uses (does not use) the load string instructions
4224 and the store string word instructions to save multiple registers and
4225 do small block moves.
4227 @item vsx
4228 @itemx no-vsx
4229 @cindex @code{target("vsx")} attribute
4230 Generate code that uses (does not use) vector/scalar (VSX)
4231 instructions, and also enable the use of built-in functions that allow
4232 more direct access to the VSX instruction set.  In 32-bit code, you
4233 cannot enable VSX or AltiVec instructions unless
4234 @option{-mabi=altivec} is used on the command line.
4236 @item friz
4237 @itemx no-friz
4238 @cindex @code{target("friz")} attribute
4239 Generate (do not generate) the @code{friz} instruction when the
4240 @option{-funsafe-math-optimizations} option is used to optimize
4241 rounding a floating-point value to 64-bit integer and back to floating
4242 point.  The @code{friz} instruction does not return the same value if
4243 the floating-point number is too large to fit in an integer.
4245 @item avoid-indexed-addresses
4246 @itemx no-avoid-indexed-addresses
4247 @cindex @code{target("avoid-indexed-addresses")} attribute
4248 Generate code that tries to avoid (not avoid) the use of indexed load
4249 or store instructions.
4251 @item paired
4252 @itemx no-paired
4253 @cindex @code{target("paired")} attribute
4254 Generate code that uses (does not use) the generation of PAIRED simd
4255 instructions.
4257 @item longcall
4258 @itemx no-longcall
4259 @cindex @code{target("longcall")} attribute
4260 Generate code that assumes (does not assume) that all calls are far
4261 away so that a longer more expensive calling sequence is required.
4263 @item cpu=@var{CPU}
4264 @cindex @code{target("cpu=@var{CPU}")} attribute
4265 Specify the architecture to generate code for when compiling the
4266 function.  If you select the @code{target("cpu=power7")} attribute when
4267 generating 32-bit code, VSX and AltiVec instructions are not generated
4268 unless you use the @option{-mabi=altivec} option on the command line.
4270 @item tune=@var{TUNE}
4271 @cindex @code{target("tune=@var{TUNE}")} attribute
4272 Specify the architecture to tune for when compiling the function.  If
4273 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4274 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4275 compilation tunes for the @var{CPU} architecture, and not the
4276 default tuning specified on the command line.
4277 @end table
4279 When compiling for Nios II, the following options are allowed:
4281 @table @samp
4282 @item custom-@var{insn}=@var{N}
4283 @itemx no-custom-@var{insn}
4284 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4285 @cindex @code{target("no-custom-@var{insn}")} attribute
4286 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4287 custom instruction with encoding @var{N} when generating code that uses 
4288 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4289 the custom instruction @var{insn}.
4290 These target attributes correspond to the
4291 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4292 command-line options, and support the same set of @var{insn} keywords.
4293 @xref{Nios II Options}, for more information.
4295 @item custom-fpu-cfg=@var{name}
4296 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4297 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4298 command-line option, to select a predefined set of custom instructions
4299 named @var{name}.
4300 @xref{Nios II Options}, for more information.
4301 @end table
4303 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4304 function that has different target options than the caller, unless the
4305 callee has a subset of the target options of the caller.  For example
4306 a function declared with @code{target("sse3")} can inline a function
4307 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4309 @item tiny_data
4310 @cindex tiny data section on the H8/300H and H8S
4311 Use this attribute on the H8/300H and H8S to indicate that the specified
4312 variable should be placed into the tiny data section.
4313 The compiler generates more efficient code for loads and stores
4314 on data in the tiny data section.  Note the tiny data area is limited to
4315 slightly under 32KB of data.
4317 @item trap_exit
4318 @cindex @code{trap_exit} attribute
4319 Use this attribute on the SH for an @code{interrupt_handler} to return using
4320 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4321 argument specifying the trap number to be used.
4323 @item trapa_handler
4324 @cindex @code{trapa_handler} attribute
4325 On SH targets this function attribute is similar to @code{interrupt_handler}
4326 but it does not save and restore all registers.
4328 @item unused
4329 @cindex @code{unused} attribute.
4330 This attribute, attached to a function, means that the function is meant
4331 to be possibly unused.  GCC does not produce a warning for this
4332 function.
4334 @item used
4335 @cindex @code{used} attribute.
4336 This attribute, attached to a function, means that code must be emitted
4337 for the function even if it appears that the function is not referenced.
4338 This is useful, for example, when the function is referenced only in
4339 inline assembly.
4341 When applied to a member function of a C++ class template, the
4342 attribute also means that the function is instantiated if the
4343 class itself is instantiated.
4345 @item vector
4346 @cindex @code{vector} attribute
4347 This RX attribute is similar to the @code{interrupt} attribute, including its
4348 parameters, but does not make the function an interrupt-handler type
4349 function (i.e. it retains the normal C function calling ABI).  See the
4350 @code{interrupt} attribute for a description of its arguments.
4352 @item version_id
4353 @cindex @code{version_id} attribute
4354 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4355 symbol to contain a version string, thus allowing for function level
4356 versioning.  HP-UX system header files may use function level versioning
4357 for some system calls.
4359 @smallexample
4360 extern int foo () __attribute__((version_id ("20040821")));
4361 @end smallexample
4363 @noindent
4364 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4366 @item visibility ("@var{visibility_type}")
4367 @cindex @code{visibility} attribute
4368 This attribute affects the linkage of the declaration to which it is attached.
4369 There are four supported @var{visibility_type} values: default,
4370 hidden, protected or internal visibility.
4372 @smallexample
4373 void __attribute__ ((visibility ("protected")))
4374 f () @{ /* @r{Do something.} */; @}
4375 int i __attribute__ ((visibility ("hidden")));
4376 @end smallexample
4378 The possible values of @var{visibility_type} correspond to the
4379 visibility settings in the ELF gABI.
4381 @table @dfn
4382 @c keep this list of visibilities in alphabetical order.
4384 @item default
4385 Default visibility is the normal case for the object file format.
4386 This value is available for the visibility attribute to override other
4387 options that may change the assumed visibility of entities.
4389 On ELF, default visibility means that the declaration is visible to other
4390 modules and, in shared libraries, means that the declared entity may be
4391 overridden.
4393 On Darwin, default visibility means that the declaration is visible to
4394 other modules.
4396 Default visibility corresponds to ``external linkage'' in the language.
4398 @item hidden
4399 Hidden visibility indicates that the entity declared has a new
4400 form of linkage, which we call ``hidden linkage''.  Two
4401 declarations of an object with hidden linkage refer to the same object
4402 if they are in the same shared object.
4404 @item internal
4405 Internal visibility is like hidden visibility, but with additional
4406 processor specific semantics.  Unless otherwise specified by the
4407 psABI, GCC defines internal visibility to mean that a function is
4408 @emph{never} called from another module.  Compare this with hidden
4409 functions which, while they cannot be referenced directly by other
4410 modules, can be referenced indirectly via function pointers.  By
4411 indicating that a function cannot be called from outside the module,
4412 GCC may for instance omit the load of a PIC register since it is known
4413 that the calling function loaded the correct value.
4415 @item protected
4416 Protected visibility is like default visibility except that it
4417 indicates that references within the defining module bind to the
4418 definition in that module.  That is, the declared entity cannot be
4419 overridden by another module.
4421 @end table
4423 All visibilities are supported on many, but not all, ELF targets
4424 (supported when the assembler supports the @samp{.visibility}
4425 pseudo-op).  Default visibility is supported everywhere.  Hidden
4426 visibility is supported on Darwin targets.
4428 The visibility attribute should be applied only to declarations that
4429 would otherwise have external linkage.  The attribute should be applied
4430 consistently, so that the same entity should not be declared with
4431 different settings of the attribute.
4433 In C++, the visibility attribute applies to types as well as functions
4434 and objects, because in C++ types have linkage.  A class must not have
4435 greater visibility than its non-static data member types and bases,
4436 and class members default to the visibility of their class.  Also, a
4437 declaration without explicit visibility is limited to the visibility
4438 of its type.
4440 In C++, you can mark member functions and static member variables of a
4441 class with the visibility attribute.  This is useful if you know a
4442 particular method or static member variable should only be used from
4443 one shared object; then you can mark it hidden while the rest of the
4444 class has default visibility.  Care must be taken to avoid breaking
4445 the One Definition Rule; for example, it is usually not useful to mark
4446 an inline method as hidden without marking the whole class as hidden.
4448 A C++ namespace declaration can also have the visibility attribute.
4450 @smallexample
4451 namespace nspace1 __attribute__ ((visibility ("protected")))
4452 @{ /* @r{Do something.} */; @}
4453 @end smallexample
4455 This attribute applies only to the particular namespace body, not to
4456 other definitions of the same namespace; it is equivalent to using
4457 @samp{#pragma GCC visibility} before and after the namespace
4458 definition (@pxref{Visibility Pragmas}).
4460 In C++, if a template argument has limited visibility, this
4461 restriction is implicitly propagated to the template instantiation.
4462 Otherwise, template instantiations and specializations default to the
4463 visibility of their template.
4465 If both the template and enclosing class have explicit visibility, the
4466 visibility from the template is used.
4468 @item vliw
4469 @cindex @code{vliw} attribute
4470 On MeP, the @code{vliw} attribute tells the compiler to emit
4471 instructions in VLIW mode instead of core mode.  Note that this
4472 attribute is not allowed unless a VLIW coprocessor has been configured
4473 and enabled through command-line options.
4475 @item warn_unused_result
4476 @cindex @code{warn_unused_result} attribute
4477 The @code{warn_unused_result} attribute causes a warning to be emitted
4478 if a caller of the function with this attribute does not use its
4479 return value.  This is useful for functions where not checking
4480 the result is either a security problem or always a bug, such as
4481 @code{realloc}.
4483 @smallexample
4484 int fn () __attribute__ ((warn_unused_result));
4485 int foo ()
4487   if (fn () < 0) return -1;
4488   fn ();
4489   return 0;
4491 @end smallexample
4493 @noindent
4494 results in warning on line 5.
4496 @item weak
4497 @cindex @code{weak} attribute
4498 The @code{weak} attribute causes the declaration to be emitted as a weak
4499 symbol rather than a global.  This is primarily useful in defining
4500 library functions that can be overridden in user code, though it can
4501 also be used with non-function declarations.  Weak symbols are supported
4502 for ELF targets, and also for a.out targets when using the GNU assembler
4503 and linker.
4505 @item weakref
4506 @itemx weakref ("@var{target}")
4507 @cindex @code{weakref} attribute
4508 The @code{weakref} attribute marks a declaration as a weak reference.
4509 Without arguments, it should be accompanied by an @code{alias} attribute
4510 naming the target symbol.  Optionally, the @var{target} may be given as
4511 an argument to @code{weakref} itself.  In either case, @code{weakref}
4512 implicitly marks the declaration as @code{weak}.  Without a
4513 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4514 @code{weakref} is equivalent to @code{weak}.
4516 @smallexample
4517 static int x() __attribute__ ((weakref ("y")));
4518 /* is equivalent to... */
4519 static int x() __attribute__ ((weak, weakref, alias ("y")));
4520 /* and to... */
4521 static int x() __attribute__ ((weakref));
4522 static int x() __attribute__ ((alias ("y")));
4523 @end smallexample
4525 A weak reference is an alias that does not by itself require a
4526 definition to be given for the target symbol.  If the target symbol is
4527 only referenced through weak references, then it becomes a @code{weak}
4528 undefined symbol.  If it is directly referenced, however, then such
4529 strong references prevail, and a definition is required for the
4530 symbol, not necessarily in the same translation unit.
4532 The effect is equivalent to moving all references to the alias to a
4533 separate translation unit, renaming the alias to the aliased symbol,
4534 declaring it as weak, compiling the two separate translation units and
4535 performing a reloadable link on them.
4537 At present, a declaration to which @code{weakref} is attached can
4538 only be @code{static}.
4540 @end table
4542 You can specify multiple attributes in a declaration by separating them
4543 by commas within the double parentheses or by immediately following an
4544 attribute declaration with another attribute declaration.
4546 @cindex @code{#pragma}, reason for not using
4547 @cindex pragma, reason for not using
4548 Some people object to the @code{__attribute__} feature, suggesting that
4549 ISO C's @code{#pragma} should be used instead.  At the time
4550 @code{__attribute__} was designed, there were two reasons for not doing
4551 this.
4553 @enumerate
4554 @item
4555 It is impossible to generate @code{#pragma} commands from a macro.
4557 @item
4558 There is no telling what the same @code{#pragma} might mean in another
4559 compiler.
4560 @end enumerate
4562 These two reasons applied to almost any application that might have been
4563 proposed for @code{#pragma}.  It was basically a mistake to use
4564 @code{#pragma} for @emph{anything}.
4566 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4567 to be generated from macros.  In addition, a @code{#pragma GCC}
4568 namespace is now in use for GCC-specific pragmas.  However, it has been
4569 found convenient to use @code{__attribute__} to achieve a natural
4570 attachment of attributes to their corresponding declarations, whereas
4571 @code{#pragma GCC} is of use for constructs that do not naturally form
4572 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4574 @node Label Attributes
4575 @section Label Attributes
4576 @cindex Label Attributes
4578 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4579 details of the exact syntax for using attributes.  Other attributes are 
4580 available for functions (@pxref{Function Attributes}), variables 
4581 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4583 This example uses the @code{cold} label attribute to indicate the 
4584 @code{ErrorHandling} branch is unlikely to be taken and that the
4585 @code{ErrorHandling} label is unused:
4587 @smallexample
4589    asm goto ("some asm" : : : : NoError);
4591 /* This branch (the fallthru from the asm) is less commonly used */
4592 ErrorHandling: 
4593    __attribute__((cold, unused)); /* Semi-colon is required here */
4594    printf("error\n");
4595    return 0;
4597 NoError:
4598    printf("no error\n");
4599    return 1;
4600 @end smallexample
4602 @table @code
4603 @item unused
4604 @cindex @code{unused} label attribute
4605 This feature is intended for program-generated code that may contain 
4606 unused labels, but which is compiled with @option{-Wall}.  It is
4607 not normally appropriate to use in it human-written code, though it
4608 could be useful in cases where the code that jumps to the label is
4609 contained within an @code{#ifdef} conditional.
4611 @item hot
4612 @cindex @code{hot} label attribute
4613 The @code{hot} attribute on a label is used to inform the compiler that
4614 the path following the label is more likely than paths that are not so
4615 annotated.  This attribute is used in cases where @code{__builtin_expect}
4616 cannot be used, for instance with computed goto or @code{asm goto}.
4618 The @code{hot} attribute on labels is not implemented in GCC versions
4619 earlier than 4.8.
4621 @item cold
4622 @cindex @code{cold} label attribute
4623 The @code{cold} attribute on labels is used to inform the compiler that
4624 the path following the label is unlikely to be executed.  This attribute
4625 is used in cases where @code{__builtin_expect} cannot be used, for instance
4626 with computed goto or @code{asm goto}.
4628 The @code{cold} attribute on labels is not implemented in GCC versions
4629 earlier than 4.8.
4631 @end table
4633 @node Attribute Syntax
4634 @section Attribute Syntax
4635 @cindex attribute syntax
4637 This section describes the syntax with which @code{__attribute__} may be
4638 used, and the constructs to which attribute specifiers bind, for the C
4639 language.  Some details may vary for C++ and Objective-C@.  Because of
4640 infelicities in the grammar for attributes, some forms described here
4641 may not be successfully parsed in all cases.
4643 There are some problems with the semantics of attributes in C++.  For
4644 example, there are no manglings for attributes, although they may affect
4645 code generation, so problems may arise when attributed types are used in
4646 conjunction with templates or overloading.  Similarly, @code{typeid}
4647 does not distinguish between types with different attributes.  Support
4648 for attributes in C++ may be restricted in future to attributes on
4649 declarations only, but not on nested declarators.
4651 @xref{Function Attributes}, for details of the semantics of attributes
4652 applying to functions.  @xref{Variable Attributes}, for details of the
4653 semantics of attributes applying to variables.  @xref{Type Attributes},
4654 for details of the semantics of attributes applying to structure, union
4655 and enumerated types.
4656 @xref{Label Attributes}, for details of the semantics of attributes 
4657 applying to labels.
4659 An @dfn{attribute specifier} is of the form
4660 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4661 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4662 each attribute is one of the following:
4664 @itemize @bullet
4665 @item
4666 Empty.  Empty attributes are ignored.
4668 @item
4669 A word (which may be an identifier such as @code{unused}, or a reserved
4670 word such as @code{const}).
4672 @item
4673 A word, followed by, in parentheses, parameters for the attribute.
4674 These parameters take one of the following forms:
4676 @itemize @bullet
4677 @item
4678 An identifier.  For example, @code{mode} attributes use this form.
4680 @item
4681 An identifier followed by a comma and a non-empty comma-separated list
4682 of expressions.  For example, @code{format} attributes use this form.
4684 @item
4685 A possibly empty comma-separated list of expressions.  For example,
4686 @code{format_arg} attributes use this form with the list being a single
4687 integer constant expression, and @code{alias} attributes use this form
4688 with the list being a single string constant.
4689 @end itemize
4690 @end itemize
4692 An @dfn{attribute specifier list} is a sequence of one or more attribute
4693 specifiers, not separated by any other tokens.
4695 @subsubheading Label Attributes
4697 In GNU C, an attribute specifier list may appear after the colon following a
4698 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4699 attributes on labels if the attribute specifier is immediately
4700 followed by a semicolon (i.e., the label applies to an empty
4701 statement).  If the semicolon is missing, C++ label attributes are
4702 ambiguous, as it is permissible for a declaration, which could begin
4703 with an attribute list, to be labelled in C++.  Declarations cannot be
4704 labelled in C90 or C99, so the ambiguity does not arise there.
4706 @subsubheading Type Attributes
4708 An attribute specifier list may appear as part of a @code{struct},
4709 @code{union} or @code{enum} specifier.  It may go either immediately
4710 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4711 the closing brace.  The former syntax is preferred.
4712 Where attribute specifiers follow the closing brace, they are considered
4713 to relate to the structure, union or enumerated type defined, not to any
4714 enclosing declaration the type specifier appears in, and the type
4715 defined is not complete until after the attribute specifiers.
4716 @c Otherwise, there would be the following problems: a shift/reduce
4717 @c conflict between attributes binding the struct/union/enum and
4718 @c binding to the list of specifiers/qualifiers; and "aligned"
4719 @c attributes could use sizeof for the structure, but the size could be
4720 @c changed later by "packed" attributes.
4723 @subsubheading All other attributes
4725 Otherwise, an attribute specifier appears as part of a declaration,
4726 counting declarations of unnamed parameters and type names, and relates
4727 to that declaration (which may be nested in another declaration, for
4728 example in the case of a parameter declaration), or to a particular declarator
4729 within a declaration.  Where an
4730 attribute specifier is applied to a parameter declared as a function or
4731 an array, it should apply to the function or array rather than the
4732 pointer to which the parameter is implicitly converted, but this is not
4733 yet correctly implemented.
4735 Any list of specifiers and qualifiers at the start of a declaration may
4736 contain attribute specifiers, whether or not such a list may in that
4737 context contain storage class specifiers.  (Some attributes, however,
4738 are essentially in the nature of storage class specifiers, and only make
4739 sense where storage class specifiers may be used; for example,
4740 @code{section}.)  There is one necessary limitation to this syntax: the
4741 first old-style parameter declaration in a function definition cannot
4742 begin with an attribute specifier, because such an attribute applies to
4743 the function instead by syntax described below (which, however, is not
4744 yet implemented in this case).  In some other cases, attribute
4745 specifiers are permitted by this grammar but not yet supported by the
4746 compiler.  All attribute specifiers in this place relate to the
4747 declaration as a whole.  In the obsolescent usage where a type of
4748 @code{int} is implied by the absence of type specifiers, such a list of
4749 specifiers and qualifiers may be an attribute specifier list with no
4750 other specifiers or qualifiers.
4752 At present, the first parameter in a function prototype must have some
4753 type specifier that is not an attribute specifier; this resolves an
4754 ambiguity in the interpretation of @code{void f(int
4755 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4756 the parentheses of a function declarator contain only attributes then
4757 those attributes are ignored, rather than yielding an error or warning
4758 or implying a single parameter of type int, but this is subject to
4759 change.
4761 An attribute specifier list may appear immediately before a declarator
4762 (other than the first) in a comma-separated list of declarators in a
4763 declaration of more than one identifier using a single list of
4764 specifiers and qualifiers.  Such attribute specifiers apply
4765 only to the identifier before whose declarator they appear.  For
4766 example, in
4768 @smallexample
4769 __attribute__((noreturn)) void d0 (void),
4770     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4771      d2 (void)
4772 @end smallexample
4774 @noindent
4775 the @code{noreturn} attribute applies to all the functions
4776 declared; the @code{format} attribute only applies to @code{d1}.
4778 An attribute specifier list may appear immediately before the comma,
4779 @code{=} or semicolon terminating the declaration of an identifier other
4780 than a function definition.  Such attribute specifiers apply
4781 to the declared object or function.  Where an
4782 assembler name for an object or function is specified (@pxref{Asm
4783 Labels}), the attribute must follow the @code{asm}
4784 specification.
4786 An attribute specifier list may, in future, be permitted to appear after
4787 the declarator in a function definition (before any old-style parameter
4788 declarations or the function body).
4790 Attribute specifiers may be mixed with type qualifiers appearing inside
4791 the @code{[]} of a parameter array declarator, in the C99 construct by
4792 which such qualifiers are applied to the pointer to which the array is
4793 implicitly converted.  Such attribute specifiers apply to the pointer,
4794 not to the array, but at present this is not implemented and they are
4795 ignored.
4797 An attribute specifier list may appear at the start of a nested
4798 declarator.  At present, there are some limitations in this usage: the
4799 attributes correctly apply to the declarator, but for most individual
4800 attributes the semantics this implies are not implemented.
4801 When attribute specifiers follow the @code{*} of a pointer
4802 declarator, they may be mixed with any type qualifiers present.
4803 The following describes the formal semantics of this syntax.  It makes the
4804 most sense if you are familiar with the formal specification of
4805 declarators in the ISO C standard.
4807 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4808 D1}, where @code{T} contains declaration specifiers that specify a type
4809 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4810 contains an identifier @var{ident}.  The type specified for @var{ident}
4811 for derived declarators whose type does not include an attribute
4812 specifier is as in the ISO C standard.
4814 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4815 and the declaration @code{T D} specifies the type
4816 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4817 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4818 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4820 If @code{D1} has the form @code{*
4821 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4822 declaration @code{T D} specifies the type
4823 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4824 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4825 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4826 @var{ident}.
4828 For example,
4830 @smallexample
4831 void (__attribute__((noreturn)) ****f) (void);
4832 @end smallexample
4834 @noindent
4835 specifies the type ``pointer to pointer to pointer to pointer to
4836 non-returning function returning @code{void}''.  As another example,
4838 @smallexample
4839 char *__attribute__((aligned(8))) *f;
4840 @end smallexample
4842 @noindent
4843 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4844 Note again that this does not work with most attributes; for example,
4845 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4846 is not yet supported.
4848 For compatibility with existing code written for compiler versions that
4849 did not implement attributes on nested declarators, some laxity is
4850 allowed in the placing of attributes.  If an attribute that only applies
4851 to types is applied to a declaration, it is treated as applying to
4852 the type of that declaration.  If an attribute that only applies to
4853 declarations is applied to the type of a declaration, it is treated
4854 as applying to that declaration; and, for compatibility with code
4855 placing the attributes immediately before the identifier declared, such
4856 an attribute applied to a function return type is treated as
4857 applying to the function type, and such an attribute applied to an array
4858 element type is treated as applying to the array type.  If an
4859 attribute that only applies to function types is applied to a
4860 pointer-to-function type, it is treated as applying to the pointer
4861 target type; if such an attribute is applied to a function return type
4862 that is not a pointer-to-function type, it is treated as applying
4863 to the function type.
4865 @node Function Prototypes
4866 @section Prototypes and Old-Style Function Definitions
4867 @cindex function prototype declarations
4868 @cindex old-style function definitions
4869 @cindex promotion of formal parameters
4871 GNU C extends ISO C to allow a function prototype to override a later
4872 old-style non-prototype definition.  Consider the following example:
4874 @smallexample
4875 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4876 #ifdef __STDC__
4877 #define P(x) x
4878 #else
4879 #define P(x) ()
4880 #endif
4882 /* @r{Prototype function declaration.}  */
4883 int isroot P((uid_t));
4885 /* @r{Old-style function definition.}  */
4887 isroot (x)   /* @r{??? lossage here ???} */
4888      uid_t x;
4890   return x == 0;
4892 @end smallexample
4894 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4895 not allow this example, because subword arguments in old-style
4896 non-prototype definitions are promoted.  Therefore in this example the
4897 function definition's argument is really an @code{int}, which does not
4898 match the prototype argument type of @code{short}.
4900 This restriction of ISO C makes it hard to write code that is portable
4901 to traditional C compilers, because the programmer does not know
4902 whether the @code{uid_t} type is @code{short}, @code{int}, or
4903 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4904 to override a later old-style definition.  More precisely, in GNU C, a
4905 function prototype argument type overrides the argument type specified
4906 by a later old-style definition if the former type is the same as the
4907 latter type before promotion.  Thus in GNU C the above example is
4908 equivalent to the following:
4910 @smallexample
4911 int isroot (uid_t);
4914 isroot (uid_t x)
4916   return x == 0;
4918 @end smallexample
4920 @noindent
4921 GNU C++ does not support old-style function definitions, so this
4922 extension is irrelevant.
4924 @node C++ Comments
4925 @section C++ Style Comments
4926 @cindex @code{//}
4927 @cindex C++ comments
4928 @cindex comments, C++ style
4930 In GNU C, you may use C++ style comments, which start with @samp{//} and
4931 continue until the end of the line.  Many other C implementations allow
4932 such comments, and they are included in the 1999 C standard.  However,
4933 C++ style comments are not recognized if you specify an @option{-std}
4934 option specifying a version of ISO C before C99, or @option{-ansi}
4935 (equivalent to @option{-std=c90}).
4937 @node Dollar Signs
4938 @section Dollar Signs in Identifier Names
4939 @cindex $
4940 @cindex dollar signs in identifier names
4941 @cindex identifier names, dollar signs in
4943 In GNU C, you may normally use dollar signs in identifier names.
4944 This is because many traditional C implementations allow such identifiers.
4945 However, dollar signs in identifiers are not supported on a few target
4946 machines, typically because the target assembler does not allow them.
4948 @node Character Escapes
4949 @section The Character @key{ESC} in Constants
4951 You can use the sequence @samp{\e} in a string or character constant to
4952 stand for the ASCII character @key{ESC}.
4954 @node Variable Attributes
4955 @section Specifying Attributes of Variables
4956 @cindex attribute of variables
4957 @cindex variable attributes
4959 The keyword @code{__attribute__} allows you to specify special
4960 attributes of variables or structure fields.  This keyword is followed
4961 by an attribute specification inside double parentheses.  Some
4962 attributes are currently defined generically for variables.
4963 Other attributes are defined for variables on particular target
4964 systems.  Other attributes are available for functions
4965 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
4966 types (@pxref{Type Attributes}).
4967 Other front ends might define more attributes
4968 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4970 You may also specify attributes with @samp{__} preceding and following
4971 each keyword.  This allows you to use them in header files without
4972 being concerned about a possible macro of the same name.  For example,
4973 you may use @code{__aligned__} instead of @code{aligned}.
4975 @xref{Attribute Syntax}, for details of the exact syntax for using
4976 attributes.
4978 @table @code
4979 @cindex @code{aligned} attribute
4980 @item aligned (@var{alignment})
4981 This attribute specifies a minimum alignment for the variable or
4982 structure field, measured in bytes.  For example, the declaration:
4984 @smallexample
4985 int x __attribute__ ((aligned (16))) = 0;
4986 @end smallexample
4988 @noindent
4989 causes the compiler to allocate the global variable @code{x} on a
4990 16-byte boundary.  On a 68040, this could be used in conjunction with
4991 an @code{asm} expression to access the @code{move16} instruction which
4992 requires 16-byte aligned operands.
4994 You can also specify the alignment of structure fields.  For example, to
4995 create a double-word aligned @code{int} pair, you could write:
4997 @smallexample
4998 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4999 @end smallexample
5001 @noindent
5002 This is an alternative to creating a union with a @code{double} member,
5003 which forces the union to be double-word aligned.
5005 As in the preceding examples, you can explicitly specify the alignment
5006 (in bytes) that you wish the compiler to use for a given variable or
5007 structure field.  Alternatively, you can leave out the alignment factor
5008 and just ask the compiler to align a variable or field to the
5009 default alignment for the target architecture you are compiling for.
5010 The default alignment is sufficient for all scalar types, but may not be
5011 enough for all vector types on a target that supports vector operations.
5012 The default alignment is fixed for a particular target ABI.
5014 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5015 which is the largest alignment ever used for any data type on the
5016 target machine you are compiling for.  For example, you could write:
5018 @smallexample
5019 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5020 @end smallexample
5022 The compiler automatically sets the alignment for the declared
5023 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5024 often make copy operations more efficient, because the compiler can
5025 use whatever instructions copy the biggest chunks of memory when
5026 performing copies to or from the variables or fields that you have
5027 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5028 may change depending on command-line options.
5030 When used on a struct, or struct member, the @code{aligned} attribute can
5031 only increase the alignment; in order to decrease it, the @code{packed}
5032 attribute must be specified as well.  When used as part of a typedef, the
5033 @code{aligned} attribute can both increase and decrease alignment, and
5034 specifying the @code{packed} attribute generates a warning.
5036 Note that the effectiveness of @code{aligned} attributes may be limited
5037 by inherent limitations in your linker.  On many systems, the linker is
5038 only able to arrange for variables to be aligned up to a certain maximum
5039 alignment.  (For some linkers, the maximum supported alignment may
5040 be very very small.)  If your linker is only able to align variables
5041 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5042 in an @code{__attribute__} still only provides you with 8-byte
5043 alignment.  See your linker documentation for further information.
5045 The @code{aligned} attribute can also be used for functions
5046 (@pxref{Function Attributes}.)
5048 @item cleanup (@var{cleanup_function})
5049 @cindex @code{cleanup} attribute
5050 The @code{cleanup} attribute runs a function when the variable goes
5051 out of scope.  This attribute can only be applied to auto function
5052 scope variables; it may not be applied to parameters or variables
5053 with static storage duration.  The function must take one parameter,
5054 a pointer to a type compatible with the variable.  The return value
5055 of the function (if any) is ignored.
5057 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5058 is run during the stack unwinding that happens during the
5059 processing of the exception.  Note that the @code{cleanup} attribute
5060 does not allow the exception to be caught, only to perform an action.
5061 It is undefined what happens if @var{cleanup_function} does not
5062 return normally.
5064 @item common
5065 @itemx nocommon
5066 @cindex @code{common} attribute
5067 @cindex @code{nocommon} attribute
5068 @opindex fcommon
5069 @opindex fno-common
5070 The @code{common} attribute requests GCC to place a variable in
5071 ``common'' storage.  The @code{nocommon} attribute requests the
5072 opposite---to allocate space for it directly.
5074 These attributes override the default chosen by the
5075 @option{-fno-common} and @option{-fcommon} flags respectively.
5077 @item deprecated
5078 @itemx deprecated (@var{msg})
5079 @cindex @code{deprecated} attribute
5080 The @code{deprecated} attribute results in a warning if the variable
5081 is used anywhere in the source file.  This is useful when identifying
5082 variables that are expected to be removed in a future version of a
5083 program.  The warning also includes the location of the declaration
5084 of the deprecated variable, to enable users to easily find further
5085 information about why the variable is deprecated, or what they should
5086 do instead.  Note that the warning only occurs for uses:
5088 @smallexample
5089 extern int old_var __attribute__ ((deprecated));
5090 extern int old_var;
5091 int new_fn () @{ return old_var; @}
5092 @end smallexample
5094 @noindent
5095 results in a warning on line 3 but not line 2.  The optional @var{msg}
5096 argument, which must be a string, is printed in the warning if
5097 present.
5099 The @code{deprecated} attribute can also be used for functions and
5100 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5102 @item mode (@var{mode})
5103 @cindex @code{mode} attribute
5104 This attribute specifies the data type for the declaration---whichever
5105 type corresponds to the mode @var{mode}.  This in effect lets you
5106 request an integer or floating-point type according to its width.
5108 You may also specify a mode of @code{byte} or @code{__byte__} to
5109 indicate the mode corresponding to a one-byte integer, @code{word} or
5110 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5111 or @code{__pointer__} for the mode used to represent pointers.
5113 @item packed
5114 @cindex @code{packed} attribute
5115 The @code{packed} attribute specifies that a variable or structure field
5116 should have the smallest possible alignment---one byte for a variable,
5117 and one bit for a field, unless you specify a larger value with the
5118 @code{aligned} attribute.
5120 Here is a structure in which the field @code{x} is packed, so that it
5121 immediately follows @code{a}:
5123 @smallexample
5124 struct foo
5126   char a;
5127   int x[2] __attribute__ ((packed));
5129 @end smallexample
5131 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5132 @code{packed} attribute on bit-fields of type @code{char}.  This has
5133 been fixed in GCC 4.4 but the change can lead to differences in the
5134 structure layout.  See the documentation of
5135 @option{-Wpacked-bitfield-compat} for more information.
5137 @item section ("@var{section-name}")
5138 @cindex @code{section} variable attribute
5139 Normally, the compiler places the objects it generates in sections like
5140 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5141 or you need certain particular variables to appear in special sections,
5142 for example to map to special hardware.  The @code{section}
5143 attribute specifies that a variable (or function) lives in a particular
5144 section.  For example, this small program uses several specific section names:
5146 @smallexample
5147 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5148 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5149 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5150 int init_data __attribute__ ((section ("INITDATA")));
5152 main()
5154   /* @r{Initialize stack pointer} */
5155   init_sp (stack + sizeof (stack));
5157   /* @r{Initialize initialized data} */
5158   memcpy (&init_data, &data, &edata - &data);
5160   /* @r{Turn on the serial ports} */
5161   init_duart (&a);
5162   init_duart (&b);
5164 @end smallexample
5166 @noindent
5167 Use the @code{section} attribute with
5168 @emph{global} variables and not @emph{local} variables,
5169 as shown in the example.
5171 You may use the @code{section} attribute with initialized or
5172 uninitialized global variables but the linker requires
5173 each object be defined once, with the exception that uninitialized
5174 variables tentatively go in the @code{common} (or @code{bss}) section
5175 and can be multiply ``defined''.  Using the @code{section} attribute
5176 changes what section the variable goes into and may cause the
5177 linker to issue an error if an uninitialized variable has multiple
5178 definitions.  You can force a variable to be initialized with the
5179 @option{-fno-common} flag or the @code{nocommon} attribute.
5181 Some file formats do not support arbitrary sections so the @code{section}
5182 attribute is not available on all platforms.
5183 If you need to map the entire contents of a module to a particular
5184 section, consider using the facilities of the linker instead.
5186 @item shared
5187 @cindex @code{shared} variable attribute
5188 On Microsoft Windows, in addition to putting variable definitions in a named
5189 section, the section can also be shared among all running copies of an
5190 executable or DLL@.  For example, this small program defines shared data
5191 by putting it in a named section @code{shared} and marking the section
5192 shareable:
5194 @smallexample
5195 int foo __attribute__((section ("shared"), shared)) = 0;
5198 main()
5200   /* @r{Read and write foo.  All running
5201      copies see the same value.}  */
5202   return 0;
5204 @end smallexample
5206 @noindent
5207 You may only use the @code{shared} attribute along with @code{section}
5208 attribute with a fully-initialized global definition because of the way
5209 linkers work.  See @code{section} attribute for more information.
5211 The @code{shared} attribute is only available on Microsoft Windows@.
5213 @item tls_model ("@var{tls_model}")
5214 @cindex @code{tls_model} attribute
5215 The @code{tls_model} attribute sets thread-local storage model
5216 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5217 overriding @option{-ftls-model=} command-line switch on a per-variable
5218 basis.
5219 The @var{tls_model} argument should be one of @code{global-dynamic},
5220 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5222 Not all targets support this attribute.
5224 @item unused
5225 This attribute, attached to a variable, means that the variable is meant
5226 to be possibly unused.  GCC does not produce a warning for this
5227 variable.
5229 @item used
5230 This attribute, attached to a variable with the static storage, means that
5231 the variable must be emitted even if it appears that the variable is not
5232 referenced.
5234 When applied to a static data member of a C++ class template, the
5235 attribute also means that the member is instantiated if the
5236 class itself is instantiated.
5238 @item vector_size (@var{bytes})
5239 This attribute specifies the vector size for the variable, measured in
5240 bytes.  For example, the declaration:
5242 @smallexample
5243 int foo __attribute__ ((vector_size (16)));
5244 @end smallexample
5246 @noindent
5247 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5248 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5249 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5251 This attribute is only applicable to integral and float scalars,
5252 although arrays, pointers, and function return values are allowed in
5253 conjunction with this construct.
5255 Aggregates with this attribute are invalid, even if they are of the same
5256 size as a corresponding scalar.  For example, the declaration:
5258 @smallexample
5259 struct S @{ int a; @};
5260 struct S  __attribute__ ((vector_size (16))) foo;
5261 @end smallexample
5263 @noindent
5264 is invalid even if the size of the structure is the same as the size of
5265 the @code{int}.
5267 @item selectany
5268 The @code{selectany} attribute causes an initialized global variable to
5269 have link-once semantics.  When multiple definitions of the variable are
5270 encountered by the linker, the first is selected and the remainder are
5271 discarded.  Following usage by the Microsoft compiler, the linker is told
5272 @emph{not} to warn about size or content differences of the multiple
5273 definitions.
5275 Although the primary usage of this attribute is for POD types, the
5276 attribute can also be applied to global C++ objects that are initialized
5277 by a constructor.  In this case, the static initialization and destruction
5278 code for the object is emitted in each translation defining the object,
5279 but the calls to the constructor and destructor are protected by a
5280 link-once guard variable.
5282 The @code{selectany} attribute is only available on Microsoft Windows
5283 targets.  You can use @code{__declspec (selectany)} as a synonym for
5284 @code{__attribute__ ((selectany))} for compatibility with other
5285 compilers.
5287 @item weak
5288 The @code{weak} attribute is described in @ref{Function Attributes}.
5290 @item dllimport
5291 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5293 @item dllexport
5294 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5296 @end table
5298 @anchor{AVR Variable Attributes}
5299 @subsection AVR Variable Attributes
5301 @table @code
5302 @item progmem
5303 @cindex @code{progmem} AVR variable attribute
5304 The @code{progmem} attribute is used on the AVR to place read-only
5305 data in the non-volatile program memory (flash). The @code{progmem}
5306 attribute accomplishes this by putting respective variables into a
5307 section whose name starts with @code{.progmem}.
5309 This attribute works similar to the @code{section} attribute
5310 but adds additional checking. Notice that just like the
5311 @code{section} attribute, @code{progmem} affects the location
5312 of the data but not how this data is accessed.
5314 In order to read data located with the @code{progmem} attribute
5315 (inline) assembler must be used.
5316 @smallexample
5317 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5318 #include <avr/pgmspace.h> 
5320 /* Locate var in flash memory */
5321 const int var[2] PROGMEM = @{ 1, 2 @};
5323 int read_var (int i)
5325     /* Access var[] by accessor macro from avr/pgmspace.h */
5326     return (int) pgm_read_word (& var[i]);
5328 @end smallexample
5330 AVR is a Harvard architecture processor and data and read-only data
5331 normally resides in the data memory (RAM).
5333 See also the @ref{AVR Named Address Spaces} section for
5334 an alternate way to locate and access data in flash memory.
5336 @item io
5337 @itemx io (@var{addr})
5338 Variables with the @code{io} attribute are used to address
5339 memory-mapped peripherals in the io address range.
5340 If an address is specified, the variable
5341 is assigned that address, and the value is interpreted as an
5342 address in the data address space.
5343 Example:
5345 @smallexample
5346 volatile int porta __attribute__((io (0x22)));
5347 @end smallexample
5349 The address specified in the address in the data address range.
5351 Otherwise, the variable it is not assigned an address, but the
5352 compiler will still use in/out instructions where applicable,
5353 assuming some other module assigns an address in the io address range.
5354 Example:
5356 @smallexample
5357 extern volatile int porta __attribute__((io));
5358 @end smallexample
5360 @item io_low
5361 @itemx io_low (@var{addr})
5362 This is like the @code{io} attribute, but additionally it informs the
5363 compiler that the object lies in the lower half of the I/O area,
5364 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5365 instructions.
5367 @item address
5368 @itemx address (@var{addr})
5369 Variables with the @code{address} attribute are used to address
5370 memory-mapped peripherals that may lie outside the io address range.
5372 @smallexample
5373 volatile int porta __attribute__((address (0x600)));
5374 @end smallexample
5376 @end table
5378 @subsection Blackfin Variable Attributes
5380 Three attributes are currently defined for the Blackfin.
5382 @table @code
5383 @item l1_data
5384 @itemx l1_data_A
5385 @itemx l1_data_B
5386 @cindex @code{l1_data} variable attribute
5387 @cindex @code{l1_data_A} variable attribute
5388 @cindex @code{l1_data_B} variable attribute
5389 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5390 Variables with @code{l1_data} attribute are put into the specific section
5391 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5392 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5393 attribute are put into the specific section named @code{.l1.data.B}.
5395 @item l2
5396 @cindex @code{l2} variable attribute
5397 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5398 Variables with @code{l2} attribute are put into the specific section
5399 named @code{.l2.data}.
5400 @end table
5402 @subsection M32R/D Variable Attributes
5404 One attribute is currently defined for the M32R/D@.
5406 @table @code
5407 @item model (@var{model-name})
5408 @cindex variable addressability on the M32R/D
5409 Use this attribute on the M32R/D to set the addressability of an object.
5410 The identifier @var{model-name} is one of @code{small}, @code{medium},
5411 or @code{large}, representing each of the code models.
5413 Small model objects live in the lower 16MB of memory (so that their
5414 addresses can be loaded with the @code{ld24} instruction).
5416 Medium and large model objects may live anywhere in the 32-bit address space
5417 (the compiler generates @code{seth/add3} instructions to load their
5418 addresses).
5419 @end table
5421 @anchor{MeP Variable Attributes}
5422 @subsection MeP Variable Attributes
5424 The MeP target has a number of addressing modes and busses.  The
5425 @code{near} space spans the standard memory space's first 16 megabytes
5426 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5427 The @code{based} space is a 128-byte region in the memory space that
5428 is addressed relative to the @code{$tp} register.  The @code{tiny}
5429 space is a 65536-byte region relative to the @code{$gp} register.  In
5430 addition to these memory regions, the MeP target has a separate 16-bit
5431 control bus which is specified with @code{cb} attributes.
5433 @table @code
5435 @item based
5436 Any variable with the @code{based} attribute is assigned to the
5437 @code{.based} section, and is accessed with relative to the
5438 @code{$tp} register.
5440 @item tiny
5441 Likewise, the @code{tiny} attribute assigned variables to the
5442 @code{.tiny} section, relative to the @code{$gp} register.
5444 @item near
5445 Variables with the @code{near} attribute are assumed to have addresses
5446 that fit in a 24-bit addressing mode.  This is the default for large
5447 variables (@code{-mtiny=4} is the default) but this attribute can
5448 override @code{-mtiny=} for small variables, or override @code{-ml}.
5450 @item far
5451 Variables with the @code{far} attribute are addressed using a full
5452 32-bit address.  Since this covers the entire memory space, this
5453 allows modules to make no assumptions about where variables might be
5454 stored.
5456 @item io
5457 @itemx io (@var{addr})
5458 Variables with the @code{io} attribute are used to address
5459 memory-mapped peripherals.  If an address is specified, the variable
5460 is assigned that address, else it is not assigned an address (it is
5461 assumed some other module assigns an address).  Example:
5463 @smallexample
5464 int timer_count __attribute__((io(0x123)));
5465 @end smallexample
5467 @item cb
5468 @itemx cb (@var{addr})
5469 Variables with the @code{cb} attribute are used to access the control
5470 bus, using special instructions.  @code{addr} indicates the control bus
5471 address.  Example:
5473 @smallexample
5474 int cpu_clock __attribute__((cb(0x123)));
5475 @end smallexample
5477 @end table
5479 @anchor{i386 Variable Attributes}
5480 @subsection i386 Variable Attributes
5482 Two attributes are currently defined for i386 configurations:
5483 @code{ms_struct} and @code{gcc_struct}
5485 @table @code
5486 @item ms_struct
5487 @itemx gcc_struct
5488 @cindex @code{ms_struct} attribute
5489 @cindex @code{gcc_struct} attribute
5491 If @code{packed} is used on a structure, or if bit-fields are used,
5492 it may be that the Microsoft ABI lays out the structure differently
5493 than the way GCC normally does.  Particularly when moving packed
5494 data between functions compiled with GCC and the native Microsoft compiler
5495 (either via function call or as data in a file), it may be necessary to access
5496 either format.
5498 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5499 compilers to match the native Microsoft compiler.
5501 The Microsoft structure layout algorithm is fairly simple with the exception
5502 of the bit-field packing.  
5503 The padding and alignment of members of structures and whether a bit-field 
5504 can straddle a storage-unit boundary are determine by these rules:
5506 @enumerate
5507 @item Structure members are stored sequentially in the order in which they are
5508 declared: the first member has the lowest memory address and the last member
5509 the highest.
5511 @item Every data object has an alignment requirement.  The alignment requirement
5512 for all data except structures, unions, and arrays is either the size of the
5513 object or the current packing size (specified with either the
5514 @code{aligned} attribute or the @code{pack} pragma),
5515 whichever is less.  For structures, unions, and arrays,
5516 the alignment requirement is the largest alignment requirement of its members.
5517 Every object is allocated an offset so that:
5519 @smallexample
5520 offset % alignment_requirement == 0
5521 @end smallexample
5523 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5524 unit if the integral types are the same size and if the next bit-field fits
5525 into the current allocation unit without crossing the boundary imposed by the
5526 common alignment requirements of the bit-fields.
5527 @end enumerate
5529 MSVC interprets zero-length bit-fields in the following ways:
5531 @enumerate
5532 @item If a zero-length bit-field is inserted between two bit-fields that
5533 are normally coalesced, the bit-fields are not coalesced.
5535 For example:
5537 @smallexample
5538 struct
5539  @{
5540    unsigned long bf_1 : 12;
5541    unsigned long : 0;
5542    unsigned long bf_2 : 12;
5543  @} t1;
5544 @end smallexample
5546 @noindent
5547 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5548 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5550 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5551 alignment of the zero-length bit-field is greater than the member that follows it,
5552 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5554 For example:
5556 @smallexample
5557 struct
5558  @{
5559    char foo : 4;
5560    short : 0;
5561    char bar;
5562  @} t2;
5564 struct
5565  @{
5566    char foo : 4;
5567    short : 0;
5568    double bar;
5569  @} t3;
5570 @end smallexample
5572 @noindent
5573 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5574 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5575 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5576 of the structure.
5578 Taking this into account, it is important to note the following:
5580 @enumerate
5581 @item If a zero-length bit-field follows a normal bit-field, the type of the
5582 zero-length bit-field may affect the alignment of the structure as whole. For
5583 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5584 normal bit-field, and is of type short.
5586 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5587 still affect the alignment of the structure:
5589 @smallexample
5590 struct
5591  @{
5592    char foo : 6;
5593    long : 0;
5594  @} t4;
5595 @end smallexample
5597 @noindent
5598 Here, @code{t4} takes up 4 bytes.
5599 @end enumerate
5601 @item Zero-length bit-fields following non-bit-field members are ignored:
5603 @smallexample
5604 struct
5605  @{
5606    char foo;
5607    long : 0;
5608    char bar;
5609  @} t5;
5610 @end smallexample
5612 @noindent
5613 Here, @code{t5} takes up 2 bytes.
5614 @end enumerate
5615 @end table
5617 @subsection PowerPC Variable Attributes
5619 Three attributes currently are defined for PowerPC configurations:
5620 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5622 For full documentation of the struct attributes please see the
5623 documentation in @ref{i386 Variable Attributes}.
5625 For documentation of @code{altivec} attribute please see the
5626 documentation in @ref{PowerPC Type Attributes}.
5628 @subsection SPU Variable Attributes
5630 The SPU supports the @code{spu_vector} attribute for variables.  For
5631 documentation of this attribute please see the documentation in
5632 @ref{SPU Type Attributes}.
5634 @subsection Xstormy16 Variable Attributes
5636 One attribute is currently defined for xstormy16 configurations:
5637 @code{below100}.
5639 @table @code
5640 @item below100
5641 @cindex @code{below100} attribute
5643 If a variable has the @code{below100} attribute (@code{BELOW100} is
5644 allowed also), GCC places the variable in the first 0x100 bytes of
5645 memory and use special opcodes to access it.  Such variables are
5646 placed in either the @code{.bss_below100} section or the
5647 @code{.data_below100} section.
5649 @end table
5651 @node Type Attributes
5652 @section Specifying Attributes of Types
5653 @cindex attribute of types
5654 @cindex type attributes
5656 The keyword @code{__attribute__} allows you to specify special
5657 attributes of @code{struct} and @code{union} types when you define
5658 such types.  This keyword is followed by an attribute specification
5659 inside double parentheses.  Eight attributes are currently defined for
5660 types: @code{aligned}, @code{packed}, @code{transparent_union},
5661 @code{scalar_storage_order}, @code{unused}, @code{deprecated},
5662 @code{visibility}, @code{may_alias} and @code{bnd_variable_size}.
5663 Other attributes are defined for functions (@pxref{Function Attributes}),
5664 labels (@pxref{Label  Attributes}) and for variables
5665 (@pxref{Variable Attributes}).
5667 You may also specify any one of these attributes with @samp{__}
5668 preceding and following its keyword.  This allows you to use these
5669 attributes in header files without being concerned about a possible
5670 macro of the same name.  For example, you may use @code{__aligned__}
5671 instead of @code{aligned}.
5673 You may specify type attributes in an enum, struct or union type
5674 declaration or definition, or for other types in a @code{typedef}
5675 declaration.
5677 For an enum, struct or union type, you may specify attributes either
5678 between the enum, struct or union tag and the name of the type, or
5679 just past the closing curly brace of the @emph{definition}.  The
5680 former syntax is preferred.
5682 @xref{Attribute Syntax}, for details of the exact syntax for using
5683 attributes.
5685 @table @code
5686 @cindex @code{aligned} attribute
5687 @item aligned (@var{alignment})
5688 This attribute specifies a minimum alignment (in bytes) for variables
5689 of the specified type.  For example, the declarations:
5691 @smallexample
5692 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5693 typedef int more_aligned_int __attribute__ ((aligned (8)));
5694 @end smallexample
5696 @noindent
5697 force the compiler to ensure (as far as it can) that each variable whose
5698 type is @code{struct S} or @code{more_aligned_int} is allocated and
5699 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5700 variables of type @code{struct S} aligned to 8-byte boundaries allows
5701 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5702 store) instructions when copying one variable of type @code{struct S} to
5703 another, thus improving run-time efficiency.
5705 Note that the alignment of any given @code{struct} or @code{union} type
5706 is required by the ISO C standard to be at least a perfect multiple of
5707 the lowest common multiple of the alignments of all of the members of
5708 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5709 effectively adjust the alignment of a @code{struct} or @code{union}
5710 type by attaching an @code{aligned} attribute to any one of the members
5711 of such a type, but the notation illustrated in the example above is a
5712 more obvious, intuitive, and readable way to request the compiler to
5713 adjust the alignment of an entire @code{struct} or @code{union} type.
5715 As in the preceding example, you can explicitly specify the alignment
5716 (in bytes) that you wish the compiler to use for a given @code{struct}
5717 or @code{union} type.  Alternatively, you can leave out the alignment factor
5718 and just ask the compiler to align a type to the maximum
5719 useful alignment for the target machine you are compiling for.  For
5720 example, you could write:
5722 @smallexample
5723 struct S @{ short f[3]; @} __attribute__ ((aligned));
5724 @end smallexample
5726 Whenever you leave out the alignment factor in an @code{aligned}
5727 attribute specification, the compiler automatically sets the alignment
5728 for the type to the largest alignment that is ever used for any data
5729 type on the target machine you are compiling for.  Doing this can often
5730 make copy operations more efficient, because the compiler can use
5731 whatever instructions copy the biggest chunks of memory when performing
5732 copies to or from the variables that have types that you have aligned
5733 this way.
5735 In the example above, if the size of each @code{short} is 2 bytes, then
5736 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5737 power of two that is greater than or equal to that is 8, so the
5738 compiler sets the alignment for the entire @code{struct S} type to 8
5739 bytes.
5741 Note that although you can ask the compiler to select a time-efficient
5742 alignment for a given type and then declare only individual stand-alone
5743 objects of that type, the compiler's ability to select a time-efficient
5744 alignment is primarily useful only when you plan to create arrays of
5745 variables having the relevant (efficiently aligned) type.  If you
5746 declare or use arrays of variables of an efficiently-aligned type, then
5747 it is likely that your program also does pointer arithmetic (or
5748 subscripting, which amounts to the same thing) on pointers to the
5749 relevant type, and the code that the compiler generates for these
5750 pointer arithmetic operations is often more efficient for
5751 efficiently-aligned types than for other types.
5753 The @code{aligned} attribute can only increase the alignment; but you
5754 can decrease it by specifying @code{packed} as well.  See below.
5756 Note that the effectiveness of @code{aligned} attributes may be limited
5757 by inherent limitations in your linker.  On many systems, the linker is
5758 only able to arrange for variables to be aligned up to a certain maximum
5759 alignment.  (For some linkers, the maximum supported alignment may
5760 be very very small.)  If your linker is only able to align variables
5761 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5762 in an @code{__attribute__} still only provides you with 8-byte
5763 alignment.  See your linker documentation for further information.
5765 @item packed
5766 This attribute, attached to @code{struct} or @code{union} type
5767 definition, specifies that each member (other than zero-width bit-fields)
5768 of the structure or union is placed to minimize the memory required.  When
5769 attached to an @code{enum} definition, it indicates that the smallest
5770 integral type should be used.
5772 @opindex fshort-enums
5773 Specifying this attribute for @code{struct} and @code{union} types is
5774 equivalent to specifying the @code{packed} attribute on each of the
5775 structure or union members.  Specifying the @option{-fshort-enums}
5776 flag on the line is equivalent to specifying the @code{packed}
5777 attribute on all @code{enum} definitions.
5779 In the following example @code{struct my_packed_struct}'s members are
5780 packed closely together, but the internal layout of its @code{s} member
5781 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5782 be packed too.
5784 @smallexample
5785 struct my_unpacked_struct
5786  @{
5787     char c;
5788     int i;
5789  @};
5791 struct __attribute__ ((__packed__)) my_packed_struct
5792   @{
5793      char c;
5794      int  i;
5795      struct my_unpacked_struct s;
5796   @};
5797 @end smallexample
5799 You may only specify this attribute on the definition of an @code{enum},
5800 @code{struct} or @code{union}, not on a @code{typedef} that does not
5801 also define the enumerated type, structure or union.
5803 @item transparent_union
5804 @cindex @code{transparent_union} attribute
5806 This attribute, attached to a @code{union} type definition, indicates
5807 that any function parameter having that union type causes calls to that
5808 function to be treated in a special way.
5810 First, the argument corresponding to a transparent union type can be of
5811 any type in the union; no cast is required.  Also, if the union contains
5812 a pointer type, the corresponding argument can be a null pointer
5813 constant or a void pointer expression; and if the union contains a void
5814 pointer type, the corresponding argument can be any pointer expression.
5815 If the union member type is a pointer, qualifiers like @code{const} on
5816 the referenced type must be respected, just as with normal pointer
5817 conversions.
5819 Second, the argument is passed to the function using the calling
5820 conventions of the first member of the transparent union, not the calling
5821 conventions of the union itself.  All members of the union must have the
5822 same machine representation; this is necessary for this argument passing
5823 to work properly.
5825 Transparent unions are designed for library functions that have multiple
5826 interfaces for compatibility reasons.  For example, suppose the
5827 @code{wait} function must accept either a value of type @code{int *} to
5828 comply with POSIX, or a value of type @code{union wait *} to comply with
5829 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5830 @code{wait} would accept both kinds of arguments, but it would also
5831 accept any other pointer type and this would make argument type checking
5832 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5833 as follows:
5835 @smallexample
5836 typedef union __attribute__ ((__transparent_union__))
5837   @{
5838     int *__ip;
5839     union wait *__up;
5840   @} wait_status_ptr_t;
5842 pid_t wait (wait_status_ptr_t);
5843 @end smallexample
5845 @noindent
5846 This interface allows either @code{int *} or @code{union wait *}
5847 arguments to be passed, using the @code{int *} calling convention.
5848 The program can call @code{wait} with arguments of either type:
5850 @smallexample
5851 int w1 () @{ int w; return wait (&w); @}
5852 int w2 () @{ union wait w; return wait (&w); @}
5853 @end smallexample
5855 @noindent
5856 With this interface, @code{wait}'s implementation might look like this:
5858 @smallexample
5859 pid_t wait (wait_status_ptr_t p)
5861   return waitpid (-1, p.__ip, 0);
5863 @end smallexample
5865 @item scalar_storage_order ("@var{endianness}")
5866 @cindex @code{scalar_storage_order} attribute
5867 When attached to a @code{union} or a @code{struct}, this attribute sets
5868 the storage order, aka endianness, of the scalar fields of the type, as
5869 well as the array fields whose component is scalar.  The supported
5870 endianness are @code{big-endian} and @code{little-endian}.  The attribute
5871 has no effects on fields which are themselves a @code{union}, a @code{struct}
5872 or an array whose component is a @code{union} or a @code{struct}, and it is
5873 possible to have fields with a different scalar storage order than the
5874 enclosing type.
5876 This attribute is supported only for targets that use a uniform default
5877 scalar storage order (fortunately, most of them), i.e. targets that store
5878 the scalars either all in big-endian or all in little-endian.
5880 Additional restrictions are enforced for types with the reverse scalar
5881 storage order with regard to the scalar storage order of the target:
5883 @itemize
5884 @item Taking the address of a scalar field of a @code{union} or a
5885 @code{struct} with reverse scalar storage order is illegal and will
5886 yield an error
5887 @item Taking the address of an array field, whose component is scalar, of
5888 a @code{union} or a @code{struct} with reverse scalar storage order is
5889 permitted but will yield a warning, unless @option{-Wno-scalar-storage-order}
5890 is specified
5891 @item Taking the address of a @code{union} or a @code{struct} with reverse
5892 scalar storage order is permitted
5893 @end itemize
5895 These restrictions exist because the storage order attribute is lost when
5896 the address of a scalar or the address of an array with scalar component
5897 is taken, so storing indirectly through this address will generally not work.
5898 The second case is nevertheless allowed to be able to perform a block copy
5899 from or to the array.
5901 @item unused
5902 When attached to a type (including a @code{union} or a @code{struct}),
5903 this attribute means that variables of that type are meant to appear
5904 possibly unused.  GCC does not produce a warning for any variables of
5905 that type, even if the variable appears to do nothing.  This is often
5906 the case with lock or thread classes, which are usually defined and then
5907 not referenced, but contain constructors and destructors that have
5908 nontrivial bookkeeping functions.
5910 @item deprecated
5911 @itemx deprecated (@var{msg})
5912 The @code{deprecated} attribute results in a warning if the type
5913 is used anywhere in the source file.  This is useful when identifying
5914 types that are expected to be removed in a future version of a program.
5915 If possible, the warning also includes the location of the declaration
5916 of the deprecated type, to enable users to easily find further
5917 information about why the type is deprecated, or what they should do
5918 instead.  Note that the warnings only occur for uses and then only
5919 if the type is being applied to an identifier that itself is not being
5920 declared as deprecated.
5922 @smallexample
5923 typedef int T1 __attribute__ ((deprecated));
5924 T1 x;
5925 typedef T1 T2;
5926 T2 y;
5927 typedef T1 T3 __attribute__ ((deprecated));
5928 T3 z __attribute__ ((deprecated));
5929 @end smallexample
5931 @noindent
5932 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5933 warning is issued for line 4 because T2 is not explicitly
5934 deprecated.  Line 5 has no warning because T3 is explicitly
5935 deprecated.  Similarly for line 6.  The optional @var{msg}
5936 argument, which must be a string, is printed in the warning if
5937 present.
5939 The @code{deprecated} attribute can also be used for functions and
5940 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5942 @item may_alias
5943 Accesses through pointers to types with this attribute are not subject
5944 to type-based alias analysis, but are instead assumed to be able to alias
5945 any other type of objects.
5946 In the context of section 6.5 paragraph 7 of the C99 standard,
5947 an lvalue expression
5948 dereferencing such a pointer is treated like having a character type.
5949 See @option{-fstrict-aliasing} for more information on aliasing issues.
5950 This extension exists to support some vector APIs, in which pointers to
5951 one vector type are permitted to alias pointers to a different vector type.
5953 Note that an object of a type with this attribute does not have any
5954 special semantics.
5956 Example of use:
5958 @smallexample
5959 typedef short __attribute__((__may_alias__)) short_a;
5962 main (void)
5964   int a = 0x12345678;
5965   short_a *b = (short_a *) &a;
5967   b[1] = 0;
5969   if (a == 0x12345678)
5970     abort();
5972   exit(0);
5974 @end smallexample
5976 @noindent
5977 If you replaced @code{short_a} with @code{short} in the variable
5978 declaration, the above program would abort when compiled with
5979 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5980 above in recent GCC versions.
5982 @item visibility
5983 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5984 applied to class, struct, union and enum types.  Unlike other type
5985 attributes, the attribute must appear between the initial keyword and
5986 the name of the type; it cannot appear after the body of the type.
5988 Note that the type visibility is applied to vague linkage entities
5989 associated with the class (vtable, typeinfo node, etc.).  In
5990 particular, if a class is thrown as an exception in one shared object
5991 and caught in another, the class must have default visibility.
5992 Otherwise the two shared objects are unable to use the same
5993 typeinfo node and exception handling will break.
5995 @item designated_init
5996 This attribute may only be applied to structure types.  It indicates
5997 that any initialization of an object of this type must use designated
5998 initializers rather than positional initializers.  The intent of this
5999 attribute is to allow the programmer to indicate that a structure's
6000 layout may change, and that therefore relying on positional
6001 initialization will result in future breakage.
6003 GCC emits warnings based on this attribute by default; use
6004 @option{-Wno-designated-init} to suppress them.
6006 @item bnd_variable_size
6007 When applied to a structure field, this attribute tells Pointer
6008 Bounds Checker that the size of this field should not be computed
6009 using static type information.  It may be used to mark variable
6010 sized static array fields placed at the end of a structure.
6012 @smallexample
6013 struct S
6015   int size;
6016   char data[1];
6018 S *p = (S *)malloc (sizeof(S) + 100);
6019 p->data[10] = 0; //Bounds violation
6020 @end smallexample
6022 By using an attribute for a field we may avoid bound violation
6023 we most probably do not want to see:
6025 @smallexample
6026 struct S
6028   int size;
6029   char data[1] __attribute__((bnd_variable_size));
6031 S *p = (S *)malloc (sizeof(S) + 100);
6032 p->data[10] = 0; //OK
6033 @end smallexample
6035 @end table
6037 To specify multiple attributes, separate them by commas within the
6038 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6039 packed))}.
6041 @subsection ARM Type Attributes
6043 On those ARM targets that support @code{dllimport} (such as Symbian
6044 OS), you can use the @code{notshared} attribute to indicate that the
6045 virtual table and other similar data for a class should not be
6046 exported from a DLL@.  For example:
6048 @smallexample
6049 class __declspec(notshared) C @{
6050 public:
6051   __declspec(dllimport) C();
6052   virtual void f();
6055 __declspec(dllexport)
6056 C::C() @{@}
6057 @end smallexample
6059 @noindent
6060 In this code, @code{C::C} is exported from the current DLL, but the
6061 virtual table for @code{C} is not exported.  (You can use
6062 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6063 most Symbian OS code uses @code{__declspec}.)
6065 @anchor{MeP Type Attributes}
6066 @subsection MeP Type Attributes
6068 Many of the MeP variable attributes may be applied to types as well.
6069 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6070 @code{far} attributes may be applied to either.  The @code{io} and
6071 @code{cb} attributes may not be applied to types.
6073 @anchor{i386 Type Attributes}
6074 @subsection i386 Type Attributes
6076 Two attributes are currently defined for i386 configurations:
6077 @code{ms_struct} and @code{gcc_struct}.
6079 @table @code
6081 @item ms_struct
6082 @itemx gcc_struct
6083 @cindex @code{ms_struct}
6084 @cindex @code{gcc_struct}
6086 If @code{packed} is used on a structure, or if bit-fields are used
6087 it may be that the Microsoft ABI packs them differently
6088 than GCC normally packs them.  Particularly when moving packed
6089 data between functions compiled with GCC and the native Microsoft compiler
6090 (either via function call or as data in a file), it may be necessary to access
6091 either format.
6093 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
6094 compilers to match the native Microsoft compiler.
6095 @end table
6097 @anchor{PowerPC Type Attributes}
6098 @subsection PowerPC Type Attributes
6100 Three attributes currently are defined for PowerPC configurations:
6101 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6103 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6104 attributes please see the documentation in @ref{i386 Type Attributes}.
6106 The @code{altivec} attribute allows one to declare AltiVec vector data
6107 types supported by the AltiVec Programming Interface Manual.  The
6108 attribute requires an argument to specify one of three vector types:
6109 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6110 and @code{bool__} (always followed by unsigned).
6112 @smallexample
6113 __attribute__((altivec(vector__)))
6114 __attribute__((altivec(pixel__))) unsigned short
6115 __attribute__((altivec(bool__))) unsigned
6116 @end smallexample
6118 These attributes mainly are intended to support the @code{__vector},
6119 @code{__pixel}, and @code{__bool} AltiVec keywords.
6121 @anchor{SPU Type Attributes}
6122 @subsection SPU Type Attributes
6124 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6125 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6126 Language Extensions Specification.  It is intended to support the
6127 @code{__vector} keyword.
6129 @node Alignment
6130 @section Inquiring on Alignment of Types or Variables
6131 @cindex alignment
6132 @cindex type alignment
6133 @cindex variable alignment
6135 The keyword @code{__alignof__} allows you to inquire about how an object
6136 is aligned, or the minimum alignment usually required by a type.  Its
6137 syntax is just like @code{sizeof}.
6139 For example, if the target machine requires a @code{double} value to be
6140 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6141 This is true on many RISC machines.  On more traditional machine
6142 designs, @code{__alignof__ (double)} is 4 or even 2.
6144 Some machines never actually require alignment; they allow reference to any
6145 data type even at an odd address.  For these machines, @code{__alignof__}
6146 reports the smallest alignment that GCC gives the data type, usually as
6147 mandated by the target ABI.
6149 If the operand of @code{__alignof__} is an lvalue rather than a type,
6150 its value is the required alignment for its type, taking into account
6151 any minimum alignment specified with GCC's @code{__attribute__}
6152 extension (@pxref{Variable Attributes}).  For example, after this
6153 declaration:
6155 @smallexample
6156 struct foo @{ int x; char y; @} foo1;
6157 @end smallexample
6159 @noindent
6160 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6161 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6163 It is an error to ask for the alignment of an incomplete type.
6166 @node Inline
6167 @section An Inline Function is As Fast As a Macro
6168 @cindex inline functions
6169 @cindex integrating function code
6170 @cindex open coding
6171 @cindex macros, inline alternative
6173 By declaring a function inline, you can direct GCC to make
6174 calls to that function faster.  One way GCC can achieve this is to
6175 integrate that function's code into the code for its callers.  This
6176 makes execution faster by eliminating the function-call overhead; in
6177 addition, if any of the actual argument values are constant, their
6178 known values may permit simplifications at compile time so that not
6179 all of the inline function's code needs to be included.  The effect on
6180 code size is less predictable; object code may be larger or smaller
6181 with function inlining, depending on the particular case.  You can
6182 also direct GCC to try to integrate all ``simple enough'' functions
6183 into their callers with the option @option{-finline-functions}.
6185 GCC implements three different semantics of declaring a function
6186 inline.  One is available with @option{-std=gnu89} or
6187 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6188 on all inline declarations, another when
6189 @option{-std=c99}, @option{-std=c11},
6190 @option{-std=gnu99} or @option{-std=gnu11}
6191 (without @option{-fgnu89-inline}), and the third
6192 is used when compiling C++.
6194 To declare a function inline, use the @code{inline} keyword in its
6195 declaration, like this:
6197 @smallexample
6198 static inline int
6199 inc (int *a)
6201   return (*a)++;
6203 @end smallexample
6205 If you are writing a header file to be included in ISO C90 programs, write
6206 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6208 The three types of inlining behave similarly in two important cases:
6209 when the @code{inline} keyword is used on a @code{static} function,
6210 like the example above, and when a function is first declared without
6211 using the @code{inline} keyword and then is defined with
6212 @code{inline}, like this:
6214 @smallexample
6215 extern int inc (int *a);
6216 inline int
6217 inc (int *a)
6219   return (*a)++;
6221 @end smallexample
6223 In both of these common cases, the program behaves the same as if you
6224 had not used the @code{inline} keyword, except for its speed.
6226 @cindex inline functions, omission of
6227 @opindex fkeep-inline-functions
6228 When a function is both inline and @code{static}, if all calls to the
6229 function are integrated into the caller, and the function's address is
6230 never used, then the function's own assembler code is never referenced.
6231 In this case, GCC does not actually output assembler code for the
6232 function, unless you specify the option @option{-fkeep-inline-functions}.
6233 Some calls cannot be integrated for various reasons (in particular,
6234 calls that precede the function's definition cannot be integrated, and
6235 neither can recursive calls within the definition).  If there is a
6236 nonintegrated call, then the function is compiled to assembler code as
6237 usual.  The function must also be compiled as usual if the program
6238 refers to its address, because that can't be inlined.
6240 @opindex Winline
6241 Note that certain usages in a function definition can make it unsuitable
6242 for inline substitution.  Among these usages are: variadic functions, use of
6243 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6244 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6245 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6246 warns when a function marked @code{inline} could not be substituted,
6247 and gives the reason for the failure.
6249 @cindex automatic @code{inline} for C++ member fns
6250 @cindex @code{inline} automatic for C++ member fns
6251 @cindex member fns, automatically @code{inline}
6252 @cindex C++ member fns, automatically @code{inline}
6253 @opindex fno-default-inline
6254 As required by ISO C++, GCC considers member functions defined within
6255 the body of a class to be marked inline even if they are
6256 not explicitly declared with the @code{inline} keyword.  You can
6257 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6258 Options,,Options Controlling C++ Dialect}.
6260 GCC does not inline any functions when not optimizing unless you specify
6261 the @samp{always_inline} attribute for the function, like this:
6263 @smallexample
6264 /* @r{Prototype.}  */
6265 inline void foo (const char) __attribute__((always_inline));
6266 @end smallexample
6268 The remainder of this section is specific to GNU C90 inlining.
6270 @cindex non-static inline function
6271 When an inline function is not @code{static}, then the compiler must assume
6272 that there may be calls from other source files; since a global symbol can
6273 be defined only once in any program, the function must not be defined in
6274 the other source files, so the calls therein cannot be integrated.
6275 Therefore, a non-@code{static} inline function is always compiled on its
6276 own in the usual fashion.
6278 If you specify both @code{inline} and @code{extern} in the function
6279 definition, then the definition is used only for inlining.  In no case
6280 is the function compiled on its own, not even if you refer to its
6281 address explicitly.  Such an address becomes an external reference, as
6282 if you had only declared the function, and had not defined it.
6284 This combination of @code{inline} and @code{extern} has almost the
6285 effect of a macro.  The way to use it is to put a function definition in
6286 a header file with these keywords, and put another copy of the
6287 definition (lacking @code{inline} and @code{extern}) in a library file.
6288 The definition in the header file causes most calls to the function
6289 to be inlined.  If any uses of the function remain, they refer to
6290 the single copy in the library.
6292 @node Volatiles
6293 @section When is a Volatile Object Accessed?
6294 @cindex accessing volatiles
6295 @cindex volatile read
6296 @cindex volatile write
6297 @cindex volatile access
6299 C has the concept of volatile objects.  These are normally accessed by
6300 pointers and used for accessing hardware or inter-thread
6301 communication.  The standard encourages compilers to refrain from
6302 optimizations concerning accesses to volatile objects, but leaves it
6303 implementation defined as to what constitutes a volatile access.  The
6304 minimum requirement is that at a sequence point all previous accesses
6305 to volatile objects have stabilized and no subsequent accesses have
6306 occurred.  Thus an implementation is free to reorder and combine
6307 volatile accesses that occur between sequence points, but cannot do
6308 so for accesses across a sequence point.  The use of volatile does
6309 not allow you to violate the restriction on updating objects multiple
6310 times between two sequence points.
6312 Accesses to non-volatile objects are not ordered with respect to
6313 volatile accesses.  You cannot use a volatile object as a memory
6314 barrier to order a sequence of writes to non-volatile memory.  For
6315 instance:
6317 @smallexample
6318 int *ptr = @var{something};
6319 volatile int vobj;
6320 *ptr = @var{something};
6321 vobj = 1;
6322 @end smallexample
6324 @noindent
6325 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6326 that the write to @var{*ptr} occurs by the time the update
6327 of @var{vobj} happens.  If you need this guarantee, you must use
6328 a stronger memory barrier such as:
6330 @smallexample
6331 int *ptr = @var{something};
6332 volatile int vobj;
6333 *ptr = @var{something};
6334 asm volatile ("" : : : "memory");
6335 vobj = 1;
6336 @end smallexample
6338 A scalar volatile object is read when it is accessed in a void context:
6340 @smallexample
6341 volatile int *src = @var{somevalue};
6342 *src;
6343 @end smallexample
6345 Such expressions are rvalues, and GCC implements this as a
6346 read of the volatile object being pointed to.
6348 Assignments are also expressions and have an rvalue.  However when
6349 assigning to a scalar volatile, the volatile object is not reread,
6350 regardless of whether the assignment expression's rvalue is used or
6351 not.  If the assignment's rvalue is used, the value is that assigned
6352 to the volatile object.  For instance, there is no read of @var{vobj}
6353 in all the following cases:
6355 @smallexample
6356 int obj;
6357 volatile int vobj;
6358 vobj = @var{something};
6359 obj = vobj = @var{something};
6360 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6361 obj = (@var{something}, vobj = @var{anotherthing});
6362 @end smallexample
6364 If you need to read the volatile object after an assignment has
6365 occurred, you must use a separate expression with an intervening
6366 sequence point.
6368 As bit-fields are not individually addressable, volatile bit-fields may
6369 be implicitly read when written to, or when adjacent bit-fields are
6370 accessed.  Bit-field operations may be optimized such that adjacent
6371 bit-fields are only partially accessed, if they straddle a storage unit
6372 boundary.  For these reasons it is unwise to use volatile bit-fields to
6373 access hardware.
6375 @node Using Assembly Language with C
6376 @section How to Use Inline Assembly Language in C Code
6378 GCC provides various extensions that allow you to embed assembler within 
6379 C code.
6381 @menu
6382 * Basic Asm::          Inline assembler with no operands.
6383 * Extended Asm::       Inline assembler with operands.
6384 * Constraints::        Constraints for @code{asm} operands
6385 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6386 * Explicit Reg Vars::  Defining variables residing in specified registers.
6387 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6388 @end menu
6390 @node Basic Asm
6391 @subsection Basic Asm --- Assembler Instructions with No Operands
6392 @cindex basic @code{asm}
6394 The @code{asm} keyword allows you to embed assembler instructions within 
6395 C code.
6397 @example
6398 asm [ volatile ] ( AssemblerInstructions )
6399 @end example
6401 To create headers compatible with ISO C, write @code{__asm__} instead of 
6402 @code{asm} (@pxref{Alternate Keywords}).
6404 By definition, a Basic @code{asm} statement is one with no operands. 
6405 @code{asm} statements that contain one or more colons (used to delineate 
6406 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6407 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6409 @subsubheading Qualifiers
6410 @emph{volatile}
6412 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6413 implicitly volatile.
6415 @subsubheading Parameters
6416 @emph{AssemblerInstructions}
6418 This is a literal string that specifies the assembler code. The string can 
6419 contain any instructions recognized by the assembler, including directives. 
6420 GCC does not parse the assembler instructions themselves and 
6421 does not know what they mean or even whether they are valid assembler input. 
6422 The compiler copies it verbatim to the assembly language output file, without 
6423 processing dialects or any of the "%" operators that are available with
6424 Extended @code{asm}. This results in minor differences between Basic 
6425 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6426 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6427 @code{asm}.
6429 You may place multiple assembler instructions together in a single @code{asm} 
6430 string, separated by the characters normally used in assembly code for the 
6431 system. A combination that works in most places is a newline to break the 
6432 line, plus a tab character (written as "\n\t").
6433 Some assemblers allow semicolons as a line separator. However, 
6434 note that some assembler dialects use semicolons to start a comment. 
6436 Do not expect a sequence of @code{asm} statements to remain perfectly 
6437 consecutive after compilation. If certain instructions need to remain 
6438 consecutive in the output, put them in a single multi-instruction asm 
6439 statement. Note that GCC's optimizers can move @code{asm} statements 
6440 relative to other code, including across jumps.
6442 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6443 GCC does not know about these jumps, and therefore cannot take 
6444 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6445 labels are only supported in Extended @code{asm}.
6447 @subsubheading Remarks
6448 Using Extended @code{asm} will typically produce smaller, safer, and more 
6449 efficient code, and in most cases it is a better solution. When writing 
6450 inline assembly language outside of C functions, however, you must use Basic 
6451 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6452 Functions declared with the @code{naked} attribute also require Basic 
6453 @code{asm} (@pxref{Function Attributes}).
6455 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6456 assembly code when optimizing. This can lead to unexpected duplicate 
6457 symbol errors during compilation if your assembly code defines symbols or 
6458 labels.
6460 Safely accessing C data and calling functions from Basic @code{asm} is more 
6461 complex than it may appear. To access C data, it is better to use Extended 
6462 @code{asm}.
6464 Since GCC does not parse the AssemblerInstructions, it has no 
6465 visibility of any symbols it references. This may result in GCC discarding 
6466 those symbols as unreferenced.
6468 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6469 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6470 as though they used a "memory" clobber (@pxref{Clobbers}).
6472 All Basic @code{asm} blocks use the assembler dialect specified by the 
6473 @option{-masm} command-line option. Basic @code{asm} provides no
6474 mechanism to provide different assembler strings for different dialects.
6476 Here is an example of Basic @code{asm} for i386:
6478 @example
6479 /* Note that this code will not compile with -masm=intel */
6480 #define DebugBreak() asm("int $3")
6481 @end example
6483 @node Extended Asm
6484 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6485 @cindex @code{asm} keyword
6486 @cindex extended @code{asm}
6487 @cindex assembler instructions
6489 The @code{asm} keyword allows you to embed assembler instructions within C 
6490 code. With Extended @code{asm} you can read and write C variables from 
6491 assembler and perform jumps from assembler code to C labels.
6493 @example
6494 @ifhtml
6495 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6497 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6498 @end ifhtml
6499 @ifnothtml
6500 asm [volatile] ( AssemblerTemplate 
6501                  : [OutputOperands] 
6502                  [ : [InputOperands] 
6503                  [ : [Clobbers] ] ])
6505 asm [volatile] goto ( AssemblerTemplate 
6506                       : 
6507                       : [InputOperands] 
6508                       : [Clobbers] 
6509                       : GotoLabels)
6510 @end ifnothtml
6511 @end example
6513 To create headers compatible with ISO C, write @code{__asm__} instead of 
6514 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6515 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6517 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6518 operands. To separate the classes of operands, you use colons. Basic 
6519 @code{asm} statements contain no colons. (So, for example, 
6520 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6521 Extended @code{asm}. @pxref{Basic Asm}.)
6523 @subsubheading Qualifiers
6524 @emph{volatile}
6526 The typical use of Extended @code{asm} statements is to manipulate input 
6527 values to produce output values. However, your @code{asm} statements may 
6528 also produce side effects. If so, you may need to use the @code{volatile} 
6529 qualifier to disable certain optimizations. @xref{Volatile}.
6531 @emph{goto}
6533 This qualifier informs the compiler that the @code{asm} statement may 
6534 perform a jump to one of the labels listed in the GotoLabels section. 
6535 @xref{GotoLabels}.
6537 @subsubheading Parameters
6538 @emph{AssemblerTemplate}
6540 This is a literal string that contains the assembler code. It is a 
6541 combination of fixed text and tokens that refer to the input, output, 
6542 and goto parameters. @xref{AssemblerTemplate}.
6544 @emph{OutputOperands}
6546 A comma-separated list of the C variables modified by the instructions in the 
6547 AssemblerTemplate. @xref{OutputOperands}.
6549 @emph{InputOperands}
6551 A comma-separated list of C expressions read by the instructions in the 
6552 AssemblerTemplate. @xref{InputOperands}.
6554 @emph{Clobbers}
6556 A comma-separated list of registers or other values changed by the 
6557 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6559 @emph{GotoLabels}
6561 When you are using the @code{goto} form of @code{asm}, this section contains 
6562 the list of all C labels to which the AssemblerTemplate may jump. 
6563 @xref{GotoLabels}.
6565 @subsubheading Remarks
6566 The @code{asm} statement allows you to include assembly instructions directly 
6567 within C code. This may help you to maximize performance in time-sensitive 
6568 code or to access assembly instructions that are not readily available to C 
6569 programs.
6571 Note that Extended @code{asm} statements must be inside a function. Only 
6572 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6573 Functions declared with the @code{naked} attribute also require Basic 
6574 @code{asm} (@pxref{Function Attributes}).
6576 While the uses of @code{asm} are many and varied, it may help to think of an 
6577 @code{asm} statement as a series of low-level instructions that convert input 
6578 parameters to output parameters. So a simple (if not particularly useful) 
6579 example for i386 using @code{asm} might look like this:
6581 @example
6582 int src = 1;
6583 int dst;   
6585 asm ("mov %1, %0\n\t"
6586     "add $1, %0"
6587     : "=r" (dst) 
6588     : "r" (src));
6590 printf("%d\n", dst);
6591 @end example
6593 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6595 @anchor{Volatile}
6596 @subsubsection Volatile
6597 @cindex volatile @code{asm}
6598 @cindex @code{asm} volatile
6600 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6601 there is no need for the output variables. Also, the optimizers may move 
6602 code out of loops if they believe that the code will always return the same 
6603 result (i.e. none of its input values change between calls). Using the 
6604 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6605 that have no output operands are implicitly volatile.
6607 Examples:
6609 This i386 code demonstrates a case that does not use (or require) the 
6610 @code{volatile} qualifier. If it is performing assertion checking, this code 
6611 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6612 unreferenced by any code. As a result, the optimizers can discard the 
6613 @code{asm} statement, which in turn removes the need for the entire 
6614 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6615 isn't needed you allow the optimizers to produce the most efficient code 
6616 possible.
6618 @example
6619 void DoCheck(uint32_t dwSomeValue)
6621    uint32_t dwRes;
6623    // Assumes dwSomeValue is not zero.
6624    asm ("bsfl %1,%0"
6625      : "=r" (dwRes)
6626      : "r" (dwSomeValue)
6627      : "cc");
6629    assert(dwRes > 3);
6631 @end example
6633 The next example shows a case where the optimizers can recognize that the input 
6634 (@var{dwSomeValue}) never changes during the execution of the function and can 
6635 therefore move the @code{asm} outside the loop to produce more efficient code. 
6636 Again, using @code{volatile} disables this type of optimization.
6638 @example
6639 void do_print(uint32_t dwSomeValue)
6641    uint32_t dwRes;
6643    for (uint32_t x=0; x < 5; x++)
6644    @{
6645       // Assumes dwSomeValue is not zero.
6646       asm ("bsfl %1,%0"
6647         : "=r" (dwRes)
6648         : "r" (dwSomeValue)
6649         : "cc");
6651       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6652    @}
6654 @end example
6656 The following example demonstrates a case where you need to use the 
6657 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6658 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6659 the optimizers might assume that the @code{asm} block will always return the 
6660 same value and therefore optimize away the second call.
6662 @example
6663 uint64_t msr;
6665 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6666         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6667         "or %%rdx, %0"        // 'Or' in the lower bits.
6668         : "=a" (msr)
6669         : 
6670         : "rdx");
6672 printf("msr: %llx\n", msr);
6674 // Do other work...
6676 // Reprint the timestamp
6677 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6678         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6679         "or %%rdx, %0"        // 'Or' in the lower bits.
6680         : "=a" (msr)
6681         : 
6682         : "rdx");
6684 printf("msr: %llx\n", msr);
6685 @end example
6687 GCC's optimizers will not treat this code like the non-volatile code in the 
6688 earlier examples. They do not move it out of loops or omit it on the 
6689 assumption that the result from a previous call is still valid.
6691 Note that the compiler can move even volatile @code{asm} instructions relative 
6692 to other code, including across jump instructions. For example, on many 
6693 targets there is a system register that controls the rounding mode of 
6694 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6695 following PowerPC example, will not work reliably.
6697 @example
6698 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6699 sum = x + y;
6700 @end example
6702 The compiler may move the addition back before the volatile @code{asm}. To 
6703 make it work as expected, add an artificial dependency to the @code{asm} by 
6704 referencing a variable in the subsequent code, for example: 
6706 @example
6707 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6708 sum = x + y;
6709 @end example
6711 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6712 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6713 errors during compilation if your asm code defines symbols or labels. Using %= 
6714 (@pxref{AssemblerTemplate}) may help resolve this problem.
6716 @anchor{AssemblerTemplate}
6717 @subsubsection Assembler Template
6718 @cindex @code{asm} assembler template
6720 An assembler template is a literal string containing assembler instructions. 
6721 The compiler will replace any references to inputs, outputs, and goto labels 
6722 in the template, and then output the resulting string to the assembler. The 
6723 string can contain any instructions recognized by the assembler, including 
6724 directives. GCC does not parse the assembler instructions 
6725 themselves and does not know what they mean or even whether they are valid 
6726 assembler input. However, it does count the statements 
6727 (@pxref{Size of an asm}).
6729 You may place multiple assembler instructions together in a single @code{asm} 
6730 string, separated by the characters normally used in assembly code for the 
6731 system. A combination that works in most places is a newline to break the 
6732 line, plus a tab character to move to the instruction field (written as 
6733 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6734 that some assembler dialects use semicolons to start a comment. 
6736 Do not expect a sequence of @code{asm} statements to remain perfectly 
6737 consecutive after compilation, even when you are using the @code{volatile} 
6738 qualifier. If certain instructions need to remain consecutive in the output, 
6739 put them in a single multi-instruction asm statement.
6741 Accessing data from C programs without using input/output operands (such as 
6742 by using global symbols directly from the assembler template) may not work as 
6743 expected. Similarly, calling functions directly from an assembler template 
6744 requires a detailed understanding of the target assembler and ABI.
6746 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6747 symbols it references. This may result in GCC discarding those symbols as 
6748 unreferenced unless they are also listed as input, output, or goto operands.
6750 GCC can support multiple assembler dialects (for example, GCC for i386 
6751 supports "att" and "intel" dialects) for inline assembler. In builds that 
6752 support this capability, the @option{-masm} option controls which dialect 
6753 GCC uses as its default. The hardware-specific documentation for the 
6754 @option{-masm} option contains the list of supported dialects, as well as the 
6755 default dialect if the option is not specified. This information may be 
6756 important to understand, since assembler code that works correctly when 
6757 compiled using one dialect will likely fail if compiled using another.
6759 @subsubheading Using braces in @code{asm} templates
6761 If your code needs to support multiple assembler dialects (for example, if 
6762 you are writing public headers that need to support a variety of compilation 
6763 options), use constructs of this form:
6765 @example
6766 @{ dialect0 | dialect1 | dialect2... @}
6767 @end example
6769 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6770 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6771 braces than the number of dialects the compiler supports, the construct 
6772 outputs nothing.
6774 For example, if an i386 compiler supports two dialects (att, intel), an 
6775 assembler template such as this:
6777 @example
6778 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6779 @end example
6781 would produce the output:
6783 @example
6784 For att: "btl %[Offset],%[Base] ; jc %l2"
6785 For intel: "bt %[Base],%[Offset]; jc %l2"
6786 @end example
6788 Using that same compiler, this code:
6790 @example
6791 "xchg@{l@}\t@{%%@}ebx, %1"
6792 @end example
6794 would produce 
6796 @example
6797 For att: "xchgl\t%%ebx, %1"
6798 For intel: "xchg\tebx, %1"
6799 @end example
6801 There is no support for nesting dialect alternatives. Also, there is no 
6802 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6803 @code{asm} template other than as a dialect indicator.
6805 @subsubheading Other format strings
6807 In addition to the tokens described by the input, output, and goto operands, 
6808 there are a few special cases:
6810 @itemize
6811 @item
6812 "%%" outputs a single "%" into the assembler code.
6814 @item
6815 "%=" outputs a number that is unique to each instance of the @code{asm} 
6816 statement in the entire compilation. This option is useful when creating local 
6817 labels and referring to them multiple times in a single template that 
6818 generates multiple assembler instructions. 
6820 @end itemize
6822 @anchor{OutputOperands}
6823 @subsubsection Output Operands
6824 @cindex @code{asm} output operands
6826 An @code{asm} statement has zero or more output operands indicating the names
6827 of C variables modified by the assembler code.
6829 In this i386 example, @var{old} (referred to in the template string as 
6830 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6831 (@code{%2}) is an input:
6833 @example
6834 bool old;
6836 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6837          "sbb %0,%0"      // Use the CF to calculate old.
6838    : "=r" (old), "+rm" (*Base)
6839    : "Ir" (Offset)
6840    : "cc");
6842 return old;
6843 @end example
6845 Operands use this format:
6847 @example
6848 [ [asmSymbolicName] ] "constraint" (cvariablename)
6849 @end example
6851 @emph{asmSymbolicName}
6854 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6855 in the list of operands in the assembler template. For example if there are 
6856 three output operands, use @code{%0} in the template to refer to the first, 
6857 @code{%1} for the second, and @code{%2} for the third. When using an 
6858 asmSymbolicName, reference it by enclosing the name in square brackets 
6859 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6860 that contains the definition. Any valid C variable name is acceptable, 
6861 including names already defined in the surrounding code. No two operands 
6862 within the same @code{asm} statement can use the same symbolic name.
6864 @emph{constraint}
6866 Output constraints must begin with either @code{"="} (a variable overwriting an 
6867 existing value) or @code{"+"} (when reading and writing). When using 
6868 @code{"="}, do not assume the location will contain the existing value (except 
6869 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6871 After the prefix, there must be one or more additional constraints 
6872 (@pxref{Constraints}) that describe where the value resides. Common 
6873 constraints include @code{"r"} for register and @code{"m"} for memory. 
6874 When you list more than one possible location (for example @code{"=rm"}), the 
6875 compiler chooses the most efficient one based on the current context. If you 
6876 list as many alternates as the @code{asm} statement allows, you will permit 
6877 the optimizers to produce the best possible code. If you must use a specific
6878 register, but your Machine Constraints do not provide sufficient 
6879 control to select the specific register you want, Local Reg Vars may provide 
6880 a solution (@pxref{Local Reg Vars}).
6882 @emph{cvariablename}
6884 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6885 any (non-constant) variable within scope.
6887 Remarks:
6889 The total number of input + output + goto operands has a limit of 30. Commas 
6890 separate the operands. When the compiler selects the registers to use to 
6891 represent the output operands, it will not use any of the clobbered registers 
6892 (@pxref{Clobbers}).
6894 Output operand expressions must be lvalues. The compiler cannot check whether 
6895 the operands have data types that are reasonable for the instruction being 
6896 executed. For output expressions that are not directly addressable (for 
6897 example a bit-field), the constraint must allow a register. In that case, GCC 
6898 uses the register as the output of the @code{asm}, and then stores that 
6899 register into the output. 
6901 Unless an output operand has the '@code{&}' constraint modifier 
6902 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6903 input operand, on the assumption that the assembler code will consume its 
6904 inputs before producing outputs. This assumption may be false if the assembler 
6905 code actually consists of more than one instruction. In this case, use 
6906 '@code{&}' on each output operand that must not overlap an input.
6908 The same problem can occur if one output parameter (@var{a}) allows a register 
6909 constraint and another output parameter (@var{b}) allows a memory constraint.
6910 The code generated by GCC to access the memory address in @var{b} can contain
6911 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6912 registers to be inputs to the asm. As above, GCC assumes that such input
6913 registers are consumed before any outputs are written. This assumption may 
6914 result in incorrect behavior if the asm writes to @var{a} before using 
6915 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6916 ensures that modifying @var{a} will not affect what address is referenced by 
6917 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6918 will be undefined if @var{a} is modified before using @var{b}.
6920 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6921 instead of simply @code{%2}). Typically these qualifiers are hardware 
6922 dependent. The list of supported modifiers for i386 is found at 
6923 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6925 If the C code that follows the @code{asm} makes no use of any of the output 
6926 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6927 optimizers from discarding the @code{asm} statement as unneeded 
6928 (see @ref{Volatile}).
6930 Examples:
6932 This code makes no use of the optional asmSymbolicName. Therefore it 
6933 references the first output operand as @code{%0} (were there a second, it 
6934 would be @code{%1}, etc). The number of the first input operand is one greater 
6935 than that of the last output operand. In this i386 example, that makes 
6936 @var{Mask} @code{%1}:
6938 @example
6939 uint32_t Mask = 1234;
6940 uint32_t Index;
6942   asm ("bsfl %1, %0"
6943      : "=r" (Index)
6944      : "r" (Mask)
6945      : "cc");
6946 @end example
6948 That code overwrites the variable Index ("="), placing the value in a register 
6949 ("r"). The generic "r" constraint instead of a constraint for a specific 
6950 register allows the compiler to pick the register to use, which can result 
6951 in more efficient code. This may not be possible if an assembler instruction 
6952 requires a specific register.
6954 The following i386 example uses the asmSymbolicName operand. It produces the 
6955 same result as the code above, but some may consider it more readable or more 
6956 maintainable since reordering index numbers is not necessary when adding or 
6957 removing operands. The names aIndex and aMask are only used to emphasize which 
6958 names get used where. It is acceptable to reuse the names Index and Mask.
6960 @example
6961 uint32_t Mask = 1234;
6962 uint32_t Index;
6964   asm ("bsfl %[aMask], %[aIndex]"
6965      : [aIndex] "=r" (Index)
6966      : [aMask] "r" (Mask)
6967      : "cc");
6968 @end example
6970 Here are some more examples of output operands.
6972 @example
6973 uint32_t c = 1;
6974 uint32_t d;
6975 uint32_t *e = &c;
6977 asm ("mov %[e], %[d]"
6978    : [d] "=rm" (d)
6979    : [e] "rm" (*e));
6980 @end example
6982 Here, @var{d} may either be in a register or in memory. Since the compiler 
6983 might already have the current value of the uint32_t pointed to by @var{e} 
6984 in a register, you can enable it to choose the best location
6985 for @var{d} by specifying both constraints.
6987 @anchor{InputOperands}
6988 @subsubsection Input Operands
6989 @cindex @code{asm} input operands
6990 @cindex @code{asm} expressions
6992 Input operands make inputs from C variables and expressions available to the 
6993 assembly code.
6995 Specify input operands by using the format:
6997 @example
6998 [ [asmSymbolicName] ] "constraint" (cexpression)
6999 @end example
7001 @emph{asmSymbolicName}
7003 When not using asmSymbolicNames, use the (zero-based) position of the operand 
7004 in the list of operands, including outputs, in the assembler template. For 
7005 example, if there are two output parameters and three inputs, @code{%2} refers 
7006 to the first input, @code{%3} to the second, and @code{%4} to the third.
7007 When using an asmSymbolicName, reference it by enclosing the name in square 
7008 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
7009 statement that contains the definition. Any valid C variable name is 
7010 acceptable, including names already defined in the surrounding code. No two 
7011 operands within the same @code{asm} statement can use the same symbolic name.
7013 @emph{constraint}
7015 Input constraints must be a string containing one or more constraints 
7016 (@pxref{Constraints}). When you give more than one possible constraint 
7017 (for example, @code{"irm"}), the compiler will choose the most efficient 
7018 method based on the current context. Input constraints may not begin with 
7019 either "=" or "+". If you must use a specific register, but your Machine
7020 Constraints do not provide sufficient control to select the specific 
7021 register you want, Local Reg Vars may provide a solution 
7022 (@pxref{Local Reg Vars}).
7024 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7025 that the specified input will be in the same place as the output constraint 
7026 at the (zero-based) index in the output constraint list. When using 
7027 asmSymbolicNames for the output operands, you may use these names (enclosed 
7028 in brackets []) instead of digits.
7030 @emph{cexpression}
7032 This is the C variable or expression being passed to the @code{asm} statement 
7033 as input.
7035 When the compiler selects the registers to use to represent the input 
7036 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7038 If there are no output operands but there are input operands, place two 
7039 consecutive colons where the output operands would go:
7041 @example
7042 __asm__ ("some instructions"
7043    : /* No outputs. */
7044    : "r" (Offset / 8);
7045 @end example
7047 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7048 (except for inputs tied to outputs). The compiler assumes that on exit from 
7049 the @code{asm} statement these operands will contain the same values as they 
7050 had before executing the assembler. It is @emph{not} possible to use Clobbers 
7051 to inform the compiler that the values in these inputs are changing. One 
7052 common work-around is to tie the changing input variable to an output variable 
7053 that never gets used. Note, however, that if the code that follows the 
7054 @code{asm} statement makes no use of any of the output operands, the GCC 
7055 optimizers may discard the @code{asm} statement as unneeded 
7056 (see @ref{Volatile}).
7058 Remarks:
7060 The total number of input + output + goto operands has a limit of 30.
7062 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
7063 instead of simply @code{%2}). Typically these qualifiers are hardware 
7064 dependent. The list of supported modifiers for i386 is found at 
7065 @ref{i386Operandmodifiers,i386 Operand modifiers}.
7067 Examples:
7069 In this example using the fictitious @code{combine} instruction, the 
7070 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7071 location as output operand 0. Only input operands may use numbers in 
7072 constraints, and they must each refer to an output operand. Only a number (or 
7073 the symbolic assembler name) in the constraint can guarantee that one operand 
7074 is in the same place as another. The mere fact that @var{foo} is the value of 
7075 both operands is not enough to guarantee that they are in the same place in 
7076 the generated assembler code.
7078 @example
7079 asm ("combine %2, %0" 
7080    : "=r" (foo) 
7081    : "0" (foo), "g" (bar));
7082 @end example
7084 Here is an example using symbolic names.
7086 @example
7087 asm ("cmoveq %1, %2, %[result]" 
7088    : [result] "=r"(result) 
7089    : "r" (test), "r" (new), "[result]" (old));
7090 @end example
7092 @anchor{Clobbers}
7093 @subsubsection Clobbers
7094 @cindex @code{asm} clobbers
7096 While the compiler is aware of changes to entries listed in the output 
7097 operands, the assembler code may modify more than just the outputs. For 
7098 example, calculations may require additional registers, or the processor may 
7099 overwrite a register as a side effect of a particular assembler instruction. 
7100 In order to inform the compiler of these changes, list them in the clobber 
7101 list. Clobber list items are either register names or the special clobbers 
7102 (listed below). Each clobber list item is enclosed in double quotes and 
7103 separated by commas.
7105 Clobber descriptions may not in any way overlap with an input or output 
7106 operand. For example, you may not have an operand describing a register class 
7107 with one member when listing that register in the clobber list. Variables 
7108 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
7109 as @code{asm} input or output operands, must have no part mentioned in the 
7110 clobber description. In particular, there is no way to specify that input 
7111 operands get modified without also specifying them as output operands.
7113 When the compiler selects which registers to use to represent input and output 
7114 operands, it will not use any of the clobbered registers. As a result, 
7115 clobbered registers are available for any use in the assembler code.
7117 Here is a realistic example for the VAX showing the use of clobbered 
7118 registers: 
7120 @example
7121 asm volatile ("movc3 %0, %1, %2"
7122                    : /* No outputs. */
7123                    : "g" (from), "g" (to), "g" (count)
7124                    : "r0", "r1", "r2", "r3", "r4", "r5");
7125 @end example
7127 Also, there are two special clobber arguments:
7129 @enumerate
7130 @item
7131 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7132 register. On some machines, GCC represents the condition codes as a specific 
7133 hardware register; "cc" serves to name this register. On other machines, 
7134 condition code handling is different, and specifying "cc" has no effect. But 
7135 it is valid no matter what the machine.
7137 @item
7138 The "memory" clobber tells the compiler that the assembly code performs memory 
7139 reads or writes to items other than those listed in the input and output 
7140 operands (for example accessing the memory pointed to by one of the input 
7141 parameters). To ensure memory contains correct values, GCC may need to flush 
7142 specific register values to memory before executing the @code{asm}. Further, 
7143 the compiler will not assume that any values read from memory before an 
7144 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7145 needed. This effectively forms a read/write memory barrier for the compiler.
7147 Note that this clobber does not prevent the @emph{processor} from doing 
7148 speculative reads past the @code{asm} statement. To prevent that, you need 
7149 processor-specific fence instructions.
7151 Flushing registers to memory has performance implications and may be an issue 
7152 for time-sensitive code. One trick to avoid this is available if the size of 
7153 the memory being accessed is known at compile time. For example, if accessing 
7154 ten bytes of a string, use a memory input like: 
7156 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7158 @end enumerate
7160 @anchor{GotoLabels}
7161 @subsubsection Goto Labels
7162 @cindex @code{asm} goto labels
7164 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7165 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7166 list of all C labels to which the assembler code may jump. GCC assumes that 
7167 @code{asm} execution falls through to the next statement (if this is not the 
7168 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7169 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7170 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7171 Attributes}). The total number of input + output + goto operands has 
7172 a limit of 30.
7174 An @code{asm goto} statement can not have outputs (which means that the 
7175 statement is implicitly volatile). This is due to an internal restriction of 
7176 the compiler: control transfer instructions cannot have outputs. If the 
7177 assembler code does modify anything, use the "memory" clobber to force the 
7178 optimizers to flush all register values to memory, and reload them if 
7179 necessary, after the @code{asm} statement.
7181 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7182 by its (zero-based) position in GotoLabels plus the number of input 
7183 arguments.  For example, if the @code{asm} has three inputs and references two 
7184 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7186 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7187 GCC's optimizers do not know about these jumps; therefore they cannot take 
7188 account of them when deciding how to optimize.
7190 Example code for i386 might look like:
7192 @example
7193 asm goto (
7194     "btl %1, %0\n\t"
7195     "jc %l2"
7196     : /* No outputs. */
7197     : "r" (p1), "r" (p2) 
7198     : "cc" 
7199     : carry);
7201 return 0;
7203 carry:
7204 return 1;
7205 @end example
7207 The following example shows an @code{asm goto} that uses the memory clobber.
7209 @example
7210 int frob(int x)
7212   int y;
7213   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7214             : /* No outputs. */
7215             : "r"(x), "r"(&y)
7216             : "r5", "memory" 
7217             : error);
7218   return y;
7219 error:
7220   return -1;
7222 @end example
7224 @anchor{i386Operandmodifiers}
7225 @subsubsection i386 Operand modifiers
7227 Input, output, and goto operands for extended @code{asm} statements can use 
7228 modifiers to affect the code output to the assembler. For example, the 
7229 following code uses the "h" and "b" modifiers for i386:
7231 @example
7232 uint16_t  num;
7233 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7234 @end example
7236 These modifiers generate this assembler code:
7238 @example
7239 xchg %ah, %al
7240 @end example
7242 The rest of this discussion uses the following code for illustrative purposes.
7244 @example
7245 int main()
7247    int iInt = 1;
7249 top:
7251    asm volatile goto ("some assembler instructions here"
7252    : /* No outputs. */
7253    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7254    : /* No clobbers. */
7255    : top);
7257 @end example
7259 With no modifiers, this is what the output from the operands would be for the 
7260 att and intel dialects of assembler:
7262 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7263 @headitem Operand @tab masm=att @tab masm=intel
7264 @item @code{%0}
7265 @tab @code{%eax}
7266 @tab @code{eax}
7267 @item @code{%1}
7268 @tab @code{$2}
7269 @tab @code{2}
7270 @item @code{%2}
7271 @tab @code{$.L2}
7272 @tab @code{OFFSET FLAT:.L2}
7273 @end multitable
7275 The table below shows the list of supported modifiers and their effects.
7277 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7278 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7279 @item @code{z}
7280 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7281 @tab @code{%z0}
7282 @tab @code{l}
7283 @tab 
7284 @item @code{b}
7285 @tab Print the QImode name of the register.
7286 @tab @code{%b0}
7287 @tab @code{%al}
7288 @tab @code{al}
7289 @item @code{h}
7290 @tab Print the QImode name for a ``high'' register.
7291 @tab @code{%h0}
7292 @tab @code{%ah}
7293 @tab @code{ah}
7294 @item @code{w}
7295 @tab Print the HImode name of the register.
7296 @tab @code{%w0}
7297 @tab @code{%ax}
7298 @tab @code{ax}
7299 @item @code{k}
7300 @tab Print the SImode name of the register.
7301 @tab @code{%k0}
7302 @tab @code{%eax}
7303 @tab @code{eax}
7304 @item @code{q}
7305 @tab Print the DImode name of the register.
7306 @tab @code{%q0}
7307 @tab @code{%rax}
7308 @tab @code{rax}
7309 @item @code{l}
7310 @tab Print the label name with no punctuation.
7311 @tab @code{%l2}
7312 @tab @code{.L2}
7313 @tab @code{.L2}
7314 @item @code{c}
7315 @tab Require a constant operand and print the constant expression with no punctuation.
7316 @tab @code{%c1}
7317 @tab @code{2}
7318 @tab @code{2}
7319 @end multitable
7321 @anchor{i386floatingpointasmoperands}
7322 @subsubsection i386 floating-point asm operands
7324 On i386 targets, there are several rules on the usage of stack-like registers
7325 in the operands of an @code{asm}.  These rules apply only to the operands
7326 that are stack-like registers:
7328 @enumerate
7329 @item
7330 Given a set of input registers that die in an @code{asm}, it is
7331 necessary to know which are implicitly popped by the @code{asm}, and
7332 which must be explicitly popped by GCC@.
7334 An input register that is implicitly popped by the @code{asm} must be
7335 explicitly clobbered, unless it is constrained to match an
7336 output operand.
7338 @item
7339 For any input register that is implicitly popped by an @code{asm}, it is
7340 necessary to know how to adjust the stack to compensate for the pop.
7341 If any non-popped input is closer to the top of the reg-stack than
7342 the implicitly popped register, it would not be possible to know what the
7343 stack looked like---it's not clear how the rest of the stack ``slides
7344 up''.
7346 All implicitly popped input registers must be closer to the top of
7347 the reg-stack than any input that is not implicitly popped.
7349 It is possible that if an input dies in an @code{asm}, the compiler might
7350 use the input register for an output reload.  Consider this example:
7352 @smallexample
7353 asm ("foo" : "=t" (a) : "f" (b));
7354 @end smallexample
7356 @noindent
7357 This code says that input @code{b} is not popped by the @code{asm}, and that
7358 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7359 deeper after the @code{asm} than it was before.  But, it is possible that
7360 reload may think that it can use the same register for both the input and
7361 the output.
7363 To prevent this from happening,
7364 if any input operand uses the @code{f} constraint, all output register
7365 constraints must use the @code{&} early-clobber modifier.
7367 The example above would be correctly written as:
7369 @smallexample
7370 asm ("foo" : "=&t" (a) : "f" (b));
7371 @end smallexample
7373 @item
7374 Some operands need to be in particular places on the stack.  All
7375 output operands fall in this category---GCC has no other way to
7376 know which registers the outputs appear in unless you indicate
7377 this in the constraints.
7379 Output operands must specifically indicate which register an output
7380 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7381 constraints must select a class with a single register.
7383 @item
7384 Output operands may not be ``inserted'' between existing stack registers.
7385 Since no 387 opcode uses a read/write operand, all output operands
7386 are dead before the @code{asm}, and are pushed by the @code{asm}.
7387 It makes no sense to push anywhere but the top of the reg-stack.
7389 Output operands must start at the top of the reg-stack: output
7390 operands may not ``skip'' a register.
7392 @item
7393 Some @code{asm} statements may need extra stack space for internal
7394 calculations.  This can be guaranteed by clobbering stack registers
7395 unrelated to the inputs and outputs.
7397 @end enumerate
7399 Here are a couple of reasonable @code{asm}s to want to write.  This
7400 @code{asm}
7401 takes one input, which is internally popped, and produces two outputs.
7403 @smallexample
7404 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7405 @end smallexample
7407 @noindent
7408 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7409 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7410 for the compiler to know that @code{fyl2xp1} pops both inputs.
7412 @smallexample
7413 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7414 @end smallexample
7416 @lowersections
7417 @include md.texi
7418 @raisesections
7420 @node Asm Labels
7421 @subsection Controlling Names Used in Assembler Code
7422 @cindex assembler names for identifiers
7423 @cindex names used in assembler code
7424 @cindex identifiers, names in assembler code
7426 You can specify the name to be used in the assembler code for a C
7427 function or variable by writing the @code{asm} (or @code{__asm__})
7428 keyword after the declarator as follows:
7430 @smallexample
7431 int foo asm ("myfoo") = 2;
7432 @end smallexample
7434 @noindent
7435 This specifies that the name to be used for the variable @code{foo} in
7436 the assembler code should be @samp{myfoo} rather than the usual
7437 @samp{_foo}.
7439 On systems where an underscore is normally prepended to the name of a C
7440 function or variable, this feature allows you to define names for the
7441 linker that do not start with an underscore.
7443 It does not make sense to use this feature with a non-static local
7444 variable since such variables do not have assembler names.  If you are
7445 trying to put the variable in a particular register, see @ref{Explicit
7446 Reg Vars}.  GCC presently accepts such code with a warning, but will
7447 probably be changed to issue an error, rather than a warning, in the
7448 future.
7450 You cannot use @code{asm} in this way in a function @emph{definition}; but
7451 you can get the same effect by writing a declaration for the function
7452 before its definition and putting @code{asm} there, like this:
7454 @smallexample
7455 extern func () asm ("FUNC");
7457 func (x, y)
7458      int x, y;
7459 /* @r{@dots{}} */
7460 @end smallexample
7462 It is up to you to make sure that the assembler names you choose do not
7463 conflict with any other assembler symbols.  Also, you must not use a
7464 register name; that would produce completely invalid assembler code.  GCC
7465 does not as yet have the ability to store static variables in registers.
7466 Perhaps that will be added.
7468 @node Explicit Reg Vars
7469 @subsection Variables in Specified Registers
7470 @cindex explicit register variables
7471 @cindex variables in specified registers
7472 @cindex specified registers
7473 @cindex registers, global allocation
7475 GNU C allows you to put a few global variables into specified hardware
7476 registers.  You can also specify the register in which an ordinary
7477 register variable should be allocated.
7479 @itemize @bullet
7480 @item
7481 Global register variables reserve registers throughout the program.
7482 This may be useful in programs such as programming language
7483 interpreters that have a couple of global variables that are accessed
7484 very often.
7486 @item
7487 Local register variables in specific registers do not reserve the
7488 registers, except at the point where they are used as input or output
7489 operands in an @code{asm} statement and the @code{asm} statement itself is
7490 not deleted.  The compiler's data flow analysis is capable of determining
7491 where the specified registers contain live values, and where they are
7492 available for other uses.  Stores into local register variables may be deleted
7493 when they appear to be dead according to dataflow analysis.  References
7494 to local register variables may be deleted or moved or simplified.
7496 These local variables are sometimes convenient for use with the extended
7497 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7498 output of the assembler instruction directly into a particular register.
7499 (This works provided the register you specify fits the constraints
7500 specified for that operand in the @code{asm}.)
7501 @end itemize
7503 @menu
7504 * Global Reg Vars::
7505 * Local Reg Vars::
7506 @end menu
7508 @node Global Reg Vars
7509 @subsubsection Defining Global Register Variables
7510 @cindex global register variables
7511 @cindex registers, global variables in
7513 You can define a global register variable in GNU C like this:
7515 @smallexample
7516 register int *foo asm ("a5");
7517 @end smallexample
7519 @noindent
7520 Here @code{a5} is the name of the register that should be used.  Choose a
7521 register that is normally saved and restored by function calls on your
7522 machine, so that library routines will not clobber it.
7524 Naturally the register name is cpu-dependent, so you need to
7525 conditionalize your program according to cpu type.  The register
7526 @code{a5} is a good choice on a 68000 for a variable of pointer
7527 type.  On machines with register windows, be sure to choose a ``global''
7528 register that is not affected magically by the function call mechanism.
7530 In addition, different operating systems on the same CPU may differ in how they
7531 name the registers; then you need additional conditionals.  For
7532 example, some 68000 operating systems call this register @code{%a5}.
7534 Eventually there may be a way of asking the compiler to choose a register
7535 automatically, but first we need to figure out how it should choose and
7536 how to enable you to guide the choice.  No solution is evident.
7538 Defining a global register variable in a certain register reserves that
7539 register entirely for this use, at least within the current compilation.
7540 The register is not allocated for any other purpose in the functions
7541 in the current compilation, and is not saved and restored by
7542 these functions.  Stores into this register are never deleted even if they
7543 appear to be dead, but references may be deleted or moved or
7544 simplified.
7546 It is not safe to access the global register variables from signal
7547 handlers, or from more than one thread of control, because the system
7548 library routines may temporarily use the register for other things (unless
7549 you recompile them specially for the task at hand).
7551 @cindex @code{qsort}, and global register variables
7552 It is not safe for one function that uses a global register variable to
7553 call another such function @code{foo} by way of a third function
7554 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7555 different source file in which the variable isn't declared).  This is
7556 because @code{lose} might save the register and put some other value there.
7557 For example, you can't expect a global register variable to be available in
7558 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7559 might have put something else in that register.  (If you are prepared to
7560 recompile @code{qsort} with the same global register variable, you can
7561 solve this problem.)
7563 If you want to recompile @code{qsort} or other source files that do not
7564 actually use your global register variable, so that they do not use that
7565 register for any other purpose, then it suffices to specify the compiler
7566 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7567 register declaration to their source code.
7569 A function that can alter the value of a global register variable cannot
7570 safely be called from a function compiled without this variable, because it
7571 could clobber the value the caller expects to find there on return.
7572 Therefore, the function that is the entry point into the part of the
7573 program that uses the global register variable must explicitly save and
7574 restore the value that belongs to its caller.
7576 @cindex register variable after @code{longjmp}
7577 @cindex global register after @code{longjmp}
7578 @cindex value after @code{longjmp}
7579 @findex longjmp
7580 @findex setjmp
7581 On most machines, @code{longjmp} restores to each global register
7582 variable the value it had at the time of the @code{setjmp}.  On some
7583 machines, however, @code{longjmp} does not change the value of global
7584 register variables.  To be portable, the function that called @code{setjmp}
7585 should make other arrangements to save the values of the global register
7586 variables, and to restore them in a @code{longjmp}.  This way, the same
7587 thing happens regardless of what @code{longjmp} does.
7589 All global register variable declarations must precede all function
7590 definitions.  If such a declaration could appear after function
7591 definitions, the declaration would be too late to prevent the register from
7592 being used for other purposes in the preceding functions.
7594 Global register variables may not have initial values, because an
7595 executable file has no means to supply initial contents for a register.
7597 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7598 registers, but certain library functions, such as @code{getwd}, as well
7599 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7600 g2 are local temporaries.
7602 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7603 Of course, it does not do to use more than a few of those.
7605 @node Local Reg Vars
7606 @subsubsection Specifying Registers for Local Variables
7607 @cindex local variables, specifying registers
7608 @cindex specifying registers for local variables
7609 @cindex registers for local variables
7611 You can define a local register variable with a specified register
7612 like this:
7614 @smallexample
7615 register int *foo asm ("a5");
7616 @end smallexample
7618 @noindent
7619 Here @code{a5} is the name of the register that should be used.  Note
7620 that this is the same syntax used for defining global register
7621 variables, but for a local variable it appears within a function.
7623 Naturally the register name is cpu-dependent, but this is not a
7624 problem, since specific registers are most often useful with explicit
7625 assembler instructions (@pxref{Extended Asm}).  Both of these things
7626 generally require that you conditionalize your program according to
7627 cpu type.
7629 In addition, operating systems on one type of cpu may differ in how they
7630 name the registers; then you need additional conditionals.  For
7631 example, some 68000 operating systems call this register @code{%a5}.
7633 Defining such a register variable does not reserve the register; it
7634 remains available for other uses in places where flow control determines
7635 the variable's value is not live.
7637 This option does not guarantee that GCC generates code that has
7638 this variable in the register you specify at all times.  You may not
7639 code an explicit reference to this register in the @emph{assembler
7640 instruction template} part of an @code{asm} statement and assume it
7641 always refers to this variable.  However, using the variable as an
7642 @code{asm} @emph{operand} guarantees that the specified register is used
7643 for the operand.
7645 Stores into local register variables may be deleted when they appear to be dead
7646 according to dataflow analysis.  References to local register variables may
7647 be deleted or moved or simplified.
7649 As with global register variables, it is recommended that you choose a
7650 register that is normally saved and restored by function calls on
7651 your machine, so that library routines will not clobber it.  
7653 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7654 specific register, but there's no matching constraint letter for that 
7655 register. To force the operand into that register, create a local variable 
7656 and specify the register in the variable's declaration. Then use the local 
7657 variable for the asm operand and specify any constraint letter that matches 
7658 the register:
7660 @smallexample
7661 register int *p1 asm ("r0") = @dots{};
7662 register int *p2 asm ("r1") = @dots{};
7663 register int *result asm ("r0");
7664 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7665 @end smallexample
7667 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7668 call-clobbered by subsequent code, including function calls and library calls 
7669 for arithmetic operators on other variables (for example the initialization 
7670 of p2). In this case, use temporary variables for expressions between the 
7671 register assignments:
7673 @smallexample
7674 int t1 = @dots{};
7675 register int *p1 asm ("r0") = @dots{};
7676 register int *p2 asm ("r1") = t1;
7677 register int *result asm ("r0");
7678 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7679 @end smallexample
7681 @node Size of an asm
7682 @subsection Size of an @code{asm}
7684 Some targets require that GCC track the size of each instruction used
7685 in order to generate correct code.  Because the final length of the
7686 code produced by an @code{asm} statement is only known by the
7687 assembler, GCC must make an estimate as to how big it will be.  It
7688 does this by counting the number of instructions in the pattern of the
7689 @code{asm} and multiplying that by the length of the longest
7690 instruction supported by that processor.  (When working out the number
7691 of instructions, it assumes that any occurrence of a newline or of
7692 whatever statement separator character is supported by the assembler --
7693 typically @samp{;} --- indicates the end of an instruction.)
7695 Normally, GCC's estimate is adequate to ensure that correct
7696 code is generated, but it is possible to confuse the compiler if you use
7697 pseudo instructions or assembler macros that expand into multiple real
7698 instructions, or if you use assembler directives that expand to more
7699 space in the object file than is needed for a single instruction.
7700 If this happens then the assembler may produce a diagnostic saying that
7701 a label is unreachable.
7703 @node Alternate Keywords
7704 @section Alternate Keywords
7705 @cindex alternate keywords
7706 @cindex keywords, alternate
7708 @option{-ansi} and the various @option{-std} options disable certain
7709 keywords.  This causes trouble when you want to use GNU C extensions, or
7710 a general-purpose header file that should be usable by all programs,
7711 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7712 @code{inline} are not available in programs compiled with
7713 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7714 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7715 ISO C99 keyword
7716 @code{restrict} is only available when @option{-std=gnu99} (which will
7717 eventually be the default) or @option{-std=c99} (or the equivalent
7718 @option{-std=iso9899:1999}), or an option for a later standard
7719 version, is used.
7721 The way to solve these problems is to put @samp{__} at the beginning and
7722 end of each problematical keyword.  For example, use @code{__asm__}
7723 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7725 Other C compilers won't accept these alternative keywords; if you want to
7726 compile with another compiler, you can define the alternate keywords as
7727 macros to replace them with the customary keywords.  It looks like this:
7729 @smallexample
7730 #ifndef __GNUC__
7731 #define __asm__ asm
7732 #endif
7733 @end smallexample
7735 @findex __extension__
7736 @opindex pedantic
7737 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7738 You can
7739 prevent such warnings within one expression by writing
7740 @code{__extension__} before the expression.  @code{__extension__} has no
7741 effect aside from this.
7743 @node Incomplete Enums
7744 @section Incomplete @code{enum} Types
7746 You can define an @code{enum} tag without specifying its possible values.
7747 This results in an incomplete type, much like what you get if you write
7748 @code{struct foo} without describing the elements.  A later declaration
7749 that does specify the possible values completes the type.
7751 You can't allocate variables or storage using the type while it is
7752 incomplete.  However, you can work with pointers to that type.
7754 This extension may not be very useful, but it makes the handling of
7755 @code{enum} more consistent with the way @code{struct} and @code{union}
7756 are handled.
7758 This extension is not supported by GNU C++.
7760 @node Function Names
7761 @section Function Names as Strings
7762 @cindex @code{__func__} identifier
7763 @cindex @code{__FUNCTION__} identifier
7764 @cindex @code{__PRETTY_FUNCTION__} identifier
7766 GCC provides three magic variables that hold the name of the current
7767 function, as a string.  The first of these is @code{__func__}, which
7768 is part of the C99 standard:
7770 The identifier @code{__func__} is implicitly declared by the translator
7771 as if, immediately following the opening brace of each function
7772 definition, the declaration
7774 @smallexample
7775 static const char __func__[] = "function-name";
7776 @end smallexample
7778 @noindent
7779 appeared, where function-name is the name of the lexically-enclosing
7780 function.  This name is the unadorned name of the function.
7782 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7783 versions of GCC recognize only this name.  However, it is not
7784 standardized.  For maximum portability, we recommend you use
7785 @code{__func__}, but provide a fallback definition with the
7786 preprocessor:
7788 @smallexample
7789 #if __STDC_VERSION__ < 199901L
7790 # if __GNUC__ >= 2
7791 #  define __func__ __FUNCTION__
7792 # else
7793 #  define __func__ "<unknown>"
7794 # endif
7795 #endif
7796 @end smallexample
7798 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7799 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7800 the type signature of the function as well as its bare name.  For
7801 example, this program:
7803 @smallexample
7804 extern "C" @{
7805 extern int printf (char *, ...);
7808 class a @{
7809  public:
7810   void sub (int i)
7811     @{
7812       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7813       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7814     @}
7818 main (void)
7820   a ax;
7821   ax.sub (0);
7822   return 0;
7824 @end smallexample
7826 @noindent
7827 gives this output:
7829 @smallexample
7830 __FUNCTION__ = sub
7831 __PRETTY_FUNCTION__ = void a::sub(int)
7832 @end smallexample
7834 These identifiers are not preprocessor macros.  In GCC 3.3 and
7835 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7836 were treated as string literals; they could be used to initialize
7837 @code{char} arrays, and they could be concatenated with other string
7838 literals.  GCC 3.4 and later treat them as variables, like
7839 @code{__func__}.  In C++, @code{__FUNCTION__} and
7840 @code{__PRETTY_FUNCTION__} have always been variables.
7842 @node Return Address
7843 @section Getting the Return or Frame Address of a Function
7845 These functions may be used to get information about the callers of a
7846 function.
7848 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7849 This function returns the return address of the current function, or of
7850 one of its callers.  The @var{level} argument is number of frames to
7851 scan up the call stack.  A value of @code{0} yields the return address
7852 of the current function, a value of @code{1} yields the return address
7853 of the caller of the current function, and so forth.  When inlining
7854 the expected behavior is that the function returns the address of
7855 the function that is returned to.  To work around this behavior use
7856 the @code{noinline} function attribute.
7858 The @var{level} argument must be a constant integer.
7860 On some machines it may be impossible to determine the return address of
7861 any function other than the current one; in such cases, or when the top
7862 of the stack has been reached, this function returns @code{0} or a
7863 random value.  In addition, @code{__builtin_frame_address} may be used
7864 to determine if the top of the stack has been reached.
7866 Additional post-processing of the returned value may be needed, see
7867 @code{__builtin_extract_return_addr}.
7869 This function should only be used with a nonzero argument for debugging
7870 purposes.
7871 @end deftypefn
7873 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7874 The address as returned by @code{__builtin_return_address} may have to be fed
7875 through this function to get the actual encoded address.  For example, on the
7876 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7877 platforms an offset has to be added for the true next instruction to be
7878 executed.
7880 If no fixup is needed, this function simply passes through @var{addr}.
7881 @end deftypefn
7883 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7884 This function does the reverse of @code{__builtin_extract_return_addr}.
7885 @end deftypefn
7887 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7888 This function is similar to @code{__builtin_return_address}, but it
7889 returns the address of the function frame rather than the return address
7890 of the function.  Calling @code{__builtin_frame_address} with a value of
7891 @code{0} yields the frame address of the current function, a value of
7892 @code{1} yields the frame address of the caller of the current function,
7893 and so forth.
7895 The frame is the area on the stack that holds local variables and saved
7896 registers.  The frame address is normally the address of the first word
7897 pushed on to the stack by the function.  However, the exact definition
7898 depends upon the processor and the calling convention.  If the processor
7899 has a dedicated frame pointer register, and the function has a frame,
7900 then @code{__builtin_frame_address} returns the value of the frame
7901 pointer register.
7903 On some machines it may be impossible to determine the frame address of
7904 any function other than the current one; in such cases, or when the top
7905 of the stack has been reached, this function returns @code{0} if
7906 the first frame pointer is properly initialized by the startup code.
7908 This function should only be used with a nonzero argument for debugging
7909 purposes.
7910 @end deftypefn
7912 @node Vector Extensions
7913 @section Using Vector Instructions through Built-in Functions
7915 On some targets, the instruction set contains SIMD vector instructions which
7916 operate on multiple values contained in one large register at the same time.
7917 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7918 this way.
7920 The first step in using these extensions is to provide the necessary data
7921 types.  This should be done using an appropriate @code{typedef}:
7923 @smallexample
7924 typedef int v4si __attribute__ ((vector_size (16)));
7925 @end smallexample
7927 @noindent
7928 The @code{int} type specifies the base type, while the attribute specifies
7929 the vector size for the variable, measured in bytes.  For example, the
7930 declaration above causes the compiler to set the mode for the @code{v4si}
7931 type to be 16 bytes wide and divided into @code{int} sized units.  For
7932 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7933 corresponding mode of @code{foo} is @acronym{V4SI}.
7935 The @code{vector_size} attribute is only applicable to integral and
7936 float scalars, although arrays, pointers, and function return values
7937 are allowed in conjunction with this construct. Only sizes that are
7938 a power of two are currently allowed.
7940 All the basic integer types can be used as base types, both as signed
7941 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7942 @code{long long}.  In addition, @code{float} and @code{double} can be
7943 used to build floating-point vector types.
7945 Specifying a combination that is not valid for the current architecture
7946 causes GCC to synthesize the instructions using a narrower mode.
7947 For example, if you specify a variable of type @code{V4SI} and your
7948 architecture does not allow for this specific SIMD type, GCC
7949 produces code that uses 4 @code{SIs}.
7951 The types defined in this manner can be used with a subset of normal C
7952 operations.  Currently, GCC allows using the following operators
7953 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7955 The operations behave like C++ @code{valarrays}.  Addition is defined as
7956 the addition of the corresponding elements of the operands.  For
7957 example, in the code below, each of the 4 elements in @var{a} is
7958 added to the corresponding 4 elements in @var{b} and the resulting
7959 vector is stored in @var{c}.
7961 @smallexample
7962 typedef int v4si __attribute__ ((vector_size (16)));
7964 v4si a, b, c;
7966 c = a + b;
7967 @end smallexample
7969 Subtraction, multiplication, division, and the logical operations
7970 operate in a similar manner.  Likewise, the result of using the unary
7971 minus or complement operators on a vector type is a vector whose
7972 elements are the negative or complemented values of the corresponding
7973 elements in the operand.
7975 It is possible to use shifting operators @code{<<}, @code{>>} on
7976 integer-type vectors. The operation is defined as following: @code{@{a0,
7977 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7978 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7979 elements. 
7981 For convenience, it is allowed to use a binary vector operation
7982 where one operand is a scalar. In that case the compiler transforms
7983 the scalar operand into a vector where each element is the scalar from
7984 the operation. The transformation happens only if the scalar could be
7985 safely converted to the vector-element type.
7986 Consider the following code.
7988 @smallexample
7989 typedef int v4si __attribute__ ((vector_size (16)));
7991 v4si a, b, c;
7992 long l;
7994 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7995 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7997 a = l + a;    /* Error, cannot convert long to int. */
7998 @end smallexample
8000 Vectors can be subscripted as if the vector were an array with
8001 the same number of elements and base type.  Out of bound accesses
8002 invoke undefined behavior at run time.  Warnings for out of bound
8003 accesses for vector subscription can be enabled with
8004 @option{-Warray-bounds}.
8006 Vector comparison is supported with standard comparison
8007 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8008 vector expressions of integer-type or real-type. Comparison between
8009 integer-type vectors and real-type vectors are not supported.  The
8010 result of the comparison is a vector of the same width and number of
8011 elements as the comparison operands with a signed integral element
8012 type.
8014 Vectors are compared element-wise producing 0 when comparison is false
8015 and -1 (constant of the appropriate type where all bits are set)
8016 otherwise. Consider the following example.
8018 @smallexample
8019 typedef int v4si __attribute__ ((vector_size (16)));
8021 v4si a = @{1,2,3,4@};
8022 v4si b = @{3,2,1,4@};
8023 v4si c;
8025 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8026 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8027 @end smallexample
8029 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8030 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8031 integer vector with the same number of elements of the same size as @code{b}
8032 and @code{c}, computes all three arguments and creates a vector
8033 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8034 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8035 As in the case of binary operations, this syntax is also accepted when
8036 one of @code{b} or @code{c} is a scalar that is then transformed into a
8037 vector. If both @code{b} and @code{c} are scalars and the type of
8038 @code{true?b:c} has the same size as the element type of @code{a}, then
8039 @code{b} and @code{c} are converted to a vector type whose elements have
8040 this type and with the same number of elements as @code{a}.
8042 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8043 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8044 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8045 For mixed operations between a scalar @code{s} and a vector @code{v},
8046 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8047 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8049 Vector shuffling is available using functions
8050 @code{__builtin_shuffle (vec, mask)} and
8051 @code{__builtin_shuffle (vec0, vec1, mask)}.
8052 Both functions construct a permutation of elements from one or two
8053 vectors and return a vector of the same type as the input vector(s).
8054 The @var{mask} is an integral vector with the same width (@var{W})
8055 and element count (@var{N}) as the output vector.
8057 The elements of the input vectors are numbered in memory ordering of
8058 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8059 elements of @var{mask} are considered modulo @var{N} in the single-operand
8060 case and modulo @math{2*@var{N}} in the two-operand case.
8062 Consider the following example,
8064 @smallexample
8065 typedef int v4si __attribute__ ((vector_size (16)));
8067 v4si a = @{1,2,3,4@};
8068 v4si b = @{5,6,7,8@};
8069 v4si mask1 = @{0,1,1,3@};
8070 v4si mask2 = @{0,4,2,5@};
8071 v4si res;
8073 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8074 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8075 @end smallexample
8077 Note that @code{__builtin_shuffle} is intentionally semantically
8078 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8080 You can declare variables and use them in function calls and returns, as
8081 well as in assignments and some casts.  You can specify a vector type as
8082 a return type for a function.  Vector types can also be used as function
8083 arguments.  It is possible to cast from one vector type to another,
8084 provided they are of the same size (in fact, you can also cast vectors
8085 to and from other datatypes of the same size).
8087 You cannot operate between vectors of different lengths or different
8088 signedness without a cast.
8090 @node Offsetof
8091 @section Offsetof
8092 @findex __builtin_offsetof
8094 GCC implements for both C and C++ a syntactic extension to implement
8095 the @code{offsetof} macro.
8097 @smallexample
8098 primary:
8099         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8101 offsetof_member_designator:
8102           @code{identifier}
8103         | offsetof_member_designator "." @code{identifier}
8104         | offsetof_member_designator "[" @code{expr} "]"
8105 @end smallexample
8107 This extension is sufficient such that
8109 @smallexample
8110 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8111 @end smallexample
8113 @noindent
8114 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8115 may be dependent.  In either case, @var{member} may consist of a single
8116 identifier, or a sequence of member accesses and array references.
8118 @node __sync Builtins
8119 @section Legacy __sync Built-in Functions for Atomic Memory Access
8121 The following built-in functions
8122 are intended to be compatible with those described
8123 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8124 section 7.4.  As such, they depart from the normal GCC practice of using
8125 the @samp{__builtin_} prefix, and further that they are overloaded such that
8126 they work on multiple types.
8128 The definition given in the Intel documentation allows only for the use of
8129 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8130 counterparts.  GCC allows any integral scalar or pointer type that is
8131 1, 2, 4 or 8 bytes in length.
8133 Not all operations are supported by all target processors.  If a particular
8134 operation cannot be implemented on the target processor, a warning is
8135 generated and a call an external function is generated.  The external
8136 function carries the same name as the built-in version,
8137 with an additional suffix
8138 @samp{_@var{n}} where @var{n} is the size of the data type.
8140 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8141 @c useful for implementing the operation under the control of an external
8142 @c mutex.
8144 In most cases, these built-in functions are considered a @dfn{full barrier}.
8145 That is,
8146 no memory operand is moved across the operation, either forward or
8147 backward.  Further, instructions are issued as necessary to prevent the
8148 processor from speculating loads across the operation and from queuing stores
8149 after the operation.
8151 All of the routines are described in the Intel documentation to take
8152 ``an optional list of variables protected by the memory barrier''.  It's
8153 not clear what is meant by that; it could mean that @emph{only} the
8154 following variables are protected, or it could mean that these variables
8155 should in addition be protected.  At present GCC ignores this list and
8156 protects all variables that are globally accessible.  If in the future
8157 we make some use of this list, an empty list will continue to mean all
8158 globally accessible variables.
8160 @table @code
8161 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8162 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8163 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8164 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8165 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8166 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8167 @findex __sync_fetch_and_add
8168 @findex __sync_fetch_and_sub
8169 @findex __sync_fetch_and_or
8170 @findex __sync_fetch_and_and
8171 @findex __sync_fetch_and_xor
8172 @findex __sync_fetch_and_nand
8173 These built-in functions perform the operation suggested by the name, and
8174 returns the value that had previously been in memory.  That is,
8176 @smallexample
8177 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8178 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8179 @end smallexample
8181 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8182 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8184 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8185 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8186 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8187 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8188 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8189 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8190 @findex __sync_add_and_fetch
8191 @findex __sync_sub_and_fetch
8192 @findex __sync_or_and_fetch
8193 @findex __sync_and_and_fetch
8194 @findex __sync_xor_and_fetch
8195 @findex __sync_nand_and_fetch
8196 These built-in functions perform the operation suggested by the name, and
8197 return the new value.  That is,
8199 @smallexample
8200 @{ *ptr @var{op}= value; return *ptr; @}
8201 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8202 @end smallexample
8204 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8205 as @code{*ptr = ~(*ptr & value)} instead of
8206 @code{*ptr = ~*ptr & value}.
8208 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8209 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8210 @findex __sync_bool_compare_and_swap
8211 @findex __sync_val_compare_and_swap
8212 These built-in functions perform an atomic compare and swap.
8213 That is, if the current
8214 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8215 @code{*@var{ptr}}.
8217 The ``bool'' version returns true if the comparison is successful and
8218 @var{newval} is written.  The ``val'' version returns the contents
8219 of @code{*@var{ptr}} before the operation.
8221 @item __sync_synchronize (...)
8222 @findex __sync_synchronize
8223 This built-in function issues a full memory barrier.
8225 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8226 @findex __sync_lock_test_and_set
8227 This built-in function, as described by Intel, is not a traditional test-and-set
8228 operation, but rather an atomic exchange operation.  It writes @var{value}
8229 into @code{*@var{ptr}}, and returns the previous contents of
8230 @code{*@var{ptr}}.
8232 Many targets have only minimal support for such locks, and do not support
8233 a full exchange operation.  In this case, a target may support reduced
8234 functionality here by which the @emph{only} valid value to store is the
8235 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8236 is implementation defined.
8238 This built-in function is not a full barrier,
8239 but rather an @dfn{acquire barrier}.
8240 This means that references after the operation cannot move to (or be
8241 speculated to) before the operation, but previous memory stores may not
8242 be globally visible yet, and previous memory loads may not yet be
8243 satisfied.
8245 @item void __sync_lock_release (@var{type} *ptr, ...)
8246 @findex __sync_lock_release
8247 This built-in function releases the lock acquired by
8248 @code{__sync_lock_test_and_set}.
8249 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8251 This built-in function is not a full barrier,
8252 but rather a @dfn{release barrier}.
8253 This means that all previous memory stores are globally visible, and all
8254 previous memory loads have been satisfied, but following memory reads
8255 are not prevented from being speculated to before the barrier.
8256 @end table
8258 @node __atomic Builtins
8259 @section Built-in functions for memory model aware atomic operations
8261 The following built-in functions approximately match the requirements for
8262 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8263 functions, but all also have a memory model parameter.  These are all
8264 identified by being prefixed with @samp{__atomic}, and most are overloaded
8265 such that they work with multiple types.
8267 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8268 bytes in length. 16-byte integral types are also allowed if
8269 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8271 Target architectures are encouraged to provide their own patterns for
8272 each of these built-in functions.  If no target is provided, the original 
8273 non-memory model set of @samp{__sync} atomic built-in functions are
8274 utilized, along with any required synchronization fences surrounding it in
8275 order to achieve the proper behavior.  Execution in this case is subject
8276 to the same restrictions as those built-in functions.
8278 If there is no pattern or mechanism to provide a lock free instruction
8279 sequence, a call is made to an external routine with the same parameters
8280 to be resolved at run time.
8282 The four non-arithmetic functions (load, store, exchange, and 
8283 compare_exchange) all have a generic version as well.  This generic
8284 version works on any data type.  If the data type size maps to one
8285 of the integral sizes that may have lock free support, the generic
8286 version utilizes the lock free built-in function.  Otherwise an
8287 external call is left to be resolved at run time.  This external call is
8288 the same format with the addition of a @samp{size_t} parameter inserted
8289 as the first parameter indicating the size of the object being pointed to.
8290 All objects must be the same size.
8292 There are 6 different memory models that can be specified.  These map
8293 to the same names in the C++11 standard.  Refer there or to the
8294 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8295 atomic synchronization} for more detailed definitions.  These memory
8296 models integrate both barriers to code motion as well as synchronization
8297 requirements with other threads. These are listed in approximately
8298 ascending order of strength. It is also possible to use target specific
8299 flags for memory model flags, like Hardware Lock Elision.
8301 @table  @code
8302 @item __ATOMIC_RELAXED
8303 No barriers or synchronization.
8304 @item __ATOMIC_CONSUME
8305 Data dependency only for both barrier and synchronization with another
8306 thread.
8307 @item __ATOMIC_ACQUIRE
8308 Barrier to hoisting of code and synchronizes with release (or stronger)
8309 semantic stores from another thread.
8310 @item __ATOMIC_RELEASE
8311 Barrier to sinking of code and synchronizes with acquire (or stronger)
8312 semantic loads from another thread.
8313 @item __ATOMIC_ACQ_REL
8314 Full barrier in both directions and synchronizes with acquire loads and
8315 release stores in another thread.
8316 @item __ATOMIC_SEQ_CST
8317 Full barrier in both directions and synchronizes with acquire loads and
8318 release stores in all threads.
8319 @end table
8321 When implementing patterns for these built-in functions, the memory model
8322 parameter can be ignored as long as the pattern implements the most
8323 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8324 execute correctly with this memory model but they may not execute as
8325 efficiently as they could with a more appropriate implementation of the
8326 relaxed requirements.
8328 Note that the C++11 standard allows for the memory model parameter to be
8329 determined at run time rather than at compile time.  These built-in
8330 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8331 than invoke a runtime library call or inline a switch statement.  This is
8332 standard compliant, safe, and the simplest approach for now.
8334 The memory model parameter is a signed int, but only the lower 8 bits are
8335 reserved for the memory model.  The remainder of the signed int is reserved
8336 for future use and should be 0.  Use of the predefined atomic values
8337 ensures proper usage.
8339 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8340 This built-in function implements an atomic load operation.  It returns the
8341 contents of @code{*@var{ptr}}.
8343 The valid memory model variants are
8344 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8345 and @code{__ATOMIC_CONSUME}.
8347 @end deftypefn
8349 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8350 This is the generic version of an atomic load.  It returns the
8351 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8353 @end deftypefn
8355 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8356 This built-in function implements an atomic store operation.  It writes 
8357 @code{@var{val}} into @code{*@var{ptr}}.  
8359 The valid memory model variants are
8360 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8362 @end deftypefn
8364 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8365 This is the generic version of an atomic store.  It stores the value
8366 of @code{*@var{val}} into @code{*@var{ptr}}.
8368 @end deftypefn
8370 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8371 This built-in function implements an atomic exchange operation.  It writes
8372 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8373 @code{*@var{ptr}}.
8375 The valid memory model variants are
8376 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8377 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8379 @end deftypefn
8381 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8382 This is the generic version of an atomic exchange.  It stores the
8383 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8384 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8386 @end deftypefn
8388 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memmodel, int failure_memmodel)
8389 This built-in function implements an atomic compare and exchange operation.
8390 This compares the contents of @code{*@var{ptr}} with the contents of
8391 @code{*@var{expected}} and if equal, writes @var{desired} into
8392 @code{*@var{ptr}}.  If they are not equal, the current contents of
8393 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8394 for weak compare_exchange, and false for the strong variation.  Many targets 
8395 only offer the strong variation and ignore the parameter.  When in doubt, use
8396 the strong variation.
8398 True is returned if @var{desired} is written into
8399 @code{*@var{ptr}} and the execution is considered to conform to the
8400 memory model specified by @var{success_memmodel}.  There are no
8401 restrictions on what memory model can be used here.
8403 False is returned otherwise, and the execution is considered to conform
8404 to @var{failure_memmodel}. This memory model cannot be
8405 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8406 stronger model than that specified by @var{success_memmodel}.
8408 @end deftypefn
8410 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memmodel, int failure_memmodel)
8411 This built-in function implements the generic version of
8412 @code{__atomic_compare_exchange}.  The function is virtually identical to
8413 @code{__atomic_compare_exchange_n}, except the desired value is also a
8414 pointer.
8416 @end deftypefn
8418 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8419 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8420 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8421 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8422 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8423 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8424 These built-in functions perform the operation suggested by the name, and
8425 return the result of the operation. That is,
8427 @smallexample
8428 @{ *ptr @var{op}= val; return *ptr; @}
8429 @end smallexample
8431 All memory models are valid.
8433 @end deftypefn
8435 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8436 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8437 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8438 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8439 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8440 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8441 These built-in functions perform the operation suggested by the name, and
8442 return the value that had previously been in @code{*@var{ptr}}.  That is,
8444 @smallexample
8445 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8446 @end smallexample
8448 All memory models are valid.
8450 @end deftypefn
8452 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8454 This built-in function performs an atomic test-and-set operation on
8455 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8456 defined nonzero ``set'' value and the return value is @code{true} if and only
8457 if the previous contents were ``set''.
8458 It should be only used for operands of type @code{bool} or @code{char}. For 
8459 other types only part of the value may be set.
8461 All memory models are valid.
8463 @end deftypefn
8465 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8467 This built-in function performs an atomic clear operation on
8468 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8469 It should be only used for operands of type @code{bool} or @code{char} and 
8470 in conjunction with @code{__atomic_test_and_set}.
8471 For other types it may only clear partially. If the type is not @code{bool}
8472 prefer using @code{__atomic_store}.
8474 The valid memory model variants are
8475 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8476 @code{__ATOMIC_RELEASE}.
8478 @end deftypefn
8480 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8482 This built-in function acts as a synchronization fence between threads
8483 based on the specified memory model.
8485 All memory orders are valid.
8487 @end deftypefn
8489 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8491 This built-in function acts as a synchronization fence between a thread
8492 and signal handlers based in the same thread.
8494 All memory orders are valid.
8496 @end deftypefn
8498 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8500 This built-in function returns true if objects of @var{size} bytes always
8501 generate lock free atomic instructions for the target architecture.  
8502 @var{size} must resolve to a compile-time constant and the result also
8503 resolves to a compile-time constant.
8505 @var{ptr} is an optional pointer to the object that may be used to determine
8506 alignment.  A value of 0 indicates typical alignment should be used.  The 
8507 compiler may also ignore this parameter.
8509 @smallexample
8510 if (_atomic_always_lock_free (sizeof (long long), 0))
8511 @end smallexample
8513 @end deftypefn
8515 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8517 This built-in function returns true if objects of @var{size} bytes always
8518 generate lock free atomic instructions for the target architecture.  If
8519 it is not known to be lock free a call is made to a runtime routine named
8520 @code{__atomic_is_lock_free}.
8522 @var{ptr} is an optional pointer to the object that may be used to determine
8523 alignment.  A value of 0 indicates typical alignment should be used.  The 
8524 compiler may also ignore this parameter.
8525 @end deftypefn
8527 @node x86 specific memory model extensions for transactional memory
8528 @section x86 specific memory model extensions for transactional memory
8530 The i386 architecture supports additional memory ordering flags
8531 to mark lock critical sections for hardware lock elision. 
8532 These must be specified in addition to an existing memory model to 
8533 atomic intrinsics.
8535 @table @code
8536 @item __ATOMIC_HLE_ACQUIRE
8537 Start lock elision on a lock variable.
8538 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8539 @item __ATOMIC_HLE_RELEASE
8540 End lock elision on a lock variable.
8541 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8542 @end table
8544 When a lock acquire fails it is required for good performance to abort
8545 the transaction quickly. This can be done with a @code{_mm_pause}
8547 @smallexample
8548 #include <immintrin.h> // For _mm_pause
8550 int lockvar;
8552 /* Acquire lock with lock elision */
8553 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8554     _mm_pause(); /* Abort failed transaction */
8556 /* Free lock with lock elision */
8557 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8558 @end smallexample
8560 @node Object Size Checking
8561 @section Object Size Checking Built-in Functions
8562 @findex __builtin_object_size
8563 @findex __builtin___memcpy_chk
8564 @findex __builtin___mempcpy_chk
8565 @findex __builtin___memmove_chk
8566 @findex __builtin___memset_chk
8567 @findex __builtin___strcpy_chk
8568 @findex __builtin___stpcpy_chk
8569 @findex __builtin___strncpy_chk
8570 @findex __builtin___strcat_chk
8571 @findex __builtin___strncat_chk
8572 @findex __builtin___sprintf_chk
8573 @findex __builtin___snprintf_chk
8574 @findex __builtin___vsprintf_chk
8575 @findex __builtin___vsnprintf_chk
8576 @findex __builtin___printf_chk
8577 @findex __builtin___vprintf_chk
8578 @findex __builtin___fprintf_chk
8579 @findex __builtin___vfprintf_chk
8581 GCC implements a limited buffer overflow protection mechanism
8582 that can prevent some buffer overflow attacks.
8584 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8585 is a built-in construct that returns a constant number of bytes from
8586 @var{ptr} to the end of the object @var{ptr} pointer points to
8587 (if known at compile time).  @code{__builtin_object_size} never evaluates
8588 its arguments for side-effects.  If there are any side-effects in them, it
8589 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8590 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8591 point to and all of them are known at compile time, the returned number
8592 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8593 0 and minimum if nonzero.  If it is not possible to determine which objects
8594 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8595 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8596 for @var{type} 2 or 3.
8598 @var{type} is an integer constant from 0 to 3.  If the least significant
8599 bit is clear, objects are whole variables, if it is set, a closest
8600 surrounding subobject is considered the object a pointer points to.
8601 The second bit determines if maximum or minimum of remaining bytes
8602 is computed.
8604 @smallexample
8605 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8606 char *p = &var.buf1[1], *q = &var.b;
8608 /* Here the object p points to is var.  */
8609 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8610 /* The subobject p points to is var.buf1.  */
8611 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8612 /* The object q points to is var.  */
8613 assert (__builtin_object_size (q, 0)
8614         == (char *) (&var + 1) - (char *) &var.b);
8615 /* The subobject q points to is var.b.  */
8616 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8617 @end smallexample
8618 @end deftypefn
8620 There are built-in functions added for many common string operation
8621 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8622 built-in is provided.  This built-in has an additional last argument,
8623 which is the number of bytes remaining in object the @var{dest}
8624 argument points to or @code{(size_t) -1} if the size is not known.
8626 The built-in functions are optimized into the normal string functions
8627 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8628 it is known at compile time that the destination object will not
8629 be overflown.  If the compiler can determine at compile time the
8630 object will be always overflown, it issues a warning.
8632 The intended use can be e.g.@:
8634 @smallexample
8635 #undef memcpy
8636 #define bos0(dest) __builtin_object_size (dest, 0)
8637 #define memcpy(dest, src, n) \
8638   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8640 char *volatile p;
8641 char buf[10];
8642 /* It is unknown what object p points to, so this is optimized
8643    into plain memcpy - no checking is possible.  */
8644 memcpy (p, "abcde", n);
8645 /* Destination is known and length too.  It is known at compile
8646    time there will be no overflow.  */
8647 memcpy (&buf[5], "abcde", 5);
8648 /* Destination is known, but the length is not known at compile time.
8649    This will result in __memcpy_chk call that can check for overflow
8650    at run time.  */
8651 memcpy (&buf[5], "abcde", n);
8652 /* Destination is known and it is known at compile time there will
8653    be overflow.  There will be a warning and __memcpy_chk call that
8654    will abort the program at run time.  */
8655 memcpy (&buf[6], "abcde", 5);
8656 @end smallexample
8658 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8659 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8660 @code{strcat} and @code{strncat}.
8662 There are also checking built-in functions for formatted output functions.
8663 @smallexample
8664 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8665 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8666                               const char *fmt, ...);
8667 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8668                               va_list ap);
8669 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8670                                const char *fmt, va_list ap);
8671 @end smallexample
8673 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8674 etc.@: functions and can contain implementation specific flags on what
8675 additional security measures the checking function might take, such as
8676 handling @code{%n} differently.
8678 The @var{os} argument is the object size @var{s} points to, like in the
8679 other built-in functions.  There is a small difference in the behavior
8680 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8681 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8682 the checking function is called with @var{os} argument set to
8683 @code{(size_t) -1}.
8685 In addition to this, there are checking built-in functions
8686 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8687 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8688 These have just one additional argument, @var{flag}, right before
8689 format string @var{fmt}.  If the compiler is able to optimize them to
8690 @code{fputc} etc.@: functions, it does, otherwise the checking function
8691 is called and the @var{flag} argument passed to it.
8693 @node Pointer Bounds Checker builtins
8694 @section Pointer Bounds Checker Built-in Functions
8695 @findex __builtin___bnd_set_ptr_bounds
8696 @findex __builtin___bnd_narrow_ptr_bounds
8697 @findex __builtin___bnd_copy_ptr_bounds
8698 @findex __builtin___bnd_init_ptr_bounds
8699 @findex __builtin___bnd_null_ptr_bounds
8700 @findex __builtin___bnd_store_ptr_bounds
8701 @findex __builtin___bnd_chk_ptr_lbounds
8702 @findex __builtin___bnd_chk_ptr_ubounds
8703 @findex __builtin___bnd_chk_ptr_bounds
8704 @findex __builtin___bnd_get_ptr_lbound
8705 @findex __builtin___bnd_get_ptr_ubound
8707 GCC provides a set of built-in functions to control Pointer Bounds Checker
8708 instrumentation.  Note that all Pointer Bounds Checker builtins are allowed
8709 to use even if you compile with Pointer Bounds Checker off.  The builtins
8710 behavior may differ in such case as documented below.
8712 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8714 This built-in function returns a new pointer with the value of @var{q}, and
8715 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
8716 Bounds Checker off built-in function just returns the first argument.
8718 @smallexample
8719 extern void *__wrap_malloc (size_t n)
8721   void *p = (void *)__real_malloc (n);
8722   if (!p) return __builtin___bnd_null_ptr_bounds (p);
8723   return __builtin___bnd_set_ptr_bounds (p, n);
8725 @end smallexample
8727 @end deftypefn
8729 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t  @var{size})
8731 This built-in function returns a new pointer with the value of @var{p}
8732 and associate it with the narrowed bounds formed by the intersection
8733 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8734 With Pointer Bounds Checker off built-in function just returns the first
8735 argument.
8737 @smallexample
8738 void init_objects (object *objs, size_t size)
8740   size_t i;
8741   /* Initialize objects one-by-one passing pointers with bounds of an object,
8742      not the full array of objects.  */
8743   for (i = 0; i < size; i++)
8744     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8746 @end smallexample
8748 @end deftypefn
8750 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8752 This built-in function returns a new pointer with the value of @var{q},
8753 and associate it with the bounds already associated with pointer @var{r}.
8754 With Pointer Bounds Checker off built-in function just returns the first
8755 argument.
8757 @smallexample
8758 /* Here is a way to get pointer to object's field but
8759    still with the full object's bounds.  */
8760 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8761 @end smallexample
8763 @end deftypefn
8765 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8767 This built-in function returns a new pointer with the value of @var{q}, and
8768 associate it with INIT (allowing full memory access) bounds. With Pointer
8769 Bounds Checker off built-in function just returns the first argument.
8771 @end deftypefn
8773 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8775 This built-in function returns a new pointer with the value of @var{q}, and
8776 associate it with NULL (allowing no memory access) bounds. With Pointer
8777 Bounds Checker off built-in function just returns the first argument.
8779 @end deftypefn
8781 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8783 This built-in function stores the bounds associated with pointer @var{ptr_val}
8784 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
8785 bounds from legacy code without touching the associated pointer's memory when
8786 pointers were copied as integers.  With Pointer Bounds Checker off built-in
8787 function call is ignored.
8789 @end deftypefn
8791 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8793 This built-in function checks if the pointer @var{q} is within the lower
8794 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8795 function call is ignored.
8797 @smallexample
8798 extern void *__wrap_memset (void *dst, int c, size_t len)
8800   if (len > 0)
8801     @{
8802       __builtin___bnd_chk_ptr_lbounds (dst);
8803       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8804       __real_memset (dst, c, len);
8805     @}
8806   return dst;
8808 @end smallexample
8810 @end deftypefn
8812 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8814 This built-in function checks if the pointer @var{q} is within the upper
8815 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8816 function call is ignored.
8818 @end deftypefn
8820 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8822 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8823 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
8824 off built-in function call is ignored.
8826 @smallexample
8827 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8829   if (n > 0)
8830     @{
8831       __bnd_chk_ptr_bounds (dst, n);
8832       __bnd_chk_ptr_bounds (src, n);
8833       __real_memcpy (dst, src, n);
8834     @}
8835   return dst;
8837 @end smallexample
8839 @end deftypefn
8841 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8843 This built-in function returns the lower bound (which is a pointer) associated
8844 with the pointer @var{q}.  This is at least useful for debugging using printf.
8845 With Pointer Bounds Checker off built-in function returns 0.
8847 @smallexample
8848 void *lb = __builtin___bnd_get_ptr_lbound (q);
8849 void *ub = __builtin___bnd_get_ptr_ubound (q);
8850 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
8851 @end smallexample
8853 @end deftypefn
8855 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8857 This built-in function returns the upper bound (which is a pointer) associated
8858 with the pointer @var{q}.  With Pointer Bounds Checker off built-in function
8859 returns -1.
8861 @end deftypefn
8863 @node Cilk Plus Builtins
8864 @section Cilk Plus C/C++ language extension Built-in Functions.
8866 GCC provides support for the following built-in reduction funtions if Cilk Plus
8867 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8869 @itemize @bullet
8870 @item __sec_implicit_index
8871 @item __sec_reduce
8872 @item __sec_reduce_add
8873 @item __sec_reduce_all_nonzero
8874 @item __sec_reduce_all_zero
8875 @item __sec_reduce_any_nonzero
8876 @item __sec_reduce_any_zero
8877 @item __sec_reduce_max
8878 @item __sec_reduce_min
8879 @item __sec_reduce_max_ind
8880 @item __sec_reduce_min_ind
8881 @item __sec_reduce_mul
8882 @item __sec_reduce_mutating
8883 @end itemize
8885 Further details and examples about these built-in functions are described 
8886 in the Cilk Plus language manual which can be found at 
8887 @uref{http://www.cilkplus.org}.
8889 @node Other Builtins
8890 @section Other Built-in Functions Provided by GCC
8891 @cindex built-in functions
8892 @findex __builtin_fpclassify
8893 @findex __builtin_isfinite
8894 @findex __builtin_isnormal
8895 @findex __builtin_isgreater
8896 @findex __builtin_isgreaterequal
8897 @findex __builtin_isinf_sign
8898 @findex __builtin_isless
8899 @findex __builtin_islessequal
8900 @findex __builtin_islessgreater
8901 @findex __builtin_isunordered
8902 @findex __builtin_powi
8903 @findex __builtin_powif
8904 @findex __builtin_powil
8905 @findex _Exit
8906 @findex _exit
8907 @findex abort
8908 @findex abs
8909 @findex acos
8910 @findex acosf
8911 @findex acosh
8912 @findex acoshf
8913 @findex acoshl
8914 @findex acosl
8915 @findex alloca
8916 @findex asin
8917 @findex asinf
8918 @findex asinh
8919 @findex asinhf
8920 @findex asinhl
8921 @findex asinl
8922 @findex atan
8923 @findex atan2
8924 @findex atan2f
8925 @findex atan2l
8926 @findex atanf
8927 @findex atanh
8928 @findex atanhf
8929 @findex atanhl
8930 @findex atanl
8931 @findex bcmp
8932 @findex bzero
8933 @findex cabs
8934 @findex cabsf
8935 @findex cabsl
8936 @findex cacos
8937 @findex cacosf
8938 @findex cacosh
8939 @findex cacoshf
8940 @findex cacoshl
8941 @findex cacosl
8942 @findex calloc
8943 @findex carg
8944 @findex cargf
8945 @findex cargl
8946 @findex casin
8947 @findex casinf
8948 @findex casinh
8949 @findex casinhf
8950 @findex casinhl
8951 @findex casinl
8952 @findex catan
8953 @findex catanf
8954 @findex catanh
8955 @findex catanhf
8956 @findex catanhl
8957 @findex catanl
8958 @findex cbrt
8959 @findex cbrtf
8960 @findex cbrtl
8961 @findex ccos
8962 @findex ccosf
8963 @findex ccosh
8964 @findex ccoshf
8965 @findex ccoshl
8966 @findex ccosl
8967 @findex ceil
8968 @findex ceilf
8969 @findex ceill
8970 @findex cexp
8971 @findex cexpf
8972 @findex cexpl
8973 @findex cimag
8974 @findex cimagf
8975 @findex cimagl
8976 @findex clog
8977 @findex clogf
8978 @findex clogl
8979 @findex conj
8980 @findex conjf
8981 @findex conjl
8982 @findex copysign
8983 @findex copysignf
8984 @findex copysignl
8985 @findex cos
8986 @findex cosf
8987 @findex cosh
8988 @findex coshf
8989 @findex coshl
8990 @findex cosl
8991 @findex cpow
8992 @findex cpowf
8993 @findex cpowl
8994 @findex cproj
8995 @findex cprojf
8996 @findex cprojl
8997 @findex creal
8998 @findex crealf
8999 @findex creall
9000 @findex csin
9001 @findex csinf
9002 @findex csinh
9003 @findex csinhf
9004 @findex csinhl
9005 @findex csinl
9006 @findex csqrt
9007 @findex csqrtf
9008 @findex csqrtl
9009 @findex ctan
9010 @findex ctanf
9011 @findex ctanh
9012 @findex ctanhf
9013 @findex ctanhl
9014 @findex ctanl
9015 @findex dcgettext
9016 @findex dgettext
9017 @findex drem
9018 @findex dremf
9019 @findex dreml
9020 @findex erf
9021 @findex erfc
9022 @findex erfcf
9023 @findex erfcl
9024 @findex erff
9025 @findex erfl
9026 @findex exit
9027 @findex exp
9028 @findex exp10
9029 @findex exp10f
9030 @findex exp10l
9031 @findex exp2
9032 @findex exp2f
9033 @findex exp2l
9034 @findex expf
9035 @findex expl
9036 @findex expm1
9037 @findex expm1f
9038 @findex expm1l
9039 @findex fabs
9040 @findex fabsf
9041 @findex fabsl
9042 @findex fdim
9043 @findex fdimf
9044 @findex fdiml
9045 @findex ffs
9046 @findex floor
9047 @findex floorf
9048 @findex floorl
9049 @findex fma
9050 @findex fmaf
9051 @findex fmal
9052 @findex fmax
9053 @findex fmaxf
9054 @findex fmaxl
9055 @findex fmin
9056 @findex fminf
9057 @findex fminl
9058 @findex fmod
9059 @findex fmodf
9060 @findex fmodl
9061 @findex fprintf
9062 @findex fprintf_unlocked
9063 @findex fputs
9064 @findex fputs_unlocked
9065 @findex frexp
9066 @findex frexpf
9067 @findex frexpl
9068 @findex fscanf
9069 @findex gamma
9070 @findex gammaf
9071 @findex gammal
9072 @findex gamma_r
9073 @findex gammaf_r
9074 @findex gammal_r
9075 @findex gettext
9076 @findex hypot
9077 @findex hypotf
9078 @findex hypotl
9079 @findex ilogb
9080 @findex ilogbf
9081 @findex ilogbl
9082 @findex imaxabs
9083 @findex index
9084 @findex isalnum
9085 @findex isalpha
9086 @findex isascii
9087 @findex isblank
9088 @findex iscntrl
9089 @findex isdigit
9090 @findex isgraph
9091 @findex islower
9092 @findex isprint
9093 @findex ispunct
9094 @findex isspace
9095 @findex isupper
9096 @findex iswalnum
9097 @findex iswalpha
9098 @findex iswblank
9099 @findex iswcntrl
9100 @findex iswdigit
9101 @findex iswgraph
9102 @findex iswlower
9103 @findex iswprint
9104 @findex iswpunct
9105 @findex iswspace
9106 @findex iswupper
9107 @findex iswxdigit
9108 @findex isxdigit
9109 @findex j0
9110 @findex j0f
9111 @findex j0l
9112 @findex j1
9113 @findex j1f
9114 @findex j1l
9115 @findex jn
9116 @findex jnf
9117 @findex jnl
9118 @findex labs
9119 @findex ldexp
9120 @findex ldexpf
9121 @findex ldexpl
9122 @findex lgamma
9123 @findex lgammaf
9124 @findex lgammal
9125 @findex lgamma_r
9126 @findex lgammaf_r
9127 @findex lgammal_r
9128 @findex llabs
9129 @findex llrint
9130 @findex llrintf
9131 @findex llrintl
9132 @findex llround
9133 @findex llroundf
9134 @findex llroundl
9135 @findex log
9136 @findex log10
9137 @findex log10f
9138 @findex log10l
9139 @findex log1p
9140 @findex log1pf
9141 @findex log1pl
9142 @findex log2
9143 @findex log2f
9144 @findex log2l
9145 @findex logb
9146 @findex logbf
9147 @findex logbl
9148 @findex logf
9149 @findex logl
9150 @findex lrint
9151 @findex lrintf
9152 @findex lrintl
9153 @findex lround
9154 @findex lroundf
9155 @findex lroundl
9156 @findex malloc
9157 @findex memchr
9158 @findex memcmp
9159 @findex memcpy
9160 @findex mempcpy
9161 @findex memset
9162 @findex modf
9163 @findex modff
9164 @findex modfl
9165 @findex nearbyint
9166 @findex nearbyintf
9167 @findex nearbyintl
9168 @findex nextafter
9169 @findex nextafterf
9170 @findex nextafterl
9171 @findex nexttoward
9172 @findex nexttowardf
9173 @findex nexttowardl
9174 @findex pow
9175 @findex pow10
9176 @findex pow10f
9177 @findex pow10l
9178 @findex powf
9179 @findex powl
9180 @findex printf
9181 @findex printf_unlocked
9182 @findex putchar
9183 @findex puts
9184 @findex remainder
9185 @findex remainderf
9186 @findex remainderl
9187 @findex remquo
9188 @findex remquof
9189 @findex remquol
9190 @findex rindex
9191 @findex rint
9192 @findex rintf
9193 @findex rintl
9194 @findex round
9195 @findex roundf
9196 @findex roundl
9197 @findex scalb
9198 @findex scalbf
9199 @findex scalbl
9200 @findex scalbln
9201 @findex scalblnf
9202 @findex scalblnf
9203 @findex scalbn
9204 @findex scalbnf
9205 @findex scanfnl
9206 @findex signbit
9207 @findex signbitf
9208 @findex signbitl
9209 @findex signbitd32
9210 @findex signbitd64
9211 @findex signbitd128
9212 @findex significand
9213 @findex significandf
9214 @findex significandl
9215 @findex sin
9216 @findex sincos
9217 @findex sincosf
9218 @findex sincosl
9219 @findex sinf
9220 @findex sinh
9221 @findex sinhf
9222 @findex sinhl
9223 @findex sinl
9224 @findex snprintf
9225 @findex sprintf
9226 @findex sqrt
9227 @findex sqrtf
9228 @findex sqrtl
9229 @findex sscanf
9230 @findex stpcpy
9231 @findex stpncpy
9232 @findex strcasecmp
9233 @findex strcat
9234 @findex strchr
9235 @findex strcmp
9236 @findex strcpy
9237 @findex strcspn
9238 @findex strdup
9239 @findex strfmon
9240 @findex strftime
9241 @findex strlen
9242 @findex strncasecmp
9243 @findex strncat
9244 @findex strncmp
9245 @findex strncpy
9246 @findex strndup
9247 @findex strpbrk
9248 @findex strrchr
9249 @findex strspn
9250 @findex strstr
9251 @findex tan
9252 @findex tanf
9253 @findex tanh
9254 @findex tanhf
9255 @findex tanhl
9256 @findex tanl
9257 @findex tgamma
9258 @findex tgammaf
9259 @findex tgammal
9260 @findex toascii
9261 @findex tolower
9262 @findex toupper
9263 @findex towlower
9264 @findex towupper
9265 @findex trunc
9266 @findex truncf
9267 @findex truncl
9268 @findex vfprintf
9269 @findex vfscanf
9270 @findex vprintf
9271 @findex vscanf
9272 @findex vsnprintf
9273 @findex vsprintf
9274 @findex vsscanf
9275 @findex y0
9276 @findex y0f
9277 @findex y0l
9278 @findex y1
9279 @findex y1f
9280 @findex y1l
9281 @findex yn
9282 @findex ynf
9283 @findex ynl
9285 GCC provides a large number of built-in functions other than the ones
9286 mentioned above.  Some of these are for internal use in the processing
9287 of exceptions or variable-length argument lists and are not
9288 documented here because they may change from time to time; we do not
9289 recommend general use of these functions.
9291 The remaining functions are provided for optimization purposes.
9293 @opindex fno-builtin
9294 GCC includes built-in versions of many of the functions in the standard
9295 C library.  The versions prefixed with @code{__builtin_} are always
9296 treated as having the same meaning as the C library function even if you
9297 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9298 Many of these functions are only optimized in certain cases; if they are
9299 not optimized in a particular case, a call to the library function is
9300 emitted.
9302 @opindex ansi
9303 @opindex std
9304 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9305 @option{-std=c99} or @option{-std=c11}), the functions
9306 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9307 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9308 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9309 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9310 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9311 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9312 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9313 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9314 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9315 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9316 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9317 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9318 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9319 @code{significandl}, @code{significand}, @code{sincosf},
9320 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9321 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9322 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9323 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9324 @code{yn}
9325 may be handled as built-in functions.
9326 All these functions have corresponding versions
9327 prefixed with @code{__builtin_}, which may be used even in strict C90
9328 mode.
9330 The ISO C99 functions
9331 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9332 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9333 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9334 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9335 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9336 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9337 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9338 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9339 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9340 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9341 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9342 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9343 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9344 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9345 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9346 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9347 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9348 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9349 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9350 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9351 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9352 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9353 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9354 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9355 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9356 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9357 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9358 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9359 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9360 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9361 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9362 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9363 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9364 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9365 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9366 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9367 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9368 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9369 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9370 are handled as built-in functions
9371 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9373 There are also built-in versions of the ISO C99 functions
9374 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9375 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9376 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9377 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9378 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9379 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9380 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9381 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9382 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9383 that are recognized in any mode since ISO C90 reserves these names for
9384 the purpose to which ISO C99 puts them.  All these functions have
9385 corresponding versions prefixed with @code{__builtin_}.
9387 The ISO C94 functions
9388 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9389 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9390 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9391 @code{towupper}
9392 are handled as built-in functions
9393 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9395 The ISO C90 functions
9396 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9397 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9398 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9399 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9400 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9401 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9402 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9403 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9404 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9405 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9406 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9407 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9408 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9409 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9410 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9411 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9412 are all recognized as built-in functions unless
9413 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9414 is specified for an individual function).  All of these functions have
9415 corresponding versions prefixed with @code{__builtin_}.
9417 GCC provides built-in versions of the ISO C99 floating-point comparison
9418 macros that avoid raising exceptions for unordered operands.  They have
9419 the same names as the standard macros ( @code{isgreater},
9420 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9421 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9422 prefixed.  We intend for a library implementor to be able to simply
9423 @code{#define} each standard macro to its built-in equivalent.
9424 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9425 @code{isinf_sign} and @code{isnormal} built-ins used with
9426 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9427 built-in functions appear both with and without the @code{__builtin_} prefix.
9429 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9431 You can use the built-in function @code{__builtin_types_compatible_p} to
9432 determine whether two types are the same.
9434 This built-in function returns 1 if the unqualified versions of the
9435 types @var{type1} and @var{type2} (which are types, not expressions) are
9436 compatible, 0 otherwise.  The result of this built-in function can be
9437 used in integer constant expressions.
9439 This built-in function ignores top level qualifiers (e.g., @code{const},
9440 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9441 int}.
9443 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9444 hand, @code{int} and @code{char *} are not compatible, even if the size
9445 of their types, on the particular architecture are the same.  Also, the
9446 amount of pointer indirection is taken into account when determining
9447 similarity.  Consequently, @code{short *} is not similar to
9448 @code{short **}.  Furthermore, two types that are typedefed are
9449 considered compatible if their underlying types are compatible.
9451 An @code{enum} type is not considered to be compatible with another
9452 @code{enum} type even if both are compatible with the same integer
9453 type; this is what the C standard specifies.
9454 For example, @code{enum @{foo, bar@}} is not similar to
9455 @code{enum @{hot, dog@}}.
9457 You typically use this function in code whose execution varies
9458 depending on the arguments' types.  For example:
9460 @smallexample
9461 #define foo(x)                                                  \
9462   (@{                                                           \
9463     typeof (x) tmp = (x);                                       \
9464     if (__builtin_types_compatible_p (typeof (x), long double)) \
9465       tmp = foo_long_double (tmp);                              \
9466     else if (__builtin_types_compatible_p (typeof (x), double)) \
9467       tmp = foo_double (tmp);                                   \
9468     else if (__builtin_types_compatible_p (typeof (x), float))  \
9469       tmp = foo_float (tmp);                                    \
9470     else                                                        \
9471       abort ();                                                 \
9472     tmp;                                                        \
9473   @})
9474 @end smallexample
9476 @emph{Note:} This construct is only available for C@.
9478 @end deftypefn
9480 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9482 You can use the built-in function @code{__builtin_choose_expr} to
9483 evaluate code depending on the value of a constant expression.  This
9484 built-in function returns @var{exp1} if @var{const_exp}, which is an
9485 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9487 This built-in function is analogous to the @samp{? :} operator in C,
9488 except that the expression returned has its type unaltered by promotion
9489 rules.  Also, the built-in function does not evaluate the expression
9490 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9491 @var{exp2} is not evaluated even if it has side-effects.
9493 This built-in function can return an lvalue if the chosen argument is an
9494 lvalue.
9496 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9497 type.  Similarly, if @var{exp2} is returned, its return type is the same
9498 as @var{exp2}.
9500 Example:
9502 @smallexample
9503 #define foo(x)                                                    \
9504   __builtin_choose_expr (                                         \
9505     __builtin_types_compatible_p (typeof (x), double),            \
9506     foo_double (x),                                               \
9507     __builtin_choose_expr (                                       \
9508       __builtin_types_compatible_p (typeof (x), float),           \
9509       foo_float (x),                                              \
9510       /* @r{The void expression results in a compile-time error}  \
9511          @r{when assigning the result to something.}  */          \
9512       (void)0))
9513 @end smallexample
9515 @emph{Note:} This construct is only available for C@.  Furthermore, the
9516 unused expression (@var{exp1} or @var{exp2} depending on the value of
9517 @var{const_exp}) may still generate syntax errors.  This may change in
9518 future revisions.
9520 @end deftypefn
9522 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9524 The built-in function @code{__builtin_complex} is provided for use in
9525 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9526 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9527 real binary floating-point type, and the result has the corresponding
9528 complex type with real and imaginary parts @var{real} and @var{imag}.
9529 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9530 infinities, NaNs and negative zeros are involved.
9532 @end deftypefn
9534 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9535 You can use the built-in function @code{__builtin_constant_p} to
9536 determine if a value is known to be constant at compile time and hence
9537 that GCC can perform constant-folding on expressions involving that
9538 value.  The argument of the function is the value to test.  The function
9539 returns the integer 1 if the argument is known to be a compile-time
9540 constant and 0 if it is not known to be a compile-time constant.  A
9541 return of 0 does not indicate that the value is @emph{not} a constant,
9542 but merely that GCC cannot prove it is a constant with the specified
9543 value of the @option{-O} option.
9545 You typically use this function in an embedded application where
9546 memory is a critical resource.  If you have some complex calculation,
9547 you may want it to be folded if it involves constants, but need to call
9548 a function if it does not.  For example:
9550 @smallexample
9551 #define Scale_Value(X)      \
9552   (__builtin_constant_p (X) \
9553   ? ((X) * SCALE + OFFSET) : Scale (X))
9554 @end smallexample
9556 You may use this built-in function in either a macro or an inline
9557 function.  However, if you use it in an inlined function and pass an
9558 argument of the function as the argument to the built-in, GCC 
9559 never returns 1 when you call the inline function with a string constant
9560 or compound literal (@pxref{Compound Literals}) and does not return 1
9561 when you pass a constant numeric value to the inline function unless you
9562 specify the @option{-O} option.
9564 You may also use @code{__builtin_constant_p} in initializers for static
9565 data.  For instance, you can write
9567 @smallexample
9568 static const int table[] = @{
9569    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9570    /* @r{@dots{}} */
9572 @end smallexample
9574 @noindent
9575 This is an acceptable initializer even if @var{EXPRESSION} is not a
9576 constant expression, including the case where
9577 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9578 folded to a constant but @var{EXPRESSION} contains operands that are
9579 not otherwise permitted in a static initializer (for example,
9580 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9581 built-in in this case, because it has no opportunity to perform
9582 optimization.
9584 Previous versions of GCC did not accept this built-in in data
9585 initializers.  The earliest version where it is completely safe is
9586 3.0.1.
9587 @end deftypefn
9589 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9590 @opindex fprofile-arcs
9591 You may use @code{__builtin_expect} to provide the compiler with
9592 branch prediction information.  In general, you should prefer to
9593 use actual profile feedback for this (@option{-fprofile-arcs}), as
9594 programmers are notoriously bad at predicting how their programs
9595 actually perform.  However, there are applications in which this
9596 data is hard to collect.
9598 The return value is the value of @var{exp}, which should be an integral
9599 expression.  The semantics of the built-in are that it is expected that
9600 @var{exp} == @var{c}.  For example:
9602 @smallexample
9603 if (__builtin_expect (x, 0))
9604   foo ();
9605 @end smallexample
9607 @noindent
9608 indicates that we do not expect to call @code{foo}, since
9609 we expect @code{x} to be zero.  Since you are limited to integral
9610 expressions for @var{exp}, you should use constructions such as
9612 @smallexample
9613 if (__builtin_expect (ptr != NULL, 1))
9614   foo (*ptr);
9615 @end smallexample
9617 @noindent
9618 when testing pointer or floating-point values.
9619 @end deftypefn
9621 @deftypefn {Built-in Function} void __builtin_trap (void)
9622 This function causes the program to exit abnormally.  GCC implements
9623 this function by using a target-dependent mechanism (such as
9624 intentionally executing an illegal instruction) or by calling
9625 @code{abort}.  The mechanism used may vary from release to release so
9626 you should not rely on any particular implementation.
9627 @end deftypefn
9629 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9630 If control flow reaches the point of the @code{__builtin_unreachable},
9631 the program is undefined.  It is useful in situations where the
9632 compiler cannot deduce the unreachability of the code.
9634 One such case is immediately following an @code{asm} statement that
9635 either never terminates, or one that transfers control elsewhere
9636 and never returns.  In this example, without the
9637 @code{__builtin_unreachable}, GCC issues a warning that control
9638 reaches the end of a non-void function.  It also generates code
9639 to return after the @code{asm}.
9641 @smallexample
9642 int f (int c, int v)
9644   if (c)
9645     @{
9646       return v;
9647     @}
9648   else
9649     @{
9650       asm("jmp error_handler");
9651       __builtin_unreachable ();
9652     @}
9654 @end smallexample
9656 @noindent
9657 Because the @code{asm} statement unconditionally transfers control out
9658 of the function, control never reaches the end of the function
9659 body.  The @code{__builtin_unreachable} is in fact unreachable and
9660 communicates this fact to the compiler.
9662 Another use for @code{__builtin_unreachable} is following a call a
9663 function that never returns but that is not declared
9664 @code{__attribute__((noreturn))}, as in this example:
9666 @smallexample
9667 void function_that_never_returns (void);
9669 int g (int c)
9671   if (c)
9672     @{
9673       return 1;
9674     @}
9675   else
9676     @{
9677       function_that_never_returns ();
9678       __builtin_unreachable ();
9679     @}
9681 @end smallexample
9683 @end deftypefn
9685 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9686 This function returns its first argument, and allows the compiler
9687 to assume that the returned pointer is at least @var{align} bytes
9688 aligned.  This built-in can have either two or three arguments,
9689 if it has three, the third argument should have integer type, and
9690 if it is nonzero means misalignment offset.  For example:
9692 @smallexample
9693 void *x = __builtin_assume_aligned (arg, 16);
9694 @end smallexample
9696 @noindent
9697 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9698 16-byte aligned, while:
9700 @smallexample
9701 void *x = __builtin_assume_aligned (arg, 32, 8);
9702 @end smallexample
9704 @noindent
9705 means that the compiler can assume for @code{x}, set to @code{arg}, that
9706 @code{(char *) x - 8} is 32-byte aligned.
9707 @end deftypefn
9709 @deftypefn {Built-in Function} int __builtin_LINE ()
9710 This function is the equivalent to the preprocessor @code{__LINE__}
9711 macro and returns the line number of the invocation of the built-in.
9712 In a C++ default argument for a function @var{F}, it gets the line number of
9713 the call to @var{F}.
9714 @end deftypefn
9716 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9717 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9718 macro and returns the function name the invocation of the built-in is in.
9719 @end deftypefn
9721 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9722 This function is the equivalent to the preprocessor @code{__FILE__}
9723 macro and returns the file name the invocation of the built-in is in.
9724 In a C++ default argument for a function @var{F}, it gets the file name of
9725 the call to @var{F}.
9726 @end deftypefn
9728 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9729 This function is used to flush the processor's instruction cache for
9730 the region of memory between @var{begin} inclusive and @var{end}
9731 exclusive.  Some targets require that the instruction cache be
9732 flushed, after modifying memory containing code, in order to obtain
9733 deterministic behavior.
9735 If the target does not require instruction cache flushes,
9736 @code{__builtin___clear_cache} has no effect.  Otherwise either
9737 instructions are emitted in-line to clear the instruction cache or a
9738 call to the @code{__clear_cache} function in libgcc is made.
9739 @end deftypefn
9741 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9742 This function is used to minimize cache-miss latency by moving data into
9743 a cache before it is accessed.
9744 You can insert calls to @code{__builtin_prefetch} into code for which
9745 you know addresses of data in memory that is likely to be accessed soon.
9746 If the target supports them, data prefetch instructions are generated.
9747 If the prefetch is done early enough before the access then the data will
9748 be in the cache by the time it is accessed.
9750 The value of @var{addr} is the address of the memory to prefetch.
9751 There are two optional arguments, @var{rw} and @var{locality}.
9752 The value of @var{rw} is a compile-time constant one or zero; one
9753 means that the prefetch is preparing for a write to the memory address
9754 and zero, the default, means that the prefetch is preparing for a read.
9755 The value @var{locality} must be a compile-time constant integer between
9756 zero and three.  A value of zero means that the data has no temporal
9757 locality, so it need not be left in the cache after the access.  A value
9758 of three means that the data has a high degree of temporal locality and
9759 should be left in all levels of cache possible.  Values of one and two
9760 mean, respectively, a low or moderate degree of temporal locality.  The
9761 default is three.
9763 @smallexample
9764 for (i = 0; i < n; i++)
9765   @{
9766     a[i] = a[i] + b[i];
9767     __builtin_prefetch (&a[i+j], 1, 1);
9768     __builtin_prefetch (&b[i+j], 0, 1);
9769     /* @r{@dots{}} */
9770   @}
9771 @end smallexample
9773 Data prefetch does not generate faults if @var{addr} is invalid, but
9774 the address expression itself must be valid.  For example, a prefetch
9775 of @code{p->next} does not fault if @code{p->next} is not a valid
9776 address, but evaluation faults if @code{p} is not a valid address.
9778 If the target does not support data prefetch, the address expression
9779 is evaluated if it includes side effects but no other code is generated
9780 and GCC does not issue a warning.
9781 @end deftypefn
9783 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9784 Returns a positive infinity, if supported by the floating-point format,
9785 else @code{DBL_MAX}.  This function is suitable for implementing the
9786 ISO C macro @code{HUGE_VAL}.
9787 @end deftypefn
9789 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9790 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9791 @end deftypefn
9793 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9794 Similar to @code{__builtin_huge_val}, except the return
9795 type is @code{long double}.
9796 @end deftypefn
9798 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9799 This built-in implements the C99 fpclassify functionality.  The first
9800 five int arguments should be the target library's notion of the
9801 possible FP classes and are used for return values.  They must be
9802 constant values and they must appear in this order: @code{FP_NAN},
9803 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9804 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9805 to classify.  GCC treats the last argument as type-generic, which
9806 means it does not do default promotion from float to double.
9807 @end deftypefn
9809 @deftypefn {Built-in Function} double __builtin_inf (void)
9810 Similar to @code{__builtin_huge_val}, except a warning is generated
9811 if the target floating-point format does not support infinities.
9812 @end deftypefn
9814 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9815 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9816 @end deftypefn
9818 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9819 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9820 @end deftypefn
9822 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9823 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9824 @end deftypefn
9826 @deftypefn {Built-in Function} float __builtin_inff (void)
9827 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9828 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9829 @end deftypefn
9831 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9832 Similar to @code{__builtin_inf}, except the return
9833 type is @code{long double}.
9834 @end deftypefn
9836 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9837 Similar to @code{isinf}, except the return value is -1 for
9838 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9839 Note while the parameter list is an
9840 ellipsis, this function only accepts exactly one floating-point
9841 argument.  GCC treats this parameter as type-generic, which means it
9842 does not do default promotion from float to double.
9843 @end deftypefn
9845 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9846 This is an implementation of the ISO C99 function @code{nan}.
9848 Since ISO C99 defines this function in terms of @code{strtod}, which we
9849 do not implement, a description of the parsing is in order.  The string
9850 is parsed as by @code{strtol}; that is, the base is recognized by
9851 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9852 in the significand such that the least significant bit of the number
9853 is at the least significant bit of the significand.  The number is
9854 truncated to fit the significand field provided.  The significand is
9855 forced to be a quiet NaN@.
9857 This function, if given a string literal all of which would have been
9858 consumed by @code{strtol}, is evaluated early enough that it is considered a
9859 compile-time constant.
9860 @end deftypefn
9862 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9863 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9864 @end deftypefn
9866 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9867 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9868 @end deftypefn
9870 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9871 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9872 @end deftypefn
9874 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9875 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9876 @end deftypefn
9878 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9879 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9880 @end deftypefn
9882 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9883 Similar to @code{__builtin_nan}, except the significand is forced
9884 to be a signaling NaN@.  The @code{nans} function is proposed by
9885 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9886 @end deftypefn
9888 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9889 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9890 @end deftypefn
9892 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9893 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9894 @end deftypefn
9896 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9897 Returns one plus the index of the least significant 1-bit of @var{x}, or
9898 if @var{x} is zero, returns zero.
9899 @end deftypefn
9901 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9902 Returns the number of leading 0-bits in @var{x}, starting at the most
9903 significant bit position.  If @var{x} is 0, the result is undefined.
9904 @end deftypefn
9906 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9907 Returns the number of trailing 0-bits in @var{x}, starting at the least
9908 significant bit position.  If @var{x} is 0, the result is undefined.
9909 @end deftypefn
9911 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9912 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9913 number of bits following the most significant bit that are identical
9914 to it.  There are no special cases for 0 or other values. 
9915 @end deftypefn
9917 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9918 Returns the number of 1-bits in @var{x}.
9919 @end deftypefn
9921 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9922 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9923 modulo 2.
9924 @end deftypefn
9926 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9927 Similar to @code{__builtin_ffs}, except the argument type is
9928 @code{long}.
9929 @end deftypefn
9931 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9932 Similar to @code{__builtin_clz}, except the argument type is
9933 @code{unsigned long}.
9934 @end deftypefn
9936 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9937 Similar to @code{__builtin_ctz}, except the argument type is
9938 @code{unsigned long}.
9939 @end deftypefn
9941 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9942 Similar to @code{__builtin_clrsb}, except the argument type is
9943 @code{long}.
9944 @end deftypefn
9946 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9947 Similar to @code{__builtin_popcount}, except the argument type is
9948 @code{unsigned long}.
9949 @end deftypefn
9951 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9952 Similar to @code{__builtin_parity}, except the argument type is
9953 @code{unsigned long}.
9954 @end deftypefn
9956 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9957 Similar to @code{__builtin_ffs}, except the argument type is
9958 @code{long long}.
9959 @end deftypefn
9961 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9962 Similar to @code{__builtin_clz}, except the argument type is
9963 @code{unsigned long long}.
9964 @end deftypefn
9966 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9967 Similar to @code{__builtin_ctz}, except the argument type is
9968 @code{unsigned long long}.
9969 @end deftypefn
9971 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9972 Similar to @code{__builtin_clrsb}, except the argument type is
9973 @code{long long}.
9974 @end deftypefn
9976 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9977 Similar to @code{__builtin_popcount}, except the argument type is
9978 @code{unsigned long long}.
9979 @end deftypefn
9981 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9982 Similar to @code{__builtin_parity}, except the argument type is
9983 @code{unsigned long long}.
9984 @end deftypefn
9986 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9987 Returns the first argument raised to the power of the second.  Unlike the
9988 @code{pow} function no guarantees about precision and rounding are made.
9989 @end deftypefn
9991 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9992 Similar to @code{__builtin_powi}, except the argument and return types
9993 are @code{float}.
9994 @end deftypefn
9996 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9997 Similar to @code{__builtin_powi}, except the argument and return types
9998 are @code{long double}.
9999 @end deftypefn
10001 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10002 Returns @var{x} with the order of the bytes reversed; for example,
10003 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10004 exactly 8 bits.
10005 @end deftypefn
10007 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10008 Similar to @code{__builtin_bswap16}, except the argument and return types
10009 are 32 bit.
10010 @end deftypefn
10012 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10013 Similar to @code{__builtin_bswap32}, except the argument and return types
10014 are 64 bit.
10015 @end deftypefn
10017 @node Target Builtins
10018 @section Built-in Functions Specific to Particular Target Machines
10020 On some target machines, GCC supports many built-in functions specific
10021 to those machines.  Generally these generate calls to specific machine
10022 instructions, but allow the compiler to schedule those calls.
10024 @menu
10025 * AArch64 Built-in Functions::
10026 * AArch64 intrinsics::
10027 * Alpha Built-in Functions::
10028 * Altera Nios II Built-in Functions::
10029 * ARC Built-in Functions::
10030 * ARC SIMD Built-in Functions::
10031 * ARM iWMMXt Built-in Functions::
10032 * ARM NEON Intrinsics::
10033 * ARM ACLE Intrinsics::
10034 * ARM Floating Point Status and Control Intrinsics::
10035 * AVR Built-in Functions::
10036 * Blackfin Built-in Functions::
10037 * FR-V Built-in Functions::
10038 * X86 Built-in Functions::
10039 * X86 transactional memory intrinsics::
10040 * MIPS DSP Built-in Functions::
10041 * MIPS Paired-Single Support::
10042 * MIPS Loongson Built-in Functions::
10043 * Other MIPS Built-in Functions::
10044 * MSP430 Built-in Functions::
10045 * NDS32 Built-in Functions::
10046 * picoChip Built-in Functions::
10047 * PowerPC Built-in Functions::
10048 * PowerPC AltiVec/VSX Built-in Functions::
10049 * PowerPC Hardware Transactional Memory Built-in Functions::
10050 * RX Built-in Functions::
10051 * S/390 System z Built-in Functions::
10052 * SH Built-in Functions::
10053 * SPARC VIS Built-in Functions::
10054 * SPU Built-in Functions::
10055 * TI C6X Built-in Functions::
10056 * TILE-Gx Built-in Functions::
10057 * TILEPro Built-in Functions::
10058 @end menu
10060 @node AArch64 Built-in Functions
10061 @subsection AArch64 Built-in Functions
10063 These built-in functions are available for the AArch64 family of
10064 processors.
10065 @smallexample
10066 unsigned int __builtin_aarch64_get_fpcr ()
10067 void __builtin_aarch64_set_fpcr (unsigned int)
10068 unsigned int __builtin_aarch64_get_fpsr ()
10069 void __builtin_aarch64_set_fpsr (unsigned int)
10070 @end smallexample
10072 @node AArch64 intrinsics
10073 @subsection ACLE Intrinsics for AArch64
10075 @include aarch64-acle-intrinsics.texi
10077 @node Alpha Built-in Functions
10078 @subsection Alpha Built-in Functions
10080 These built-in functions are available for the Alpha family of
10081 processors, depending on the command-line switches used.
10083 The following built-in functions are always available.  They
10084 all generate the machine instruction that is part of the name.
10086 @smallexample
10087 long __builtin_alpha_implver (void)
10088 long __builtin_alpha_rpcc (void)
10089 long __builtin_alpha_amask (long)
10090 long __builtin_alpha_cmpbge (long, long)
10091 long __builtin_alpha_extbl (long, long)
10092 long __builtin_alpha_extwl (long, long)
10093 long __builtin_alpha_extll (long, long)
10094 long __builtin_alpha_extql (long, long)
10095 long __builtin_alpha_extwh (long, long)
10096 long __builtin_alpha_extlh (long, long)
10097 long __builtin_alpha_extqh (long, long)
10098 long __builtin_alpha_insbl (long, long)
10099 long __builtin_alpha_inswl (long, long)
10100 long __builtin_alpha_insll (long, long)
10101 long __builtin_alpha_insql (long, long)
10102 long __builtin_alpha_inswh (long, long)
10103 long __builtin_alpha_inslh (long, long)
10104 long __builtin_alpha_insqh (long, long)
10105 long __builtin_alpha_mskbl (long, long)
10106 long __builtin_alpha_mskwl (long, long)
10107 long __builtin_alpha_mskll (long, long)
10108 long __builtin_alpha_mskql (long, long)
10109 long __builtin_alpha_mskwh (long, long)
10110 long __builtin_alpha_msklh (long, long)
10111 long __builtin_alpha_mskqh (long, long)
10112 long __builtin_alpha_umulh (long, long)
10113 long __builtin_alpha_zap (long, long)
10114 long __builtin_alpha_zapnot (long, long)
10115 @end smallexample
10117 The following built-in functions are always with @option{-mmax}
10118 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10119 later.  They all generate the machine instruction that is part
10120 of the name.
10122 @smallexample
10123 long __builtin_alpha_pklb (long)
10124 long __builtin_alpha_pkwb (long)
10125 long __builtin_alpha_unpkbl (long)
10126 long __builtin_alpha_unpkbw (long)
10127 long __builtin_alpha_minub8 (long, long)
10128 long __builtin_alpha_minsb8 (long, long)
10129 long __builtin_alpha_minuw4 (long, long)
10130 long __builtin_alpha_minsw4 (long, long)
10131 long __builtin_alpha_maxub8 (long, long)
10132 long __builtin_alpha_maxsb8 (long, long)
10133 long __builtin_alpha_maxuw4 (long, long)
10134 long __builtin_alpha_maxsw4 (long, long)
10135 long __builtin_alpha_perr (long, long)
10136 @end smallexample
10138 The following built-in functions are always with @option{-mcix}
10139 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10140 later.  They all generate the machine instruction that is part
10141 of the name.
10143 @smallexample
10144 long __builtin_alpha_cttz (long)
10145 long __builtin_alpha_ctlz (long)
10146 long __builtin_alpha_ctpop (long)
10147 @end smallexample
10149 The following built-in functions are available on systems that use the OSF/1
10150 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10151 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10152 @code{rdval} and @code{wrval}.
10154 @smallexample
10155 void *__builtin_thread_pointer (void)
10156 void __builtin_set_thread_pointer (void *)
10157 @end smallexample
10159 @node Altera Nios II Built-in Functions
10160 @subsection Altera Nios II Built-in Functions
10162 These built-in functions are available for the Altera Nios II
10163 family of processors.
10165 The following built-in functions are always available.  They
10166 all generate the machine instruction that is part of the name.
10168 @example
10169 int __builtin_ldbio (volatile const void *)
10170 int __builtin_ldbuio (volatile const void *)
10171 int __builtin_ldhio (volatile const void *)
10172 int __builtin_ldhuio (volatile const void *)
10173 int __builtin_ldwio (volatile const void *)
10174 void __builtin_stbio (volatile void *, int)
10175 void __builtin_sthio (volatile void *, int)
10176 void __builtin_stwio (volatile void *, int)
10177 void __builtin_sync (void)
10178 int __builtin_rdctl (int) 
10179 void __builtin_wrctl (int, int)
10180 @end example
10182 The following built-in functions are always available.  They
10183 all generate a Nios II Custom Instruction. The name of the
10184 function represents the types that the function takes and
10185 returns. The letter before the @code{n} is the return type
10186 or void if absent. The @code{n} represents the first parameter
10187 to all the custom instructions, the custom instruction number.
10188 The two letters after the @code{n} represent the up to two
10189 parameters to the function.
10191 The letters represent the following data types:
10192 @table @code
10193 @item <no letter>
10194 @code{void} for return type and no parameter for parameter types.
10196 @item i
10197 @code{int} for return type and parameter type
10199 @item f
10200 @code{float} for return type and parameter type
10202 @item p
10203 @code{void *} for return type and parameter type
10205 @end table
10207 And the function names are:
10208 @example
10209 void __builtin_custom_n (void)
10210 void __builtin_custom_ni (int)
10211 void __builtin_custom_nf (float)
10212 void __builtin_custom_np (void *)
10213 void __builtin_custom_nii (int, int)
10214 void __builtin_custom_nif (int, float)
10215 void __builtin_custom_nip (int, void *)
10216 void __builtin_custom_nfi (float, int)
10217 void __builtin_custom_nff (float, float)
10218 void __builtin_custom_nfp (float, void *)
10219 void __builtin_custom_npi (void *, int)
10220 void __builtin_custom_npf (void *, float)
10221 void __builtin_custom_npp (void *, void *)
10222 int __builtin_custom_in (void)
10223 int __builtin_custom_ini (int)
10224 int __builtin_custom_inf (float)
10225 int __builtin_custom_inp (void *)
10226 int __builtin_custom_inii (int, int)
10227 int __builtin_custom_inif (int, float)
10228 int __builtin_custom_inip (int, void *)
10229 int __builtin_custom_infi (float, int)
10230 int __builtin_custom_inff (float, float)
10231 int __builtin_custom_infp (float, void *)
10232 int __builtin_custom_inpi (void *, int)
10233 int __builtin_custom_inpf (void *, float)
10234 int __builtin_custom_inpp (void *, void *)
10235 float __builtin_custom_fn (void)
10236 float __builtin_custom_fni (int)
10237 float __builtin_custom_fnf (float)
10238 float __builtin_custom_fnp (void *)
10239 float __builtin_custom_fnii (int, int)
10240 float __builtin_custom_fnif (int, float)
10241 float __builtin_custom_fnip (int, void *)
10242 float __builtin_custom_fnfi (float, int)
10243 float __builtin_custom_fnff (float, float)
10244 float __builtin_custom_fnfp (float, void *)
10245 float __builtin_custom_fnpi (void *, int)
10246 float __builtin_custom_fnpf (void *, float)
10247 float __builtin_custom_fnpp (void *, void *)
10248 void * __builtin_custom_pn (void)
10249 void * __builtin_custom_pni (int)
10250 void * __builtin_custom_pnf (float)
10251 void * __builtin_custom_pnp (void *)
10252 void * __builtin_custom_pnii (int, int)
10253 void * __builtin_custom_pnif (int, float)
10254 void * __builtin_custom_pnip (int, void *)
10255 void * __builtin_custom_pnfi (float, int)
10256 void * __builtin_custom_pnff (float, float)
10257 void * __builtin_custom_pnfp (float, void *)
10258 void * __builtin_custom_pnpi (void *, int)
10259 void * __builtin_custom_pnpf (void *, float)
10260 void * __builtin_custom_pnpp (void *, void *)
10261 @end example
10263 @node ARC Built-in Functions
10264 @subsection ARC Built-in Functions
10266 The following built-in functions are provided for ARC targets.  The
10267 built-ins generate the corresponding assembly instructions.  In the
10268 examples given below, the generated code often requires an operand or
10269 result to be in a register.  Where necessary further code will be
10270 generated to ensure this is true, but for brevity this is not
10271 described in each case.
10273 @emph{Note:} Using a built-in to generate an instruction not supported
10274 by a target may cause problems. At present the compiler is not
10275 guaranteed to detect such misuse, and as a result an internal compiler
10276 error may be generated.
10278 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10279 Return 1 if @var{val} is known to have the byte alignment given
10280 by @var{alignval}, otherwise return 0.
10281 Note that this is different from
10282 @smallexample
10283 __alignof__(*(char *)@var{val}) >= alignval
10284 @end smallexample
10285 because __alignof__ sees only the type of the dereference, whereas
10286 __builtin_arc_align uses alignment information from the pointer
10287 as well as from the pointed-to type.
10288 The information available will depend on optimization level.
10289 @end deftypefn
10291 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10292 Generates
10293 @example
10295 @end example
10296 @end deftypefn
10298 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10299 The operand is the number of a register to be read.  Generates:
10300 @example
10301 mov  @var{dest}, r@var{regno}
10302 @end example
10303 where the value in @var{dest} will be the result returned from the
10304 built-in.
10305 @end deftypefn
10307 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10308 The first operand is the number of a register to be written, the
10309 second operand is a compile time constant to write into that
10310 register.  Generates:
10311 @example
10312 mov  r@var{regno}, @var{val}
10313 @end example
10314 @end deftypefn
10316 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10317 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10318 Generates:
10319 @example
10320 divaw  @var{dest}, @var{a}, @var{b}
10321 @end example
10322 where the value in @var{dest} will be the result returned from the
10323 built-in.
10324 @end deftypefn
10326 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10327 Generates
10328 @example
10329 flag  @var{a}
10330 @end example
10331 @end deftypefn
10333 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10334 The operand, @var{auxv}, is the address of an auxiliary register and
10335 must be a compile time constant.  Generates:
10336 @example
10337 lr  @var{dest}, [@var{auxr}]
10338 @end example
10339 Where the value in @var{dest} will be the result returned from the
10340 built-in.
10341 @end deftypefn
10343 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10344 Only available with @option{-mmul64}.  Generates:
10345 @example
10346 mul64  @var{a}, @var{b}
10347 @end example
10348 @end deftypefn
10350 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10351 Only available with @option{-mmul64}.  Generates:
10352 @example
10353 mulu64  @var{a}, @var{b}
10354 @end example
10355 @end deftypefn
10357 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10358 Generates:
10359 @example
10361 @end example
10362 @end deftypefn
10364 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10365 Only valid if the @samp{norm} instruction is available through the
10366 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10367 Generates:
10368 @example
10369 norm  @var{dest}, @var{src}
10370 @end example
10371 Where the value in @var{dest} will be the result returned from the
10372 built-in.
10373 @end deftypefn
10375 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10376 Only valid if the @samp{normw} instruction is available through the
10377 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10378 Generates:
10379 @example
10380 normw  @var{dest}, @var{src}
10381 @end example
10382 Where the value in @var{dest} will be the result returned from the
10383 built-in.
10384 @end deftypefn
10386 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10387 Generates:
10388 @example
10389 rtie
10390 @end example
10391 @end deftypefn
10393 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10394 Generates:
10395 @example
10396 sleep  @var{a}
10397 @end example
10398 @end deftypefn
10400 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10401 The first argument, @var{auxv}, is the address of an auxiliary
10402 register, the second argument, @var{val}, is a compile time constant
10403 to be written to the register.  Generates:
10404 @example
10405 sr  @var{auxr}, [@var{val}]
10406 @end example
10407 @end deftypefn
10409 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10410 Only valid with @option{-mswap}.  Generates:
10411 @example
10412 swap  @var{dest}, @var{src}
10413 @end example
10414 Where the value in @var{dest} will be the result returned from the
10415 built-in.
10416 @end deftypefn
10418 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10419 Generates:
10420 @example
10422 @end example
10423 @end deftypefn
10425 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10426 Only available with @option{-mcpu=ARC700}.  Generates:
10427 @example
10428 sync
10429 @end example
10430 @end deftypefn
10432 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10433 Only available with @option{-mcpu=ARC700}.  Generates:
10434 @example
10435 trap_s  @var{c}
10436 @end example
10437 @end deftypefn
10439 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10440 Only available with @option{-mcpu=ARC700}.  Generates:
10441 @example
10442 unimp_s
10443 @end example
10444 @end deftypefn
10446 The instructions generated by the following builtins are not
10447 considered as candidates for scheduling.  They are not moved around by
10448 the compiler during scheduling, and thus can be expected to appear
10449 where they are put in the C code:
10450 @example
10451 __builtin_arc_brk()
10452 __builtin_arc_core_read()
10453 __builtin_arc_core_write()
10454 __builtin_arc_flag()
10455 __builtin_arc_lr()
10456 __builtin_arc_sleep()
10457 __builtin_arc_sr()
10458 __builtin_arc_swi()
10459 @end example
10461 @node ARC SIMD Built-in Functions
10462 @subsection ARC SIMD Built-in Functions
10464 SIMD builtins provided by the compiler can be used to generate the
10465 vector instructions.  This section describes the available builtins
10466 and their usage in programs.  With the @option{-msimd} option, the
10467 compiler provides 128-bit vector types, which can be specified using
10468 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10469 can be included to use the following predefined types:
10470 @example
10471 typedef int __v4si   __attribute__((vector_size(16)));
10472 typedef short __v8hi __attribute__((vector_size(16)));
10473 @end example
10475 These types can be used to define 128-bit variables.  The built-in
10476 functions listed in the following section can be used on these
10477 variables to generate the vector operations.
10479 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10480 @file{arc-simd.h} also provides equivalent macros called
10481 @code{_@var{someinsn}} that can be used for programming ease and
10482 improved readability.  The following macros for DMA control are also
10483 provided:
10484 @example
10485 #define _setup_dma_in_channel_reg _vdiwr
10486 #define _setup_dma_out_channel_reg _vdowr
10487 @end example
10489 The following is a complete list of all the SIMD built-ins provided
10490 for ARC, grouped by calling signature.
10492 The following take two @code{__v8hi} arguments and return a
10493 @code{__v8hi} result:
10494 @example
10495 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10496 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10497 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10498 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10499 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10500 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10501 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10502 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10503 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10504 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10505 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10506 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10507 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10508 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10509 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10510 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10511 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10512 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10513 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10514 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10515 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10516 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10517 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10518 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10519 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10520 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10521 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10522 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10523 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10524 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10525 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10526 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10527 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10528 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10529 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10530 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10531 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10532 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10533 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10534 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10535 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10536 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10537 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10538 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10539 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10540 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10541 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10542 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10543 @end example
10545 The following take one @code{__v8hi} and one @code{int} argument and return a
10546 @code{__v8hi} result:
10548 @example
10549 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10550 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10551 __v8hi __builtin_arc_vbminw (__v8hi, int)
10552 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10553 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10554 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10555 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10556 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10557 @end example
10559 The following take one @code{__v8hi} argument and one @code{int} argument which
10560 must be a 3-bit compile time constant indicating a register number
10561 I0-I7.  They return a @code{__v8hi} result.
10562 @example
10563 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10564 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10565 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10566 @end example
10568 The following take one @code{__v8hi} argument and one @code{int}
10569 argument which must be a 6-bit compile time constant.  They return a
10570 @code{__v8hi} result.
10571 @example
10572 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10573 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10574 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10575 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10576 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10577 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10578 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10579 @end example
10581 The following take one @code{__v8hi} argument and one @code{int} argument which
10582 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10583 result.
10584 @example
10585 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10586 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10587 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10588 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10589 @end example
10591 The following take two @code{int} arguments, the second of which which
10592 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10593 result:
10594 @example
10595 __v8hi __builtin_arc_vmovaw (int, const int)
10596 __v8hi __builtin_arc_vmovw (int, const int)
10597 __v8hi __builtin_arc_vmovzw (int, const int)
10598 @end example
10600 The following take a single @code{__v8hi} argument and return a
10601 @code{__v8hi} result:
10602 @example
10603 __v8hi __builtin_arc_vabsaw (__v8hi)
10604 __v8hi __builtin_arc_vabsw (__v8hi)
10605 __v8hi __builtin_arc_vaddsuw (__v8hi)
10606 __v8hi __builtin_arc_vexch1 (__v8hi)
10607 __v8hi __builtin_arc_vexch2 (__v8hi)
10608 __v8hi __builtin_arc_vexch4 (__v8hi)
10609 __v8hi __builtin_arc_vsignw (__v8hi)
10610 __v8hi __builtin_arc_vupbaw (__v8hi)
10611 __v8hi __builtin_arc_vupbw (__v8hi)
10612 __v8hi __builtin_arc_vupsbaw (__v8hi)
10613 __v8hi __builtin_arc_vupsbw (__v8hi)
10614 @end example
10616 The followign take two @code{int} arguments and return no result:
10617 @example
10618 void __builtin_arc_vdirun (int, int)
10619 void __builtin_arc_vdorun (int, int)
10620 @end example
10622 The following take two @code{int} arguments and return no result.  The
10623 first argument must a 3-bit compile time constant indicating one of
10624 the DR0-DR7 DMA setup channels:
10625 @example
10626 void __builtin_arc_vdiwr (const int, int)
10627 void __builtin_arc_vdowr (const int, int)
10628 @end example
10630 The following take an @code{int} argument and return no result:
10631 @example
10632 void __builtin_arc_vendrec (int)
10633 void __builtin_arc_vrec (int)
10634 void __builtin_arc_vrecrun (int)
10635 void __builtin_arc_vrun (int)
10636 @end example
10638 The following take a @code{__v8hi} argument and two @code{int}
10639 arguments and return a @code{__v8hi} result.  The second argument must
10640 be a 3-bit compile time constants, indicating one the registers I0-I7,
10641 and the third argument must be an 8-bit compile time constant.
10643 @emph{Note:} Although the equivalent hardware instructions do not take
10644 an SIMD register as an operand, these builtins overwrite the relevant
10645 bits of the @code{__v8hi} register provided as the first argument with
10646 the value loaded from the @code{[Ib, u8]} location in the SDM.
10648 @example
10649 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10650 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10651 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10652 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10653 @end example
10655 The following take two @code{int} arguments and return a @code{__v8hi}
10656 result.  The first argument must be a 3-bit compile time constants,
10657 indicating one the registers I0-I7, and the second argument must be an
10658 8-bit compile time constant.
10660 @example
10661 __v8hi __builtin_arc_vld128 (const int, const int)
10662 __v8hi __builtin_arc_vld64w (const int, const int)
10663 @end example
10665 The following take a @code{__v8hi} argument and two @code{int}
10666 arguments and return no result.  The second argument must be a 3-bit
10667 compile time constants, indicating one the registers I0-I7, and the
10668 third argument must be an 8-bit compile time constant.
10670 @example
10671 void __builtin_arc_vst128 (__v8hi, const int, const int)
10672 void __builtin_arc_vst64 (__v8hi, const int, const int)
10673 @end example
10675 The following take a @code{__v8hi} argument and three @code{int}
10676 arguments and return no result.  The second argument must be a 3-bit
10677 compile-time constant, identifying the 16-bit sub-register to be
10678 stored, the third argument must be a 3-bit compile time constants,
10679 indicating one the registers I0-I7, and the fourth argument must be an
10680 8-bit compile time constant.
10682 @example
10683 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10684 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10685 @end example
10687 @node ARM iWMMXt Built-in Functions
10688 @subsection ARM iWMMXt Built-in Functions
10690 These built-in functions are available for the ARM family of
10691 processors when the @option{-mcpu=iwmmxt} switch is used:
10693 @smallexample
10694 typedef int v2si __attribute__ ((vector_size (8)));
10695 typedef short v4hi __attribute__ ((vector_size (8)));
10696 typedef char v8qi __attribute__ ((vector_size (8)));
10698 int __builtin_arm_getwcgr0 (void)
10699 void __builtin_arm_setwcgr0 (int)
10700 int __builtin_arm_getwcgr1 (void)
10701 void __builtin_arm_setwcgr1 (int)
10702 int __builtin_arm_getwcgr2 (void)
10703 void __builtin_arm_setwcgr2 (int)
10704 int __builtin_arm_getwcgr3 (void)
10705 void __builtin_arm_setwcgr3 (int)
10706 int __builtin_arm_textrmsb (v8qi, int)
10707 int __builtin_arm_textrmsh (v4hi, int)
10708 int __builtin_arm_textrmsw (v2si, int)
10709 int __builtin_arm_textrmub (v8qi, int)
10710 int __builtin_arm_textrmuh (v4hi, int)
10711 int __builtin_arm_textrmuw (v2si, int)
10712 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10713 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10714 v2si __builtin_arm_tinsrw (v2si, int, int)
10715 long long __builtin_arm_tmia (long long, int, int)
10716 long long __builtin_arm_tmiabb (long long, int, int)
10717 long long __builtin_arm_tmiabt (long long, int, int)
10718 long long __builtin_arm_tmiaph (long long, int, int)
10719 long long __builtin_arm_tmiatb (long long, int, int)
10720 long long __builtin_arm_tmiatt (long long, int, int)
10721 int __builtin_arm_tmovmskb (v8qi)
10722 int __builtin_arm_tmovmskh (v4hi)
10723 int __builtin_arm_tmovmskw (v2si)
10724 long long __builtin_arm_waccb (v8qi)
10725 long long __builtin_arm_wacch (v4hi)
10726 long long __builtin_arm_waccw (v2si)
10727 v8qi __builtin_arm_waddb (v8qi, v8qi)
10728 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10729 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10730 v4hi __builtin_arm_waddh (v4hi, v4hi)
10731 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10732 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10733 v2si __builtin_arm_waddw (v2si, v2si)
10734 v2si __builtin_arm_waddwss (v2si, v2si)
10735 v2si __builtin_arm_waddwus (v2si, v2si)
10736 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10737 long long __builtin_arm_wand(long long, long long)
10738 long long __builtin_arm_wandn (long long, long long)
10739 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10740 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10741 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10742 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10743 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10744 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10745 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10746 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10747 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10748 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10749 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10750 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10751 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10752 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10753 long long __builtin_arm_wmacsz (v4hi, v4hi)
10754 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10755 long long __builtin_arm_wmacuz (v4hi, v4hi)
10756 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10757 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10758 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10759 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10760 v2si __builtin_arm_wmaxsw (v2si, v2si)
10761 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10762 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10763 v2si __builtin_arm_wmaxuw (v2si, v2si)
10764 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10765 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10766 v2si __builtin_arm_wminsw (v2si, v2si)
10767 v8qi __builtin_arm_wminub (v8qi, v8qi)
10768 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10769 v2si __builtin_arm_wminuw (v2si, v2si)
10770 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10771 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10772 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10773 long long __builtin_arm_wor (long long, long long)
10774 v2si __builtin_arm_wpackdss (long long, long long)
10775 v2si __builtin_arm_wpackdus (long long, long long)
10776 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10777 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10778 v4hi __builtin_arm_wpackwss (v2si, v2si)
10779 v4hi __builtin_arm_wpackwus (v2si, v2si)
10780 long long __builtin_arm_wrord (long long, long long)
10781 long long __builtin_arm_wrordi (long long, int)
10782 v4hi __builtin_arm_wrorh (v4hi, long long)
10783 v4hi __builtin_arm_wrorhi (v4hi, int)
10784 v2si __builtin_arm_wrorw (v2si, long long)
10785 v2si __builtin_arm_wrorwi (v2si, int)
10786 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10787 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10788 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10789 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10790 v4hi __builtin_arm_wshufh (v4hi, int)
10791 long long __builtin_arm_wslld (long long, long long)
10792 long long __builtin_arm_wslldi (long long, int)
10793 v4hi __builtin_arm_wsllh (v4hi, long long)
10794 v4hi __builtin_arm_wsllhi (v4hi, int)
10795 v2si __builtin_arm_wsllw (v2si, long long)
10796 v2si __builtin_arm_wsllwi (v2si, int)
10797 long long __builtin_arm_wsrad (long long, long long)
10798 long long __builtin_arm_wsradi (long long, int)
10799 v4hi __builtin_arm_wsrah (v4hi, long long)
10800 v4hi __builtin_arm_wsrahi (v4hi, int)
10801 v2si __builtin_arm_wsraw (v2si, long long)
10802 v2si __builtin_arm_wsrawi (v2si, int)
10803 long long __builtin_arm_wsrld (long long, long long)
10804 long long __builtin_arm_wsrldi (long long, int)
10805 v4hi __builtin_arm_wsrlh (v4hi, long long)
10806 v4hi __builtin_arm_wsrlhi (v4hi, int)
10807 v2si __builtin_arm_wsrlw (v2si, long long)
10808 v2si __builtin_arm_wsrlwi (v2si, int)
10809 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10810 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10811 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10812 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10813 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10814 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10815 v2si __builtin_arm_wsubw (v2si, v2si)
10816 v2si __builtin_arm_wsubwss (v2si, v2si)
10817 v2si __builtin_arm_wsubwus (v2si, v2si)
10818 v4hi __builtin_arm_wunpckehsb (v8qi)
10819 v2si __builtin_arm_wunpckehsh (v4hi)
10820 long long __builtin_arm_wunpckehsw (v2si)
10821 v4hi __builtin_arm_wunpckehub (v8qi)
10822 v2si __builtin_arm_wunpckehuh (v4hi)
10823 long long __builtin_arm_wunpckehuw (v2si)
10824 v4hi __builtin_arm_wunpckelsb (v8qi)
10825 v2si __builtin_arm_wunpckelsh (v4hi)
10826 long long __builtin_arm_wunpckelsw (v2si)
10827 v4hi __builtin_arm_wunpckelub (v8qi)
10828 v2si __builtin_arm_wunpckeluh (v4hi)
10829 long long __builtin_arm_wunpckeluw (v2si)
10830 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10831 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10832 v2si __builtin_arm_wunpckihw (v2si, v2si)
10833 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10834 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10835 v2si __builtin_arm_wunpckilw (v2si, v2si)
10836 long long __builtin_arm_wxor (long long, long long)
10837 long long __builtin_arm_wzero ()
10838 @end smallexample
10840 @node ARM NEON Intrinsics
10841 @subsection ARM NEON Intrinsics
10843 These built-in intrinsics for the ARM Advanced SIMD extension are available
10844 when the @option{-mfpu=neon} switch is used:
10846 @include arm-neon-intrinsics.texi
10848 @node ARM ACLE Intrinsics
10849 @subsection ARM ACLE Intrinsics
10851 @include arm-acle-intrinsics.texi
10853 @node ARM Floating Point Status and Control Intrinsics
10854 @subsection ARM Floating Point Status and Control Intrinsics
10856 These built-in functions are available for the ARM family of
10857 processors with floating-point unit.
10859 @smallexample
10860 unsigned int __builtin_arm_get_fpscr ()
10861 void __builtin_arm_set_fpscr (unsigned int)
10862 @end smallexample
10864 @node AVR Built-in Functions
10865 @subsection AVR Built-in Functions
10867 For each built-in function for AVR, there is an equally named,
10868 uppercase built-in macro defined. That way users can easily query if
10869 or if not a specific built-in is implemented or not. For example, if
10870 @code{__builtin_avr_nop} is available the macro
10871 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10873 The following built-in functions map to the respective machine
10874 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10875 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10876 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10877 as library call if no hardware multiplier is available.
10879 @smallexample
10880 void __builtin_avr_nop (void)
10881 void __builtin_avr_sei (void)
10882 void __builtin_avr_cli (void)
10883 void __builtin_avr_sleep (void)
10884 void __builtin_avr_wdr (void)
10885 unsigned char __builtin_avr_swap (unsigned char)
10886 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10887 int __builtin_avr_fmuls (char, char)
10888 int __builtin_avr_fmulsu (char, unsigned char)
10889 @end smallexample
10891 In order to delay execution for a specific number of cycles, GCC
10892 implements
10893 @smallexample
10894 void __builtin_avr_delay_cycles (unsigned long ticks)
10895 @end smallexample
10897 @noindent
10898 @code{ticks} is the number of ticks to delay execution. Note that this
10899 built-in does not take into account the effect of interrupts that
10900 might increase delay time. @code{ticks} must be a compile-time
10901 integer constant; delays with a variable number of cycles are not supported.
10903 @smallexample
10904 char __builtin_avr_flash_segment (const __memx void*)
10905 @end smallexample
10907 @noindent
10908 This built-in takes a byte address to the 24-bit
10909 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10910 the number of the flash segment (the 64 KiB chunk) where the address
10911 points to.  Counting starts at @code{0}.
10912 If the address does not point to flash memory, return @code{-1}.
10914 @smallexample
10915 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10916 @end smallexample
10918 @noindent
10919 Insert bits from @var{bits} into @var{val} and return the resulting
10920 value. The nibbles of @var{map} determine how the insertion is
10921 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10922 @enumerate
10923 @item If @var{X} is @code{0xf},
10924 then the @var{n}-th bit of @var{val} is returned unaltered.
10926 @item If X is in the range 0@dots{}7,
10927 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10929 @item If X is in the range 8@dots{}@code{0xe},
10930 then the @var{n}-th result bit is undefined.
10931 @end enumerate
10933 @noindent
10934 One typical use case for this built-in is adjusting input and
10935 output values to non-contiguous port layouts. Some examples:
10937 @smallexample
10938 // same as val, bits is unused
10939 __builtin_avr_insert_bits (0xffffffff, bits, val)
10940 @end smallexample
10942 @smallexample
10943 // same as bits, val is unused
10944 __builtin_avr_insert_bits (0x76543210, bits, val)
10945 @end smallexample
10947 @smallexample
10948 // same as rotating bits by 4
10949 __builtin_avr_insert_bits (0x32107654, bits, 0)
10950 @end smallexample
10952 @smallexample
10953 // high nibble of result is the high nibble of val
10954 // low nibble of result is the low nibble of bits
10955 __builtin_avr_insert_bits (0xffff3210, bits, val)
10956 @end smallexample
10958 @smallexample
10959 // reverse the bit order of bits
10960 __builtin_avr_insert_bits (0x01234567, bits, 0)
10961 @end smallexample
10963 @node Blackfin Built-in Functions
10964 @subsection Blackfin Built-in Functions
10966 Currently, there are two Blackfin-specific built-in functions.  These are
10967 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10968 using inline assembly; by using these built-in functions the compiler can
10969 automatically add workarounds for hardware errata involving these
10970 instructions.  These functions are named as follows:
10972 @smallexample
10973 void __builtin_bfin_csync (void)
10974 void __builtin_bfin_ssync (void)
10975 @end smallexample
10977 @node FR-V Built-in Functions
10978 @subsection FR-V Built-in Functions
10980 GCC provides many FR-V-specific built-in functions.  In general,
10981 these functions are intended to be compatible with those described
10982 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
10983 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
10984 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
10985 pointer rather than by value.
10987 Most of the functions are named after specific FR-V instructions.
10988 Such functions are said to be ``directly mapped'' and are summarized
10989 here in tabular form.
10991 @menu
10992 * Argument Types::
10993 * Directly-mapped Integer Functions::
10994 * Directly-mapped Media Functions::
10995 * Raw read/write Functions::
10996 * Other Built-in Functions::
10997 @end menu
10999 @node Argument Types
11000 @subsubsection Argument Types
11002 The arguments to the built-in functions can be divided into three groups:
11003 register numbers, compile-time constants and run-time values.  In order
11004 to make this classification clear at a glance, the arguments and return
11005 values are given the following pseudo types:
11007 @multitable @columnfractions .20 .30 .15 .35
11008 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11009 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11010 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11011 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11012 @item @code{uw2} @tab @code{unsigned long long} @tab No
11013 @tab an unsigned doubleword
11014 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11015 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11016 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11017 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11018 @end multitable
11020 These pseudo types are not defined by GCC, they are simply a notational
11021 convenience used in this manual.
11023 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11024 and @code{sw2} are evaluated at run time.  They correspond to
11025 register operands in the underlying FR-V instructions.
11027 @code{const} arguments represent immediate operands in the underlying
11028 FR-V instructions.  They must be compile-time constants.
11030 @code{acc} arguments are evaluated at compile time and specify the number
11031 of an accumulator register.  For example, an @code{acc} argument of 2
11032 selects the ACC2 register.
11034 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11035 number of an IACC register.  See @pxref{Other Built-in Functions}
11036 for more details.
11038 @node Directly-mapped Integer Functions
11039 @subsubsection Directly-mapped Integer Functions
11041 The functions listed below map directly to FR-V I-type instructions.
11043 @multitable @columnfractions .45 .32 .23
11044 @item Function prototype @tab Example usage @tab Assembly output
11045 @item @code{sw1 __ADDSS (sw1, sw1)}
11046 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11047 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11048 @item @code{sw1 __SCAN (sw1, sw1)}
11049 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11050 @tab @code{SCAN @var{a},@var{b},@var{c}}
11051 @item @code{sw1 __SCUTSS (sw1)}
11052 @tab @code{@var{b} = __SCUTSS (@var{a})}
11053 @tab @code{SCUTSS @var{a},@var{b}}
11054 @item @code{sw1 __SLASS (sw1, sw1)}
11055 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11056 @tab @code{SLASS @var{a},@var{b},@var{c}}
11057 @item @code{void __SMASS (sw1, sw1)}
11058 @tab @code{__SMASS (@var{a}, @var{b})}
11059 @tab @code{SMASS @var{a},@var{b}}
11060 @item @code{void __SMSSS (sw1, sw1)}
11061 @tab @code{__SMSSS (@var{a}, @var{b})}
11062 @tab @code{SMSSS @var{a},@var{b}}
11063 @item @code{void __SMU (sw1, sw1)}
11064 @tab @code{__SMU (@var{a}, @var{b})}
11065 @tab @code{SMU @var{a},@var{b}}
11066 @item @code{sw2 __SMUL (sw1, sw1)}
11067 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11068 @tab @code{SMUL @var{a},@var{b},@var{c}}
11069 @item @code{sw1 __SUBSS (sw1, sw1)}
11070 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11071 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11072 @item @code{uw2 __UMUL (uw1, uw1)}
11073 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11074 @tab @code{UMUL @var{a},@var{b},@var{c}}
11075 @end multitable
11077 @node Directly-mapped Media Functions
11078 @subsubsection Directly-mapped Media Functions
11080 The functions listed below map directly to FR-V M-type instructions.
11082 @multitable @columnfractions .45 .32 .23
11083 @item Function prototype @tab Example usage @tab Assembly output
11084 @item @code{uw1 __MABSHS (sw1)}
11085 @tab @code{@var{b} = __MABSHS (@var{a})}
11086 @tab @code{MABSHS @var{a},@var{b}}
11087 @item @code{void __MADDACCS (acc, acc)}
11088 @tab @code{__MADDACCS (@var{b}, @var{a})}
11089 @tab @code{MADDACCS @var{a},@var{b}}
11090 @item @code{sw1 __MADDHSS (sw1, sw1)}
11091 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11092 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11093 @item @code{uw1 __MADDHUS (uw1, uw1)}
11094 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11095 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11096 @item @code{uw1 __MAND (uw1, uw1)}
11097 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11098 @tab @code{MAND @var{a},@var{b},@var{c}}
11099 @item @code{void __MASACCS (acc, acc)}
11100 @tab @code{__MASACCS (@var{b}, @var{a})}
11101 @tab @code{MASACCS @var{a},@var{b}}
11102 @item @code{uw1 __MAVEH (uw1, uw1)}
11103 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11104 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11105 @item @code{uw2 __MBTOH (uw1)}
11106 @tab @code{@var{b} = __MBTOH (@var{a})}
11107 @tab @code{MBTOH @var{a},@var{b}}
11108 @item @code{void __MBTOHE (uw1 *, uw1)}
11109 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11110 @tab @code{MBTOHE @var{a},@var{b}}
11111 @item @code{void __MCLRACC (acc)}
11112 @tab @code{__MCLRACC (@var{a})}
11113 @tab @code{MCLRACC @var{a}}
11114 @item @code{void __MCLRACCA (void)}
11115 @tab @code{__MCLRACCA ()}
11116 @tab @code{MCLRACCA}
11117 @item @code{uw1 __Mcop1 (uw1, uw1)}
11118 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11119 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11120 @item @code{uw1 __Mcop2 (uw1, uw1)}
11121 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11122 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11123 @item @code{uw1 __MCPLHI (uw2, const)}
11124 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11125 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11126 @item @code{uw1 __MCPLI (uw2, const)}
11127 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11128 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11129 @item @code{void __MCPXIS (acc, sw1, sw1)}
11130 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11131 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11132 @item @code{void __MCPXIU (acc, uw1, uw1)}
11133 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11134 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11135 @item @code{void __MCPXRS (acc, sw1, sw1)}
11136 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11137 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11138 @item @code{void __MCPXRU (acc, uw1, uw1)}
11139 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11140 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11141 @item @code{uw1 __MCUT (acc, uw1)}
11142 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11143 @tab @code{MCUT @var{a},@var{b},@var{c}}
11144 @item @code{uw1 __MCUTSS (acc, sw1)}
11145 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11146 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11147 @item @code{void __MDADDACCS (acc, acc)}
11148 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11149 @tab @code{MDADDACCS @var{a},@var{b}}
11150 @item @code{void __MDASACCS (acc, acc)}
11151 @tab @code{__MDASACCS (@var{b}, @var{a})}
11152 @tab @code{MDASACCS @var{a},@var{b}}
11153 @item @code{uw2 __MDCUTSSI (acc, const)}
11154 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11155 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11156 @item @code{uw2 __MDPACKH (uw2, uw2)}
11157 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11158 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11159 @item @code{uw2 __MDROTLI (uw2, const)}
11160 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11161 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11162 @item @code{void __MDSUBACCS (acc, acc)}
11163 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11164 @tab @code{MDSUBACCS @var{a},@var{b}}
11165 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11166 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11167 @tab @code{MDUNPACKH @var{a},@var{b}}
11168 @item @code{uw2 __MEXPDHD (uw1, const)}
11169 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11170 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11171 @item @code{uw1 __MEXPDHW (uw1, const)}
11172 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11173 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11174 @item @code{uw1 __MHDSETH (uw1, const)}
11175 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11176 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11177 @item @code{sw1 __MHDSETS (const)}
11178 @tab @code{@var{b} = __MHDSETS (@var{a})}
11179 @tab @code{MHDSETS #@var{a},@var{b}}
11180 @item @code{uw1 __MHSETHIH (uw1, const)}
11181 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11182 @tab @code{MHSETHIH #@var{a},@var{b}}
11183 @item @code{sw1 __MHSETHIS (sw1, const)}
11184 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11185 @tab @code{MHSETHIS #@var{a},@var{b}}
11186 @item @code{uw1 __MHSETLOH (uw1, const)}
11187 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11188 @tab @code{MHSETLOH #@var{a},@var{b}}
11189 @item @code{sw1 __MHSETLOS (sw1, const)}
11190 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11191 @tab @code{MHSETLOS #@var{a},@var{b}}
11192 @item @code{uw1 __MHTOB (uw2)}
11193 @tab @code{@var{b} = __MHTOB (@var{a})}
11194 @tab @code{MHTOB @var{a},@var{b}}
11195 @item @code{void __MMACHS (acc, sw1, sw1)}
11196 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11197 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11198 @item @code{void __MMACHU (acc, uw1, uw1)}
11199 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11200 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11201 @item @code{void __MMRDHS (acc, sw1, sw1)}
11202 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11203 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11204 @item @code{void __MMRDHU (acc, uw1, uw1)}
11205 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11206 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11207 @item @code{void __MMULHS (acc, sw1, sw1)}
11208 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11209 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11210 @item @code{void __MMULHU (acc, uw1, uw1)}
11211 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11212 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11213 @item @code{void __MMULXHS (acc, sw1, sw1)}
11214 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11215 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11216 @item @code{void __MMULXHU (acc, uw1, uw1)}
11217 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11218 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11219 @item @code{uw1 __MNOT (uw1)}
11220 @tab @code{@var{b} = __MNOT (@var{a})}
11221 @tab @code{MNOT @var{a},@var{b}}
11222 @item @code{uw1 __MOR (uw1, uw1)}
11223 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11224 @tab @code{MOR @var{a},@var{b},@var{c}}
11225 @item @code{uw1 __MPACKH (uh, uh)}
11226 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11227 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11228 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11229 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11230 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11231 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11232 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11233 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11234 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11235 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11236 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11237 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11238 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11239 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11240 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11241 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11242 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11243 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11244 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11245 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11246 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11247 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11248 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11249 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11250 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11251 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11252 @item @code{void __MQMACHS (acc, sw2, sw2)}
11253 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11254 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11255 @item @code{void __MQMACHU (acc, uw2, uw2)}
11256 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11257 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11258 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11259 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11260 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11261 @item @code{void __MQMULHS (acc, sw2, sw2)}
11262 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11263 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11264 @item @code{void __MQMULHU (acc, uw2, uw2)}
11265 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11266 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11267 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11268 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11269 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11270 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11271 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11272 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11273 @item @code{sw2 __MQSATHS (sw2, sw2)}
11274 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11275 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11276 @item @code{uw2 __MQSLLHI (uw2, int)}
11277 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11278 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11279 @item @code{sw2 __MQSRAHI (sw2, int)}
11280 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11281 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11282 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11283 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11284 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11285 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11286 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11287 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11288 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11289 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11290 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11291 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11292 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11293 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11294 @item @code{uw1 __MRDACC (acc)}
11295 @tab @code{@var{b} = __MRDACC (@var{a})}
11296 @tab @code{MRDACC @var{a},@var{b}}
11297 @item @code{uw1 __MRDACCG (acc)}
11298 @tab @code{@var{b} = __MRDACCG (@var{a})}
11299 @tab @code{MRDACCG @var{a},@var{b}}
11300 @item @code{uw1 __MROTLI (uw1, const)}
11301 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11302 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11303 @item @code{uw1 __MROTRI (uw1, const)}
11304 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11305 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11306 @item @code{sw1 __MSATHS (sw1, sw1)}
11307 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11308 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11309 @item @code{uw1 __MSATHU (uw1, uw1)}
11310 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11311 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11312 @item @code{uw1 __MSLLHI (uw1, const)}
11313 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11314 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11315 @item @code{sw1 __MSRAHI (sw1, const)}
11316 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11317 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11318 @item @code{uw1 __MSRLHI (uw1, const)}
11319 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11320 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11321 @item @code{void __MSUBACCS (acc, acc)}
11322 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11323 @tab @code{MSUBACCS @var{a},@var{b}}
11324 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11325 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11326 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11327 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11328 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11329 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11330 @item @code{void __MTRAP (void)}
11331 @tab @code{__MTRAP ()}
11332 @tab @code{MTRAP}
11333 @item @code{uw2 __MUNPACKH (uw1)}
11334 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11335 @tab @code{MUNPACKH @var{a},@var{b}}
11336 @item @code{uw1 __MWCUT (uw2, uw1)}
11337 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11338 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11339 @item @code{void __MWTACC (acc, uw1)}
11340 @tab @code{__MWTACC (@var{b}, @var{a})}
11341 @tab @code{MWTACC @var{a},@var{b}}
11342 @item @code{void __MWTACCG (acc, uw1)}
11343 @tab @code{__MWTACCG (@var{b}, @var{a})}
11344 @tab @code{MWTACCG @var{a},@var{b}}
11345 @item @code{uw1 __MXOR (uw1, uw1)}
11346 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11347 @tab @code{MXOR @var{a},@var{b},@var{c}}
11348 @end multitable
11350 @node Raw read/write Functions
11351 @subsubsection Raw read/write Functions
11353 This sections describes built-in functions related to read and write
11354 instructions to access memory.  These functions generate
11355 @code{membar} instructions to flush the I/O load and stores where
11356 appropriate, as described in Fujitsu's manual described above.
11358 @table @code
11360 @item unsigned char __builtin_read8 (void *@var{data})
11361 @item unsigned short __builtin_read16 (void *@var{data})
11362 @item unsigned long __builtin_read32 (void *@var{data})
11363 @item unsigned long long __builtin_read64 (void *@var{data})
11365 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11366 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11367 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11368 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11369 @end table
11371 @node Other Built-in Functions
11372 @subsubsection Other Built-in Functions
11374 This section describes built-in functions that are not named after
11375 a specific FR-V instruction.
11377 @table @code
11378 @item sw2 __IACCreadll (iacc @var{reg})
11379 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11380 for future expansion and must be 0.
11382 @item sw1 __IACCreadl (iacc @var{reg})
11383 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11384 Other values of @var{reg} are rejected as invalid.
11386 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11387 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11388 is reserved for future expansion and must be 0.
11390 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11391 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11392 is 1.  Other values of @var{reg} are rejected as invalid.
11394 @item void __data_prefetch0 (const void *@var{x})
11395 Use the @code{dcpl} instruction to load the contents of address @var{x}
11396 into the data cache.
11398 @item void __data_prefetch (const void *@var{x})
11399 Use the @code{nldub} instruction to load the contents of address @var{x}
11400 into the data cache.  The instruction is issued in slot I1@.
11401 @end table
11403 @node X86 Built-in Functions
11404 @subsection X86 Built-in Functions
11406 These built-in functions are available for the i386 and x86-64 family
11407 of computers, depending on the command-line switches used.
11409 If you specify command-line switches such as @option{-msse},
11410 the compiler could use the extended instruction sets even if the built-ins
11411 are not used explicitly in the program.  For this reason, applications
11412 that perform run-time CPU detection must compile separate files for each
11413 supported architecture, using the appropriate flags.  In particular,
11414 the file containing the CPU detection code should be compiled without
11415 these options.
11417 The following machine modes are available for use with MMX built-in functions
11418 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11419 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11420 vector of eight 8-bit integers.  Some of the built-in functions operate on
11421 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11423 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11424 of two 32-bit floating-point values.
11426 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11427 floating-point values.  Some instructions use a vector of four 32-bit
11428 integers, these use @code{V4SI}.  Finally, some instructions operate on an
11429 entire vector register, interpreting it as a 128-bit integer, these use mode
11430 @code{TI}.
11432 In 64-bit mode, the x86-64 family of processors uses additional built-in
11433 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11434 floating point and @code{TC} 128-bit complex floating-point values.
11436 The following floating-point built-in functions are available in 64-bit
11437 mode.  All of them implement the function that is part of the name.
11439 @smallexample
11440 __float128 __builtin_fabsq (__float128)
11441 __float128 __builtin_copysignq (__float128, __float128)
11442 @end smallexample
11444 The following built-in function is always available.
11446 @table @code
11447 @item void __builtin_ia32_pause (void)
11448 Generates the @code{pause} machine instruction with a compiler memory
11449 barrier.
11450 @end table
11452 The following floating-point built-in functions are made available in the
11453 64-bit mode.
11455 @table @code
11456 @item __float128 __builtin_infq (void)
11457 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11458 @findex __builtin_infq
11460 @item __float128 __builtin_huge_valq (void)
11461 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11462 @findex __builtin_huge_valq
11463 @end table
11465 The following built-in functions are always available and can be used to
11466 check the target platform type.
11468 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11469 This function runs the CPU detection code to check the type of CPU and the
11470 features supported.  This built-in function needs to be invoked along with the built-in functions
11471 to check CPU type and features, @code{__builtin_cpu_is} and
11472 @code{__builtin_cpu_supports}, only when used in a function that is
11473 executed before any constructors are called.  The CPU detection code is
11474 automatically executed in a very high priority constructor.
11476 For example, this function has to be used in @code{ifunc} resolvers that
11477 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11478 and @code{__builtin_cpu_supports}, or in constructors on targets that
11479 don't support constructor priority.
11480 @smallexample
11482 static void (*resolve_memcpy (void)) (void)
11484   // ifunc resolvers fire before constructors, explicitly call the init
11485   // function.
11486   __builtin_cpu_init ();
11487   if (__builtin_cpu_supports ("ssse3"))
11488     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11489   else
11490     return default_memcpy;
11493 void *memcpy (void *, const void *, size_t)
11494      __attribute__ ((ifunc ("resolve_memcpy")));
11495 @end smallexample
11497 @end deftypefn
11499 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11500 This function returns a positive integer if the run-time CPU
11501 is of type @var{cpuname}
11502 and returns @code{0} otherwise. The following CPU names can be detected:
11504 @table @samp
11505 @item intel
11506 Intel CPU.
11508 @item atom
11509 Intel Atom CPU.
11511 @item core2
11512 Intel Core 2 CPU.
11514 @item corei7
11515 Intel Core i7 CPU.
11517 @item nehalem
11518 Intel Core i7 Nehalem CPU.
11520 @item westmere
11521 Intel Core i7 Westmere CPU.
11523 @item sandybridge
11524 Intel Core i7 Sandy Bridge CPU.
11526 @item amd
11527 AMD CPU.
11529 @item amdfam10h
11530 AMD Family 10h CPU.
11532 @item barcelona
11533 AMD Family 10h Barcelona CPU.
11535 @item shanghai
11536 AMD Family 10h Shanghai CPU.
11538 @item istanbul
11539 AMD Family 10h Istanbul CPU.
11541 @item btver1
11542 AMD Family 14h CPU.
11544 @item amdfam15h
11545 AMD Family 15h CPU.
11547 @item bdver1
11548 AMD Family 15h Bulldozer version 1.
11550 @item bdver2
11551 AMD Family 15h Bulldozer version 2.
11553 @item bdver3
11554 AMD Family 15h Bulldozer version 3.
11556 @item bdver4
11557 AMD Family 15h Bulldozer version 4.
11559 @item btver2
11560 AMD Family 16h CPU.
11561 @end table
11563 Here is an example:
11564 @smallexample
11565 if (__builtin_cpu_is ("corei7"))
11566   @{
11567      do_corei7 (); // Core i7 specific implementation.
11568   @}
11569 else
11570   @{
11571      do_generic (); // Generic implementation.
11572   @}
11573 @end smallexample
11574 @end deftypefn
11576 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11577 This function returns a positive integer if the run-time CPU
11578 supports @var{feature}
11579 and returns @code{0} otherwise. The following features can be detected:
11581 @table @samp
11582 @item cmov
11583 CMOV instruction.
11584 @item mmx
11585 MMX instructions.
11586 @item popcnt
11587 POPCNT instruction.
11588 @item sse
11589 SSE instructions.
11590 @item sse2
11591 SSE2 instructions.
11592 @item sse3
11593 SSE3 instructions.
11594 @item ssse3
11595 SSSE3 instructions.
11596 @item sse4.1
11597 SSE4.1 instructions.
11598 @item sse4.2
11599 SSE4.2 instructions.
11600 @item avx
11601 AVX instructions.
11602 @item avx2
11603 AVX2 instructions.
11604 @end table
11606 Here is an example:
11607 @smallexample
11608 if (__builtin_cpu_supports ("popcnt"))
11609   @{
11610      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11611   @}
11612 else
11613   @{
11614      count = generic_countbits (n); //generic implementation.
11615   @}
11616 @end smallexample
11617 @end deftypefn
11620 The following built-in functions are made available by @option{-mmmx}.
11621 All of them generate the machine instruction that is part of the name.
11623 @smallexample
11624 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11625 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11626 v2si __builtin_ia32_paddd (v2si, v2si)
11627 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11628 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11629 v2si __builtin_ia32_psubd (v2si, v2si)
11630 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11631 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11632 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11633 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11634 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11635 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11636 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11637 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11638 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11639 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11640 di __builtin_ia32_pand (di, di)
11641 di __builtin_ia32_pandn (di,di)
11642 di __builtin_ia32_por (di, di)
11643 di __builtin_ia32_pxor (di, di)
11644 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11645 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11646 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11647 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11648 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11649 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11650 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11651 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11652 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11653 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11654 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11655 v2si __builtin_ia32_punpckldq (v2si, v2si)
11656 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11657 v4hi __builtin_ia32_packssdw (v2si, v2si)
11658 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11660 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11661 v2si __builtin_ia32_pslld (v2si, v2si)
11662 v1di __builtin_ia32_psllq (v1di, v1di)
11663 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11664 v2si __builtin_ia32_psrld (v2si, v2si)
11665 v1di __builtin_ia32_psrlq (v1di, v1di)
11666 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11667 v2si __builtin_ia32_psrad (v2si, v2si)
11668 v4hi __builtin_ia32_psllwi (v4hi, int)
11669 v2si __builtin_ia32_pslldi (v2si, int)
11670 v1di __builtin_ia32_psllqi (v1di, int)
11671 v4hi __builtin_ia32_psrlwi (v4hi, int)
11672 v2si __builtin_ia32_psrldi (v2si, int)
11673 v1di __builtin_ia32_psrlqi (v1di, int)
11674 v4hi __builtin_ia32_psrawi (v4hi, int)
11675 v2si __builtin_ia32_psradi (v2si, int)
11677 @end smallexample
11679 The following built-in functions are made available either with
11680 @option{-msse}, or with a combination of @option{-m3dnow} and
11681 @option{-march=athlon}.  All of them generate the machine
11682 instruction that is part of the name.
11684 @smallexample
11685 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11686 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11687 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11688 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11689 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11690 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11691 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11692 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11693 int __builtin_ia32_pmovmskb (v8qi)
11694 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11695 void __builtin_ia32_movntq (di *, di)
11696 void __builtin_ia32_sfence (void)
11697 @end smallexample
11699 The following built-in functions are available when @option{-msse} is used.
11700 All of them generate the machine instruction that is part of the name.
11702 @smallexample
11703 int __builtin_ia32_comieq (v4sf, v4sf)
11704 int __builtin_ia32_comineq (v4sf, v4sf)
11705 int __builtin_ia32_comilt (v4sf, v4sf)
11706 int __builtin_ia32_comile (v4sf, v4sf)
11707 int __builtin_ia32_comigt (v4sf, v4sf)
11708 int __builtin_ia32_comige (v4sf, v4sf)
11709 int __builtin_ia32_ucomieq (v4sf, v4sf)
11710 int __builtin_ia32_ucomineq (v4sf, v4sf)
11711 int __builtin_ia32_ucomilt (v4sf, v4sf)
11712 int __builtin_ia32_ucomile (v4sf, v4sf)
11713 int __builtin_ia32_ucomigt (v4sf, v4sf)
11714 int __builtin_ia32_ucomige (v4sf, v4sf)
11715 v4sf __builtin_ia32_addps (v4sf, v4sf)
11716 v4sf __builtin_ia32_subps (v4sf, v4sf)
11717 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11718 v4sf __builtin_ia32_divps (v4sf, v4sf)
11719 v4sf __builtin_ia32_addss (v4sf, v4sf)
11720 v4sf __builtin_ia32_subss (v4sf, v4sf)
11721 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11722 v4sf __builtin_ia32_divss (v4sf, v4sf)
11723 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11724 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11725 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11726 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11727 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11728 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11729 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11730 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11731 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11732 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11733 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11734 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11735 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11736 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11737 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11738 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11739 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11740 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11741 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11742 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11743 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11744 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11745 v4sf __builtin_ia32_minps (v4sf, v4sf)
11746 v4sf __builtin_ia32_minss (v4sf, v4sf)
11747 v4sf __builtin_ia32_andps (v4sf, v4sf)
11748 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11749 v4sf __builtin_ia32_orps (v4sf, v4sf)
11750 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11751 v4sf __builtin_ia32_movss (v4sf, v4sf)
11752 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11753 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11754 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11755 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11756 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11757 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11758 v2si __builtin_ia32_cvtps2pi (v4sf)
11759 int __builtin_ia32_cvtss2si (v4sf)
11760 v2si __builtin_ia32_cvttps2pi (v4sf)
11761 int __builtin_ia32_cvttss2si (v4sf)
11762 v4sf __builtin_ia32_rcpps (v4sf)
11763 v4sf __builtin_ia32_rsqrtps (v4sf)
11764 v4sf __builtin_ia32_sqrtps (v4sf)
11765 v4sf __builtin_ia32_rcpss (v4sf)
11766 v4sf __builtin_ia32_rsqrtss (v4sf)
11767 v4sf __builtin_ia32_sqrtss (v4sf)
11768 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11769 void __builtin_ia32_movntps (float *, v4sf)
11770 int __builtin_ia32_movmskps (v4sf)
11771 @end smallexample
11773 The following built-in functions are available when @option{-msse} is used.
11775 @table @code
11776 @item v4sf __builtin_ia32_loadups (float *)
11777 Generates the @code{movups} machine instruction as a load from memory.
11778 @item void __builtin_ia32_storeups (float *, v4sf)
11779 Generates the @code{movups} machine instruction as a store to memory.
11780 @item v4sf __builtin_ia32_loadss (float *)
11781 Generates the @code{movss} machine instruction as a load from memory.
11782 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11783 Generates the @code{movhps} machine instruction as a load from memory.
11784 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11785 Generates the @code{movlps} machine instruction as a load from memory
11786 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11787 Generates the @code{movhps} machine instruction as a store to memory.
11788 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11789 Generates the @code{movlps} machine instruction as a store to memory.
11790 @end table
11792 The following built-in functions are available when @option{-msse2} is used.
11793 All of them generate the machine instruction that is part of the name.
11795 @smallexample
11796 int __builtin_ia32_comisdeq (v2df, v2df)
11797 int __builtin_ia32_comisdlt (v2df, v2df)
11798 int __builtin_ia32_comisdle (v2df, v2df)
11799 int __builtin_ia32_comisdgt (v2df, v2df)
11800 int __builtin_ia32_comisdge (v2df, v2df)
11801 int __builtin_ia32_comisdneq (v2df, v2df)
11802 int __builtin_ia32_ucomisdeq (v2df, v2df)
11803 int __builtin_ia32_ucomisdlt (v2df, v2df)
11804 int __builtin_ia32_ucomisdle (v2df, v2df)
11805 int __builtin_ia32_ucomisdgt (v2df, v2df)
11806 int __builtin_ia32_ucomisdge (v2df, v2df)
11807 int __builtin_ia32_ucomisdneq (v2df, v2df)
11808 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11809 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11810 v2df __builtin_ia32_cmplepd (v2df, v2df)
11811 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11812 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11813 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11814 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11815 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11816 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11817 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11818 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11819 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11820 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11821 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11822 v2df __builtin_ia32_cmplesd (v2df, v2df)
11823 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11824 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11825 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11826 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11827 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11828 v2di __builtin_ia32_paddq (v2di, v2di)
11829 v2di __builtin_ia32_psubq (v2di, v2di)
11830 v2df __builtin_ia32_addpd (v2df, v2df)
11831 v2df __builtin_ia32_subpd (v2df, v2df)
11832 v2df __builtin_ia32_mulpd (v2df, v2df)
11833 v2df __builtin_ia32_divpd (v2df, v2df)
11834 v2df __builtin_ia32_addsd (v2df, v2df)
11835 v2df __builtin_ia32_subsd (v2df, v2df)
11836 v2df __builtin_ia32_mulsd (v2df, v2df)
11837 v2df __builtin_ia32_divsd (v2df, v2df)
11838 v2df __builtin_ia32_minpd (v2df, v2df)
11839 v2df __builtin_ia32_maxpd (v2df, v2df)
11840 v2df __builtin_ia32_minsd (v2df, v2df)
11841 v2df __builtin_ia32_maxsd (v2df, v2df)
11842 v2df __builtin_ia32_andpd (v2df, v2df)
11843 v2df __builtin_ia32_andnpd (v2df, v2df)
11844 v2df __builtin_ia32_orpd (v2df, v2df)
11845 v2df __builtin_ia32_xorpd (v2df, v2df)
11846 v2df __builtin_ia32_movsd (v2df, v2df)
11847 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11848 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11849 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11850 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11851 v4si __builtin_ia32_paddd128 (v4si, v4si)
11852 v2di __builtin_ia32_paddq128 (v2di, v2di)
11853 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11854 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11855 v4si __builtin_ia32_psubd128 (v4si, v4si)
11856 v2di __builtin_ia32_psubq128 (v2di, v2di)
11857 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11858 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11859 v2di __builtin_ia32_pand128 (v2di, v2di)
11860 v2di __builtin_ia32_pandn128 (v2di, v2di)
11861 v2di __builtin_ia32_por128 (v2di, v2di)
11862 v2di __builtin_ia32_pxor128 (v2di, v2di)
11863 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11864 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11865 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11866 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11867 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11868 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11869 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11870 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11871 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11872 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11873 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11874 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11875 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11876 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11877 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11878 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11879 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11880 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11881 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11882 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11883 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11884 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11885 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11886 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11887 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11888 v2df __builtin_ia32_loadupd (double *)
11889 void __builtin_ia32_storeupd (double *, v2df)
11890 v2df __builtin_ia32_loadhpd (v2df, double const *)
11891 v2df __builtin_ia32_loadlpd (v2df, double const *)
11892 int __builtin_ia32_movmskpd (v2df)
11893 int __builtin_ia32_pmovmskb128 (v16qi)
11894 void __builtin_ia32_movnti (int *, int)
11895 void __builtin_ia32_movnti64 (long long int *, long long int)
11896 void __builtin_ia32_movntpd (double *, v2df)
11897 void __builtin_ia32_movntdq (v2df *, v2df)
11898 v4si __builtin_ia32_pshufd (v4si, int)
11899 v8hi __builtin_ia32_pshuflw (v8hi, int)
11900 v8hi __builtin_ia32_pshufhw (v8hi, int)
11901 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11902 v2df __builtin_ia32_sqrtpd (v2df)
11903 v2df __builtin_ia32_sqrtsd (v2df)
11904 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11905 v2df __builtin_ia32_cvtdq2pd (v4si)
11906 v4sf __builtin_ia32_cvtdq2ps (v4si)
11907 v4si __builtin_ia32_cvtpd2dq (v2df)
11908 v2si __builtin_ia32_cvtpd2pi (v2df)
11909 v4sf __builtin_ia32_cvtpd2ps (v2df)
11910 v4si __builtin_ia32_cvttpd2dq (v2df)
11911 v2si __builtin_ia32_cvttpd2pi (v2df)
11912 v2df __builtin_ia32_cvtpi2pd (v2si)
11913 int __builtin_ia32_cvtsd2si (v2df)
11914 int __builtin_ia32_cvttsd2si (v2df)
11915 long long __builtin_ia32_cvtsd2si64 (v2df)
11916 long long __builtin_ia32_cvttsd2si64 (v2df)
11917 v4si __builtin_ia32_cvtps2dq (v4sf)
11918 v2df __builtin_ia32_cvtps2pd (v4sf)
11919 v4si __builtin_ia32_cvttps2dq (v4sf)
11920 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11921 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11922 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11923 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11924 void __builtin_ia32_clflush (const void *)
11925 void __builtin_ia32_lfence (void)
11926 void __builtin_ia32_mfence (void)
11927 v16qi __builtin_ia32_loaddqu (const char *)
11928 void __builtin_ia32_storedqu (char *, v16qi)
11929 v1di __builtin_ia32_pmuludq (v2si, v2si)
11930 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11931 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11932 v4si __builtin_ia32_pslld128 (v4si, v4si)
11933 v2di __builtin_ia32_psllq128 (v2di, v2di)
11934 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11935 v4si __builtin_ia32_psrld128 (v4si, v4si)
11936 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11937 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11938 v4si __builtin_ia32_psrad128 (v4si, v4si)
11939 v2di __builtin_ia32_pslldqi128 (v2di, int)
11940 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11941 v4si __builtin_ia32_pslldi128 (v4si, int)
11942 v2di __builtin_ia32_psllqi128 (v2di, int)
11943 v2di __builtin_ia32_psrldqi128 (v2di, int)
11944 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11945 v4si __builtin_ia32_psrldi128 (v4si, int)
11946 v2di __builtin_ia32_psrlqi128 (v2di, int)
11947 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11948 v4si __builtin_ia32_psradi128 (v4si, int)
11949 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11950 v2di __builtin_ia32_movq128 (v2di)
11951 @end smallexample
11953 The following built-in functions are available when @option{-msse3} is used.
11954 All of them generate the machine instruction that is part of the name.
11956 @smallexample
11957 v2df __builtin_ia32_addsubpd (v2df, v2df)
11958 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11959 v2df __builtin_ia32_haddpd (v2df, v2df)
11960 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11961 v2df __builtin_ia32_hsubpd (v2df, v2df)
11962 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11963 v16qi __builtin_ia32_lddqu (char const *)
11964 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11965 v4sf __builtin_ia32_movshdup (v4sf)
11966 v4sf __builtin_ia32_movsldup (v4sf)
11967 void __builtin_ia32_mwait (unsigned int, unsigned int)
11968 @end smallexample
11970 The following built-in functions are available when @option{-mssse3} is used.
11971 All of them generate the machine instruction that is part of the name.
11973 @smallexample
11974 v2si __builtin_ia32_phaddd (v2si, v2si)
11975 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
11976 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
11977 v2si __builtin_ia32_phsubd (v2si, v2si)
11978 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
11979 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
11980 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
11981 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
11982 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
11983 v8qi __builtin_ia32_psignb (v8qi, v8qi)
11984 v2si __builtin_ia32_psignd (v2si, v2si)
11985 v4hi __builtin_ia32_psignw (v4hi, v4hi)
11986 v1di __builtin_ia32_palignr (v1di, v1di, int)
11987 v8qi __builtin_ia32_pabsb (v8qi)
11988 v2si __builtin_ia32_pabsd (v2si)
11989 v4hi __builtin_ia32_pabsw (v4hi)
11990 @end smallexample
11992 The following built-in functions are available when @option{-mssse3} is used.
11993 All of them generate the machine instruction that is part of the name.
11995 @smallexample
11996 v4si __builtin_ia32_phaddd128 (v4si, v4si)
11997 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
11998 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
11999 v4si __builtin_ia32_phsubd128 (v4si, v4si)
12000 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
12001 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
12002 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
12003 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
12004 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
12005 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
12006 v4si __builtin_ia32_psignd128 (v4si, v4si)
12007 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
12008 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
12009 v16qi __builtin_ia32_pabsb128 (v16qi)
12010 v4si __builtin_ia32_pabsd128 (v4si)
12011 v8hi __builtin_ia32_pabsw128 (v8hi)
12012 @end smallexample
12014 The following built-in functions are available when @option{-msse4.1} is
12015 used.  All of them generate the machine instruction that is part of the
12016 name.
12018 @smallexample
12019 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
12020 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
12021 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
12022 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
12023 v2df __builtin_ia32_dppd (v2df, v2df, const int)
12024 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
12025 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
12026 v2di __builtin_ia32_movntdqa (v2di *);
12027 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
12028 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
12029 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
12030 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
12031 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
12032 v8hi __builtin_ia32_phminposuw128 (v8hi)
12033 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
12034 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
12035 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
12036 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
12037 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
12038 v4si __builtin_ia32_pminsd128 (v4si, v4si)
12039 v4si __builtin_ia32_pminud128 (v4si, v4si)
12040 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
12041 v4si __builtin_ia32_pmovsxbd128 (v16qi)
12042 v2di __builtin_ia32_pmovsxbq128 (v16qi)
12043 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
12044 v2di __builtin_ia32_pmovsxdq128 (v4si)
12045 v4si __builtin_ia32_pmovsxwd128 (v8hi)
12046 v2di __builtin_ia32_pmovsxwq128 (v8hi)
12047 v4si __builtin_ia32_pmovzxbd128 (v16qi)
12048 v2di __builtin_ia32_pmovzxbq128 (v16qi)
12049 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
12050 v2di __builtin_ia32_pmovzxdq128 (v4si)
12051 v4si __builtin_ia32_pmovzxwd128 (v8hi)
12052 v2di __builtin_ia32_pmovzxwq128 (v8hi)
12053 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
12054 v4si __builtin_ia32_pmulld128 (v4si, v4si)
12055 int __builtin_ia32_ptestc128 (v2di, v2di)
12056 int __builtin_ia32_ptestnzc128 (v2di, v2di)
12057 int __builtin_ia32_ptestz128 (v2di, v2di)
12058 v2df __builtin_ia32_roundpd (v2df, const int)
12059 v4sf __builtin_ia32_roundps (v4sf, const int)
12060 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
12061 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
12062 @end smallexample
12064 The following built-in functions are available when @option{-msse4.1} is
12065 used.
12067 @table @code
12068 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
12069 Generates the @code{insertps} machine instruction.
12070 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
12071 Generates the @code{pextrb} machine instruction.
12072 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
12073 Generates the @code{pinsrb} machine instruction.
12074 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
12075 Generates the @code{pinsrd} machine instruction.
12076 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
12077 Generates the @code{pinsrq} machine instruction in 64bit mode.
12078 @end table
12080 The following built-in functions are changed to generate new SSE4.1
12081 instructions when @option{-msse4.1} is used.
12083 @table @code
12084 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
12085 Generates the @code{extractps} machine instruction.
12086 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
12087 Generates the @code{pextrd} machine instruction.
12088 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
12089 Generates the @code{pextrq} machine instruction in 64bit mode.
12090 @end table
12092 The following built-in functions are available when @option{-msse4.2} is
12093 used.  All of them generate the machine instruction that is part of the
12094 name.
12096 @smallexample
12097 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
12098 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
12099 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
12100 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
12101 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
12102 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
12103 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
12104 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
12105 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
12106 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
12107 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
12108 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
12109 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
12110 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
12111 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
12112 @end smallexample
12114 The following built-in functions are available when @option{-msse4.2} is
12115 used.
12117 @table @code
12118 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
12119 Generates the @code{crc32b} machine instruction.
12120 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
12121 Generates the @code{crc32w} machine instruction.
12122 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
12123 Generates the @code{crc32l} machine instruction.
12124 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
12125 Generates the @code{crc32q} machine instruction.
12126 @end table
12128 The following built-in functions are changed to generate new SSE4.2
12129 instructions when @option{-msse4.2} is used.
12131 @table @code
12132 @item int __builtin_popcount (unsigned int)
12133 Generates the @code{popcntl} machine instruction.
12134 @item int __builtin_popcountl (unsigned long)
12135 Generates the @code{popcntl} or @code{popcntq} machine instruction,
12136 depending on the size of @code{unsigned long}.
12137 @item int __builtin_popcountll (unsigned long long)
12138 Generates the @code{popcntq} machine instruction.
12139 @end table
12141 The following built-in functions are available when @option{-mavx} is
12142 used. All of them generate the machine instruction that is part of the
12143 name.
12145 @smallexample
12146 v4df __builtin_ia32_addpd256 (v4df,v4df)
12147 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
12148 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
12149 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
12150 v4df __builtin_ia32_andnpd256 (v4df,v4df)
12151 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
12152 v4df __builtin_ia32_andpd256 (v4df,v4df)
12153 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
12154 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
12155 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
12156 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
12157 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
12158 v2df __builtin_ia32_cmppd (v2df,v2df,int)
12159 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
12160 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
12161 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
12162 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
12163 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
12164 v4df __builtin_ia32_cvtdq2pd256 (v4si)
12165 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
12166 v4si __builtin_ia32_cvtpd2dq256 (v4df)
12167 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
12168 v8si __builtin_ia32_cvtps2dq256 (v8sf)
12169 v4df __builtin_ia32_cvtps2pd256 (v4sf)
12170 v4si __builtin_ia32_cvttpd2dq256 (v4df)
12171 v8si __builtin_ia32_cvttps2dq256 (v8sf)
12172 v4df __builtin_ia32_divpd256 (v4df,v4df)
12173 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
12174 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
12175 v4df __builtin_ia32_haddpd256 (v4df,v4df)
12176 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
12177 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
12178 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
12179 v32qi __builtin_ia32_lddqu256 (pcchar)
12180 v32qi __builtin_ia32_loaddqu256 (pcchar)
12181 v4df __builtin_ia32_loadupd256 (pcdouble)
12182 v8sf __builtin_ia32_loadups256 (pcfloat)
12183 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
12184 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
12185 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
12186 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
12187 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
12188 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
12189 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
12190 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
12191 v4df __builtin_ia32_maxpd256 (v4df,v4df)
12192 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
12193 v4df __builtin_ia32_minpd256 (v4df,v4df)
12194 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
12195 v4df __builtin_ia32_movddup256 (v4df)
12196 int __builtin_ia32_movmskpd256 (v4df)
12197 int __builtin_ia32_movmskps256 (v8sf)
12198 v8sf __builtin_ia32_movshdup256 (v8sf)
12199 v8sf __builtin_ia32_movsldup256 (v8sf)
12200 v4df __builtin_ia32_mulpd256 (v4df,v4df)
12201 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
12202 v4df __builtin_ia32_orpd256 (v4df,v4df)
12203 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
12204 v2df __builtin_ia32_pd_pd256 (v4df)
12205 v4df __builtin_ia32_pd256_pd (v2df)
12206 v4sf __builtin_ia32_ps_ps256 (v8sf)
12207 v8sf __builtin_ia32_ps256_ps (v4sf)
12208 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
12209 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
12210 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
12211 v8sf __builtin_ia32_rcpps256 (v8sf)
12212 v4df __builtin_ia32_roundpd256 (v4df,int)
12213 v8sf __builtin_ia32_roundps256 (v8sf,int)
12214 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
12215 v8sf __builtin_ia32_rsqrtps256 (v8sf)
12216 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
12217 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
12218 v4si __builtin_ia32_si_si256 (v8si)
12219 v8si __builtin_ia32_si256_si (v4si)
12220 v4df __builtin_ia32_sqrtpd256 (v4df)
12221 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
12222 v8sf __builtin_ia32_sqrtps256 (v8sf)
12223 void __builtin_ia32_storedqu256 (pchar,v32qi)
12224 void __builtin_ia32_storeupd256 (pdouble,v4df)
12225 void __builtin_ia32_storeups256 (pfloat,v8sf)
12226 v4df __builtin_ia32_subpd256 (v4df,v4df)
12227 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
12228 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
12229 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
12230 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
12231 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
12232 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
12233 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
12234 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
12235 v4sf __builtin_ia32_vbroadcastss (pcfloat)
12236 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
12237 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
12238 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
12239 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
12240 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
12241 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
12242 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
12243 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
12244 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
12245 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
12246 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
12247 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
12248 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
12249 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12250 v2df __builtin_ia32_vpermilpd (v2df,int)
12251 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12252 v4sf __builtin_ia32_vpermilps (v4sf,int)
12253 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12254 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12255 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12256 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12257 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12258 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12259 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12260 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12261 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12262 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12263 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12264 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12265 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12266 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12267 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12268 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12269 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12270 void __builtin_ia32_vzeroall (void)
12271 void __builtin_ia32_vzeroupper (void)
12272 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12273 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12274 @end smallexample
12276 The following built-in functions are available when @option{-mavx2} is
12277 used. All of them generate the machine instruction that is part of the
12278 name.
12280 @smallexample
12281 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12282 v32qi __builtin_ia32_pabsb256 (v32qi)
12283 v16hi __builtin_ia32_pabsw256 (v16hi)
12284 v8si __builtin_ia32_pabsd256 (v8si)
12285 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12286 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12287 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12288 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12289 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12290 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12291 v8si __builtin_ia32_paddd256 (v8si,v8si)
12292 v4di __builtin_ia32_paddq256 (v4di,v4di)
12293 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12294 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12295 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12296 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12297 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12298 v4di __builtin_ia32_andsi256 (v4di,v4di)
12299 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12300 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12301 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12302 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12303 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12304 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12305 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12306 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12307 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12308 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12309 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12310 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12311 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12312 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12313 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12314 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12315 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12316 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12317 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12318 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12319 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12320 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12321 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12322 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12323 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12324 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12325 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12326 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12327 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12328 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12329 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12330 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12331 v8si __builtin_ia32_pminud256 (v8si,v8si)
12332 int __builtin_ia32_pmovmskb256 (v32qi)
12333 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12334 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12335 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12336 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12337 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12338 v4di __builtin_ia32_pmovsxdq256 (v4si)
12339 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12340 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12341 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12342 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12343 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12344 v4di __builtin_ia32_pmovzxdq256 (v4si)
12345 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12346 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12347 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12348 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12349 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12350 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12351 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12352 v4di __builtin_ia32_por256 (v4di,v4di)
12353 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12354 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12355 v8si __builtin_ia32_pshufd256 (v8si,int)
12356 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12357 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12358 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12359 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12360 v8si __builtin_ia32_psignd256 (v8si,v8si)
12361 v4di __builtin_ia32_pslldqi256 (v4di,int)
12362 v16hi __builtin_ia32_psllwi256 (16hi,int)
12363 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12364 v8si __builtin_ia32_pslldi256 (v8si,int)
12365 v8si __builtin_ia32_pslld256(v8si,v4si)
12366 v4di __builtin_ia32_psllqi256 (v4di,int)
12367 v4di __builtin_ia32_psllq256(v4di,v2di)
12368 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12369 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12370 v8si __builtin_ia32_psradi256 (v8si,int)
12371 v8si __builtin_ia32_psrad256 (v8si,v4si)
12372 v4di __builtin_ia32_psrldqi256 (v4di, int)
12373 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12374 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12375 v8si __builtin_ia32_psrldi256 (v8si,int)
12376 v8si __builtin_ia32_psrld256 (v8si,v4si)
12377 v4di __builtin_ia32_psrlqi256 (v4di,int)
12378 v4di __builtin_ia32_psrlq256(v4di,v2di)
12379 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12380 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12381 v8si __builtin_ia32_psubd256 (v8si,v8si)
12382 v4di __builtin_ia32_psubq256 (v4di,v4di)
12383 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12384 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12385 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12386 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12387 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12388 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12389 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12390 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12391 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12392 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12393 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12394 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12395 v4di __builtin_ia32_pxor256 (v4di,v4di)
12396 v4di __builtin_ia32_movntdqa256 (pv4di)
12397 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12398 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12399 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12400 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12401 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12402 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12403 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12404 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12405 v8si __builtin_ia32_pbroadcastd256 (v4si)
12406 v4di __builtin_ia32_pbroadcastq256 (v2di)
12407 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12408 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12409 v4si __builtin_ia32_pbroadcastd128 (v4si)
12410 v2di __builtin_ia32_pbroadcastq128 (v2di)
12411 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12412 v4df __builtin_ia32_permdf256 (v4df,int)
12413 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12414 v4di __builtin_ia32_permdi256 (v4di,int)
12415 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12416 v4di __builtin_ia32_extract128i256 (v4di,int)
12417 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12418 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12419 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12420 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12421 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12422 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12423 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12424 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12425 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12426 v8si __builtin_ia32_psllv8si (v8si,v8si)
12427 v4si __builtin_ia32_psllv4si (v4si,v4si)
12428 v4di __builtin_ia32_psllv4di (v4di,v4di)
12429 v2di __builtin_ia32_psllv2di (v2di,v2di)
12430 v8si __builtin_ia32_psrav8si (v8si,v8si)
12431 v4si __builtin_ia32_psrav4si (v4si,v4si)
12432 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12433 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12434 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12435 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12436 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12437 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12438 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12439 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12440 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12441 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12442 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12443 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12444 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12445 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12446 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12447 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12448 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12449 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12450 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12451 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12452 @end smallexample
12454 The following built-in functions are available when @option{-maes} is
12455 used.  All of them generate the machine instruction that is part of the
12456 name.
12458 @smallexample
12459 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12460 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12461 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12462 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12463 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12464 v2di __builtin_ia32_aesimc128 (v2di)
12465 @end smallexample
12467 The following built-in function is available when @option{-mpclmul} is
12468 used.
12470 @table @code
12471 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12472 Generates the @code{pclmulqdq} machine instruction.
12473 @end table
12475 The following built-in function is available when @option{-mfsgsbase} is
12476 used.  All of them generate the machine instruction that is part of the
12477 name.
12479 @smallexample
12480 unsigned int __builtin_ia32_rdfsbase32 (void)
12481 unsigned long long __builtin_ia32_rdfsbase64 (void)
12482 unsigned int __builtin_ia32_rdgsbase32 (void)
12483 unsigned long long __builtin_ia32_rdgsbase64 (void)
12484 void _writefsbase_u32 (unsigned int)
12485 void _writefsbase_u64 (unsigned long long)
12486 void _writegsbase_u32 (unsigned int)
12487 void _writegsbase_u64 (unsigned long long)
12488 @end smallexample
12490 The following built-in function is available when @option{-mrdrnd} is
12491 used.  All of them generate the machine instruction that is part of the
12492 name.
12494 @smallexample
12495 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12496 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12497 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12498 @end smallexample
12500 The following built-in functions are available when @option{-msse4a} is used.
12501 All of them generate the machine instruction that is part of the name.
12503 @smallexample
12504 void __builtin_ia32_movntsd (double *, v2df)
12505 void __builtin_ia32_movntss (float *, v4sf)
12506 v2di __builtin_ia32_extrq  (v2di, v16qi)
12507 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12508 v2di __builtin_ia32_insertq (v2di, v2di)
12509 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12510 @end smallexample
12512 The following built-in functions are available when @option{-mxop} is used.
12513 @smallexample
12514 v2df __builtin_ia32_vfrczpd (v2df)
12515 v4sf __builtin_ia32_vfrczps (v4sf)
12516 v2df __builtin_ia32_vfrczsd (v2df)
12517 v4sf __builtin_ia32_vfrczss (v4sf)
12518 v4df __builtin_ia32_vfrczpd256 (v4df)
12519 v8sf __builtin_ia32_vfrczps256 (v8sf)
12520 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12521 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12522 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12523 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12524 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12525 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12526 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12527 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12528 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12529 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12530 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12531 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12532 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12533 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12534 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12535 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12536 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12537 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12538 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12539 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12540 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12541 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12542 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12543 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12544 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12545 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12546 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12547 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12548 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12549 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12550 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12551 v4si __builtin_ia32_vpcomged (v4si, v4si)
12552 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12553 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12554 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12555 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12556 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12557 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12558 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12559 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12560 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12561 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12562 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12563 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12564 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12565 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12566 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12567 v4si __builtin_ia32_vpcomled (v4si, v4si)
12568 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12569 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12570 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12571 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12572 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12573 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12574 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12575 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12576 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12577 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12578 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12579 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12580 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12581 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12582 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12583 v4si __builtin_ia32_vpcomned (v4si, v4si)
12584 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12585 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12586 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12587 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12588 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12589 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12590 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12591 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12592 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12593 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12594 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12595 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12596 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12597 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12598 v4si __builtin_ia32_vphaddbd (v16qi)
12599 v2di __builtin_ia32_vphaddbq (v16qi)
12600 v8hi __builtin_ia32_vphaddbw (v16qi)
12601 v2di __builtin_ia32_vphadddq (v4si)
12602 v4si __builtin_ia32_vphaddubd (v16qi)
12603 v2di __builtin_ia32_vphaddubq (v16qi)
12604 v8hi __builtin_ia32_vphaddubw (v16qi)
12605 v2di __builtin_ia32_vphaddudq (v4si)
12606 v4si __builtin_ia32_vphadduwd (v8hi)
12607 v2di __builtin_ia32_vphadduwq (v8hi)
12608 v4si __builtin_ia32_vphaddwd (v8hi)
12609 v2di __builtin_ia32_vphaddwq (v8hi)
12610 v8hi __builtin_ia32_vphsubbw (v16qi)
12611 v2di __builtin_ia32_vphsubdq (v4si)
12612 v4si __builtin_ia32_vphsubwd (v8hi)
12613 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12614 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12615 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12616 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12617 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12618 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12619 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12620 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12621 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12622 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12623 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12624 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12625 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12626 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12627 v4si __builtin_ia32_vprotd (v4si, v4si)
12628 v2di __builtin_ia32_vprotq (v2di, v2di)
12629 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12630 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12631 v4si __builtin_ia32_vpshad (v4si, v4si)
12632 v2di __builtin_ia32_vpshaq (v2di, v2di)
12633 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12634 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12635 v4si __builtin_ia32_vpshld (v4si, v4si)
12636 v2di __builtin_ia32_vpshlq (v2di, v2di)
12637 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12638 @end smallexample
12640 The following built-in functions are available when @option{-mfma4} is used.
12641 All of them generate the machine instruction that is part of the name.
12643 @smallexample
12644 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12645 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12646 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12647 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12648 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12649 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12650 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12651 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12652 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12653 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12654 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12655 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12656 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12657 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12658 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12659 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12660 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12661 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12662 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12663 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12664 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12665 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12666 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12667 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12668 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12669 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12670 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12671 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12672 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12673 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12674 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12675 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12677 @end smallexample
12679 The following built-in functions are available when @option{-mlwp} is used.
12681 @smallexample
12682 void __builtin_ia32_llwpcb16 (void *);
12683 void __builtin_ia32_llwpcb32 (void *);
12684 void __builtin_ia32_llwpcb64 (void *);
12685 void * __builtin_ia32_llwpcb16 (void);
12686 void * __builtin_ia32_llwpcb32 (void);
12687 void * __builtin_ia32_llwpcb64 (void);
12688 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12689 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12690 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12691 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12692 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12693 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12694 @end smallexample
12696 The following built-in functions are available when @option{-mbmi} is used.
12697 All of them generate the machine instruction that is part of the name.
12698 @smallexample
12699 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12700 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12701 @end smallexample
12703 The following built-in functions are available when @option{-mbmi2} is used.
12704 All of them generate the machine instruction that is part of the name.
12705 @smallexample
12706 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12707 unsigned int _pdep_u32 (unsigned int, unsigned int)
12708 unsigned int _pext_u32 (unsigned int, unsigned int)
12709 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12710 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12711 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12712 @end smallexample
12714 The following built-in functions are available when @option{-mlzcnt} is used.
12715 All of them generate the machine instruction that is part of the name.
12716 @smallexample
12717 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12718 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12719 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12720 @end smallexample
12722 The following built-in functions are available when @option{-mfxsr} is used.
12723 All of them generate the machine instruction that is part of the name.
12724 @smallexample
12725 void __builtin_ia32_fxsave (void *)
12726 void __builtin_ia32_fxrstor (void *)
12727 void __builtin_ia32_fxsave64 (void *)
12728 void __builtin_ia32_fxrstor64 (void *)
12729 @end smallexample
12731 The following built-in functions are available when @option{-mxsave} is used.
12732 All of them generate the machine instruction that is part of the name.
12733 @smallexample
12734 void __builtin_ia32_xsave (void *, long long)
12735 void __builtin_ia32_xrstor (void *, long long)
12736 void __builtin_ia32_xsave64 (void *, long long)
12737 void __builtin_ia32_xrstor64 (void *, long long)
12738 @end smallexample
12740 The following built-in functions are available when @option{-mxsaveopt} is used.
12741 All of them generate the machine instruction that is part of the name.
12742 @smallexample
12743 void __builtin_ia32_xsaveopt (void *, long long)
12744 void __builtin_ia32_xsaveopt64 (void *, long long)
12745 @end smallexample
12747 The following built-in functions are available when @option{-mtbm} is used.
12748 Both of them generate the immediate form of the bextr machine instruction.
12749 @smallexample
12750 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12751 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12752 @end smallexample
12755 The following built-in functions are available when @option{-m3dnow} is used.
12756 All of them generate the machine instruction that is part of the name.
12758 @smallexample
12759 void __builtin_ia32_femms (void)
12760 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12761 v2si __builtin_ia32_pf2id (v2sf)
12762 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12763 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12764 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12765 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12766 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12767 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12768 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12769 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12770 v2sf __builtin_ia32_pfrcp (v2sf)
12771 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12772 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12773 v2sf __builtin_ia32_pfrsqrt (v2sf)
12774 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12775 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12776 v2sf __builtin_ia32_pi2fd (v2si)
12777 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12778 @end smallexample
12780 The following built-in functions are available when both @option{-m3dnow}
12781 and @option{-march=athlon} are used.  All of them generate the machine
12782 instruction that is part of the name.
12784 @smallexample
12785 v2si __builtin_ia32_pf2iw (v2sf)
12786 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12787 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12788 v2sf __builtin_ia32_pi2fw (v2si)
12789 v2sf __builtin_ia32_pswapdsf (v2sf)
12790 v2si __builtin_ia32_pswapdsi (v2si)
12791 @end smallexample
12793 The following built-in functions are available when @option{-mrtm} is used
12794 They are used for restricted transactional memory. These are the internal
12795 low level functions. Normally the functions in 
12796 @ref{X86 transactional memory intrinsics} should be used instead.
12798 @smallexample
12799 int __builtin_ia32_xbegin ()
12800 void __builtin_ia32_xend ()
12801 void __builtin_ia32_xabort (status)
12802 int __builtin_ia32_xtest ()
12803 @end smallexample
12805 @node X86 transactional memory intrinsics
12806 @subsection X86 transaction memory intrinsics
12808 Hardware transactional memory intrinsics for i386. These allow to use
12809 memory transactions with RTM (Restricted Transactional Memory).
12810 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12811 This support is enabled with the @option{-mrtm} option.
12813 A memory transaction commits all changes to memory in an atomic way,
12814 as visible to other threads. If the transaction fails it is rolled back
12815 and all side effects discarded.
12817 Generally there is no guarantee that a memory transaction ever succeeds
12818 and suitable fallback code always needs to be supplied.
12820 @deftypefn {RTM Function} {unsigned} _xbegin ()
12821 Start a RTM (Restricted Transactional Memory) transaction. 
12822 Returns _XBEGIN_STARTED when the transaction
12823 started successfully (note this is not 0, so the constant has to be 
12824 explicitely tested). When the transaction aborts all side effects
12825 are undone and an abort code is returned. There is no guarantee
12826 any transaction ever succeeds, so there always needs to be a valid
12827 tested fallback path.
12828 @end deftypefn
12830 @smallexample
12831 #include <immintrin.h>
12833 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12834     ... transaction code...
12835     _xend ();
12836 @} else @{
12837     ... non transactional fallback path...
12839 @end smallexample
12841 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12843 @table @code
12844 @item _XABORT_EXPLICIT
12845 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12846 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12847 @item _XABORT_RETRY
12848 Transaction retry is possible.
12849 @item _XABORT_CONFLICT
12850 Transaction abort due to a memory conflict with another thread
12851 @item _XABORT_CAPACITY
12852 Transaction abort due to the transaction using too much memory
12853 @item _XABORT_DEBUG
12854 Transaction abort due to a debug trap
12855 @item _XABORT_NESTED
12856 Transaction abort in a inner nested transaction
12857 @end table
12859 @deftypefn {RTM Function} {void} _xend ()
12860 Commit the current transaction. When no transaction is active this will
12861 fault. All memory side effects of the transactions will become visible
12862 to other threads in an atomic matter.
12863 @end deftypefn
12865 @deftypefn {RTM Function} {int} _xtest ()
12866 Return a value not zero when a transaction is currently active, otherwise 0.
12867 @end deftypefn
12869 @deftypefn {RTM Function} {void} _xabort (status)
12870 Abort the current transaction. When no transaction is active this is a no-op.
12871 status must be a 8bit constant, that is included in the status code returned
12872 by @code{_xbegin}
12873 @end deftypefn
12875 @node MIPS DSP Built-in Functions
12876 @subsection MIPS DSP Built-in Functions
12878 The MIPS DSP Application-Specific Extension (ASE) includes new
12879 instructions that are designed to improve the performance of DSP and
12880 media applications.  It provides instructions that operate on packed
12881 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12883 GCC supports MIPS DSP operations using both the generic
12884 vector extensions (@pxref{Vector Extensions}) and a collection of
12885 MIPS-specific built-in functions.  Both kinds of support are
12886 enabled by the @option{-mdsp} command-line option.
12888 Revision 2 of the ASE was introduced in the second half of 2006.
12889 This revision adds extra instructions to the original ASE, but is
12890 otherwise backwards-compatible with it.  You can select revision 2
12891 using the command-line option @option{-mdspr2}; this option implies
12892 @option{-mdsp}.
12894 The SCOUNT and POS bits of the DSP control register are global.  The
12895 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12896 POS bits.  During optimization, the compiler does not delete these
12897 instructions and it does not delete calls to functions containing
12898 these instructions.
12900 At present, GCC only provides support for operations on 32-bit
12901 vectors.  The vector type associated with 8-bit integer data is
12902 usually called @code{v4i8}, the vector type associated with Q7
12903 is usually called @code{v4q7}, the vector type associated with 16-bit
12904 integer data is usually called @code{v2i16}, and the vector type
12905 associated with Q15 is usually called @code{v2q15}.  They can be
12906 defined in C as follows:
12908 @smallexample
12909 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12910 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12911 typedef short v2i16 __attribute__ ((vector_size(4)));
12912 typedef short v2q15 __attribute__ ((vector_size(4)));
12913 @end smallexample
12915 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12916 initialized in the same way as aggregates.  For example:
12918 @smallexample
12919 v4i8 a = @{1, 2, 3, 4@};
12920 v4i8 b;
12921 b = (v4i8) @{5, 6, 7, 8@};
12923 v2q15 c = @{0x0fcb, 0x3a75@};
12924 v2q15 d;
12925 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12926 @end smallexample
12928 @emph{Note:} The CPU's endianness determines the order in which values
12929 are packed.  On little-endian targets, the first value is the least
12930 significant and the last value is the most significant.  The opposite
12931 order applies to big-endian targets.  For example, the code above
12932 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12933 and @code{4} on big-endian targets.
12935 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12936 representation.  As shown in this example, the integer representation
12937 of a Q7 value can be obtained by multiplying the fractional value by
12938 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12939 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12940 @code{0x1.0p31}.
12942 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12943 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12944 and @code{c} and @code{d} are @code{v2q15} values.
12946 @multitable @columnfractions .50 .50
12947 @item C code @tab MIPS instruction
12948 @item @code{a + b} @tab @code{addu.qb}
12949 @item @code{c + d} @tab @code{addq.ph}
12950 @item @code{a - b} @tab @code{subu.qb}
12951 @item @code{c - d} @tab @code{subq.ph}
12952 @end multitable
12954 The table below lists the @code{v2i16} operation for which
12955 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12956 @code{v2i16} values.
12958 @multitable @columnfractions .50 .50
12959 @item C code @tab MIPS instruction
12960 @item @code{e * f} @tab @code{mul.ph}
12961 @end multitable
12963 It is easier to describe the DSP built-in functions if we first define
12964 the following types:
12966 @smallexample
12967 typedef int q31;
12968 typedef int i32;
12969 typedef unsigned int ui32;
12970 typedef long long a64;
12971 @end smallexample
12973 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12974 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12975 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12976 @code{long long}, but we use @code{a64} to indicate values that are
12977 placed in one of the four DSP accumulators (@code{$ac0},
12978 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12980 Also, some built-in functions prefer or require immediate numbers as
12981 parameters, because the corresponding DSP instructions accept both immediate
12982 numbers and register operands, or accept immediate numbers only.  The
12983 immediate parameters are listed as follows.
12985 @smallexample
12986 imm0_3: 0 to 3.
12987 imm0_7: 0 to 7.
12988 imm0_15: 0 to 15.
12989 imm0_31: 0 to 31.
12990 imm0_63: 0 to 63.
12991 imm0_255: 0 to 255.
12992 imm_n32_31: -32 to 31.
12993 imm_n512_511: -512 to 511.
12994 @end smallexample
12996 The following built-in functions map directly to a particular MIPS DSP
12997 instruction.  Please refer to the architecture specification
12998 for details on what each instruction does.
13000 @smallexample
13001 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13002 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13003 q31 __builtin_mips_addq_s_w (q31, q31)
13004 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13005 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13006 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13007 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13008 q31 __builtin_mips_subq_s_w (q31, q31)
13009 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13010 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13011 i32 __builtin_mips_addsc (i32, i32)
13012 i32 __builtin_mips_addwc (i32, i32)
13013 i32 __builtin_mips_modsub (i32, i32)
13014 i32 __builtin_mips_raddu_w_qb (v4i8)
13015 v2q15 __builtin_mips_absq_s_ph (v2q15)
13016 q31 __builtin_mips_absq_s_w (q31)
13017 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13018 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13019 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13020 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13021 q31 __builtin_mips_preceq_w_phl (v2q15)
13022 q31 __builtin_mips_preceq_w_phr (v2q15)
13023 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13024 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13025 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13026 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13027 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13028 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13029 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13030 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13031 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13032 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13033 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13034 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13035 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13036 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13037 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13038 q31 __builtin_mips_shll_s_w (q31, i32)
13039 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13040 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13041 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13042 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13043 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13044 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13045 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13046 q31 __builtin_mips_shra_r_w (q31, i32)
13047 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13048 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13049 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13050 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13051 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13052 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13053 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13054 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13055 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13056 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13057 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13058 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13059 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13060 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13061 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13062 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13063 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13064 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13065 i32 __builtin_mips_bitrev (i32)
13066 i32 __builtin_mips_insv (i32, i32)
13067 v4i8 __builtin_mips_repl_qb (imm0_255)
13068 v4i8 __builtin_mips_repl_qb (i32)
13069 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13070 v2q15 __builtin_mips_repl_ph (i32)
13071 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13072 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13073 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13074 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13075 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13076 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13077 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13078 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13079 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13080 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13081 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13082 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13083 i32 __builtin_mips_extr_w (a64, imm0_31)
13084 i32 __builtin_mips_extr_w (a64, i32)
13085 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13086 i32 __builtin_mips_extr_s_h (a64, i32)
13087 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13088 i32 __builtin_mips_extr_rs_w (a64, i32)
13089 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13090 i32 __builtin_mips_extr_r_w (a64, i32)
13091 i32 __builtin_mips_extp (a64, imm0_31)
13092 i32 __builtin_mips_extp (a64, i32)
13093 i32 __builtin_mips_extpdp (a64, imm0_31)
13094 i32 __builtin_mips_extpdp (a64, i32)
13095 a64 __builtin_mips_shilo (a64, imm_n32_31)
13096 a64 __builtin_mips_shilo (a64, i32)
13097 a64 __builtin_mips_mthlip (a64, i32)
13098 void __builtin_mips_wrdsp (i32, imm0_63)
13099 i32 __builtin_mips_rddsp (imm0_63)
13100 i32 __builtin_mips_lbux (void *, i32)
13101 i32 __builtin_mips_lhx (void *, i32)
13102 i32 __builtin_mips_lwx (void *, i32)
13103 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13104 i32 __builtin_mips_bposge32 (void)
13105 a64 __builtin_mips_madd (a64, i32, i32);
13106 a64 __builtin_mips_maddu (a64, ui32, ui32);
13107 a64 __builtin_mips_msub (a64, i32, i32);
13108 a64 __builtin_mips_msubu (a64, ui32, ui32);
13109 a64 __builtin_mips_mult (i32, i32);
13110 a64 __builtin_mips_multu (ui32, ui32);
13111 @end smallexample
13113 The following built-in functions map directly to a particular MIPS DSP REV 2
13114 instruction.  Please refer to the architecture specification
13115 for details on what each instruction does.
13117 @smallexample
13118 v4q7 __builtin_mips_absq_s_qb (v4q7);
13119 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13120 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13121 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13122 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13123 i32 __builtin_mips_append (i32, i32, imm0_31);
13124 i32 __builtin_mips_balign (i32, i32, imm0_3);
13125 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13126 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13127 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13128 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13129 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13130 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13131 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13132 q31 __builtin_mips_mulq_rs_w (q31, q31);
13133 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13134 q31 __builtin_mips_mulq_s_w (q31, q31);
13135 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13136 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13137 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13138 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13139 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13140 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13141 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13142 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13143 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13144 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13145 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13146 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13147 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13148 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13149 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13150 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13151 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13152 q31 __builtin_mips_addqh_w (q31, q31);
13153 q31 __builtin_mips_addqh_r_w (q31, q31);
13154 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13155 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13156 q31 __builtin_mips_subqh_w (q31, q31);
13157 q31 __builtin_mips_subqh_r_w (q31, q31);
13158 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13159 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13160 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13161 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13162 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13163 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13164 @end smallexample
13167 @node MIPS Paired-Single Support
13168 @subsection MIPS Paired-Single Support
13170 The MIPS64 architecture includes a number of instructions that
13171 operate on pairs of single-precision floating-point values.
13172 Each pair is packed into a 64-bit floating-point register,
13173 with one element being designated the ``upper half'' and
13174 the other being designated the ``lower half''.
13176 GCC supports paired-single operations using both the generic
13177 vector extensions (@pxref{Vector Extensions}) and a collection of
13178 MIPS-specific built-in functions.  Both kinds of support are
13179 enabled by the @option{-mpaired-single} command-line option.
13181 The vector type associated with paired-single values is usually
13182 called @code{v2sf}.  It can be defined in C as follows:
13184 @smallexample
13185 typedef float v2sf __attribute__ ((vector_size (8)));
13186 @end smallexample
13188 @code{v2sf} values are initialized in the same way as aggregates.
13189 For example:
13191 @smallexample
13192 v2sf a = @{1.5, 9.1@};
13193 v2sf b;
13194 float e, f;
13195 b = (v2sf) @{e, f@};
13196 @end smallexample
13198 @emph{Note:} The CPU's endianness determines which value is stored in
13199 the upper half of a register and which value is stored in the lower half.
13200 On little-endian targets, the first value is the lower one and the second
13201 value is the upper one.  The opposite order applies to big-endian targets.
13202 For example, the code above sets the lower half of @code{a} to
13203 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13205 @node MIPS Loongson Built-in Functions
13206 @subsection MIPS Loongson Built-in Functions
13208 GCC provides intrinsics to access the SIMD instructions provided by the
13209 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13210 available after inclusion of the @code{loongson.h} header file,
13211 operate on the following 64-bit vector types:
13213 @itemize
13214 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13215 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13216 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13217 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13218 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13219 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13220 @end itemize
13222 The intrinsics provided are listed below; each is named after the
13223 machine instruction to which it corresponds, with suffixes added as
13224 appropriate to distinguish intrinsics that expand to the same machine
13225 instruction yet have different argument types.  Refer to the architecture
13226 documentation for a description of the functionality of each
13227 instruction.
13229 @smallexample
13230 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13231 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13232 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13233 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13234 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13235 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13236 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13237 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13238 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13239 uint64_t paddd_u (uint64_t s, uint64_t t);
13240 int64_t paddd_s (int64_t s, int64_t t);
13241 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13242 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13243 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13244 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13245 uint64_t pandn_ud (uint64_t s, uint64_t t);
13246 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13247 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13248 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13249 int64_t pandn_sd (int64_t s, int64_t t);
13250 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13251 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13252 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13253 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13254 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13255 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13256 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13257 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13258 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13259 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13260 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13261 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13262 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13263 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13264 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13265 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13266 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13267 uint16x4_t pextrh_u (uint16x4_t s, int field);
13268 int16x4_t pextrh_s (int16x4_t s, int field);
13269 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13270 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13271 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13272 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13273 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13274 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13275 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13276 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13277 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13278 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13279 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13280 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13281 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13282 uint8x8_t pmovmskb_u (uint8x8_t s);
13283 int8x8_t pmovmskb_s (int8x8_t s);
13284 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13285 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13286 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13287 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13288 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13289 uint16x4_t biadd (uint8x8_t s);
13290 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13291 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13292 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13293 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13294 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13295 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13296 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13297 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13298 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13299 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13300 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13301 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13302 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13303 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13304 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13305 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13306 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13307 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13308 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13309 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13310 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13311 uint64_t psubd_u (uint64_t s, uint64_t t);
13312 int64_t psubd_s (int64_t s, int64_t t);
13313 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13314 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13315 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13316 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13317 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13318 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13319 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13320 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13321 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13322 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13323 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13324 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13325 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13326 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13327 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13328 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13329 @end smallexample
13331 @menu
13332 * Paired-Single Arithmetic::
13333 * Paired-Single Built-in Functions::
13334 * MIPS-3D Built-in Functions::
13335 @end menu
13337 @node Paired-Single Arithmetic
13338 @subsubsection Paired-Single Arithmetic
13340 The table below lists the @code{v2sf} operations for which hardware
13341 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13342 values and @code{x} is an integral value.
13344 @multitable @columnfractions .50 .50
13345 @item C code @tab MIPS instruction
13346 @item @code{a + b} @tab @code{add.ps}
13347 @item @code{a - b} @tab @code{sub.ps}
13348 @item @code{-a} @tab @code{neg.ps}
13349 @item @code{a * b} @tab @code{mul.ps}
13350 @item @code{a * b + c} @tab @code{madd.ps}
13351 @item @code{a * b - c} @tab @code{msub.ps}
13352 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13353 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13354 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13355 @end multitable
13357 Note that the multiply-accumulate instructions can be disabled
13358 using the command-line option @code{-mno-fused-madd}.
13360 @node Paired-Single Built-in Functions
13361 @subsubsection Paired-Single Built-in Functions
13363 The following paired-single functions map directly to a particular
13364 MIPS instruction.  Please refer to the architecture specification
13365 for details on what each instruction does.
13367 @table @code
13368 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13369 Pair lower lower (@code{pll.ps}).
13371 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13372 Pair upper lower (@code{pul.ps}).
13374 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13375 Pair lower upper (@code{plu.ps}).
13377 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13378 Pair upper upper (@code{puu.ps}).
13380 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13381 Convert pair to paired single (@code{cvt.ps.s}).
13383 @item float __builtin_mips_cvt_s_pl (v2sf)
13384 Convert pair lower to single (@code{cvt.s.pl}).
13386 @item float __builtin_mips_cvt_s_pu (v2sf)
13387 Convert pair upper to single (@code{cvt.s.pu}).
13389 @item v2sf __builtin_mips_abs_ps (v2sf)
13390 Absolute value (@code{abs.ps}).
13392 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13393 Align variable (@code{alnv.ps}).
13395 @emph{Note:} The value of the third parameter must be 0 or 4
13396 modulo 8, otherwise the result is unpredictable.  Please read the
13397 instruction description for details.
13398 @end table
13400 The following multi-instruction functions are also available.
13401 In each case, @var{cond} can be any of the 16 floating-point conditions:
13402 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13403 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13404 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13406 @table @code
13407 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13408 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13409 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13410 @code{movt.ps}/@code{movf.ps}).
13412 The @code{movt} functions return the value @var{x} computed by:
13414 @smallexample
13415 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13416 mov.ps @var{x},@var{c}
13417 movt.ps @var{x},@var{d},@var{cc}
13418 @end smallexample
13420 The @code{movf} functions are similar but use @code{movf.ps} instead
13421 of @code{movt.ps}.
13423 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13424 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13425 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13426 @code{bc1t}/@code{bc1f}).
13428 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13429 and return either the upper or lower half of the result.  For example:
13431 @smallexample
13432 v2sf a, b;
13433 if (__builtin_mips_upper_c_eq_ps (a, b))
13434   upper_halves_are_equal ();
13435 else
13436   upper_halves_are_unequal ();
13438 if (__builtin_mips_lower_c_eq_ps (a, b))
13439   lower_halves_are_equal ();
13440 else
13441   lower_halves_are_unequal ();
13442 @end smallexample
13443 @end table
13445 @node MIPS-3D Built-in Functions
13446 @subsubsection MIPS-3D Built-in Functions
13448 The MIPS-3D Application-Specific Extension (ASE) includes additional
13449 paired-single instructions that are designed to improve the performance
13450 of 3D graphics operations.  Support for these instructions is controlled
13451 by the @option{-mips3d} command-line option.
13453 The functions listed below map directly to a particular MIPS-3D
13454 instruction.  Please refer to the architecture specification for
13455 more details on what each instruction does.
13457 @table @code
13458 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13459 Reduction add (@code{addr.ps}).
13461 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13462 Reduction multiply (@code{mulr.ps}).
13464 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13465 Convert paired single to paired word (@code{cvt.pw.ps}).
13467 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13468 Convert paired word to paired single (@code{cvt.ps.pw}).
13470 @item float __builtin_mips_recip1_s (float)
13471 @itemx double __builtin_mips_recip1_d (double)
13472 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13473 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13475 @item float __builtin_mips_recip2_s (float, float)
13476 @itemx double __builtin_mips_recip2_d (double, double)
13477 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13478 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13480 @item float __builtin_mips_rsqrt1_s (float)
13481 @itemx double __builtin_mips_rsqrt1_d (double)
13482 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13483 Reduced-precision reciprocal square root (sequence step 1)
13484 (@code{rsqrt1.@var{fmt}}).
13486 @item float __builtin_mips_rsqrt2_s (float, float)
13487 @itemx double __builtin_mips_rsqrt2_d (double, double)
13488 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13489 Reduced-precision reciprocal square root (sequence step 2)
13490 (@code{rsqrt2.@var{fmt}}).
13491 @end table
13493 The following multi-instruction functions are also available.
13494 In each case, @var{cond} can be any of the 16 floating-point conditions:
13495 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13496 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13497 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13499 @table @code
13500 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13501 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13502 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13503 @code{bc1t}/@code{bc1f}).
13505 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13506 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13507 For example:
13509 @smallexample
13510 float a, b;
13511 if (__builtin_mips_cabs_eq_s (a, b))
13512   true ();
13513 else
13514   false ();
13515 @end smallexample
13517 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13518 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13519 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13520 @code{bc1t}/@code{bc1f}).
13522 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13523 and return either the upper or lower half of the result.  For example:
13525 @smallexample
13526 v2sf a, b;
13527 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13528   upper_halves_are_equal ();
13529 else
13530   upper_halves_are_unequal ();
13532 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13533   lower_halves_are_equal ();
13534 else
13535   lower_halves_are_unequal ();
13536 @end smallexample
13538 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13539 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13540 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13541 @code{movt.ps}/@code{movf.ps}).
13543 The @code{movt} functions return the value @var{x} computed by:
13545 @smallexample
13546 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13547 mov.ps @var{x},@var{c}
13548 movt.ps @var{x},@var{d},@var{cc}
13549 @end smallexample
13551 The @code{movf} functions are similar but use @code{movf.ps} instead
13552 of @code{movt.ps}.
13554 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13555 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13556 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13557 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13558 Comparison of two paired-single values
13559 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13560 @code{bc1any2t}/@code{bc1any2f}).
13562 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13563 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13564 result is true and the @code{all} forms return true if both results are true.
13565 For example:
13567 @smallexample
13568 v2sf a, b;
13569 if (__builtin_mips_any_c_eq_ps (a, b))
13570   one_is_true ();
13571 else
13572   both_are_false ();
13574 if (__builtin_mips_all_c_eq_ps (a, b))
13575   both_are_true ();
13576 else
13577   one_is_false ();
13578 @end smallexample
13580 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13581 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13582 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13583 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13584 Comparison of four paired-single values
13585 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13586 @code{bc1any4t}/@code{bc1any4f}).
13588 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13589 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13590 The @code{any} forms return true if any of the four results are true
13591 and the @code{all} forms return true if all four results are true.
13592 For example:
13594 @smallexample
13595 v2sf a, b, c, d;
13596 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13597   some_are_true ();
13598 else
13599   all_are_false ();
13601 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13602   all_are_true ();
13603 else
13604   some_are_false ();
13605 @end smallexample
13606 @end table
13608 @node Other MIPS Built-in Functions
13609 @subsection Other MIPS Built-in Functions
13611 GCC provides other MIPS-specific built-in functions:
13613 @table @code
13614 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13615 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13616 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13617 when this function is available.
13619 @item unsigned int __builtin_mips_get_fcsr (void)
13620 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13621 Get and set the contents of the floating-point control and status register
13622 (FPU control register 31).  These functions are only available in hard-float
13623 code but can be called in both MIPS16 and non-MIPS16 contexts.
13625 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13626 register except the condition codes, which GCC assumes are preserved.
13627 @end table
13629 @node MSP430 Built-in Functions
13630 @subsection MSP430 Built-in Functions
13632 GCC provides a couple of special builtin functions to aid in the
13633 writing of interrupt handlers in C.
13635 @table @code
13636 @item __bic_SR_register_on_exit (int @var{mask})
13637 This clears the indicated bits in the saved copy of the status register
13638 currently residing on the stack.  This only works inside interrupt
13639 handlers and the changes to the status register will only take affect
13640 once the handler returns.
13642 @item __bis_SR_register_on_exit (int @var{mask})
13643 This sets the indicated bits in the saved copy of the status register
13644 currently residing on the stack.  This only works inside interrupt
13645 handlers and the changes to the status register will only take affect
13646 once the handler returns.
13648 @item __delay_cycles (long long @var{cycles})
13649 This inserts an instruction sequence that takes exactly @var{cycles}
13650 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13651 may use jumps, loops, or no-ops, and does not interfere with any other
13652 instructions.  Note that @var{cycles} must be a compile-time constant
13653 integer - that is, you must pass a number, not a variable that may be
13654 optimized to a constant later.  The number of cycles delayed by this
13655 builtin is exact.
13656 @end table
13658 @node NDS32 Built-in Functions
13659 @subsection NDS32 Built-in Functions
13661 These built-in functions are available for the NDS32 target:
13663 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13664 Insert an ISYNC instruction into the instruction stream where
13665 @var{addr} is an instruction address for serialization.
13666 @end deftypefn
13668 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13669 Insert an ISB instruction into the instruction stream.
13670 @end deftypefn
13672 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13673 Return the content of a system register which is mapped by @var{sr}.
13674 @end deftypefn
13676 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13677 Return the content of a user space register which is mapped by @var{usr}.
13678 @end deftypefn
13680 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13681 Move the @var{value} to a system register which is mapped by @var{sr}.
13682 @end deftypefn
13684 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13685 Move the @var{value} to a user space register which is mapped by @var{usr}.
13686 @end deftypefn
13688 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13689 Enable global interrupt.
13690 @end deftypefn
13692 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13693 Disable global interrupt.
13694 @end deftypefn
13696 @node picoChip Built-in Functions
13697 @subsection picoChip Built-in Functions
13699 GCC provides an interface to selected machine instructions from the
13700 picoChip instruction set.
13702 @table @code
13703 @item int __builtin_sbc (int @var{value})
13704 Sign bit count.  Return the number of consecutive bits in @var{value}
13705 that have the same value as the sign bit.  The result is the number of
13706 leading sign bits minus one, giving the number of redundant sign bits in
13707 @var{value}.
13709 @item int __builtin_byteswap (int @var{value})
13710 Byte swap.  Return the result of swapping the upper and lower bytes of
13711 @var{value}.
13713 @item int __builtin_brev (int @var{value})
13714 Bit reversal.  Return the result of reversing the bits in
13715 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13716 and so on.
13718 @item int __builtin_adds (int @var{x}, int @var{y})
13719 Saturating addition.  Return the result of adding @var{x} and @var{y},
13720 storing the value 32767 if the result overflows.
13722 @item int __builtin_subs (int @var{x}, int @var{y})
13723 Saturating subtraction.  Return the result of subtracting @var{y} from
13724 @var{x}, storing the value @minus{}32768 if the result overflows.
13726 @item void __builtin_halt (void)
13727 Halt.  The processor stops execution.  This built-in is useful for
13728 implementing assertions.
13730 @end table
13732 @node PowerPC Built-in Functions
13733 @subsection PowerPC Built-in Functions
13735 These built-in functions are available for the PowerPC family of
13736 processors:
13737 @smallexample
13738 float __builtin_recipdivf (float, float);
13739 float __builtin_rsqrtf (float);
13740 double __builtin_recipdiv (double, double);
13741 double __builtin_rsqrt (double);
13742 uint64_t __builtin_ppc_get_timebase ();
13743 unsigned long __builtin_ppc_mftb ();
13744 double __builtin_unpack_longdouble (long double, int);
13745 long double __builtin_pack_longdouble (double, double);
13746 @end smallexample
13748 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13749 @code{__builtin_rsqrtf} functions generate multiple instructions to
13750 implement the reciprocal sqrt functionality using reciprocal sqrt
13751 estimate instructions.
13753 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13754 functions generate multiple instructions to implement division using
13755 the reciprocal estimate instructions.
13757 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13758 functions generate instructions to read the Time Base Register.  The
13759 @code{__builtin_ppc_get_timebase} function may generate multiple
13760 instructions and always returns the 64 bits of the Time Base Register.
13761 The @code{__builtin_ppc_mftb} function always generates one instruction and
13762 returns the Time Base Register value as an unsigned long, throwing away
13763 the most significant word on 32-bit environments.
13765 The following built-in functions are available for the PowerPC family
13766 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13767 or @option{-mpopcntd}):
13768 @smallexample
13769 long __builtin_bpermd (long, long);
13770 int __builtin_divwe (int, int);
13771 int __builtin_divweo (int, int);
13772 unsigned int __builtin_divweu (unsigned int, unsigned int);
13773 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13774 long __builtin_divde (long, long);
13775 long __builtin_divdeo (long, long);
13776 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13777 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13778 unsigned int cdtbcd (unsigned int);
13779 unsigned int cbcdtd (unsigned int);
13780 unsigned int addg6s (unsigned int, unsigned int);
13781 @end smallexample
13783 The @code{__builtin_divde}, @code{__builtin_divdeo},
13784 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13785 64-bit environment support ISA 2.06 or later.
13787 The following built-in functions are available for the PowerPC family
13788 of processors when hardware decimal floating point
13789 (@option{-mhard-dfp}) is available:
13790 @smallexample
13791 _Decimal64 __builtin_dxex (_Decimal64);
13792 _Decimal128 __builtin_dxexq (_Decimal128);
13793 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13794 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13795 _Decimal64 __builtin_denbcd (int, _Decimal64);
13796 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13797 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13798 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13799 _Decimal64 __builtin_dscli (_Decimal64, int);
13800 _Decimal128 __builitn_dscliq (_Decimal128, int);
13801 _Decimal64 __builtin_dscri (_Decimal64, int);
13802 _Decimal128 __builitn_dscriq (_Decimal128, int);
13803 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13804 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13805 @end smallexample
13807 The following built-in functions are available for the PowerPC family
13808 of processors when the Vector Scalar (vsx) instruction set is
13809 available:
13810 @smallexample
13811 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13812 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13813                                                 unsigned long long);
13814 @end smallexample
13816 @node PowerPC AltiVec/VSX Built-in Functions
13817 @subsection PowerPC AltiVec Built-in Functions
13819 GCC provides an interface for the PowerPC family of processors to access
13820 the AltiVec operations described in Motorola's AltiVec Programming
13821 Interface Manual.  The interface is made available by including
13822 @code{<altivec.h>} and using @option{-maltivec} and
13823 @option{-mabi=altivec}.  The interface supports the following vector
13824 types.
13826 @smallexample
13827 vector unsigned char
13828 vector signed char
13829 vector bool char
13831 vector unsigned short
13832 vector signed short
13833 vector bool short
13834 vector pixel
13836 vector unsigned int
13837 vector signed int
13838 vector bool int
13839 vector float
13840 @end smallexample
13842 If @option{-mvsx} is used the following additional vector types are
13843 implemented.
13845 @smallexample
13846 vector unsigned long
13847 vector signed long
13848 vector double
13849 @end smallexample
13851 The long types are only implemented for 64-bit code generation, and
13852 the long type is only used in the floating point/integer conversion
13853 instructions.
13855 GCC's implementation of the high-level language interface available from
13856 C and C++ code differs from Motorola's documentation in several ways.
13858 @itemize @bullet
13860 @item
13861 A vector constant is a list of constant expressions within curly braces.
13863 @item
13864 A vector initializer requires no cast if the vector constant is of the
13865 same type as the variable it is initializing.
13867 @item
13868 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13869 vector type is the default signedness of the base type.  The default
13870 varies depending on the operating system, so a portable program should
13871 always specify the signedness.
13873 @item
13874 Compiling with @option{-maltivec} adds keywords @code{__vector},
13875 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13876 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13877 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13878 disabled.  To use them, you must include @code{<altivec.h>} instead.
13880 @item
13881 GCC allows using a @code{typedef} name as the type specifier for a
13882 vector type.
13884 @item
13885 For C, overloaded functions are implemented with macros so the following
13886 does not work:
13888 @smallexample
13889   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13890 @end smallexample
13892 @noindent
13893 Since @code{vec_add} is a macro, the vector constant in the example
13894 is treated as four separate arguments.  Wrap the entire argument in
13895 parentheses for this to work.
13896 @end itemize
13898 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13899 Internally, GCC uses built-in functions to achieve the functionality in
13900 the aforementioned header file, but they are not supported and are
13901 subject to change without notice.
13903 The following interfaces are supported for the generic and specific
13904 AltiVec operations and the AltiVec predicates.  In cases where there
13905 is a direct mapping between generic and specific operations, only the
13906 generic names are shown here, although the specific operations can also
13907 be used.
13909 Arguments that are documented as @code{const int} require literal
13910 integral values within the range required for that operation.
13912 @smallexample
13913 vector signed char vec_abs (vector signed char);
13914 vector signed short vec_abs (vector signed short);
13915 vector signed int vec_abs (vector signed int);
13916 vector float vec_abs (vector float);
13918 vector signed char vec_abss (vector signed char);
13919 vector signed short vec_abss (vector signed short);
13920 vector signed int vec_abss (vector signed int);
13922 vector signed char vec_add (vector bool char, vector signed char);
13923 vector signed char vec_add (vector signed char, vector bool char);
13924 vector signed char vec_add (vector signed char, vector signed char);
13925 vector unsigned char vec_add (vector bool char, vector unsigned char);
13926 vector unsigned char vec_add (vector unsigned char, vector bool char);
13927 vector unsigned char vec_add (vector unsigned char,
13928                               vector unsigned char);
13929 vector signed short vec_add (vector bool short, vector signed short);
13930 vector signed short vec_add (vector signed short, vector bool short);
13931 vector signed short vec_add (vector signed short, vector signed short);
13932 vector unsigned short vec_add (vector bool short,
13933                                vector unsigned short);
13934 vector unsigned short vec_add (vector unsigned short,
13935                                vector bool short);
13936 vector unsigned short vec_add (vector unsigned short,
13937                                vector unsigned short);
13938 vector signed int vec_add (vector bool int, vector signed int);
13939 vector signed int vec_add (vector signed int, vector bool int);
13940 vector signed int vec_add (vector signed int, vector signed int);
13941 vector unsigned int vec_add (vector bool int, vector unsigned int);
13942 vector unsigned int vec_add (vector unsigned int, vector bool int);
13943 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13944 vector float vec_add (vector float, vector float);
13946 vector float vec_vaddfp (vector float, vector float);
13948 vector signed int vec_vadduwm (vector bool int, vector signed int);
13949 vector signed int vec_vadduwm (vector signed int, vector bool int);
13950 vector signed int vec_vadduwm (vector signed int, vector signed int);
13951 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13952 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13953 vector unsigned int vec_vadduwm (vector unsigned int,
13954                                  vector unsigned int);
13956 vector signed short vec_vadduhm (vector bool short,
13957                                  vector signed short);
13958 vector signed short vec_vadduhm (vector signed short,
13959                                  vector bool short);
13960 vector signed short vec_vadduhm (vector signed short,
13961                                  vector signed short);
13962 vector unsigned short vec_vadduhm (vector bool short,
13963                                    vector unsigned short);
13964 vector unsigned short vec_vadduhm (vector unsigned short,
13965                                    vector bool short);
13966 vector unsigned short vec_vadduhm (vector unsigned short,
13967                                    vector unsigned short);
13969 vector signed char vec_vaddubm (vector bool char, vector signed char);
13970 vector signed char vec_vaddubm (vector signed char, vector bool char);
13971 vector signed char vec_vaddubm (vector signed char, vector signed char);
13972 vector unsigned char vec_vaddubm (vector bool char,
13973                                   vector unsigned char);
13974 vector unsigned char vec_vaddubm (vector unsigned char,
13975                                   vector bool char);
13976 vector unsigned char vec_vaddubm (vector unsigned char,
13977                                   vector unsigned char);
13979 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13981 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13982 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13983 vector unsigned char vec_adds (vector unsigned char,
13984                                vector unsigned char);
13985 vector signed char vec_adds (vector bool char, vector signed char);
13986 vector signed char vec_adds (vector signed char, vector bool char);
13987 vector signed char vec_adds (vector signed char, vector signed char);
13988 vector unsigned short vec_adds (vector bool short,
13989                                 vector unsigned short);
13990 vector unsigned short vec_adds (vector unsigned short,
13991                                 vector bool short);
13992 vector unsigned short vec_adds (vector unsigned short,
13993                                 vector unsigned short);
13994 vector signed short vec_adds (vector bool short, vector signed short);
13995 vector signed short vec_adds (vector signed short, vector bool short);
13996 vector signed short vec_adds (vector signed short, vector signed short);
13997 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13998 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13999 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14000 vector signed int vec_adds (vector bool int, vector signed int);
14001 vector signed int vec_adds (vector signed int, vector bool int);
14002 vector signed int vec_adds (vector signed int, vector signed int);
14004 vector signed int vec_vaddsws (vector bool int, vector signed int);
14005 vector signed int vec_vaddsws (vector signed int, vector bool int);
14006 vector signed int vec_vaddsws (vector signed int, vector signed int);
14008 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14009 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14010 vector unsigned int vec_vadduws (vector unsigned int,
14011                                  vector unsigned int);
14013 vector signed short vec_vaddshs (vector bool short,
14014                                  vector signed short);
14015 vector signed short vec_vaddshs (vector signed short,
14016                                  vector bool short);
14017 vector signed short vec_vaddshs (vector signed short,
14018                                  vector signed short);
14020 vector unsigned short vec_vadduhs (vector bool short,
14021                                    vector unsigned short);
14022 vector unsigned short vec_vadduhs (vector unsigned short,
14023                                    vector bool short);
14024 vector unsigned short vec_vadduhs (vector unsigned short,
14025                                    vector unsigned short);
14027 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14028 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14029 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14031 vector unsigned char vec_vaddubs (vector bool char,
14032                                   vector unsigned char);
14033 vector unsigned char vec_vaddubs (vector unsigned char,
14034                                   vector bool char);
14035 vector unsigned char vec_vaddubs (vector unsigned char,
14036                                   vector unsigned char);
14038 vector float vec_and (vector float, vector float);
14039 vector float vec_and (vector float, vector bool int);
14040 vector float vec_and (vector bool int, vector float);
14041 vector bool int vec_and (vector bool int, vector bool int);
14042 vector signed int vec_and (vector bool int, vector signed int);
14043 vector signed int vec_and (vector signed int, vector bool int);
14044 vector signed int vec_and (vector signed int, vector signed int);
14045 vector unsigned int vec_and (vector bool int, vector unsigned int);
14046 vector unsigned int vec_and (vector unsigned int, vector bool int);
14047 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14048 vector bool short vec_and (vector bool short, vector bool short);
14049 vector signed short vec_and (vector bool short, vector signed short);
14050 vector signed short vec_and (vector signed short, vector bool short);
14051 vector signed short vec_and (vector signed short, vector signed short);
14052 vector unsigned short vec_and (vector bool short,
14053                                vector unsigned short);
14054 vector unsigned short vec_and (vector unsigned short,
14055                                vector bool short);
14056 vector unsigned short vec_and (vector unsigned short,
14057                                vector unsigned short);
14058 vector signed char vec_and (vector bool char, vector signed char);
14059 vector bool char vec_and (vector bool char, vector bool char);
14060 vector signed char vec_and (vector signed char, vector bool char);
14061 vector signed char vec_and (vector signed char, vector signed char);
14062 vector unsigned char vec_and (vector bool char, vector unsigned char);
14063 vector unsigned char vec_and (vector unsigned char, vector bool char);
14064 vector unsigned char vec_and (vector unsigned char,
14065                               vector unsigned char);
14067 vector float vec_andc (vector float, vector float);
14068 vector float vec_andc (vector float, vector bool int);
14069 vector float vec_andc (vector bool int, vector float);
14070 vector bool int vec_andc (vector bool int, vector bool int);
14071 vector signed int vec_andc (vector bool int, vector signed int);
14072 vector signed int vec_andc (vector signed int, vector bool int);
14073 vector signed int vec_andc (vector signed int, vector signed int);
14074 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14075 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14076 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14077 vector bool short vec_andc (vector bool short, vector bool short);
14078 vector signed short vec_andc (vector bool short, vector signed short);
14079 vector signed short vec_andc (vector signed short, vector bool short);
14080 vector signed short vec_andc (vector signed short, vector signed short);
14081 vector unsigned short vec_andc (vector bool short,
14082                                 vector unsigned short);
14083 vector unsigned short vec_andc (vector unsigned short,
14084                                 vector bool short);
14085 vector unsigned short vec_andc (vector unsigned short,
14086                                 vector unsigned short);
14087 vector signed char vec_andc (vector bool char, vector signed char);
14088 vector bool char vec_andc (vector bool char, vector bool char);
14089 vector signed char vec_andc (vector signed char, vector bool char);
14090 vector signed char vec_andc (vector signed char, vector signed char);
14091 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14092 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14093 vector unsigned char vec_andc (vector unsigned char,
14094                                vector unsigned char);
14096 vector unsigned char vec_avg (vector unsigned char,
14097                               vector unsigned char);
14098 vector signed char vec_avg (vector signed char, vector signed char);
14099 vector unsigned short vec_avg (vector unsigned short,
14100                                vector unsigned short);
14101 vector signed short vec_avg (vector signed short, vector signed short);
14102 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14103 vector signed int vec_avg (vector signed int, vector signed int);
14105 vector signed int vec_vavgsw (vector signed int, vector signed int);
14107 vector unsigned int vec_vavguw (vector unsigned int,
14108                                 vector unsigned int);
14110 vector signed short vec_vavgsh (vector signed short,
14111                                 vector signed short);
14113 vector unsigned short vec_vavguh (vector unsigned short,
14114                                   vector unsigned short);
14116 vector signed char vec_vavgsb (vector signed char, vector signed char);
14118 vector unsigned char vec_vavgub (vector unsigned char,
14119                                  vector unsigned char);
14121 vector float vec_copysign (vector float);
14123 vector float vec_ceil (vector float);
14125 vector signed int vec_cmpb (vector float, vector float);
14127 vector bool char vec_cmpeq (vector signed char, vector signed char);
14128 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14129 vector bool short vec_cmpeq (vector signed short, vector signed short);
14130 vector bool short vec_cmpeq (vector unsigned short,
14131                              vector unsigned short);
14132 vector bool int vec_cmpeq (vector signed int, vector signed int);
14133 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14134 vector bool int vec_cmpeq (vector float, vector float);
14136 vector bool int vec_vcmpeqfp (vector float, vector float);
14138 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14139 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14141 vector bool short vec_vcmpequh (vector signed short,
14142                                 vector signed short);
14143 vector bool short vec_vcmpequh (vector unsigned short,
14144                                 vector unsigned short);
14146 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14147 vector bool char vec_vcmpequb (vector unsigned char,
14148                                vector unsigned char);
14150 vector bool int vec_cmpge (vector float, vector float);
14152 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14153 vector bool char vec_cmpgt (vector signed char, vector signed char);
14154 vector bool short vec_cmpgt (vector unsigned short,
14155                              vector unsigned short);
14156 vector bool short vec_cmpgt (vector signed short, vector signed short);
14157 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14158 vector bool int vec_cmpgt (vector signed int, vector signed int);
14159 vector bool int vec_cmpgt (vector float, vector float);
14161 vector bool int vec_vcmpgtfp (vector float, vector float);
14163 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14165 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14167 vector bool short vec_vcmpgtsh (vector signed short,
14168                                 vector signed short);
14170 vector bool short vec_vcmpgtuh (vector unsigned short,
14171                                 vector unsigned short);
14173 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14175 vector bool char vec_vcmpgtub (vector unsigned char,
14176                                vector unsigned char);
14178 vector bool int vec_cmple (vector float, vector float);
14180 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14181 vector bool char vec_cmplt (vector signed char, vector signed char);
14182 vector bool short vec_cmplt (vector unsigned short,
14183                              vector unsigned short);
14184 vector bool short vec_cmplt (vector signed short, vector signed short);
14185 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14186 vector bool int vec_cmplt (vector signed int, vector signed int);
14187 vector bool int vec_cmplt (vector float, vector float);
14189 vector float vec_cpsgn (vector float, vector float);
14191 vector float vec_ctf (vector unsigned int, const int);
14192 vector float vec_ctf (vector signed int, const int);
14193 vector double vec_ctf (vector unsigned long, const int);
14194 vector double vec_ctf (vector signed long, const int);
14196 vector float vec_vcfsx (vector signed int, const int);
14198 vector float vec_vcfux (vector unsigned int, const int);
14200 vector signed int vec_cts (vector float, const int);
14201 vector signed long vec_cts (vector double, const int);
14203 vector unsigned int vec_ctu (vector float, const int);
14204 vector unsigned long vec_ctu (vector double, const int);
14206 void vec_dss (const int);
14208 void vec_dssall (void);
14210 void vec_dst (const vector unsigned char *, int, const int);
14211 void vec_dst (const vector signed char *, int, const int);
14212 void vec_dst (const vector bool char *, int, const int);
14213 void vec_dst (const vector unsigned short *, int, const int);
14214 void vec_dst (const vector signed short *, int, const int);
14215 void vec_dst (const vector bool short *, int, const int);
14216 void vec_dst (const vector pixel *, int, const int);
14217 void vec_dst (const vector unsigned int *, int, const int);
14218 void vec_dst (const vector signed int *, int, const int);
14219 void vec_dst (const vector bool int *, int, const int);
14220 void vec_dst (const vector float *, int, const int);
14221 void vec_dst (const unsigned char *, int, const int);
14222 void vec_dst (const signed char *, int, const int);
14223 void vec_dst (const unsigned short *, int, const int);
14224 void vec_dst (const short *, int, const int);
14225 void vec_dst (const unsigned int *, int, const int);
14226 void vec_dst (const int *, int, const int);
14227 void vec_dst (const unsigned long *, int, const int);
14228 void vec_dst (const long *, int, const int);
14229 void vec_dst (const float *, int, const int);
14231 void vec_dstst (const vector unsigned char *, int, const int);
14232 void vec_dstst (const vector signed char *, int, const int);
14233 void vec_dstst (const vector bool char *, int, const int);
14234 void vec_dstst (const vector unsigned short *, int, const int);
14235 void vec_dstst (const vector signed short *, int, const int);
14236 void vec_dstst (const vector bool short *, int, const int);
14237 void vec_dstst (const vector pixel *, int, const int);
14238 void vec_dstst (const vector unsigned int *, int, const int);
14239 void vec_dstst (const vector signed int *, int, const int);
14240 void vec_dstst (const vector bool int *, int, const int);
14241 void vec_dstst (const vector float *, int, const int);
14242 void vec_dstst (const unsigned char *, int, const int);
14243 void vec_dstst (const signed char *, int, const int);
14244 void vec_dstst (const unsigned short *, int, const int);
14245 void vec_dstst (const short *, int, const int);
14246 void vec_dstst (const unsigned int *, int, const int);
14247 void vec_dstst (const int *, int, const int);
14248 void vec_dstst (const unsigned long *, int, const int);
14249 void vec_dstst (const long *, int, const int);
14250 void vec_dstst (const float *, int, const int);
14252 void vec_dststt (const vector unsigned char *, int, const int);
14253 void vec_dststt (const vector signed char *, int, const int);
14254 void vec_dststt (const vector bool char *, int, const int);
14255 void vec_dststt (const vector unsigned short *, int, const int);
14256 void vec_dststt (const vector signed short *, int, const int);
14257 void vec_dststt (const vector bool short *, int, const int);
14258 void vec_dststt (const vector pixel *, int, const int);
14259 void vec_dststt (const vector unsigned int *, int, const int);
14260 void vec_dststt (const vector signed int *, int, const int);
14261 void vec_dststt (const vector bool int *, int, const int);
14262 void vec_dststt (const vector float *, int, const int);
14263 void vec_dststt (const unsigned char *, int, const int);
14264 void vec_dststt (const signed char *, int, const int);
14265 void vec_dststt (const unsigned short *, int, const int);
14266 void vec_dststt (const short *, int, const int);
14267 void vec_dststt (const unsigned int *, int, const int);
14268 void vec_dststt (const int *, int, const int);
14269 void vec_dststt (const unsigned long *, int, const int);
14270 void vec_dststt (const long *, int, const int);
14271 void vec_dststt (const float *, int, const int);
14273 void vec_dstt (const vector unsigned char *, int, const int);
14274 void vec_dstt (const vector signed char *, int, const int);
14275 void vec_dstt (const vector bool char *, int, const int);
14276 void vec_dstt (const vector unsigned short *, int, const int);
14277 void vec_dstt (const vector signed short *, int, const int);
14278 void vec_dstt (const vector bool short *, int, const int);
14279 void vec_dstt (const vector pixel *, int, const int);
14280 void vec_dstt (const vector unsigned int *, int, const int);
14281 void vec_dstt (const vector signed int *, int, const int);
14282 void vec_dstt (const vector bool int *, int, const int);
14283 void vec_dstt (const vector float *, int, const int);
14284 void vec_dstt (const unsigned char *, int, const int);
14285 void vec_dstt (const signed char *, int, const int);
14286 void vec_dstt (const unsigned short *, int, const int);
14287 void vec_dstt (const short *, int, const int);
14288 void vec_dstt (const unsigned int *, int, const int);
14289 void vec_dstt (const int *, int, const int);
14290 void vec_dstt (const unsigned long *, int, const int);
14291 void vec_dstt (const long *, int, const int);
14292 void vec_dstt (const float *, int, const int);
14294 vector float vec_expte (vector float);
14296 vector float vec_floor (vector float);
14298 vector float vec_ld (int, const vector float *);
14299 vector float vec_ld (int, const float *);
14300 vector bool int vec_ld (int, const vector bool int *);
14301 vector signed int vec_ld (int, const vector signed int *);
14302 vector signed int vec_ld (int, const int *);
14303 vector signed int vec_ld (int, const long *);
14304 vector unsigned int vec_ld (int, const vector unsigned int *);
14305 vector unsigned int vec_ld (int, const unsigned int *);
14306 vector unsigned int vec_ld (int, const unsigned long *);
14307 vector bool short vec_ld (int, const vector bool short *);
14308 vector pixel vec_ld (int, const vector pixel *);
14309 vector signed short vec_ld (int, const vector signed short *);
14310 vector signed short vec_ld (int, const short *);
14311 vector unsigned short vec_ld (int, const vector unsigned short *);
14312 vector unsigned short vec_ld (int, const unsigned short *);
14313 vector bool char vec_ld (int, const vector bool char *);
14314 vector signed char vec_ld (int, const vector signed char *);
14315 vector signed char vec_ld (int, const signed char *);
14316 vector unsigned char vec_ld (int, const vector unsigned char *);
14317 vector unsigned char vec_ld (int, const unsigned char *);
14319 vector signed char vec_lde (int, const signed char *);
14320 vector unsigned char vec_lde (int, const unsigned char *);
14321 vector signed short vec_lde (int, const short *);
14322 vector unsigned short vec_lde (int, const unsigned short *);
14323 vector float vec_lde (int, const float *);
14324 vector signed int vec_lde (int, const int *);
14325 vector unsigned int vec_lde (int, const unsigned int *);
14326 vector signed int vec_lde (int, const long *);
14327 vector unsigned int vec_lde (int, const unsigned long *);
14329 vector float vec_lvewx (int, float *);
14330 vector signed int vec_lvewx (int, int *);
14331 vector unsigned int vec_lvewx (int, unsigned int *);
14332 vector signed int vec_lvewx (int, long *);
14333 vector unsigned int vec_lvewx (int, unsigned long *);
14335 vector signed short vec_lvehx (int, short *);
14336 vector unsigned short vec_lvehx (int, unsigned short *);
14338 vector signed char vec_lvebx (int, char *);
14339 vector unsigned char vec_lvebx (int, unsigned char *);
14341 vector float vec_ldl (int, const vector float *);
14342 vector float vec_ldl (int, const float *);
14343 vector bool int vec_ldl (int, const vector bool int *);
14344 vector signed int vec_ldl (int, const vector signed int *);
14345 vector signed int vec_ldl (int, const int *);
14346 vector signed int vec_ldl (int, const long *);
14347 vector unsigned int vec_ldl (int, const vector unsigned int *);
14348 vector unsigned int vec_ldl (int, const unsigned int *);
14349 vector unsigned int vec_ldl (int, const unsigned long *);
14350 vector bool short vec_ldl (int, const vector bool short *);
14351 vector pixel vec_ldl (int, const vector pixel *);
14352 vector signed short vec_ldl (int, const vector signed short *);
14353 vector signed short vec_ldl (int, const short *);
14354 vector unsigned short vec_ldl (int, const vector unsigned short *);
14355 vector unsigned short vec_ldl (int, const unsigned short *);
14356 vector bool char vec_ldl (int, const vector bool char *);
14357 vector signed char vec_ldl (int, const vector signed char *);
14358 vector signed char vec_ldl (int, const signed char *);
14359 vector unsigned char vec_ldl (int, const vector unsigned char *);
14360 vector unsigned char vec_ldl (int, const unsigned char *);
14362 vector float vec_loge (vector float);
14364 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14365 vector unsigned char vec_lvsl (int, const volatile signed char *);
14366 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14367 vector unsigned char vec_lvsl (int, const volatile short *);
14368 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14369 vector unsigned char vec_lvsl (int, const volatile int *);
14370 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14371 vector unsigned char vec_lvsl (int, const volatile long *);
14372 vector unsigned char vec_lvsl (int, const volatile float *);
14374 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14375 vector unsigned char vec_lvsr (int, const volatile signed char *);
14376 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14377 vector unsigned char vec_lvsr (int, const volatile short *);
14378 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14379 vector unsigned char vec_lvsr (int, const volatile int *);
14380 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14381 vector unsigned char vec_lvsr (int, const volatile long *);
14382 vector unsigned char vec_lvsr (int, const volatile float *);
14384 vector float vec_madd (vector float, vector float, vector float);
14386 vector signed short vec_madds (vector signed short,
14387                                vector signed short,
14388                                vector signed short);
14390 vector unsigned char vec_max (vector bool char, vector unsigned char);
14391 vector unsigned char vec_max (vector unsigned char, vector bool char);
14392 vector unsigned char vec_max (vector unsigned char,
14393                               vector unsigned char);
14394 vector signed char vec_max (vector bool char, vector signed char);
14395 vector signed char vec_max (vector signed char, vector bool char);
14396 vector signed char vec_max (vector signed char, vector signed char);
14397 vector unsigned short vec_max (vector bool short,
14398                                vector unsigned short);
14399 vector unsigned short vec_max (vector unsigned short,
14400                                vector bool short);
14401 vector unsigned short vec_max (vector unsigned short,
14402                                vector unsigned short);
14403 vector signed short vec_max (vector bool short, vector signed short);
14404 vector signed short vec_max (vector signed short, vector bool short);
14405 vector signed short vec_max (vector signed short, vector signed short);
14406 vector unsigned int vec_max (vector bool int, vector unsigned int);
14407 vector unsigned int vec_max (vector unsigned int, vector bool int);
14408 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14409 vector signed int vec_max (vector bool int, vector signed int);
14410 vector signed int vec_max (vector signed int, vector bool int);
14411 vector signed int vec_max (vector signed int, vector signed int);
14412 vector float vec_max (vector float, vector float);
14414 vector float vec_vmaxfp (vector float, vector float);
14416 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14417 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14418 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14420 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14421 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14422 vector unsigned int vec_vmaxuw (vector unsigned int,
14423                                 vector unsigned int);
14425 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14426 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14427 vector signed short vec_vmaxsh (vector signed short,
14428                                 vector signed short);
14430 vector unsigned short vec_vmaxuh (vector bool short,
14431                                   vector unsigned short);
14432 vector unsigned short vec_vmaxuh (vector unsigned short,
14433                                   vector bool short);
14434 vector unsigned short vec_vmaxuh (vector unsigned short,
14435                                   vector unsigned short);
14437 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14438 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14439 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14441 vector unsigned char vec_vmaxub (vector bool char,
14442                                  vector unsigned char);
14443 vector unsigned char vec_vmaxub (vector unsigned char,
14444                                  vector bool char);
14445 vector unsigned char vec_vmaxub (vector unsigned char,
14446                                  vector unsigned char);
14448 vector bool char vec_mergeh (vector bool char, vector bool char);
14449 vector signed char vec_mergeh (vector signed char, vector signed char);
14450 vector unsigned char vec_mergeh (vector unsigned char,
14451                                  vector unsigned char);
14452 vector bool short vec_mergeh (vector bool short, vector bool short);
14453 vector pixel vec_mergeh (vector pixel, vector pixel);
14454 vector signed short vec_mergeh (vector signed short,
14455                                 vector signed short);
14456 vector unsigned short vec_mergeh (vector unsigned short,
14457                                   vector unsigned short);
14458 vector float vec_mergeh (vector float, vector float);
14459 vector bool int vec_mergeh (vector bool int, vector bool int);
14460 vector signed int vec_mergeh (vector signed int, vector signed int);
14461 vector unsigned int vec_mergeh (vector unsigned int,
14462                                 vector unsigned int);
14464 vector float vec_vmrghw (vector float, vector float);
14465 vector bool int vec_vmrghw (vector bool int, vector bool int);
14466 vector signed int vec_vmrghw (vector signed int, vector signed int);
14467 vector unsigned int vec_vmrghw (vector unsigned int,
14468                                 vector unsigned int);
14470 vector bool short vec_vmrghh (vector bool short, vector bool short);
14471 vector signed short vec_vmrghh (vector signed short,
14472                                 vector signed short);
14473 vector unsigned short vec_vmrghh (vector unsigned short,
14474                                   vector unsigned short);
14475 vector pixel vec_vmrghh (vector pixel, vector pixel);
14477 vector bool char vec_vmrghb (vector bool char, vector bool char);
14478 vector signed char vec_vmrghb (vector signed char, vector signed char);
14479 vector unsigned char vec_vmrghb (vector unsigned char,
14480                                  vector unsigned char);
14482 vector bool char vec_mergel (vector bool char, vector bool char);
14483 vector signed char vec_mergel (vector signed char, vector signed char);
14484 vector unsigned char vec_mergel (vector unsigned char,
14485                                  vector unsigned char);
14486 vector bool short vec_mergel (vector bool short, vector bool short);
14487 vector pixel vec_mergel (vector pixel, vector pixel);
14488 vector signed short vec_mergel (vector signed short,
14489                                 vector signed short);
14490 vector unsigned short vec_mergel (vector unsigned short,
14491                                   vector unsigned short);
14492 vector float vec_mergel (vector float, vector float);
14493 vector bool int vec_mergel (vector bool int, vector bool int);
14494 vector signed int vec_mergel (vector signed int, vector signed int);
14495 vector unsigned int vec_mergel (vector unsigned int,
14496                                 vector unsigned int);
14498 vector float vec_vmrglw (vector float, vector float);
14499 vector signed int vec_vmrglw (vector signed int, vector signed int);
14500 vector unsigned int vec_vmrglw (vector unsigned int,
14501                                 vector unsigned int);
14502 vector bool int vec_vmrglw (vector bool int, vector bool int);
14504 vector bool short vec_vmrglh (vector bool short, vector bool short);
14505 vector signed short vec_vmrglh (vector signed short,
14506                                 vector signed short);
14507 vector unsigned short vec_vmrglh (vector unsigned short,
14508                                   vector unsigned short);
14509 vector pixel vec_vmrglh (vector pixel, vector pixel);
14511 vector bool char vec_vmrglb (vector bool char, vector bool char);
14512 vector signed char vec_vmrglb (vector signed char, vector signed char);
14513 vector unsigned char vec_vmrglb (vector unsigned char,
14514                                  vector unsigned char);
14516 vector unsigned short vec_mfvscr (void);
14518 vector unsigned char vec_min (vector bool char, vector unsigned char);
14519 vector unsigned char vec_min (vector unsigned char, vector bool char);
14520 vector unsigned char vec_min (vector unsigned char,
14521                               vector unsigned char);
14522 vector signed char vec_min (vector bool char, vector signed char);
14523 vector signed char vec_min (vector signed char, vector bool char);
14524 vector signed char vec_min (vector signed char, vector signed char);
14525 vector unsigned short vec_min (vector bool short,
14526                                vector unsigned short);
14527 vector unsigned short vec_min (vector unsigned short,
14528                                vector bool short);
14529 vector unsigned short vec_min (vector unsigned short,
14530                                vector unsigned short);
14531 vector signed short vec_min (vector bool short, vector signed short);
14532 vector signed short vec_min (vector signed short, vector bool short);
14533 vector signed short vec_min (vector signed short, vector signed short);
14534 vector unsigned int vec_min (vector bool int, vector unsigned int);
14535 vector unsigned int vec_min (vector unsigned int, vector bool int);
14536 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14537 vector signed int vec_min (vector bool int, vector signed int);
14538 vector signed int vec_min (vector signed int, vector bool int);
14539 vector signed int vec_min (vector signed int, vector signed int);
14540 vector float vec_min (vector float, vector float);
14542 vector float vec_vminfp (vector float, vector float);
14544 vector signed int vec_vminsw (vector bool int, vector signed int);
14545 vector signed int vec_vminsw (vector signed int, vector bool int);
14546 vector signed int vec_vminsw (vector signed int, vector signed int);
14548 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14549 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14550 vector unsigned int vec_vminuw (vector unsigned int,
14551                                 vector unsigned int);
14553 vector signed short vec_vminsh (vector bool short, vector signed short);
14554 vector signed short vec_vminsh (vector signed short, vector bool short);
14555 vector signed short vec_vminsh (vector signed short,
14556                                 vector signed short);
14558 vector unsigned short vec_vminuh (vector bool short,
14559                                   vector unsigned short);
14560 vector unsigned short vec_vminuh (vector unsigned short,
14561                                   vector bool short);
14562 vector unsigned short vec_vminuh (vector unsigned short,
14563                                   vector unsigned short);
14565 vector signed char vec_vminsb (vector bool char, vector signed char);
14566 vector signed char vec_vminsb (vector signed char, vector bool char);
14567 vector signed char vec_vminsb (vector signed char, vector signed char);
14569 vector unsigned char vec_vminub (vector bool char,
14570                                  vector unsigned char);
14571 vector unsigned char vec_vminub (vector unsigned char,
14572                                  vector bool char);
14573 vector unsigned char vec_vminub (vector unsigned char,
14574                                  vector unsigned char);
14576 vector signed short vec_mladd (vector signed short,
14577                                vector signed short,
14578                                vector signed short);
14579 vector signed short vec_mladd (vector signed short,
14580                                vector unsigned short,
14581                                vector unsigned short);
14582 vector signed short vec_mladd (vector unsigned short,
14583                                vector signed short,
14584                                vector signed short);
14585 vector unsigned short vec_mladd (vector unsigned short,
14586                                  vector unsigned short,
14587                                  vector unsigned short);
14589 vector signed short vec_mradds (vector signed short,
14590                                 vector signed short,
14591                                 vector signed short);
14593 vector unsigned int vec_msum (vector unsigned char,
14594                               vector unsigned char,
14595                               vector unsigned int);
14596 vector signed int vec_msum (vector signed char,
14597                             vector unsigned char,
14598                             vector signed int);
14599 vector unsigned int vec_msum (vector unsigned short,
14600                               vector unsigned short,
14601                               vector unsigned int);
14602 vector signed int vec_msum (vector signed short,
14603                             vector signed short,
14604                             vector signed int);
14606 vector signed int vec_vmsumshm (vector signed short,
14607                                 vector signed short,
14608                                 vector signed int);
14610 vector unsigned int vec_vmsumuhm (vector unsigned short,
14611                                   vector unsigned short,
14612                                   vector unsigned int);
14614 vector signed int vec_vmsummbm (vector signed char,
14615                                 vector unsigned char,
14616                                 vector signed int);
14618 vector unsigned int vec_vmsumubm (vector unsigned char,
14619                                   vector unsigned char,
14620                                   vector unsigned int);
14622 vector unsigned int vec_msums (vector unsigned short,
14623                                vector unsigned short,
14624                                vector unsigned int);
14625 vector signed int vec_msums (vector signed short,
14626                              vector signed short,
14627                              vector signed int);
14629 vector signed int vec_vmsumshs (vector signed short,
14630                                 vector signed short,
14631                                 vector signed int);
14633 vector unsigned int vec_vmsumuhs (vector unsigned short,
14634                                   vector unsigned short,
14635                                   vector unsigned int);
14637 void vec_mtvscr (vector signed int);
14638 void vec_mtvscr (vector unsigned int);
14639 void vec_mtvscr (vector bool int);
14640 void vec_mtvscr (vector signed short);
14641 void vec_mtvscr (vector unsigned short);
14642 void vec_mtvscr (vector bool short);
14643 void vec_mtvscr (vector pixel);
14644 void vec_mtvscr (vector signed char);
14645 void vec_mtvscr (vector unsigned char);
14646 void vec_mtvscr (vector bool char);
14648 vector unsigned short vec_mule (vector unsigned char,
14649                                 vector unsigned char);
14650 vector signed short vec_mule (vector signed char,
14651                               vector signed char);
14652 vector unsigned int vec_mule (vector unsigned short,
14653                               vector unsigned short);
14654 vector signed int vec_mule (vector signed short, vector signed short);
14656 vector signed int vec_vmulesh (vector signed short,
14657                                vector signed short);
14659 vector unsigned int vec_vmuleuh (vector unsigned short,
14660                                  vector unsigned short);
14662 vector signed short vec_vmulesb (vector signed char,
14663                                  vector signed char);
14665 vector unsigned short vec_vmuleub (vector unsigned char,
14666                                   vector unsigned char);
14668 vector unsigned short vec_mulo (vector unsigned char,
14669                                 vector unsigned char);
14670 vector signed short vec_mulo (vector signed char, vector signed char);
14671 vector unsigned int vec_mulo (vector unsigned short,
14672                               vector unsigned short);
14673 vector signed int vec_mulo (vector signed short, vector signed short);
14675 vector signed int vec_vmulosh (vector signed short,
14676                                vector signed short);
14678 vector unsigned int vec_vmulouh (vector unsigned short,
14679                                  vector unsigned short);
14681 vector signed short vec_vmulosb (vector signed char,
14682                                  vector signed char);
14684 vector unsigned short vec_vmuloub (vector unsigned char,
14685                                    vector unsigned char);
14687 vector float vec_nmsub (vector float, vector float, vector float);
14689 vector float vec_nor (vector float, vector float);
14690 vector signed int vec_nor (vector signed int, vector signed int);
14691 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14692 vector bool int vec_nor (vector bool int, vector bool int);
14693 vector signed short vec_nor (vector signed short, vector signed short);
14694 vector unsigned short vec_nor (vector unsigned short,
14695                                vector unsigned short);
14696 vector bool short vec_nor (vector bool short, vector bool short);
14697 vector signed char vec_nor (vector signed char, vector signed char);
14698 vector unsigned char vec_nor (vector unsigned char,
14699                               vector unsigned char);
14700 vector bool char vec_nor (vector bool char, vector bool char);
14702 vector float vec_or (vector float, vector float);
14703 vector float vec_or (vector float, vector bool int);
14704 vector float vec_or (vector bool int, vector float);
14705 vector bool int vec_or (vector bool int, vector bool int);
14706 vector signed int vec_or (vector bool int, vector signed int);
14707 vector signed int vec_or (vector signed int, vector bool int);
14708 vector signed int vec_or (vector signed int, vector signed int);
14709 vector unsigned int vec_or (vector bool int, vector unsigned int);
14710 vector unsigned int vec_or (vector unsigned int, vector bool int);
14711 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14712 vector bool short vec_or (vector bool short, vector bool short);
14713 vector signed short vec_or (vector bool short, vector signed short);
14714 vector signed short vec_or (vector signed short, vector bool short);
14715 vector signed short vec_or (vector signed short, vector signed short);
14716 vector unsigned short vec_or (vector bool short, vector unsigned short);
14717 vector unsigned short vec_or (vector unsigned short, vector bool short);
14718 vector unsigned short vec_or (vector unsigned short,
14719                               vector unsigned short);
14720 vector signed char vec_or (vector bool char, vector signed char);
14721 vector bool char vec_or (vector bool char, vector bool char);
14722 vector signed char vec_or (vector signed char, vector bool char);
14723 vector signed char vec_or (vector signed char, vector signed char);
14724 vector unsigned char vec_or (vector bool char, vector unsigned char);
14725 vector unsigned char vec_or (vector unsigned char, vector bool char);
14726 vector unsigned char vec_or (vector unsigned char,
14727                              vector unsigned char);
14729 vector signed char vec_pack (vector signed short, vector signed short);
14730 vector unsigned char vec_pack (vector unsigned short,
14731                                vector unsigned short);
14732 vector bool char vec_pack (vector bool short, vector bool short);
14733 vector signed short vec_pack (vector signed int, vector signed int);
14734 vector unsigned short vec_pack (vector unsigned int,
14735                                 vector unsigned int);
14736 vector bool short vec_pack (vector bool int, vector bool int);
14738 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14739 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14740 vector unsigned short vec_vpkuwum (vector unsigned int,
14741                                    vector unsigned int);
14743 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14744 vector signed char vec_vpkuhum (vector signed short,
14745                                 vector signed short);
14746 vector unsigned char vec_vpkuhum (vector unsigned short,
14747                                   vector unsigned short);
14749 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14751 vector unsigned char vec_packs (vector unsigned short,
14752                                 vector unsigned short);
14753 vector signed char vec_packs (vector signed short, vector signed short);
14754 vector unsigned short vec_packs (vector unsigned int,
14755                                  vector unsigned int);
14756 vector signed short vec_packs (vector signed int, vector signed int);
14758 vector signed short vec_vpkswss (vector signed int, vector signed int);
14760 vector unsigned short vec_vpkuwus (vector unsigned int,
14761                                    vector unsigned int);
14763 vector signed char vec_vpkshss (vector signed short,
14764                                 vector signed short);
14766 vector unsigned char vec_vpkuhus (vector unsigned short,
14767                                   vector unsigned short);
14769 vector unsigned char vec_packsu (vector unsigned short,
14770                                  vector unsigned short);
14771 vector unsigned char vec_packsu (vector signed short,
14772                                  vector signed short);
14773 vector unsigned short vec_packsu (vector unsigned int,
14774                                   vector unsigned int);
14775 vector unsigned short vec_packsu (vector signed int, vector signed int);
14777 vector unsigned short vec_vpkswus (vector signed int,
14778                                    vector signed int);
14780 vector unsigned char vec_vpkshus (vector signed short,
14781                                   vector signed short);
14783 vector float vec_perm (vector float,
14784                        vector float,
14785                        vector unsigned char);
14786 vector signed int vec_perm (vector signed int,
14787                             vector signed int,
14788                             vector unsigned char);
14789 vector unsigned int vec_perm (vector unsigned int,
14790                               vector unsigned int,
14791                               vector unsigned char);
14792 vector bool int vec_perm (vector bool int,
14793                           vector bool int,
14794                           vector unsigned char);
14795 vector signed short vec_perm (vector signed short,
14796                               vector signed short,
14797                               vector unsigned char);
14798 vector unsigned short vec_perm (vector unsigned short,
14799                                 vector unsigned short,
14800                                 vector unsigned char);
14801 vector bool short vec_perm (vector bool short,
14802                             vector bool short,
14803                             vector unsigned char);
14804 vector pixel vec_perm (vector pixel,
14805                        vector pixel,
14806                        vector unsigned char);
14807 vector signed char vec_perm (vector signed char,
14808                              vector signed char,
14809                              vector unsigned char);
14810 vector unsigned char vec_perm (vector unsigned char,
14811                                vector unsigned char,
14812                                vector unsigned char);
14813 vector bool char vec_perm (vector bool char,
14814                            vector bool char,
14815                            vector unsigned char);
14817 vector float vec_re (vector float);
14819 vector signed char vec_rl (vector signed char,
14820                            vector unsigned char);
14821 vector unsigned char vec_rl (vector unsigned char,
14822                              vector unsigned char);
14823 vector signed short vec_rl (vector signed short, vector unsigned short);
14824 vector unsigned short vec_rl (vector unsigned short,
14825                               vector unsigned short);
14826 vector signed int vec_rl (vector signed int, vector unsigned int);
14827 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14829 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14830 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14832 vector signed short vec_vrlh (vector signed short,
14833                               vector unsigned short);
14834 vector unsigned short vec_vrlh (vector unsigned short,
14835                                 vector unsigned short);
14837 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14838 vector unsigned char vec_vrlb (vector unsigned char,
14839                                vector unsigned char);
14841 vector float vec_round (vector float);
14843 vector float vec_recip (vector float, vector float);
14845 vector float vec_rsqrt (vector float);
14847 vector float vec_rsqrte (vector float);
14849 vector float vec_sel (vector float, vector float, vector bool int);
14850 vector float vec_sel (vector float, vector float, vector unsigned int);
14851 vector signed int vec_sel (vector signed int,
14852                            vector signed int,
14853                            vector bool int);
14854 vector signed int vec_sel (vector signed int,
14855                            vector signed int,
14856                            vector unsigned int);
14857 vector unsigned int vec_sel (vector unsigned int,
14858                              vector unsigned int,
14859                              vector bool int);
14860 vector unsigned int vec_sel (vector unsigned int,
14861                              vector unsigned int,
14862                              vector unsigned int);
14863 vector bool int vec_sel (vector bool int,
14864                          vector bool int,
14865                          vector bool int);
14866 vector bool int vec_sel (vector bool int,
14867                          vector bool int,
14868                          vector unsigned int);
14869 vector signed short vec_sel (vector signed short,
14870                              vector signed short,
14871                              vector bool short);
14872 vector signed short vec_sel (vector signed short,
14873                              vector signed short,
14874                              vector unsigned short);
14875 vector unsigned short vec_sel (vector unsigned short,
14876                                vector unsigned short,
14877                                vector bool short);
14878 vector unsigned short vec_sel (vector unsigned short,
14879                                vector unsigned short,
14880                                vector unsigned short);
14881 vector bool short vec_sel (vector bool short,
14882                            vector bool short,
14883                            vector bool short);
14884 vector bool short vec_sel (vector bool short,
14885                            vector bool short,
14886                            vector unsigned short);
14887 vector signed char vec_sel (vector signed char,
14888                             vector signed char,
14889                             vector bool char);
14890 vector signed char vec_sel (vector signed char,
14891                             vector signed char,
14892                             vector unsigned char);
14893 vector unsigned char vec_sel (vector unsigned char,
14894                               vector unsigned char,
14895                               vector bool char);
14896 vector unsigned char vec_sel (vector unsigned char,
14897                               vector unsigned char,
14898                               vector unsigned char);
14899 vector bool char vec_sel (vector bool char,
14900                           vector bool char,
14901                           vector bool char);
14902 vector bool char vec_sel (vector bool char,
14903                           vector bool char,
14904                           vector unsigned char);
14906 vector signed char vec_sl (vector signed char,
14907                            vector unsigned char);
14908 vector unsigned char vec_sl (vector unsigned char,
14909                              vector unsigned char);
14910 vector signed short vec_sl (vector signed short, vector unsigned short);
14911 vector unsigned short vec_sl (vector unsigned short,
14912                               vector unsigned short);
14913 vector signed int vec_sl (vector signed int, vector unsigned int);
14914 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14916 vector signed int vec_vslw (vector signed int, vector unsigned int);
14917 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14919 vector signed short vec_vslh (vector signed short,
14920                               vector unsigned short);
14921 vector unsigned short vec_vslh (vector unsigned short,
14922                                 vector unsigned short);
14924 vector signed char vec_vslb (vector signed char, vector unsigned char);
14925 vector unsigned char vec_vslb (vector unsigned char,
14926                                vector unsigned char);
14928 vector float vec_sld (vector float, vector float, const int);
14929 vector signed int vec_sld (vector signed int,
14930                            vector signed int,
14931                            const int);
14932 vector unsigned int vec_sld (vector unsigned int,
14933                              vector unsigned int,
14934                              const int);
14935 vector bool int vec_sld (vector bool int,
14936                          vector bool int,
14937                          const int);
14938 vector signed short vec_sld (vector signed short,
14939                              vector signed short,
14940                              const int);
14941 vector unsigned short vec_sld (vector unsigned short,
14942                                vector unsigned short,
14943                                const int);
14944 vector bool short vec_sld (vector bool short,
14945                            vector bool short,
14946                            const int);
14947 vector pixel vec_sld (vector pixel,
14948                       vector pixel,
14949                       const int);
14950 vector signed char vec_sld (vector signed char,
14951                             vector signed char,
14952                             const int);
14953 vector unsigned char vec_sld (vector unsigned char,
14954                               vector unsigned char,
14955                               const int);
14956 vector bool char vec_sld (vector bool char,
14957                           vector bool char,
14958                           const int);
14960 vector signed int vec_sll (vector signed int,
14961                            vector unsigned int);
14962 vector signed int vec_sll (vector signed int,
14963                            vector unsigned short);
14964 vector signed int vec_sll (vector signed int,
14965                            vector unsigned char);
14966 vector unsigned int vec_sll (vector unsigned int,
14967                              vector unsigned int);
14968 vector unsigned int vec_sll (vector unsigned int,
14969                              vector unsigned short);
14970 vector unsigned int vec_sll (vector unsigned int,
14971                              vector unsigned char);
14972 vector bool int vec_sll (vector bool int,
14973                          vector unsigned int);
14974 vector bool int vec_sll (vector bool int,
14975                          vector unsigned short);
14976 vector bool int vec_sll (vector bool int,
14977                          vector unsigned char);
14978 vector signed short vec_sll (vector signed short,
14979                              vector unsigned int);
14980 vector signed short vec_sll (vector signed short,
14981                              vector unsigned short);
14982 vector signed short vec_sll (vector signed short,
14983                              vector unsigned char);
14984 vector unsigned short vec_sll (vector unsigned short,
14985                                vector unsigned int);
14986 vector unsigned short vec_sll (vector unsigned short,
14987                                vector unsigned short);
14988 vector unsigned short vec_sll (vector unsigned short,
14989                                vector unsigned char);
14990 vector bool short vec_sll (vector bool short, vector unsigned int);
14991 vector bool short vec_sll (vector bool short, vector unsigned short);
14992 vector bool short vec_sll (vector bool short, vector unsigned char);
14993 vector pixel vec_sll (vector pixel, vector unsigned int);
14994 vector pixel vec_sll (vector pixel, vector unsigned short);
14995 vector pixel vec_sll (vector pixel, vector unsigned char);
14996 vector signed char vec_sll (vector signed char, vector unsigned int);
14997 vector signed char vec_sll (vector signed char, vector unsigned short);
14998 vector signed char vec_sll (vector signed char, vector unsigned char);
14999 vector unsigned char vec_sll (vector unsigned char,
15000                               vector unsigned int);
15001 vector unsigned char vec_sll (vector unsigned char,
15002                               vector unsigned short);
15003 vector unsigned char vec_sll (vector unsigned char,
15004                               vector unsigned char);
15005 vector bool char vec_sll (vector bool char, vector unsigned int);
15006 vector bool char vec_sll (vector bool char, vector unsigned short);
15007 vector bool char vec_sll (vector bool char, vector unsigned char);
15009 vector float vec_slo (vector float, vector signed char);
15010 vector float vec_slo (vector float, vector unsigned char);
15011 vector signed int vec_slo (vector signed int, vector signed char);
15012 vector signed int vec_slo (vector signed int, vector unsigned char);
15013 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15014 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15015 vector signed short vec_slo (vector signed short, vector signed char);
15016 vector signed short vec_slo (vector signed short, vector unsigned char);
15017 vector unsigned short vec_slo (vector unsigned short,
15018                                vector signed char);
15019 vector unsigned short vec_slo (vector unsigned short,
15020                                vector unsigned char);
15021 vector pixel vec_slo (vector pixel, vector signed char);
15022 vector pixel vec_slo (vector pixel, vector unsigned char);
15023 vector signed char vec_slo (vector signed char, vector signed char);
15024 vector signed char vec_slo (vector signed char, vector unsigned char);
15025 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15026 vector unsigned char vec_slo (vector unsigned char,
15027                               vector unsigned char);
15029 vector signed char vec_splat (vector signed char, const int);
15030 vector unsigned char vec_splat (vector unsigned char, const int);
15031 vector bool char vec_splat (vector bool char, const int);
15032 vector signed short vec_splat (vector signed short, const int);
15033 vector unsigned short vec_splat (vector unsigned short, const int);
15034 vector bool short vec_splat (vector bool short, const int);
15035 vector pixel vec_splat (vector pixel, const int);
15036 vector float vec_splat (vector float, const int);
15037 vector signed int vec_splat (vector signed int, const int);
15038 vector unsigned int vec_splat (vector unsigned int, const int);
15039 vector bool int vec_splat (vector bool int, const int);
15040 vector signed long vec_splat (vector signed long, const int);
15041 vector unsigned long vec_splat (vector unsigned long, const int);
15043 vector signed char vec_splats (signed char);
15044 vector unsigned char vec_splats (unsigned char);
15045 vector signed short vec_splats (signed short);
15046 vector unsigned short vec_splats (unsigned short);
15047 vector signed int vec_splats (signed int);
15048 vector unsigned int vec_splats (unsigned int);
15049 vector float vec_splats (float);
15051 vector float vec_vspltw (vector float, const int);
15052 vector signed int vec_vspltw (vector signed int, const int);
15053 vector unsigned int vec_vspltw (vector unsigned int, const int);
15054 vector bool int vec_vspltw (vector bool int, const int);
15056 vector bool short vec_vsplth (vector bool short, const int);
15057 vector signed short vec_vsplth (vector signed short, const int);
15058 vector unsigned short vec_vsplth (vector unsigned short, const int);
15059 vector pixel vec_vsplth (vector pixel, const int);
15061 vector signed char vec_vspltb (vector signed char, const int);
15062 vector unsigned char vec_vspltb (vector unsigned char, const int);
15063 vector bool char vec_vspltb (vector bool char, const int);
15065 vector signed char vec_splat_s8 (const int);
15067 vector signed short vec_splat_s16 (const int);
15069 vector signed int vec_splat_s32 (const int);
15071 vector unsigned char vec_splat_u8 (const int);
15073 vector unsigned short vec_splat_u16 (const int);
15075 vector unsigned int vec_splat_u32 (const int);
15077 vector signed char vec_sr (vector signed char, vector unsigned char);
15078 vector unsigned char vec_sr (vector unsigned char,
15079                              vector unsigned char);
15080 vector signed short vec_sr (vector signed short,
15081                             vector unsigned short);
15082 vector unsigned short vec_sr (vector unsigned short,
15083                               vector unsigned short);
15084 vector signed int vec_sr (vector signed int, vector unsigned int);
15085 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15087 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15088 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15090 vector signed short vec_vsrh (vector signed short,
15091                               vector unsigned short);
15092 vector unsigned short vec_vsrh (vector unsigned short,
15093                                 vector unsigned short);
15095 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15096 vector unsigned char vec_vsrb (vector unsigned char,
15097                                vector unsigned char);
15099 vector signed char vec_sra (vector signed char, vector unsigned char);
15100 vector unsigned char vec_sra (vector unsigned char,
15101                               vector unsigned char);
15102 vector signed short vec_sra (vector signed short,
15103                              vector unsigned short);
15104 vector unsigned short vec_sra (vector unsigned short,
15105                                vector unsigned short);
15106 vector signed int vec_sra (vector signed int, vector unsigned int);
15107 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15109 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15110 vector unsigned int vec_vsraw (vector unsigned int,
15111                                vector unsigned int);
15113 vector signed short vec_vsrah (vector signed short,
15114                                vector unsigned short);
15115 vector unsigned short vec_vsrah (vector unsigned short,
15116                                  vector unsigned short);
15118 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15119 vector unsigned char vec_vsrab (vector unsigned char,
15120                                 vector unsigned char);
15122 vector signed int vec_srl (vector signed int, vector unsigned int);
15123 vector signed int vec_srl (vector signed int, vector unsigned short);
15124 vector signed int vec_srl (vector signed int, vector unsigned char);
15125 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15126 vector unsigned int vec_srl (vector unsigned int,
15127                              vector unsigned short);
15128 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15129 vector bool int vec_srl (vector bool int, vector unsigned int);
15130 vector bool int vec_srl (vector bool int, vector unsigned short);
15131 vector bool int vec_srl (vector bool int, vector unsigned char);
15132 vector signed short vec_srl (vector signed short, vector unsigned int);
15133 vector signed short vec_srl (vector signed short,
15134                              vector unsigned short);
15135 vector signed short vec_srl (vector signed short, vector unsigned char);
15136 vector unsigned short vec_srl (vector unsigned short,
15137                                vector unsigned int);
15138 vector unsigned short vec_srl (vector unsigned short,
15139                                vector unsigned short);
15140 vector unsigned short vec_srl (vector unsigned short,
15141                                vector unsigned char);
15142 vector bool short vec_srl (vector bool short, vector unsigned int);
15143 vector bool short vec_srl (vector bool short, vector unsigned short);
15144 vector bool short vec_srl (vector bool short, vector unsigned char);
15145 vector pixel vec_srl (vector pixel, vector unsigned int);
15146 vector pixel vec_srl (vector pixel, vector unsigned short);
15147 vector pixel vec_srl (vector pixel, vector unsigned char);
15148 vector signed char vec_srl (vector signed char, vector unsigned int);
15149 vector signed char vec_srl (vector signed char, vector unsigned short);
15150 vector signed char vec_srl (vector signed char, vector unsigned char);
15151 vector unsigned char vec_srl (vector unsigned char,
15152                               vector unsigned int);
15153 vector unsigned char vec_srl (vector unsigned char,
15154                               vector unsigned short);
15155 vector unsigned char vec_srl (vector unsigned char,
15156                               vector unsigned char);
15157 vector bool char vec_srl (vector bool char, vector unsigned int);
15158 vector bool char vec_srl (vector bool char, vector unsigned short);
15159 vector bool char vec_srl (vector bool char, vector unsigned char);
15161 vector float vec_sro (vector float, vector signed char);
15162 vector float vec_sro (vector float, vector unsigned char);
15163 vector signed int vec_sro (vector signed int, vector signed char);
15164 vector signed int vec_sro (vector signed int, vector unsigned char);
15165 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15166 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15167 vector signed short vec_sro (vector signed short, vector signed char);
15168 vector signed short vec_sro (vector signed short, vector unsigned char);
15169 vector unsigned short vec_sro (vector unsigned short,
15170                                vector signed char);
15171 vector unsigned short vec_sro (vector unsigned short,
15172                                vector unsigned char);
15173 vector pixel vec_sro (vector pixel, vector signed char);
15174 vector pixel vec_sro (vector pixel, vector unsigned char);
15175 vector signed char vec_sro (vector signed char, vector signed char);
15176 vector signed char vec_sro (vector signed char, vector unsigned char);
15177 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15178 vector unsigned char vec_sro (vector unsigned char,
15179                               vector unsigned char);
15181 void vec_st (vector float, int, vector float *);
15182 void vec_st (vector float, int, float *);
15183 void vec_st (vector signed int, int, vector signed int *);
15184 void vec_st (vector signed int, int, int *);
15185 void vec_st (vector unsigned int, int, vector unsigned int *);
15186 void vec_st (vector unsigned int, int, unsigned int *);
15187 void vec_st (vector bool int, int, vector bool int *);
15188 void vec_st (vector bool int, int, unsigned int *);
15189 void vec_st (vector bool int, int, int *);
15190 void vec_st (vector signed short, int, vector signed short *);
15191 void vec_st (vector signed short, int, short *);
15192 void vec_st (vector unsigned short, int, vector unsigned short *);
15193 void vec_st (vector unsigned short, int, unsigned short *);
15194 void vec_st (vector bool short, int, vector bool short *);
15195 void vec_st (vector bool short, int, unsigned short *);
15196 void vec_st (vector pixel, int, vector pixel *);
15197 void vec_st (vector pixel, int, unsigned short *);
15198 void vec_st (vector pixel, int, short *);
15199 void vec_st (vector bool short, int, short *);
15200 void vec_st (vector signed char, int, vector signed char *);
15201 void vec_st (vector signed char, int, signed char *);
15202 void vec_st (vector unsigned char, int, vector unsigned char *);
15203 void vec_st (vector unsigned char, int, unsigned char *);
15204 void vec_st (vector bool char, int, vector bool char *);
15205 void vec_st (vector bool char, int, unsigned char *);
15206 void vec_st (vector bool char, int, signed char *);
15208 void vec_ste (vector signed char, int, signed char *);
15209 void vec_ste (vector unsigned char, int, unsigned char *);
15210 void vec_ste (vector bool char, int, signed char *);
15211 void vec_ste (vector bool char, int, unsigned char *);
15212 void vec_ste (vector signed short, int, short *);
15213 void vec_ste (vector unsigned short, int, unsigned short *);
15214 void vec_ste (vector bool short, int, short *);
15215 void vec_ste (vector bool short, int, unsigned short *);
15216 void vec_ste (vector pixel, int, short *);
15217 void vec_ste (vector pixel, int, unsigned short *);
15218 void vec_ste (vector float, int, float *);
15219 void vec_ste (vector signed int, int, int *);
15220 void vec_ste (vector unsigned int, int, unsigned int *);
15221 void vec_ste (vector bool int, int, int *);
15222 void vec_ste (vector bool int, int, unsigned int *);
15224 void vec_stvewx (vector float, int, float *);
15225 void vec_stvewx (vector signed int, int, int *);
15226 void vec_stvewx (vector unsigned int, int, unsigned int *);
15227 void vec_stvewx (vector bool int, int, int *);
15228 void vec_stvewx (vector bool int, int, unsigned int *);
15230 void vec_stvehx (vector signed short, int, short *);
15231 void vec_stvehx (vector unsigned short, int, unsigned short *);
15232 void vec_stvehx (vector bool short, int, short *);
15233 void vec_stvehx (vector bool short, int, unsigned short *);
15234 void vec_stvehx (vector pixel, int, short *);
15235 void vec_stvehx (vector pixel, int, unsigned short *);
15237 void vec_stvebx (vector signed char, int, signed char *);
15238 void vec_stvebx (vector unsigned char, int, unsigned char *);
15239 void vec_stvebx (vector bool char, int, signed char *);
15240 void vec_stvebx (vector bool char, int, unsigned char *);
15242 void vec_stl (vector float, int, vector float *);
15243 void vec_stl (vector float, int, float *);
15244 void vec_stl (vector signed int, int, vector signed int *);
15245 void vec_stl (vector signed int, int, int *);
15246 void vec_stl (vector unsigned int, int, vector unsigned int *);
15247 void vec_stl (vector unsigned int, int, unsigned int *);
15248 void vec_stl (vector bool int, int, vector bool int *);
15249 void vec_stl (vector bool int, int, unsigned int *);
15250 void vec_stl (vector bool int, int, int *);
15251 void vec_stl (vector signed short, int, vector signed short *);
15252 void vec_stl (vector signed short, int, short *);
15253 void vec_stl (vector unsigned short, int, vector unsigned short *);
15254 void vec_stl (vector unsigned short, int, unsigned short *);
15255 void vec_stl (vector bool short, int, vector bool short *);
15256 void vec_stl (vector bool short, int, unsigned short *);
15257 void vec_stl (vector bool short, int, short *);
15258 void vec_stl (vector pixel, int, vector pixel *);
15259 void vec_stl (vector pixel, int, unsigned short *);
15260 void vec_stl (vector pixel, int, short *);
15261 void vec_stl (vector signed char, int, vector signed char *);
15262 void vec_stl (vector signed char, int, signed char *);
15263 void vec_stl (vector unsigned char, int, vector unsigned char *);
15264 void vec_stl (vector unsigned char, int, unsigned char *);
15265 void vec_stl (vector bool char, int, vector bool char *);
15266 void vec_stl (vector bool char, int, unsigned char *);
15267 void vec_stl (vector bool char, int, signed char *);
15269 vector signed char vec_sub (vector bool char, vector signed char);
15270 vector signed char vec_sub (vector signed char, vector bool char);
15271 vector signed char vec_sub (vector signed char, vector signed char);
15272 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15273 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15274 vector unsigned char vec_sub (vector unsigned char,
15275                               vector unsigned char);
15276 vector signed short vec_sub (vector bool short, vector signed short);
15277 vector signed short vec_sub (vector signed short, vector bool short);
15278 vector signed short vec_sub (vector signed short, vector signed short);
15279 vector unsigned short vec_sub (vector bool short,
15280                                vector unsigned short);
15281 vector unsigned short vec_sub (vector unsigned short,
15282                                vector bool short);
15283 vector unsigned short vec_sub (vector unsigned short,
15284                                vector unsigned short);
15285 vector signed int vec_sub (vector bool int, vector signed int);
15286 vector signed int vec_sub (vector signed int, vector bool int);
15287 vector signed int vec_sub (vector signed int, vector signed int);
15288 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15289 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15290 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15291 vector float vec_sub (vector float, vector float);
15293 vector float vec_vsubfp (vector float, vector float);
15295 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15296 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15297 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15298 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15299 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15300 vector unsigned int vec_vsubuwm (vector unsigned int,
15301                                  vector unsigned int);
15303 vector signed short vec_vsubuhm (vector bool short,
15304                                  vector signed short);
15305 vector signed short vec_vsubuhm (vector signed short,
15306                                  vector bool short);
15307 vector signed short vec_vsubuhm (vector signed short,
15308                                  vector signed short);
15309 vector unsigned short vec_vsubuhm (vector bool short,
15310                                    vector unsigned short);
15311 vector unsigned short vec_vsubuhm (vector unsigned short,
15312                                    vector bool short);
15313 vector unsigned short vec_vsubuhm (vector unsigned short,
15314                                    vector unsigned short);
15316 vector signed char vec_vsububm (vector bool char, vector signed char);
15317 vector signed char vec_vsububm (vector signed char, vector bool char);
15318 vector signed char vec_vsububm (vector signed char, vector signed char);
15319 vector unsigned char vec_vsububm (vector bool char,
15320                                   vector unsigned char);
15321 vector unsigned char vec_vsububm (vector unsigned char,
15322                                   vector bool char);
15323 vector unsigned char vec_vsububm (vector unsigned char,
15324                                   vector unsigned char);
15326 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15328 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15329 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15330 vector unsigned char vec_subs (vector unsigned char,
15331                                vector unsigned char);
15332 vector signed char vec_subs (vector bool char, vector signed char);
15333 vector signed char vec_subs (vector signed char, vector bool char);
15334 vector signed char vec_subs (vector signed char, vector signed char);
15335 vector unsigned short vec_subs (vector bool short,
15336                                 vector unsigned short);
15337 vector unsigned short vec_subs (vector unsigned short,
15338                                 vector bool short);
15339 vector unsigned short vec_subs (vector unsigned short,
15340                                 vector unsigned short);
15341 vector signed short vec_subs (vector bool short, vector signed short);
15342 vector signed short vec_subs (vector signed short, vector bool short);
15343 vector signed short vec_subs (vector signed short, vector signed short);
15344 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15345 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15346 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15347 vector signed int vec_subs (vector bool int, vector signed int);
15348 vector signed int vec_subs (vector signed int, vector bool int);
15349 vector signed int vec_subs (vector signed int, vector signed int);
15351 vector signed int vec_vsubsws (vector bool int, vector signed int);
15352 vector signed int vec_vsubsws (vector signed int, vector bool int);
15353 vector signed int vec_vsubsws (vector signed int, vector signed int);
15355 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15356 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15357 vector unsigned int vec_vsubuws (vector unsigned int,
15358                                  vector unsigned int);
15360 vector signed short vec_vsubshs (vector bool short,
15361                                  vector signed short);
15362 vector signed short vec_vsubshs (vector signed short,
15363                                  vector bool short);
15364 vector signed short vec_vsubshs (vector signed short,
15365                                  vector signed short);
15367 vector unsigned short vec_vsubuhs (vector bool short,
15368                                    vector unsigned short);
15369 vector unsigned short vec_vsubuhs (vector unsigned short,
15370                                    vector bool short);
15371 vector unsigned short vec_vsubuhs (vector unsigned short,
15372                                    vector unsigned short);
15374 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15375 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15376 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15378 vector unsigned char vec_vsububs (vector bool char,
15379                                   vector unsigned char);
15380 vector unsigned char vec_vsububs (vector unsigned char,
15381                                   vector bool char);
15382 vector unsigned char vec_vsububs (vector unsigned char,
15383                                   vector unsigned char);
15385 vector unsigned int vec_sum4s (vector unsigned char,
15386                                vector unsigned int);
15387 vector signed int vec_sum4s (vector signed char, vector signed int);
15388 vector signed int vec_sum4s (vector signed short, vector signed int);
15390 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15392 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15394 vector unsigned int vec_vsum4ubs (vector unsigned char,
15395                                   vector unsigned int);
15397 vector signed int vec_sum2s (vector signed int, vector signed int);
15399 vector signed int vec_sums (vector signed int, vector signed int);
15401 vector float vec_trunc (vector float);
15403 vector signed short vec_unpackh (vector signed char);
15404 vector bool short vec_unpackh (vector bool char);
15405 vector signed int vec_unpackh (vector signed short);
15406 vector bool int vec_unpackh (vector bool short);
15407 vector unsigned int vec_unpackh (vector pixel);
15409 vector bool int vec_vupkhsh (vector bool short);
15410 vector signed int vec_vupkhsh (vector signed short);
15412 vector unsigned int vec_vupkhpx (vector pixel);
15414 vector bool short vec_vupkhsb (vector bool char);
15415 vector signed short vec_vupkhsb (vector signed char);
15417 vector signed short vec_unpackl (vector signed char);
15418 vector bool short vec_unpackl (vector bool char);
15419 vector unsigned int vec_unpackl (vector pixel);
15420 vector signed int vec_unpackl (vector signed short);
15421 vector bool int vec_unpackl (vector bool short);
15423 vector unsigned int vec_vupklpx (vector pixel);
15425 vector bool int vec_vupklsh (vector bool short);
15426 vector signed int vec_vupklsh (vector signed short);
15428 vector bool short vec_vupklsb (vector bool char);
15429 vector signed short vec_vupklsb (vector signed char);
15431 vector float vec_xor (vector float, vector float);
15432 vector float vec_xor (vector float, vector bool int);
15433 vector float vec_xor (vector bool int, vector float);
15434 vector bool int vec_xor (vector bool int, vector bool int);
15435 vector signed int vec_xor (vector bool int, vector signed int);
15436 vector signed int vec_xor (vector signed int, vector bool int);
15437 vector signed int vec_xor (vector signed int, vector signed int);
15438 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15439 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15440 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15441 vector bool short vec_xor (vector bool short, vector bool short);
15442 vector signed short vec_xor (vector bool short, vector signed short);
15443 vector signed short vec_xor (vector signed short, vector bool short);
15444 vector signed short vec_xor (vector signed short, vector signed short);
15445 vector unsigned short vec_xor (vector bool short,
15446                                vector unsigned short);
15447 vector unsigned short vec_xor (vector unsigned short,
15448                                vector bool short);
15449 vector unsigned short vec_xor (vector unsigned short,
15450                                vector unsigned short);
15451 vector signed char vec_xor (vector bool char, vector signed char);
15452 vector bool char vec_xor (vector bool char, vector bool char);
15453 vector signed char vec_xor (vector signed char, vector bool char);
15454 vector signed char vec_xor (vector signed char, vector signed char);
15455 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15456 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15457 vector unsigned char vec_xor (vector unsigned char,
15458                               vector unsigned char);
15460 int vec_all_eq (vector signed char, vector bool char);
15461 int vec_all_eq (vector signed char, vector signed char);
15462 int vec_all_eq (vector unsigned char, vector bool char);
15463 int vec_all_eq (vector unsigned char, vector unsigned char);
15464 int vec_all_eq (vector bool char, vector bool char);
15465 int vec_all_eq (vector bool char, vector unsigned char);
15466 int vec_all_eq (vector bool char, vector signed char);
15467 int vec_all_eq (vector signed short, vector bool short);
15468 int vec_all_eq (vector signed short, vector signed short);
15469 int vec_all_eq (vector unsigned short, vector bool short);
15470 int vec_all_eq (vector unsigned short, vector unsigned short);
15471 int vec_all_eq (vector bool short, vector bool short);
15472 int vec_all_eq (vector bool short, vector unsigned short);
15473 int vec_all_eq (vector bool short, vector signed short);
15474 int vec_all_eq (vector pixel, vector pixel);
15475 int vec_all_eq (vector signed int, vector bool int);
15476 int vec_all_eq (vector signed int, vector signed int);
15477 int vec_all_eq (vector unsigned int, vector bool int);
15478 int vec_all_eq (vector unsigned int, vector unsigned int);
15479 int vec_all_eq (vector bool int, vector bool int);
15480 int vec_all_eq (vector bool int, vector unsigned int);
15481 int vec_all_eq (vector bool int, vector signed int);
15482 int vec_all_eq (vector float, vector float);
15484 int vec_all_ge (vector bool char, vector unsigned char);
15485 int vec_all_ge (vector unsigned char, vector bool char);
15486 int vec_all_ge (vector unsigned char, vector unsigned char);
15487 int vec_all_ge (vector bool char, vector signed char);
15488 int vec_all_ge (vector signed char, vector bool char);
15489 int vec_all_ge (vector signed char, vector signed char);
15490 int vec_all_ge (vector bool short, vector unsigned short);
15491 int vec_all_ge (vector unsigned short, vector bool short);
15492 int vec_all_ge (vector unsigned short, vector unsigned short);
15493 int vec_all_ge (vector signed short, vector signed short);
15494 int vec_all_ge (vector bool short, vector signed short);
15495 int vec_all_ge (vector signed short, vector bool short);
15496 int vec_all_ge (vector bool int, vector unsigned int);
15497 int vec_all_ge (vector unsigned int, vector bool int);
15498 int vec_all_ge (vector unsigned int, vector unsigned int);
15499 int vec_all_ge (vector bool int, vector signed int);
15500 int vec_all_ge (vector signed int, vector bool int);
15501 int vec_all_ge (vector signed int, vector signed int);
15502 int vec_all_ge (vector float, vector float);
15504 int vec_all_gt (vector bool char, vector unsigned char);
15505 int vec_all_gt (vector unsigned char, vector bool char);
15506 int vec_all_gt (vector unsigned char, vector unsigned char);
15507 int vec_all_gt (vector bool char, vector signed char);
15508 int vec_all_gt (vector signed char, vector bool char);
15509 int vec_all_gt (vector signed char, vector signed char);
15510 int vec_all_gt (vector bool short, vector unsigned short);
15511 int vec_all_gt (vector unsigned short, vector bool short);
15512 int vec_all_gt (vector unsigned short, vector unsigned short);
15513 int vec_all_gt (vector bool short, vector signed short);
15514 int vec_all_gt (vector signed short, vector bool short);
15515 int vec_all_gt (vector signed short, vector signed short);
15516 int vec_all_gt (vector bool int, vector unsigned int);
15517 int vec_all_gt (vector unsigned int, vector bool int);
15518 int vec_all_gt (vector unsigned int, vector unsigned int);
15519 int vec_all_gt (vector bool int, vector signed int);
15520 int vec_all_gt (vector signed int, vector bool int);
15521 int vec_all_gt (vector signed int, vector signed int);
15522 int vec_all_gt (vector float, vector float);
15524 int vec_all_in (vector float, vector float);
15526 int vec_all_le (vector bool char, vector unsigned char);
15527 int vec_all_le (vector unsigned char, vector bool char);
15528 int vec_all_le (vector unsigned char, vector unsigned char);
15529 int vec_all_le (vector bool char, vector signed char);
15530 int vec_all_le (vector signed char, vector bool char);
15531 int vec_all_le (vector signed char, vector signed char);
15532 int vec_all_le (vector bool short, vector unsigned short);
15533 int vec_all_le (vector unsigned short, vector bool short);
15534 int vec_all_le (vector unsigned short, vector unsigned short);
15535 int vec_all_le (vector bool short, vector signed short);
15536 int vec_all_le (vector signed short, vector bool short);
15537 int vec_all_le (vector signed short, vector signed short);
15538 int vec_all_le (vector bool int, vector unsigned int);
15539 int vec_all_le (vector unsigned int, vector bool int);
15540 int vec_all_le (vector unsigned int, vector unsigned int);
15541 int vec_all_le (vector bool int, vector signed int);
15542 int vec_all_le (vector signed int, vector bool int);
15543 int vec_all_le (vector signed int, vector signed int);
15544 int vec_all_le (vector float, vector float);
15546 int vec_all_lt (vector bool char, vector unsigned char);
15547 int vec_all_lt (vector unsigned char, vector bool char);
15548 int vec_all_lt (vector unsigned char, vector unsigned char);
15549 int vec_all_lt (vector bool char, vector signed char);
15550 int vec_all_lt (vector signed char, vector bool char);
15551 int vec_all_lt (vector signed char, vector signed char);
15552 int vec_all_lt (vector bool short, vector unsigned short);
15553 int vec_all_lt (vector unsigned short, vector bool short);
15554 int vec_all_lt (vector unsigned short, vector unsigned short);
15555 int vec_all_lt (vector bool short, vector signed short);
15556 int vec_all_lt (vector signed short, vector bool short);
15557 int vec_all_lt (vector signed short, vector signed short);
15558 int vec_all_lt (vector bool int, vector unsigned int);
15559 int vec_all_lt (vector unsigned int, vector bool int);
15560 int vec_all_lt (vector unsigned int, vector unsigned int);
15561 int vec_all_lt (vector bool int, vector signed int);
15562 int vec_all_lt (vector signed int, vector bool int);
15563 int vec_all_lt (vector signed int, vector signed int);
15564 int vec_all_lt (vector float, vector float);
15566 int vec_all_nan (vector float);
15568 int vec_all_ne (vector signed char, vector bool char);
15569 int vec_all_ne (vector signed char, vector signed char);
15570 int vec_all_ne (vector unsigned char, vector bool char);
15571 int vec_all_ne (vector unsigned char, vector unsigned char);
15572 int vec_all_ne (vector bool char, vector bool char);
15573 int vec_all_ne (vector bool char, vector unsigned char);
15574 int vec_all_ne (vector bool char, vector signed char);
15575 int vec_all_ne (vector signed short, vector bool short);
15576 int vec_all_ne (vector signed short, vector signed short);
15577 int vec_all_ne (vector unsigned short, vector bool short);
15578 int vec_all_ne (vector unsigned short, vector unsigned short);
15579 int vec_all_ne (vector bool short, vector bool short);
15580 int vec_all_ne (vector bool short, vector unsigned short);
15581 int vec_all_ne (vector bool short, vector signed short);
15582 int vec_all_ne (vector pixel, vector pixel);
15583 int vec_all_ne (vector signed int, vector bool int);
15584 int vec_all_ne (vector signed int, vector signed int);
15585 int vec_all_ne (vector unsigned int, vector bool int);
15586 int vec_all_ne (vector unsigned int, vector unsigned int);
15587 int vec_all_ne (vector bool int, vector bool int);
15588 int vec_all_ne (vector bool int, vector unsigned int);
15589 int vec_all_ne (vector bool int, vector signed int);
15590 int vec_all_ne (vector float, vector float);
15592 int vec_all_nge (vector float, vector float);
15594 int vec_all_ngt (vector float, vector float);
15596 int vec_all_nle (vector float, vector float);
15598 int vec_all_nlt (vector float, vector float);
15600 int vec_all_numeric (vector float);
15602 int vec_any_eq (vector signed char, vector bool char);
15603 int vec_any_eq (vector signed char, vector signed char);
15604 int vec_any_eq (vector unsigned char, vector bool char);
15605 int vec_any_eq (vector unsigned char, vector unsigned char);
15606 int vec_any_eq (vector bool char, vector bool char);
15607 int vec_any_eq (vector bool char, vector unsigned char);
15608 int vec_any_eq (vector bool char, vector signed char);
15609 int vec_any_eq (vector signed short, vector bool short);
15610 int vec_any_eq (vector signed short, vector signed short);
15611 int vec_any_eq (vector unsigned short, vector bool short);
15612 int vec_any_eq (vector unsigned short, vector unsigned short);
15613 int vec_any_eq (vector bool short, vector bool short);
15614 int vec_any_eq (vector bool short, vector unsigned short);
15615 int vec_any_eq (vector bool short, vector signed short);
15616 int vec_any_eq (vector pixel, vector pixel);
15617 int vec_any_eq (vector signed int, vector bool int);
15618 int vec_any_eq (vector signed int, vector signed int);
15619 int vec_any_eq (vector unsigned int, vector bool int);
15620 int vec_any_eq (vector unsigned int, vector unsigned int);
15621 int vec_any_eq (vector bool int, vector bool int);
15622 int vec_any_eq (vector bool int, vector unsigned int);
15623 int vec_any_eq (vector bool int, vector signed int);
15624 int vec_any_eq (vector float, vector float);
15626 int vec_any_ge (vector signed char, vector bool char);
15627 int vec_any_ge (vector unsigned char, vector bool char);
15628 int vec_any_ge (vector unsigned char, vector unsigned char);
15629 int vec_any_ge (vector signed char, vector signed char);
15630 int vec_any_ge (vector bool char, vector unsigned char);
15631 int vec_any_ge (vector bool char, vector signed char);
15632 int vec_any_ge (vector unsigned short, vector bool short);
15633 int vec_any_ge (vector unsigned short, vector unsigned short);
15634 int vec_any_ge (vector signed short, vector signed short);
15635 int vec_any_ge (vector signed short, vector bool short);
15636 int vec_any_ge (vector bool short, vector unsigned short);
15637 int vec_any_ge (vector bool short, vector signed short);
15638 int vec_any_ge (vector signed int, vector bool int);
15639 int vec_any_ge (vector unsigned int, vector bool int);
15640 int vec_any_ge (vector unsigned int, vector unsigned int);
15641 int vec_any_ge (vector signed int, vector signed int);
15642 int vec_any_ge (vector bool int, vector unsigned int);
15643 int vec_any_ge (vector bool int, vector signed int);
15644 int vec_any_ge (vector float, vector float);
15646 int vec_any_gt (vector bool char, vector unsigned char);
15647 int vec_any_gt (vector unsigned char, vector bool char);
15648 int vec_any_gt (vector unsigned char, vector unsigned char);
15649 int vec_any_gt (vector bool char, vector signed char);
15650 int vec_any_gt (vector signed char, vector bool char);
15651 int vec_any_gt (vector signed char, vector signed char);
15652 int vec_any_gt (vector bool short, vector unsigned short);
15653 int vec_any_gt (vector unsigned short, vector bool short);
15654 int vec_any_gt (vector unsigned short, vector unsigned short);
15655 int vec_any_gt (vector bool short, vector signed short);
15656 int vec_any_gt (vector signed short, vector bool short);
15657 int vec_any_gt (vector signed short, vector signed short);
15658 int vec_any_gt (vector bool int, vector unsigned int);
15659 int vec_any_gt (vector unsigned int, vector bool int);
15660 int vec_any_gt (vector unsigned int, vector unsigned int);
15661 int vec_any_gt (vector bool int, vector signed int);
15662 int vec_any_gt (vector signed int, vector bool int);
15663 int vec_any_gt (vector signed int, vector signed int);
15664 int vec_any_gt (vector float, vector float);
15666 int vec_any_le (vector bool char, vector unsigned char);
15667 int vec_any_le (vector unsigned char, vector bool char);
15668 int vec_any_le (vector unsigned char, vector unsigned char);
15669 int vec_any_le (vector bool char, vector signed char);
15670 int vec_any_le (vector signed char, vector bool char);
15671 int vec_any_le (vector signed char, vector signed char);
15672 int vec_any_le (vector bool short, vector unsigned short);
15673 int vec_any_le (vector unsigned short, vector bool short);
15674 int vec_any_le (vector unsigned short, vector unsigned short);
15675 int vec_any_le (vector bool short, vector signed short);
15676 int vec_any_le (vector signed short, vector bool short);
15677 int vec_any_le (vector signed short, vector signed short);
15678 int vec_any_le (vector bool int, vector unsigned int);
15679 int vec_any_le (vector unsigned int, vector bool int);
15680 int vec_any_le (vector unsigned int, vector unsigned int);
15681 int vec_any_le (vector bool int, vector signed int);
15682 int vec_any_le (vector signed int, vector bool int);
15683 int vec_any_le (vector signed int, vector signed int);
15684 int vec_any_le (vector float, vector float);
15686 int vec_any_lt (vector bool char, vector unsigned char);
15687 int vec_any_lt (vector unsigned char, vector bool char);
15688 int vec_any_lt (vector unsigned char, vector unsigned char);
15689 int vec_any_lt (vector bool char, vector signed char);
15690 int vec_any_lt (vector signed char, vector bool char);
15691 int vec_any_lt (vector signed char, vector signed char);
15692 int vec_any_lt (vector bool short, vector unsigned short);
15693 int vec_any_lt (vector unsigned short, vector bool short);
15694 int vec_any_lt (vector unsigned short, vector unsigned short);
15695 int vec_any_lt (vector bool short, vector signed short);
15696 int vec_any_lt (vector signed short, vector bool short);
15697 int vec_any_lt (vector signed short, vector signed short);
15698 int vec_any_lt (vector bool int, vector unsigned int);
15699 int vec_any_lt (vector unsigned int, vector bool int);
15700 int vec_any_lt (vector unsigned int, vector unsigned int);
15701 int vec_any_lt (vector bool int, vector signed int);
15702 int vec_any_lt (vector signed int, vector bool int);
15703 int vec_any_lt (vector signed int, vector signed int);
15704 int vec_any_lt (vector float, vector float);
15706 int vec_any_nan (vector float);
15708 int vec_any_ne (vector signed char, vector bool char);
15709 int vec_any_ne (vector signed char, vector signed char);
15710 int vec_any_ne (vector unsigned char, vector bool char);
15711 int vec_any_ne (vector unsigned char, vector unsigned char);
15712 int vec_any_ne (vector bool char, vector bool char);
15713 int vec_any_ne (vector bool char, vector unsigned char);
15714 int vec_any_ne (vector bool char, vector signed char);
15715 int vec_any_ne (vector signed short, vector bool short);
15716 int vec_any_ne (vector signed short, vector signed short);
15717 int vec_any_ne (vector unsigned short, vector bool short);
15718 int vec_any_ne (vector unsigned short, vector unsigned short);
15719 int vec_any_ne (vector bool short, vector bool short);
15720 int vec_any_ne (vector bool short, vector unsigned short);
15721 int vec_any_ne (vector bool short, vector signed short);
15722 int vec_any_ne (vector pixel, vector pixel);
15723 int vec_any_ne (vector signed int, vector bool int);
15724 int vec_any_ne (vector signed int, vector signed int);
15725 int vec_any_ne (vector unsigned int, vector bool int);
15726 int vec_any_ne (vector unsigned int, vector unsigned int);
15727 int vec_any_ne (vector bool int, vector bool int);
15728 int vec_any_ne (vector bool int, vector unsigned int);
15729 int vec_any_ne (vector bool int, vector signed int);
15730 int vec_any_ne (vector float, vector float);
15732 int vec_any_nge (vector float, vector float);
15734 int vec_any_ngt (vector float, vector float);
15736 int vec_any_nle (vector float, vector float);
15738 int vec_any_nlt (vector float, vector float);
15740 int vec_any_numeric (vector float);
15742 int vec_any_out (vector float, vector float);
15743 @end smallexample
15745 If the vector/scalar (VSX) instruction set is available, the following
15746 additional functions are available:
15748 @smallexample
15749 vector double vec_abs (vector double);
15750 vector double vec_add (vector double, vector double);
15751 vector double vec_and (vector double, vector double);
15752 vector double vec_and (vector double, vector bool long);
15753 vector double vec_and (vector bool long, vector double);
15754 vector long vec_and (vector long, vector long);
15755 vector long vec_and (vector long, vector bool long);
15756 vector long vec_and (vector bool long, vector long);
15757 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15758 vector unsigned long vec_and (vector unsigned long, vector bool long);
15759 vector unsigned long vec_and (vector bool long, vector unsigned long);
15760 vector double vec_andc (vector double, vector double);
15761 vector double vec_andc (vector double, vector bool long);
15762 vector double vec_andc (vector bool long, vector double);
15763 vector long vec_andc (vector long, vector long);
15764 vector long vec_andc (vector long, vector bool long);
15765 vector long vec_andc (vector bool long, vector long);
15766 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15767 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15768 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15769 vector double vec_ceil (vector double);
15770 vector bool long vec_cmpeq (vector double, vector double);
15771 vector bool long vec_cmpge (vector double, vector double);
15772 vector bool long vec_cmpgt (vector double, vector double);
15773 vector bool long vec_cmple (vector double, vector double);
15774 vector bool long vec_cmplt (vector double, vector double);
15775 vector double vec_cpsgn (vector double, vector double);
15776 vector float vec_div (vector float, vector float);
15777 vector double vec_div (vector double, vector double);
15778 vector long vec_div (vector long, vector long);
15779 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15780 vector double vec_floor (vector double);
15781 vector double vec_ld (int, const vector double *);
15782 vector double vec_ld (int, const double *);
15783 vector double vec_ldl (int, const vector double *);
15784 vector double vec_ldl (int, const double *);
15785 vector unsigned char vec_lvsl (int, const volatile double *);
15786 vector unsigned char vec_lvsr (int, const volatile double *);
15787 vector double vec_madd (vector double, vector double, vector double);
15788 vector double vec_max (vector double, vector double);
15789 vector signed long vec_mergeh (vector signed long, vector signed long);
15790 vector signed long vec_mergeh (vector signed long, vector bool long);
15791 vector signed long vec_mergeh (vector bool long, vector signed long);
15792 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15793 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15794 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15795 vector signed long vec_mergel (vector signed long, vector signed long);
15796 vector signed long vec_mergel (vector signed long, vector bool long);
15797 vector signed long vec_mergel (vector bool long, vector signed long);
15798 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15799 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15800 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15801 vector double vec_min (vector double, vector double);
15802 vector float vec_msub (vector float, vector float, vector float);
15803 vector double vec_msub (vector double, vector double, vector double);
15804 vector float vec_mul (vector float, vector float);
15805 vector double vec_mul (vector double, vector double);
15806 vector long vec_mul (vector long, vector long);
15807 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15808 vector float vec_nearbyint (vector float);
15809 vector double vec_nearbyint (vector double);
15810 vector float vec_nmadd (vector float, vector float, vector float);
15811 vector double vec_nmadd (vector double, vector double, vector double);
15812 vector double vec_nmsub (vector double, vector double, vector double);
15813 vector double vec_nor (vector double, vector double);
15814 vector long vec_nor (vector long, vector long);
15815 vector long vec_nor (vector long, vector bool long);
15816 vector long vec_nor (vector bool long, vector long);
15817 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15818 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15819 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15820 vector double vec_or (vector double, vector double);
15821 vector double vec_or (vector double, vector bool long);
15822 vector double vec_or (vector bool long, vector double);
15823 vector long vec_or (vector long, vector long);
15824 vector long vec_or (vector long, vector bool long);
15825 vector long vec_or (vector bool long, vector long);
15826 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15827 vector unsigned long vec_or (vector unsigned long, vector bool long);
15828 vector unsigned long vec_or (vector bool long, vector unsigned long);
15829 vector double vec_perm (vector double, vector double, vector unsigned char);
15830 vector long vec_perm (vector long, vector long, vector unsigned char);
15831 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15832                                vector unsigned char);
15833 vector double vec_rint (vector double);
15834 vector double vec_recip (vector double, vector double);
15835 vector double vec_rsqrt (vector double);
15836 vector double vec_rsqrte (vector double);
15837 vector double vec_sel (vector double, vector double, vector bool long);
15838 vector double vec_sel (vector double, vector double, vector unsigned long);
15839 vector long vec_sel (vector long, vector long, vector long);
15840 vector long vec_sel (vector long, vector long, vector unsigned long);
15841 vector long vec_sel (vector long, vector long, vector bool long);
15842 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15843                               vector long);
15844 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15845                               vector unsigned long);
15846 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15847                               vector bool long);
15848 vector double vec_splats (double);
15849 vector signed long vec_splats (signed long);
15850 vector unsigned long vec_splats (unsigned long);
15851 vector float vec_sqrt (vector float);
15852 vector double vec_sqrt (vector double);
15853 void vec_st (vector double, int, vector double *);
15854 void vec_st (vector double, int, double *);
15855 vector double vec_sub (vector double, vector double);
15856 vector double vec_trunc (vector double);
15857 vector double vec_xor (vector double, vector double);
15858 vector double vec_xor (vector double, vector bool long);
15859 vector double vec_xor (vector bool long, vector double);
15860 vector long vec_xor (vector long, vector long);
15861 vector long vec_xor (vector long, vector bool long);
15862 vector long vec_xor (vector bool long, vector long);
15863 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15864 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15865 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15866 int vec_all_eq (vector double, vector double);
15867 int vec_all_ge (vector double, vector double);
15868 int vec_all_gt (vector double, vector double);
15869 int vec_all_le (vector double, vector double);
15870 int vec_all_lt (vector double, vector double);
15871 int vec_all_nan (vector double);
15872 int vec_all_ne (vector double, vector double);
15873 int vec_all_nge (vector double, vector double);
15874 int vec_all_ngt (vector double, vector double);
15875 int vec_all_nle (vector double, vector double);
15876 int vec_all_nlt (vector double, vector double);
15877 int vec_all_numeric (vector double);
15878 int vec_any_eq (vector double, vector double);
15879 int vec_any_ge (vector double, vector double);
15880 int vec_any_gt (vector double, vector double);
15881 int vec_any_le (vector double, vector double);
15882 int vec_any_lt (vector double, vector double);
15883 int vec_any_nan (vector double);
15884 int vec_any_ne (vector double, vector double);
15885 int vec_any_nge (vector double, vector double);
15886 int vec_any_ngt (vector double, vector double);
15887 int vec_any_nle (vector double, vector double);
15888 int vec_any_nlt (vector double, vector double);
15889 int vec_any_numeric (vector double);
15891 vector double vec_vsx_ld (int, const vector double *);
15892 vector double vec_vsx_ld (int, const double *);
15893 vector float vec_vsx_ld (int, const vector float *);
15894 vector float vec_vsx_ld (int, const float *);
15895 vector bool int vec_vsx_ld (int, const vector bool int *);
15896 vector signed int vec_vsx_ld (int, const vector signed int *);
15897 vector signed int vec_vsx_ld (int, const int *);
15898 vector signed int vec_vsx_ld (int, const long *);
15899 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15900 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15901 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15902 vector bool short vec_vsx_ld (int, const vector bool short *);
15903 vector pixel vec_vsx_ld (int, const vector pixel *);
15904 vector signed short vec_vsx_ld (int, const vector signed short *);
15905 vector signed short vec_vsx_ld (int, const short *);
15906 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15907 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15908 vector bool char vec_vsx_ld (int, const vector bool char *);
15909 vector signed char vec_vsx_ld (int, const vector signed char *);
15910 vector signed char vec_vsx_ld (int, const signed char *);
15911 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15912 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15914 void vec_vsx_st (vector double, int, vector double *);
15915 void vec_vsx_st (vector double, int, double *);
15916 void vec_vsx_st (vector float, int, vector float *);
15917 void vec_vsx_st (vector float, int, float *);
15918 void vec_vsx_st (vector signed int, int, vector signed int *);
15919 void vec_vsx_st (vector signed int, int, int *);
15920 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15921 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15922 void vec_vsx_st (vector bool int, int, vector bool int *);
15923 void vec_vsx_st (vector bool int, int, unsigned int *);
15924 void vec_vsx_st (vector bool int, int, int *);
15925 void vec_vsx_st (vector signed short, int, vector signed short *);
15926 void vec_vsx_st (vector signed short, int, short *);
15927 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15928 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15929 void vec_vsx_st (vector bool short, int, vector bool short *);
15930 void vec_vsx_st (vector bool short, int, unsigned short *);
15931 void vec_vsx_st (vector pixel, int, vector pixel *);
15932 void vec_vsx_st (vector pixel, int, unsigned short *);
15933 void vec_vsx_st (vector pixel, int, short *);
15934 void vec_vsx_st (vector bool short, int, short *);
15935 void vec_vsx_st (vector signed char, int, vector signed char *);
15936 void vec_vsx_st (vector signed char, int, signed char *);
15937 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15938 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15939 void vec_vsx_st (vector bool char, int, vector bool char *);
15940 void vec_vsx_st (vector bool char, int, unsigned char *);
15941 void vec_vsx_st (vector bool char, int, signed char *);
15943 vector double vec_xxpermdi (vector double, vector double, int);
15944 vector float vec_xxpermdi (vector float, vector float, int);
15945 vector long long vec_xxpermdi (vector long long, vector long long, int);
15946 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15947                                         vector unsigned long long, int);
15948 vector int vec_xxpermdi (vector int, vector int, int);
15949 vector unsigned int vec_xxpermdi (vector unsigned int,
15950                                   vector unsigned int, int);
15951 vector short vec_xxpermdi (vector short, vector short, int);
15952 vector unsigned short vec_xxpermdi (vector unsigned short,
15953                                     vector unsigned short, int);
15954 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15955 vector unsigned char vec_xxpermdi (vector unsigned char,
15956                                    vector unsigned char, int);
15958 vector double vec_xxsldi (vector double, vector double, int);
15959 vector float vec_xxsldi (vector float, vector float, int);
15960 vector long long vec_xxsldi (vector long long, vector long long, int);
15961 vector unsigned long long vec_xxsldi (vector unsigned long long,
15962                                       vector unsigned long long, int);
15963 vector int vec_xxsldi (vector int, vector int, int);
15964 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15965 vector short vec_xxsldi (vector short, vector short, int);
15966 vector unsigned short vec_xxsldi (vector unsigned short,
15967                                   vector unsigned short, int);
15968 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15969 vector unsigned char vec_xxsldi (vector unsigned char,
15970                                  vector unsigned char, int);
15971 @end smallexample
15973 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15974 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15975 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15976 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15977 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15979 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15980 instruction set is available, the following additional functions are
15981 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15982 can use @var{vector long} instead of @var{vector long long},
15983 @var{vector bool long} instead of @var{vector bool long long}, and
15984 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15986 @smallexample
15987 vector long long vec_abs (vector long long);
15989 vector long long vec_add (vector long long, vector long long);
15990 vector unsigned long long vec_add (vector unsigned long long,
15991                                    vector unsigned long long);
15993 int vec_all_eq (vector long long, vector long long);
15994 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15995 int vec_all_ge (vector long long, vector long long);
15996 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15997 int vec_all_gt (vector long long, vector long long);
15998 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15999 int vec_all_le (vector long long, vector long long);
16000 int vec_all_le (vector unsigned long long, vector unsigned long long);
16001 int vec_all_lt (vector long long, vector long long);
16002 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16003 int vec_all_ne (vector long long, vector long long);
16004 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16006 int vec_any_eq (vector long long, vector long long);
16007 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16008 int vec_any_ge (vector long long, vector long long);
16009 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16010 int vec_any_gt (vector long long, vector long long);
16011 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16012 int vec_any_le (vector long long, vector long long);
16013 int vec_any_le (vector unsigned long long, vector unsigned long long);
16014 int vec_any_lt (vector long long, vector long long);
16015 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16016 int vec_any_ne (vector long long, vector long long);
16017 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16019 vector long long vec_eqv (vector long long, vector long long);
16020 vector long long vec_eqv (vector bool long long, vector long long);
16021 vector long long vec_eqv (vector long long, vector bool long long);
16022 vector unsigned long long vec_eqv (vector unsigned long long,
16023                                    vector unsigned long long);
16024 vector unsigned long long vec_eqv (vector bool long long,
16025                                    vector unsigned long long);
16026 vector unsigned long long vec_eqv (vector unsigned long long,
16027                                    vector bool long long);
16028 vector int vec_eqv (vector int, vector int);
16029 vector int vec_eqv (vector bool int, vector int);
16030 vector int vec_eqv (vector int, vector bool int);
16031 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16032 vector unsigned int vec_eqv (vector bool unsigned int,
16033                              vector unsigned int);
16034 vector unsigned int vec_eqv (vector unsigned int,
16035                              vector bool unsigned int);
16036 vector short vec_eqv (vector short, vector short);
16037 vector short vec_eqv (vector bool short, vector short);
16038 vector short vec_eqv (vector short, vector bool short);
16039 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16040 vector unsigned short vec_eqv (vector bool unsigned short,
16041                                vector unsigned short);
16042 vector unsigned short vec_eqv (vector unsigned short,
16043                                vector bool unsigned short);
16044 vector signed char vec_eqv (vector signed char, vector signed char);
16045 vector signed char vec_eqv (vector bool signed char, vector signed char);
16046 vector signed char vec_eqv (vector signed char, vector bool signed char);
16047 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16048 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16049 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16051 vector long long vec_max (vector long long, vector long long);
16052 vector unsigned long long vec_max (vector unsigned long long,
16053                                    vector unsigned long long);
16055 vector signed int vec_mergee (vector signed int, vector signed int);
16056 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16057 vector bool int vec_mergee (vector bool int, vector bool int);
16059 vector signed int vec_mergeo (vector signed int, vector signed int);
16060 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16061 vector bool int vec_mergeo (vector bool int, vector bool int);
16063 vector long long vec_min (vector long long, vector long long);
16064 vector unsigned long long vec_min (vector unsigned long long,
16065                                    vector unsigned long long);
16067 vector long long vec_nand (vector long long, vector long long);
16068 vector long long vec_nand (vector bool long long, vector long long);
16069 vector long long vec_nand (vector long long, vector bool long long);
16070 vector unsigned long long vec_nand (vector unsigned long long,
16071                                     vector unsigned long long);
16072 vector unsigned long long vec_nand (vector bool long long,
16073                                    vector unsigned long long);
16074 vector unsigned long long vec_nand (vector unsigned long long,
16075                                     vector bool long long);
16076 vector int vec_nand (vector int, vector int);
16077 vector int vec_nand (vector bool int, vector int);
16078 vector int vec_nand (vector int, vector bool int);
16079 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16080 vector unsigned int vec_nand (vector bool unsigned int,
16081                               vector unsigned int);
16082 vector unsigned int vec_nand (vector unsigned int,
16083                               vector bool unsigned int);
16084 vector short vec_nand (vector short, vector short);
16085 vector short vec_nand (vector bool short, vector short);
16086 vector short vec_nand (vector short, vector bool short);
16087 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16088 vector unsigned short vec_nand (vector bool unsigned short,
16089                                 vector unsigned short);
16090 vector unsigned short vec_nand (vector unsigned short,
16091                                 vector bool unsigned short);
16092 vector signed char vec_nand (vector signed char, vector signed char);
16093 vector signed char vec_nand (vector bool signed char, vector signed char);
16094 vector signed char vec_nand (vector signed char, vector bool signed char);
16095 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16096 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16097 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16099 vector long long vec_orc (vector long long, vector long long);
16100 vector long long vec_orc (vector bool long long, vector long long);
16101 vector long long vec_orc (vector long long, vector bool long long);
16102 vector unsigned long long vec_orc (vector unsigned long long,
16103                                    vector unsigned long long);
16104 vector unsigned long long vec_orc (vector bool long long,
16105                                    vector unsigned long long);
16106 vector unsigned long long vec_orc (vector unsigned long long,
16107                                    vector bool long long);
16108 vector int vec_orc (vector int, vector int);
16109 vector int vec_orc (vector bool int, vector int);
16110 vector int vec_orc (vector int, vector bool int);
16111 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16112 vector unsigned int vec_orc (vector bool unsigned int,
16113                              vector unsigned int);
16114 vector unsigned int vec_orc (vector unsigned int,
16115                              vector bool unsigned int);
16116 vector short vec_orc (vector short, vector short);
16117 vector short vec_orc (vector bool short, vector short);
16118 vector short vec_orc (vector short, vector bool short);
16119 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16120 vector unsigned short vec_orc (vector bool unsigned short,
16121                                vector unsigned short);
16122 vector unsigned short vec_orc (vector unsigned short,
16123                                vector bool unsigned short);
16124 vector signed char vec_orc (vector signed char, vector signed char);
16125 vector signed char vec_orc (vector bool signed char, vector signed char);
16126 vector signed char vec_orc (vector signed char, vector bool signed char);
16127 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16128 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16129 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16131 vector int vec_pack (vector long long, vector long long);
16132 vector unsigned int vec_pack (vector unsigned long long,
16133                               vector unsigned long long);
16134 vector bool int vec_pack (vector bool long long, vector bool long long);
16136 vector int vec_packs (vector long long, vector long long);
16137 vector unsigned int vec_packs (vector unsigned long long,
16138                                vector unsigned long long);
16140 vector unsigned int vec_packsu (vector long long, vector long long);
16141 vector unsigned int vec_packsu (vector unsigned long long,
16142                                 vector unsigned long long);
16144 vector long long vec_rl (vector long long,
16145                          vector unsigned long long);
16146 vector long long vec_rl (vector unsigned long long,
16147                          vector unsigned long long);
16149 vector long long vec_sl (vector long long, vector unsigned long long);
16150 vector long long vec_sl (vector unsigned long long,
16151                          vector unsigned long long);
16153 vector long long vec_sr (vector long long, vector unsigned long long);
16154 vector unsigned long long char vec_sr (vector unsigned long long,
16155                                        vector unsigned long long);
16157 vector long long vec_sra (vector long long, vector unsigned long long);
16158 vector unsigned long long vec_sra (vector unsigned long long,
16159                                    vector unsigned long long);
16161 vector long long vec_sub (vector long long, vector long long);
16162 vector unsigned long long vec_sub (vector unsigned long long,
16163                                    vector unsigned long long);
16165 vector long long vec_unpackh (vector int);
16166 vector unsigned long long vec_unpackh (vector unsigned int);
16168 vector long long vec_unpackl (vector int);
16169 vector unsigned long long vec_unpackl (vector unsigned int);
16171 vector long long vec_vaddudm (vector long long, vector long long);
16172 vector long long vec_vaddudm (vector bool long long, vector long long);
16173 vector long long vec_vaddudm (vector long long, vector bool long long);
16174 vector unsigned long long vec_vaddudm (vector unsigned long long,
16175                                        vector unsigned long long);
16176 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16177                                        vector unsigned long long);
16178 vector unsigned long long vec_vaddudm (vector unsigned long long,
16179                                        vector bool unsigned long long);
16181 vector long long vec_vbpermq (vector signed char, vector signed char);
16182 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16184 vector long long vec_cntlz (vector long long);
16185 vector unsigned long long vec_cntlz (vector unsigned long long);
16186 vector int vec_cntlz (vector int);
16187 vector unsigned int vec_cntlz (vector int);
16188 vector short vec_cntlz (vector short);
16189 vector unsigned short vec_cntlz (vector unsigned short);
16190 vector signed char vec_cntlz (vector signed char);
16191 vector unsigned char vec_cntlz (vector unsigned char);
16193 vector long long vec_vclz (vector long long);
16194 vector unsigned long long vec_vclz (vector unsigned long long);
16195 vector int vec_vclz (vector int);
16196 vector unsigned int vec_vclz (vector int);
16197 vector short vec_vclz (vector short);
16198 vector unsigned short vec_vclz (vector unsigned short);
16199 vector signed char vec_vclz (vector signed char);
16200 vector unsigned char vec_vclz (vector unsigned char);
16202 vector signed char vec_vclzb (vector signed char);
16203 vector unsigned char vec_vclzb (vector unsigned char);
16205 vector long long vec_vclzd (vector long long);
16206 vector unsigned long long vec_vclzd (vector unsigned long long);
16208 vector short vec_vclzh (vector short);
16209 vector unsigned short vec_vclzh (vector unsigned short);
16211 vector int vec_vclzw (vector int);
16212 vector unsigned int vec_vclzw (vector int);
16214 vector signed char vec_vgbbd (vector signed char);
16215 vector unsigned char vec_vgbbd (vector unsigned char);
16217 vector long long vec_vmaxsd (vector long long, vector long long);
16219 vector unsigned long long vec_vmaxud (vector unsigned long long,
16220                                       unsigned vector long long);
16222 vector long long vec_vminsd (vector long long, vector long long);
16224 vector unsigned long long vec_vminud (vector long long,
16225                                       vector long long);
16227 vector int vec_vpksdss (vector long long, vector long long);
16228 vector unsigned int vec_vpksdss (vector long long, vector long long);
16230 vector unsigned int vec_vpkudus (vector unsigned long long,
16231                                  vector unsigned long long);
16233 vector int vec_vpkudum (vector long long, vector long long);
16234 vector unsigned int vec_vpkudum (vector unsigned long long,
16235                                  vector unsigned long long);
16236 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16238 vector long long vec_vpopcnt (vector long long);
16239 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16240 vector int vec_vpopcnt (vector int);
16241 vector unsigned int vec_vpopcnt (vector int);
16242 vector short vec_vpopcnt (vector short);
16243 vector unsigned short vec_vpopcnt (vector unsigned short);
16244 vector signed char vec_vpopcnt (vector signed char);
16245 vector unsigned char vec_vpopcnt (vector unsigned char);
16247 vector signed char vec_vpopcntb (vector signed char);
16248 vector unsigned char vec_vpopcntb (vector unsigned char);
16250 vector long long vec_vpopcntd (vector long long);
16251 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16253 vector short vec_vpopcnth (vector short);
16254 vector unsigned short vec_vpopcnth (vector unsigned short);
16256 vector int vec_vpopcntw (vector int);
16257 vector unsigned int vec_vpopcntw (vector int);
16259 vector long long vec_vrld (vector long long, vector unsigned long long);
16260 vector unsigned long long vec_vrld (vector unsigned long long,
16261                                     vector unsigned long long);
16263 vector long long vec_vsld (vector long long, vector unsigned long long);
16264 vector long long vec_vsld (vector unsigned long long,
16265                            vector unsigned long long);
16267 vector long long vec_vsrad (vector long long, vector unsigned long long);
16268 vector unsigned long long vec_vsrad (vector unsigned long long,
16269                                      vector unsigned long long);
16271 vector long long vec_vsrd (vector long long, vector unsigned long long);
16272 vector unsigned long long char vec_vsrd (vector unsigned long long,
16273                                          vector unsigned long long);
16275 vector long long vec_vsubudm (vector long long, vector long long);
16276 vector long long vec_vsubudm (vector bool long long, vector long long);
16277 vector long long vec_vsubudm (vector long long, vector bool long long);
16278 vector unsigned long long vec_vsubudm (vector unsigned long long,
16279                                        vector unsigned long long);
16280 vector unsigned long long vec_vsubudm (vector bool long long,
16281                                        vector unsigned long long);
16282 vector unsigned long long vec_vsubudm (vector unsigned long long,
16283                                        vector bool long long);
16285 vector long long vec_vupkhsw (vector int);
16286 vector unsigned long long vec_vupkhsw (vector unsigned int);
16288 vector long long vec_vupklsw (vector int);
16289 vector unsigned long long vec_vupklsw (vector int);
16290 @end smallexample
16292 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16293 instruction set is available, the following additional functions are
16294 available for 64-bit targets.  New vector types
16295 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16296 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16297 builtins.
16299 The normal vector extract, and set operations work on
16300 @var{vector __int128_t} and @var{vector __uint128_t} types,
16301 but the index value must be 0.
16303 @smallexample
16304 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16305 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16307 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16308 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16310 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16311                                 vector __int128_t);
16312 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
16313                                  vector __uint128_t);
16315 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16316                                 vector __int128_t);
16317 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
16318                                  vector __uint128_t);
16320 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16321                                 vector __int128_t);
16322 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
16323                                  vector __uint128_t);
16325 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16326                                 vector __int128_t);
16327 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16328                                  vector __uint128_t);
16330 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16331 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16333 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16334 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16336 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16337 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16338 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16339 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16340 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16341 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16342 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16343 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16344 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16345 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16346 @end smallexample
16348 If the cryptographic instructions are enabled (@option{-mcrypto} or
16349 @option{-mcpu=power8}), the following builtins are enabled.
16351 @smallexample
16352 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16354 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16355                                                     vector unsigned long long);
16357 vector unsigned long long __builtin_crypto_vcipherlast
16358                                      (vector unsigned long long,
16359                                       vector unsigned long long);
16361 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16362                                                      vector unsigned long long);
16364 vector unsigned long long __builtin_crypto_vncipherlast
16365                                      (vector unsigned long long,
16366                                       vector unsigned long long);
16368 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16369                                                 vector unsigned char,
16370                                                 vector unsigned char);
16372 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16373                                                  vector unsigned short,
16374                                                  vector unsigned short);
16376 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16377                                                vector unsigned int,
16378                                                vector unsigned int);
16380 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16381                                                      vector unsigned long long,
16382                                                      vector unsigned long long);
16384 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16385                                                vector unsigned char);
16387 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16388                                                 vector unsigned short);
16390 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16391                                               vector unsigned int);
16393 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16394                                                     vector unsigned long long);
16396 vector unsigned long long __builtin_crypto_vshasigmad
16397                                (vector unsigned long long, int, int);
16399 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16400                                                  int, int);
16401 @end smallexample
16403 The second argument to the @var{__builtin_crypto_vshasigmad} and
16404 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16405 integer that is 0 or 1.  The third argument to these builtin functions
16406 must be a constant integer in the range of 0 to 15.
16408 @node PowerPC Hardware Transactional Memory Built-in Functions
16409 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16410 GCC provides two interfaces for accessing the Hardware Transactional
16411 Memory (HTM) instructions available on some of the PowerPC family
16412 of prcoessors (eg, POWER8).  The two interfaces come in a low level
16413 interface, consisting of built-in functions specific to PowerPC and a
16414 higher level interface consisting of inline functions that are common
16415 between PowerPC and S/390.
16417 @subsubsection PowerPC HTM Low Level Built-in Functions
16419 The following low level built-in functions are available with
16420 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16421 They all generate the machine instruction that is part of the name.
16423 The HTM built-ins return true or false depending on their success and
16424 their arguments match exactly the type and order of the associated
16425 hardware instruction's operands.  Refer to the ISA manual for a
16426 description of each instruction's operands.
16428 @smallexample
16429 unsigned int __builtin_tbegin (unsigned int)
16430 unsigned int __builtin_tend (unsigned int)
16432 unsigned int __builtin_tabort (unsigned int)
16433 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16434 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16435 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16436 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16438 unsigned int __builtin_tcheck (unsigned int)
16439 unsigned int __builtin_treclaim (unsigned int)
16440 unsigned int __builtin_trechkpt (void)
16441 unsigned int __builtin_tsr (unsigned int)
16442 @end smallexample
16444 In addition to the above HTM built-ins, we have added built-ins for
16445 some common extended mnemonics of the HTM instructions:
16447 @smallexample
16448 unsigned int __builtin_tendall (void)
16449 unsigned int __builtin_tresume (void)
16450 unsigned int __builtin_tsuspend (void)
16451 @end smallexample
16453 The following set of built-in functions are available to gain access
16454 to the HTM specific special purpose registers.
16456 @smallexample
16457 unsigned long __builtin_get_texasr (void)
16458 unsigned long __builtin_get_texasru (void)
16459 unsigned long __builtin_get_tfhar (void)
16460 unsigned long __builtin_get_tfiar (void)
16462 void __builtin_set_texasr (unsigned long);
16463 void __builtin_set_texasru (unsigned long);
16464 void __builtin_set_tfhar (unsigned long);
16465 void __builtin_set_tfiar (unsigned long);
16466 @end smallexample
16468 Example usage of these low level built-in functions may look like:
16470 @smallexample
16471 #include <htmintrin.h>
16473 int num_retries = 10;
16475 while (1)
16476   @{
16477     if (__builtin_tbegin (0))
16478       @{
16479         /* Transaction State Initiated.  */
16480         if (is_locked (lock))
16481           __builtin_tabort (0);
16482         ... transaction code...
16483         __builtin_tend (0);
16484         break;
16485       @}
16486     else
16487       @{
16488         /* Transaction State Failed.  Use locks if the transaction
16489            failure is "persistent" or we've tried too many times.  */
16490         if (num_retries-- <= 0
16491             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16492           @{
16493             acquire_lock (lock);
16494             ... non transactional fallback path...
16495             release_lock (lock);
16496             break;
16497           @}
16498       @}
16499   @}
16500 @end smallexample
16502 One final built-in function has been added that returns the value of
16503 the 2-bit Transaction State field of the Machine Status Register (MSR)
16504 as stored in @code{CR0}.
16506 @smallexample
16507 unsigned long __builtin_ttest (void)
16508 @end smallexample
16510 This built-in can be used to determine the current transaction state
16511 using the following code example:
16513 @smallexample
16514 #include <htmintrin.h>
16516 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16518 if (tx_state == _HTM_TRANSACTIONAL)
16519   @{
16520     /* Code to use in transactional state.  */
16521   @}
16522 else if (tx_state == _HTM_NONTRANSACTIONAL)
16523   @{
16524     /* Code to use in non-transactional state.  */
16525   @}
16526 else if (tx_state == _HTM_SUSPENDED)
16527   @{
16528     /* Code to use in transaction suspended state.  */
16529   @}
16530 @end smallexample
16532 @subsubsection PowerPC HTM High Level Inline Functions
16534 The following high level HTM interface is made available by including
16535 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16536 where CPU is `power8' or later.  This interface is common between PowerPC
16537 and S/390, allowing users to write one HTM source implementation that
16538 can be compiled and executed on either system.
16540 @smallexample
16541 long __TM_simple_begin (void)
16542 long __TM_begin (void* const TM_buff)
16543 long __TM_end (void)
16544 void __TM_abort (void)
16545 void __TM_named_abort (unsigned char const code)
16546 void __TM_resume (void)
16547 void __TM_suspend (void)
16549 long __TM_is_user_abort (void* const TM_buff)
16550 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16551 long __TM_is_illegal (void* const TM_buff)
16552 long __TM_is_footprint_exceeded (void* const TM_buff)
16553 long __TM_nesting_depth (void* const TM_buff)
16554 long __TM_is_nested_too_deep(void* const TM_buff)
16555 long __TM_is_conflict(void* const TM_buff)
16556 long __TM_is_failure_persistent(void* const TM_buff)
16557 long __TM_failure_address(void* const TM_buff)
16558 long long __TM_failure_code(void* const TM_buff)
16559 @end smallexample
16561 Using these common set of HTM inline functions, we can create
16562 a more portable version of the HTM example in the previous
16563 section that will work on either PowerPC or S/390:
16565 @smallexample
16566 #include <htmxlintrin.h>
16568 int num_retries = 10;
16569 TM_buff_type TM_buff;
16571 while (1)
16572   @{
16573     if (__TM_begin (TM_buff))
16574       @{
16575         /* Transaction State Initiated.  */
16576         if (is_locked (lock))
16577           __TM_abort ();
16578         ... transaction code...
16579         __TM_end ();
16580         break;
16581       @}
16582     else
16583       @{
16584         /* Transaction State Failed.  Use locks if the transaction
16585            failure is "persistent" or we've tried too many times.  */
16586         if (num_retries-- <= 0
16587             || __TM_is_failure_persistent (TM_buff))
16588           @{
16589             acquire_lock (lock);
16590             ... non transactional fallback path...
16591             release_lock (lock);
16592             break;
16593           @}
16594       @}
16595   @}
16596 @end smallexample
16598 @node RX Built-in Functions
16599 @subsection RX Built-in Functions
16600 GCC supports some of the RX instructions which cannot be expressed in
16601 the C programming language via the use of built-in functions.  The
16602 following functions are supported:
16604 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16605 Generates the @code{brk} machine instruction.
16606 @end deftypefn
16608 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16609 Generates the @code{clrpsw} machine instruction to clear the specified
16610 bit in the processor status word.
16611 @end deftypefn
16613 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16614 Generates the @code{int} machine instruction to generate an interrupt
16615 with the specified value.
16616 @end deftypefn
16618 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16619 Generates the @code{machi} machine instruction to add the result of
16620 multiplying the top 16 bits of the two arguments into the
16621 accumulator.
16622 @end deftypefn
16624 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16625 Generates the @code{maclo} machine instruction to add the result of
16626 multiplying the bottom 16 bits of the two arguments into the
16627 accumulator.
16628 @end deftypefn
16630 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16631 Generates the @code{mulhi} machine instruction to place the result of
16632 multiplying the top 16 bits of the two arguments into the
16633 accumulator.
16634 @end deftypefn
16636 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16637 Generates the @code{mullo} machine instruction to place the result of
16638 multiplying the bottom 16 bits of the two arguments into the
16639 accumulator.
16640 @end deftypefn
16642 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16643 Generates the @code{mvfachi} machine instruction to read the top
16644 32 bits of the accumulator.
16645 @end deftypefn
16647 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16648 Generates the @code{mvfacmi} machine instruction to read the middle
16649 32 bits of the accumulator.
16650 @end deftypefn
16652 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16653 Generates the @code{mvfc} machine instruction which reads the control
16654 register specified in its argument and returns its value.
16655 @end deftypefn
16657 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16658 Generates the @code{mvtachi} machine instruction to set the top
16659 32 bits of the accumulator.
16660 @end deftypefn
16662 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16663 Generates the @code{mvtaclo} machine instruction to set the bottom
16664 32 bits of the accumulator.
16665 @end deftypefn
16667 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16668 Generates the @code{mvtc} machine instruction which sets control
16669 register number @code{reg} to @code{val}.
16670 @end deftypefn
16672 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16673 Generates the @code{mvtipl} machine instruction set the interrupt
16674 priority level.
16675 @end deftypefn
16677 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16678 Generates the @code{racw} machine instruction to round the accumulator
16679 according to the specified mode.
16680 @end deftypefn
16682 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16683 Generates the @code{revw} machine instruction which swaps the bytes in
16684 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16685 and also bits 16--23 occupy bits 24--31 and vice versa.
16686 @end deftypefn
16688 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16689 Generates the @code{rmpa} machine instruction which initiates a
16690 repeated multiply and accumulate sequence.
16691 @end deftypefn
16693 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16694 Generates the @code{round} machine instruction which returns the
16695 floating-point argument rounded according to the current rounding mode
16696 set in the floating-point status word register.
16697 @end deftypefn
16699 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16700 Generates the @code{sat} machine instruction which returns the
16701 saturated value of the argument.
16702 @end deftypefn
16704 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16705 Generates the @code{setpsw} machine instruction to set the specified
16706 bit in the processor status word.
16707 @end deftypefn
16709 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16710 Generates the @code{wait} machine instruction.
16711 @end deftypefn
16713 @node S/390 System z Built-in Functions
16714 @subsection S/390 System z Built-in Functions
16715 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16716 Generates the @code{tbegin} machine instruction starting a
16717 non-constraint hardware transaction.  If the parameter is non-NULL the
16718 memory area is used to store the transaction diagnostic buffer and
16719 will be passed as first operand to @code{tbegin}.  This buffer can be
16720 defined using the @code{struct __htm_tdb} C struct defined in
16721 @code{htmintrin.h} and must reside on a double-word boundary.  The
16722 second tbegin operand is set to @code{0xff0c}. This enables
16723 save/restore of all GPRs and disables aborts for FPR and AR
16724 manipulations inside the transaction body.  The condition code set by
16725 the tbegin instruction is returned as integer value.  The tbegin
16726 instruction by definition overwrites the content of all FPRs.  The
16727 compiler will generate code which saves and restores the FPRs.  For
16728 soft-float code it is recommended to used the @code{*_nofloat}
16729 variant.  In order to prevent a TDB from being written it is required
16730 to pass an constant zero value as parameter.  Passing the zero value
16731 through a variable is not sufficient.  Although modifications of
16732 access registers inside the transaction will not trigger an
16733 transaction abort it is not supported to actually modify them.  Access
16734 registers do not get saved when entering a transaction. They will have
16735 undefined state when reaching the abort code.
16736 @end deftypefn
16738 Macros for the possible return codes of tbegin are defined in the
16739 @code{htmintrin.h} header file:
16741 @table @code
16742 @item _HTM_TBEGIN_STARTED
16743 @code{tbegin} has been executed as part of normal processing.  The
16744 transaction body is supposed to be executed.
16745 @item _HTM_TBEGIN_INDETERMINATE
16746 The transaction was aborted due to an indeterminate condition which
16747 might be persistent.
16748 @item _HTM_TBEGIN_TRANSIENT
16749 The transaction aborted due to a transient failure.  The transaction
16750 should be re-executed in that case.
16751 @item _HTM_TBEGIN_PERSISTENT
16752 The transaction aborted due to a persistent failure.  Re-execution
16753 under same circumstances will not be productive.
16754 @end table
16756 @defmac _HTM_FIRST_USER_ABORT_CODE
16757 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16758 specifies the first abort code which can be used for
16759 @code{__builtin_tabort}.  Values below this threshold are reserved for
16760 machine use.
16761 @end defmac
16763 @deftp {Data type} {struct __htm_tdb}
16764 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16765 the structure of the transaction diagnostic block as specified in the
16766 Principles of Operation manual chapter 5-91.
16767 @end deftp
16769 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16770 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16771 Using this variant in code making use of FPRs will leave the FPRs in
16772 undefined state when entering the transaction abort handler code.
16773 @end deftypefn
16775 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16776 In addition to @code{__builtin_tbegin} a loop for transient failures
16777 is generated.  If tbegin returns a condition code of 2 the transaction
16778 will be retried as often as specified in the second argument.  The
16779 perform processor assist instruction is used to tell the CPU about the
16780 number of fails so far.
16781 @end deftypefn
16783 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16784 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16785 restores.  Using this variant in code making use of FPRs will leave
16786 the FPRs in undefined state when entering the transaction abort
16787 handler code.
16788 @end deftypefn
16790 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16791 Generates the @code{tbeginc} machine instruction starting a constraint
16792 hardware transaction.  The second operand is set to @code{0xff08}.
16793 @end deftypefn
16795 @deftypefn {Built-in Function} int __builtin_tend (void)
16796 Generates the @code{tend} machine instruction finishing a transaction
16797 and making the changes visible to other threads.  The condition code
16798 generated by tend is returned as integer value.
16799 @end deftypefn
16801 @deftypefn {Built-in Function} void __builtin_tabort (int)
16802 Generates the @code{tabort} machine instruction with the specified
16803 abort code.  Abort codes from 0 through 255 are reserved and will
16804 result in an error message.
16805 @end deftypefn
16807 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16808 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16809 integer parameter is loaded into rX and a value of zero is loaded into
16810 rY.  The integer parameter specifies the number of times the
16811 transaction repeatedly aborted.
16812 @end deftypefn
16814 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16815 Generates the @code{etnd} machine instruction.  The current nesting
16816 depth is returned as integer value.  For a nesting depth of 0 the code
16817 is not executed as part of an transaction.
16818 @end deftypefn
16820 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16822 Generates the @code{ntstg} machine instruction.  The second argument
16823 is written to the first arguments location.  The store operation will
16824 not be rolled-back in case of an transaction abort.
16825 @end deftypefn
16827 @node SH Built-in Functions
16828 @subsection SH Built-in Functions
16829 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16830 families of processors:
16832 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16833 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16834 used by system code that manages threads and execution contexts.  The compiler
16835 normally does not generate code that modifies the contents of @samp{GBR} and
16836 thus the value is preserved across function calls.  Changing the @samp{GBR}
16837 value in user code must be done with caution, since the compiler might use
16838 @samp{GBR} in order to access thread local variables.
16840 @end deftypefn
16842 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16843 Returns the value that is currently set in the @samp{GBR} register.
16844 Memory loads and stores that use the thread pointer as a base address are
16845 turned into @samp{GBR} based displacement loads and stores, if possible.
16846 For example:
16847 @smallexample
16848 struct my_tcb
16850    int a, b, c, d, e;
16853 int get_tcb_value (void)
16855   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16856   return ((my_tcb*)__builtin_thread_pointer ())->c;
16859 @end smallexample
16860 @end deftypefn
16862 @node SPARC VIS Built-in Functions
16863 @subsection SPARC VIS Built-in Functions
16865 GCC supports SIMD operations on the SPARC using both the generic vector
16866 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16867 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16868 switch, the VIS extension is exposed as the following built-in functions:
16870 @smallexample
16871 typedef int v1si __attribute__ ((vector_size (4)));
16872 typedef int v2si __attribute__ ((vector_size (8)));
16873 typedef short v4hi __attribute__ ((vector_size (8)));
16874 typedef short v2hi __attribute__ ((vector_size (4)));
16875 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16876 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16878 void __builtin_vis_write_gsr (int64_t);
16879 int64_t __builtin_vis_read_gsr (void);
16881 void * __builtin_vis_alignaddr (void *, long);
16882 void * __builtin_vis_alignaddrl (void *, long);
16883 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16884 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16885 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16886 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16888 v4hi __builtin_vis_fexpand (v4qi);
16890 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16891 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16892 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16893 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16894 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16895 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16896 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16898 v4qi __builtin_vis_fpack16 (v4hi);
16899 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16900 v2hi __builtin_vis_fpackfix (v2si);
16901 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16903 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16905 long __builtin_vis_edge8 (void *, void *);
16906 long __builtin_vis_edge8l (void *, void *);
16907 long __builtin_vis_edge16 (void *, void *);
16908 long __builtin_vis_edge16l (void *, void *);
16909 long __builtin_vis_edge32 (void *, void *);
16910 long __builtin_vis_edge32l (void *, void *);
16912 long __builtin_vis_fcmple16 (v4hi, v4hi);
16913 long __builtin_vis_fcmple32 (v2si, v2si);
16914 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16915 long __builtin_vis_fcmpne32 (v2si, v2si);
16916 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16917 long __builtin_vis_fcmpgt32 (v2si, v2si);
16918 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16919 long __builtin_vis_fcmpeq32 (v2si, v2si);
16921 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16922 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16923 v2si __builtin_vis_fpadd32 (v2si, v2si);
16924 v1si __builtin_vis_fpadd32s (v1si, v1si);
16925 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16926 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16927 v2si __builtin_vis_fpsub32 (v2si, v2si);
16928 v1si __builtin_vis_fpsub32s (v1si, v1si);
16930 long __builtin_vis_array8 (long, long);
16931 long __builtin_vis_array16 (long, long);
16932 long __builtin_vis_array32 (long, long);
16933 @end smallexample
16935 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16936 functions also become available:
16938 @smallexample
16939 long __builtin_vis_bmask (long, long);
16940 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16941 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16942 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16943 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16945 long __builtin_vis_edge8n (void *, void *);
16946 long __builtin_vis_edge8ln (void *, void *);
16947 long __builtin_vis_edge16n (void *, void *);
16948 long __builtin_vis_edge16ln (void *, void *);
16949 long __builtin_vis_edge32n (void *, void *);
16950 long __builtin_vis_edge32ln (void *, void *);
16951 @end smallexample
16953 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16954 functions also become available:
16956 @smallexample
16957 void __builtin_vis_cmask8 (long);
16958 void __builtin_vis_cmask16 (long);
16959 void __builtin_vis_cmask32 (long);
16961 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16963 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16964 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16965 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16966 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16967 v2si __builtin_vis_fsll16 (v2si, v2si);
16968 v2si __builtin_vis_fslas16 (v2si, v2si);
16969 v2si __builtin_vis_fsrl16 (v2si, v2si);
16970 v2si __builtin_vis_fsra16 (v2si, v2si);
16972 long __builtin_vis_pdistn (v8qi, v8qi);
16974 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16976 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16977 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16979 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16980 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16981 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16982 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16983 v2si __builtin_vis_fpadds32 (v2si, v2si);
16984 v1si __builtin_vis_fpadds32s (v1si, v1si);
16985 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16986 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16988 long __builtin_vis_fucmple8 (v8qi, v8qi);
16989 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16990 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16991 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16993 float __builtin_vis_fhadds (float, float);
16994 double __builtin_vis_fhaddd (double, double);
16995 float __builtin_vis_fhsubs (float, float);
16996 double __builtin_vis_fhsubd (double, double);
16997 float __builtin_vis_fnhadds (float, float);
16998 double __builtin_vis_fnhaddd (double, double);
17000 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17001 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17002 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17003 @end smallexample
17005 @node SPU Built-in Functions
17006 @subsection SPU Built-in Functions
17008 GCC provides extensions for the SPU processor as described in the
17009 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17010 found at @uref{http://cell.scei.co.jp/} or
17011 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
17012 implementation differs in several ways.
17014 @itemize @bullet
17016 @item
17017 The optional extension of specifying vector constants in parentheses is
17018 not supported.
17020 @item
17021 A vector initializer requires no cast if the vector constant is of the
17022 same type as the variable it is initializing.
17024 @item
17025 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17026 vector type is the default signedness of the base type.  The default
17027 varies depending on the operating system, so a portable program should
17028 always specify the signedness.
17030 @item
17031 By default, the keyword @code{__vector} is added. The macro
17032 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17033 undefined.
17035 @item
17036 GCC allows using a @code{typedef} name as the type specifier for a
17037 vector type.
17039 @item
17040 For C, overloaded functions are implemented with macros so the following
17041 does not work:
17043 @smallexample
17044   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17045 @end smallexample
17047 @noindent
17048 Since @code{spu_add} is a macro, the vector constant in the example
17049 is treated as four separate arguments.  Wrap the entire argument in
17050 parentheses for this to work.
17052 @item
17053 The extended version of @code{__builtin_expect} is not supported.
17055 @end itemize
17057 @emph{Note:} Only the interface described in the aforementioned
17058 specification is supported. Internally, GCC uses built-in functions to
17059 implement the required functionality, but these are not supported and
17060 are subject to change without notice.
17062 @node TI C6X Built-in Functions
17063 @subsection TI C6X Built-in Functions
17065 GCC provides intrinsics to access certain instructions of the TI C6X
17066 processors.  These intrinsics, listed below, are available after
17067 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
17068 to C6X instructions.
17070 @smallexample
17072 int _sadd (int, int)
17073 int _ssub (int, int)
17074 int _sadd2 (int, int)
17075 int _ssub2 (int, int)
17076 long long _mpy2 (int, int)
17077 long long _smpy2 (int, int)
17078 int _add4 (int, int)
17079 int _sub4 (int, int)
17080 int _saddu4 (int, int)
17082 int _smpy (int, int)
17083 int _smpyh (int, int)
17084 int _smpyhl (int, int)
17085 int _smpylh (int, int)
17087 int _sshl (int, int)
17088 int _subc (int, int)
17090 int _avg2 (int, int)
17091 int _avgu4 (int, int)
17093 int _clrr (int, int)
17094 int _extr (int, int)
17095 int _extru (int, int)
17096 int _abs (int)
17097 int _abs2 (int)
17099 @end smallexample
17101 @node TILE-Gx Built-in Functions
17102 @subsection TILE-Gx Built-in Functions
17104 GCC provides intrinsics to access every instruction of the TILE-Gx
17105 processor.  The intrinsics are of the form:
17107 @smallexample
17109 unsigned long long __insn_@var{op} (...)
17111 @end smallexample
17113 Where @var{op} is the name of the instruction.  Refer to the ISA manual
17114 for the complete list of instructions.
17116 GCC also provides intrinsics to directly access the network registers.
17117 The intrinsics are:
17119 @smallexample
17121 unsigned long long __tile_idn0_receive (void)
17122 unsigned long long __tile_idn1_receive (void)
17123 unsigned long long __tile_udn0_receive (void)
17124 unsigned long long __tile_udn1_receive (void)
17125 unsigned long long __tile_udn2_receive (void)
17126 unsigned long long __tile_udn3_receive (void)
17127 void __tile_idn_send (unsigned long long)
17128 void __tile_udn_send (unsigned long long)
17130 @end smallexample
17132 The intrinsic @code{void __tile_network_barrier (void)} is used to
17133 guarantee that no network operations before it are reordered with
17134 those after it.
17136 @node TILEPro Built-in Functions
17137 @subsection TILEPro Built-in Functions
17139 GCC provides intrinsics to access every instruction of the TILEPro
17140 processor.  The intrinsics are of the form:
17142 @smallexample
17144 unsigned __insn_@var{op} (...)
17146 @end smallexample
17148 @noindent
17149 where @var{op} is the name of the instruction.  Refer to the ISA manual
17150 for the complete list of instructions.
17152 GCC also provides intrinsics to directly access the network registers.
17153 The intrinsics are:
17155 @smallexample
17157 unsigned __tile_idn0_receive (void)
17158 unsigned __tile_idn1_receive (void)
17159 unsigned __tile_sn_receive (void)
17160 unsigned __tile_udn0_receive (void)
17161 unsigned __tile_udn1_receive (void)
17162 unsigned __tile_udn2_receive (void)
17163 unsigned __tile_udn3_receive (void)
17164 void __tile_idn_send (unsigned)
17165 void __tile_sn_send (unsigned)
17166 void __tile_udn_send (unsigned)
17168 @end smallexample
17170 The intrinsic @code{void __tile_network_barrier (void)} is used to
17171 guarantee that no network operations before it are reordered with
17172 those after it.
17174 @node Target Format Checks
17175 @section Format Checks Specific to Particular Target Machines
17177 For some target machines, GCC supports additional options to the
17178 format attribute
17179 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17181 @menu
17182 * Solaris Format Checks::
17183 * Darwin Format Checks::
17184 @end menu
17186 @node Solaris Format Checks
17187 @subsection Solaris Format Checks
17189 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17190 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17191 conversions, and the two-argument @code{%b} conversion for displaying
17192 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17194 @node Darwin Format Checks
17195 @subsection Darwin Format Checks
17197 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17198 attribute context.  Declarations made with such attribution are parsed for correct syntax
17199 and format argument types.  However, parsing of the format string itself is currently undefined
17200 and is not carried out by this version of the compiler.
17202 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17203 also be used as format arguments.  Note that the relevant headers are only likely to be
17204 available on Darwin (OSX) installations.  On such installations, the XCode and system
17205 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17206 associated functions.
17208 @node Pragmas
17209 @section Pragmas Accepted by GCC
17210 @cindex pragmas
17211 @cindex @code{#pragma}
17213 GCC supports several types of pragmas, primarily in order to compile
17214 code originally written for other compilers.  Note that in general
17215 we do not recommend the use of pragmas; @xref{Function Attributes},
17216 for further explanation.
17218 @menu
17219 * ARM Pragmas::
17220 * M32C Pragmas::
17221 * MeP Pragmas::
17222 * RS/6000 and PowerPC Pragmas::
17223 * Darwin Pragmas::
17224 * Solaris Pragmas::
17225 * Symbol-Renaming Pragmas::
17226 * Structure-Packing Pragmas::
17227 * Weak Pragmas::
17228 * Diagnostic Pragmas::
17229 * Visibility Pragmas::
17230 * Push/Pop Macro Pragmas::
17231 * Function Specific Option Pragmas::
17232 * Loop-Specific Pragmas::
17233 @end menu
17235 @node ARM Pragmas
17236 @subsection ARM Pragmas
17238 The ARM target defines pragmas for controlling the default addition of
17239 @code{long_call} and @code{short_call} attributes to functions.
17240 @xref{Function Attributes}, for information about the effects of these
17241 attributes.
17243 @table @code
17244 @item long_calls
17245 @cindex pragma, long_calls
17246 Set all subsequent functions to have the @code{long_call} attribute.
17248 @item no_long_calls
17249 @cindex pragma, no_long_calls
17250 Set all subsequent functions to have the @code{short_call} attribute.
17252 @item long_calls_off
17253 @cindex pragma, long_calls_off
17254 Do not affect the @code{long_call} or @code{short_call} attributes of
17255 subsequent functions.
17256 @end table
17258 @node M32C Pragmas
17259 @subsection M32C Pragmas
17261 @table @code
17262 @item GCC memregs @var{number}
17263 @cindex pragma, memregs
17264 Overrides the command-line option @code{-memregs=} for the current
17265 file.  Use with care!  This pragma must be before any function in the
17266 file, and mixing different memregs values in different objects may
17267 make them incompatible.  This pragma is useful when a
17268 performance-critical function uses a memreg for temporary values,
17269 as it may allow you to reduce the number of memregs used.
17271 @item ADDRESS @var{name} @var{address}
17272 @cindex pragma, address
17273 For any declared symbols matching @var{name}, this does three things
17274 to that symbol: it forces the symbol to be located at the given
17275 address (a number), it forces the symbol to be volatile, and it
17276 changes the symbol's scope to be static.  This pragma exists for
17277 compatibility with other compilers, but note that the common
17278 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17279 instead).  Example:
17281 @smallexample
17282 #pragma ADDRESS port3 0x103
17283 char port3;
17284 @end smallexample
17286 @end table
17288 @node MeP Pragmas
17289 @subsection MeP Pragmas
17291 @table @code
17293 @item custom io_volatile (on|off)
17294 @cindex pragma, custom io_volatile
17295 Overrides the command-line option @code{-mio-volatile} for the current
17296 file.  Note that for compatibility with future GCC releases, this
17297 option should only be used once before any @code{io} variables in each
17298 file.
17300 @item GCC coprocessor available @var{registers}
17301 @cindex pragma, coprocessor available
17302 Specifies which coprocessor registers are available to the register
17303 allocator.  @var{registers} may be a single register, register range
17304 separated by ellipses, or comma-separated list of those.  Example:
17306 @smallexample
17307 #pragma GCC coprocessor available $c0...$c10, $c28
17308 @end smallexample
17310 @item GCC coprocessor call_saved @var{registers}
17311 @cindex pragma, coprocessor call_saved
17312 Specifies which coprocessor registers are to be saved and restored by
17313 any function using them.  @var{registers} may be a single register,
17314 register range separated by ellipses, or comma-separated list of
17315 those.  Example:
17317 @smallexample
17318 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17319 @end smallexample
17321 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17322 @cindex pragma, coprocessor subclass
17323 Creates and defines a register class.  These register classes can be
17324 used by inline @code{asm} constructs.  @var{registers} may be a single
17325 register, register range separated by ellipses, or comma-separated
17326 list of those.  Example:
17328 @smallexample
17329 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17331 asm ("cpfoo %0" : "=B" (x));
17332 @end smallexample
17334 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17335 @cindex pragma, disinterrupt
17336 For the named functions, the compiler adds code to disable interrupts
17337 for the duration of those functions.  If any functions so named 
17338 are not encountered in the source, a warning is emitted that the pragma is
17339 not used.  Examples:
17341 @smallexample
17342 #pragma disinterrupt foo
17343 #pragma disinterrupt bar, grill
17344 int foo () @{ @dots{} @}
17345 @end smallexample
17347 @item GCC call @var{name} , @var{name} @dots{}
17348 @cindex pragma, call
17349 For the named functions, the compiler always uses a register-indirect
17350 call model when calling the named functions.  Examples:
17352 @smallexample
17353 extern int foo ();
17354 #pragma call foo
17355 @end smallexample
17357 @end table
17359 @node RS/6000 and PowerPC Pragmas
17360 @subsection RS/6000 and PowerPC Pragmas
17362 The RS/6000 and PowerPC targets define one pragma for controlling
17363 whether or not the @code{longcall} attribute is added to function
17364 declarations by default.  This pragma overrides the @option{-mlongcall}
17365 option, but not the @code{longcall} and @code{shortcall} attributes.
17366 @xref{RS/6000 and PowerPC Options}, for more information about when long
17367 calls are and are not necessary.
17369 @table @code
17370 @item longcall (1)
17371 @cindex pragma, longcall
17372 Apply the @code{longcall} attribute to all subsequent function
17373 declarations.
17375 @item longcall (0)
17376 Do not apply the @code{longcall} attribute to subsequent function
17377 declarations.
17378 @end table
17380 @c Describe h8300 pragmas here.
17381 @c Describe sh pragmas here.
17382 @c Describe v850 pragmas here.
17384 @node Darwin Pragmas
17385 @subsection Darwin Pragmas
17387 The following pragmas are available for all architectures running the
17388 Darwin operating system.  These are useful for compatibility with other
17389 Mac OS compilers.
17391 @table @code
17392 @item mark @var{tokens}@dots{}
17393 @cindex pragma, mark
17394 This pragma is accepted, but has no effect.
17396 @item options align=@var{alignment}
17397 @cindex pragma, options align
17398 This pragma sets the alignment of fields in structures.  The values of
17399 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17400 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17401 properly; to restore the previous setting, use @code{reset} for the
17402 @var{alignment}.
17404 @item segment @var{tokens}@dots{}
17405 @cindex pragma, segment
17406 This pragma is accepted, but has no effect.
17408 @item unused (@var{var} [, @var{var}]@dots{})
17409 @cindex pragma, unused
17410 This pragma declares variables to be possibly unused.  GCC does not
17411 produce warnings for the listed variables.  The effect is similar to
17412 that of the @code{unused} attribute, except that this pragma may appear
17413 anywhere within the variables' scopes.
17414 @end table
17416 @node Solaris Pragmas
17417 @subsection Solaris Pragmas
17419 The Solaris target supports @code{#pragma redefine_extname}
17420 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17421 @code{#pragma} directives for compatibility with the system compiler.
17423 @table @code
17424 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17425 @cindex pragma, align
17427 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17428 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17429 Attributes}).  Macro expansion occurs on the arguments to this pragma
17430 when compiling C and Objective-C@.  It does not currently occur when
17431 compiling C++, but this is a bug which may be fixed in a future
17432 release.
17434 @item fini (@var{function} [, @var{function}]...)
17435 @cindex pragma, fini
17437 This pragma causes each listed @var{function} to be called after
17438 main, or during shared module unloading, by adding a call to the
17439 @code{.fini} section.
17441 @item init (@var{function} [, @var{function}]...)
17442 @cindex pragma, init
17444 This pragma causes each listed @var{function} to be called during
17445 initialization (before @code{main}) or during shared module loading, by
17446 adding a call to the @code{.init} section.
17448 @end table
17450 @node Symbol-Renaming Pragmas
17451 @subsection Symbol-Renaming Pragmas
17453 GCC supports a @code{#pragma} directive that changes the name used in
17454 assembly for a given declaration. This effect can also be achieved
17455 using the asm labels extension (@pxref{Asm Labels}).
17457 @table @code
17458 @item redefine_extname @var{oldname} @var{newname}
17459 @cindex pragma, redefine_extname
17461 This pragma gives the C function @var{oldname} the assembly symbol
17462 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17463 is defined if this pragma is available (currently on all platforms).
17464 @end table
17466 This pragma and the asm labels extension interact in a complicated
17467 manner.  Here are some corner cases you may want to be aware of:
17469 @enumerate
17470 @item This pragma silently applies only to declarations with external
17471 linkage.  Asm labels do not have this restriction.
17473 @item In C++, this pragma silently applies only to declarations with
17474 ``C'' linkage.  Again, asm labels do not have this restriction.
17476 @item If either of the ways of changing the assembly name of a
17477 declaration are applied to a declaration whose assembly name has
17478 already been determined (either by a previous use of one of these
17479 features, or because the compiler needed the assembly name in order to
17480 generate code), and the new name is different, a warning issues and
17481 the name does not change.
17483 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17484 always the C-language name.
17485 @end enumerate
17487 @node Structure-Packing Pragmas
17488 @subsection Structure-Packing Pragmas
17490 For compatibility with Microsoft Windows compilers, GCC supports a
17491 set of @code{#pragma} directives that change the maximum alignment of
17492 members of structures (other than zero-width bit-fields), unions, and
17493 classes subsequently defined. The @var{n} value below always is required
17494 to be a small power of two and specifies the new alignment in bytes.
17496 @enumerate
17497 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17498 @item @code{#pragma pack()} sets the alignment to the one that was in
17499 effect when compilation started (see also command-line option
17500 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17501 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17502 setting on an internal stack and then optionally sets the new alignment.
17503 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17504 saved at the top of the internal stack (and removes that stack entry).
17505 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17506 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17507 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17508 @code{#pragma pack(pop)}.
17509 @end enumerate
17511 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17512 @code{#pragma} which lays out a structure as the documented
17513 @code{__attribute__ ((ms_struct))}.
17514 @enumerate
17515 @item @code{#pragma ms_struct on} turns on the layout for structures
17516 declared.
17517 @item @code{#pragma ms_struct off} turns off the layout for structures
17518 declared.
17519 @item @code{#pragma ms_struct reset} goes back to the default layout.
17520 @end enumerate
17522 @node Weak Pragmas
17523 @subsection Weak Pragmas
17525 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17526 directives for declaring symbols to be weak, and defining weak
17527 aliases.
17529 @table @code
17530 @item #pragma weak @var{symbol}
17531 @cindex pragma, weak
17532 This pragma declares @var{symbol} to be weak, as if the declaration
17533 had the attribute of the same name.  The pragma may appear before
17534 or after the declaration of @var{symbol}.  It is not an error for
17535 @var{symbol} to never be defined at all.
17537 @item #pragma weak @var{symbol1} = @var{symbol2}
17538 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17539 It is an error if @var{symbol2} is not defined in the current
17540 translation unit.
17541 @end table
17543 @node Diagnostic Pragmas
17544 @subsection Diagnostic Pragmas
17546 GCC allows the user to selectively enable or disable certain types of
17547 diagnostics, and change the kind of the diagnostic.  For example, a
17548 project's policy might require that all sources compile with
17549 @option{-Werror} but certain files might have exceptions allowing
17550 specific types of warnings.  Or, a project might selectively enable
17551 diagnostics and treat them as errors depending on which preprocessor
17552 macros are defined.
17554 @table @code
17555 @item #pragma GCC diagnostic @var{kind} @var{option}
17556 @cindex pragma, diagnostic
17558 Modifies the disposition of a diagnostic.  Note that not all
17559 diagnostics are modifiable; at the moment only warnings (normally
17560 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17561 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17562 are controllable and which option controls them.
17564 @var{kind} is @samp{error} to treat this diagnostic as an error,
17565 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17566 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17567 @var{option} is a double quoted string that matches the command-line
17568 option.
17570 @smallexample
17571 #pragma GCC diagnostic warning "-Wformat"
17572 #pragma GCC diagnostic error "-Wformat"
17573 #pragma GCC diagnostic ignored "-Wformat"
17574 @end smallexample
17576 Note that these pragmas override any command-line options.  GCC keeps
17577 track of the location of each pragma, and issues diagnostics according
17578 to the state as of that point in the source file.  Thus, pragmas occurring
17579 after a line do not affect diagnostics caused by that line.
17581 @item #pragma GCC diagnostic push
17582 @itemx #pragma GCC diagnostic pop
17584 Causes GCC to remember the state of the diagnostics as of each
17585 @code{push}, and restore to that point at each @code{pop}.  If a
17586 @code{pop} has no matching @code{push}, the command-line options are
17587 restored.
17589 @smallexample
17590 #pragma GCC diagnostic error "-Wuninitialized"
17591   foo(a);                       /* error is given for this one */
17592 #pragma GCC diagnostic push
17593 #pragma GCC diagnostic ignored "-Wuninitialized"
17594   foo(b);                       /* no diagnostic for this one */
17595 #pragma GCC diagnostic pop
17596   foo(c);                       /* error is given for this one */
17597 #pragma GCC diagnostic pop
17598   foo(d);                       /* depends on command-line options */
17599 @end smallexample
17601 @end table
17603 GCC also offers a simple mechanism for printing messages during
17604 compilation.
17606 @table @code
17607 @item #pragma message @var{string}
17608 @cindex pragma, diagnostic
17610 Prints @var{string} as a compiler message on compilation.  The message
17611 is informational only, and is neither a compilation warning nor an error.
17613 @smallexample
17614 #pragma message "Compiling " __FILE__ "..."
17615 @end smallexample
17617 @var{string} may be parenthesized, and is printed with location
17618 information.  For example,
17620 @smallexample
17621 #define DO_PRAGMA(x) _Pragma (#x)
17622 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17624 TODO(Remember to fix this)
17625 @end smallexample
17627 @noindent
17628 prints @samp{/tmp/file.c:4: note: #pragma message:
17629 TODO - Remember to fix this}.
17631 @end table
17633 @node Visibility Pragmas
17634 @subsection Visibility Pragmas
17636 @table @code
17637 @item #pragma GCC visibility push(@var{visibility})
17638 @itemx #pragma GCC visibility pop
17639 @cindex pragma, visibility
17641 This pragma allows the user to set the visibility for multiple
17642 declarations without having to give each a visibility attribute
17643 (@pxref{Function Attributes}).
17645 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17646 declarations.  Class members and template specializations are not
17647 affected; if you want to override the visibility for a particular
17648 member or instantiation, you must use an attribute.
17650 @end table
17653 @node Push/Pop Macro Pragmas
17654 @subsection Push/Pop Macro Pragmas
17656 For compatibility with Microsoft Windows compilers, GCC supports
17657 @samp{#pragma push_macro(@var{"macro_name"})}
17658 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17660 @table @code
17661 @item #pragma push_macro(@var{"macro_name"})
17662 @cindex pragma, push_macro
17663 This pragma saves the value of the macro named as @var{macro_name} to
17664 the top of the stack for this macro.
17666 @item #pragma pop_macro(@var{"macro_name"})
17667 @cindex pragma, pop_macro
17668 This pragma sets the value of the macro named as @var{macro_name} to
17669 the value on top of the stack for this macro. If the stack for
17670 @var{macro_name} is empty, the value of the macro remains unchanged.
17671 @end table
17673 For example:
17675 @smallexample
17676 #define X  1
17677 #pragma push_macro("X")
17678 #undef X
17679 #define X -1
17680 #pragma pop_macro("X")
17681 int x [X];
17682 @end smallexample
17684 @noindent
17685 In this example, the definition of X as 1 is saved by @code{#pragma
17686 push_macro} and restored by @code{#pragma pop_macro}.
17688 @node Function Specific Option Pragmas
17689 @subsection Function Specific Option Pragmas
17691 @table @code
17692 @item #pragma GCC target (@var{"string"}...)
17693 @cindex pragma GCC target
17695 This pragma allows you to set target specific options for functions
17696 defined later in the source file.  One or more strings can be
17697 specified.  Each function that is defined after this point is as
17698 if @code{attribute((target("STRING")))} was specified for that
17699 function.  The parenthesis around the options is optional.
17700 @xref{Function Attributes}, for more information about the
17701 @code{target} attribute and the attribute syntax.
17703 The @code{#pragma GCC target} pragma is presently implemented for
17704 i386/x86_64, PowerPC, and Nios II targets only.
17705 @end table
17707 @table @code
17708 @item #pragma GCC optimize (@var{"string"}...)
17709 @cindex pragma GCC optimize
17711 This pragma allows you to set global optimization options for functions
17712 defined later in the source file.  One or more strings can be
17713 specified.  Each function that is defined after this point is as
17714 if @code{attribute((optimize("STRING")))} was specified for that
17715 function.  The parenthesis around the options is optional.
17716 @xref{Function Attributes}, for more information about the
17717 @code{optimize} attribute and the attribute syntax.
17719 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17720 versions earlier than 4.4.
17721 @end table
17723 @table @code
17724 @item #pragma GCC push_options
17725 @itemx #pragma GCC pop_options
17726 @cindex pragma GCC push_options
17727 @cindex pragma GCC pop_options
17729 These pragmas maintain a stack of the current target and optimization
17730 options.  It is intended for include files where you temporarily want
17731 to switch to using a different @samp{#pragma GCC target} or
17732 @samp{#pragma GCC optimize} and then to pop back to the previous
17733 options.
17735 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17736 pragmas are not implemented in GCC versions earlier than 4.4.
17737 @end table
17739 @table @code
17740 @item #pragma GCC reset_options
17741 @cindex pragma GCC reset_options
17743 This pragma clears the current @code{#pragma GCC target} and
17744 @code{#pragma GCC optimize} to use the default switches as specified
17745 on the command line.
17747 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17748 versions earlier than 4.4.
17749 @end table
17751 @node Loop-Specific Pragmas
17752 @subsection Loop-Specific Pragmas
17754 @table @code
17755 @item #pragma GCC ivdep
17756 @cindex pragma GCC ivdep
17757 @end table
17759 With this pragma, the programmer asserts that there are no loop-carried
17760 dependencies which would prevent that consecutive iterations of
17761 the following loop can be executed concurrently with SIMD
17762 (single instruction multiple data) instructions.
17764 For example, the compiler can only unconditionally vectorize the following
17765 loop with the pragma:
17767 @smallexample
17768 void foo (int n, int *a, int *b, int *c)
17770   int i, j;
17771 #pragma GCC ivdep
17772   for (i = 0; i < n; ++i)
17773     a[i] = b[i] + c[i];
17775 @end smallexample
17777 @noindent
17778 In this example, using the @code{restrict} qualifier had the same
17779 effect. In the following example, that would not be possible. Assume
17780 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17781 that it can unconditionally vectorize the following loop:
17783 @smallexample
17784 void ignore_vec_dep (int *a, int k, int c, int m)
17786 #pragma GCC ivdep
17787   for (int i = 0; i < m; i++)
17788     a[i] = a[i + k] * c;
17790 @end smallexample
17793 @node Unnamed Fields
17794 @section Unnamed struct/union fields within structs/unions
17795 @cindex @code{struct}
17796 @cindex @code{union}
17798 As permitted by ISO C11 and for compatibility with other compilers,
17799 GCC allows you to define
17800 a structure or union that contains, as fields, structures and unions
17801 without names.  For example:
17803 @smallexample
17804 struct @{
17805   int a;
17806   union @{
17807     int b;
17808     float c;
17809   @};
17810   int d;
17811 @} foo;
17812 @end smallexample
17814 @noindent
17815 In this example, you are able to access members of the unnamed
17816 union with code like @samp{foo.b}.  Note that only unnamed structs and
17817 unions are allowed, you may not have, for example, an unnamed
17818 @code{int}.
17820 You must never create such structures that cause ambiguous field definitions.
17821 For example, in this structure:
17823 @smallexample
17824 struct @{
17825   int a;
17826   struct @{
17827     int a;
17828   @};
17829 @} foo;
17830 @end smallexample
17832 @noindent
17833 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17834 The compiler gives errors for such constructs.
17836 @opindex fms-extensions
17837 Unless @option{-fms-extensions} is used, the unnamed field must be a
17838 structure or union definition without a tag (for example, @samp{struct
17839 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17840 also be a definition with a tag such as @samp{struct foo @{ int a;
17841 @};}, a reference to a previously defined structure or union such as
17842 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17843 previously defined structure or union type.
17845 @opindex fplan9-extensions
17846 The option @option{-fplan9-extensions} enables
17847 @option{-fms-extensions} as well as two other extensions.  First, a
17848 pointer to a structure is automatically converted to a pointer to an
17849 anonymous field for assignments and function calls.  For example:
17851 @smallexample
17852 struct s1 @{ int a; @};
17853 struct s2 @{ struct s1; @};
17854 extern void f1 (struct s1 *);
17855 void f2 (struct s2 *p) @{ f1 (p); @}
17856 @end smallexample
17858 @noindent
17859 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17860 converted into a pointer to the anonymous field.
17862 Second, when the type of an anonymous field is a @code{typedef} for a
17863 @code{struct} or @code{union}, code may refer to the field using the
17864 name of the @code{typedef}.
17866 @smallexample
17867 typedef struct @{ int a; @} s1;
17868 struct s2 @{ s1; @};
17869 s1 f1 (struct s2 *p) @{ return p->s1; @}
17870 @end smallexample
17872 These usages are only permitted when they are not ambiguous.
17874 @node Thread-Local
17875 @section Thread-Local Storage
17876 @cindex Thread-Local Storage
17877 @cindex @acronym{TLS}
17878 @cindex @code{__thread}
17880 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17881 are allocated such that there is one instance of the variable per extant
17882 thread.  The runtime model GCC uses to implement this originates
17883 in the IA-64 processor-specific ABI, but has since been migrated
17884 to other processors as well.  It requires significant support from
17885 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17886 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17887 is not available everywhere.
17889 At the user level, the extension is visible with a new storage
17890 class keyword: @code{__thread}.  For example:
17892 @smallexample
17893 __thread int i;
17894 extern __thread struct state s;
17895 static __thread char *p;
17896 @end smallexample
17898 The @code{__thread} specifier may be used alone, with the @code{extern}
17899 or @code{static} specifiers, but with no other storage class specifier.
17900 When used with @code{extern} or @code{static}, @code{__thread} must appear
17901 immediately after the other storage class specifier.
17903 The @code{__thread} specifier may be applied to any global, file-scoped
17904 static, function-scoped static, or static data member of a class.  It may
17905 not be applied to block-scoped automatic or non-static data member.
17907 When the address-of operator is applied to a thread-local variable, it is
17908 evaluated at run time and returns the address of the current thread's
17909 instance of that variable.  An address so obtained may be used by any
17910 thread.  When a thread terminates, any pointers to thread-local variables
17911 in that thread become invalid.
17913 No static initialization may refer to the address of a thread-local variable.
17915 In C++, if an initializer is present for a thread-local variable, it must
17916 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17917 standard.
17919 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17920 ELF Handling For Thread-Local Storage} for a detailed explanation of
17921 the four thread-local storage addressing models, and how the runtime
17922 is expected to function.
17924 @menu
17925 * C99 Thread-Local Edits::
17926 * C++98 Thread-Local Edits::
17927 @end menu
17929 @node C99 Thread-Local Edits
17930 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17932 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17933 that document the exact semantics of the language extension.
17935 @itemize @bullet
17936 @item
17937 @cite{5.1.2  Execution environments}
17939 Add new text after paragraph 1
17941 @quotation
17942 Within either execution environment, a @dfn{thread} is a flow of
17943 control within a program.  It is implementation defined whether
17944 or not there may be more than one thread associated with a program.
17945 It is implementation defined how threads beyond the first are
17946 created, the name and type of the function called at thread
17947 startup, and how threads may be terminated.  However, objects
17948 with thread storage duration shall be initialized before thread
17949 startup.
17950 @end quotation
17952 @item
17953 @cite{6.2.4  Storage durations of objects}
17955 Add new text before paragraph 3
17957 @quotation
17958 An object whose identifier is declared with the storage-class
17959 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17960 Its lifetime is the entire execution of the thread, and its
17961 stored value is initialized only once, prior to thread startup.
17962 @end quotation
17964 @item
17965 @cite{6.4.1  Keywords}
17967 Add @code{__thread}.
17969 @item
17970 @cite{6.7.1  Storage-class specifiers}
17972 Add @code{__thread} to the list of storage class specifiers in
17973 paragraph 1.
17975 Change paragraph 2 to
17977 @quotation
17978 With the exception of @code{__thread}, at most one storage-class
17979 specifier may be given [@dots{}].  The @code{__thread} specifier may
17980 be used alone, or immediately following @code{extern} or
17981 @code{static}.
17982 @end quotation
17984 Add new text after paragraph 6
17986 @quotation
17987 The declaration of an identifier for a variable that has
17988 block scope that specifies @code{__thread} shall also
17989 specify either @code{extern} or @code{static}.
17991 The @code{__thread} specifier shall be used only with
17992 variables.
17993 @end quotation
17994 @end itemize
17996 @node C++98 Thread-Local Edits
17997 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
17999 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18000 that document the exact semantics of the language extension.
18002 @itemize @bullet
18003 @item
18004 @b{[intro.execution]}
18006 New text after paragraph 4
18008 @quotation
18009 A @dfn{thread} is a flow of control within the abstract machine.
18010 It is implementation defined whether or not there may be more than
18011 one thread.
18012 @end quotation
18014 New text after paragraph 7
18016 @quotation
18017 It is unspecified whether additional action must be taken to
18018 ensure when and whether side effects are visible to other threads.
18019 @end quotation
18021 @item
18022 @b{[lex.key]}
18024 Add @code{__thread}.
18026 @item
18027 @b{[basic.start.main]}
18029 Add after paragraph 5
18031 @quotation
18032 The thread that begins execution at the @code{main} function is called
18033 the @dfn{main thread}.  It is implementation defined how functions
18034 beginning threads other than the main thread are designated or typed.
18035 A function so designated, as well as the @code{main} function, is called
18036 a @dfn{thread startup function}.  It is implementation defined what
18037 happens if a thread startup function returns.  It is implementation
18038 defined what happens to other threads when any thread calls @code{exit}.
18039 @end quotation
18041 @item
18042 @b{[basic.start.init]}
18044 Add after paragraph 4
18046 @quotation
18047 The storage for an object of thread storage duration shall be
18048 statically initialized before the first statement of the thread startup
18049 function.  An object of thread storage duration shall not require
18050 dynamic initialization.
18051 @end quotation
18053 @item
18054 @b{[basic.start.term]}
18056 Add after paragraph 3
18058 @quotation
18059 The type of an object with thread storage duration shall not have a
18060 non-trivial destructor, nor shall it be an array type whose elements
18061 (directly or indirectly) have non-trivial destructors.
18062 @end quotation
18064 @item
18065 @b{[basic.stc]}
18067 Add ``thread storage duration'' to the list in paragraph 1.
18069 Change paragraph 2
18071 @quotation
18072 Thread, static, and automatic storage durations are associated with
18073 objects introduced by declarations [@dots{}].
18074 @end quotation
18076 Add @code{__thread} to the list of specifiers in paragraph 3.
18078 @item
18079 @b{[basic.stc.thread]}
18081 New section before @b{[basic.stc.static]}
18083 @quotation
18084 The keyword @code{__thread} applied to a non-local object gives the
18085 object thread storage duration.
18087 A local variable or class data member declared both @code{static}
18088 and @code{__thread} gives the variable or member thread storage
18089 duration.
18090 @end quotation
18092 @item
18093 @b{[basic.stc.static]}
18095 Change paragraph 1
18097 @quotation
18098 All objects that have neither thread storage duration, dynamic
18099 storage duration nor are local [@dots{}].
18100 @end quotation
18102 @item
18103 @b{[dcl.stc]}
18105 Add @code{__thread} to the list in paragraph 1.
18107 Change paragraph 1
18109 @quotation
18110 With the exception of @code{__thread}, at most one
18111 @var{storage-class-specifier} shall appear in a given
18112 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18113 be used alone, or immediately following the @code{extern} or
18114 @code{static} specifiers.  [@dots{}]
18115 @end quotation
18117 Add after paragraph 5
18119 @quotation
18120 The @code{__thread} specifier can be applied only to the names of objects
18121 and to anonymous unions.
18122 @end quotation
18124 @item
18125 @b{[class.mem]}
18127 Add after paragraph 6
18129 @quotation
18130 Non-@code{static} members shall not be @code{__thread}.
18131 @end quotation
18132 @end itemize
18134 @node Binary constants
18135 @section Binary constants using the @samp{0b} prefix
18136 @cindex Binary constants using the @samp{0b} prefix
18138 Integer constants can be written as binary constants, consisting of a
18139 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18140 @samp{0B}.  This is particularly useful in environments that operate a
18141 lot on the bit level (like microcontrollers).
18143 The following statements are identical:
18145 @smallexample
18146 i =       42;
18147 i =     0x2a;
18148 i =      052;
18149 i = 0b101010;
18150 @end smallexample
18152 The type of these constants follows the same rules as for octal or
18153 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18154 can be applied.
18156 @node C++ Extensions
18157 @chapter Extensions to the C++ Language
18158 @cindex extensions, C++ language
18159 @cindex C++ language extensions
18161 The GNU compiler provides these extensions to the C++ language (and you
18162 can also use most of the C language extensions in your C++ programs).  If you
18163 want to write code that checks whether these features are available, you can
18164 test for the GNU compiler the same way as for C programs: check for a
18165 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18166 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18167 Predefined Macros,cpp,The GNU C Preprocessor}).
18169 @menu
18170 * C++ Volatiles::       What constitutes an access to a volatile object.
18171 * Restricted Pointers:: C99 restricted pointers and references.
18172 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18173 * C++ Interface::       You can use a single C++ header file for both
18174                         declarations and definitions.
18175 * Template Instantiation:: Methods for ensuring that exactly one copy of
18176                         each needed template instantiation is emitted.
18177 * Bound member functions:: You can extract a function pointer to the
18178                         method denoted by a @samp{->*} or @samp{.*} expression.
18179 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18180 * Function Multiversioning::   Declaring multiple function versions.
18181 * Namespace Association:: Strong using-directives for namespace association.
18182 * Type Traits::         Compiler support for type traits
18183 * Java Exceptions::     Tweaking exception handling to work with Java.
18184 * Deprecated Features:: Things will disappear from G++.
18185 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18186 @end menu
18188 @node C++ Volatiles
18189 @section When is a Volatile C++ Object Accessed?
18190 @cindex accessing volatiles
18191 @cindex volatile read
18192 @cindex volatile write
18193 @cindex volatile access
18195 The C++ standard differs from the C standard in its treatment of
18196 volatile objects.  It fails to specify what constitutes a volatile
18197 access, except to say that C++ should behave in a similar manner to C
18198 with respect to volatiles, where possible.  However, the different
18199 lvalueness of expressions between C and C++ complicate the behavior.
18200 G++ behaves the same as GCC for volatile access, @xref{C
18201 Extensions,,Volatiles}, for a description of GCC's behavior.
18203 The C and C++ language specifications differ when an object is
18204 accessed in a void context:
18206 @smallexample
18207 volatile int *src = @var{somevalue};
18208 *src;
18209 @end smallexample
18211 The C++ standard specifies that such expressions do not undergo lvalue
18212 to rvalue conversion, and that the type of the dereferenced object may
18213 be incomplete.  The C++ standard does not specify explicitly that it
18214 is lvalue to rvalue conversion that is responsible for causing an
18215 access.  There is reason to believe that it is, because otherwise
18216 certain simple expressions become undefined.  However, because it
18217 would surprise most programmers, G++ treats dereferencing a pointer to
18218 volatile object of complete type as GCC would do for an equivalent
18219 type in C@.  When the object has incomplete type, G++ issues a
18220 warning; if you wish to force an error, you must force a conversion to
18221 rvalue with, for instance, a static cast.
18223 When using a reference to volatile, G++ does not treat equivalent
18224 expressions as accesses to volatiles, but instead issues a warning that
18225 no volatile is accessed.  The rationale for this is that otherwise it
18226 becomes difficult to determine where volatile access occur, and not
18227 possible to ignore the return value from functions returning volatile
18228 references.  Again, if you wish to force a read, cast the reference to
18229 an rvalue.
18231 G++ implements the same behavior as GCC does when assigning to a
18232 volatile object---there is no reread of the assigned-to object, the
18233 assigned rvalue is reused.  Note that in C++ assignment expressions
18234 are lvalues, and if used as an lvalue, the volatile object is
18235 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18236 expected, in the following example:
18238 @smallexample
18239 volatile int vobj;
18240 volatile int &vref = vobj = @var{something};
18241 @end smallexample
18243 @node Restricted Pointers
18244 @section Restricting Pointer Aliasing
18245 @cindex restricted pointers
18246 @cindex restricted references
18247 @cindex restricted this pointer
18249 As with the C front end, G++ understands the C99 feature of restricted pointers,
18250 specified with the @code{__restrict__}, or @code{__restrict} type
18251 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18252 language flag, @code{restrict} is not a keyword in C++.
18254 In addition to allowing restricted pointers, you can specify restricted
18255 references, which indicate that the reference is not aliased in the local
18256 context.
18258 @smallexample
18259 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18261   /* @r{@dots{}} */
18263 @end smallexample
18265 @noindent
18266 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18267 @var{rref} refers to a (different) unaliased integer.
18269 You may also specify whether a member function's @var{this} pointer is
18270 unaliased by using @code{__restrict__} as a member function qualifier.
18272 @smallexample
18273 void T::fn () __restrict__
18275   /* @r{@dots{}} */
18277 @end smallexample
18279 @noindent
18280 Within the body of @code{T::fn}, @var{this} has the effective
18281 definition @code{T *__restrict__ const this}.  Notice that the
18282 interpretation of a @code{__restrict__} member function qualifier is
18283 different to that of @code{const} or @code{volatile} qualifier, in that it
18284 is applied to the pointer rather than the object.  This is consistent with
18285 other compilers that implement restricted pointers.
18287 As with all outermost parameter qualifiers, @code{__restrict__} is
18288 ignored in function definition matching.  This means you only need to
18289 specify @code{__restrict__} in a function definition, rather than
18290 in a function prototype as well.
18292 @node Vague Linkage
18293 @section Vague Linkage
18294 @cindex vague linkage
18296 There are several constructs in C++ that require space in the object
18297 file but are not clearly tied to a single translation unit.  We say that
18298 these constructs have ``vague linkage''.  Typically such constructs are
18299 emitted wherever they are needed, though sometimes we can be more
18300 clever.
18302 @table @asis
18303 @item Inline Functions
18304 Inline functions are typically defined in a header file which can be
18305 included in many different compilations.  Hopefully they can usually be
18306 inlined, but sometimes an out-of-line copy is necessary, if the address
18307 of the function is taken or if inlining fails.  In general, we emit an
18308 out-of-line copy in all translation units where one is needed.  As an
18309 exception, we only emit inline virtual functions with the vtable, since
18310 it always requires a copy.
18312 Local static variables and string constants used in an inline function
18313 are also considered to have vague linkage, since they must be shared
18314 between all inlined and out-of-line instances of the function.
18316 @item VTables
18317 @cindex vtable
18318 C++ virtual functions are implemented in most compilers using a lookup
18319 table, known as a vtable.  The vtable contains pointers to the virtual
18320 functions provided by a class, and each object of the class contains a
18321 pointer to its vtable (or vtables, in some multiple-inheritance
18322 situations).  If the class declares any non-inline, non-pure virtual
18323 functions, the first one is chosen as the ``key method'' for the class,
18324 and the vtable is only emitted in the translation unit where the key
18325 method is defined.
18327 @emph{Note:} If the chosen key method is later defined as inline, the
18328 vtable is still emitted in every translation unit that defines it.
18329 Make sure that any inline virtuals are declared inline in the class
18330 body, even if they are not defined there.
18332 @item @code{type_info} objects
18333 @cindex @code{type_info}
18334 @cindex RTTI
18335 C++ requires information about types to be written out in order to
18336 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18337 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18338 object is written out along with the vtable so that @samp{dynamic_cast}
18339 can determine the dynamic type of a class object at run time.  For all
18340 other types, we write out the @samp{type_info} object when it is used: when
18341 applying @samp{typeid} to an expression, throwing an object, or
18342 referring to a type in a catch clause or exception specification.
18344 @item Template Instantiations
18345 Most everything in this section also applies to template instantiations,
18346 but there are other options as well.
18347 @xref{Template Instantiation,,Where's the Template?}.
18349 @end table
18351 When used with GNU ld version 2.8 or later on an ELF system such as
18352 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18353 these constructs will be discarded at link time.  This is known as
18354 COMDAT support.
18356 On targets that don't support COMDAT, but do support weak symbols, GCC
18357 uses them.  This way one copy overrides all the others, but
18358 the unused copies still take up space in the executable.
18360 For targets that do not support either COMDAT or weak symbols,
18361 most entities with vague linkage are emitted as local symbols to
18362 avoid duplicate definition errors from the linker.  This does not happen
18363 for local statics in inlines, however, as having multiple copies
18364 almost certainly breaks things.
18366 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18367 another way to control placement of these constructs.
18369 @node C++ Interface
18370 @section #pragma interface and implementation
18372 @cindex interface and implementation headers, C++
18373 @cindex C++ interface and implementation headers
18374 @cindex pragmas, interface and implementation
18376 @code{#pragma interface} and @code{#pragma implementation} provide the
18377 user with a way of explicitly directing the compiler to emit entities
18378 with vague linkage (and debugging information) in a particular
18379 translation unit.
18381 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18382 most cases, because of COMDAT support and the ``key method'' heuristic
18383 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18384 program to grow due to unnecessary out-of-line copies of inline
18385 functions.  Currently (3.4) the only benefit of these
18386 @code{#pragma}s is reduced duplication of debugging information, and
18387 that should be addressed soon on DWARF 2 targets with the use of
18388 COMDAT groups.
18390 @table @code
18391 @item #pragma interface
18392 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18393 @kindex #pragma interface
18394 Use this directive in @emph{header files} that define object classes, to save
18395 space in most of the object files that use those classes.  Normally,
18396 local copies of certain information (backup copies of inline member
18397 functions, debugging information, and the internal tables that implement
18398 virtual functions) must be kept in each object file that includes class
18399 definitions.  You can use this pragma to avoid such duplication.  When a
18400 header file containing @samp{#pragma interface} is included in a
18401 compilation, this auxiliary information is not generated (unless
18402 the main input source file itself uses @samp{#pragma implementation}).
18403 Instead, the object files contain references to be resolved at link
18404 time.
18406 The second form of this directive is useful for the case where you have
18407 multiple headers with the same name in different directories.  If you
18408 use this form, you must specify the same string to @samp{#pragma
18409 implementation}.
18411 @item #pragma implementation
18412 @itemx #pragma implementation "@var{objects}.h"
18413 @kindex #pragma implementation
18414 Use this pragma in a @emph{main input file}, when you want full output from
18415 included header files to be generated (and made globally visible).  The
18416 included header file, in turn, should use @samp{#pragma interface}.
18417 Backup copies of inline member functions, debugging information, and the
18418 internal tables used to implement virtual functions are all generated in
18419 implementation files.
18421 @cindex implied @code{#pragma implementation}
18422 @cindex @code{#pragma implementation}, implied
18423 @cindex naming convention, implementation headers
18424 If you use @samp{#pragma implementation} with no argument, it applies to
18425 an include file with the same basename@footnote{A file's @dfn{basename}
18426 is the name stripped of all leading path information and of trailing
18427 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18428 file.  For example, in @file{allclass.cc}, giving just
18429 @samp{#pragma implementation}
18430 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18432 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18433 an implementation file whenever you would include it from
18434 @file{allclass.cc} even if you never specified @samp{#pragma
18435 implementation}.  This was deemed to be more trouble than it was worth,
18436 however, and disabled.
18438 Use the string argument if you want a single implementation file to
18439 include code from multiple header files.  (You must also use
18440 @samp{#include} to include the header file; @samp{#pragma
18441 implementation} only specifies how to use the file---it doesn't actually
18442 include it.)
18444 There is no way to split up the contents of a single header file into
18445 multiple implementation files.
18446 @end table
18448 @cindex inlining and C++ pragmas
18449 @cindex C++ pragmas, effect on inlining
18450 @cindex pragmas in C++, effect on inlining
18451 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18452 effect on function inlining.
18454 If you define a class in a header file marked with @samp{#pragma
18455 interface}, the effect on an inline function defined in that class is
18456 similar to an explicit @code{extern} declaration---the compiler emits
18457 no code at all to define an independent version of the function.  Its
18458 definition is used only for inlining with its callers.
18460 @opindex fno-implement-inlines
18461 Conversely, when you include the same header file in a main source file
18462 that declares it as @samp{#pragma implementation}, the compiler emits
18463 code for the function itself; this defines a version of the function
18464 that can be found via pointers (or by callers compiled without
18465 inlining).  If all calls to the function can be inlined, you can avoid
18466 emitting the function by compiling with @option{-fno-implement-inlines}.
18467 If any calls are not inlined, you will get linker errors.
18469 @node Template Instantiation
18470 @section Where's the Template?
18471 @cindex template instantiation
18473 C++ templates are the first language feature to require more
18474 intelligence from the environment than one usually finds on a UNIX
18475 system.  Somehow the compiler and linker have to make sure that each
18476 template instance occurs exactly once in the executable if it is needed,
18477 and not at all otherwise.  There are two basic approaches to this
18478 problem, which are referred to as the Borland model and the Cfront model.
18480 @table @asis
18481 @item Borland model
18482 Borland C++ solved the template instantiation problem by adding the code
18483 equivalent of common blocks to their linker; the compiler emits template
18484 instances in each translation unit that uses them, and the linker
18485 collapses them together.  The advantage of this model is that the linker
18486 only has to consider the object files themselves; there is no external
18487 complexity to worry about.  This disadvantage is that compilation time
18488 is increased because the template code is being compiled repeatedly.
18489 Code written for this model tends to include definitions of all
18490 templates in the header file, since they must be seen to be
18491 instantiated.
18493 @item Cfront model
18494 The AT&T C++ translator, Cfront, solved the template instantiation
18495 problem by creating the notion of a template repository, an
18496 automatically maintained place where template instances are stored.  A
18497 more modern version of the repository works as follows: As individual
18498 object files are built, the compiler places any template definitions and
18499 instantiations encountered in the repository.  At link time, the link
18500 wrapper adds in the objects in the repository and compiles any needed
18501 instances that were not previously emitted.  The advantages of this
18502 model are more optimal compilation speed and the ability to use the
18503 system linker; to implement the Borland model a compiler vendor also
18504 needs to replace the linker.  The disadvantages are vastly increased
18505 complexity, and thus potential for error; for some code this can be
18506 just as transparent, but in practice it can been very difficult to build
18507 multiple programs in one directory and one program in multiple
18508 directories.  Code written for this model tends to separate definitions
18509 of non-inline member templates into a separate file, which should be
18510 compiled separately.
18511 @end table
18513 When used with GNU ld version 2.8 or later on an ELF system such as
18514 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18515 Borland model.  On other systems, G++ implements neither automatic
18516 model.
18518 You have the following options for dealing with template instantiations:
18520 @enumerate
18521 @item
18522 @opindex frepo
18523 Compile your template-using code with @option{-frepo}.  The compiler
18524 generates files with the extension @samp{.rpo} listing all of the
18525 template instantiations used in the corresponding object files that
18526 could be instantiated there; the link wrapper, @samp{collect2},
18527 then updates the @samp{.rpo} files to tell the compiler where to place
18528 those instantiations and rebuild any affected object files.  The
18529 link-time overhead is negligible after the first pass, as the compiler
18530 continues to place the instantiations in the same files.
18532 This is your best option for application code written for the Borland
18533 model, as it just works.  Code written for the Cfront model 
18534 needs to be modified so that the template definitions are available at
18535 one or more points of instantiation; usually this is as simple as adding
18536 @code{#include <tmethods.cc>} to the end of each template header.
18538 For library code, if you want the library to provide all of the template
18539 instantiations it needs, just try to link all of its object files
18540 together; the link will fail, but cause the instantiations to be
18541 generated as a side effect.  Be warned, however, that this may cause
18542 conflicts if multiple libraries try to provide the same instantiations.
18543 For greater control, use explicit instantiation as described in the next
18544 option.
18546 @item
18547 @opindex fno-implicit-templates
18548 Compile your code with @option{-fno-implicit-templates} to disable the
18549 implicit generation of template instances, and explicitly instantiate
18550 all the ones you use.  This approach requires more knowledge of exactly
18551 which instances you need than do the others, but it's less
18552 mysterious and allows greater control.  You can scatter the explicit
18553 instantiations throughout your program, perhaps putting them in the
18554 translation units where the instances are used or the translation units
18555 that define the templates themselves; you can put all of the explicit
18556 instantiations you need into one big file; or you can create small files
18557 like
18559 @smallexample
18560 #include "Foo.h"
18561 #include "Foo.cc"
18563 template class Foo<int>;
18564 template ostream& operator <<
18565                 (ostream&, const Foo<int>&);
18566 @end smallexample
18568 @noindent
18569 for each of the instances you need, and create a template instantiation
18570 library from those.
18572 If you are using Cfront-model code, you can probably get away with not
18573 using @option{-fno-implicit-templates} when compiling files that don't
18574 @samp{#include} the member template definitions.
18576 If you use one big file to do the instantiations, you may want to
18577 compile it without @option{-fno-implicit-templates} so you get all of the
18578 instances required by your explicit instantiations (but not by any
18579 other files) without having to specify them as well.
18581 The ISO C++ 2011 standard allows forward declaration of explicit
18582 instantiations (with @code{extern}). G++ supports explicit instantiation
18583 declarations in C++98 mode and has extended the template instantiation
18584 syntax to support instantiation of the compiler support data for a
18585 template class (i.e.@: the vtable) without instantiating any of its
18586 members (with @code{inline}), and instantiation of only the static data
18587 members of a template class, without the support data or member
18588 functions (with @code{static}):
18590 @smallexample
18591 extern template int max (int, int);
18592 inline template class Foo<int>;
18593 static template class Foo<int>;
18594 @end smallexample
18596 @item
18597 Do nothing.  Pretend G++ does implement automatic instantiation
18598 management.  Code written for the Borland model works fine, but
18599 each translation unit contains instances of each of the templates it
18600 uses.  In a large program, this can lead to an unacceptable amount of code
18601 duplication.
18602 @end enumerate
18604 @node Bound member functions
18605 @section Extracting the function pointer from a bound pointer to member function
18606 @cindex pmf
18607 @cindex pointer to member function
18608 @cindex bound pointer to member function
18610 In C++, pointer to member functions (PMFs) are implemented using a wide
18611 pointer of sorts to handle all the possible call mechanisms; the PMF
18612 needs to store information about how to adjust the @samp{this} pointer,
18613 and if the function pointed to is virtual, where to find the vtable, and
18614 where in the vtable to look for the member function.  If you are using
18615 PMFs in an inner loop, you should really reconsider that decision.  If
18616 that is not an option, you can extract the pointer to the function that
18617 would be called for a given object/PMF pair and call it directly inside
18618 the inner loop, to save a bit of time.
18620 Note that you still pay the penalty for the call through a
18621 function pointer; on most modern architectures, such a call defeats the
18622 branch prediction features of the CPU@.  This is also true of normal
18623 virtual function calls.
18625 The syntax for this extension is
18627 @smallexample
18628 extern A a;
18629 extern int (A::*fp)();
18630 typedef int (*fptr)(A *);
18632 fptr p = (fptr)(a.*fp);
18633 @end smallexample
18635 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18636 no object is needed to obtain the address of the function.  They can be
18637 converted to function pointers directly:
18639 @smallexample
18640 fptr p1 = (fptr)(&A::foo);
18641 @end smallexample
18643 @opindex Wno-pmf-conversions
18644 You must specify @option{-Wno-pmf-conversions} to use this extension.
18646 @node C++ Attributes
18647 @section C++-Specific Variable, Function, and Type Attributes
18649 Some attributes only make sense for C++ programs.
18651 @table @code
18652 @item abi_tag ("@var{tag}", ...)
18653 @cindex @code{abi_tag} attribute
18654 The @code{abi_tag} attribute can be applied to a function or class
18655 declaration.  It modifies the mangled name of the function or class to
18656 incorporate the tag name, in order to distinguish the function or
18657 class from an earlier version with a different ABI; perhaps the class
18658 has changed size, or the function has a different return type that is
18659 not encoded in the mangled name.
18661 The argument can be a list of strings of arbitrary length.  The
18662 strings are sorted on output, so the order of the list is
18663 unimportant.
18665 A redeclaration of a function or class must not add new ABI tags,
18666 since doing so would change the mangled name.
18668 The ABI tags apply to a name, so all instantiations and
18669 specializations of a template have the same tags.  The attribute will
18670 be ignored if applied to an explicit specialization or instantiation.
18672 The @option{-Wabi-tag} flag enables a warning about a class which does
18673 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18674 that needs to coexist with an earlier ABI, using this option can help
18675 to find all affected types that need to be tagged.
18677 @item init_priority (@var{priority})
18678 @cindex @code{init_priority} attribute
18681 In Standard C++, objects defined at namespace scope are guaranteed to be
18682 initialized in an order in strict accordance with that of their definitions
18683 @emph{in a given translation unit}.  No guarantee is made for initializations
18684 across translation units.  However, GNU C++ allows users to control the
18685 order of initialization of objects defined at namespace scope with the
18686 @code{init_priority} attribute by specifying a relative @var{priority},
18687 a constant integral expression currently bounded between 101 and 65535
18688 inclusive.  Lower numbers indicate a higher priority.
18690 In the following example, @code{A} would normally be created before
18691 @code{B}, but the @code{init_priority} attribute reverses that order:
18693 @smallexample
18694 Some_Class  A  __attribute__ ((init_priority (2000)));
18695 Some_Class  B  __attribute__ ((init_priority (543)));
18696 @end smallexample
18698 @noindent
18699 Note that the particular values of @var{priority} do not matter; only their
18700 relative ordering.
18702 @item java_interface
18703 @cindex @code{java_interface} attribute
18705 This type attribute informs C++ that the class is a Java interface.  It may
18706 only be applied to classes declared within an @code{extern "Java"} block.
18707 Calls to methods declared in this interface are dispatched using GCJ's
18708 interface table mechanism, instead of regular virtual table dispatch.
18710 @item warn_unused
18711 @cindex @code{warn_unused} attribute
18713 For C++ types with non-trivial constructors and/or destructors it is
18714 impossible for the compiler to determine whether a variable of this
18715 type is truly unused if it is not referenced. This type attribute
18716 informs the compiler that variables of this type should be warned
18717 about if they appear to be unused, just like variables of fundamental
18718 types.
18720 This attribute is appropriate for types which just represent a value,
18721 such as @code{std::string}; it is not appropriate for types which
18722 control a resource, such as @code{std::mutex}.
18724 This attribute is also accepted in C, but it is unnecessary because C
18725 does not have constructors or destructors.
18727 @end table
18729 See also @ref{Namespace Association}.
18731 @node Function Multiversioning
18732 @section Function Multiversioning
18733 @cindex function versions
18735 With the GNU C++ front end, for target i386, you may specify multiple
18736 versions of a function, where each function is specialized for a
18737 specific target feature.  At runtime, the appropriate version of the
18738 function is automatically executed depending on the characteristics of
18739 the execution platform.  Here is an example.
18741 @smallexample
18742 __attribute__ ((target ("default")))
18743 int foo ()
18745   // The default version of foo.
18746   return 0;
18749 __attribute__ ((target ("sse4.2")))
18750 int foo ()
18752   // foo version for SSE4.2
18753   return 1;
18756 __attribute__ ((target ("arch=atom")))
18757 int foo ()
18759   // foo version for the Intel ATOM processor
18760   return 2;
18763 __attribute__ ((target ("arch=amdfam10")))
18764 int foo ()
18766   // foo version for the AMD Family 0x10 processors.
18767   return 3;
18770 int main ()
18772   int (*p)() = &foo;
18773   assert ((*p) () == foo ());
18774   return 0;
18776 @end smallexample
18778 In the above example, four versions of function foo are created. The
18779 first version of foo with the target attribute "default" is the default
18780 version.  This version gets executed when no other target specific
18781 version qualifies for execution on a particular platform. A new version
18782 of foo is created by using the same function signature but with a
18783 different target string.  Function foo is called or a pointer to it is
18784 taken just like a regular function.  GCC takes care of doing the
18785 dispatching to call the right version at runtime.  Refer to the
18786 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18787 Function Multiversioning} for more details.
18789 @node Namespace Association
18790 @section Namespace Association
18792 @strong{Caution:} The semantics of this extension are equivalent
18793 to C++ 2011 inline namespaces.  Users should use inline namespaces
18794 instead as this extension will be removed in future versions of G++.
18796 A using-directive with @code{__attribute ((strong))} is stronger
18797 than a normal using-directive in two ways:
18799 @itemize @bullet
18800 @item
18801 Templates from the used namespace can be specialized and explicitly
18802 instantiated as though they were members of the using namespace.
18804 @item
18805 The using namespace is considered an associated namespace of all
18806 templates in the used namespace for purposes of argument-dependent
18807 name lookup.
18808 @end itemize
18810 The used namespace must be nested within the using namespace so that
18811 normal unqualified lookup works properly.
18813 This is useful for composing a namespace transparently from
18814 implementation namespaces.  For example:
18816 @smallexample
18817 namespace std @{
18818   namespace debug @{
18819     template <class T> struct A @{ @};
18820   @}
18821   using namespace debug __attribute ((__strong__));
18822   template <> struct A<int> @{ @};   // @r{OK to specialize}
18824   template <class T> void f (A<T>);
18827 int main()
18829   f (std::A<float>());             // @r{lookup finds} std::f
18830   f (std::A<int>());
18832 @end smallexample
18834 @node Type Traits
18835 @section Type Traits
18837 The C++ front end implements syntactic extensions that allow
18838 compile-time determination of 
18839 various characteristics of a type (or of a
18840 pair of types).
18842 @table @code
18843 @item __has_nothrow_assign (type)
18844 If @code{type} is const qualified or is a reference type then the trait is
18845 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18846 is true, else if @code{type} is a cv class or union type with copy assignment
18847 operators that are known not to throw an exception then the trait is true,
18848 else it is false.  Requires: @code{type} shall be a complete type,
18849 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18851 @item __has_nothrow_copy (type)
18852 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18853 @code{type} is a cv class or union type with copy constructors that
18854 are known not to throw an exception then the trait is true, else it is false.
18855 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18856 @code{void}, or an array of unknown bound.
18858 @item __has_nothrow_constructor (type)
18859 If @code{__has_trivial_constructor (type)} is true then the trait is
18860 true, else if @code{type} is a cv class or union type (or array
18861 thereof) with a default constructor that is known not to throw an
18862 exception then the trait is true, else it is false.  Requires:
18863 @code{type} shall be a complete type, (possibly cv-qualified)
18864 @code{void}, or an array of unknown bound.
18866 @item __has_trivial_assign (type)
18867 If @code{type} is const qualified or is a reference type then the trait is
18868 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18869 true, else if @code{type} is a cv class or union type with a trivial
18870 copy assignment ([class.copy]) then the trait is true, else it is
18871 false.  Requires: @code{type} shall be a complete type, (possibly
18872 cv-qualified) @code{void}, or an array of unknown bound.
18874 @item __has_trivial_copy (type)
18875 If @code{__is_pod (type)} is true or @code{type} is a reference type
18876 then the trait is true, else if @code{type} is a cv class or union type
18877 with a trivial copy constructor ([class.copy]) then the trait
18878 is true, else it is false.  Requires: @code{type} shall be a complete
18879 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18881 @item __has_trivial_constructor (type)
18882 If @code{__is_pod (type)} is true then the trait is true, else if
18883 @code{type} is a cv class or union type (or array thereof) with a
18884 trivial default constructor ([class.ctor]) then the trait is true,
18885 else it is false.  Requires: @code{type} shall be a complete
18886 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18888 @item __has_trivial_destructor (type)
18889 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18890 the trait is true, else if @code{type} is a cv class or union type (or
18891 array thereof) with a trivial destructor ([class.dtor]) then the trait
18892 is true, else it is false.  Requires: @code{type} shall be a complete
18893 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18895 @item __has_virtual_destructor (type)
18896 If @code{type} is a class type with a virtual destructor
18897 ([class.dtor]) then the trait is true, else it is false.  Requires:
18898 @code{type} shall be a complete type, (possibly cv-qualified)
18899 @code{void}, or an array of unknown bound.
18901 @item __is_abstract (type)
18902 If @code{type} is an abstract class ([class.abstract]) then the trait
18903 is true, else it is false.  Requires: @code{type} shall be a complete
18904 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18906 @item __is_base_of (base_type, derived_type)
18907 If @code{base_type} is a base class of @code{derived_type}
18908 ([class.derived]) then the trait is true, otherwise it is false.
18909 Top-level cv qualifications of @code{base_type} and
18910 @code{derived_type} are ignored.  For the purposes of this trait, a
18911 class type is considered is own base.  Requires: if @code{__is_class
18912 (base_type)} and @code{__is_class (derived_type)} are true and
18913 @code{base_type} and @code{derived_type} are not the same type
18914 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18915 type.  Diagnostic is produced if this requirement is not met.
18917 @item __is_class (type)
18918 If @code{type} is a cv class type, and not a union type
18919 ([basic.compound]) the trait is true, else it is false.
18921 @item __is_empty (type)
18922 If @code{__is_class (type)} is false then the trait is false.
18923 Otherwise @code{type} is considered empty if and only if: @code{type}
18924 has no non-static data members, or all non-static data members, if
18925 any, are bit-fields of length 0, and @code{type} has no virtual
18926 members, and @code{type} has no virtual base classes, and @code{type}
18927 has no base classes @code{base_type} for which
18928 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
18929 be a complete type, (possibly cv-qualified) @code{void}, or an array
18930 of unknown bound.
18932 @item __is_enum (type)
18933 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18934 true, else it is false.
18936 @item __is_literal_type (type)
18937 If @code{type} is a literal type ([basic.types]) the trait is
18938 true, else it is false.  Requires: @code{type} shall be a complete type,
18939 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18941 @item __is_pod (type)
18942 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18943 else it is false.  Requires: @code{type} shall be a complete type,
18944 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18946 @item __is_polymorphic (type)
18947 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18948 is true, else it is false.  Requires: @code{type} shall be a complete
18949 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18951 @item __is_standard_layout (type)
18952 If @code{type} is a standard-layout type ([basic.types]) the trait is
18953 true, else it is false.  Requires: @code{type} shall be a complete
18954 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18956 @item __is_trivial (type)
18957 If @code{type} is a trivial type ([basic.types]) the trait is
18958 true, else it is false.  Requires: @code{type} shall be a complete
18959 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18961 @item __is_union (type)
18962 If @code{type} is a cv union type ([basic.compound]) the trait is
18963 true, else it is false.
18965 @item __underlying_type (type)
18966 The underlying type of @code{type}.  Requires: @code{type} shall be
18967 an enumeration type ([dcl.enum]).
18969 @end table
18971 @node Java Exceptions
18972 @section Java Exceptions
18974 The Java language uses a slightly different exception handling model
18975 from C++.  Normally, GNU C++ automatically detects when you are
18976 writing C++ code that uses Java exceptions, and handle them
18977 appropriately.  However, if C++ code only needs to execute destructors
18978 when Java exceptions are thrown through it, GCC guesses incorrectly.
18979 Sample problematic code is:
18981 @smallexample
18982   struct S @{ ~S(); @};
18983   extern void bar();    // @r{is written in Java, and may throw exceptions}
18984   void foo()
18985   @{
18986     S s;
18987     bar();
18988   @}
18989 @end smallexample
18991 @noindent
18992 The usual effect of an incorrect guess is a link failure, complaining of
18993 a missing routine called @samp{__gxx_personality_v0}.
18995 You can inform the compiler that Java exceptions are to be used in a
18996 translation unit, irrespective of what it might think, by writing
18997 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
18998 @samp{#pragma} must appear before any functions that throw or catch
18999 exceptions, or run destructors when exceptions are thrown through them.
19001 You cannot mix Java and C++ exceptions in the same translation unit.  It
19002 is believed to be safe to throw a C++ exception from one file through
19003 another file compiled for the Java exception model, or vice versa, but
19004 there may be bugs in this area.
19006 @node Deprecated Features
19007 @section Deprecated Features
19009 In the past, the GNU C++ compiler was extended to experiment with new
19010 features, at a time when the C++ language was still evolving.  Now that
19011 the C++ standard is complete, some of those features are superseded by
19012 superior alternatives.  Using the old features might cause a warning in
19013 some cases that the feature will be dropped in the future.  In other
19014 cases, the feature might be gone already.
19016 While the list below is not exhaustive, it documents some of the options
19017 that are now deprecated:
19019 @table @code
19020 @item -fexternal-templates
19021 @itemx -falt-external-templates
19022 These are two of the many ways for G++ to implement template
19023 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19024 defines how template definitions have to be organized across
19025 implementation units.  G++ has an implicit instantiation mechanism that
19026 should work just fine for standard-conforming code.
19028 @item -fstrict-prototype
19029 @itemx -fno-strict-prototype
19030 Previously it was possible to use an empty prototype parameter list to
19031 indicate an unspecified number of parameters (like C), rather than no
19032 parameters, as C++ demands.  This feature has been removed, except where
19033 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19034 @end table
19036 G++ allows a virtual function returning @samp{void *} to be overridden
19037 by one returning a different pointer type.  This extension to the
19038 covariant return type rules is now deprecated and will be removed from a
19039 future version.
19041 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19042 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19043 and are now removed from G++.  Code using these operators should be
19044 modified to use @code{std::min} and @code{std::max} instead.
19046 The named return value extension has been deprecated, and is now
19047 removed from G++.
19049 The use of initializer lists with new expressions has been deprecated,
19050 and is now removed from G++.
19052 Floating and complex non-type template parameters have been deprecated,
19053 and are now removed from G++.
19055 The implicit typename extension has been deprecated and is now
19056 removed from G++.
19058 The use of default arguments in function pointers, function typedefs
19059 and other places where they are not permitted by the standard is
19060 deprecated and will be removed from a future version of G++.
19062 G++ allows floating-point literals to appear in integral constant expressions,
19063 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19064 This extension is deprecated and will be removed from a future version.
19066 G++ allows static data members of const floating-point type to be declared
19067 with an initializer in a class definition. The standard only allows
19068 initializers for static members of const integral types and const
19069 enumeration types so this extension has been deprecated and will be removed
19070 from a future version.
19072 @node Backwards Compatibility
19073 @section Backwards Compatibility
19074 @cindex Backwards Compatibility
19075 @cindex ARM [Annotated C++ Reference Manual]
19077 Now that there is a definitive ISO standard C++, G++ has a specification
19078 to adhere to.  The C++ language evolved over time, and features that
19079 used to be acceptable in previous drafts of the standard, such as the ARM
19080 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19081 compilation of C++ written to such drafts, G++ contains some backwards
19082 compatibilities.  @emph{All such backwards compatibility features are
19083 liable to disappear in future versions of G++.} They should be considered
19084 deprecated.   @xref{Deprecated Features}.
19086 @table @code
19087 @item For scope
19088 If a variable is declared at for scope, it used to remain in scope until
19089 the end of the scope that contained the for statement (rather than just
19090 within the for scope).  G++ retains this, but issues a warning, if such a
19091 variable is accessed outside the for scope.
19093 @item Implicit C language
19094 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19095 scope to set the language.  On such systems, all header files are
19096 implicitly scoped inside a C language scope.  Also, an empty prototype
19097 @code{()} is treated as an unspecified number of arguments, rather
19098 than no arguments, as C++ demands.
19099 @end table
19101 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19102 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign